[Libreoffice-commits] core.git: sdext/source sd/source

Noel (via logerrit) logerrit at kemper.freedesktop.org
Sun Feb 21 15:13:46 UTC 2021


 sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx      |    2 
 sd/source/ui/accessibility/AccessibleSlideSorterView.cxx        |    2 
 sd/source/ui/framework/configuration/Configuration.cxx          |    4 -
 sd/source/ui/slidesorter/controller/SlsClipboard.cxx            |    8 +--
 sd/source/ui/slidesorter/controller/SlsTransferableData.cxx     |    4 -
 sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx |    2 
 sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx         |    6 --
 sd/source/ui/unoidl/unopage.cxx                                 |   16 +++---
 sd/source/ui/unoidl/unosrch.cxx                                 |    2 
 sd/source/ui/view/drviews5.cxx                                  |    6 --
 sd/source/ui/view/outlnvsh.cxx                                  |    6 --
 sd/source/ui/view/sdview2.cxx                                   |   23 ++++------
 sdext/source/pdfimport/pdfiadaptor.cxx                          |   13 +++--
 13 files changed, 41 insertions(+), 53 deletions(-)

New commits:
commit 8f231fc5df201c45d16bce0b4b17f727842b2121
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Sun Feb 21 12:32:12 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Feb 21 16:13:06 2021 +0100

    loplugin:refcounting in sd
    
    Change-Id: Ic95aa7a3c1fdab1baef744ec85ffc9c98dee5f1e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111272
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx
index a8c81225130b..fde0cd953677 100644
--- a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx
+++ b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx
@@ -188,7 +188,7 @@ Reference<XAccessibleStateSet> SAL_CALL
 {
     ThrowIfDisposed();
     const SolarMutexGuard aSolarGuard;
-    ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
+    rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper();
 
     if (mxParent.is())
     {
diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
index ee663f2fbb1a..3ce13b899ef9 100644
--- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
+++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
@@ -285,7 +285,7 @@ Reference<XAccessibleStateSet > SAL_CALL
 {
     ThrowIfDisposed();
     const SolarMutexGuard aSolarGuard;
-    ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
+    rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper();
 
     pStateSet->AddState(AccessibleStateType::FOCUSABLE);
     pStateSet->AddState(AccessibleStateType::SELECTABLE);
diff --git a/sd/source/ui/framework/configuration/Configuration.cxx b/sd/source/ui/framework/configuration/Configuration.cxx
index 53bbaa339316..f155e0992e68 100644
--- a/sd/source/ui/framework/configuration/Configuration.cxx
+++ b/sd/source/ui/framework/configuration/Configuration.cxx
@@ -182,12 +182,10 @@ Reference<util::XCloneable> SAL_CALL Configuration::createClone()
     ::osl::MutexGuard aGuard (maMutex);
     ThrowIfDisposed();
 
-    Configuration* pConfiguration = new Configuration(
+    return new Configuration(
         mxBroadcaster,
         mbBroadcastRequestEvents,
         *mpResourceContainer);
-
-    return Reference<util::XCloneable>(pConfiguration);
 }
 
 //----- XNamed ----------------------------------------------------------------
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index 25e2aaea7b56..c7f333a5f0b9 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -429,17 +429,17 @@ void Clipboard::CreateSlideTransferable (
         return;
 
     mrSlideSorter.GetView().BrkAction();
-    SdTransferable* pTransferable = TransferableData::CreateTransferable (
+    rtl::Reference<SdTransferable> pTransferable = TransferableData::CreateTransferable (
         pDocument,
         dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()),
         aRepresentatives);
 
     if (bDrag)
-        SD_MOD()->pTransferDrag = pTransferable;
+        SD_MOD()->pTransferDrag = pTransferable.get();
     else
-        SD_MOD()->pTransferClip = pTransferable;
+        SD_MOD()->pTransferClip = pTransferable.get();
 
-    pDocument->CreatingDataObj (pTransferable);
+    pDocument->CreatingDataObj (pTransferable.get());
     pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument());
     std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
     pTransferable->GetWorkDocument()->GetDocSh()
diff --git a/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx
index b340642553cc..2aac76fe0600 100644
--- a/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsTransferableData.cxx
@@ -23,12 +23,12 @@
 
 namespace sd::slidesorter::controller {
 
-SdTransferable* TransferableData::CreateTransferable (
+rtl::Reference<SdTransferable> TransferableData::CreateTransferable (
     SdDrawDocument* pSrcDoc,
     SlideSorterViewShell* pViewShell,
     const ::std::vector<Representative>& rRepresentatives)
 {
-    SdTransferable* pTransferable = new SdTransferable (pSrcDoc, nullptr, false/*bInitOnGetData*/);
+    rtl::Reference<SdTransferable> pTransferable = new SdTransferable (pSrcDoc, nullptr, false/*bInitOnGetData*/);
     auto pData = std::make_shared<TransferableData>(pViewShell, rRepresentatives);
     pTransferable->AddUserData(pData);
     return pTransferable;
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx b/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx
index 7354697f05e1..24380f831d17 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsTransferableData.hxx
@@ -49,7 +49,7 @@ public:
         bool mbIsExcluded;
     };
 
-    static SdTransferable* CreateTransferable (
+    static rtl::Reference<SdTransferable> CreateTransferable (
         SdDrawDocument* pSrcDoc,
         SlideSorterViewShell* pViewShell,
         const ::std::vector<TransferableData::Representative>& rRepresentatives);
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
index d2f6d32ab191..60bc5fadec77 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
@@ -264,16 +264,14 @@ css::uno::Reference<css::accessibility::XAccessible>
 
     assert(mpSlideSorter);
 
-    ::accessibility::AccessibleSlideSorterView *pAccessibleView =
+    rtl::Reference<::accessibility::AccessibleSlideSorterView> pAccessibleView =
     new ::accessibility::AccessibleSlideSorterView(
         *mpSlideSorter,
         pWindow);
 
-    css::uno::Reference< css::accessibility::XAccessible> xRet(pAccessibleView);
-
     pAccessibleView->Init();
 
-    return xRet;
+    return pAccessibleView;
 }
 
 void SlideSorterViewShell::SwitchViewFireFocus(const css::uno::Reference< css::accessibility::XAccessible >& xAcc )
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index af642f7b1f36..26db26b2a12e 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -1371,7 +1371,7 @@ Reference< drawing::XShape >  SdGenericDrawPage::CreateShape(SdrObject *pObj) co
     {
         PresObjKind eKind = GetPage()->GetPresObjKind(pObj);
 
-        SvxShape* pShape = nullptr;
+        rtl::Reference<SvxShape> pShape;
 
         if(pObj->GetObjInventor() == SdrInventor::Default)
         {
@@ -2442,11 +2442,10 @@ void SdDrawPage::setBackground( const Any& rValue )
     }
     else
     {
-        SdUnoPageBackground* pBackground = new SdUnoPageBackground();
+        rtl::Reference<SdUnoPageBackground> pBackground = new SdUnoPageBackground();
 
         Reference< beans::XPropertySetInfo >  xSetInfo( xSet->getPropertySetInfo() );
-        Reference< beans::XPropertySet >  xDestSet( static_cast<beans::XPropertySet*>(pBackground) );
-        Reference< beans::XPropertySetInfo >  xDestSetInfo( xDestSet->getPropertySetInfo() );
+        Reference< beans::XPropertySetInfo >  xDestSetInfo( pBackground->getPropertySetInfo() );
 
         const Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() );
 
@@ -2454,7 +2453,7 @@ void SdDrawPage::setBackground( const Any& rValue )
         {
             const OUString aPropName( rProp.Name );
             if( xSetInfo->hasPropertyByName( aPropName ) )
-                xDestSet->setPropertyValue( aPropName,
+                pBackground->setPropertyValue( aPropName,
                         xSet->getPropertyValue( aPropName ) );
         }
 
@@ -2811,11 +2810,10 @@ void SdMasterPage::setBackground( const Any& rValue )
             }
             else
             {
-                SdUnoPageBackground* pBackground = new SdUnoPageBackground();
+                rtl::Reference<SdUnoPageBackground> pBackground = new SdUnoPageBackground();
 
                 Reference< beans::XPropertySetInfo > xInputSetInfo( xInputSet->getPropertySetInfo(), UNO_SET_THROW );
-                Reference< beans::XPropertySet > xDestSet( static_cast<beans::XPropertySet*>(pBackground) );
-                Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo(), UNO_SET_THROW );
+                Reference< beans::XPropertySetInfo > xDestSetInfo( pBackground->getPropertySetInfo(), UNO_SET_THROW );
 
                 const uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() );
 
@@ -2823,7 +2821,7 @@ void SdMasterPage::setBackground( const Any& rValue )
                 {
                     const OUString aPropName( rProp.Name );
                     if( xInputSetInfo->hasPropertyByName( aPropName ) )
-                        xDestSet->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) );
+                        pBackground->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) );
                 }
 
                 pBackground->fillItemSet( static_cast<SdDrawDocument*>(&SvxFmDrawPage::mpPage->getSdrModelFromSdrPage()), aSet );
diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx
index e23d2c26b5df..3afda2d5d646 100644
--- a/sd/source/ui/unoidl/unosrch.cxx
+++ b/sd/source/ui/unoidl/unosrch.cxx
@@ -550,7 +550,7 @@ uno::Reference< text::XTextRange >  SdUnoSearchReplaceShape::Search( const uno::
 
             if(pParent)
             {
-                SvxUnoTextRange *pRange = new SvxUnoTextRange( *pParent );
+                rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *pParent );
                 xFound = pRange;
                 pRange->SetSelection(aSelection);
             }
diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx
index d632d24a46d0..7d92475aac0e 100644
--- a/sd/source/ui/view/drviews5.cxx
+++ b/sd/source/ui/view/drviews5.cxx
@@ -581,16 +581,14 @@ css::uno::Reference<css::accessibility::XAccessible>
 {
     if (GetViewShellBase().GetController() != nullptr)
     {
-        accessibility::AccessibleDrawDocumentView* pDocumentView =
+        rtl::Reference<accessibility::AccessibleDrawDocumentView> pDocumentView =
             new accessibility::AccessibleDrawDocumentView (
                 pWindow,
                 this,
                 GetViewShellBase().GetController(),
                 pWindow->GetAccessibleParentWindow()->GetAccessible());
         pDocumentView->Init();
-        return css::uno::Reference<css::accessibility::XAccessible>
-            (static_cast< css::uno::XWeak*>(pDocumentView),
-                css::uno::UNO_QUERY);
+        return pDocumentView;
     }
 
     SAL_WARN("sd", "DrawViewShell::CreateAccessibleDocumentView: no controller");
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index 7068a519a96a..f106b943a8b1 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1828,16 +1828,14 @@ css::uno::Reference<css::accessibility::XAccessible>
     OSL_ASSERT (GetViewShell()!=nullptr);
     if (GetViewShell()->GetController() != nullptr)
     {
-        ::accessibility::AccessibleOutlineView* pDocumentView =
+        rtl::Reference<::accessibility::AccessibleOutlineView> pDocumentView =
             new ::accessibility::AccessibleOutlineView (
                 pWindow,
                 this,
                 GetViewShell()->GetController(),
                 pWindow->GetAccessibleParentWindow()->GetAccessible());
         pDocumentView->Init();
-        return css::uno::Reference<css::accessibility::XAccessible>
-            (static_cast< css::uno::XWeak*>(pDocumentView),
-                css::uno::UNO_QUERY);
+        return pDocumentView;
     }
 
     SAL_WARN("sd", "OutlineViewShell::CreateAccessibleDocumentView: no controller");
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 7f5caafe6733..f71246ea651e 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -81,12 +81,11 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
 {
     // since SdTransferable::CopyToClipboard is called, this
     // dynamically created object is destroyed automatically
-    SdTransferable* pTransferable = new SdTransferable( &mrDoc, nullptr, false );
-    css::uno::Reference< css::datatransfer::XTransferable > xRet( pTransferable );
+    rtl::Reference<SdTransferable> pTransferable = new SdTransferable( &mrDoc, nullptr, false );
 
-    SD_MOD()->pTransferClip = pTransferable;
+    SD_MOD()->pTransferClip = pTransferable.get();
 
-    mrDoc.CreatingDataObj( pTransferable );
+    mrDoc.CreatingDataObj( pTransferable.get() );
     pTransferable->SetWorkDocument( static_cast<SdDrawDocument*>(CreateMarkedObjModel().release()) );
     mrDoc.CreatingDataObj( nullptr );
 
@@ -138,15 +137,14 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
     pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
     pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() );
 
-    return xRet;
+    return pTransferable;
 }
 
 css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObject( View* pWorkView, vcl::Window& rWindow, const Point& rDragPos )
 {
-    SdTransferable* pTransferable = new SdTransferable( &mrDoc, pWorkView, false );
-    css::uno::Reference< css::datatransfer::XTransferable > xRet( pTransferable );
+    rtl::Reference<SdTransferable> pTransferable = new SdTransferable( &mrDoc, pWorkView, false );
 
-    SD_MOD()->pTransferDrag = pTransferable;
+    SD_MOD()->pTransferDrag = pTransferable.get();
 
     std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
     OUString                        aDisplayName;
@@ -187,17 +185,16 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
     pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
     pTransferable->StartDrag( &rWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
 
-    return xRet;
+    return pTransferable;
 }
 
 css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDataObject( View* pWorkView, vcl::Window& rWindow )
 {
-    SdTransferable*                 pTransferable = new SdTransferable( &mrDoc, pWorkView, true );
-    css::uno::Reference< css::datatransfer::XTransferable > xRet( pTransferable );
+    rtl::Reference<SdTransferable> pTransferable = new SdTransferable( &mrDoc, pWorkView, true );
     std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
     const ::tools::Rectangle                 aMarkRect( GetAllMarkedRect() );
 
-    SD_MOD()->pTransferSelection = pTransferable;
+    SD_MOD()->pTransferSelection = pTransferable.get();
 
     if( mpDocSh )
     {
@@ -211,7 +208,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat
     pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
     pTransferable->CopyToSelection( &rWindow );
 
-    return xRet;
+    return pTransferable;
 }
 
 void View::UpdateSelectionClipboard( bool bForceDeselect )
diff --git a/sdext/source/pdfimport/pdfiadaptor.cxx b/sdext/source/pdfimport/pdfiadaptor.cxx
index a8b045ca0ccc..0291ac95d925 100644
--- a/sdext/source/pdfimport/pdfiadaptor.cxx
+++ b/sdext/source/pdfimport/pdfiadaptor.cxx
@@ -27,6 +27,7 @@
 
 #include <osl/file.h>
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 
 #include <cppuhelper/supportsservice.hxx>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -332,30 +333,30 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
 sdext_PDFIRawAdaptor_Writer_get_implementation(
     css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.WriterPDFImport", context );
+    rtl::Reference<pdfi::PDFIRawAdaptor> pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.WriterPDFImport", context );
     pAdaptor->setTreeVisitorFactory(pdfi::createWriterTreeVisitorFactory());
     pAdaptor->acquire();
-    return static_cast<cppu::OWeakObject*>(pAdaptor);
+    return static_cast<cppu::OWeakObject*>(pAdaptor.get());
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
 sdext_PDFIRawAdaptor_Draw_get_implementation(
     css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.DrawPDFImport", context );
+    rtl::Reference<pdfi::PDFIRawAdaptor> pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.DrawPDFImport", context );
     pAdaptor->setTreeVisitorFactory(pdfi::createDrawTreeVisitorFactory());
     pAdaptor->acquire();
-    return static_cast<cppu::OWeakObject*>(pAdaptor);
+    return static_cast<cppu::OWeakObject*>(pAdaptor.get());
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
 sdext_PDFIRawAdaptor_Impress_get_implementation(
     css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    pdfi::PDFIRawAdaptor* pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.ImpressPDFImport", context );
+    rtl::Reference<pdfi::PDFIRawAdaptor> pAdaptor = new pdfi::PDFIRawAdaptor( "org.libreoffice.comp.documents.ImpressPDFImport", context );
     pAdaptor->setTreeVisitorFactory(pdfi::createImpressTreeVisitorFactory());
     pAdaptor->acquire();
-    return static_cast<cppu::OWeakObject*>(pAdaptor);
+    return static_cast<cppu::OWeakObject*>(pAdaptor.get());
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*


More information about the Libreoffice-commits mailing list