summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Co <rattles2013@gmail.com>2013-06-02 11:21:18 +0300
committerMiklos Vajna <vmiklos@suse.cz>2013-06-03 09:59:33 +0200
commit515701a1ff18d04ede235bef862c465adf41062f (patch)
tree5dbd04938563bea4d002762c28d7eaa481dc6db5
parent1fadebef054b811d8d6487d45d76dea1990e1268 (diff)
fdo#65257 : DOCX not exporting background color
Signed-off-by: Miklos Vajna <vmiklos@suse.cz> Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Change-Id: Ida3f66d5adb063400494e1da589a463b4d7c2a86
-rw-r--r--sw/qa/extras/ooxmlexport/data/page-background.docxbin0 -> 10041 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx9
-rw-r--r--sw/source/filter/ww8/docxexport.cxx25
3 files changed, 34 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/page-background.docx b/sw/qa/extras/ooxmlexport/data/page-background.docx
new file mode 100644
index 000000000000..8c1f2ebdb239
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/page-background.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 3ed2f188b175..278d71c33f88 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -70,6 +70,7 @@ public:
void testFdo48557();
void testI120928();
void testFdo64826();
+ void testPageBackground();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -118,6 +119,7 @@ void Test::run()
{"fdo48557.odt", &Test::testFdo48557},
{"i120928.docx", &Test::testI120928},
{"fdo64826.docx", &Test::testFdo64826},
+ {"page-background.docx", &Test::testPageBackground},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -680,6 +682,13 @@ void Test::testFdo64826()
CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(mxComponent, "RecordChanges")));
}
+void Test::testPageBackground()
+{
+ // 'Document Background' wasn't exported.
+ uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 0ceacc05b15d..dd280dcbad65 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -44,6 +44,7 @@
#include <frmfmt.hxx>
#include <section.hxx>
#include <ftninfo.hxx>
+#include <pagedesc.hxx>
#include <editeng/editobj.hxx>
#include <editeng/outlobj.hxx>
@@ -690,6 +691,16 @@ void DocxExport::WriteSettings()
OString aZoom(OString::valueOf(sal_Int32(pViewShell->GetViewOptions()->GetZoom())));
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)
+ {
+ // Turn on the 'displayBackgroundShape'
+ pFS->singleElementNS( XML_w, XML_displayBackgroundShape, FSEND );
+ }
+
// Track Changes
if ( settings.trackRevisions )
pFS->singleElementNS( XML_w, XML_trackRevisions, FSEND );
@@ -732,6 +743,20 @@ void DocxExport::WriteMainText()
// setup the namespaces
m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces( m_pDocumentFS ));
+ // Write background page color
+ 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();
+ OString aBackgroundColorStr = msfilter::util::ConvertColor(backgroundColor);
+
+ m_pDocumentFS->singleElementNS( XML_w, XML_background, FSNS( XML_w, XML_color ), aBackgroundColorStr, FSEND );
+ }
+
// body
m_pDocumentFS->startElementNS( XML_w, XML_body, FSEND );