[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Mar 14 00:38:40 PDT 2014


 sc/source/filter/excel/excdoc.cxx   |    3 ++-
 sc/source/filter/excel/excrecds.cxx |   24 ++++++++++++++++--------
 sc/source/filter/inc/excrecds.hxx   |   25 ++++++++++++++++++-------
 3 files changed, 36 insertions(+), 16 deletions(-)

New commits:
commit 00b7d4c8043a0c6b9e267f0fd5d7389128628ca0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Mar 13 21:49:04 2014 -0400

    fdo#58307: Export sheet tab colors to xlsx.
    
    And let's not re-use Biff's XclExpWsbool record class to export <SheetPr>
    elements.  That was a bit hacky...
    
    (cherry picked from commit 5063f31c248fd3c16115582a1e3aef182257a225)
    
    Conflicts:
    	sc/source/filter/excel/excrecds.cxx
    	sc/source/filter/inc/excrecds.hxx
    
    Change-Id: Ia585f53d547af3d6840fce1b1244b60bb5076b07
    Reviewed-on: https://gerrit.libreoffice.org/8583
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 9cf433d..87b17aa 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -550,7 +550,8 @@ void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx )
 
     Add( new ExcBof8 );
 
-    Add( new XclExpWsbool( bFitToPages, mnScTab, &GetFilterManager() ) );
+    Color aTabColor = GetRoot().GetDoc().GetTabBgColor(mnScTab);
+    Add(new XclExpXmlSheetPr(bFitToPages, mnScTab, aTabColor, &GetFilterManager()));
 
     // GUTS (count & size of outline icons)
     aRecList.AppendRecord( mxCellTable->CreateRecord( EXC_ID_GUTS ) );
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index 9be9bfe..614a70a 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -442,16 +442,17 @@ void XclExpCountry::WriteBody( XclExpStream& rStrm )
 
 // XclExpWsbool ===============================================================
 
-XclExpWsbool::XclExpWsbool( bool bFitToPages, SCTAB nScTab, XclExpFilterManager* pManager )
+XclExpWsbool::XclExpWsbool( bool bFitToPages )
     : XclExpUInt16Record( EXC_ID_WSBOOL, EXC_WSBOOL_DEFAULTFLAGS )
-    , mnScTab( nScTab )
-    , mpManager( pManager )
 {
     if( bFitToPages )
         SetValue( GetValue() | EXC_WSBOOL_FITTOPAGE );
 }
 
-void XclExpWsbool::SaveXml( XclExpXmlStream& rStrm )
+XclExpXmlSheetPr::XclExpXmlSheetPr( bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager ) :
+    mnScTab(nScTab), mpManager(pManager), mbFitToPage(bFitToPages), maTabColor(rTabColor) {}
+
+void XclExpXmlSheetPr::SaveXml( XclExpXmlStream& rStrm )
 {
     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
     rWorksheet->startElement( XML_sheetPr,
@@ -465,11 +466,18 @@ void XclExpWsbool::SaveXml( XclExpXmlStream& rStrm )
             XML_filterMode, mpManager ? XclXmlUtils::ToPsz( mpManager->HasFilterMode( mnScTab ) ) : NULL,
             // OOXTODO: XML_enableFormatConditionsCalculation,
             FSEND );
-    // OOXTODO: elements XML_tabColor, XML_outlinePr
-    rWorksheet->singleElement( XML_pageSetUpPr,
+
+    // Note : the order of child elements is significant. Don't change the order.
+
+    // OOXTODO: XML_outlinePr
+
+    rWorksheet->singleElement(
+        XML_tabColor, XML_rgb, XclXmlUtils::ToOString(maTabColor).getStr(), FSEND);
+
+    rWorksheet->singleElement(XML_pageSetUpPr,
             // OOXTODO: XML_autoPageBreaks,
-            XML_fitToPage,  XclXmlUtils::ToPsz( GetValue() & EXC_WSBOOL_FITTOPAGE ),
-            FSEND );
+        XML_fitToPage,  XclXmlUtils::ToPsz(mbFitToPage), FSEND);
+
     rWorksheet->endElement( XML_sheetPr );
 }
 
diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx
index 0a6b7be..b4a3ba9 100644
--- a/sc/source/filter/inc/excrecds.hxx
+++ b/sc/source/filter/inc/excrecds.hxx
@@ -24,6 +24,7 @@
 #include <rtl/ustring.hxx>
 #include <svl/zforlist.hxx>
 #include <tools/solar.h>
+#include <tools/color.hxx>
 #include <vcl/vclenum.hxx>
 
 
@@ -325,16 +326,26 @@ private:
 class XclExpWsbool : public XclExpUInt16Record
 {
 public:
-    explicit                    XclExpWsbool( bool bFitToPages, SCTAB nScTab = -1, XclExpFilterManager* pManager = NULL );
-
-    virtual void                SaveXml( XclExpXmlStream& rStrm );
-private:
-    SCTAB                       mnScTab;
-    XclExpFilterManager*        mpManager;
+    explicit XclExpWsbool( bool bFitToPages );
 };
 
+/**
+ * Save sheetPr element and its children for xlsx export.
+ */
+class XclExpXmlSheetPr : public XclExpRecordBase
+{
+public:
+    explicit XclExpXmlSheetPr(
+        bool bFitToPages, SCTAB nScTab, const Color& rTabColor, XclExpFilterManager* pManager );
+
+    virtual void SaveXml( XclExpXmlStream& rStrm );
 
-// ============================================================================
+private:
+    SCTAB mnScTab;
+    XclExpFilterManager* mpManager;
+    bool mbFitToPage;
+    Color maTabColor;
+};
 
 class XclExpFiltermode : public XclExpEmptyRecord
 {


More information about the Libreoffice-commits mailing list