diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-13 21:49:04 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-13 22:49:20 -0400 |
commit | 5063f31c248fd3c16115582a1e3aef182257a225 (patch) | |
tree | d5760bcdc81eb2dcfe22444dd7a9362912a25e24 /sc/source | |
parent | 12ae7672f285da1d4c730315e8db23b3396b71cc (diff) |
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...
Change-Id: Ia585f53d547af3d6840fce1b1244b60bb5076b07
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/excel/excdoc.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 24 | ||||
-rw-r--r-- | sc/source/filter/inc/excrecds.hxx | 24 |
3 files changed, 36 insertions, 15 deletions
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 9cf433d50c78..87b17aa871e4 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 4c9485035656..b7e6df7b153c 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) != 0 ), - 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 796e624d87d3..90a2a12fa58c 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,15 +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 |