diff options
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/svdraw/svddrag.cxx | 1 | ||||
-rw-r--r-- | svx/source/svdraw/svddrgmt.cxx | 6 | ||||
-rw-r--r-- | svx/source/svdraw/svdundo.cxx | 7 | ||||
-rw-r--r-- | svx/source/table/svdotable.cxx | 14 | ||||
-rw-r--r-- | svx/source/table/tablerow.cxx | 4 | ||||
-rw-r--r-- | svx/source/table/tablerow.hxx | 2 | ||||
-rw-r--r-- | svx/source/table/tableundo.cxx | 3 |
7 files changed, 36 insertions, 1 deletions
diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx index 8eb54cbef3d8..75c046a1326b 100644 --- a/svx/source/svdraw/svddrag.cxx +++ b/svx/source/svdraw/svddrag.cxx @@ -50,6 +50,7 @@ void SdrDragStat::Reset() pDragMethod=nullptr; bEndDragChangesAttributes=false; bEndDragChangesGeoAndAttributes=false; + mbEndDragChangesLayout=false; bMouseIsUp=false; Clear(true); aActionRect=Rectangle(); diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 09ca6cba9b1a..5996b50eaecd 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1410,6 +1410,12 @@ bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/) } bRet = pObj->applySpecialDrag(DragStat()); + if (DragStat().IsEndDragChangesLayout()) + { + auto pGeoUndo = dynamic_cast<SdrUndoGeoObj*>(pUndo); + if (pGeoUndo) + pGeoUndo->SetSkipChangeLayout(true); + } if(bRet) { diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index 37e81e7cdffe..e3cc47895528 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -598,6 +598,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj) , pUndoGeo(nullptr) , pRedoGeo(nullptr) , pUndoGroup(nullptr) + , mbSkipChangeLayout(false) { SdrObjList* pOL=rNewObj.GetSubList(); if (pOL!=nullptr && pOL->GetObjCount() && dynamic_cast<const E3dScene* >( &rNewObj) == nullptr) @@ -640,7 +641,13 @@ void SdrUndoGeoObj::Undo() { delete pRedoGeo; pRedoGeo=pObj->GetGeoData(); + + auto pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pObj); + if (pTableObj && mbSkipChangeLayout) + pTableObj->SetSkipChangeLayout(true); pObj->SetGeoData(*pUndoGeo); + if (pTableObj && mbSkipChangeLayout && pTableObj) + pTableObj->SetSkipChangeLayout(false); } } 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 ) ); diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx index ee95e905554b..cd82cc423b45 100644 --- a/svx/source/table/tablerow.cxx +++ b/svx/source/table/tablerow.cxx @@ -149,6 +149,10 @@ void TableRow::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) } } +TableModelRef TableRow::getModel() const +{ + return mxTableModel; +} // XCellRange diff --git a/svx/source/table/tablerow.hxx b/svx/source/table/tablerow.hxx index 77d654f23297..6b38b8037389 100644 --- a/svx/source/table/tablerow.hxx +++ b/svx/source/table/tablerow.hxx @@ -47,6 +47,8 @@ public: void insertColumns( sal_Int32 nIndex, sal_Int32 nCount, CellVector::iterator* pIter = nullptr ); void removeColumns( sal_Int32 nIndex, sal_Int32 nCount ); + /// Reference to the table model containing this row. + TableModelRef getModel() const; // XCellRange virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) override; diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index baa7e6c29456..3a60ab02d0c2 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -463,6 +463,9 @@ void TableRowUndo::setData( const Data& rData ) mxRow->mbIsVisible = rData.mbIsVisible; mxRow->mbIsStartOfNewPage = rData.mbIsStartOfNewPage; mxRow->maName = rData.maName; + + // Trigger re-layout of the table. + mxRow->getModel()->setModified(true); } |