diff options
-rw-r--r-- | filter/source/xslt/export/spreadsheetml/formular.xsl | 6 | ||||
-rw-r--r-- | filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl | 180 | ||||
-rw-r--r-- | filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl | 215 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 | ||||
-rw-r--r-- | oox/source/xls/worksheethelper.cxx | 2 | ||||
-rw-r--r-- | oox/source/xls/worksheetsettings.cxx | 14 |
6 files changed, 412 insertions, 6 deletions
diff --git a/filter/source/xslt/export/spreadsheetml/formular.xsl b/filter/source/xslt/export/spreadsheetml/formular.xsl index 3acb4f393c42..8134412ec8d9 100644 --- a/filter/source/xslt/export/spreadsheetml/formular.xsl +++ b/filter/source/xslt/export/spreadsheetml/formular.xsl @@ -377,7 +377,7 @@ </xsl:when> <xsl:otherwise> <xsl:value-of select="$earlierCandidate" /> - <xsl:variable name="parameterCandidate"> + <xsl:variable name="parameterCandidate2"> <xsl:variable name="formularAfterCandidate" select="substring-after($expressionSuffix, $earlierCandidate)" /> <xsl:variable name="parameterTillBracket" select="concat(substring-before($formularAfterCandidate,')'),')')" /> <xsl:variable name="parameterTillComma" select="substring-before(substring-after($expressionSuffix, $parameterTillBracket),',')" /> @@ -401,8 +401,8 @@ <xsl:call-template name="getParameter"> <xsl:with-param name="closingBracketCount" select="$closingBracketCount" /> <xsl:with-param name="openingBracketCount" select="$openingBracketCount" /> - <xsl:with-param name="parameterCandidate" select="$parameterCandidate" /> - <xsl:with-param name="earlierCandidate" select="$parameterCandidate" /> + <xsl:with-param name="parameterCandidate" select="$parameterCandidate2" /> + <xsl:with-param name="earlierCandidate" select="$parameterCandidate2" /> <xsl:with-param name="expressionSuffix" select="$expressionSuffix" /> </xsl:call-template> </xsl:otherwise> diff --git a/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl b/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl index 027f732d2f2a..420d06474a3a 100644 --- a/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl +++ b/filter/source/xslt/export/spreadsheetml/ooo2spreadsheetml.xsl @@ -141,6 +141,17 @@ <RGB><xsl:value-of select="." /></RGB> </Color> </xsl:for-each> + <xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]"> + <xsl:sort select="." /> + <Color> + <Index><xsl:value-of select="56 - position()" /></Index> + <RGB> + <xsl:call-template name="colordecimal2rgb"> + <xsl:with-param name="colordecimal" select="."/> + </xsl:call-template> + </RGB> + </Color> + </xsl:for-each> </Colors> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> @@ -171,6 +182,160 @@ </Workbook> </xsl:template> + <xsl:template name="colordecimal2rgb"> + <xsl:param name="colordecimal"/> + <xsl:choose> + <xsl:when test="$colordecimal <= 16777215 and $colordecimal >= 65536"> + <xsl:variable name="redValue" select="floor(($colordecimal) div 65536)"/> + <xsl:variable name="greenValue" select="floor(($colordecimal - ($redValue*65536)) div 256)"/> + <xsl:variable name="blueValue" select="$colordecimal - ($redValue*65536) - ($greenValue*256)"/> + <xsl:call-template name="dec_rgb2Hex"> + <xsl:with-param name="decRedValue" select="$redValue"/> + <xsl:with-param name="decGreenValue" select="$greenValue"/> + <xsl:with-param name="decBlueValue" select="$blueValue"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$colordecimal <= 65535 and $colordecimal >= 256"> + <xsl:variable name="redValue" select="0"/> + <xsl:variable name="greenValue" select="$colordecimal div 256"/> + <xsl:variable name="blueValue" select="$colordecimal - ($greenValue*256)"/> + <xsl:call-template name="dec_rgb2Hex"> + <xsl:with-param name="decRedValue" select="$redValue"/> + <xsl:with-param name="decGreenValue" select="$greenValue"/> + <xsl:with-param name="decBlueValue" select="$blueValue"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$colordecimal <= 255 and $colordecimal >= 0"> + <xsl:variable name="redValue" select="0"/> + <xsl:variable name="greenValue" select="0"/> + <xsl:variable name="blueValue" select="$colordecimal"/> + <xsl:call-template name="dec_rgb2Hex"> + <xsl:with-param name="decRedValue" select="$redValue"/> + <xsl:with-param name="decGreenValue" select="$greenValue"/> + <xsl:with-param name="decBlueValue" select="$blueValue"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise/> + </xsl:choose> + </xsl:template> + <xsl:template name="dec_rgb2Hex"> + <xsl:param name="decRedValue"/> + <xsl:param name="decGreenValue"/> + <xsl:param name="decBlueValue"/> + <xsl:variable name="hexRedValue"> + <xsl:variable name="tmpHexRedValue"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$decRedValue"/> + <xsl:with-param name="last-value" select="'H'"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($tmpHexRedValue) = 1"> + <xsl:value-of select="concat('0',$tmpHexRedValue)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$tmpHexRedValue"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="hexGreenValue"> + <xsl:variable name="tmpHexGreenValue"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$decGreenValue"/> + <xsl:with-param name="last-value" select="'H'"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($tmpHexGreenValue) = 1"> + <xsl:value-of select="concat('0',$tmpHexGreenValue)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$tmpHexGreenValue"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="hexBlueValue"> + <xsl:variable name="tmpHexBlueValue"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$decBlueValue"/> + <xsl:with-param name="last-value" select="'H'"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($tmpHexBlueValue) = 1"> + <xsl:value-of select="concat('0',$tmpHexBlueValue)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$tmpHexBlueValue"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:value-of select="concat('#',$hexRedValue,$hexGreenValue,$hexBlueValue)"/> + </xsl:template> + <xsl:template name="decimal2hex"> + <!-- transforms a decimal number to a hex number,only for two-bit hex(less than 256 in decimal) currently --> + <xsl:param name="dec-number"/> + <xsl:param name="last-value"/> + <xsl:variable name="current-value"> + <xsl:call-template name="decNumber2hex"> + <xsl:with-param name="dec-value"> + <xsl:if test="$dec-number > 15"> + <xsl:value-of select="floor($dec-number div 16)"/> + </xsl:if> + <xsl:if test="$dec-number < 16"> + <xsl:value-of select="$dec-number"/> + </xsl:if> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + <xsl:if test="$dec-number > 15"> + <xsl:call-template name="decimal2hex"> + <xsl:with-param name="dec-number" select="$dec-number mod 16"/> + <xsl:with-param name="last-value" select="concat($last-value,$current-value)"/> + </xsl:call-template> + </xsl:if> + <xsl:if test="$dec-number < 16"> + <xsl:value-of select="substring-after(concat($last-value,$current-value),'H')"/> + </xsl:if> + </xsl:template> + + <xsl:template name="decNumber2hex"> + <!-- return a hex number for a decimal character --> + <xsl:param name="dec-value"/> + <xsl:choose> + <xsl:when test="$dec-value = 10"> + <xsl:value-of select="'A'"/> + </xsl:when> + <xsl:when test="$dec-value = 11"> + <xsl:value-of select="'B'"/> + </xsl:when> + <xsl:when test="$dec-value = 12"> + <xsl:value-of select="'C'"/> + </xsl:when> + <xsl:when test="$dec-value = 13"> + <xsl:value-of select="'D'"/> + </xsl:when> + <xsl:when test="$dec-value = 14"> + <xsl:value-of select="'E'"/> + </xsl:when> + <xsl:when test="$dec-value = 15"> + <xsl:value-of select="'F'"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$dec-value"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template name="GetTabColorIndex"> + <xsl:param name="SheetColor"/> + <xsl:for-each select="key('config', 'TabColor')[not(.=preceding::config:config-item)]"> + <xsl:sort select="." /> + <xsl:variable name="tmpColor" select="."/> + <xsl:if test=". = $SheetColor" > + <xsl:value-of select="56 - position()"/> + </xsl:if> + </xsl:for-each> + </xsl:template> <xsl:template match="office:body"> <!-- office:body table:table children are spreadsheets --> <xsl:apply-templates /> @@ -183,8 +348,11 @@ <!-- office:body table:table children are spreadsheets --> <xsl:template match="office:spreadsheet/table:table"> <xsl:element name="ss:Worksheet"> - <xsl:attribute name="ss:Name"> + <xsl:variable name="TableName"> <xsl:value-of select="@table:name" /> + </xsl:variable> + <xsl:attribute name="ss:Name"> + <xsl:value-of select="$TableName" /> </xsl:attribute> <xsl:call-template name="table:table" /> <xsl:element name="x:WorksheetOptions"> @@ -200,6 +368,16 @@ <xsl:if test="key('config', 'ShowZeroValues') = 'false'"> <xsl:element name="x:DoNotDisplayZeros" /> </xsl:if> + <xsl:if test="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item-map-named/config:config-item-map-entry[@config:name=$TableName]/config:config-item[@config:name='TabColor']"> + <xsl:element name="x:TabColorIndex"> + <xsl:variable name="TabColorIndex"> + <xsl:call-template name="GetTabColorIndex"> + <xsl:with-param name="SheetColor" select="/*/office:settings/config:config-item-set/config:config-item-map-indexed/config:config-item-map-entry/config:config-item-map-named/config:config-item-map-entry[@config:name=$TableName]/config:config-item[@config:name='TabColor']"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$TabColorIndex"/> + </xsl:element> + </xsl:if> </xsl:element> </xsl:element> </xsl:template> diff --git a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl index 64ac1302b744..71f1baa492d0 100644 --- a/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl +++ b/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl @@ -381,6 +381,16 @@ </xsl:otherwise> </xsl:choose> <xsl:copy-of select="$sharedConfiguration"/> + <xsl:if test="x:WorksheetOptions/x:TabColorIndex"> + <config:config-item config:name="TabColor" config:type="int"> + <xsl:variable name="temp-value"> + <xsl:call-template name="colorindex2decimal"> + <xsl:with-param name="colorindex" select="x:WorksheetOptions/x:TabColorIndex"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$temp-value"/> + </config:config-item> + </xsl:if> </config:config-item-map-entry> </xsl:for-each> </config:config-item-map-named> @@ -4637,6 +4647,211 @@ </xsl:variable> <xsl:value-of select="concat('#',$R-value,$G-value,$B-value)"/> </xsl:template> + <xsl:template name="colorindex2decimal"> + <xsl:param name="colorindex"/> + <xsl:variable name="colorIndexLookup"> + <xsl:value-of select="$colorindex - 8"/> + </xsl:variable> + <xsl:variable name="tempColorValue"> + <xsl:choose> + <!-- Grab the color from the custom color index if it exists... --> + <xsl:when test="/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:Index=$colorIndexLookup"> + <xsl:value-of select="substring-after(normalize-space(/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:RGB[/ss:Workbook/o:OfficeDocumentSettings/o:Colors/o:Color/o:Index=$colorIndexLookup]), '#')"/> + </xsl:when > + <xsl:otherwise> + <xsl:choose> + <xsl:when test="$colorindex=8"> + <xsl:value-of select="'000000'"/> + </xsl:when> + <xsl:when test="$colorindex=9"> + <xsl:value-of select="'FFFFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=10"> + <xsl:value-of select="'FF0000'"/> + </xsl:when> + <xsl:when test="$colorindex=11"> + <xsl:value-of select="'00FF00'"/> + </xsl:when> + <xsl:when test="$colorindex=12"> + <xsl:value-of select="'0000FF'"/> + </xsl:when> + <xsl:when test="$colorindex=13"> + <xsl:value-of select="'FFFF00'"/> + </xsl:when> + <xsl:when test="$colorindex=14"> + <xsl:value-of select="'FF00FF'"/> + </xsl:when> + <xsl:when test="$colorindex=15"> + <xsl:value-of select="'00FFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=16"> + <xsl:value-of select="'800000'"/> + </xsl:when> + <xsl:when test="$colorindex=17"> + <xsl:value-of select="'008000'"/> + </xsl:when> + <xsl:when test="$colorindex=18"> + <xsl:value-of select="'000080'"/> + </xsl:when> + <xsl:when test="$colorindex=19"> + <xsl:value-of select="'808000'"/> + </xsl:when> + <xsl:when test="$colorindex=20"> + <xsl:value-of select="'800080'"/> + </xsl:when> + <xsl:when test="$colorindex=21"> + <xsl:value-of select="'008080'"/> + </xsl:when> + <xsl:when test="$colorindex=22"> + <xsl:value-of select="'C0C0C0'"/> + </xsl:when> + <xsl:when test="$colorindex=23"> + <xsl:value-of select="'808080'"/> + </xsl:when> + <xsl:when test="$colorindex=24"> + <xsl:value-of select="'9999FF'"/> + </xsl:when> + <xsl:when test="$colorindex=25"> + <xsl:value-of select="'993366'"/> + </xsl:when> + <xsl:when test="$colorindex=26"> + <xsl:value-of select="'FFFFCC'"/> + </xsl:when> + <xsl:when test="$colorindex=27"> + <xsl:value-of select="'CCFFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=28"> + <xsl:value-of select="'660066'"/> + </xsl:when> + <xsl:when test="$colorindex=29"> + <xsl:value-of select="'FF8080'"/> + </xsl:when> + <xsl:when test="$colorindex=30"> + <xsl:value-of select="'0066CC'"/> + </xsl:when> + <xsl:when test="$colorindex=31"> + <xsl:value-of select="'CCCCFF'"/> + </xsl:when> + <xsl:when test="$colorindex=32"> + <xsl:value-of select="'000080'"/> + </xsl:when> + <xsl:when test="$colorindex=33"> + <xsl:value-of select="'FF00FF'"/> + </xsl:when> + <xsl:when test="$colorindex=34"> + <xsl:value-of select="'FFFF00'"/> + </xsl:when> + <xsl:when test="$colorindex=35"> + <xsl:value-of select="'00FFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=36"> + <xsl:value-of select="'800080'"/> + </xsl:when> + <xsl:when test="$colorindex=37"> + <xsl:value-of select="'800000'"/> + </xsl:when> + <xsl:when test="$colorindex=38"> + <xsl:value-of select="'008080'"/> + </xsl:when> + <xsl:when test="$colorindex=39"> + <xsl:value-of select="'0000FF'"/> + </xsl:when> + <xsl:when test="$colorindex=40"> + <xsl:value-of select="'00CCFF'"/> + </xsl:when> + <xsl:when test="$colorindex=41"> + <xsl:value-of select="'CCFFFF'"/> + </xsl:when> + <xsl:when test="$colorindex=42"> + <xsl:value-of select="'CCFFCC'"/> + </xsl:when> + <xsl:when test="$colorindex=43"> + <xsl:value-of select="'FFFF99'"/> + </xsl:when> + <xsl:when test="$colorindex=44"> + <xsl:value-of select="'99CCFF'"/> + </xsl:when> + <xsl:when test="$colorindex=45"> + <xsl:value-of select="'FF99CC'"/> + </xsl:when> + <xsl:when test="$colorindex=46"> + <xsl:value-of select="'CC99FF'"/> + </xsl:when> + <xsl:when test="$colorindex=47"> + <xsl:value-of select="'FFCC99'"/> + </xsl:when> + <xsl:when test="$colorindex=48"> + <xsl:value-of select="'3366FF'"/> + </xsl:when> + <xsl:when test="$colorindex=49"> + <xsl:value-of select="'33CCCC'"/> + </xsl:when> + <xsl:when test="$colorindex=50"> + <xsl:value-of select="'99CC00'"/> + </xsl:when> + <xsl:when test="$colorindex=51"> + <xsl:value-of select="'FFCC00'"/> + </xsl:when> + <xsl:when test="$colorindex=52"> + <xsl:value-of select="'FF9900'"/> + </xsl:when> + <xsl:when test="$colorindex=53"> + <xsl:value-of select="'FF6600'"/> + </xsl:when> + <xsl:when test="$colorindex=54"> + <xsl:value-of select="'666699'"/> + </xsl:when> + <xsl:when test="$colorindex=55"> + <xsl:value-of select="'969696'"/> + </xsl:when> + <xsl:when test="$colorindex=56"> + <xsl:value-of select="'003366'"/> + </xsl:when> + <xsl:when test="$colorindex=57"> + <xsl:value-of select="'339966'"/> + </xsl:when> + <xsl:when test="$colorindex=58"> + <xsl:value-of select="'003300'"/> + </xsl:when> + <xsl:when test="$colorindex=59"> + <xsl:value-of select="'333300'"/> + </xsl:when> + <xsl:when test="$colorindex=60"> + <xsl:value-of select="'993300'"/> + </xsl:when> + <xsl:when test="$colorindex=61"> + <xsl:value-of select="'993366'"/> + </xsl:when> + <xsl:when test="$colorindex=62"> + <xsl:value-of select="'333399'"/> + </xsl:when> + <xsl:when test="$colorindex=63"> + <xsl:value-of select="'333333'"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="'NOTFOUND'"/> + </xsl:otherwise> + </xsl:choose> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="tempColorDecimal"> + <xsl:choose> + <xsl:when test="not($tempColorValue = 'NOTFOUND')"> + <xsl:call-template name="hex2decimal"> + <xsl:with-param name="hex-number" select="$tempColorValue"/> + <xsl:with-param name="index" select="1"/> + <xsl:with-param name="str-length" select="6"/> + <xsl:with-param name="last-value" select="0"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="4294967295"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:value-of select="$tempColorDecimal"/> + </xsl:template> <xsl:template name="hex2decimal"> <!-- transforms a hex number to a decimal number.parses the string from left to right --> <xsl:param name="hex-number"/> diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index a0f0021d710a..38fa2fc2c02b 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -396,6 +396,7 @@ Suffix SwapXAndYAxis Symbol SymbolColor +TabColor TabIndex TableBorder TableLayout diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx index 381def644ce5..efce7f2f385c 100644 --- a/oox/source/xls/worksheethelper.cxx +++ b/oox/source/xls/worksheethelper.cxx @@ -994,6 +994,8 @@ void WorksheetData::finalizeWorksheetImport() maCondFormats.finalizeImport(); maPageSett.finalizeImport(); maSheetViewSett.finalizeImport(); + maSheetSett.finalizeImport(); + lclUpdateProgressBar( mxFinalProgress, 0.5 ); convertColumns(); convertRows(); diff --git a/oox/source/xls/worksheetsettings.cxx b/oox/source/xls/worksheetsettings.cxx index 6a42c38e1647..0cc9d5f17780 100644 --- a/oox/source/xls/worksheetsettings.cxx +++ b/oox/source/xls/worksheetsettings.cxx @@ -26,15 +26,19 @@ ************************************************************************/ #include "oox/xls/worksheetsettings.hxx" -#include <com/sun/star/util/XProtectable.hpp> -#include "properties.hxx" #include "oox/helper/attributelist.hxx" #include "oox/helper/recordinputstream.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/pagesettings.hxx" #include "oox/xls/workbooksettings.hxx" +#include "oox/core/filterbase.hxx" +#include "properties.hxx" + +#include <com/sun/star/util/XProtectable.hpp> using ::rtl::OUString; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::UNO_QUERY_THROW; @@ -319,6 +323,12 @@ void WorksheetSettings::finalizeImport() // VBA code name PropertySet aPropSet( getSheet() ); aPropSet.setProperty( PROP_CodeName, maSheetSettings.maCodeName ); + + if (!maSheetSettings.maTabColor.isAuto()) + { + sal_Int32 nColor = maSheetSettings.maTabColor.getColor(getBaseFilter().getGraphicHelper()); + aPropSet.setProperty(PROP_TabColor, nColor); + } } // ============================================================================ |