summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2020-07-20 02:29:58 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-08-03 00:08:18 +0200
commitc84764e08da5e1c6202d300684baab0076d6b3ed (patch)
treecc42e3c3cd406f9ee294a57d4b02c1325bb9c746
parent7956d73cf531a0630f17d746940e91eb76959008 (diff)
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@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@CIB.de>
-rw-r--r--sw/qa/extras/odfimport/data/tdf134971a.odtbin0 -> 9960 bytes
-rw-r--r--sw/qa/extras/odfimport/data/tdf134971b.odtbin0 -> 8599 bytes
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx24
-rw-r--r--xmloff/source/style/xmlstyle.cxx4
4 files changed, 27 insertions, 1 deletions
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
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/tdf134971a.odt
Binary files 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
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/tdf134971b.odt
Binary files 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 );
}