summaryrefslogtreecommitdiff
path: root/svx/source/table/svdotable.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-04-25 10:57:49 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-04-25 09:52:54 +0000
commitcafc53f8b4c08443524b1da6f4918d49afd45bb5 (patch)
tree22fe5b1c721bb4a83504b89201e34e3ab77a3842 /svx/source/table/svdotable.cxx
parent474eca1f9b42749665bbf69f6dc62c66ea4ad7fd (diff)
tdf#99452 svx: fix undo of table row edge drag
The problem as seen by the user: if you have a table of 2 rows and 1 column, and the separator line is dragged upwards by the mouse, then undo doesn't restore the original situation. Two items are created on the undo stack: sd::UndoGeoObject and sdr::table::TableRowUndo. Let's say the table height is 8000 mm100 and the two cell heights are 4000 and 4000. If the user resizes the first cell, so that its height is 2000, then the new table height will be 6000. The problem is that when undo is executed, first sd::UndoGeoObject resizes the table, distributing the newly available 2000 between the existing rows, and then sdr::table::TableRowUndo sets the row height of the first row: the height of the second cell will be larger than expected. Fix the problem by not doing a relayout during sd::UndoGeoObject, but doing a relayout after sdr::table::TableRowUndo in this case. This is done by: 1) Adding a new SdrDragStat::mbEndDragChangesLayout, so that SdrTableObj::applySpecialDrag() can inform SdrDragObjOwn::EndSdrDrag() that TableRowUndo will do the layout instead of UndoGeoObject. (This is done only in case a row edge is dragged, as otherwise it's not guaranteed that a TableRowUndo will follow the UndoGeoObject on the undo stack.) 2) Adding a new SdrUndoGeoObj::mbSkipChangeLayout, so that SdrTableObj::applySpecialDrag() can let SdrUndoGeoObj::Undo() not do the layout. 3) Adding a sdr::table::SdrTableObjImpl::mbSkipChangeLayout, so that SdrUndoGeoObj::Undo() can let SdrTableObj::NbcSetLogicRect() not do the layout. 4) Marking the table model as modified in TableRowUndo::setData(), so it does the layout at the end of the undo group. Change-Id: I8adde3cdad5741e6fcb420e333ce336e18c77cf1 Reviewed-on: https://gerrit.libreoffice.org/24363 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'svx/source/table/svdotable.cxx')
-rw-r--r--svx/source/table/svdotable.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 4121fdaf3d6c..9d13f8fca6b3 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -204,6 +204,7 @@ public:
TableStyleSettings maTableStyle;
Reference< XIndexAccess > mxTableStyle;
std::vector<std::unique_ptr<SdrUndoAction>> maUndos;
+ bool mbSkipChangeLayout;
void SetModel(SdrModel* pOldModel, SdrModel* pNewModel);
@@ -260,6 +261,7 @@ sal_Int32 SdrTableObjImpl::lastColCount;
SdrTableObjImpl::SdrTableObjImpl()
: mpTableObj( nullptr )
, mpLayouter( nullptr )
+, mbSkipChangeLayout(false)
{
}
@@ -1868,7 +1870,11 @@ void SdrTableObj::NbcSetLogicRect(const Rectangle& rRect)
const bool bWidth = maLogicRect.getWidth() != maRect.getWidth();
const bool bHeight = maLogicRect.getHeight() != maRect.getHeight();
maRect = maLogicRect;
- NbcAdjustTextFrameWidthAndHeight( !bHeight, !bWidth );
+ if (mpImpl->mbSkipChangeLayout)
+ // Avoid distributing newly available space between existing cells.
+ NbcAdjustTextFrameWidthAndHeight(true, true);
+ else
+ NbcAdjustTextFrameWidthAndHeight(!bHeight, !bWidth);
SetRectsDirty();
}
@@ -2005,6 +2011,11 @@ void SdrTableObj::AddUndo(SdrUndoAction* pUndo)
mpImpl->maUndos.push_back(std::unique_ptr<SdrUndoAction>(pUndo));
}
+void SdrTableObj::SetSkipChangeLayout(bool bSkipChangeLayout)
+{
+ mpImpl->mbSkipChangeLayout = bSkipChangeLayout;
+}
+
// gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
// with the base geometry and returns TRUE. Otherwise it returns FALSE.
bool SdrTableObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon ) const
@@ -2247,6 +2258,7 @@ bool SdrTableObj::applySpecialDrag(SdrDragStat& rDrag)
if( GetModel() && IsInserted() )
{
rDrag.SetEndDragChangesAttributes(true);
+ rDrag.SetEndDragChangesLayout(true);
}
mpImpl->DragEdge( pEdgeHdl->IsHorizontalEdge(), pEdgeHdl->GetPointNum(), pEdgeHdl->GetValidDragOffset( rDrag ) );