diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2015-12-22 18:31:19 +1000 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-01-05 07:18:17 +0000 |
commit | 3b4059dc53ec764be5423517363223043d6dbfad (patch) | |
tree | 27fb3c23df9725572628b8c6f39c4d3fba5186e2 /sd/qa | |
parent | 26eb0debda788d996d9bd63d72947652a5066087 (diff) |
tdf#96708: don't modify document while copying to clipboard
I.e., don't try to create auto-layout for clipboard pages which
don't contain one; don't resize objects to text.
Also, don't invalidate items that are equal to defaults,
because explicitly set items are not the same as absent items:
pasting an object without an item makes the property to inherit
new target's default, while when the item is present, the default
doesn't apply.
Also, don't consider selected state of the page while stringifying
- this makes selected page string to differ from not-selected
clipboard page.
Change-Id: I172e03e1a8c428e5fcae3a116cc9ad8de79f1a87
Reviewed-on: https://gerrit.libreoffice.org/20871
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/data/odp/tdf96708.odp | bin | 0 -> 7758 bytes | |||
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 53 |
2 files changed, 47 insertions, 6 deletions
diff --git a/sd/qa/unit/data/odp/tdf96708.odp b/sd/qa/unit/data/odp/tdf96708.odp Binary files differnew file mode 100644 index 000000000000..bb602f39003c --- /dev/null +++ b/sd/qa/unit/data/odp/tdf96708.odp diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index f36a671d10c5..e1d8b2abed40 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -30,6 +30,7 @@ #include <SlideSorter.hxx> #include <controller/SlideSorterController.hxx> #include <controller/SlsClipboard.hxx> +#include <controller/SlsPageSelector.hxx> using namespace ::com::sun::star; @@ -38,17 +39,19 @@ class SdMiscTest : public SdModelTestBase { public: void testTdf96206(); + void testTdf96708(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf96206); + CPPUNIT_TEST(testTdf96708); CPPUNIT_TEST_SUITE_END(); +private: + sd::DrawDocShellRef Load(const OUString& rURL, sal_Int32 nFormat); }; -void SdMiscTest::testTdf96206() +sd::DrawDocShellRef SdMiscTest::Load(const OUString& rURL, sal_Int32 nFormat) { - // Copying/pasting slide referring to a non-default master with a text duplicated the master - uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext()); CPPUNIT_ASSERT(xDesktop.is()); @@ -57,8 +60,8 @@ void SdMiscTest::testTdf96206() CPPUNIT_ASSERT(xTargetFrame.is()); // 1. Open the document - sd::DrawDocShellRef xDocSh = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/tdf96206.odp"), ODP); - CPPUNIT_ASSERT_MESSAGE("Failed to load tdf96206.odp.", xDocSh.Is()); + sd::DrawDocShellRef xDocSh = loadURL(rURL, nFormat); + CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocSh.Is()); uno::Reference< frame::XModel2 > xModel2(xDocSh->GetModel(), uno::UNO_QUERY); CPPUNIT_ASSERT(xModel2.is()); @@ -82,12 +85,25 @@ void SdMiscTest::testTdf96206() while (Scheduler::ProcessTaskScheduling(true)); if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase())) != nullptr) break; - TimeValue aSleep(0, 100*1000000); // 100 msec + TimeValue aSleep(0, 100 * 1000000); // 100 msec osl::Thread::wait(aSleep); } CPPUNIT_ASSERT(pSSVS); + + return xDocSh; +} + +void SdMiscTest::testTdf96206() +{ + // Copying/pasting slide referring to a non-default master with a text duplicated the master + + sd::DrawDocShellRef xDocSh = Load(getURLFromSrc("/sd/qa/unit/data/odp/tdf96206.odp"), ODP); + sd::ViewShell *pViewShell = xDocSh->GetViewShell(); + auto pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase()); auto& xSSController = pSSVS->GetSlideSorter().GetController(); + const sal_uInt16 nMasterPageCnt1 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::PK_STANDARD); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), nMasterPageCnt1); xSSController.GetClipboard().DoCopy(); xSSController.GetClipboard().DoPaste(); const sal_uInt16 nMasterPageCnt2 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::PK_STANDARD); @@ -96,6 +112,31 @@ void SdMiscTest::testTdf96206() xDocSh->DoClose(); } +void SdMiscTest::testTdf96708() +{ + sd::DrawDocShellRef xDocSh = Load(getURLFromSrc("/sd/qa/unit/data/odp/tdf96708.odp"), ODP); + sd::ViewShell *pViewShell = xDocSh->GetViewShell(); + auto pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase()); + auto& xSSController = pSSVS->GetSlideSorter().GetController(); + auto& xPageSelector = xSSController.GetPageSelector(); + + const sal_uInt16 nMasterPageCnt1 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::PK_STANDARD); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), nMasterPageCnt1); + xPageSelector.SelectAllPages(); + xSSController.GetClipboard().DoCopy(); + + // Now wait for timers to trigger creation of auto-layout + TimeValue aSleep(0, 100 * 1000000); // 100 msec + osl::Thread::wait(aSleep); + Scheduler::ProcessTaskScheduling(true); + + xSSController.GetClipboard().DoPaste(); + const sal_uInt16 nMasterPageCnt2 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::PK_STANDARD); + CPPUNIT_ASSERT_EQUAL(nMasterPageCnt1, nMasterPageCnt2); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); |