[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sd/CppunitTest_sd_misc_tests.mk sd/Module_sd.mk sd/qa sd/source svx/source tools/source

Mike Kaganski mike.kaganski at collabora.com
Mon Dec 14 03:10:35 PST 2015


 sd/CppunitTest_sd_misc_tests.mk                                   |  155 ++++++++++
 sd/Module_sd.mk                                                   |    1 
 sd/qa/unit/data/odp/tdf96206.odp                                  |binary
 sd/qa/unit/misc-tests.cxx                                         |  103 ++++++
 sd/source/core/drawdoc3.cxx                                       |   22 +
 sd/source/ui/inc/SlideSorter.hxx                                  |    4 
 sd/source/ui/inc/SlideSorterViewShell.hxx                         |    7 
 sd/source/ui/inc/ViewShell.hxx                                    |    3 
 sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx |    5 
 sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx          |    8 
 svx/source/svdraw/svdobj.cxx                                      |    1 
 tools/source/stream/stream.cxx                                    |    1 
 12 files changed, 296 insertions(+), 14 deletions(-)

New commits:
commit 02d09f424cac957e2d214a3fc6eebac14b3852a7
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Dec 3 19:05:03 2015 +1000

    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 at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 6381fe554aec600d13d0359903216811d644dd36)
    Reviewed-on: https://gerrit.libreoffice.org/20694
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/CppunitTest_sd_misc_tests.mk b/sd/CppunitTest_sd_misc_tests.mk
new file mode 100644
index 0000000..453ec35
--- /dev/null
+++ b/sd/CppunitTest_sd_misc_tests.mk
@@ -0,0 +1,155 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sd_misc_tests))
+
+$(eval $(call gb_CppunitTest_use_external,sd_misc_tests,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_misc_tests, \
+    sd/qa/unit/misc-tests \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sd_misc_tests, \
+    $(call gb_Helper_optional,AVMEDIA,avmedia) \
+    basegfx \
+    canvastools \
+    comphelper \
+    cppcanvas \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    for \
+    forui \
+    i18nlangtag \
+    i18nutil \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sd \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+    test \
+    tl \
+    tk \
+    ucbhelper \
+    unotest \
+    utl \
+    vcl \
+    xo \
+    $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sd_misc_tests,\
+    -I$(SRCDIR)/sd/inc \
+    -I$(SRCDIR)/sd/source/ui/inc \
+    -I$(SRCDIR)/sd/source/ui/slidesorter/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sd_misc_tests,\
+    offapi \
+    udkapi \
+))
+
+ifeq ($(OS),WNT)
+$(eval $(call gb_CppunitTest_use_system_win32_libs,sd_misc_tests,\
+    uuid \
+    ws2_32 \
+))
+endif
+
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_CppunitTest_add_libs,sd_uimpress,\
+    -lobjc \
+))
+
+$(eval $(call gb_CppunitTest_use_system_darwin_frameworks,sd_uimpress,\
+    Foundation \
+    IOBluetooth \
+))
+endif
+
+$(eval $(call gb_CppunitTest_use_externals,sd_misc_tests,\
+    boost_headers \
+    gtk \
+    dbus \
+    $(if $(ENABLE_AVAHI), \
+        avahi \
+    ) \
+    $(if $(filter WNT,$(OS)),mDNSResponder) \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sd_misc_tests))
+$(eval $(call gb_CppunitTest_use_vcl,sd_misc_tests))
+
+$(eval $(call gb_CppunitTest_use_components,sd_misc_tests,\
+    animations/source/animcore/animcore \
+    basic/util/sb \
+    chart2/source/chartcore \
+    chart2/source/controller/chartcontroller \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    dbaccess/util/dba \
+    desktop/source/deployment/deployment \
+    embeddedobj/util/embobj \
+    filter/source/config/cache/filterconfig1 \
+    filter/source/odfflatxml/odfflatxml \
+    filter/source/svg/svgfilter \
+    filter/source/xmlfilteradaptor/xmlfa \
+    filter/source/xmlfilterdetect/xmlfd \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    linguistic/source/lng \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    sd/util/sd \
+    sd/util/sdfilt \
+    sd/util/sdd \
+    sfx2/util/sfx \
+    sot/util/sot \
+    svl/source/fsstor/fsstorage \
+    svtools/util/svt \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/expand/ucpexpand1 \
+    ucb/source/ucp/file/ucpfile1 \
+    ucb/source/ucp/package/ucppkg1 \
+    ucb/source/ucp/tdoc/ucptdoc1 \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+    xmloff/util/xo \
+    xmlsecurity/util/xsec_fw \
+    xmlsecurity/util/xmlsecurity \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sd_misc_tests))
+
+$(eval $(call gb_CppunitTest_use_packages,sd_misc_tests,\
+    oox_customshapes \
+))
+
+
+$(call gb_CppunitTest_get_target,sd_misc_tests) : $(call gb_AllLangResTarget_get_target,sd)
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 09b36b2..981750b 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Module_add_check_targets,sd,\
     CppunitTest_sd_import_tests \
     CppunitTest_sd_export_tests \
     CppunitTest_sd_filters_test \
+    CppunitTest_sd_misc_tests \
     CppunitTest_sd_html_export_tests \
     CppunitTest_sd_tiledrendering \
 ))
diff --git a/sd/qa/unit/data/odp/tdf96206.odp b/sd/qa/unit/data/odp/tdf96206.odp
new file mode 100644
index 0000000..faebfd1
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf96206.odp differ
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
new file mode 100644
index 0000000..f36a671
--- /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: */
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 5fb0e78..f63295c 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -51,6 +51,7 @@
 #include "strmname.h"
 #include "anminfo.hxx"
 #include "customshowlist.hxx"
+#include "sdxfer.hxx"
 
 #include "../ui/inc/unmovss.hxx"
 #include "../ui/inc/unchss.hxx"
@@ -110,7 +111,7 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
         {
             // Ignore Layouts with "Default" these seem to be special - in the sense that there are lot of assumption all over Impress
             // about this
-            if( bRenameDuplicates && aTest != OUString( SdResId( STR_LAYOUT_DEFAULT_NAME ) ) && pTestPage->getHash() != pBMMPage->getHash() )
+            if( bRenameDuplicates && aTest != OUString( SdResId( STR_LAYOUT_DEFAULT_NAME ) ) && pTestPage->stringify() != pBMMPage->stringify() )
             {
                 pBookmarkDoc->RenameLayoutTemplate(
                     pBMMPage->GetLayoutName(), pBMMPage->GetName() + "_");
@@ -437,17 +438,26 @@ bool SdDrawDocument::InsertBookmarkAsPage(
     sal_Int32 nNRight = pNPage->GetRgtBorder();
     sal_Int32 nNUpper = pNPage->GetUppBorder();
     sal_Int32 nNLower = pNPage->GetLwrBorder();
-    Orientation eNOrient = pRefPage->GetOrientation();
+    Orientation eNOrient = pNPage->GetOrientation();
 
     // Adapt page size and margins to those of the later pages?
     pRefPage = GetSdPage(nSdPageCount - 1, PK_STANDARD);
 
     if( bNoDialogs )
     {
-        if( rBookmarkList.empty() )
-            bScaleObjects = pRefPage->IsScaleObjects();
-        else
-            bScaleObjects = true;
+        // If this is clipboard, then no need to scale objects:
+        // 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)
+        {
+            if (rBookmarkList.empty())
+                bScaleObjects = pRefPage->IsScaleObjects();
+            else
+                bScaleObjects = true;
+        }
     }
     else
     {
diff --git a/sd/source/ui/inc/SlideSorter.hxx b/sd/source/ui/inc/SlideSorter.hxx
index 6890178..79eb9fe 100644
--- a/sd/source/ui/inc/SlideSorter.hxx
+++ b/sd/source/ui/inc/SlideSorter.hxx
@@ -28,6 +28,7 @@
 #include <boost/noncopyable.hpp>
 #include <boost/current_function.hpp>
 #include <vcl/scrbar.hxx>
+#include "sddllapi.h"
 #include <memory>
 
 class ScrollBar;
@@ -138,7 +139,8 @@ public:
 
     view::SlideSorterView& GetView() const;
 
-    controller::SlideSorterController& GetController() const;
+    // Exported for unit test
+    SD_DLLPUBLIC controller::SlideSorterController& GetController() const;
 
     /** Return the view shell that was given at construction.
         @return
diff --git a/sd/source/ui/inc/SlideSorterViewShell.hxx b/sd/source/ui/inc/SlideSorterViewShell.hxx
index c0b8e80..8338211 100644
--- a/sd/source/ui/inc/SlideSorterViewShell.hxx
+++ b/sd/source/ui/inc/SlideSorterViewShell.hxx
@@ -24,6 +24,7 @@
 #include "glob.hxx"
 #include <sfx2/shell.hxx>
 #include <sfx2/viewfac.hxx>
+#include "sddllapi.h"
 #include <memory>
 #include <vector>
 
@@ -69,7 +70,8 @@ public:
         pane is returned.  When no slidesorter is visible then NULL is
         returned.
     */
-    static SlideSorterViewShell* GetSlideSorter (ViewShellBase& rBase);
+    // Exported for unit test
+    SD_DLLPUBLIC static SlideSorterViewShell* GetSlideSorter(ViewShellBase& rBase);
 
     virtual SdPage* GetActualPage() override;
 
@@ -185,7 +187,8 @@ public:
     // handle SlideSorterView specially because AccessibleSlideSorterView doesn't inherit from AccessibleDocumentViewBase
     virtual void SwitchViewFireFocus( css::uno::Reference< css::accessibility::XAccessible > xAcc ) override;
 
-    SlideSorter& GetSlideSorter() const;
+    // Exported for unit test
+    SD_DLLPUBLIC SlideSorter& GetSlideSorter() const;
 
     /** Try to relocate all toplevel window elements to the given parent
         window.
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index c534b2f..7f097bc 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -360,7 +360,8 @@ public:
     //  virtual void OuterResizePixel(const Point &rPos, const Size &rSize);
     //  virtual void InnerResizePixel(const Point &rPos, const Size &rSize);
 
-    ViewShellBase& GetViewShellBase() const;
+    // Exported for unit test
+    SD_DLLPUBLIC ViewShellBase& GetViewShellBase() const;
 
     /** Return <TRUE/> when the called view shell is the main sub shell of
         its ViewShellBase object, i.e. is display in the center pane.  This
diff --git a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
index a33c304..83d01eb 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlideSorterController.hxx
@@ -30,6 +30,8 @@
 #include <tools/link.hxx>
 #include <tools/gen.hxx>
 
+#include "sddllapi.h"
+
 #include <memory>
 
 namespace sd { namespace slidesorter {
@@ -110,7 +112,8 @@ public:
 
     PageSelector& GetPageSelector();
     FocusManager& GetFocusManager();
-    controller::Clipboard& GetClipboard();
+    // Exported for unit test
+    SD_DLLPUBLIC controller::Clipboard& GetClipboard();
 
     /** Return the object that manages the scroll bars.
     */
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx
index 2180f22..01d4bb3 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsClipboard.hxx
@@ -28,6 +28,8 @@
 #include <tools/solar.h>
 #include <svx/svdpage.hxx>
 
+#include "sddllapi.h"
+
 #include <set>
 
 class SfxRequest;
@@ -71,8 +73,10 @@ public:
     void HandleSlotCall (SfxRequest& rRequest);
 
     void DoCut (vcl::Window* pWindow = nullptr);
-    void DoCopy (vcl::Window* pWindow = nullptr);
-    void DoPaste (vcl::Window* pWindow = nullptr);
+    // Exported for unit test
+    SD_DLLPUBLIC void DoCopy(vcl::Window* pWindow = nullptr);
+    // Exported for unit test
+    SD_DLLPUBLIC void DoPaste(vcl::Window* pWindow = nullptr);
     void DoDelete (vcl::Window* pWindow = nullptr);
 
     void StartDrag (
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 5cbef08..b0b602a 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1756,6 +1756,7 @@ OString SdrObject::stringify() const
     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());
 
     return aString.makeStringAndClear();
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index c019804..479657a 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1726,7 +1726,6 @@ SvMemoryStream::~SvMemoryStream()
 
 const void* SvMemoryStream::GetBuffer()
 {
-    Flush();
     return GetData();
 }
 


More information about the Libreoffice-commits mailing list