Kaydet (Commit) 89935d18 authored tarafından Miklos Vajna's avatar Miklos Vajna

Introduce DocxExport::getBackground()

Does the same as part of DocxExport::WriteMainText() and
DocxExport::WriteSettings().

Change-Id: I5597edc2c3a84bd2058ee8c4cfdc21241e471bd3
üst f5d6e7af
......@@ -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 );
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment