sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 4 +++ writerfilter/source/dmapper/StyleSheetTable.cxx | 27 +++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)
New commits: commit 39a4f21fc4a16f7c57a9b6f1ddd5ce2953781576 Author: Justin Luth <justin_l...@sil.org> Date: Fri Jul 6 15:19:26 2018 +0300 tdf#102619 writerfilter: first create style, then set FollowStyle Styles were having FollowStyle set to themselves (Heading 1), not to a defined follow (Text body). The style was being created with a FollowStyle property that identified a style which had not yet been created. So svl code was warning "svl.items", "StyleSheet-Follow not found" This section of code should really be cleaned up, but that will happen in a separate commit. Change-Id: Iae79fac917f64cdaa14ca6568e7d903ec6dc60fa Reviewed-on: https://gerrit.libreoffice.org/57074 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> 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. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits