sw/qa/extras/uiwriter/data/fdo72942-insert.docx |binary sw/qa/extras/uiwriter/data/fdo72942.docx |binary sw/qa/extras/uiwriter/uiwriter.cxx | 36 ++++++++++++++++++++++++ writerfilter/source/dmapper/StyleSheetTable.cxx | 15 ++++++++++ 4 files changed, 51 insertions(+)
New commits: commit 148df9e201ba197819fee34857e5b8d1a7c46058 Author: Serge Krot <[email protected]> Date: Mon Jan 29 12:17:06 2018 +0100 tdf#72942 Do not overwrite styles from the inserted doc During inserting of the text from the external document we should not change original default styles in currently opened document. Added unit test. Change-Id: Ida754a0da5efaaa043464cd807c0b52cfb0d5670 Reviewed-on: https://gerrit.libreoffice.org/48861 Reviewed-by: Thorsten Behrens <[email protected]> Tested-by: Thorsten Behrens <[email protected]> diff --git a/sw/qa/extras/uiwriter/data/fdo72942-insert.docx b/sw/qa/extras/uiwriter/data/fdo72942-insert.docx new file mode 100755 index 000000000000..fb1f80c4ae09 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo72942-insert.docx differ diff --git a/sw/qa/extras/uiwriter/data/fdo72942.docx b/sw/qa/extras/uiwriter/data/fdo72942.docx new file mode 100755 index 000000000000..0906ec464271 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo72942.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 90c13315ad77..e9a9b7918644 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -207,6 +207,7 @@ public: void testTdf105417(); void testTdf112025(); void testTdf114306(); + void testTdf72942(); void testTdf113877(); void testTdf113877NoMerge(); @@ -315,6 +316,7 @@ public: CPPUNIT_TEST(testTdf105417); CPPUNIT_TEST(testTdf112025); CPPUNIT_TEST(testTdf114306); + CPPUNIT_TEST(testTdf72942); CPPUNIT_TEST(testTdf113877); CPPUNIT_TEST(testTdf113877NoMerge); CPPUNIT_TEST_SUITE_END(); @@ -3790,6 +3792,40 @@ void SwUiWriterTest::testTdf112025() CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle, "IsLandscape")); } +void SwUiWriterTest::testTdf72942() +{ + load(DATA_DIRECTORY, "fdo72942.docx"); + + // get a page cursor + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToEndOfPage(); + + OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "fdo72942-insert.docx"; + uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({{ "Name", uno::makeAny(insertFileid) }})); + lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); + + // check styles of paragraphs + const uno::Reference< text::XTextRange > xRun1 = getRun(getParagraph(1), 1); + CPPUNIT_ASSERT_EQUAL(OUString("Default English (Liberation serif) text with "), xRun1->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), getProperty<OUString>(xRun1, "CharFontName")); + + const uno::Reference< text::XTextRange > xRun2 = getRun(getParagraph(2), 1); + CPPUNIT_ASSERT_EQUAL(OUString("Header 1 English text (Liberation sans) with "), xRun2->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("Liberation Sans"), getProperty<OUString>(xRun2, "CharFontName")); + + const uno::Reference< text::XTextRange > xRun3 = getRun(getParagraph(4), 1); + CPPUNIT_ASSERT_EQUAL(OUString("Default German text (Calibri) with "), xRun3->getString()); +// CPPUNIT_ASSERT_EQUAL(OUString("Calibri"), getProperty<OUString>(xRun3, "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), getProperty<OUString>(xRun3, "CharFontName")); + + const uno::Reference< text::XTextRange > xRun4 = getRun(getParagraph(5), 1); + CPPUNIT_ASSERT_EQUAL(OUString("Header 1 German text (Calibri Light) with "), xRun4->getString()); +// CPPUNIT_ASSERT_EQUAL(OUString("Calibri Light"), getProperty<OUString>(xRun4, "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Liberation Sans"), getProperty<OUString>(xRun4, "CharFontName")); +} + void SwUiWriterTest::testTdf114306() { load(DATA_DIRECTORY, "fdo114306.odt"); diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 73348739d36f..10fff35235a5 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -902,6 +902,13 @@ uno::Sequence< OUString > PropValVector::getNames() void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) { + if (!m_pImpl->m_bIsNewDoc) + { + // tdf#72942: do not import styles from document being inserted, + // while they corrupts original styles in master document + return; + } + try { uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); @@ -1498,6 +1505,14 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten void StyleSheetTable::applyDefaults(bool bParaProperties) { try{ + + if (!m_pImpl->m_bIsNewDoc) + { + // tdf#72942: do not corrupts original styles in master document + // during inserting of text from second document + return; + } + if(!m_pImpl->m_xTextDefaults.is()) { m_pImpl->m_xTextDefaults.set( _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
