summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2024-02-13 13:58:08 -0500
committerMiklos Vajna <vmiklos@collabora.com>2024-02-26 08:55:59 +0100
commitaca1125350e68d94906074fc075b079d4460ae7f (patch)
tree32d93e54830df8b4baf67ca09fc6326a8dd91057 /sw
parent2c97f30c6aeaddfb9942a1906f182a7704fbf093 (diff)
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 of 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 <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163866 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport21.cxx3
-rw-r--r--sw/source/filter/ww8/docxexport.cxx21
2 files changed, 22 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
index d4bc37d5f700..b9b04eafb0f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -73,10 +73,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 a4c06ab5ac5b..e84bbc48eb20 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);
}