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

Justin Luth justin_luth at sil.org
Thu Sep 15 08:41:29 UTC 2016


 sw/qa/extras/ooxmlexport/data/tdf53856_conflictingStyle.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx                     |    9 +++++++++
 writerfilter/source/dmapper/StyleSheetTable.cxx              |    6 ++++++
 3 files changed, 15 insertions(+)

New commits:
commit b79b5e0df6dc5a0ba18054b0503d6fa804b69f02
Author: Justin Luth <justin_luth at sil.org>
Date:   Wed Sep 14 14:34:29 2016 +0300

    tdf#53856 writerfilter set parentless style based on default
    
    docx import of base-less style "Text" was conflicting with
    LibreOffice's builtin "Caption"->"Text" paragraph style.
    
    This only worked when the parent .isEmpty(). Style names can
    use localization, so forcing the imported parent-name will not
    match between different language versions.
    
    Change-Id: I86d9965abb4ee90b04c713371529a679d045660c
    Reviewed-on: https://gerrit.libreoffice.org/28894
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Tested-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf53856_conflictingStyle.docx b/sw/qa/extras/ooxmlexport/data/tdf53856_conflictingStyle.docx
new file mode 100644
index 0000000..71b925a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf53856_conflictingStyle.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 90cef9f..a6cf96f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -9,6 +9,7 @@
 
 #include <swmodeltestbase.hxx>
 
+#include <com/sun/star/awt/FontSlant.hpp>
 #include <com/sun/star/awt/XBitmap.hpp>
 #include <com/sun/star/drawing/FillStyle.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
@@ -351,6 +352,14 @@ DECLARE_OOXMLEXPORT_TEST(testNumberingFont, "numbering-font.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf53856_conflictingStyle, "tdf53856_conflictingStyle.docx")
+{
+    // The "Text" style conflicted with builtin paragraph style Caption -> Text
+    uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Text"), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("Times New Roman"), getProperty<OUString>(xStyle, "CharFontName"));
+    CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, getProperty<awt::FontSlant>(xStyle, "CharPosture"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testDrawingmlFlipv, "drawingml-flipv.docx")
 {
     // The problem was that the shape had vertical flip only, but then we added rotation as well on export.
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index ae00da4..c9ef060 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -943,7 +943,13 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
 
                         // Standard is handled already in applyDefaults().
                         if (sConvertedStyleName != "Standard")
+                        {
                             StyleSheetTable_Impl::SetPropertiesToDefault(xStyle);
+
+                            // resolve import conflicts with built-in styles
+                            if( pEntry->sBaseStyleIdentifier.isEmpty() && !xStyle->getParentStyle().isEmpty() )
+                                xStyle->setParentStyle( "Standard" );
+                        }
                     }
                     else
                     {


More information about the Libreoffice-commits mailing list