[Libreoffice-commits] core.git: sc/qa sc/source

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 15 19:07:00 UTC 2021


 sc/qa/unit/uicalc/uicalc.cxx   |   77 +++++++++++------------------------------
 sc/source/ui/inc/viewfunc.hxx  |    2 -
 sc/source/ui/view/viewfun3.cxx |    4 +-
 3 files changed, 24 insertions(+), 59 deletions(-)

New commits:
commit 8a7b46c0372eb2445c0bd35c1ebe4a7c96115e5c
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Mar 15 16:19:53 2021 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Mar 15 20:06:22 2021 +0100

    sc_uicalc: use UNO commands for copy, cut or paste everywhere
    
    It's fine to use them since
    043c67e0f7358753a2007b7c2bb6cc68aeea7ecb
    < dummy clipboard for unit tests >
    
    While at it, remove a couple of obsolete FIXME comments
    
    Partially revert 9fd193168fe092bf15edbc81b8b1a15ca6d7c032
    < tdf#118207: tdf#118189: sc: Move UItest to CppUnitTest >
    since CutToClip is no longer used
    
    Change-Id: I73959fbc810dc5e82b76862338814e720dc97d89
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112533
    Tested-by: Jenkins

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index c6e421569395..6d161ab81c23 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -179,14 +179,11 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100582)
 
     goToCell("C10");
 
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     goToCell("C10:H14");
 
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     pModelObj = saveAndReload(mxComponent, "MS Excel 97");
     pDoc = pModelObj->GetDocument();
@@ -264,15 +261,11 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf92963)
 
     goToCell("A3:C4");
 
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     goToCell("A1:C1");
 
-    // Without the fix in place, this test would have crashed here
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     CPPUNIT_ASSERT_EQUAL(size_t(2), pList->size());
 
@@ -385,14 +378,11 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf120660)
 
     goToCell("A8:E8");
 
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     goToCell("A4:E4");
 
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     CPPUNIT_ASSERT_EQUAL(1200.0, pDoc->GetValue(ScAddress(4, 3, 0)));
     CPPUNIT_ASSERT_EQUAL(-100.0, pDoc->GetValue(ScAddress(4, 7, 0)));
@@ -404,13 +394,11 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf120660)
 
     goToCell("A8:D8");
 
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     goToCell("A4:D4");
 
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     CPPUNIT_ASSERT_EQUAL(1200.0, pDoc->GetValue(ScAddress(4, 3, 0)));
 
@@ -455,7 +443,6 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf117706)
     dispatchCommand(mxComponent, ".uno:SelectRow", {});
     Scheduler::ProcessEventsToIdle();
 
-    // FIXME: The rows are not copied/pasted if using CopyToClip/PasteToClip
     dispatchCommand(mxComponent, ".uno:Copy", {});
 
     mxComponent->dispose();
@@ -598,16 +585,11 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf108654)
 
     dispatchCommand(mxComponent, ".uno:SelectAll", {});
 
-    // .uno:Copy without touching shared clipboard
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     insertNewSheet(*pDoc);
 
-    // .uno:Paste without touching shared clipboard
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     OUString aFormula;
     pDoc->GetFormula(3, 126, 1, aFormula);
@@ -634,10 +616,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326)
 
     dispatchCommand(mxComponent, ".uno:SelectAll", {});
 
-    // .uno:Copy without touching shared clipboard
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     insertNewSheet(*pDoc);
 
@@ -645,9 +624,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326)
     pDoc->GetFormula(0, 0, 1, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
 
-    // .uno:Paste without touching shared clipboard
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     pDoc->GetFormula(0, 0, 1, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString("=RAND()*1000000"), aFormula);
@@ -863,7 +840,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124822)
     dispatchCommand(mxComponent, ".uno:SelectAll", {});
     Scheduler::ProcessEventsToIdle();
 
-    ScDocShell::GetViewData()->GetView()->CutToClip();
+    dispatchCommand(mxComponent, ".uno:Cut", {});
 
     CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(0, 0, 2)));
 
@@ -883,8 +860,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf118189)
     // Select column A
     goToCell("A:A");
 
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     mxComponent->dispose();
 
@@ -895,14 +871,13 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf118189)
     pDoc = pModelObj->GetDocument();
     CPPUNIT_ASSERT(pDoc);
 
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     OUString aFormula;
     pDoc->GetFormula(0, 77, 0, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString("=FALSE()"), aFormula);
 
-    ScDocShell::GetViewData()->GetView()->CutToClip();
+    dispatchCommand(mxComponent, ".uno:Cut", {});
 
     pDoc->GetFormula(0, 77, 0, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
@@ -936,8 +911,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf118207)
     pDoc->GetFormula(0, 77, 0, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString("=FALSE()"), aFormula);
 
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CutToClip(&aClipDoc);
+    dispatchCommand(mxComponent, ".uno:Cut", {});
 
     pDoc->GetFormula(0, 77, 0, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
@@ -945,14 +919,12 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf118207)
     // Select column B
     goToCell("B:B");
 
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     pDoc->GetFormula(1, 77, 0, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString("=FALSE()"), aFormula);
 
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     pDoc->GetFormula(1, 77, 0, aFormula);
     CPPUNIT_ASSERT_EQUAL(OUString("=FALSE()"), aFormula);
@@ -1029,17 +1001,12 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138428)
     CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", pDoc->HasNote(ScAddress(0, 0, 0)));
     CPPUNIT_ASSERT_MESSAGE("There shouldn't be a note on B1", !pDoc->HasNote(ScAddress(1, 0, 0)));
 
-    // .uno:Copy without touching shared clipboard
-    ScDocument aClipDoc(SCDOCMODE_CLIP);
-    ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Copy", {});
 
     dispatchCommand(mxComponent, ".uno:GoRight", {});
     lcl_AssertCurrentCursorPosition(1, 0);
 
-    // .uno:Paste without touching shared clipboard
-    ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc);
-    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:Paste", {});
 
     CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", pDoc->HasNote(ScAddress(0, 0, 0)));
     CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", pDoc->HasNote(ScAddress(1, 0, 0)));
@@ -1106,7 +1073,6 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf130614)
 
     lcl_SelectObjectByName(u"Object 1");
 
-    // FIXME: The OLE object is not copied/pasted if using CopyToClip/PasteToClip
     dispatchCommand(mxComponent, ".uno:Copy", {});
     Scheduler::ProcessEventsToIdle();
 
@@ -1121,7 +1087,6 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf130614)
 
     // Without the fix in place, this test would have crashed here
     dispatchCommand(mxComponent, ".uno:Paste", {});
-    Scheduler::ProcessEventsToIdle();
 
     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
     SdrPage* pPage = pDrawLayer->GetPage(0);
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 9431c9aa16da..7515c9e93858 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -107,7 +107,7 @@ public:
 
     void            EnterDataAtCursor( const OUString& rString );         //! Not used?
 
-    SC_DLLPUBLIC void           CutToClip(ScDocument* pClipDoc = nullptr);
+    SC_DLLPUBLIC void           CutToClip();
     SC_DLLPUBLIC bool           CopyToClip( ScDocument* pClipDoc, bool bCut, bool bApi = false,
                                             bool bIncludeObjects = false, bool bStopEdit = true );
     SC_DLLPUBLIC bool           CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRange, bool bCut,
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index e4ba7302799e..e6439ffc04b9 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -85,7 +85,7 @@ void collectUIInformation(const std::map<OUString, OUString>& aParameters, const
 
 //      C U T
 
-void ScViewFunc::CutToClip(ScDocument* pClipDoc)
+void ScViewFunc::CutToClip()
 {
     UpdateInputLine();
 
@@ -114,7 +114,7 @@ void ScViewFunc::CutToClip(ScDocument* pClipDoc)
             MarkDataChanged();
         }
 
-        CopyToClip( pClipDoc, true, false, true/*bIncludeObjects*/ );           // copy to clipboard
+        CopyToClip( nullptr, true, false, true/*bIncludeObjects*/ );           // copy to clipboard
 
         ScAddress aOldEnd( aRange.aEnd );       //  combined cells in this range?
         rDoc.ExtendMerge( aRange, true );


More information about the Libreoffice-commits mailing list