summaryrefslogtreecommitdiff
path: root/sd/qa/unit/misc-tests.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2015-12-03 19:05:03 +1000
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-12-14 09:05:21 +0000
commit6381fe554aec600d13d0359903216811d644dd36 (patch)
tree4c3201d70533a241495320ccd0bbf6297bb0bb10 /sd/qa/unit/misc-tests.cxx
parent6f8deb4601816c750743048deaed22f01dda0a36 (diff)
tdf#96206: Avoid scaling objects while copying to clipboard
... to prevent duplicating masters on slide copy-paste. Also fixed a 10-year copy-paste error (pRefPage wasn't replaced with pNPage). Fixed argument evaluation order issue (aStream.GetEndOfData() depends on Flush() but doesn't call it, so will return incorrect result if called before aStream.GetBuffer()). Replaced compare of hashes with results of stringify(), because it removes useless overhead (hashes are calculated from stringify() anyway, and are not cached anywhere). Removed Flush() called from SvMemoryStream::GetBuffer(), because it calls GetData(), which calls Flush() itself. Thanks to Andras Timar for unit test framework. Change-Id: Ia46d4e9a017fc628d424949a9d229045a249a4ca Reviewed-on: https://gerrit.libreoffice.org/20367 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sd/qa/unit/misc-tests.cxx')
-rw-r--r--sd/qa/unit/misc-tests.cxx103
1 files changed, 103 insertions, 0 deletions
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
new file mode 100644
index 000000000000..f36a671d10c5
--- /dev/null
+++ b/sd/qa/unit/misc-tests.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "sdmodeltestbase.hxx"
+
+#include <vcl/svapp.hxx>
+#include <sddll.hxx>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+
+#include <vcl/scheduler.hxx>
+#include <osl/thread.hxx>
+#include <FactoryIds.hxx>
+#include <sdmod.hxx>
+#include <tools/shl.hxx>
+#include <ImpressViewShellBase.hxx>
+#include <SlideSorterViewShell.hxx>
+#include <SlideSorter.hxx>
+#include <controller/SlideSorterController.hxx>
+#include <controller/SlsClipboard.hxx>
+
+using namespace ::com::sun::star;
+
+/// Impress miscellaneous tests.
+class SdMiscTest : public SdModelTestBase
+{
+public:
+ void testTdf96206();
+
+ CPPUNIT_TEST_SUITE(SdMiscTest);
+ CPPUNIT_TEST(testTdf96206);
+ CPPUNIT_TEST_SUITE_END();
+
+};
+
+void SdMiscTest::testTdf96206()
+{
+ // 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());
+
+ // create a frame
+ uno::Reference< frame::XFrame > xTargetFrame = xDesktop->findFrame("_blank", 0);
+ 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());
+
+ uno::Reference< frame::XModel2 > xModel2(xDocSh->GetModel(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xModel2.is());
+
+ uno::Reference< frame::XController2 > xController(xModel2->createDefaultViewController(xTargetFrame), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xController.is());
+
+ // introduce model/view/controller to each other
+ xController->attachModel(xModel2.get());
+ xModel2->connectController(xController.get());
+ xTargetFrame->setComponent(xController->getComponentWindow(), xController.get());
+ xController->attachFrame(xTargetFrame);
+ xModel2->setCurrentController(xController.get());
+
+ sd::ViewShell *pViewShell = xDocSh->GetViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ sd::slidesorter::SlideSorterViewShell* pSSVS = nullptr;
+ for (int i = 0; i < 1000; i++)
+ {
+ // Process all Tasks - slide sorter is created here
+ while (Scheduler::ProcessTaskScheduling(true));
+ if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase())) != nullptr)
+ break;
+ TimeValue aSleep(0, 100*1000000); // 100 msec
+ osl::Thread::wait(aSleep);
+ }
+ CPPUNIT_ASSERT(pSSVS);
+ auto& xSSController = pSSVS->GetSlideSorter().GetController();
+ const sal_uInt16 nMasterPageCnt1 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::PK_STANDARD);
+ xSSController.GetClipboard().DoCopy();
+ 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();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */