ersion="1.0" encoding="utf-8"?>
<!--
Microsoft (R) Windows (R) User Interface Command and Controls (UICC)
Copyright (c) Microsoft Corporation. All rights reserved.
-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
  
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="Button" mode="QATMenuItem">
    <xsl:call-template name="QatButtonType">
      <xsl:with-param name="id">
        <xsl:value-of select="@Tcid"/>
      </xsl:with-param>
      <xsl:with-param name="isVisible">
        <xsl:value-of select="@ApplicationDefaults.IsChecked"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="ToggleButton" mode="QATMenuItem">
    <xsl:call-template name="QatToggleButtonType">
      <xsl:with-param name="id">
        <xsl:value-of select="@Tcid"/>
      </xsl:with-param>
      <xsl:with-param name="isVisible">
        <xsl:value-of select="@ApplicationDefaults.IsChecked"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="CheckBox" mode="QATMenuItem">
    <xsl:call-template name="QatCheckBoxType">
      <xsl:with-param name="id">
        <xsl:value-of select="@Tcid"/>
      </xsl:with-param>
      <xsl:with-param name="isVisible">
        <xsl:value-of select="@ApplicationDefaults.IsChecked"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="Gallery" mode="QATMenuItem">
    <xsl:call-template name="QatGalleryType">
      <xsl:with-param name="id">
        <xsl:value-of select="@Tcid"/>
      </xsl:with-param>
      <xsl:with-param name="isVisible">
        <xsl:value-of select="@ApplicationDefaults.IsChecked"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="QuickAccessToolbar.ApplicationDefaults" mode="QATDefaults">
    <xsl:element name="Items">
      <xsl:apply-templates select="node()" mode="QATMenuItem"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "QuickAccessToolbar" >
    <xsl:element name="QAT">
      
      <xsl:apply-templates select="@Tcid"/>
      <xsl:apply-templates select="node()" mode="QATDefaults"/>
        
      
      <xsl:element name="Widgets">
        
        <xsl:element name="FlyoutAnchor">
          
          <xsl:attribute name="Tcid">65164</xsl:attribute>
          <xsl:attribute name="ShowLabel">false</xsl:attribute>
          <xsl:attribute name="NoAutoDisable">true</xsl:attribute>
          <xsl:element name="Items">
            
            <xsl:element name="MenuCategory">
              
              <xsl:attribute name="Tcid">65172</xsl:attribute>
              <xsl:attribute name="Class">StandardItems</xsl:attribute>
              <xsl:element name="Items">
                <xsl:element name="BooleanChoice">
                  
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">0</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">1</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">2</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">3</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">4</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">5</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">6</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">7</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">8</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">9</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">10</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">11</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">13</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">14</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">15</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">16</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">17</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">18</xsl:attribute>
                </xsl:element>
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65173</xsl:attribute>
                  <xsl:attribute name="Argument">19</xsl:attribute>
                </xsl:element>
              </xsl:element>
            </xsl:element>
            <xsl:element name="MenuCategory">
              <xsl:attribute name="Class">StandardItems</xsl:attribute>
              <xsl:element name="Items">
                
                <xsl:element name="ExecuteAction">
                  <xsl:attribute name="Tcid">65153</xsl:attribute>
                  <xsl:attribute name="Argument">0</xsl:attribute>
                </xsl:element>
                
                <xsl:element name="ExecuteAction">
                  <xsl:attribute name="Tcid">65152</xsl:attribute>
                  
                  <xsl:choose>
                    <xsl:when test="@CustomizeCommandName">
                      <xsl:attribute name="UserTcid">
                        <xsl:value-of select="@CustomizeCommandName" />
                      </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:attribute name="UserTcid">0</xsl:attribute>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:element>
              </xsl:element>
            </xsl:element>
            <xsl:element name="MenuCategory">
              <xsl:attribute name="Class">StandardItems</xsl:attribute>
              <xsl:element name="Items">
                
                <xsl:element name="BooleanChoice">
                  <xsl:attribute name="Tcid">65176</xsl:attribute>
                  <xsl:attribute name="IsCheckbox">true</xsl:attribute>
                </xsl:element>
              </xsl:element>
            </xsl:element>
          </xsl:element>
        </xsl:element>
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="ApplicationMenu" >
    <xsl:element name="File">
      <xsl:element name="FileMenuAnchor">
        
        <xsl:copy-of select="@*"/>
        <xsl:attribute name="NoAutoDisable">true</xsl:attribute>
        
        <xsl:attribute name="Argument">0</xsl:attribute>
        <xsl:element name="Items">
          
          <xsl:apply-templates select="MenuGroup"/>
        </xsl:element>
        
        <xsl:element name="MRUItems">
          <xsl:apply-templates select="ApplicationMenu.RecentItems" />
        </xsl:element>
        <xsl:element name="FooterItems" />
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="ApplicationMenu.RecentItems" >
    <xsl:copy-of select="node()" />
  </xsl:template>
  
  <xsl:template match = "Group" >
    <xsl:element name="Chunk">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "Button" >
    <xsl:element name="ExecuteAction">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template name = "QatButtonType" >
    <xsl:param name="id"/>
    <xsl:param name="isVisible"/>
    <xsl:element name="ExecuteAction">
      <xsl:attribute name="Tcid">
        <xsl:value-of select = "$id" />
      </xsl:attribute>
      <xsl:attribute name="IsVisible">
        <xsl:value-of select = "$isVisible" />
      </xsl:attribute>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "ToggleButton" >
    <xsl:element name="BooleanChoice">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template name = "QatToggleButtonType" >
    <xsl:param name="id"/>
    <xsl:param name="isVisible"/>
    <xsl:element name="BooleanChoice">
      <xsl:attribute name="Tcid">
        <xsl:value-of select = "$id" />
      </xsl:attribute>
      <xsl:attribute name="IsVisible">
        <xsl:value-of select = "$isVisible" />
      </xsl:attribute>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "CheckBox" >
    <xsl:element name="BooleanChoice">
      <xsl:attribute name="IsCheckbox">true</xsl:attribute>
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  
  <xsl:template name = "QatCheckBoxType" >
    <xsl:param name="id"/>
    <xsl:param name="isVisible"/>
    <xsl:element name="BooleanChoice">
      <xsl:attribute name="IsCheckbox">true</xsl:attribute>
      <xsl:attribute name="Tcid">
        <xsl:value-of select = "$id" />
      </xsl:attribute>
      <xsl:attribute name="IsVisible">
        <xsl:value-of select = "$isVisible" />
      </xsl:attribute>
    </xsl:element>
  </xsl:template>
  
  <xsl:template name = "QatGalleryType" >
    <xsl:param name="id"/>
    <xsl:param name="isVisible"/>
    <xsl:element name="Gallery">
      <xsl:attribute name="Tcid">
        <xsl:value-of select = "$id" />
      </xsl:attribute>
      <xsl:attribute name="IsVisible">
        <xsl:value-of select = "$isVisible" />
      </xsl:attribute>
      
      <xsl:apply-templates select="@*[name(.)!='ApplicationDefaults.IsChecked']|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "SplitButton" >
    <xsl:element name="ExecuteThisOrOtherAction">
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "SplitButton.ButtonItem" >
    <xsl:element name="ButtonItems">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "MenuGroup" >
    <xsl:element name="MenuCategory">
      <xsl:apply-templates select="@*"/>
      <xsl:element name="Items">
        
        <xsl:apply-templates select="node()"/>
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "Spinner" >
    <xsl:element name="EnterDecimal">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "DialogLauncher" >
    <xsl:element name="LauncherItem">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "FlyoutAnchor" >
    <xsl:element name="FlyoutAnchor">
      
      <xsl:apply-templates select="@*"/>
      <xsl:element name="Items">
        
        <xsl:apply-templates select="node()"/>
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "Ribbon" >
    <xsl:element name="Ribbon">
      <xsl:if test ="@GroupSpacing">
        <xsl:attribute name="ChunkSpacing">
          <xsl:value-of select = "@GroupSpacing" />
        </xsl:attribute>
      </xsl:if>
      <xsl:if test ="@Name">
        <xsl:attribute name="Name">
          <xsl:value-of select = "@Name" />
        </xsl:attribute>
      </xsl:if>
      
      <xsl:apply-templates select="node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "Ribbon.Tabs" >
    <xsl:element name="Tabs">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "ContextPopup" >
    <xsl:element name="ContextGroup">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "ControlGroup" >
    <xsl:element name="Group">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  
  <xsl:template match = "Ribbon.ContextualTabs" >
    <xsl:element name="ContextualTabs">
      
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "MiniToolbar" >
    <xsl:element name="MiniToolBar">
      
      <xsl:apply-templates select="@*"/>
      <xsl:element name="Items">
        
        <xsl:apply-templates select="node()"/>
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "TabGroup" >
    <xsl:element name="TabSet">
      
      <xsl:apply-templates select="@*"/>
      <xsl:element name="Items">
        
        <xsl:apply-templates select="node()"/>
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template name = "FontFaceGallery">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
        <Commands>
          <MenuCategory Class="StandardItems">
            <Items>
              
              <ExecuteAction Tcid="63900" />
            </Items>
          </MenuCategory>
        </Commands>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match = "Gallery" >
    <xsl:choose>
      
      <xsl:when test ="62000 &lt;= number(@Tcid) and number(@Tcid) &lt; 62100">
        <xsl:call-template name="FontFaceGallery"/>
      </xsl:when>
      
      <xsl:otherwise>
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template match = "ContextMap" >
    <xsl:element name="ContextualUI">
      
      <xsl:apply-templates select="@*"/>
      <xsl:if test="node()">
        <xsl:element name="Items">
          
          <xsl:apply-templates select="node()"/>
        </xsl:element>
      </xsl:if>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "ContextPopup.MiniToolbars|ContextPopup.ContextMaps|Application.Views|Ribbon.QuickAccessToolbar|Ribbon.HelpButton|SplitButton.MenuGroups|Ribbon.ApplicationMenu|Gallery.MenuGroups">
    
    <xsl:apply-templates select="node()"/>
  </xsl:template>
  
  <xsl:template match = "HelpButton" >
    <xsl:element name="MdiControls2">
      <xsl:element name="ExecuteAction">
        
        <xsl:apply-templates select="@*"/>
        <xsl:attribute name="Argument">0</xsl:attribute>
      </xsl:element>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="DynamicUI">
    <xsl:element name="DynamicUI">
      <xsl:choose>
        <xsl:when test="name(*[1])='Tab'">
          <xsl:element name="Tabs">
            <xsl:apply-templates select="node()" />
          </xsl:element>
        </xsl:when>
        <xsl:when test="name(*[1])='TabGroup'">
          <xsl:element name="ContextualTabs">
            <xsl:apply-templates select="node()" />
          </xsl:element>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select="node()" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<!--
Microsoft (R) Windows (R) User Interface Command and Controls (UICC)
Copyright (c) Microsoft Corporation. All rights reserved.
-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
  
  
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="@*" mode="GalleryAttributes">
    <xsl:choose>
      <xsl:when test="name(current())='MaxColumns'">
        <xsl:attribute name="InRibbonItemsWidth">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="name(current())='MaxRows'">
        <xsl:attribute name="InRibbonItemsHeight">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="name(current())='MinColumnsLarge'">
        <xsl:attribute name="InRibbonMinItemsLarge">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="name(current())='MaxColumnsMedium'">
        <xsl:attribute name="InRibbonMaxItemsMedium">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="name(current())='MinColumnsMedium'">
        <xsl:attribute name="InRibbonMinItemsMedium">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="name(current())='HasLargeItems'">
        <xsl:attribute name="IsLargeItems">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        
        <xsl:copy>
          <xsl:apply-templates select="@*"/>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="*" mode="GalleryMenuLayout">
    <xsl:param name="LayoutForFlowMenuLayout"/>
    <xsl:param name="OverrideColumnsForFlowMenuLayout"/>
    <xsl:param name="ColumnsForFlowMenuLayout"/>
    
    <xsl:attribute name="ItemsHeight">
      <xsl:value-of select = "@Rows" />
    </xsl:attribute>
    
    <xsl:attribute name="ResizeType">
      <xsl:choose>
        <xsl:when test="@Gripper='Vertical'">VerticalResize</xsl:when>
        <xsl:when test="@Gripper='Corner'">CornerResize</xsl:when>
        <xsl:when test="@Gripper='None'">NoResize</xsl:when>
      </xsl:choose>
    </xsl:attribute>
    
    <xsl:choose>
      <xsl:when test="name(current())='VerticalMenuLayout'">
        
        <xsl:attribute name="ItemsWidth">1</xsl:attribute>
        <xsl:attribute name="Layout">Vertical</xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="$OverrideColumnsForFlowMenuLayout='false'">
            <xsl:attribute name="ItemsWidth">
              <xsl:value-of select="@Columns" />
            </xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:choose>
              <xsl:when test="$ColumnsForFlowMenuLayout">
                
                <xsl:attribute name="ItemsWidth">
                  <xsl:value-of select="$ColumnsForFlowMenuLayout" />
                </xsl:attribute>
              </xsl:when>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:attribute name="Layout">
          <xsl:value-of select="$LayoutForFlowMenuLayout"/>
        </xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
    
    <xsl:choose>
      <xsl:when test="ancestor::node()[name()='SplitButtonGallery' or name()='DropDownGallery']/@Type='Items' and name(current())='VerticalMenuLayout' and @IsMultipleHighlightingEnabled='true'">
        <xsl:attribute name="IsMultipleHighlightingEnabled">true</xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="IsMultipleHighlightingEnabled">false</xsl:attribute>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template match="*" mode="GalleryWithMenuLayout">
    <xsl:param name="MenuLayoutName"/>
    <xsl:param name="LayoutForFlowMenuLayout"/>
    <xsl:param name="OverrideColumnsForFlowMenuLayout"/>
    <xsl:param name="ColumnsForFlowMenuLayout"/>
    <xsl:choose>
      <xsl:when test="name(current())=$MenuLayoutName">
        <xsl:apply-templates select="node()" mode="GalleryMenuLayout">
          <xsl:with-param name="LayoutForFlowMenuLayout" select="$LayoutForFlowMenuLayout"/>
          <xsl:with-param name="OverrideColumnsForFlowMenuLayout" select="$OverrideColumnsForFlowMenuLayout"/>
          <xsl:with-param name="ColumnsForFlowMenuLayout" select="$ColumnsForFlowMenuLayout"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:otherwise>
        
        <xsl:apply-templates select="current()"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="DefaultGalleryMenuLayout">
    
    <xsl:param name="LayoutForFlowMenuLayout"/>
    <xsl:attribute name="Layout">
      <xsl:value-of select="$LayoutForFlowMenuLayout"/>
    </xsl:attribute>
    <xsl:attribute name="ItemsWidth">2</xsl:attribute>
    <xsl:attribute name="ItemsHeight">-1</xsl:attribute>
    <xsl:attribute name="ResizeType">CornerResize</xsl:attribute>
    
    <xsl:apply-templates select="*"/>
  </xsl:template>
  
  <xsl:template match = "ComboBox" >
    <xsl:element name="ComboBox">
      
      <xsl:if test="ancestor::node()[name()='Ribbon.QuickAccessToolbar']">
          <xsl:attribute name="ShowLabel">false</xsl:attribute>
          <xsl:attribute name="ShowImage">false</xsl:attribute>
      </xsl:if>
      
      <xsl:apply-templates select="@*"/>
    </xsl:element>
  </xsl:template>
      
  <xsl:template match = "InRibbonGallery" >
    <xsl:element name="Gallery">
      <xsl:choose>
        
        <xsl:when test="ancestor::node()[name()='Ribbon.QuickAccessToolbar']">
          <xsl:attribute name="Anchor">DropButton</xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="Anchor">NoAnchor</xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:attribute name="IsLivePreviewEnabled">true</xsl:attribute>
      
      <xsl:apply-templates select="@*" mode="GalleryAttributes"/>
      
      <xsl:choose>
        <xsl:when test="InRibbonGallery.MenuLayout">
          <xsl:apply-templates select="*" mode="GalleryWithMenuLayout">
            <xsl:with-param name="MenuLayoutName">InRibbonGallery.MenuLayout</xsl:with-param>
            <xsl:with-param name="LayoutForFlowMenuLayout">Horizontal</xsl:with-param>
            
            <xsl:with-param name="OverrideColumnsForFlowMenuLayout">true</xsl:with-param>
            <xsl:with-param name="ColumnsForFlowMenuLayout" select="@MaxColumns"/>
          </xsl:apply-templates>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="DefaultGalleryMenuLayout">
            <xsl:with-param name="LayoutForFlowMenuLayout">Horizontal</xsl:with-param>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "DropDownGallery" >
    <xsl:element name="Gallery">
      <xsl:attribute name="Anchor">DropButton</xsl:attribute>
      <xsl:attribute name="IsLivePreviewEnabled">true</xsl:attribute>
      <xsl:choose>
        <xsl:when test="ancestor::node()[name()='Ribbon.ApplicationMenu']">
          <xsl:attribute name="Type">Commands</xsl:attribute>
          <xsl:attribute name="ResizeType">NoResize</xsl:attribute>
          <xsl:attribute name="ItemsWidth">1</xsl:attribute>
          <xsl:attribute name="Layout">Vertical</xsl:attribute>
          <xsl:attribute name="IsLargeItems">true</xsl:attribute>
          <xsl:attribute name="TextPosition">Right</xsl:attribute>
          <xsl:attribute name="ItemWidth">-1</xsl:attribute>
          <xsl:attribute name="ItemHeight">-1</xsl:attribute>
          <xsl:apply-templates select="@*"/>
        </xsl:when>
        <xsl:otherwise>
          
          <xsl:apply-templates select="@*" mode="GalleryAttributes"/>
          
          <xsl:choose>
            <xsl:when test="DropDownGallery.MenuLayout">
              <xsl:apply-templates select="*" mode="GalleryWithMenuLayout">
                <xsl:with-param name="MenuLayoutName">DropDownGallery.MenuLayout</xsl:with-param>
                <xsl:with-param name="LayoutForFlowMenuLayout">Grid</xsl:with-param>
                <xsl:with-param name="OverrideColumnsForFlowMenuLayout">false</xsl:with-param>
              </xsl:apply-templates>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="DefaultGalleryMenuLayout">
                <xsl:with-param name="LayoutForFlowMenuLayout">Grid</xsl:with-param>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "SplitButtonGallery" >
    <xsl:element name="Gallery">
      <xsl:attribute name="Anchor">SplitButton</xsl:attribute>
      <xsl:attribute name="IsLivePreviewEnabled">true</xsl:attribute>
      <xsl:choose>
        <xsl:when test="ancestor::node()[name()='Ribbon.ApplicationMenu']">
          <xsl:attribute name="Type">Commands</xsl:attribute>
          <xsl:attribute name="ResizeType">NoResize</xsl:attribute>
          <xsl:attribute name="ItemsWidth">1</xsl:attribute>
          <xsl:attribute name="Layout">Vertical</xsl:attribute>
          <xsl:attribute name="IsLargeItems">true</xsl:attribute>
          <xsl:attribute name="TextPosition">Right</xsl:attribute>
          <xsl:attribute name="ItemWidth">-1</xsl:attribute>
          <xsl:attribute name="ItemHeight">-1</xsl:attribute>
          <xsl:apply-templates select="@*"/>
        </xsl:when>
        <xsl:otherwise>
          
          <xsl:apply-templates select="@*" mode="GalleryAttributes"/>
          
          <xsl:choose>
            <xsl:when test="SplitButtonGallery.MenuLayout">
              <xsl:apply-templates select="*" mode="GalleryWithMenuLayout">
                <xsl:with-param name="MenuLayoutName">SplitButtonGallery.MenuLayout</xsl:with-param>
                <xsl:with-param name="LayoutForFlowMenuLayout">Grid</xsl:with-param>
                <xsl:with-param name="OverrideColumnsForFlowMenuLayout">false</xsl:with-param>
              </xsl:apply-templates>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="DefaultGalleryMenuLayout">
                <xsl:with-param name="LayoutForFlowMenuLayout">Grid</xsl:with-param>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:element>
  </xsl:template>
  
  
  <xsl:template match="@*" mode="DropDownColorPickerAttributes">
    <xsl:choose>
      <xsl:when test="name(current())='IsAutomaticColorButtonVisible'">
        <xsl:attribute name="AutomaticColorButtonVisible">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:when test="name(current())='IsNoColorButtonVisible'">
        <xsl:attribute name="NoColorButtonVisible">
          <xsl:value-of select = "current()" />
        </xsl:attribute>
      </xsl:when>
      <xsl:otherwise>
        
        <xsl:copy>
          <xsl:apply-templates select="@*"/>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match = "DropDownColorPicker" >
    <xsl:element name="Gallery">
      <xsl:attribute name="Anchor">SplitButton</xsl:attribute>
      <xsl:attribute name="Layout">Vertical</xsl:attribute>
      <xsl:attribute name="Type">DropDownColorPicker</xsl:attribute>
      <xsl:attribute name="IsLivePreviewEnabled">true</xsl:attribute>
      
      <xsl:apply-templates select="@*" mode="DropDownColorPickerAttributes"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "InRibbonColorPicker" >
    <xsl:element name="Gallery">
      <xsl:attribute name="Anchor">NoAnchor</xsl:attribute>
      <xsl:attribute name="IsLivePreviewEnabled">true</xsl:attribute>
      <xsl:attribute name="Type">InRibbonColorPicker</xsl:attribute>
      
      <xsl:copy-of select="@*"/>
      <xsl:call-template name="DefaultGalleryMenuLayout">
        <xsl:with-param name="LayoutForFlowMenuLayout">Horizontal</xsl:with-param>
      </xsl:call-template>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "InRibbonGallery.MenuGroups|DropDownGallery.MenuGroups|SplitButtonGallery.MenuGroups">
    <xsl:element name="Gallery.MenuGroups">
      
      <xsl:apply-templates select="node()"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match = "DropDownButton" >
    <xsl:element name="FlyoutAnchor">
      
      <xsl:apply-templates select="@*"/>
      <xsl:choose>
        <xsl:when test="name(node())!='MenuGroup'">
          <xsl:element name="MenuGroup">
            <xsl:attribute name="Class">StandardItems</xsl:attribute>
            
            <xsl:apply-templates select="node()"/>
          </xsl:element>
        </xsl:when>
        <xsl:otherwise>
          
          <xsl:apply-templates select="node()"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
