[Libreoffice-commits] core.git: sw/qa sw/source

Adam Co rattles2013 at gmail.com
Mon Jun 3 01:00:07 PDT 2013


 sw/qa/extras/ooxmlexport/data/page-background.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx           |    9 +++++++
 sw/source/filter/ww8/docxexport.cxx                |   25 +++++++++++++++++++++
 3 files changed, 34 insertions(+)

New commits:
commit 515701a1ff18d04ede235bef862c465adf41062f
Author: Adam Co <rattles2013 at gmail.com>
Date:   Sun Jun 2 11:21:18 2013 +0300

    fdo#65257 : DOCX not exporting background color
    
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>
    
    Conflicts:
    	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    
    Change-Id: Ida3f66d5adb063400494e1da589a463b4d7c2a86

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 0000000..8c1f2ebd
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/page-background.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 3ed2f18..278d71c 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 0ceacc05..dd280dc 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 );
 


More information about the Libreoffice-commits mailing list