[Libreoffice-commits] core.git: include/svx sd/inc sd/qa sd/source svl/source svx/source

Mike Kaganski mike.kaganski at collabora.com
Mon Jan 4 23:18:38 PST 2016


 include/svx/svdmodel.hxx                                          |    6 -
 sd/inc/drawdoc.hxx                                                |    1 
 sd/qa/unit/data/odp/tdf96708.odp                                  |binary
 sd/qa/unit/misc-tests.cxx                                         |   53 ++++++++--
 sd/source/core/drawdoc2.cxx                                       |    3 
 sd/source/core/drawdoc3.cxx                                       |    6 -
 sd/source/core/sdpage2.cxx                                        |    2 
 sd/source/ui/slidesorter/controller/SlsClipboard.cxx              |    3 
 sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx |    3 
 sd/source/ui/slidesorter/inc/controller/SlsPageSelector.hxx       |    5 
 svl/source/items/itemset.cxx                                      |    4 
 svx/source/svdraw/svdmodel.cxx                                    |    2 
 svx/source/svdraw/svdoashp.cxx                                    |    2 
 svx/source/svdraw/svdobj.cxx                                      |    7 -
 14 files changed, 71 insertions(+), 26 deletions(-)

New commits:
commit 3b4059dc53ec764be5423517363223043d6dbfad
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Tue Dec 22 18:31:19 2015 +1000

    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 at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index c400c66..4a246d9 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 23e5ecf..e2ff20c 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 0000000..bb602f3
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf96708.odp differ
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index f36a671..e1d8b2a 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 27dbcda..a5406d2 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 41f0919..0a3502e 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 f4c09ce..f3ca063 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 a2b1c1d..99c5faf 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 83d01eb..5d69577 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 5485fb1..d084044 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 a4e2c8a..2d146e0 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 9d3fe07..a500958 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 1e51ae6..6304c47 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 d5dc3b9..b48665d 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();
 }


More information about the Libreoffice-commits mailing list