[Libreoffice-commits] core.git: sw/qa writerfilter/source

Justin Luth justin_luth at sil.org
Tue Sep 13 08:17:14 UTC 2016


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

New commits:
commit 5aaf4d89c5acfbdf1e85a760e3b3585f7d04e48a
Author: Justin Luth <justin_luth at 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 <ci at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 03b77a7..4ddf5e4 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 30590cb..c921527 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.


More information about the Libreoffice-commits mailing list