summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2015-12-22 18:31:19 +1000
committerAndras Timar <andras.timar@collabora.com>2016-01-05 07:18:17 +0000
commit3b4059dc53ec764be5423517363223043d6dbfad (patch)
tree27fb3c23df9725572628b8c6f39c4d3fba5186e2 /sd
parent26eb0debda788d996d9bd63d72947652a5066087 (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')
-rw-r--r--sd/inc/drawdoc.hxx1
-rw-r--r--sd/qa/unit/data/odp/tdf96708.odpbin0 -> 7758 bytes
-rw-r--r--sd/qa/unit/misc-tests.cxx53
-rw-r--r--sd/source/core/drawdoc2.cxx3
-rw-r--r--sd/source/core/drawdoc3.cxx6
-rw-r--r--sd/source/core/sdpage2.cxx2
-rw-r--r--sd/source/ui/slidesorter/controller/SlsClipboard.cxx3
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx3
-rw-r--r--sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx5
9 files changed, 63 insertions, 13 deletions
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 23e5ecf2984d..e2ff20cd2b55 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -237,6 +237,7 @@ public:
SAL_DLLPRIVATE void SetAllocDocSh(bool bAlloc);
SAL_DLLPRIVATE void CreatingDataObj( SdTransferable* pTransferable ) { mpCreatingTransferable = pTransferable; }
+ SAL_DLLPRIVATE virtual bool IsCreatingDataObj() const override { return mpCreatingTransferable != nullptr; }
/** if the document does not contain at least one handout, one slide and one notes page with
at least one master each this methods creates them.
diff --git a/sd/qa/unit/data/odp/tdf96708.odp b/sd/qa/unit/data/odp/tdf96708.odp
new file mode 100644
index 000000000000..bb602f39003c
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf96708.odp
Binary files differ
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();
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 27dbcda95495..a5406d2a1a75 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -852,6 +852,9 @@ LanguageType SdDrawDocument::GetLanguage( const sal_uInt16 nId ) const
// Initiate WorkStartup
IMPL_LINK_NOARG_TYPED(SdDrawDocument, WorkStartupHdl, Timer *, void)
{
+ if (IsTransportContainer())
+ return;
+
if( mpDocSh )
mpDocSh->SetWaitCursor( true );
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 41f091979fc3..0a3502e64815 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -449,9 +449,9 @@ bool SdDrawDocument::InsertBookmarkAsPage(
// this will make copied masters to differ from the originals,
// and thus InsertBookmarkAsPage_FindDuplicateLayouts will
// duplicate masters on insert to same document
- bool bIsClipBoard = (SD_MOD()->pTransferClip &&
- SD_MOD()->pTransferClip->GetWorkDocument() == this);
- if (!bIsClipBoard)
+ bTransportContainer = (SD_MOD()->pTransferClip &&
+ SD_MOD()->pTransferClip->GetWorkDocument() == this);
+ if (!bTransportContainer)
{
if (rBookmarkList.empty())
bScaleObjects = pRefPage->IsScaleObjects();
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index f4c09ced768d..f3ca063dc0b7 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -560,7 +560,7 @@ void SdPage::setTransitionDuration ( double fTranstionDuration )
OString SdPage::stringify() const
{
OStringBuffer aString(100);
- aString.append((sal_Int32)mePageKind).append((sal_Int32)meAutoLayout).append(mbSelected).append((sal_Int32)mePresChange).append(mfTime).append(mbSoundOn).append(mbExcluded).
+ aString.append((sal_Int32)mePageKind).append((sal_Int32)meAutoLayout).append((sal_Int32)mePresChange).append(mfTime).append(mbSoundOn).append(mbExcluded).
append(OUStringToOString( maLayoutName, RTL_TEXTENCODING_UTF8 )).
append(OUStringToOString(maSoundFile, RTL_TEXTENCODING_UTF8 )).
append(mbLoopSound).append(mbStopSound).
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index a2b1c1dc3246..99c5faf5ffd2 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -432,7 +432,6 @@ void Clipboard::CreateSlideTransferable (
pDocument->CreatingDataObj (pTransferable);
pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument());
- pDocument->CreatingDataObj (nullptr);
TransferableObjectDescriptor aObjDesc;
pTransferable->GetWorkDocument()->GetDocSh()
->FillTransferableObjectDescriptor (aObjDesc);
@@ -465,6 +464,8 @@ void Clipboard::CreateSlideTransferable (
}
else
pTransferable->CopyToClipboard (pActionWindow);
+
+ pDocument->CreatingDataObj(nullptr);
}
}
diff --git a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
index 83d01eb4fe35..5d6957724524 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
@@ -110,7 +110,8 @@ public:
*/
model::SharedPageDescriptor GetPageAt (const Point& rPixelPosition);
- PageSelector& GetPageSelector();
+ // Exported for unit test
+ SD_DLLPUBLIC PageSelector& GetPageSelector();
FocusManager& GetFocusManager();
// Exported for unit test
SD_DLLPUBLIC controller::Clipboard& GetClipboard();
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx
index 5485fb1f440b..d084044f7a08 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx
@@ -27,6 +27,8 @@
#include <memory>
#include <boost/noncopyable.hpp>
+#include "sddllapi.h"
+
class SdPage;
namespace sd { namespace slidesorter {
@@ -55,7 +57,8 @@ class PageSelector : private ::boost::noncopyable
public:
PageSelector (SlideSorter& rSlideSorter);
- void SelectAllPages();
+ // Exported for unit test
+ SD_DLLPUBLIC void SelectAllPages();
void DeselectAllPages();
/** Update the selection state of all page descriptors to be the same as