sw/qa/extras/uiwriter/data/tdf113877_blank.odt |binary sw/qa/extras/uiwriter/data/tdf113877_blank_ownStandard.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 68 +++++++++++++ sw/source/core/txtnode/ndtxt.cxx | 45 ++++++++ 4 files changed, 111 insertions(+), 2 deletions(-)
New commits: commit e78239c928de1c73a7dda5a37ff38a1407ced052 Author: Serge Krot <serge.k...@cib.de> Date: Mon Jun 18 18:15:55 2018 +0200 tdf#113877 Insert doc: merge list into text with specifc style When inserting document, in the current position the text could have custom style but really it is the same Standard style. Therefore we should not merge first inserted node into the insert position and just overwrite style in the insert position with text style from the inserted node. Change-Id: Ib67c56bed3d30f356f83dc0b4d4a1710def10853 Reviewed-on: https://gerrit.libreoffice.org/56052 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Reviewed-on: https://gerrit.libreoffice.org/56408 Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/qa/extras/uiwriter/data/tdf113877_blank.odt b/sw/qa/extras/uiwriter/data/tdf113877_blank.odt new file mode 100755 index 000000000000..741d7d5e6d0a Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf113877_blank.odt differ diff --git a/sw/qa/extras/uiwriter/data/tdf113877_blank_ownStandard.odt b/sw/qa/extras/uiwriter/data/tdf113877_blank_ownStandard.odt new file mode 100755 index 000000000000..3dbebda6f93c Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf113877_blank_ownStandard.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx old mode 100644 new mode 100755 index b4d2f264bf42..2410ab136a8e --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -215,6 +215,8 @@ public: void testTdf72942(); void testTdf113877(); void testTdf113877NoMerge(); + void testTdf113877_default_style(); + void testTdf113877_Standard_style(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -328,6 +330,8 @@ public: CPPUNIT_TEST(testTdf72942); CPPUNIT_TEST(testTdf113877); CPPUNIT_TEST(testTdf113877NoMerge); + CPPUNIT_TEST(testTdf113877_default_style); + CPPUNIT_TEST(testTdf113877_Standard_style); CPPUNIT_TEST_SUITE_END(); private: @@ -3953,6 +3957,70 @@ void SwUiWriterTest::testTdf113877NoMerge() CPPUNIT_ASSERT(listId6 != listId7); } +// Related test to testTdf113877(): Inserting into empty document a new document with list. +// Insert position has NO its own paragraph style ("Standard" will be used). +// +// Resulting document should be the same for following tests: +// - testTdf113877_default_style() +// - testTdf113877_Standard_style() +// +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); + } + + 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); +} + +// Related test to testTdf113877(): Inserting into empty document a new document with list. +// Insert position has its own paragraph style derived from "Standard", but this style is the same as "Standard". +// +// Resulting document should be the same for following tests: +// - testTdf113877_default_style() +// - testTdf113877_Standard_style() +// +void SwUiWriterTest::testTdf113877_Standard_style() +{ + load(DATA_DIRECTORY, "tdf113877_blank_ownStandard.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); + } + + 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); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx old mode 100644 new mode 100755 index 13064a1c2f6a..4b7815a1c221 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2077,8 +2077,49 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwIndex & rDestStart, // harte Absatz umspannende Attribute kopieren if (HasSwAttrSet()) { - // alle, oder nur die CharAttribute ? - if( nInitSize || pDest->HasSwAttrSet() || + bool hasSwAttrSet = pDest->HasSwAttrSet(); + if (hasSwAttrSet) + { + // if we have our own property set it doesn't mean + // that this set defines any style different to Standard one. + hasSwAttrSet = false; + + // so, let's check deeper if property set has defined any property + if (pDest->GetpSwAttrSet()) + { + // check all items in the property set + SfxItemIter aIter( *pDest->GetpSwAttrSet() ); + const SfxPoolItem* pItem = aIter.GetCurItem(); + while( true ) + { + // check current item + sal_uInt16 nWhich = IsInvalidItem( pItem ) + ? pDest->GetpSwAttrSet()->GetWhichByPos( aIter.GetCurPos() ) + : pItem->Which(); + if( RES_FRMATR_STYLE_NAME != nWhich && + RES_FRMATR_CONDITIONAL_STYLE_NAME != nWhich && + SfxItemState::SET == pDest->GetpSwAttrSet()->GetItemState( nWhich, false ) ) + { + // check if parent value (original value in style) has the same value as in [pItem] + const SfxPoolItem& rParentItem = pDest->GetpSwAttrSet()->GetParent()->Get( nWhich, true ); + + hasSwAttrSet = (rParentItem != *pItem); + + // property set is not empty => no need to make anymore checks + if (hasSwAttrSet) + break; + } + + // let's check next item + if( aIter.IsAtEnd() ) + break; + pItem = aIter.NextItem(); + } + } + } + + // all or just the Char attributes? + if( nInitSize || hasSwAttrSet || nLen != pDest->GetText().getLength()) { SfxItemSet aCharSet( pDest->GetDoc()->GetAttrPool(), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits