sw/source/uibase/docvw/edtwin.cxx |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit f4b53f9fb513b5238cbefb6a415bbcf2bd8aa238
Author:     GWDx <[email protected]>
AuthorDate: Sat Aug 2 16:03:53 2025 +0800
Commit:     Hossein <[email protected]>
CommitDate: Thu Sep 25 16:07:32 2025 +0200

    tdf#94074 tdf#94075 Fix object selection/resizing for captioned images
    
    Steps to reproduce the bug:
    1. Insert an image with a caption.
    2. Click the frame → the entire frame (including caption and image) is
       selected.
    3. Click the image twice → the image is selected.
    4. Resize the image by dragging from a corner →
       aspect ratio is not preserved (unexpected behavior).
    
    Reason:
    - In step 4, the resizing logic in `SwEditWin::MouseMove()` uses the
     `bResizeKeepRatio` flag to determine whether to maintain the aspect
      ratio. This flag is computed via a call chain:
      `SwWrtShell::GetSelectionType()` → `SwEditShell::GetCntType()`
        → `GetCursor()->GetPointNode()`.
    - In step 3, `SwEditWin::MouseButtonUp()` calls `SdrMarkView::MarkObj()`
      to select the image. However, `MarkObj()` marks the image object
      without updating the cursor.
    - As a result, `GetCursor()->GetPointNode()` still refers to a text node
      instead of a graphic node, causing the aspect ratio logic to
      misbehave.
    
    The change here is:
      Replace `SdrMarkView::MarkObj()` with `SwFEShell::SelectObj()`.
    
    Change-Id: I17e7eaa1ab04cdde758c39eaca3da49ea3f07f6e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188824
    Tested-by: Hossein <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Hossein <[email protected]>

diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 33ac354df7da..8f5a2d3d3e37 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -4820,7 +4820,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
                     if (!pShapeFormat)
                     {
                         pSdrView->UnmarkAllObj();
-                        pSdrView->MarkObj(pObj, pPV);
+                        rSh.SelectObj(aDocPos, 0, pObj);
                         if (rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
                             SwModule::get()->GetUsrPref(
                                 dynamic_cast<const SwWebView*>(&m_rView) != 
nullptr)->
@@ -4832,7 +4832,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
                         // If the fly frame is a textbox of a shape, then 
select the shape instead.
                         SdrObject* pShape = pShapeFormat->FindSdrObject();
                         pSdrView->UnmarkAllObj();
-                        pSdrView->MarkObj(pShape, pPV);
+                        rSh.SelectObj(aDocPos, SW_ALLOW_TEXTBOX, pShape);
                     }
                 }
             }

Reply via email to