sw/qa/extras/uiwriter/uiwriter6.cxx |   50 ++++++++++++++++++++++++++++++++++++
 sw/source/uibase/docvw/edtwin.cxx   |   12 +++++++-
 2 files changed, 60 insertions(+), 2 deletions(-)

New commits:
commit 03d40ad9dea1629f55a1270d425a5995ed229ddb
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Fri Apr 26 22:03:53 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue May 14 11:03:30 2024 +0200

    tdf#160836 sw: resize rows at images cropped by row height
    
    Fixed row height can crop cell content, including images
    anchored as character. Resizing the row height with mouse
    was not possible there, because selection of the cropped
    image avoided to drag & drop the horizontal cell border.
    
    Change-Id: I6dde79e77563468059794548b6c058cad61586a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166795
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: Jenkins
    (cherry picked from commit 30de13743f144aced83bc43d310592f82788c910)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167210
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index db0c8f6929c7..8e67d26e4652 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -1513,6 +1513,56 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf160842)
     CPPUNIT_ASSERT(pWrtShell->IsCursorInTable());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf160836)
+{
+    createSwDoc("tdf160842.fodt");
+    SwDoc* pDoc = getSwDoc();
+    CPPUNIT_ASSERT(pDoc);
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    // set table row height by drag & drop at images cropped by the fixed row 
height
+    SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+    auto pPage = dynamic_cast<SwPageFrame*>(pLayout->Lower());
+    CPPUNIT_ASSERT(pPage);
+    const SwSortedObjs& rPageObjs = *pPage->GetSortedObjs();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPageObjs.size());
+    auto pPageFly = dynamic_cast<SwFlyAtContentFrame*>(rPageObjs[0]);
+    CPPUNIT_ASSERT(pPageFly);
+    auto pTable = dynamic_cast<SwTabFrame*>(pPageFly->GetLower());
+    CPPUNIT_ASSERT(pTable);
+    auto pRow1 = pTable->GetLower();
+    CPPUNIT_ASSERT(pRow1->IsRowFrame());
+    auto pCellA1 = pRow1->GetLower();
+    CPPUNIT_ASSERT(pCellA1);
+    const SwRect& rCellA1Rect = pCellA1->getFrameArea();
+    auto nRowHeight = rCellA1Rect.Height();
+    // select center of the bottom border of the first table cell
+    Point ptFrom(rCellA1Rect.Left() + rCellA1Rect.Width() / 2, 
rCellA1Rect.Top() + nRowHeight);
+    // halve the row height
+    Point ptTo(rCellA1Rect.Left() + rCellA1Rect.Width() / 2, rCellA1Rect.Top() 
+ 0.5 * nRowHeight);
+    vcl::Window& rEditWin = pDoc->GetDocShell()->GetView()->GetEditWin();
+    Point aFrom = rEditWin.LogicToPixel(ptFrom);
+    MouseEvent aClickEvent(aFrom, 1, MouseEventModifiers::SIMPLECLICK | 
MouseEventModifiers::SELECT,
+                           MOUSE_LEFT);
+    rEditWin.MouseButtonDown(aClickEvent);
+    Point aTo = rEditWin.LogicToPixel(ptTo);
+    MouseEvent aMoveEvent(aTo, 1, MouseEventModifiers::SIMPLECLICK | 
MouseEventModifiers::SELECT,
+                          MOUSE_LEFT);
+    TrackingEvent aTEvt(aMoveEvent, TrackingEventFlags::Repeat);
+    // drag & drop of cell border inside the document (and outside the table)
+    // still based on the ruler code, use that to simulate dragging
+    pDoc->GetDocShell()->GetView()->GetVRuler().Tracking(aTEvt);
+    TrackingEvent aTEvt2(aMoveEvent, TrackingEventFlags::End);
+    pDoc->GetDocShell()->GetView()->GetVRuler().Tracking(aTEvt2);
+    Scheduler::ProcessEventsToIdle();
+    rEditWin.CaptureMouse();
+    rEditWin.ReleaseMouse();
+
+    // this was 3910 (not modified row height previously)
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1980), pCellA1->getFrameArea().Height());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf115132)
 {
     createSwDoc();
diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 073b6b59649e..9aa4862a43a4 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -3113,9 +3113,13 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
     SwTab nMouseTabCol = SwTab::COL_NONE;
     const bool bTmp = !rSh.IsDrawCreate() && !m_pApplyTempl && 
!rSh.IsInSelect()
                       && aMEvt.GetClicks() == 1 && MOUSE_LEFT == 
aMEvt.GetButtons();
+
     if (  bTmp &&
          SwTab::COL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPos ) ) 
&&
-         !rSh.IsObjSelectable( aDocPos ) )
+         ( !rSh.IsObjSelectable( aDocPos ) ||
+             // allow resizing row height, if the image is anchored as 
character in the cell
+             ( rSh.ShouldObjectBeSelected(aDocPos) &&
+                 !( SwTab::COL_VERT == nMouseTabCol || SwTab::COL_HORI == 
nMouseTabCol ) ) ) )
     {
         // Enhanced table selection
         if ( SwTab::SEL_HORI <= nMouseTabCol && SwTab::COLSEL_VERT >= 
nMouseTabCol )
@@ -3984,8 +3988,12 @@ bool SwEditWin::changeMousePointer(Point const & 
rDocPoint)
     SwWrtShell & rShell = m_rView.GetWrtShell();
 
     SwTab nMouseTabCol;
+
     if ( SwTab::COL_NONE != (nMouseTabCol = rShell.WhichMouseTabCol( rDocPoint 
) ) &&
-         !rShell.IsObjSelectable( rDocPoint ) )
+         ( !rShell.IsObjSelectable( rDocPoint ) ||
+             // allow resizing row height, if the image is anchored as 
character in the cell
+             ( rShell.ShouldObjectBeSelected(rDocPoint) &&
+                 !( SwTab::COL_VERT == nMouseTabCol || SwTab::COL_HORI == 
nMouseTabCol ) ) ) )
     {
         PointerStyle nPointer = PointerStyle::Null;
         bool bChkTableSel = false;

Reply via email to