summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2016-09-09 23:32:11 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-12-02 10:54:19 +0000
commit5a61165b32dc356ca41117f101846d43929bc551 (patch)
treefe593bffbfbfa2ac46ddc2009ffdc6042f30c207 /writerfilter
parentb35bfc7c10a5e06d68340db22486f6682247d8df (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> Signed-off-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/31466
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx13
1 files changed, 12 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 30590cb75936..ae00da431bd3 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -916,6 +916,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
if(xCharStyles.is() && xParaStyles.is())
{
+ std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > 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 +929,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 +1149,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.emplace_back( sParentStyle, xStyle );
+
xStyles->insertByName( sConvertedStyleName, uno::makeAny( xStyle) );
}
@@ -1171,6 +1176,12 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
++aIt;
}
+ // Update the styles that were created before their parents
+ for( auto const & 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.