sw/qa/extras/ooxmlexport/ooxmlexport4.cxx       |    5 +++++
 writerfilter/source/dmapper/StyleSheetTable.cxx |   13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 5a61165b32dc356ca41117f101846d43929bc551
Author: Justin Luth <justin_l...@sil.org>
Date:   Fri Sep 9 23:32:11 2016 +0300

    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 <c...@libreoffice.org>
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Signed-off-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/31466

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index c199d6f..699cc03 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -982,6 +982,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 30590cb..ae00da4 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.
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to