sw/qa/extras/uiwriter/uiwriter6.cxx |   66 ++++++++++++++++++++++++++++++++++++
 sw/source/uibase/uiview/viewtab.cxx |    2 -
 2 files changed, 67 insertions(+), 1 deletion(-)

New commits:
commit 5b3037e2caa5dc857f51dd0dd7f38646535ee232
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Apr 23 16:04:47 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon May 13 11:54:01 2024 +0200

    tdf#44773 sw: allow resizing table rows, if cursor outside the table
    
    If the cursor wasn't in the table, only column width of text
    tables was resizeable by dragging the horizontal cell borders:
    It was possible to drag the horizontal border, showing its
    preview, but the drop cancelled the operation instead of
    resizing the table row according to the selected position.
    
    Now it's possible to resize the height of the table rows
    without moving the text cursor inside the table.
    
    Note: This is important for floating tables containing images:
    here it's not possible to put the cursor inside the table, if
    the image is cropped only by the cell borders: so it was not
    possible to resize the row height.
    
    Change-Id: I181d79a28cdeefabb796b7b978ee1368a9378888
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166793
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 6c00a73348511b688be214439941e128fc430a34)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167088
    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 5b4140e02967..9b8ae0244efe 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -13,6 +13,7 @@
 #include <itabenum.hxx>
 #include <ndtxt.hxx>
 #include <wrtsh.hxx>
+#include <edtwin.hxx>
 #include <drawdoc.hxx>
 #include <view.hxx>
 #include <com/sun/star/text/XTextColumns.hpp>
@@ -1406,6 +1407,71 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, 
testTdf154771_MovingMultipleColumns)
     CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getColumns()->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf44773)
+{
+    // allow resizing table rows, if cursor outside the table
+    createSwDoc();
+    SwDoc* pDoc = getSwDoc();
+    CPPUNIT_ASSERT(pDoc);
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    // insert an empty paragraph
+    pWrtShell->SplitNode();
+
+    // create a table
+    SwInsertTableOptions TableOpt(SwInsertTableFlags::DefaultBorder, 0);
+    (void)&pWrtShell->InsertTable(TableOpt, 2, 1);
+
+    // the cursor is not inside the table
+    CPPUNIT_ASSERT(!pWrtShell->IsCursorInTable());
+
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xTableNames = 
xTablesSupplier->getTextTables();
+    CPPUNIT_ASSERT(xTableNames->hasByName("Table1"));
+    uno::Reference<text::XTextTable> xTable1(xTableNames->getByName("Table1"), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable1->getRows()->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable1->getColumns()->getCount());
+
+    Scheduler::ProcessEventsToIdle();
+
+    // set table row height by drag & drop
+    SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+
+    SwFrame* pPage = pLayout->Lower();
+    SwFrame* pBody = pPage->GetLower();
+    SwFrame* pTable = pBody->GetLower()->GetNext();
+    SwFrame* pRow1 = pTable->GetLower();
+    CPPUNIT_ASSERT(pRow1->IsRowFrame());
+    SwFrame* pCellA1 = pRow1->GetLower();
+    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);
+    // double the row height
+    Point ptTo(rCellA1Rect.Left() + rCellA1Rect.Width() / 2, rCellA1Rect.Top() 
+ 2 * 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 396 (not modified row height previously)
+    CPPUNIT_ASSERT_EQUAL(tools::Long(810), pCellA1->getFrameArea().Height());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf115132)
 {
     createSwDoc();
diff --git a/sw/source/uibase/uiview/viewtab.cxx 
b/sw/source/uibase/uiview/viewtab.cxx
index 52a26eabb672..eb7f65dc9602 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -1034,7 +1034,7 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
         {
             SvxColumnItem aColItem(static_cast<const 
SvxColumnItem&>(pReqArgs->Get(nSlot)));
 
-            if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFormat()) )
+            if( m_bSetTabColFromDoc || m_bSetTabRowFromDoc || (!bSect && 
rSh.GetTableFormat()) )
             {
                 OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
 

Reply via email to