diff options
author | Justin Luth <justin_luth@sil.org> | 2016-09-09 23:32:11 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-09-13 08:16:12 +0000 |
commit | 5aaf4d89c5acfbdf1e85a760e3b3585f7d04e48a (patch) | |
tree | 8760228f039d860f350b832d10d9e60ea5046ffc | |
parent | 714de95ec549a7a79574cbe5a59450083c279dc6 (diff) |
tdf#89315 writerfilter add missing parents to out-of-order styles
Styles that inherit from a parent style, but were defined in style.xml
before the parent, were losing their base style.
Change-Id: Ic12876dddb1aa961cd8ef7579061cca30c320c71
Reviewed-on: https://gerrit.libreoffice.org/28785
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 03b77a776788..4ddf5e46a901 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -1015,6 +1015,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81345_045Original,"tdf81345.docx") xCursor->jumpToPage(2); OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); CPPUNIT_ASSERT(pageStyleName != "Standard"); + + // tdf89297 Styles were being added before their base/parent/inherited-from style existed, and so were using default settings. + uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles")); + uno::Reference<beans::XPropertySet> xStyle(xParaStyles->getByName("Pull quote"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6736947), getProperty<sal_Int32>(xStyle, "CharColor")); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 30590cb75936..c92152775b89 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -51,6 +51,7 @@ namespace dmapper { typedef ::std::map< OUString, OUString> StringPairMap_t; +typedef ::std::pair<OUString, uno::Reference< style::XStyle>> ParentOfStylePair_t; StyleSheetEntry::StyleSheetEntry() : @@ -916,6 +917,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles; if(xCharStyles.is() && xParaStyles.is()) { + std::vector< ParentOfStylePair_t > aMissingParent; std::vector<beans::PropertyValue> aTableStylesVec; std::vector< StyleSheetEntryPtr >::iterator aIt = m_pImpl->m_aStyleSheetEntries.begin(); while( aIt != m_pImpl->m_aStyleSheetEntries.end() ) @@ -928,7 +930,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) bool bInsert = false; uno::Reference< container::XNameContainer > xStyles = bParaStyle ? xParaStyles : (bListStyle ? xNumberingStyles : xCharStyles); uno::Reference< style::XStyle > xStyle; - OUString sConvertedStyleName = ConvertStyleName( pEntry->sStyleName ); + const OUString sConvertedStyleName = ConvertStyleName( pEntry->sStyleName ); if(xStyles->hasByName( sConvertedStyleName )) { @@ -1148,6 +1150,10 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) // Numbering style got inserted earlier. if(bInsert && !bListStyle) { + const OUString sParentStyle = xStyle->getParentStyle(); + if( !sParentStyle.isEmpty() && !xStyles->hasByName( sParentStyle ) ) + aMissingParent.push_back( ParentOfStylePair_t(sParentStyle, xStyle) ); + xStyles->insertByName( sConvertedStyleName, uno::makeAny( xStyle) ); } @@ -1171,6 +1177,12 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) ++aIt; } + // Update the styles that were created before their parents + for( auto iter : aMissingParent ) + { + iter.second->setParentStyle( iter.first ); + } + if (!aTableStylesVec.empty()) { // If we had any table styles, add a new document-level InteropGrabBag entry for them. |