summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGWDx <gwdx@mail.ustc.edu.cn>2025-08-02 16:03:53 +0800
committerHossein <hossein@libreoffice.org>2025-09-25 16:07:32 +0200
commitf4b53f9fb513b5238cbefb6a415bbcf2bd8aa238 (patch)
tree131b00da3eb1c773607ef6b1f5a0a0386b4b8010
parent12c50f2206f3f37083721beeb8757fc680aa1831 (diff)
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 <hossein@libreoffice.org> Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx4
1 files changed, 2 insertions, 2 deletions
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);
}
}
}