include/svx/sdr/table/tablecontroller.hxx | 1 include/svx/selectioncontroller.hxx | 1 svx/source/svdraw/selectioncontroller.cxx | 5 ++ svx/source/table/tablecontroller.cxx | 52 +++++++++++++++--------------- 4 files changed, 33 insertions(+), 26 deletions(-)
New commits: commit 76ce16307dc19d8bd955cbc43da401855ac58e38 Author: Caolán McNamara <[email protected]> Date: Tue Sep 1 16:46:26 2015 +0100 refactor to create a HasMarked, no logic change Change-Id: I667a8582a740f5fbbcdbcd82907e40e82f6165a1 diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx index 2b7d13b..1df8742 100644 --- a/include/svx/sdr/table/tablecontroller.hxx +++ b/include/svx/sdr/table/tablecontroller.hxx @@ -51,6 +51,7 @@ public: SVX_DLLPRIVATE virtual bool onMouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE; SVX_DLLPRIVATE virtual bool onMouseMove(const MouseEvent& rMEvt, vcl::Window* pWin) SAL_OVERRIDE; + SVX_DLLPRIVATE virtual bool HasMarked() SAL_OVERRIDE; SVX_DLLPRIVATE virtual bool DeleteMarked() SAL_OVERRIDE; SVX_DLLPRIVATE virtual void onSelectionHasChanged() SAL_OVERRIDE; diff --git a/include/svx/selectioncontroller.hxx b/include/svx/selectioncontroller.hxx index 52bb9aa..4c4a8e5 100644 --- a/include/svx/selectioncontroller.hxx +++ b/include/svx/selectioncontroller.hxx @@ -50,6 +50,7 @@ public: virtual void GetState( SfxItemSet& rSet ); virtual void Execute( SfxRequest& rReq ); + virtual bool HasMarked(); virtual bool DeleteMarked(); virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const; diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx index d8f7fbf..3138f37 100644 --- a/svx/source/svdraw/selectioncontroller.cxx +++ b/svx/source/svdraw/selectioncontroller.cxx @@ -55,6 +55,11 @@ void SelectionController::Execute( SfxRequest& /*rReq*/ ) { } +bool SelectionController::HasMarked() +{ + return false; +} + bool SelectionController::DeleteMarked() { return false; diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index cee5e2b..1c4cfcd 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -1325,41 +1325,41 @@ void SvxTableController::DistributeRows() } } +bool SvxTableController::HasMarked() +{ + return mbCellSelectionMode && mxTable.is(); +} + bool SvxTableController::DeleteMarked() { - if( mbCellSelectionMode ) + if (!HasMarked()) + return false; + + const bool bUndo = mpModel && mpModel->IsUndoEnabled(); + if (bUndo) + mpModel->BegUndo(ImpGetResStr(STR_TABLE_DELETE_CELL_CONTENTS)); + + CellPos aStart, aEnd; + getSelectedCells( aStart, aEnd ); + for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ ) { - if( mxTable.is() ) + for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ ) { - const bool bUndo = mpModel && mpModel->IsUndoEnabled(); - if (bUndo) - mpModel->BegUndo(ImpGetResStr(STR_TABLE_DELETE_CELL_CONTENTS)); - - CellPos aStart, aEnd; - getSelectedCells( aStart, aEnd ); - for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ ) + CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); + if (xCell.is() && xCell->hasText()) { - for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ ) - { - CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); - if (xCell.is() && xCell->hasText()) - { - if (bUndo) - xCell->AddUndo(); - xCell->SetOutlinerParaObject(0); - } - } + if (bUndo) + xCell->AddUndo(); + xCell->SetOutlinerParaObject(0); } - - if (bUndo) - mpModel->EndUndo(); - - UpdateTableShape(); - return true; } } - return false; + if (bUndo) + mpModel->EndUndo(); + + UpdateTableShape(); + return true; } bool SvxTableController::GetStyleSheet( SfxStyleSheet*& rpStyleSheet ) const
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
