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

Thorsten Behrens (via logerrit) logerrit at kemper.freedesktop.org
Sun Aug 2 22:08:55 UTC 2020


 sw/qa/extras/odfimport/data/tdf134971a.odt |binary
 sw/qa/extras/odfimport/data/tdf134971b.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx       |   24 ++++++++++++++++++++++++
 xmloff/source/style/xmlstyle.cxx           |    4 +++-
 4 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit c84764e08da5e1c6202d300684baab0076d6b3ed
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Mon Jul 20 02:29:58 2020 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Mon Aug 3 00:08:18 2020 +0200

    tdf#134971 Don't overwrite default styles when inserting doc
    
    Seems code never really bothered not to touch default style
    info, when inserting from file. Original commit is:
    
     Author: Sascha Ballach <sab at openoffice.org>
     Date:   Wed Feb 28 08:24:41 2001 +0000
    
        import of default styles added
    
    Change-Id: Ibb639a585bedabdcc5987900ecca1e04f4bb593a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99015
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/qa/extras/odfimport/data/tdf134971a.odt b/sw/qa/extras/odfimport/data/tdf134971a.odt
new file mode 100644
index 000000000000..ee9fa68236a2
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf134971a.odt differ
diff --git a/sw/qa/extras/odfimport/data/tdf134971b.odt b/sw/qa/extras/odfimport/data/tdf134971b.odt
new file mode 100644
index 000000000000..9bfadda694f0
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf134971b.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 5f7ccd68db4f..e14e23dba0d1 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -41,6 +41,8 @@
 #include <com/sun/star/drawing/XDrawPage.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 
+#include <comphelper/propertysequence.hxx>
+
 #include <IDocumentSettingAccess.hxx>
 #include <wrtsh.hxx>
 #include <ndtxt.hxx>
@@ -1087,5 +1089,27 @@ DECLARE_ODFIMPORT_TEST(testTdf133459, "tdf133459.odt")
     CPPUNIT_ASSERT_EQUAL(OUString("QQ YYYY"), getProperty<OUString>(xFormat, "FormatString"));
 }
 
+DECLARE_ODFIMPORT_TEST(testTdf134971, "tdf134971a.odt")
+{
+    // now insert 2nd file somewhere - insertDocumentFromURL should
+    // _not_ touch pool defaults
+    uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence(
+    {
+        {"Name", uno::makeAny(
+                m_directories.getURLFromSrc(mpTestDocumentPath) + "tdf134971b.odt")},
+        {"Filter", uno::makeAny(OUString("writer8"))},
+    });
+    dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues);
+
+    // tdf134971b re-defines default font as "Liberation Sans" - make sure this stays
+    // Arial in final doc:
+    OUString sString;
+    uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles"));
+    uno::Reference<beans::XPropertySet> xStyle1(xParaStyles->getByName(
+            "Standard"), uno::UNO_QUERY);
+    xStyle1->getPropertyValue("CharFontName") >>= sString;
+    CPPUNIT_ASSERT_EQUAL(OUString("Arial"), sString);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx
index cc11a46dfe13..b87939436db1 100644
--- a/xmloff/source/style/xmlstyle.cxx
+++ b/xmloff/source/style/xmlstyle.cxx
@@ -839,7 +839,9 @@ void SvXMLStylesContext::CopyStylesToDoc( bool bOverwrite,
             continue;
 
         if (pStyle->IsDefaultStyle())
-            pStyle->SetDefaults();
+        {
+            if (bOverwrite) pStyle->SetDefaults();
+        }
         else if( InsertStyleFamily( pStyle->GetFamily() ) )
             pStyle->CreateAndInsert( bOverwrite );
     }


More information about the Libreoffice-commits mailing list