[Libreoffice-commits] core.git: include/tools svx/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 19 10:04:16 UTC 2020


 include/tools/weakbase.h             |    3 ++
 include/tools/weakbase.hxx           |    6 +++++
 svx/source/svdraw/svdedxv.cxx        |   13 ++++-------
 svx/source/table/tablecontroller.cxx |   38 +++++++++++++++++------------------
 svx/source/table/tableundo.cxx       |    4 +--
 5 files changed, 35 insertions(+), 29 deletions(-)

New commits:
commit 34ea5c21a752364caef9727850ef34943ad5c752
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Mar 19 11:22:11 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Mar 19 11:03:42 2020 +0100

    add operator* to tools::WeakReference
    
    which fixes warnings from
        commit ef37ab245b8095895f715217236e8e2fb90613c6
        Date:   Thu Mar 19 09:21:45 2020 +0200
        loplugin:redundantpointerops add some more smart pointer types
    which I pushed earlier, where I added tools::WeakReference to the list
    of smart pointer types, but of course the conversion it recommended is
    not possible without an operator*
    
    Change-Id: I9433b7aba46a3a15f9d833847ae3659367388109
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90735
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/tools/weakbase.h b/include/tools/weakbase.h
index 458381e47fff..e614efcc4111 100644
--- a/include/tools/weakbase.h
+++ b/include/tools/weakbase.h
@@ -97,6 +97,9 @@ public:
     /** returns the pointer to the reference object or null */
     inline reference_type * operator->() const;
 
+    /** returns a ref to the reference object */
+    inline reference_type& operator*() const;
+
     /** returns true if this instance references pReferenceObject */
     inline bool operator== (const reference_type * pReferenceObject) const;
 
diff --git a/include/tools/weakbase.hxx b/include/tools/weakbase.hxx
index fa16edd2f147..5c1645e69cf1 100644
--- a/include/tools/weakbase.hxx
+++ b/include/tools/weakbase.hxx
@@ -82,6 +82,12 @@ inline reference_type * WeakReference< reference_type >::operator->() const
     return get();
 }
 
+template< class reference_type >
+inline reference_type& WeakReference< reference_type >::operator*() const
+{
+    return *get();
+}
+
 template< class reference_type >
 inline bool WeakReference< reference_type >::operator==(const reference_type * pReferenceObject) const
 {
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index c5ddfef3dac4..9b76a6eafe31 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1450,7 +1450,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
 
     if (GetModel() && mxTextEditObj.is())
     {
-        SdrHint aHint(SdrHintKind::EndEdit, *mxTextEditObj.get());
+        SdrHint aHint(SdrHintKind::EndEdit, *mxTextEditObj);
         GetModel()->Broadcast(aHint);
     }
 
@@ -2168,8 +2168,7 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
                 if (bUndo)
                 {
                     BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
-                    AddUndo(
-                        GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
+                    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj));
 
                     // If this is a text object also rescue the OutlinerParaObject since
                     // applying attributes to the object may change text layout when
@@ -2179,7 +2178,7 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
                     bool bRescueText = mxTextEditObj.get();
 
                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(
-                        *mxTextEditObj.get(), false, !bNoEEItems || bRescueText));
+                        *mxTextEditObj, false, !bNoEEItems || bRescueText));
                     EndUndo();
                 }
 
@@ -2216,10 +2215,8 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
                 if (IsUndoEnabled())
                 {
                     BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
-                    AddUndo(
-                        GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
-                    AddUndo(
-                        GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get()));
+                    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj));
+                    AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj));
                     EndUndo();
                 }
 
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 5a397d8d7aa0..c30eca131f2b 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -221,7 +221,7 @@ bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWindow
     if(!checkTableObject())
         return false;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
 
     // check if we are read only
@@ -429,7 +429,7 @@ void SvxTableController::GetState( SfxItemSet& rSet )
     if(!mxTable.is() || !mxTableObj.is())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     std::unique_ptr<SfxItemSet> xSet;
     bool bVertDone(false);
@@ -519,7 +519,7 @@ void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs )
     if(!checkTableObject())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     bool bInsertAfter = true;
     sal_uInt16 nCount = 0;
@@ -893,7 +893,7 @@ void SvxTableController::onFormatTable(const SfxRequest& rReq)
     if(!mxTableObj.is())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const SfxItemSet* pArgs = rReq.GetArgs();
 
@@ -1057,7 +1057,7 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
     if(!checkTableObject())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
 
     if(!pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)))
@@ -1143,7 +1143,7 @@ void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
     if(!checkTableObject())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
 
     TableStyleSettings aSettings(rTableObj.getTableStyleSettings() );
@@ -1189,7 +1189,7 @@ void SvxTableController::SetVertical( sal_uInt16 nSId )
     if(!checkTableObject())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
 
     TableModelNotifyGuard aGuard( mxTable.get() );
@@ -1278,7 +1278,7 @@ void SvxTableController::SplitMarkedCells(const SfxRequest& rReq)
         Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
         const sal_Int32 nRowCount = mxTable->getRowCount();
         const sal_Int32 nColCount = mxTable->getColumnCount();
-        SdrTableObj& rTableObj(*mxTableObj.get());
+        SdrTableObj& rTableObj(*mxTableObj);
 
         if( rTableObj.IsTextEditActive() )
             mrView.SdrEndTextEdit(true);
@@ -1317,7 +1317,7 @@ void SvxTableController::DistributeColumns(const bool bOptimize, const bool bMin
     if(!checkTableObject())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const bool bUndo(rModel.IsUndoEnabled());
 
@@ -1340,7 +1340,7 @@ void SvxTableController::DistributeRows(const bool bOptimize, const bool bMinimi
     if(!checkTableObject())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const bool bUndo(rModel.IsUndoEnabled());
 
@@ -1368,7 +1368,7 @@ bool SvxTableController::DeleteMarked()
     if(!checkTableObject() || !HasMarked())
         return false;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const bool bUndo(rModel.IsUndoEnabled());
 
@@ -1480,7 +1480,7 @@ void SvxTableController::changeTableEdge(const SfxRequest& rReq)
         const sal_uInt16 nIndex = pIndex->GetValue();
         const sal_Int32 nOffset = convertTwipToMm100(pOffset->GetValue());
 
-        SdrTableObj& rTableObj(*mxTableObj.get());
+        SdrTableObj& rTableObj(*mxTableObj);
 
         sal_Int32 nEdgeIndex = -1;
         bool bHorizontal = sType.startsWith("row");
@@ -1895,7 +1895,7 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s
 
         if( xRange->isMergeable() )
         {
-            SdrTableObj& rTableObj(*mxTableObj.get());
+            SdrTableObj& rTableObj(*mxTableObj);
             SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
             const bool bUndo(rModel.IsUndoEnabled());
 
@@ -1961,7 +1961,7 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl
     if(nullptr == pPV || !checkTableObject())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
 
     if(rTableObj.getSdrPageFromSdrObject() == pPV->GetPage())
     {
@@ -2142,7 +2142,7 @@ bool SvxTableController::ChangeFontSize(bool bGrow, const FontList* pFontList)
     if(!checkTableObject() || !mxTable.is())
         return false;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
 
     if (mrView.IsTextEdit())
@@ -2618,7 +2618,7 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
     if(!checkTableObject() || !mxTable.is())
         return;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const bool bUndo(rModel.IsUndoEnabled());
 
@@ -2828,7 +2828,7 @@ bool SvxTableController::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNo
     if(!checkTableObject())
         return false;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
     const bool bUndo(rModel.IsUndoEnabled());
 
@@ -3210,7 +3210,7 @@ bool SvxTableController::isRowHeader()
     if(!checkTableObject())
         return false;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
 
     return aSettings.mbUseFirstRow;
@@ -3221,7 +3221,7 @@ bool SvxTableController::isColumnHeader()
     if(!checkTableObject())
         return false;
 
-    SdrTableObj& rTableObj(*mxTableObj.get());
+    SdrTableObj& rTableObj(*mxTableObj);
     TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
 
     return aSettings.mbUseFirstColumn;
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
index d0433bbe9b54..31ac85755e40 100644
--- a/svx/source/table/tableundo.cxx
+++ b/svx/source/table/tableundo.cxx
@@ -102,7 +102,7 @@ bool CellUndo::Merge( SfxUndoAction *pNextAction )
 void CellUndo::setDataToCell( const Data& rData )
 {
     if( rData.mpProperties )
-        mxCell->mpProperties.reset(Cell::CloneProperties( rData.mpProperties, *mxObjRef.get(), *mxCell ));
+        mxCell->mpProperties.reset(Cell::CloneProperties( rData.mpProperties, *mxObjRef, *mxCell ));
     else
         mxCell->mpProperties.reset();
 
@@ -132,7 +132,7 @@ void CellUndo::getDataFromCell( Data& rData )
     if( mxObjRef.is() && mxCell.is() )
     {
         if( mxCell->mpProperties )
-            rData.mpProperties = mxCell->CloneProperties( *mxObjRef.get(), *mxCell);
+            rData.mpProperties = mxCell->CloneProperties( *mxObjRef, *mxCell);
 
         if( mxCell->GetOutlinerParaObject() )
             rData.mpOutlinerParaObject = new OutlinerParaObject(*mxCell->GetOutlinerParaObject());


More information about the Libreoffice-commits mailing list