diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 27 |
2 files changed, 26 insertions, 5 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ca24b6420e5e..732a938c8094 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -818,6 +818,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf89791, "tdf89791.docx") uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess->hasByName("docProps/custom.xml"))); } + + //tdf#102619 - setting FollowStyle with a not-yet-created style was failing. (Titre is created before Corps de texte). + uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("Titre"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Corps de texte"), getProperty<OUString>(properties, "FollowStyle")); } DECLARE_OOXMLEXPORT_TEST(testTdf91261, "tdf91261.docx") diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 383ac0d5a0f9..14c2348fb0d5 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -903,6 +903,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) if(xCharStyles.is() && xParaStyles.is()) { std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingParent; + std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingFollow; std::vector<beans::PropertyValue> aTableStylesVec; std::vector< StyleSheetEntryPtr >::iterator aIt = m_pImpl->m_aStyleSheetEntries.begin(); while( aIt != m_pImpl->m_aStyleSheetEntries.end() ) @@ -1133,10 +1134,16 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) { if (!(*it)->sStyleName.isEmpty() && (*it)->sStyleIdentifierD == pEntry->sNextStyleIdentifier) { - beans::PropertyValue aNew; - aNew.Name = "FollowStyle"; - aNew.Value <<= ConvertStyleName((*it)->sStyleName); - aSortedPropVals.Insert(aNew); + const OUString sFollowStyle = ConvertStyleName((*it)->sStyleName); + if ( !xStyles->hasByName( sFollowStyle ) ) + aMissingFollow.emplace_back( sFollowStyle, xStyle ); + else + { + beans::PropertyValue aNew; + aNew.Name = "FollowStyle"; + aNew.Value <<= sFollowStyle; + aSortedPropVals.Insert(aNew); + } break; } } @@ -1210,12 +1217,22 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) ++aIt; } - // Update the styles that were created before their parents + // Update the styles that were created before their parents or next-styles for( auto const & iter : aMissingParent ) { iter.second->setParentStyle( iter.first ); } + for( auto const & iter : aMissingFollow ) + { + try + { + uno::Reference<beans::XPropertySet> xPropertySet(iter.second, uno::UNO_QUERY); + xPropertySet->setPropertyValue( "FollowStyle", uno::makeAny(iter.first) ); + } + catch( uno::Exception & ) {} + } + if (!aTableStylesVec.empty()) { // If we had any table styles, add a new document-level InteropGrabBag entry for them. |