diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-25 12:59:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-27 17:19:26 +0100 |
commit | c95d91ee35ca09379a8a1d415ae77716ddeadaac (patch) | |
tree | 370b0ad6832f3aca2ee0e2ef375bb6f953e5d360 /svx/source/table | |
parent | 2d8f17565ebe867210f5769851d91b2e7b612a8f (diff) |
improve subtyping when dealing with tools::WeakReference
tweak the templating to make it easier to declare a WeakReference that
points to a subclass for a weak-capable class.
Which lets us declare some fields with more specific types, and dump a
lot of unnecessary casting.
And make WeakBase be inherited from virtually, so we don't end
up with weird states where two weak refernces could point to two
different parts of the same object.
Change-Id: I3213ea27e087038457b0761b5171c7bce96e71f3
Reviewed-on: https://gerrit.libreoffice.org/48650
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/table')
-rw-r--r-- | svx/source/table/tablecontroller.cxx | 54 | ||||
-rw-r--r-- | svx/source/table/tableundo.cxx | 4 | ||||
-rw-r--r-- | svx/source/table/tableundo.hxx | 2 |
3 files changed, 30 insertions, 30 deletions
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index 59dec64df181..f683569df3df 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -174,10 +174,10 @@ SvxTableController::SvxTableController( SdrObjEditView* pView, const SdrObject* if( mxTableObj.is() ) { - static_cast< const SdrTableObj* >( pObj )->getActiveCellPos( maCursorFirstPos ); + mxTableObj->getActiveCellPos( maCursorFirstPos ); maCursorLastPos = maCursorFirstPos; - Reference< XTable > xTable( static_cast< const SdrTableObj* >( pObj )->getTable() ); + Reference< XTable > xTable( mxTableObj->getTable() ); if( xTable.is() ) { mxModifyListener = new SvxTableControllerModifyListener( this ); @@ -198,7 +198,7 @@ SvxTableController::~SvxTableController() if( mxModifyListener.is() && mxTableObj.get() ) { - Reference< XTable > xTable( static_cast< SdrTableObj* >( mxTableObj.get() )->getTable() ); + Reference< XTable > xTable( mxTableObj->getTable() ); if( xTable.is() ) { xTable->removeModifyListener( mxModifyListener ); @@ -273,7 +273,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* if( !rMEvt.IsRight() && mpView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN, aVEvt) == SdrHitKind::Handle ) return false; - TableHitKind eHit = static_cast< SdrTableObj* >(mxTableObj.get())->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow); + TableHitKind eHit = mxTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow); mbLeftButtonDown = (rMEvt.GetClicks() == 1) && rMEvt.IsLeft(); @@ -299,7 +299,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* } else { - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( !pWindow || !pTableObj || eHit == TableHitKind::NONE) { @@ -350,7 +350,7 @@ bool SvxTableController::onMouseMove(const MouseEvent& rMEvt, vcl::Window* pWind if( !checkTableObject() ) return false; - SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); CellPos aPos; if (mbLeftButtonDown && pTableObj && pTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), aPos.mnCol, aPos.mnRow ) != TableHitKind::NONE) { @@ -380,7 +380,7 @@ void SvxTableController::onSelectionHasChanged() { bool bSelected = false; - SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); if( pTableObj && pTableObj->IsTextEditActive() ) { pTableObj->getActiveCellPos( maCursorFirstPos ); @@ -512,7 +512,7 @@ void SvxTableController::GetState( SfxItemSet& rSet ) void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs ) { - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( !pTableObj ) return; @@ -788,7 +788,7 @@ void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs ) void SvxTableController::onDelete( sal_uInt16 nSId ) { - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( !pTableObj ) return; @@ -893,7 +893,7 @@ namespace void SvxTableController::onFormatTable( SfxRequest const & rReq ) { - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( !pTableObj ) return; @@ -1033,7 +1033,7 @@ void SvxTableController::Execute( SfxRequest& rReq ) void SvxTableController::SetTableStyle( const SfxItemSet* pArgs ) { - SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr; if( !pTableObj || !pModel || !pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)) ) @@ -1116,7 +1116,7 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs ) void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs ) { - SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr; if( !pTableObj || !pModel ) @@ -1163,7 +1163,7 @@ void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs ) void SvxTableController::SetVertical( sal_uInt16 nSId ) { - SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); if( !mxTable.is() || !pTableObj ) return; @@ -1222,7 +1222,7 @@ void SvxTableController::MergeMarkedCells() { CellPos aStart, aEnd; getSelectedCells( aStart, aEnd ); - SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); if( pTableObj ) { if( pTableObj->IsTextEditActive() ) @@ -1256,7 +1256,7 @@ void SvxTableController::SplitMarkedCells() const sal_Int32 nColCount = mxTable->getColumnCount(); - SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); if( pTableObj ) { if( pTableObj->IsTextEditActive() ) @@ -1293,7 +1293,7 @@ void SvxTableController::SplitMarkedCells() void SvxTableController::DistributeColumns() { - SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); if( pTableObj ) { const bool bUndo = mpModel && mpModel->IsUndoEnabled(); @@ -1314,7 +1314,7 @@ void SvxTableController::DistributeColumns() void SvxTableController::DistributeRows() { - SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); if( pTableObj ) { const bool bUndo = mpModel && mpModel->IsUndoEnabled(); @@ -1456,7 +1456,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve TblAction nAction = TblAction::HandledByView; - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( !pTableObj ) return nAction; @@ -1637,7 +1637,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve bool SvxTableController::executeAction(TblAction nAction, bool bSelect, vcl::Window* pWindow) { - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( !pTableObj ) return false; @@ -1746,14 +1746,14 @@ bool SvxTableController::executeAction(TblAction nAction, bool bSelect, vcl::Win void SvxTableController::gotoCell(const CellPos& rPos, bool bSelect, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */) { - if( mxTableObj.is() && static_cast<SdrTableObj*>(mxTableObj.get())->IsTextEditActive() ) + if( mxTableObj.is() && mxTableObj->IsTextEditActive() ) mpView->SdrEndTextEdit(true); if( bSelect ) { maCursorLastPos = rPos; if( mxTableObj.is() ) - static_cast< SdrTableObj* >( mxTableObj.get() )->setActiveCell( rPos ); + mxTableObj->setActiveCell( rPos ); if( !mbCellSelectionMode ) { @@ -1857,7 +1857,7 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl { SdrPageView* pPV = mpView->GetSdrPageView(); - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( pTableObj && pTableObj->GetPage() == pPV->GetPage() ) { bool bEmptyOutliner = false; @@ -2123,7 +2123,7 @@ void SvxTableController::updateSelectionOverlay() destroySelectionOverlay(); if( mbCellSelectionMode ) { - sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); if( pTableObj ) { sdr::overlay::OverlayObjectCell::RangeVector aRanges; @@ -2595,7 +2595,7 @@ bool SvxTableController::GetMarkedObjModel( SdrPage* pNewPage ) { if( mxTableObj.is() && mbCellSelectionMode && pNewPage ) try { - sdr::table::SdrTableObj& rTableObj = *static_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + sdr::table::SdrTableObj& rTableObj = *mxTableObj.get(); CellPos aStart, aEnd; getSelectedCells( aStart, aEnd ); @@ -3084,7 +3084,7 @@ bool SvxTableController::isColumnSelected( sal_Int32 nColumn ) bool SvxTableController::isRowHeader() { - SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr; if( !pTableObj || !pModel ) @@ -3097,7 +3097,7 @@ bool SvxTableController::isRowHeader() bool SvxTableController::isColumnHeader() { - SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( mxTableObj.get() ); + SdrTableObj* pTableObj = mxTableObj.get(); SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr; if( !pTableObj || !pModel ) @@ -3113,7 +3113,7 @@ bool SvxTableController::setCursorLogicPosition(const Point& rPosition, bool bPo if (mxTableObj->GetObjIdentifier() != OBJ_TABLE) return false; - SdrTableObj* pTableObj = static_cast<SdrTableObj*>(mxTableObj.get()); + SdrTableObj* pTableObj = mxTableObj.get(); CellPos aCellPos; if (pTableObj->CheckTableHit(rPosition, aCellPos.mnCol, aCellPos.mnRow) != TableHitKind::NONE) { diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index 27c93bd4b158..9a14948b1dfe 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -499,7 +499,7 @@ void TableStyleUndo::Redo() void TableStyleUndo::setData( const Data& rData ) { - SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxObjRef.get() ); + SdrTableObj* pTableObj = mxObjRef.get(); if( pTableObj ) { pTableObj->setTableStyle( rData.mxTableStyle ); @@ -509,7 +509,7 @@ void TableStyleUndo::setData( const Data& rData ) void TableStyleUndo::getData( Data& rData ) { - SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxObjRef.get() ); + SdrTableObj* pTableObj = mxObjRef.get(); if( pTableObj ) { rData.maSettings = pTableObj->getTableStyleSettings(); diff --git a/svx/source/table/tableundo.hxx b/svx/source/table/tableundo.hxx index dda6c8b57e91..60d661878a70 100644 --- a/svx/source/table/tableundo.hxx +++ b/svx/source/table/tableundo.hxx @@ -237,7 +237,7 @@ public: virtual void Redo() override; private: - tools::WeakReference<SdrObject> mxObjRef; + tools::WeakReference<SdrTableObj> mxObjRef; struct Data { |