diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/theme-preservation.docx | bin | 14739 -> 14798 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 53 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/CellColorHandler.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/dmapper/CellColorHandler.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.cxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.hxx | 1 |
9 files changed, 77 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/theme-preservation.docx b/sw/qa/extras/ooxmlexport/data/theme-preservation.docx Binary files differindex ff7c5700c965..778e10646ed3 100644 --- a/sw/qa/extras/ooxmlexport/data/theme-preservation.docx +++ b/sw/qa/extras/ooxmlexport/data/theme-preservation.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index fce454751a76..11d962aa97f0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2092,6 +2092,9 @@ DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx") getProperty<OUString>(getRun(getParagraph(4, "Direct format font"), 1), "CharFontName")); CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"), getProperty<OUString>(getParagraph(5, "Major theme font"), "CharFontName")); + + // check the paragraph background theme color has been preserved + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFill", "text2"); } DECLARE_OOXMLEXPORT_TEST(testcantSplit, "2_table_doc.docx") diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 7daf7888fddc..29a6cd45b84d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -694,6 +694,14 @@ void DocxAttributeOutput::WriteCollectedParagraphProperties() m_pSerializer->singleElementNS( XML_w, XML_spacing, xAttrList ); } + + if ( m_pBackgroundAttrList ) + { + XFastAttributeListRef xAttrList( m_pBackgroundAttrList ); + m_pBackgroundAttrList = NULL; + + m_pSerializer->singleElementNS( XML_w, XML_shd, xAttrList ); + } } void DocxAttributeOutput::EndParagraphProperties( const SwRedlineData* pRedlineData, const SwRedlineData* pRedlineParagraphMarkerDeleted, const SwRedlineData* pRedlineParagraphMarkerInserted ) @@ -5769,10 +5777,24 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) } else if ( !m_rExport.bOutPageDescs ) { - m_pSerializer->singleElementNS( XML_w, XML_shd, - FSNS( XML_w, XML_fill ), sColor.getStr( ), - FSNS( XML_w, XML_val ), "clear", - FSEND ); + if( !m_pBackgroundAttrList ) + m_pBackgroundAttrList = m_pSerializer->createAttrList(); + + // compare fill color with the original fill color + OString sOriginalFill = rtl::OUStringToOString( + m_pBackgroundAttrList->getOptionalValue( FSNS( XML_w, XML_fill ) ), RTL_TEXTENCODING_UTF8 ); + if( sOriginalFill.isEmpty() ) + { + m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() ); + } + else if ( sOriginalFill != sColor ) + { + // fill was modified during edition, theme fill attribute must be dropped + delete m_pBackgroundAttrList; + m_pBackgroundAttrList = m_pSerializer->createAttrList(); + m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() ); + } + m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" ); } } @@ -6109,6 +6131,27 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem) m_nParaAfterSpacing = MM100_TO_TWIP(m_nParaAfterSpacing); SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: property =" << i->first << " : m_nParaBeforeSpacing= " << m_nParaAfterSpacing); } + else if (i->first == "CharThemeFill") + { + uno::Sequence<beans::PropertyValue> aGrabBagSeq; + i->second >>= aGrabBagSeq; + OUString sThemeFill, sOriginalFill; + for (sal_Int32 j=0; j < aGrabBagSeq.getLength(); ++j) + { + if (aGrabBagSeq[j].Name == "themeFill") + aGrabBagSeq[j].Value >>= sThemeFill; + else if (aGrabBagSeq[j].Name == "fill") + aGrabBagSeq[j].Value >>= sOriginalFill; + } + + if (!m_pBackgroundAttrList) + m_pBackgroundAttrList = m_pSerializer->createAttrList(); + + m_pBackgroundAttrList->add(FSNS(XML_w, XML_themeFill), + OUStringToOString(sThemeFill, RTL_TEXTENCODING_UTF8)); + m_pBackgroundAttrList->add(FSNS(XML_w, XML_fill), + OUStringToOString(sOriginalFill, RTL_TEXTENCODING_UTF8)); + } else SAL_INFO("sw.ww8", "DocxAttributeOutput::ParaGrabBag: unhandled grab bag property " << i->first ); } @@ -6236,6 +6279,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_pFlyWrapAttrList( NULL ), m_pTextboxAttrList( NULL ), m_pColorAttrList( NULL ), + m_pBackgroundAttrList( NULL ), m_pFlyFrameSize(0), m_pFootnotesList( new ::docx::FootnotesList() ), m_pEndnotesList( new ::docx::FootnotesList() ), @@ -6293,6 +6337,7 @@ DocxAttributeOutput::~DocxAttributeOutput() delete m_pBodyPrAttrList, m_pBodyPrAttrList = NULL; delete m_pTextboxAttrList, m_pTextboxAttrList = NULL; delete m_pColorAttrList, m_pColorAttrList = NULL; + delete m_pBackgroundAttrList, m_pBackgroundAttrList = NULL; delete m_pFootnotesList, m_pFootnotesList = NULL; delete m_pEndnotesList, m_pEndnotesList = NULL; diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 62ec9f4b7c05..a2a39772cfea 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -686,6 +686,8 @@ private: ::sax_fastparser::FastAttributeList *m_pTextboxAttrList; /// Attributes of the run color ::sax_fastparser::FastAttributeList *m_pColorAttrList; + /// Attributes of the paragraph background + ::sax_fastparser::FastAttributeList *m_pBackgroundAttrList; /// When exporting fly frames, this holds the real size of the frame. const Size* m_pFlyFrameSize; diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx index da8c9cb75bdc..4204b5b6c2e7 100644 --- a/writerfilter/source/dmapper/CellColorHandler.cxx +++ b/writerfilter/source/dmapper/CellColorHandler.cxx @@ -359,6 +359,17 @@ beans::PropertyValue CellColorHandler::getInteropGrabBag() return aRet; } +void CellColorHandler::disableInteropGrabBag() +{ + m_aInteropGrabBagName = ""; + m_aInteropGrabBag.clear(); +} + +sal_Bool CellColorHandler::isInteropGrabBagEnabled() +{ + return !(m_aInteropGrabBagName.isEmpty()); +} + } //namespace dmapper } //namespace writerfilter diff --git a/writerfilter/source/dmapper/CellColorHandler.hxx b/writerfilter/source/dmapper/CellColorHandler.hxx index 7904a9deccdf..e3e1c0b59a7f 100644 --- a/writerfilter/source/dmapper/CellColorHandler.hxx +++ b/writerfilter/source/dmapper/CellColorHandler.hxx @@ -58,6 +58,8 @@ public: void enableInteropGrabBag(OUString aName); beans::PropertyValue getInteropGrabBag(); + void disableInteropGrabBag(); + sal_Bool isInteropGrabBagEnabled(); }; typedef boost::shared_ptr< CellColorHandler > CellColorHandlerPtr; }} diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index bc5d2bf2aedb..5e151e6e8843 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1961,8 +1961,16 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType { CellColorHandlerPtr pCellColorHandler( new CellColorHandler ); pCellColorHandler->setOutputFormat( CellColorHandler::Paragraph ); + sal_Bool bEnableTempGrabBag = !pCellColorHandler->isInteropGrabBagEnabled(); + if( bEnableTempGrabBag ) + pCellColorHandler->enableInteropGrabBag( "TempShdPropsGrabBag" ); + pProperties->resolve(*pCellColorHandler); rContext->InsertProps(pCellColorHandler->getProperties()); + + rContext->Insert(PROP_CHAR_THEME_FILL, pCellColorHandler->getInteropGrabBag().Value, true, PARA_GRAB_BAG); + if(bEnableTempGrabBag) + pCellColorHandler->disableInteropGrabBag(); } } break; diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index a0c9dc48d5c7..a05249a5c6a3 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -358,6 +358,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_CHAR_THEME_COLOR : sName = "CharThemeColor"; break; case PROP_CHAR_THEME_ORIGINAL_COLOR : sName = "CharThemeOriginalColor"; break; case PROP_CHAR_THEME_COLOR_SHADE : sName = "CharThemeColorShade"; break; + case PROP_CHAR_THEME_FILL : sName = "CharThemeFill"; break; } ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt = m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName )); diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index e9ad035c6d3f..ae3e02a4c7b8 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -329,6 +329,7 @@ enum PropertyIds ,PROP_CHAR_THEME_COLOR ,PROP_CHAR_THEME_ORIGINAL_COLOR ,PROP_CHAR_THEME_COLOR_SHADE + ,PROP_CHAR_THEME_FILL }; struct PropertyNameSupplier_Impl; class PropertyNameSupplier |