diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-08-26 17:08:00 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-08-26 20:44:07 +0200 |
commit | d84e590486e2c26212931de80a84181d7aca7bbe (patch) | |
tree | b0e1448db85e72ba5e480ca9ab3fa0573e048821 /sw/source/filter | |
parent | 8280491bec32fea5bbdad23f000538d000ed2f24 (diff) |
sw: DOCX export: don't export text frames as transparent
Writer paints text frames without fill still as opaque but nothing is
written in the DOCX file and Word by default treats DrawingML text frame
as transparent (the VML fallback is opaque though).
Change-Id: I0ce539ac8084c5047b4732abc5c199589ee369ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101411
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/attributeoutputbase.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 24 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 9 |
4 files changed, 36 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index d8b851da17d7..89865c7de7f5 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -668,6 +668,8 @@ public: ( ww8::WW8TableNodeInfoInner const * pTableTextNodeInfoInner, long& rPageSize, bool& rRelBoxSize ); + virtual void MaybeOutputBrushItem(SfxItemSet const&) { } + /// Exports the definition (image, size) of a single numbering picture bullet. virtual void BulletDefinition(int /*nId*/, const Graphic& /*rGraphic*/, Size /*aSize*/) {} diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 83527d26c470..6e39cf528ed0 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -89,8 +89,10 @@ #include <editeng/editobj.hxx> #include <editeng/keepitem.hxx> #include <svx/xfillit0.hxx> +#include <svx/xflclit.hxx> #include <svx/xflgrit.hxx> #include <svx/svdouno.hxx> +#include <svx/unobrushitemhelper.hxx> #include <svl/grabbagitem.hxx> #include <sfx2/sfxbasemodel.hxx> #include <tools/datetimeutils.hxx> @@ -6003,6 +6005,27 @@ oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML() return m_rDrawingML; } +void DocxAttributeOutput::MaybeOutputBrushItem(SfxItemSet const& rSet) +{ + const XFillStyleItem* pXFillStyleItem(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE)); + + if ((pXFillStyleItem && pXFillStyleItem->GetValue() != drawing::FillStyle_NONE) + || !m_rExport.SdrExporter().getDMLTextFrameSyntax()) + { + return; + } + + // sw text frames are opaque by default, even with fill none! + std::unique_ptr<SfxItemSet> const pClone(rSet.Clone()); + XFillColorItem const aColor(OUString(), COL_WHITE); + pClone->Put(aColor); + // call getSvxBrushItemForSolid - this also takes XFillTransparenceItem into account + XFillStyleItem const aSolid(drawing::FillStyle_SOLID); + pClone->Put(aSolid); + std::unique_ptr<SvxBrushItem> const pBrush(getSvxBrushItemFromSourceSet(*pClone, RES_BACKGROUND)); + FormatBackground(*pBrush); +} + namespace { /// Functor to do case-insensitive ordering of OUString instances. @@ -8843,6 +8866,7 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) { if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { + // ugh, exporting fill here is quite some hack... this OutputItemSet abstraction is quite leaky // <a:gradFill> should be before <a:ln>. const SfxPoolItem* pItem = GetExport().HasItem(XATTR_FILLSTYLE); if (pItem) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 83e3110734ba..471992eed57f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -1018,6 +1018,7 @@ public: virtual OUString FindRelId(BitmapChecksum nChecksum) override; virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) override; virtual oox::drawingml::DrawingML& GetDrawingML() override; + virtual void MaybeOutputBrushItem(SfxItemSet const&) override; void BulletDefinition(int nId, const Graphic& rGraphic, Size aSize) override; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index c4f5734b8833..74fea5ab0688 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -332,6 +332,8 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b ExportPoolItemsToCHP(aItems, nScript, nullptr); if ( bPapFormat ) { + AttrOutput().MaybeOutputBrushItem(rSet); + for ( const auto& rItem : aItems ) { pItem = rItem.second; @@ -350,6 +352,13 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b std::unique_ptr<SvxBrushItem> aBrush(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND)); AttrOutput().OutputItem(*aBrush); } +#if 0 + else + { + // note: *does not work* due to undocumented Word behavior: must be before a:ln element at least + AttrOutput().MaybeOutputBrushItem(rSet); + } +#endif } m_pISet = nullptr; // for double attributes } |