diff options
author | Justin Luth <justin_luth@sil.org> | 2018-07-06 15:19:26 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-07-09 06:03:07 +0200 |
commit | 39a4f21fc4a16f7c57a9b6f1ddd5ce2953781576 (patch) | |
tree | 7697877ebdf974acbefe9cc1814e8b6ba7b2f458 | |
parent | a7699fc27240f1329602a5d442667c326525ad55 (diff) |
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_luth@sil.org>
-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. |