diff options
author | Serge Krot <Serge.Krot@cib.de> | 2020-10-08 09:01:33 +0200 |
---|---|---|
committer | Gabor Kelemen <kelemeng@ubuntu.com> | 2022-07-15 16:25:07 +0200 |
commit | 0dbc79be3a0de50700205eae501cf18254d88e40 (patch) | |
tree | 52bafbde7d3b146e4bf8589330f6aea918703c76 | |
parent | aab9c00b6d4e09532dd191a52c338042bad71abe (diff) |
tdf#132289 missing styles when inserting file with listfeature/cib_contract891
Warning: this does not work yet
Follow the instructions in the bug, inserting does not change
style for first line in document
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104085
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104319
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
(cherry picked from commit 92c05bd1f8ef695a56718c4b54babbe757ab9b89)
Change-Id: I444997a6cc55cfe287f4c610f538f2f54803646c
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf113877_blank_bold_off.odt | bin | 0 -> 8742 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf113877_blank_bold_on.odt | bin | 0 -> 9349 bytes | |||
-rwxr-xr-x | sw/qa/extras/uiwriter/uiwriter.cxx | 87 | ||||
-rwxr-xr-x | sw/source/core/txtnode/ndtxt.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimp.cxx | 3 |
5 files changed, 48 insertions, 46 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf113877_blank_bold_off.odt b/sw/qa/extras/uiwriter/data/tdf113877_blank_bold_off.odt Binary files differnew file mode 100644 index 000000000000..f4d58da53b95 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf113877_blank_bold_off.odt diff --git a/sw/qa/extras/uiwriter/data/tdf113877_blank_bold_on.odt b/sw/qa/extras/uiwriter/data/tdf113877_blank_bold_on.odt Binary files differnew file mode 100644 index 000000000000..8de77fc6161c --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf113877_blank_bold_on.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 12f74e1d9647..0881a66412ba 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -25,6 +25,11 @@ public: void testFdo69893(); void testFdo75110(); void testFdo75898(); + + void testTdf113877_mergeDocs(const char* aDestDoc, const char* aInsertDoc); + void testTdf113877_blank_bold_on(); + void testTdf113877_blank_bold_off(); + void testTdf113877(); void testTdf113877NoMerge(); void testTdf113877_default_style(); @@ -36,6 +41,8 @@ public: CPPUNIT_TEST(testFdo69893); CPPUNIT_TEST(testFdo75110); CPPUNIT_TEST(testFdo75898); + CPPUNIT_TEST(testTdf113877_blank_bold_on); + CPPUNIT_TEST(testTdf113877_blank_bold_off); CPPUNIT_TEST(testTdf113877); CPPUNIT_TEST(testTdf113877NoMerge); CPPUNIT_TEST(testTdf113877_default_style); @@ -153,11 +160,9 @@ void SwUiWriterTest::testFdo69893() CPPUNIT_ASSERT_EQUAL(OUString("Para after table."), rEnd.GetTxt()); } -// During insert of the document with list inside into the main document inside the list -// we should merge both lists into one, when they have the same list properties -void SwUiWriterTest::testTdf113877() +void SwUiWriterTest::testTdf113877_mergeDocs(const char* aDestDoc, const char* aInsertDoc) { - load(DATA_DIRECTORY, "tdf113877_insert_numbered_list.odt"); + load(DATA_DIRECTORY, aDestDoc); // set a page cursor into the end of the document uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); @@ -167,10 +172,17 @@ void SwUiWriterTest::testTdf113877() // insert the same document at current cursor position { - const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list.odt"; + const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(aInsertDoc); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); } +} + +// During insert of the document with list inside into the main document inside the list +// we should merge both lists into one, when they have the same list properties +void SwUiWriterTest::testTdf113877() +{ + testTdf113877_mergeDocs("tdf113877_insert_numbered_list.odt", "tdf113877_insert_numbered_list.odt"); const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); const OUString listId4 = getProperty<OUString>(getParagraph(4), "ListId"); @@ -190,20 +202,7 @@ void SwUiWriterTest::testTdf113877() // The same test as testTdf113877() but merging of two list should not be performed. void SwUiWriterTest::testTdf113877NoMerge() { - load(DATA_DIRECTORY, "tdf113877_insert_numbered_list.odt"); - - // set a page cursor into the end of the document - 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(); - - // insert the same document at current cursor position - { - const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list_abcd.odt"; - uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); - } + testTdf113877_mergeDocs("tdf113877_insert_numbered_list.odt", "tdf113877_insert_numbered_list_abcd.odt"); const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); const OUString listId4 = getProperty<OUString>(getParagraph(4), "ListId"); @@ -229,20 +228,7 @@ void SwUiWriterTest::testTdf113877NoMerge() // void SwUiWriterTest::testTdf113877_default_style() { - load(DATA_DIRECTORY, "tdf113877_blank.odt"); - - // set a page cursor into the end of the document - 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(); - - // insert the same document at current cursor position - { - const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list_abcd.odt"; - uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); - } + testTdf113877_mergeDocs("tdf113877_blank.odt", "tdf113877_insert_numbered_list_abcd.odt"); const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); const OUString listId2 = getProperty<OUString>(getParagraph(2), "ListId"); @@ -261,20 +247,31 @@ void SwUiWriterTest::testTdf113877_default_style() // void SwUiWriterTest::testTdf113877_Standard_style() { - load(DATA_DIRECTORY, "tdf113877_blank_ownStandard.odt"); + testTdf113877_mergeDocs("tdf113877_blank_ownStandard.odt", "tdf113877_insert_numbered_list_abcd.odt"); - // set a page cursor into the end of the document - 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(); + const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); + const OUString listId2 = getProperty<OUString>(getParagraph(2), "ListId"); + const OUString listId3 = getProperty<OUString>(getParagraph(3), "ListId"); - // insert the same document at current cursor position - { - const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list_abcd.odt"; - uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); - lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); - } + CPPUNIT_ASSERT_EQUAL(listId1, listId2); + CPPUNIT_ASSERT_EQUAL(listId1, listId3); +} + +void SwUiWriterTest::testTdf113877_blank_bold_on() +{ + testTdf113877_mergeDocs("tdf113877_blank_bold_on.odt", "tdf113877_insert_numbered_list_abcd.odt"); + + const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); + const OUString listId2 = getProperty<OUString>(getParagraph(2), "ListId"); + const OUString listId3 = getProperty<OUString>(getParagraph(3), "ListId"); + + CPPUNIT_ASSERT_EQUAL(listId1, listId2); + CPPUNIT_ASSERT_EQUAL(listId1, listId3); +} + +void SwUiWriterTest::testTdf113877_blank_bold_off() +{ + testTdf113877_mergeDocs("tdf113877_blank_bold_off.odt", "tdf113877_insert_numbered_list_abcd.odt"); const OUString listId1 = getProperty<OUString>(getParagraph(1), "ListId"); const OUString listId2 = getProperty<OUString>(getParagraph(2), "ListId"); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index e70560abfa2d..c08564702a33 100755 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2144,11 +2144,13 @@ void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, while( true ) { // check current item - sal_uInt16 nWhich = IsInvalidItem( pItem ) + const sal_uInt16 nWhich = IsInvalidItem( pItem ) ? pDest->GetpSwAttrSet()->GetWhichByPos( aIter.GetCurPos() ) : pItem->Which(); if( RES_FRMATR_STYLE_NAME != nWhich && RES_FRMATR_CONDITIONAL_STYLE_NAME != nWhich && + RES_PAGEDESC != nWhich && + RES_BREAK != nWhich && SFX_ITEM_SET == pDest->GetpSwAttrSet()->GetItemState( nWhich, false ) ) { // check if parent value (original value in style) has the same value as in [pItem] diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index c05f76160f66..7299cee58d3c 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -805,7 +805,10 @@ void SwXMLImport::endDocument( void ) if (!pTxtNode->GetTxt().isEmpty()) pDelNd->FmtToTxtAttr( pTxtNode ); else + { + pTxtNode->ResetAttr(RES_CHRATR_BEGIN, RES_CHRATR_END); pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() ); + } pTxtNode->JoinNext(); } } |