svx/source/svdraw/svdsnpv.cxx          |    3 
 sw/CppunitTest_sw_snap_to_grid.mk      |   65 +++++++++
 sw/Module_sw.mk                        |    1 
 sw/qa/extras/snaptogrid/snaptogrid.cxx |  223 +++++++++++++++++++++++++++++++++
 sw/qa/extras/uiwriter/uiwriter11.cxx   |   65 ---------
 5 files changed, 292 insertions(+), 65 deletions(-)

New commits:
commit 729633c91132a499f48a18098fe748af71240314
Author:     Tamás Zolnai <[email protected]>
AuthorDate: Mon Oct 6 08:39:33 2025 +0200
Commit:     Tamás Zolnai <[email protected]>
CommitDate: Mon Oct 6 08:39:33 2025 +0200

    testTryToMoveShape
    
    Change-Id: I41d8825adbfe771b38c4386ea57e21efd3521d40

diff --git a/sw/qa/extras/snaptogrid/snaptogrid.cxx 
b/sw/qa/extras/snaptogrid/snaptogrid.cxx
index d79b62251c19..5778f4f8dd53 100644
--- a/sw/qa/extras/snaptogrid/snaptogrid.cxx
+++ b/sw/qa/extras/snaptogrid/snaptogrid.cxx
@@ -172,6 +172,51 @@ CPPUNIT_TEST_FIXTURE(SwSnapToGridTest, testMoveShapeOnGrid)
     checkShapeSize(pObject, aStartSize.Width, aStartSize.Height);
 }
 
+CPPUNIT_TEST_FIXTURE(SwSnapToGridTest, testTryToMoveShape)
+{
+    // Apply grid options
+    const sal_Int32 nGridSize = 1016;
+    applyGridOptions(true, nGridSize, nGridSize, 0, 0);
+
+    // Load a document with a single shape
+    createSwDoc("snapToGridShape.fodt");
+
+    // Check original position / size of the shape (it's on the grid)
+    const awt::Point aStartPosition{ 4064, 1016 };
+    const awt::Size aStartSize{ 1016, 1016 };
+    SdrObject* pObject = getShapeObject(0);
+    checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y);
+    checkShapeSize(pObject, aStartSize.Width, aStartSize.Height);
+
+    const tools::Long nMove = nGridSize / 4; // Move distance is too small.
+
+    // Try to move the shape to the right
+    {
+        moveShape(pObject, nMove, 0);
+        checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y);
+    }
+
+    // Try to move the shape down
+    {
+        moveShape(pObject, 0, nMove);
+        checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y);
+    }
+
+    // Try to move the shape to the left
+    {
+        moveShape(pObject, -nMove, 0);
+        checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y);
+    }
+
+    // Try to move the shape up
+    {
+        moveShape(pObject, 0, -nMove);
+        checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y);
+    }
+
+    checkShapeSize(pObject, aStartSize.Width, aStartSize.Height);
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 
commit 5ba800e051fa87d8732c0d35e940d6584552467d
Author:     Tamás Zolnai <[email protected]>
AuthorDate: Mon Oct 6 06:55:24 2025 +0200
Commit:     Tamás Zolnai <[email protected]>
CommitDate: Mon Oct 6 08:35:13 2025 +0200

    Rework unit test.
    
    Change-Id: I80de270f8906c68cc2111cd8dad5f761a8f5d03a

diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx
index 541f59dc127c..a36dfe5ff2a6 100644
--- a/svx/source/svdraw/svdsnpv.cxx
+++ b/svx/source/svdraw/svdsnpv.cxx
@@ -407,8 +407,11 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const 
SdrPageView* pPV) const
             else
                 fx -= fSnapWidth / 2.0;
 
+            SAL_WARN( "SdrSnapView", "mbGridSnap, fx: " << fx);
             x = static_cast<tools::Long>((fx - 
static_cast<double>(gridOrigin.X())) / fSnapWidth);
+            SAL_WARN( "SdrSnapView", "mbGridSnap, x: " << x);
             x = static_cast<tools::Long>(static_cast<double>(x) * fSnapWidth + 
static_cast<double>(gridOrigin.X()));
+            SAL_WARN( "SdrSnapView", "mbGridSnap, x: " << x);
             dx = 0;
             SAL_WARN( "SdrSnapView", "mbGridSnap, new x: " << x);
         }
diff --git a/sw/qa/extras/snaptogrid/snaptogrid.cxx 
b/sw/qa/extras/snaptogrid/snaptogrid.cxx
index a7b02335e89f..d79b62251c19 100644
--- a/sw/qa/extras/snaptogrid/snaptogrid.cxx
+++ b/sw/qa/extras/snaptogrid/snaptogrid.cxx
@@ -29,51 +29,66 @@ public:
         : SwModelTestBase(u"/sw/qa/extras/snaptogrid/data/"_ustr)
     {
     }
+
+protected:
+    void applyGridOptions(const bool snapToGrid, const sal_Int32 resolutionX,
+                          const sal_Int32 resolutionY, const sal_Int32 
subdivisionX,
+                          const sal_Int32 subdivisionY);
+
+    SdrObject* getShapeObject(const size_t objectIndex);
+    void moveShape(const SdrObject* pObject, const tools::Long nMoveX, const 
tools::Long nMoveY);
+
+    void checkShapeSize(SdrObject* pObject, const sal_Int32 nWidth, const 
sal_Int32 nHeight);
+    void checkShapePosition(SdrObject* pObject, const sal_Int32 nX, const 
sal_Int32 nY);
 };
 
-CPPUNIT_TEST_FIXTURE(SwSnapToGridTest, testSnapToGridShape)
+void SwSnapToGridTest::applyGridOptions(const bool snapToGrid, const sal_Int32 
resolutionX,
+                                        const sal_Int32 resolutionY, const 
sal_Int32 subdivisionX,
+                                        const sal_Int32 subdivisionY)
 {
-    // Apply grid settings
     std::shared_ptr<comphelper::ConfigurationChanges> batch(
         comphelper::ConfigurationChanges::create());
-    officecfg::Office::Writer::Grid::Option::VisibleGrid::set(true, batch);
-    officecfg::Office::Writer::Grid::Option::SnapToGrid::set(true, batch);
-    officecfg::Office::Writer::Grid::Resolution::XAxis::set(1016, batch);
-    officecfg::Office::Writer::Grid::Resolution::YAxis::set(1016, batch);
-    officecfg::Office::Writer::Grid::Subdivision::XAxis::set(1, batch);
-    officecfg::Office::Writer::Grid::Subdivision::YAxis::set(1, batch);
+    officecfg::Office::Writer::Grid::Option::SnapToGrid::set(snapToGrid, 
batch);
+    officecfg::Office::Writer::Grid::Resolution::XAxis::set(resolutionX, 
batch);
+    officecfg::Office::Writer::Grid::Resolution::YAxis::set(resolutionY, 
batch);
+    officecfg::Office::Writer::Grid::Subdivision::XAxis::set(subdivisionX, 
batch);
+    officecfg::Office::Writer::Grid::Subdivision::YAxis::set(subdivisionY, 
batch);
     batch->commit();
+}
 
-    // Given a document with a single shape
-    createSwDoc("snapToGridShape.fodt");
-
-    // Check original position / size of the shape
-    uno::Reference<css::drawing::XShape> xShape = getShape(1);
-    CPPUNIT_ASSERT(xShape.is());
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(4064), xShape->getPosition().X);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
-
-    // Select the shape
+SdrObject* SwSnapToGridTest::getShapeObject(const size_t objectIndex)
+{
     SwDoc* pDoc = getSwDoc();
     CPPUNIT_ASSERT(pDoc);
+
     SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
     CPPUNIT_ASSERT(pWrtShell);
+
     SdrPage* pPage = 
pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
     CPPUNIT_ASSERT(pPage);
-    SdrObject* pObject = pPage->GetObj(0);
+
+    SdrObject* pObject = pPage->GetObj(objectIndex);
     CPPUNIT_ASSERT(pObject);
-    const bool bSelected = pWrtShell->SelectObj(Point(), 0, pObject);
-    CPPUNIT_ASSERT(bSelected);
-    const tools::Rectangle& rBoundRect = pObject->GetLastBoundRect();
 
-    // Move shape
+    return pObject;
+}
+
+void SwSnapToGridTest::moveShape(const SdrObject* pObject, const tools::Long 
nMoveX,
+                                 const tools::Long nMoveY)
+{
+    CPPUNIT_ASSERT(pObject);
+
+    const tools::Long nMoveXTwips = o3tl::toTwips(nMoveX, o3tl::Length::mm100);
+    const tools::Long nMoveYTwips = o3tl::toTwips(nMoveY, o3tl::Length::mm100);
+
+    const tools::Rectangle& rBoundRect = pObject->GetLastBoundRect();
     Point ptFrom(rBoundRect.Center().X(), rBoundRect.Center().Y());
-    Point ptTo(rBoundRect.Center().X() + 600, rBoundRect.Center().Y());
+    Point ptTo(rBoundRect.Center().X() + nMoveXTwips, rBoundRect.Center().Y() 
+ nMoveYTwips);
+
     vcl::Window& rEditWin = getSwDocShell()->GetView()->GetEditWin();
     Point aFrom = rEditWin.LogicToPixel(ptFrom);
     Point aTo = rEditWin.LogicToPixel(ptTo);
+
     MouseEvent aClickEvent(aFrom, 1, MouseEventModifiers::SIMPLECLICK, 
MOUSE_LEFT);
     rEditWin.MouseButtonDown(aClickEvent);
     MouseEvent aClickEvent2(aTo, 0, MouseEventModifiers::SIMPLEMOVE, 
MOUSE_LEFT);
@@ -82,12 +97,79 @@ CPPUNIT_TEST_FIXTURE(SwSnapToGridTest, testSnapToGridShape)
     MouseEvent aClickEvent3(aTo, 1, MouseEventModifiers::SIMPLECLICK, 
MOUSE_LEFT);
     rEditWin.MouseButtonUp(aClickEvent3);
     Scheduler::ProcessEventsToIdle();
+}
+
+void SwSnapToGridTest::checkShapeSize(SdrObject* pObject, const sal_Int32 
nWidth,
+                                      const sal_Int32 nHeight)
+{
+    CPPUNIT_ASSERT(pObject);
+
+    css::uno::Reference<css::drawing::XShape> xShape = pObject->getUnoShape();
+    CPPUNIT_ASSERT(xShape.is());
+
+    awt::Size aSize = xShape->getSize();
+    CPPUNIT_ASSERT_EQUAL(nWidth, aSize.Width);
+    CPPUNIT_ASSERT_EQUAL(nHeight, aSize.Height);
+}
+
+void SwSnapToGridTest::checkShapePosition(SdrObject* pObject, const sal_Int32 
nX,
+                                          const sal_Int32 nY)
+{
+    CPPUNIT_ASSERT(pObject);
+
+    css::uno::Reference<css::drawing::XShape> xShape = pObject->getUnoShape();
+    CPPUNIT_ASSERT(xShape.is());
+
+    awt::Point aPosition = xShape->getPosition();
+    CPPUNIT_ASSERT_EQUAL(nX, aPosition.X);
+    CPPUNIT_ASSERT_EQUAL(nY, aPosition.Y);
+}
+
+CPPUNIT_TEST_FIXTURE(SwSnapToGridTest, testMoveShapeOnGrid)
+{
+    // Apply grid options
+    const sal_Int32 nGridSize = 1016;
+    applyGridOptions(true, nGridSize, nGridSize, 0, 0);
+
+    // Load a document with a single shape
+    createSwDoc("snapToGridShape.fodt");
+
+    // Check original position / size of the shape (it's on the grid)
+    const awt::Point aStartPosition{ 4064, 1016 };
+    const awt::Size aStartSize{ 1016, 1016 };
+    SdrObject* pObject = getShapeObject(0);
+    checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y);
+    checkShapeSize(pObject, aStartSize.Width, aStartSize.Height);
+
+    // Move the shape one grid position to the right
+    {
+        const tools::Long nMove = nGridSize - 10;
+        moveShape(pObject, nMove, 0);
+        checkShapePosition(pObject, aStartPosition.X + nGridSize, 
aStartPosition.Y);
+    }
+
+    // Move the shape one grid position down
+    {
+        const tools::Long nMove = nGridSize + 10;
+        moveShape(pObject, 0, nMove);
+        checkShapePosition(pObject, aStartPosition.X + nGridSize, 
aStartPosition.Y + nGridSize);
+    }
+
+    // Move the shape one grid position to the left
+    {
+        const tools::Long nMove = nGridSize;
+        moveShape(pObject, -nMove, 0);
+        checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y + 
nGridSize);
+    }
+
+    // Move the shape one grid position up
+    {
+        const tools::Long nMove = nGridSize / 2 + 10;
+        moveShape(pObject, 0, -nMove);
+        checkShapePosition(pObject, aStartPosition.X, aStartPosition.Y);
+    }
 
-    // Check new position / size of the shape
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(5080), xShape->getPosition().X);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
+    checkShapeSize(pObject, aStartSize.Width, aStartSize.Height);
 }
 
 } // end of anonymous namespace
commit 9c8f3dd94790c4eaac5d724e4063e74beb7075a2
Author:     Tamás Zolnai <[email protected]>
AuthorDate: Mon Oct 6 05:46:54 2025 +0200
Commit:     Tamás Zolnai <[email protected]>
CommitDate: Mon Oct 6 06:07:57 2025 +0200

    Add separate test suite for snap to grid tests.
    
    Change-Id: I404ce94bdafe6dae8f3f692be8cf89d1e3f4a157

diff --git a/sw/CppunitTest_sw_snap_to_grid.mk 
b/sw/CppunitTest_sw_snap_to_grid.mk
new file mode 100644
index 000000000000..2ce5fed62eef
--- /dev/null
+++ b/sw/CppunitTest_sw_snap_to_grid.mk
@@ -0,0 +1,65 @@
+$(eval $(call gb_CppunitTest_CppunitTest,sw_snap_to_grid))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_snap_to_grid))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_snap_to_grid, \
+    sw/qa/extras/snaptogrid/snaptogrid \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_snap_to_grid, \
+    comphelper \
+    cppu \
+    cppuhelper \
+    docmodel \
+    editeng \
+    i18nlangtag \
+    msword \
+    sal \
+    sfx \
+    subsequenttest \
+    svl \
+    svt \
+    svxcore \
+    sw \
+    swqahelper \
+    test \
+    unotest \
+    vcl \
+    tl \
+    utl \
+    svx \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_snap_to_grid,\
+       boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_snap_to_grid,\
+    officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_snap_to_grid,\
+    -I$(SRCDIR)/sw/inc \
+    -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/source/uibase/inc \
+    -I$(SRCDIR)/sw/qa/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_snap_to_grid,\
+       udkapi \
+       offapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_snap_to_grid))
+$(eval $(call gb_CppunitTest_use_vcl,sw_snap_to_grid))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_snap_to_grid,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_snap_to_grid))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_snap_to_grid,\
+    modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_snap_to_grid))
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index d0b8b48f6254..79c672ae8c3e 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -193,6 +193,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_writerfilter_ooxml \
     CppunitTest_sw_writerfilter_rtftok \
     CppunitTest_sw_writerfilter_filter \
+    CppunitTest_sw_snap_to_grid \
 ))
 
 ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/extras/uiwriter/data/snapToGridShape.fodt 
b/sw/qa/extras/snaptogrid/data/snapToGridShape.fodt
similarity index 100%
rename from sw/qa/extras/uiwriter/data/snapToGridShape.fodt
rename to sw/qa/extras/snaptogrid/data/snapToGridShape.fodt
diff --git a/sw/qa/extras/snaptogrid/snaptogrid.cxx 
b/sw/qa/extras/snaptogrid/snaptogrid.cxx
new file mode 100644
index 000000000000..a7b02335e89f
--- /dev/null
+++ b/sw/qa/extras/snaptogrid/snaptogrid.cxx
@@ -0,0 +1,96 @@
+/* -*- 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 <swmodeltestbase.hxx>
+#include <comphelper/configuration.hxx>
+#include <officecfg/Office/Writer.hxx>
+#include <IDocumentDrawModelAccess.hxx>
+#include <docsh.hxx>
+#include <drawdoc.hxx>
+#include <svx/svdpage.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <vcl/event.hxx>
+#include <vcl/scheduler.hxx>
+
+namespace
+{
+class SwSnapToGridTest : public SwModelTestBase
+{
+public:
+    SwSnapToGridTest()
+        : SwModelTestBase(u"/sw/qa/extras/snaptogrid/data/"_ustr)
+    {
+    }
+};
+
+CPPUNIT_TEST_FIXTURE(SwSnapToGridTest, testSnapToGridShape)
+{
+    // Apply grid settings
+    std::shared_ptr<comphelper::ConfigurationChanges> batch(
+        comphelper::ConfigurationChanges::create());
+    officecfg::Office::Writer::Grid::Option::VisibleGrid::set(true, batch);
+    officecfg::Office::Writer::Grid::Option::SnapToGrid::set(true, batch);
+    officecfg::Office::Writer::Grid::Resolution::XAxis::set(1016, batch);
+    officecfg::Office::Writer::Grid::Resolution::YAxis::set(1016, batch);
+    officecfg::Office::Writer::Grid::Subdivision::XAxis::set(1, batch);
+    officecfg::Office::Writer::Grid::Subdivision::YAxis::set(1, batch);
+    batch->commit();
+
+    // Given a document with a single shape
+    createSwDoc("snapToGridShape.fodt");
+
+    // Check original position / size of the shape
+    uno::Reference<css::drawing::XShape> xShape = getShape(1);
+    CPPUNIT_ASSERT(xShape.is());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4064), xShape->getPosition().X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
+
+    // Select the shape
+    SwDoc* pDoc = getSwDoc();
+    CPPUNIT_ASSERT(pDoc);
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+    SdrPage* pPage = 
pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    CPPUNIT_ASSERT(pPage);
+    SdrObject* pObject = pPage->GetObj(0);
+    CPPUNIT_ASSERT(pObject);
+    const bool bSelected = pWrtShell->SelectObj(Point(), 0, pObject);
+    CPPUNIT_ASSERT(bSelected);
+    const tools::Rectangle& rBoundRect = pObject->GetLastBoundRect();
+
+    // Move shape
+    Point ptFrom(rBoundRect.Center().X(), rBoundRect.Center().Y());
+    Point ptTo(rBoundRect.Center().X() + 600, rBoundRect.Center().Y());
+    vcl::Window& rEditWin = getSwDocShell()->GetView()->GetEditWin();
+    Point aFrom = rEditWin.LogicToPixel(ptFrom);
+    Point aTo = rEditWin.LogicToPixel(ptTo);
+    MouseEvent aClickEvent(aFrom, 1, MouseEventModifiers::SIMPLECLICK, 
MOUSE_LEFT);
+    rEditWin.MouseButtonDown(aClickEvent);
+    MouseEvent aClickEvent2(aTo, 0, MouseEventModifiers::SIMPLEMOVE, 
MOUSE_LEFT);
+    rEditWin.MouseMove(aClickEvent2);
+    rEditWin.MouseMove(aClickEvent2);
+    MouseEvent aClickEvent3(aTo, 1, MouseEventModifiers::SIMPLECLICK, 
MOUSE_LEFT);
+    rEditWin.MouseButtonUp(aClickEvent3);
+    Scheduler::ProcessEventsToIdle();
+
+    // Check new position / size of the shape
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5080), xShape->getPosition().X);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
+}
+
+} // end of anonymous namespace
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter11.cxx 
b/sw/qa/extras/uiwriter/uiwriter11.cxx
index f250a2f82601..baef7da824be 100644
--- a/sw/qa/extras/uiwriter/uiwriter11.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter11.cxx
@@ -18,7 +18,6 @@
 #include <AnnotationWin.hxx>
 #include <cmdid.h>
 #include <docufld.hxx>
-#include <drawdoc.hxx>
 #include <edtwin.hxx>
 #include <PostItMgr.hxx>
 #include <view.hxx>
@@ -26,12 +25,7 @@
 #include <unotxdoc.hxx>
 #include <ndtxt.hxx>
 #include <svx/svxids.hrc>
-#include <svx/svdpage.hxx>
-#include <swdtflvr.hxx>
 #include <IDocumentLayoutAccess.hxx>
-#include <IDocumentDrawModelAccess.hxx>
-#include <officecfg/Office/Writer.hxx>
-#include <vcl/event.hxx>
 
 namespace
 {
@@ -380,65 +374,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791)
     }
 }
 
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testSnapToGridShape)
-{
-    // Apply grid settings
-    std::shared_ptr<comphelper::ConfigurationChanges> batch(
-        comphelper::ConfigurationChanges::create());
-    officecfg::Office::Writer::Grid::Option::VisibleGrid::set(true, batch);
-    officecfg::Office::Writer::Grid::Option::SnapToGrid::set(true, batch);
-    officecfg::Office::Writer::Grid::Resolution::XAxis::set(1016, batch);
-    officecfg::Office::Writer::Grid::Resolution::YAxis::set(1016, batch);
-    officecfg::Office::Writer::Grid::Subdivision::XAxis::set(1, batch);
-    officecfg::Office::Writer::Grid::Subdivision::YAxis::set(1, batch);
-    batch->commit();
-
-    // Given a document with a single shape
-    createSwDoc("snapToGridShape.fodt");
-
-    // Check original position / size of the shape
-    uno::Reference<css::drawing::XShape> xShape = getShape(1);
-    CPPUNIT_ASSERT(xShape.is());
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(4064), xShape->getPosition().X);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
-
-    // Select the shape
-    SwDoc* pDoc = getSwDoc();
-    CPPUNIT_ASSERT(pDoc);
-    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
-    CPPUNIT_ASSERT(pWrtShell);
-    SdrPage* pPage = 
pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
-    CPPUNIT_ASSERT(pPage);
-    SdrObject* pObject = pPage->GetObj(0);
-    CPPUNIT_ASSERT(pObject);
-    const bool bSelected = pWrtShell->SelectObj(Point(), 0, pObject);
-    CPPUNIT_ASSERT(bSelected);
-    const tools::Rectangle& rBoundRect = pObject->GetLastBoundRect();
-
-    // Move shape
-    Point ptFrom(rBoundRect.Center().X(), rBoundRect.Center().Y());
-    Point ptTo(rBoundRect.Center().X() + 600, rBoundRect.Center().Y());
-    vcl::Window& rEditWin = getSwDocShell()->GetView()->GetEditWin();
-    Point aFrom = rEditWin.LogicToPixel(ptFrom);
-    Point aTo = rEditWin.LogicToPixel(ptTo);
-    MouseEvent aClickEvent(aFrom, 1, MouseEventModifiers::SIMPLECLICK, 
MOUSE_LEFT);
-    rEditWin.MouseButtonDown(aClickEvent);
-    MouseEvent aClickEvent2(aTo, 0, MouseEventModifiers::SIMPLEMOVE, 
MOUSE_LEFT);
-    rEditWin.MouseMove(aClickEvent2);
-    rEditWin.MouseMove(aClickEvent2);
-    MouseEvent aClickEvent3(aTo, 1, MouseEventModifiers::SIMPLECLICK, 
MOUSE_LEFT);
-    rEditWin.MouseButtonUp(aClickEvent3);
-    Scheduler::ProcessEventsToIdle();
-
-    // Check new position / size of the shape
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(5080), xShape->getPosition().X);
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
-}
-
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 

Reply via email to