diff options
| author | Justin Luth <justin_luth@sil.org> | 2018-07-06 16:55:26 +0300 |
|---|---|---|
| committer | Justin Luth <justin_luth@sil.org> | 2018-07-10 06:09:28 +0200 |
| commit | ab16d43dd649b111e095a06f3b75ab77721830fe (patch) | |
| tree | 3a3afd1e022afa911f7d8da4ee616249ef0297f6 | |
| parent | 1947730e9810cfbe5f1f7612aa48879b89c8ed6a (diff) | |
~NFC related tdf#102619 writerfilter: use ConvertStyleName()
This cleanup should help simplify and clarify immensely.
An empty followStyle is treated the same as not
defining it at all, and if a style specifies a follow, why
not accept any style with that ID, regardless of whether
a UI name was attached?
HOWEVER, both this unit test and
tdf104713_undefinedStyles.docx ignore the w:next
IN MSO. I tested with 2013, 2010, and 2003 and they all
revert back to w:next being the same style
in these broken documents.
Perhaps the existing test of whether sStyleName.isEmpty()
is not the best test, but that is what it was, so keeping
it until some proof document comes along.
Change-Id: I28b1a5d67e6feea6b4d1ffdb77ec27bf6c824251
Reviewed-on: https://gerrit.libreoffice.org/57075
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
| -rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 4 | ||||
| -rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 37 |
2 files changed, 13 insertions, 28 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 4b3a9cf3b7d5..e958de434a81 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -558,6 +558,10 @@ DECLARE_OOXMLEXPORT_TEST(testN780853, "n780853.docx") uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + + //tdf#102619 - I would have expected this to be "Standard", but MSO 2013/2010/2003 all give FollowStyle==Date + uno::Reference< beans::XPropertySet > properties(getStyles("ParagraphStyles")->getByName("Date"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Date"), getProperty<OUString>(properties, "FollowStyle")); } DECLARE_OOXMLEXPORT_TEST(testN780843, "n780843.docx") diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 14c2348fb0d5..263d74881ad5 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -1060,15 +1060,18 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) } auto aPropValues = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(pEntry->pProperties->GetPropertyValues()); - bool bAddFollowStyle = false; - if(bParaStyle && !pEntry->sNextStyleIdentifier.isEmpty() ) - { - bAddFollowStyle = true; - } // remove Left/RightMargin values from TOX heading styles if( bParaStyle ) { + // delay adding FollowStyle property: all styles need to be created first + if ( !pEntry->sNextStyleIdentifier.isEmpty() ) + { + StyleSheetEntryPtr pFollowStyle = FindStyleSheetByISTD( pEntry->sNextStyleIdentifier ); + if ( pFollowStyle && !pFollowStyle->sStyleName.isEmpty() ) + aMissingFollow.emplace_back( ConvertStyleName( pFollowStyle->sStyleName ), xStyle ); + } + // Set the outline levels const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr); if ( pStyleSheetProperties ) @@ -1113,7 +1116,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) } } - if(bAddFollowStyle || !aPropValues.empty()) + if ( !aPropValues.empty() ) { PropValVector aSortedPropVals; for (const beans::PropertyValue& rValue : aPropValues) @@ -1126,28 +1129,6 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) aSortedPropVals.Insert(rValue); } } - if(bAddFollowStyle) - { - //find the name of the Next style - std::vector< StyleSheetEntryPtr >::iterator it = m_pImpl->m_aStyleSheetEntries.begin(); - for (; it != m_pImpl->m_aStyleSheetEntries.end(); ++it) - { - if (!(*it)->sStyleName.isEmpty() && (*it)->sStyleIdentifierD == pEntry->sNextStyleIdentifier) - { - 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; - } - } - } try { |
