diff options
author | Justin Luth <justin_luth@sil.org> | 2018-07-06 10:03:07 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-07-11 17:40:51 +0200 |
commit | 3d9e0874becde20d901fda561633202e2e478eff (patch) | |
tree | c373daf98e6d803483d4863e0fa7adb148c631ff /writerfilter | |
parent | Update git submodules (diff) | |
download | core-3d9e0874becde20d901fda561633202e2e478eff.tar.gz core-3d9e0874becde20d901fda561633202e2e478eff.zip |
backport combined tdf#95115 and tdf#102619: writerfilter
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. And also
some stylenames were not recognized since it didn't do
an extended search.
tdf#95114 writerfilter: follow correctly converted stylename
commit ac540c1d743250062b3e71b094209ec1428872e9
tdf#102619 writerfilter: first create style, then set FollowStyle
commit 39a4f21fc4a16f7c57a9b6f1ddd5ce2953781576
~NFC related tdf#102619 writerfilter: use ConvertStyleName()
commit d22bca292532ff58839bc593a7b3e1d3b6f3552c
These commit were done separately to aid in regression testing
in master, but logically all combine together for easy
backporting.
Change-Id: I77f143760c10be4b7853f16bce2b57474b70d3f1
Reviewed-on: https://gerrit.libreoffice.org/57073
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-on: https://gerrit.libreoffice.org/57175
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 7e28500a11c0..69a03c6e8ea0 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -904,6 +904,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() ) @@ -1060,15 +1061,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 +1117,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) } } - if(bAddFollowStyle || !aPropValues.empty()) + if ( !aPropValues.empty() ) { PropValVector aSortedPropVals; for (const beans::PropertyValue& rValue : aPropValues) @@ -1126,22 +1130,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) - { - beans::PropertyValue aNew; - aNew.Name = "FollowStyle"; - aNew.Value <<= ConvertStyleName((*it)->sStyleIdentifierD); - aSortedPropVals.Insert(aNew); - break; - } - } - } try { @@ -1211,12 +1199,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. |