summaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-06-03 10:25:05 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-06-03 10:25:59 +0200
commit89935d18826ada54abceb8148fad8731be2571f5 (patch)
tree0d8a0c160ce3bd029d3c28fe32f6f0a998e16d16 /sw
parentFixing crash with dereferencing front() and back() of an empty vector (diff)
downloadcore-89935d18826ada54abceb8148fad8731be2571f5.tar.gz
core-89935d18826ada54abceb8148fad8731be2571f5.zip
Introduce DocxExport::getBackground()
Does the same as part of DocxExport::WriteMainText() and DocxExport::WriteSettings(). Change-Id: I5597edc2c3a84bd2058ee8c4cfdc21241e471bd3
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxexport.cxx28
-rw-r--r--sw/source/filter/ww8/docxexport.hxx4
2 files changed, 22 insertions, 10 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index dd280dcbad65..0afa634ab5ce 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 2348349f5c79..c7a2b2888c3e 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.