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 a975573406553f46507dd309f02a5bf5198596fc
Author:     Thorsten Behrens <[email protected]>
AuthorDate: Mon Jul 20 02:29:58 2020 +0200
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Tue Aug 4 10:23:19 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 <[email protected]>
     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 <[email protected]>
    (cherry picked from commit c84764e08da5e1c6202d300684baab0076d6b3ed)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99919
    Reviewed-by: Michael Stahl <[email protected]>

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 70d5a158b22c..2cd4f40b2267 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -34,6 +34,8 @@
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 #include <com/sun/star/lang/Locale.hpp>
 
+#include <comphelper/propertysequence.hxx>
+
 #include <IDocumentSettingAccess.hxx>
 #include <wrtsh.hxx>
 #include <ndtxt.hxx>
@@ -1078,5 +1080,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 d020280cb173..f6eeb70dea17 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 );
     }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to