summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2024-04-23 16:04:47 +0200
committerLászló Németh <nemeth@numbertext.org>2024-04-29 00:16:12 +0200
commit6c00a73348511b688be214439941e128fc430a34 (patch)
tree7584c3e5769a3b2823d843670729a5c02e256e14
parent5425103fb5a09c7e5e56d077260523438c593e21 (diff)
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 <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter6.cxx66
-rw-r--r--sw/source/uibase/uiview/viewtab.cxx2
2 files changed, 67 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx
index e4303419a599..51f15a09f2d8 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>
@@ -1397,6 +1398,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 3b5e130f45b5..2e5bb65435ec 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!!");