sw/source/filter/ww8/docxexport.cxx | 28 ++++++++++++++++++---------- sw/source/filter/ww8/docxexport.hxx | 4 ++++ 2 files changed, 22 insertions(+), 10 deletions(-)
New commits: commit 89935d18826ada54abceb8148fad8731be2571f5 Author: Miklos Vajna <vmik...@suse.cz> Date: Mon Jun 3 10:25:05 2013 +0200 Introduce DocxExport::getBackground() Does the same as part of DocxExport::WriteMainText() and DocxExport::WriteSettings(). Change-Id: I5597edc2c3a84bd2058ee8c4cfdc21241e471bd3 diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index dd280dc..0afa634 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -692,10 +692,7 @@ void DocxExport::WriteSettings() pFS->singleElementNS(XML_w, XML_zoom, FSNS(XML_w, XML_percent), aZoom.getStr(), FSEND); // Display Background Shape - const SwFrmFmt &rFmt = pDoc->GetPageDesc(0).GetMaster(); - const SfxPoolItem* pItem = 0; - SfxItemState eState = rFmt.GetItemState(RES_BACKGROUND, true, &pItem); - if (SFX_ITEM_SET == eState && pItem) + if (boost::optional<const SvxBrushItem*> oBrush = getBackground()) { // Turn on the 'displayBackgroundShape' pFS->singleElementNS( XML_w, XML_displayBackgroundShape, FSEND ); @@ -738,20 +735,31 @@ VMLExport& DocxExport::VMLExporter() return *m_pVMLExport; } -void DocxExport::WriteMainText() +boost::optional<const SvxBrushItem*> DocxExport::getBackground() { - // setup the namespaces - m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces( m_pDocumentFS )); - - // Write background page color + boost::optional<const SvxBrushItem*> oRet; const SwFrmFmt &rFmt = pDoc->GetPageDesc(0).GetMaster(); const SfxPoolItem* pItem = 0; SfxItemState eState = rFmt.GetItemState(RES_BACKGROUND, true, &pItem); + if (SFX_ITEM_SET == eState && pItem) { // The 'color' is set for the first page style - take it and use it as the background color of the entire DOCX const SvxBrushItem* pBrush = (const SvxBrushItem*)pItem; - Color backgroundColor = pBrush->GetColor(); + oRet.reset(pBrush); + } + return oRet; +} + +void DocxExport::WriteMainText() +{ + // setup the namespaces + m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces( m_pDocumentFS )); + + // Write background page color + if (boost::optional<const SvxBrushItem*> oBrush = getBackground()) + { + Color backgroundColor = (*oBrush)->GetColor(); OString aBackgroundColorStr = msfilter::util::ConvertColor(backgroundColor); m_pDocumentFS->singleElementNS( XML_w, XML_background, FSNS( XML_w, XML_color ), aBackgroundColorStr, FSEND ); diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 2348349..c7a2b28 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -28,6 +28,7 @@ #include <cstdio> #include <vector> +#include <boost/optional.hpp> class DocxAttributeOutput; class DocxExportFilter; @@ -206,6 +207,9 @@ private: /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...) sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer ); + /// Get background color of the document, if there is one. + boost::optional<const SvxBrushItem*> getBackground(); + public: /// FIXME this is temporary, remotely reminding the method of the same /// name in WW8Export. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits