sw/qa/extras/ooxmlexport/ooxmlexport21.cxx |    3 +--
 sw/source/filter/ww8/docxexport.cxx        |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit f3efd1dc397e2801a30e705120a21a4e384596ec
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Feb 13 13:58:08 2024 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Feb 23 10:56:07 2024 +0100

    tdf#126533 DOCX: export page vml fill gradient
    
    Simplistic export of gradient fill.
    
    I just used the existing docxattribute stuff that textboxes
    use to export their background as VML fallback.
    
    Note that docxattribute only knows how to export gradient,
    not gradientRadial. (Done in follow-up patch.)
    
    Lots of stuff is missing in terms properly supporting gradients.
    But likely fixing page background will fix
    the same problem in textboxes etc.
    
    Given how incredibly different LO and MSO are in terms of gradients,
    it makes sense to commit this change and at least get the basics
    wired in.
    
    make CppunitTest_sw_ooxmlexport21 \
        CPPUNIT_TEST_NAME=testTdf126533_pageGradient
    
    Change-Id: I2ac14fdef2fe29609bc8d5a5d8f65b3f0da71889
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163469
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index 224f8f2aa27d..d2bd3440a90b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -377,10 +377,9 @@ DECLARE_OOXMLEXPORT_TEST(testTdf126533_noPageBitmap, 
"tdf126533_noPageBitmap.doc
                          getProperty<drawing::FillStyle>(xPageStyle, 
"FillStyle"));
 }
 
-CPPUNIT_TEST_FIXTURE(Test, testTdf126533_pageGradient)
+DECLARE_OOXMLEXPORT_TEST(testTdf126533_pageGradient, "fill.docx")
 {
     // given a document with a gradient page background
-    loadFromFile(u"fill.docx");
     uno::Reference<beans::XPropertySet> 
xPageStyle(getStyles("PageStyles")->getByName("Standard"),
                                                    uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,
diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index 466fe652d5dd..787c90e32b12 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -55,6 +55,7 @@
 #include <oox/ole/olehelper.hxx>
 
 #include <svx/svdpage.hxx>
+#include <svx/xfillit0.hxx>
 #include <svx/xflbmtit.hxx>
 
 #include <map>
@@ -1916,6 +1917,7 @@ void DocxExport::WriteMainText()
                                       
msfilter::util::ConvertColor(oBrush->GetColor()));
 
         const SwAttrSet& rPageStyleAttrSet = 
m_rDoc.GetPageDesc(0).GetMaster().GetAttrSet();
+        const drawing::FillStyle eFillType = 
rPageStyleAttrSet.Get(XATTR_FILLSTYLE).GetValue();
         const GraphicObject* pGraphicObj = oBrush->GetGraphicObject();
         if (pGraphicObj) // image/pattern/texture
         {
@@ -1934,6 +1936,25 @@ void DocxExport::WriteMainText()
                 m_pDocumentFS->endElementNS(XML_v, XML_background);
             }
         }
+        else if (eFillType == drawing::FillStyle_GRADIENT)
+        {
+            SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> 
aSet(m_rDoc.GetAttrPool());
+            aSet.Set(rPageStyleAttrSet);
+
+            // Collect all of the gradient attributes into SdrExporter() 
AttrLists
+            m_pAttrOutput->OutputStyleItemSet(aSet, /*TestForDefault=*/true);
+            assert(SdrExporter().getFlyAttrList().is() && "type and fillcolor 
are always provided");
+            assert(SdrExporter().getFlyFillAttrList().is() && "color2 is 
always provided");
+
+            rtl::Reference<FastAttributeList> 
xFlyAttrList(SdrExporter().getFlyAttrList());
+            rtl::Reference<FastAttributeList> 
xFillAttrList(SdrExporter().getFlyFillAttrList());
+            m_pDocumentFS->startElementNS(XML_v, XML_background, xFlyAttrList);
+            m_pDocumentFS->singleElementNS(XML_v, XML_fill, xFillAttrList);
+            m_pDocumentFS->endElementNS(XML_v, XML_background);
+
+            SdrExporter().getFlyAttrList().clear();
+            SdrExporter().getFlyFillAttrList().clear();
+        }
 
         m_pDocumentFS->endElementNS(XML_w, XML_background);
     }

Reply via email to