diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf140336_paraNoneShading.odt | bin | 0 -> 10529 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/attributeoutputbase.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 21 |
6 files changed, 34 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf140336_paraNoneShading.odt b/sw/qa/extras/ooxmlexport/data/tdf140336_paraNoneShading.odt Binary files differnew file mode 100644 index 000000000000..c4bd80f1a65c --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf140336_paraNoneShading.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index ac46467b87f7..bda5911c1b16 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -15,6 +15,7 @@ #include <svx/svdobj.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> @@ -140,6 +141,17 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf135773_numberingShading, "tdf135774_n assertXPath(pXmlStyles, "/w:numbering/w:abstractNum[@w:abstractNumId='1']/w:lvl[@w:ilvl='0']/w:rPr/w:shd", "fill", "ED4C05"); } +DECLARE_OOXMLEXPORT_TEST(testTdf140336_paraNoneShading, "tdf140336_paraNoneShading.odt") +{ + // Before the fix, the background from a style was exported to dis-inheriting paragraphs/styles. + CPPUNIT_ASSERT_EQUAL(sal_uInt32(COL_AUTO), getProperty<sal_uInt32>(getParagraph(1), "ParaBackColor")); + uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("CanclledBackground"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xStyle, "FillStyle")); + + // sanity check: backgroundColor paragraph style has a golden color(FF7F50), which para2 inherits + CPPUNIT_ASSERT_EQUAL(sal_uInt32(16744272), getProperty<sal_uInt32>(getParagraph(2), "ParaBackColor")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf141173_missingFrames, "tdf141173_missingFrames.rtf") { // Without the fix in place, almost all of the text and textboxes were missing. diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index e102b3f7012b..cea47b8e3c60 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -666,7 +666,7 @@ public: ( ww8::WW8TableNodeInfoInner const * pTableTextNodeInfoInner, tools::Long& rPageSize, bool& rRelBoxSize ); - virtual void MaybeOutputBrushItem(SfxItemSet const&) { } + virtual bool MaybeOutputBrushItem(SfxItemSet const&) { return false; } /// 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 f4688e5f6a01..7e67ffda5590 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6308,14 +6308,14 @@ oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML() return m_rDrawingML; } -void DocxAttributeOutput::MaybeOutputBrushItem(SfxItemSet const& rSet) +bool 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; + return false; } // sw text frames are opaque by default, even with fill none! @@ -6327,6 +6327,7 @@ void DocxAttributeOutput::MaybeOutputBrushItem(SfxItemSet const& rSet) pClone->Put(aSolid); std::unique_ptr<SvxBrushItem> const pBrush(getSvxBrushItemFromSourceSet(*pClone, RES_BACKGROUND)); FormatBackground(*pBrush); + return true; } namespace { diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 565741bd0afe..7a2826e81ea9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -1031,7 +1031,7 @@ public: virtual css::uno::Reference<css::text::XTextFrame> GetUnoTextFrame( css::uno::Reference<css::drawing::XShape> xShape) override; virtual oox::drawingml::DrawingML& GetDrawingML() override; - virtual void MaybeOutputBrushItem(SfxItemSet const&) override; + virtual bool 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 5d3f4b8ae0d2..95b7bab8034b 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -352,7 +352,7 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b ExportPoolItemsToCHP(aItems, nScript, nullptr); if ( bPapFormat ) { - AttrOutput().MaybeOutputBrushItem(rSet); + const bool bAlreadyOutputBrushItem = AttrOutput().MaybeOutputBrushItem(rSet); for ( const auto& rItem : aItems ) { @@ -365,12 +365,25 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b } // Has to be called after RES_PARATR_GRABBAG is processed. - const XFillStyleItem* pXFillStyleItem(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE)); - if (pXFillStyleItem && pXFillStyleItem->GetValue() == drawing::FillStyle_SOLID && !rSet.HasItem(RES_BACKGROUND)) + const XFillStyleItem* pFill(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE, false)); + if (!bAlreadyOutputBrushItem && pFill + && (pFill->GetValue() == drawing::FillStyle_SOLID || pFill->GetValue() == drawing::FillStyle_NONE) + && !rSet.GetItem(RES_BACKGROUND, false)) { + const bool bFillStyleNone = pFill->GetValue() == drawing::FillStyle_NONE; + // No need to write out a NONE background if it can't inherit something else, or if it already inherits a NONE. + std::unique_ptr<SvxBrushItem> pInherited; + if (bFillStyleNone) + { + if ( auto pNd = dynamic_cast<const SwContentNode*>(m_pOutFormatNode)) //paragraph + pInherited = getSvxBrushItemFromSourceSet(static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet(), RES_BACKGROUND); + else if (m_bStyDef && m_pCurrentStyle && m_pCurrentStyle->DerivedFrom()) //style + pInherited = getSvxBrushItemFromSourceSet(m_pCurrentStyle->DerivedFrom()->GetAttrSet(), RES_BACKGROUND); + } // Construct an SvxBrushItem, as expected by the exporters. std::unique_ptr<SvxBrushItem> aBrush(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND)); - AttrOutput().OutputItem(*aBrush); + if (!bFillStyleNone || (pInherited && *pInherited != *aBrush)) + AttrOutput().OutputItem(*aBrush); } #if 0 else |