summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/svx/svdmodel.hxx6
-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
-rw-r--r--svl/source/items/itemset.cxx4
-rw-r--r--svx/source/svdraw/svdmodel.cxx2
-rw-r--r--svx/source/svdraw/svdoashp.cxx2
-rw-r--r--svx/source/svdraw/svdobj.cxx7
14 files changed, 71 insertions, 26 deletions
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index c400c669b90b..4a246d90de13 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -198,14 +198,14 @@ protected:
bool bInfoChanged:1;
bool bPagNumsDirty:1;
bool bMPgNumsDirty:1;
- bool bPageNotValid:1; // TRUE=Doc is only object container. Page is invalid.
+ bool bTransportContainer:1; // doc is temporary object container, no display (e.g. clipboard)
bool bSavePortable:1; // save metafiles portably
bool bNoBitmapCaching:1; // cache bitmaps for screen output
bool bReadOnly:1;
bool bTransparentTextFrames:1;
bool bSaveCompressed:1;
bool bSwapGraphics:1;
- bool bPasteResize:1; // Objects are beingresized due to Paste with different MapMode
+ bool bPasteResize:1; // Objects are being resized due to Paste with different MapMode
bool bSaveOLEPreview:1; // save preview metafile of OLE objects
bool bSaveNative:1;
bool bStarDrawPreviewMode:1;
@@ -274,6 +274,8 @@ private:
css::uno::Reference< css::uno::XInterface > mxUnoModel;
public:
+ SVX_DLLPRIVATE virtual bool IsCreatingDataObj() const { return false; }
+ bool IsTransportContainer() const { return bTransportContainer; }
bool IsPasteResize() const { return bPasteResize; }
void SetPasteResize(bool bOn) { bPasteResize=bOn; }
// If a custom Pool is put here, the class will call methods
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
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index a4e2c8a33702..2d146e0f8541 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1552,9 +1552,7 @@ sal_Int32 SfxItemSet::getHash() const
OString SfxItemSet::stringify() const
{
SvMemoryStream aStream;
- SfxItemSet aSet(*this);
- aSet.InvalidateDefaultItems();
- aSet.Store(aStream, true);
+ Store(aStream, true);
aStream.Flush();
return OString(
static_cast<char const *>(aStream.GetData()), aStream.GetEndOfData());
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 9d3fe0747384..a500958a86b8 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -148,7 +148,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe
bInfoChanged=false;
bPagNumsDirty=false;
bMPgNumsDirty=false;
- bPageNotValid=false;
+ bTransportContainer = false;
bSavePortable=false;
bSaveCompressed=false;
bSaveNative=false;
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 1e51ae6935fb..6304c471dd5d 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -1432,7 +1432,7 @@ const Rectangle& SdrObjCustomShape::GetLogicRect() const
// state of the ResizeShapeToFitText flag to correctly set TextMinFrameWidth/Height
void SdrObjCustomShape::AdaptTextMinSize()
{
- if(!pModel || !pModel->IsPasteResize())
+ if (!pModel || (!pModel->IsCreatingDataObj() && !pModel->IsPasteResize()))
{
const bool bResizeShapeToFitText(static_cast< const SdrOnOffItem& >(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue());
SfxItemSet aSet(
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index d5dc3b970449..b48665dd8197 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1747,12 +1747,7 @@ OString SdrObject::stringify() const
//append(maBLIPSizeRectangle).
append(mnLayerID);
- SvMemoryStream aStream;
- SfxItemSet aSet(GetMergedItemSet());
- aSet.InvalidateDefaultItems();
- aSet.Store(aStream, true);
- aStream.Flush(); // for correct results from aStream.GetEndOfData()
- aString.append(static_cast<const char *>(aStream.GetBuffer()), aStream.GetEndOfData());
+ aString.append(GetMergedItemSet().stringify());
return aString.makeStringAndClear();
}