sc/source/ui/inc/gridwin.hxx   |    2 ++
 sc/source/ui/view/gridwin.cxx  |    1 +
 sc/source/ui/view/gridwin3.cxx |   21 +++++++++++++++++++--
 3 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit 677e40c8b83b06ded8e06b6151f71686baf5f6b5
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Mon Apr 14 11:59:22 2025 +0200
Commit:     Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
CommitDate: Tue Apr 22 17:03:43 2025 +0200

    tdf#166177 Fixes unintended switch to rotate mode
    
    Fixes switch to rotate mode after inserting or
    moving a shape.
    
    Change-Id: I4e8ce8b5891a08c6c3f20a9c29fa4bef4428eb84
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184141
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index d347c32900c2..249876d750d8 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -212,6 +212,8 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public 
vcl::DocWindow, public DropTarget
     ScAddress               aAutoMarkPos;
     ScAddress               aListValPos;
 
+    Point                   aDrawSelectionPos;
+
     tools::Rectangle               aInvertRect;
 
     RfCorner                aRFSelectedCorned;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3398a2b14d97..faaa9ba51c82 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -390,6 +390,7 @@ ScGridWindow::ScGridWindow( vcl::Window* pParent, 
ScViewData& rData, ScSplitPos
             aComboButton( GetOutDev() ),
             aCurMousePos( 0,0 ),
             nPaintCount( 0 ),
+            aDrawSelectionPos( 0,0 ),
             aRFSelectedCorned( NONE ),
             maShowPageBreaksTimer("ScGridWindow maShowPageBreaksTimer"),
             bEEMouse( false ),
diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx
index 48342b299fb3..3b257fabc226 100644
--- a/sc/source/ui/view/gridwin3.cxx
+++ b/sc/source/ui/view/gridwin3.cxx
@@ -31,6 +31,7 @@
 #include <output.hxx>
 #include <drawview.hxx>
 #include <fupoor.hxx>
+#include <fusel.hxx>
 #include <scmod.hxx>
 #include <appoptio.hxx>
 
@@ -51,6 +52,12 @@ static bool lcl_HasSelectionChanged(const SdrMarkList & 
rBeforeList, const SdrMa
     return false;
 }
 
+static bool lcl_PosUnchanged(const tools::Rectangle& rSelectionRect, const 
Point& rDrawSelectionPos)
+{
+    return rDrawSelectionPos.X() == rSelectionRect.Left() &&
+        rDrawSelectionPos.Y() == rSelectionRect.Top();
+}
+
 bool ScGridWindow::DrawMouseButtonDown(const MouseEvent& rMEvt)
 {
     bool bRet = false;
@@ -67,6 +74,15 @@ bool ScGridWindow::DrawMouseButtonDown(const MouseEvent& 
rMEvt)
 
         pDraw->SetWindow( this );
         Point aLogicPos = PixelToLogic(rMEvt.GetPosPixel());
+        SdrMarkList aPreMarkList = pDrView->GetMarkedObjectList();
+        if(!aPreMarkList.GetMarkCount())
+            aDrawSelectionPos = Point(0,0);
+        else
+        {
+            tools::Rectangle aRect = pDrView->GetAllMarkedRect();
+            aDrawSelectionPos = Point(aRect.Left(), aRect.Top());
+        }
+
         if ( pDraw->IsDetectiveHit( aLogicPos ) )
         {
             // nothing on detective arrows (double click is evaluated on 
ButtonUp)
@@ -74,7 +90,6 @@ bool ScGridWindow::DrawMouseButtonDown(const MouseEvent& 
rMEvt)
         }
         else
         {
-            SdrMarkList aPreMarkList = pDrView->GetMarkedObjectList();
             bRet = pDraw->MouseButtonDown( rMEvt );
             if (bRet)
             {
@@ -130,7 +145,9 @@ bool ScGridWindow::DrawMouseButtonUp(const MouseEvent& 
rMEvt)
                  && rMEvt.IsLeft()
                  && rMEvt.GetClicks() == 1
             && ScModule::get()->GetAppOptions().IsClickChangeRotation()
-            && !pDraw->HasSelectionChanged())
+            && !pDraw->HasSelectionChanged()
+            && dynamic_cast<FuSelection*>(pDraw)
+            && lcl_PosUnchanged(pDrView->GetAllMarkedRect(), 
aDrawSelectionPos))
         {
             mrViewData.GetView()->SwitchRotateMode();
         }

Reply via email to