[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - 2 commits - sc/qa sd/qa svx/source sw/qa

merttumer (via logerrit) logerrit at kemper.freedesktop.org
Mon May 31 03:54:03 UTC 2021


 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   52 +++++++++++++++++++++
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |   54 ++++++++++++++++++++++
 svx/source/table/tablecontroller.cxx           |   30 +++++++++---
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   60 +++++++++++++++++++++++++
 4 files changed, 188 insertions(+), 8 deletions(-)

New commits:
commit 0f94dd7975e19e40665a74fd8c847f1213825d79
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Mon May 17 05:52:01 2021 +0300
Commit:     Mert Tumer <mert.tumer at collabora.com>
CommitDate: Mon May 31 05:53:45 2021 +0200

    Implemented Delete key deletes the table when all the cells are selected
    
    Change-Id: I8a17c73781a3399b214d5655b83036652933a90a
    Signed-off-by: merttumer <mert.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115689
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116309

diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 4ad539380e63..9b1cfd516b3d 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -1424,30 +1424,44 @@ bool SvxTableController::DeleteMarked()
     SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const bool bUndo(rModel.IsUndoEnabled());
+    bool bDeleteTable = false;
 
     if (bUndo)
         rModel.BegUndo(SvxResId(STR_TABLE_DELETE_CELL_CONTENTS));
 
     CellPos aStart, aEnd;
     getSelectedCells( aStart, aEnd );
-    for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+    const sal_Int32 nRemovedColumns = aEnd.mnCol - aStart.mnCol + 1;
+    const sal_Int32 nRemovedRows = aEnd.mnRow - aStart.mnRow + 1;
+    if( nRemovedColumns == mxTable->getColumnCount() && nRemovedRows == mxTable->getRowCount())
     {
-        for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+        bDeleteTable = true;
+    }
+    else
+    {
+        for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
         {
-            CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
-            if (xCell.is() && xCell->hasText())
+            for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
             {
-                if (bUndo)
-                    xCell->AddUndo();
-                xCell->SetOutlinerParaObject(nullptr);
+                CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+                if (xCell.is() && xCell->hasText())
+                {
+                    if (bUndo)
+                        xCell->AddUndo();
+                    xCell->SetOutlinerParaObject(nullptr);
+                }
             }
         }
     }
 
+    if (bDeleteTable)
+        mrView.DeleteMarkedObj();
+
     if (bUndo)
         rModel.EndUndo();
 
-    UpdateTableShape();
+    if (!bDeleteTable)
+        UpdateTableShape();
     return true;
 }
 
commit e39f6b4d296ce9325ff3910c9cf25ca689c0eedb
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Thu May 13 11:21:11 2021 +0300
Commit:     Mert Tumer <mert.tumer at collabora.com>
CommitDate: Mon May 31 05:53:30 2021 +0200

    Unit tests for .uno:MoveShapeHandle command
    
    Change-Id: Ia1049325bf26fbe6a3c8ac77c873d1af010d3581
    Signed-off-by: merttumer <mert.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115541
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116308

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 80e0f7b2e2f0..620e79541a28 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -120,6 +120,7 @@ public:
     void testSortAscendingDescending();
     void testAutoInputStringBlock();
     void testAutoInputExactMatch();
+    void testMoveShapeHandle();
 
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
@@ -171,6 +172,7 @@ public:
     CPPUNIT_TEST(testSortAscendingDescending);
     CPPUNIT_TEST(testAutoInputStringBlock);
     CPPUNIT_TEST(testAutoInputExactMatch);
+    CPPUNIT_TEST(testMoveShapeHandle);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -448,6 +450,7 @@ public:
     boost::property_tree::ptree m_aCommentCallbackResult;
     OString m_sInvalidateHeader;
     OString m_sInvalidateSheetGeometry;
+    OString m_ShapeSelection;
 
     ViewCallback(bool bDeleteListenerOnDestruct=true)
         : m_bOwnCursorInvalidated(false),
@@ -510,6 +513,7 @@ public:
         case LOK_CALLBACK_GRAPHIC_SELECTION:
         {
             m_bGraphicSelection = true;
+            m_ShapeSelection = OString(pPayload);
         }
         break;
         case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
@@ -670,6 +674,54 @@ void ScTiledRenderingTest::testViewLock()
     CPPUNIT_ASSERT(!aView1.m_bViewLock);
 }
 
+static void lcl_extractHandleParameters(const OString& selection, int& id, int& x, int& y)
+{
+    OString extraInfo = selection.copy(selection.indexOf("{"));
+    std::stringstream aStream(extraInfo.getStr());
+    boost::property_tree::ptree aTree;
+    boost::property_tree::read_json(aStream, aTree);
+    boost::property_tree::ptree
+        handle0 = aTree
+            .get_child("handles")
+            .get_child("kinds")
+            .get_child("rectangle")
+            .get_child("1")
+            .begin()->second;
+    id = handle0.get_child("id").get_value<int>();
+    x = handle0.get_child("point").get_child("x").get_value<int>();
+    y = handle0.get_child("point").get_child("y").get_value<int>();
+}
+
+void ScTiledRenderingTest::testMoveShapeHandle()
+{
+    comphelper::LibreOfficeKit::setActive();
+    ScModelObj* pModelObj = createDoc("shape.ods");
+    ViewCallback aView1;
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, /*x=*/ 1,/*y=*/ 1,/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+    pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, /*x=*/ 1, /*y=*/ 1, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+    {
+        int id, x, y;
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        int oldX = x;
+        int oldY = y;
+        uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+        {
+            {"HandleNum", uno::makeAny(id)},
+            {"NewPosX", uno::makeAny(x+1)},
+            {"NewPosY", uno::makeAny(y+1)}
+        }));
+        comphelper::dispatchCommand(".uno:MoveShapeHandle", aPropertyValues);
+        Scheduler::ProcessEventsToIdle();
+        CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        CPPUNIT_ASSERT_EQUAL(x-1, oldX);
+        CPPUNIT_ASSERT_EQUAL(y-1, oldY);
+    }
+}
+
 void ScTiledRenderingTest::testColRowResize()
 {
     comphelper::LibreOfficeKit::setActive();
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index d8d8ed089533..fe6ee4e628b7 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -131,6 +131,7 @@ public:
     void testInsertDeletePageInvalidation();
     void testSpellOnlineRenderParameter();
     void testSlideDuplicateUndo();
+    void testMoveShapeHandle();
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
     CPPUNIT_TEST(testCreateDestroy);
@@ -186,6 +187,7 @@ public:
     CPPUNIT_TEST(testInsertDeletePageInvalidation);
     CPPUNIT_TEST(testSpellOnlineRenderParameter);
     CPPUNIT_TEST(testSlideDuplicateUndo);
+    CPPUNIT_TEST(testMoveShapeHandle);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -866,6 +868,7 @@ public:
     std::map<int, bool> m_aViewCursorVisibilities;
     bool m_bViewSelectionSet;
     boost::property_tree::ptree m_aCommentCallbackResult;
+    OString m_ShapeSelection;
 
     ViewCallback()
         : m_bGraphicSelectionInvalidated(false),
@@ -917,6 +920,7 @@ public:
         case LOK_CALLBACK_GRAPHIC_SELECTION:
         {
             m_bGraphicSelectionInvalidated = true;
+            m_ShapeSelection = OString(pPayload);
         }
         break;
         case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
@@ -2594,6 +2598,56 @@ void SdTiledRenderingTest::testSlideDuplicateUndo()
     CPPUNIT_ASSERT(!pView0->GetTextEditPageView());
 }
 
+static void lcl_extractHandleParameters(const OString& selection, int& id, int& x, int& y)
+{
+    OString extraInfo = selection.copy(selection.indexOf("{"));
+    std::stringstream aStream(extraInfo.getStr());
+    boost::property_tree::ptree aTree;
+    boost::property_tree::read_json(aStream, aTree);
+    boost::property_tree::ptree
+        handle0 = aTree
+            .get_child("handles")
+            .get_child("kinds")
+            .get_child("rectangle")
+            .get_child("1")
+            .begin()->second;
+    id = handle0.get_child("id").get_value<int>();
+    x = handle0.get_child("point").get_child("x").get_value<int>();
+    y = handle0.get_child("point").get_child("y").get_value<int>();
+}
+
+void SdTiledRenderingTest::testMoveShapeHandle()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+    ViewCallback aView1;
+    sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+    SdPage* pPage = pViewShell->GetActualPage();
+    SdrObject* pObject = pPage->GetObj(0);
+    SdrView* pView = pViewShell->GetView();
+    pView->MarkObj(pObject, pView->GetSdrPageView());
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+    {
+        int id, x, y;
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        int oldX = x;
+        int oldY = y;
+        uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+        {
+            {"HandleNum", uno::makeAny(id)},
+            {"NewPosX", uno::makeAny(x+1)},
+            {"NewPosY", uno::makeAny(y+1)}
+        }));
+        comphelper::dispatchCommand(".uno:MoveShapeHandle", aPropertyValues);
+        Scheduler::ProcessEventsToIdle();
+        CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty());
+        lcl_extractHandleParameters(aView1.m_ShapeSelection, id, x ,y);
+        CPPUNIT_ASSERT_EQUAL(x-1, oldX);
+        CPPUNIT_ASSERT_EQUAL(y-1, oldY);
+    }
+
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index a0aea532d7c1..2add6e6237c6 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -155,6 +155,7 @@ public:
     void testBulletNoNumInvalidation();
     void testBulletMultiDeleteInvalidation();
     void testCondCollCopy();
+    void testMoveShapeHandle();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -233,6 +234,7 @@ public:
     CPPUNIT_TEST(testBulletNoNumInvalidation);
     CPPUNIT_TEST(testBulletMultiDeleteInvalidation);
     CPPUNIT_TEST(testCondCollCopy);
+    CPPUNIT_TEST(testMoveShapeHandle);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -257,6 +259,7 @@ private:
     OString m_sHyperlinkText;
     OString m_sHyperlinkLink;
     OString m_aFormFieldButton;
+    OString m_ShapeSelection;
 };
 
 SwTiledRenderingTest::SwTiledRenderingTest()
@@ -416,7 +419,13 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
         m_aFormFieldButton = OString(pPayload);
     }
     break;
+    case LOK_CALLBACK_GRAPHIC_SELECTION:
+    {
+        m_ShapeSelection = OString(pPayload);
+    }
+    break;
     }
+
 }
 
 void SwTiledRenderingTest::testRegisterCallback()
@@ -2822,6 +2831,57 @@ void SwTiledRenderingTest::testDropDownFormFieldButtonNoSelection()
     }
 }
 
+static void lcl_extractHandleParameters(const OString& selection, int& id, int& x, int& y)
+{
+    OString extraInfo = selection.copy(selection.indexOf("{"));
+    std::stringstream aStream(extraInfo.getStr());
+    boost::property_tree::ptree aTree;
+    boost::property_tree::read_json(aStream, aTree);
+    boost::property_tree::ptree
+        handle0 = aTree
+            .get_child("handles")
+            .get_child("kinds")
+            .get_child("rectangle")
+            .get_child("1")
+            .begin()->second;
+    id = handle0.get_child("id").get_value<int>();
+    x = handle0.get_child("point").get_child("x").get_value<int>();
+    y = handle0.get_child("point").get_child("y").get_value<int>();
+}
+
+void SwTiledRenderingTest::testMoveShapeHandle()
+{
+    comphelper::LibreOfficeKit::setActive();
+    SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+
+    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+    pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+    SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    SdrObject* pObject = pPage->GetObj(0);
+    pWrtShell->SelectObj(Point(), 0, pObject);
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(!m_ShapeSelection.isEmpty());
+    {
+        int id, x, y;
+        lcl_extractHandleParameters(m_ShapeSelection, id, x ,y);
+        int oldX = x;
+        int oldY = y;
+        uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+        {
+            {"HandleNum", uno::makeAny(id)},
+            {"NewPosX", uno::makeAny(x+1)},
+            {"NewPosY", uno::makeAny(y+1)}
+        }));
+        comphelper::dispatchCommand(".uno:MoveShapeHandle", aPropertyValues);
+        Scheduler::ProcessEventsToIdle();
+        CPPUNIT_ASSERT(!m_ShapeSelection.isEmpty());
+        lcl_extractHandleParameters(m_ShapeSelection, id, x ,y);
+        CPPUNIT_ASSERT_EQUAL(x-1, oldX);
+        CPPUNIT_ASSERT_EQUAL(y-1, oldY);
+    }
+}
+
 void SwTiledRenderingTest::testDropDownFormFieldButtonNoItem()
 {
     SwXTextDocument* pXTextDocument = createDoc("drop_down_form_field_noitem.odt");


More information about the Libreoffice-commits mailing list