summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-21 20:02:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-22 17:30:15 +0100
commitdc37866f3266f92c71bb4b3cec2b869069230c28 (patch)
tree6adeb7ddb91f738f52d4b19ff41bf9a26897acaf
parentb8a38885093fc447792e6025b339f51e0874a66b (diff)
loplugin:refcounting in editeng
Change-Id: I7d00bede5dbf216e5d3d179a03b101322ae23e11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111287 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--editeng/source/accessibility/AccessibleContextBase.cxx10
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx4
-rw-r--r--editeng/source/accessibility/AccessibleHyperlink.cxx2
-rw-r--r--editeng/source/accessibility/AccessibleImageBullet.cxx2
-rw-r--r--editeng/source/editeng/impedit.cxx3
-rw-r--r--editeng/source/editeng/impedit2.cxx5
-rw-r--r--editeng/source/misc/unolingu.cxx2
-rw-r--r--editeng/source/uno/unotext.cxx13
-rw-r--r--editeng/source/uno/unotext2.cxx4
-rw-r--r--editeng/source/xml/xmltxtexp.cxx2
-rw-r--r--editeng/source/xml/xmltxtimp.cxx5
-rw-r--r--include/editeng/unolingu.hxx3
12 files changed, 26 insertions, 29 deletions
diff --git a/editeng/source/accessibility/AccessibleContextBase.cxx b/editeng/source/accessibility/AccessibleContextBase.cxx
index 72ac002c9940..6683d7eec29d 100644
--- a/editeng/source/accessibility/AccessibleContextBase.cxx
+++ b/editeng/source/accessibility/AccessibleContextBase.cxx
@@ -31,6 +31,7 @@
#include <comphelper/accessibleeventnotifier.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
#include <utility>
@@ -54,7 +55,7 @@ AccessibleContextBase::AccessibleContextBase (
maRole(aRole)
{
// Create the state set.
- ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper ();
+ rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper ();
mxStateSet = pStateSet;
// Set some states. Don't use the SetState method because no events
@@ -67,8 +68,7 @@ AccessibleContextBase::AccessibleContextBase (
pStateSet->AddState (AccessibleStateType::SELECTABLE);
// Create the relation set.
- ::utl::AccessibleRelationSetHelper* pRelationSet = new ::utl::AccessibleRelationSetHelper ();
- mxRelationSet = pRelationSet;
+ mxRelationSet = new ::utl::AccessibleRelationSetHelper ();
}
AccessibleContextBase::~AccessibleContextBase()
@@ -301,7 +301,7 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL
uno::Reference<XAccessibleStateSet> SAL_CALL
AccessibleContextBase::getAccessibleStateSet()
{
- ::utl::AccessibleStateSetHelper* pStateSet = nullptr;
+ rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet;
if (rBHelper.bDisposed)
{
@@ -319,7 +319,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL
pStateSet = new ::utl::AccessibleStateSetHelper (*pStateSet);
}
- return uno::Reference<XAccessibleStateSet>(pStateSet);
+ return pStateSet;
}
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index a12bfe7232de..fa7c00b85a99 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -125,7 +125,7 @@ namespace accessibility
try
{
// Create the state set.
- ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper ();
+ rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper ();
mxStateSet = pStateSet;
// these are always on
@@ -770,7 +770,7 @@ namespace accessibility
// and CONTENT_FLOWS_TO
if ( mpParaManager )
{
- utl::AccessibleRelationSetHelper* pAccRelSetHelper =
+ rtl::Reference<utl::AccessibleRelationSetHelper> pAccRelSetHelper =
new utl::AccessibleRelationSetHelper();
sal_Int32 nMyParaIndex( GetParagraphIndex() );
// relation CONTENT_FLOWS_FROM
diff --git a/editeng/source/accessibility/AccessibleHyperlink.cxx b/editeng/source/accessibility/AccessibleHyperlink.cxx
index a1c48f9693fb..25d9683fceff 100644
--- a/editeng/source/accessibility/AccessibleHyperlink.cxx
+++ b/editeng/source/accessibility/AccessibleHyperlink.cxx
@@ -82,7 +82,7 @@ namespace accessibility
if( isValid() && ( nIndex == 0 ) )
{
- ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
+ rtl::Reference<::comphelper::OAccessibleKeyBindingHelper> pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
xKeyBinding = pKeyBindingHelper;
awt::KeyStroke aKeyStroke;
diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx
index b75d3f32194d..a5dc2b66bd92 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.cxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.cxx
@@ -65,7 +65,7 @@ namespace accessibility
try
{
// Create the state set.
- ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper ();
+ rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper ();
mxStateSet = pStateSet;
// these are always on
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index ac51af7597ab..216914946734 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -2619,8 +2619,7 @@ void ImpEditView::AddDragAndDropListeners()
if (!xDropTarget.is())
return;
- vcl::unohelper::DragAndDropWrapper* pDnDWrapper = new vcl::unohelper::DragAndDropWrapper(this);
- mxDnDListener = pDnDWrapper;
+ mxDnDListener = new vcl::unohelper::DragAndDropWrapper(this);
css::uno::Reference<css::datatransfer::dnd::XDragGestureRecognizer> xDragGestureRecognizer(xDropTarget, uno::UNO_QUERY);
if (xDragGestureRecognizer.is())
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 8ea35eb3e91f..2ea63b8d3cf5 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3473,8 +3473,7 @@ uno::Reference< datatransfer::XTransferable > ImpEditEngine::CreateTransferable(
EditSelection aSelection( rSelection );
aSelection.Adjust( GetEditDoc() );
- EditDataObject* pDataObj = new EditDataObject;
- uno::Reference< datatransfer::XTransferable > xDataObj = pDataObj;
+ rtl::Reference<EditDataObject> pDataObj = new EditDataObject;
pDataObj->GetString() = convertLineEnd(GetSelected(aSelection), GetSystemLineEnd()); // System specific
@@ -3513,7 +3512,7 @@ uno::Reference< datatransfer::XTransferable > ImpEditEngine::CreateTransferable(
}
}
- return xDataObj;
+ return pDataObj;
}
EditSelection ImpEditEngine::PasteText( uno::Reference< datatransfer::XTransferable > const & rxDataObj, const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial )
diff --git a/editeng/source/misc/unolingu.cxx b/editeng/source/misc/unolingu.cxx
index af32538f9702..a65af50b37e1 100644
--- a/editeng/source/misc/unolingu.cxx
+++ b/editeng/source/misc/unolingu.cxx
@@ -447,7 +447,7 @@ void LinguMgrExitLstnr::AtExit()
}
-LinguMgrExitLstnr * LinguMgr::pExitLstnr = nullptr;
+rtl::Reference<LinguMgrExitLstnr> LinguMgr::pExitLstnr;
bool LinguMgr::bExiting = false;
uno::Reference< XLinguServiceManager2 > LinguMgr::xLngSvcMgr;
uno::Reference< XSpellChecker1 > LinguMgr::xSpell;
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 9476ba7659c7..851efc127671 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -318,7 +318,7 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart()
if(pText == nullptr)
throw uno::RuntimeException();
- SvxUnoTextRange* pRange = new SvxUnoTextRange( *pText );
+ rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *pText );
xRange = pRange;
ESelection aNewSel = maSelection;
@@ -346,7 +346,7 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd()
if(pText == nullptr)
throw uno::RuntimeException();
- SvxUnoTextRange* pNew = new SvxUnoTextRange( *pText );
+ rtl::Reference<SvxUnoTextRange> pNew = new SvxUnoTextRange( *pText );
xRet = pNew;
ESelection aNewSel = maSelection;
@@ -1695,10 +1695,9 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextBase::getImplementationId()
uno::Reference< text::XTextCursor > SvxUnoTextBase::createTextCursorBySelection( const ESelection& rSel )
{
- SvxUnoTextCursor* pCursor = new SvxUnoTextCursor( *this );
- uno::Reference< text::XTextCursor > xCursor( pCursor );
+ rtl::Reference<SvxUnoTextCursor> pCursor = new SvxUnoTextCursor( *this );
pCursor->SetSelection( rSel );
- return xCursor;
+ return pCursor;
}
// XSimpleText
@@ -2059,7 +2058,7 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraph(
ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), pTextForwarder, nPara );
pTextForwarder->QuickSetAttribs( aItemSet, aSel );
pEditSource->UpdateData();
- SvxUnoTextRange* pRange = new SvxUnoTextRange( *this );
+ rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this );
xRet = pRange;
pRange->SetSelection( aSel );
}
@@ -2104,7 +2103,7 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion(
SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara );
pTextForwarder->QuickSetAttribs( aItemSet, aSel );
- SvxUnoTextRange* pRange = new SvxUnoTextRange( *this );
+ rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this );
xRet = pRange;
pRange->SetSelection( aSel );
for( const beans::PropertyValue& rProp : rCharAndParaProps )
diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx
index 04d63ea6b839..d88bb55daa9d 100644
--- a/editeng/source/uno/unotext2.cxx
+++ b/editeng/source/uno/unotext2.cxx
@@ -54,7 +54,7 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase
for( sal_Int32 currentPara = rSel.nStartPara; currentPara < maxParaIndex; currentPara++ )
{
const SvxUnoTextRangeBaseVec& rRanges( mpEditSource->getRanges() );
- SvxUnoTextContent* pContent = nullptr;
+ rtl::Reference<SvxUnoTextContent> pContent;
sal_Int32 nStartPos = 0;
sal_Int32 nEndPos = pTextForwarder->GetTextLen( currentPara );
if( currentPara == rSel.nStartPara )
@@ -404,7 +404,7 @@ SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration(const SvxUnoTextBase& rPa
ESelection aSel( nParagraph, nStartPos, nParagraph, nEndPos );
const SvxUnoTextRangeBaseVec& rRanges( mpEditSource->getRanges() );
- SvxUnoTextRange* pRange = nullptr;
+ rtl::Reference<SvxUnoTextRange> pRange;
for (auto const& elemRange : rRanges)
{
if (pRange)
diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx
index af20aeb2ffb0..4ad23b10abae 100644
--- a/editeng/source/xml/xmltxtexp.cxx
+++ b/editeng/source/xml/xmltxtexp.cxx
@@ -283,7 +283,7 @@ SvxXMLTextExportComponent::SvxXMLTextExportComponent(
};
static SvxItemPropertySet aSvxXMLTextExportComponentPropertySet( SvxXMLTextExportComponentPropertyMap, EditEngine::GetGlobalItemPool() );
- SvxUnoText* pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextExportComponentPropertySet, mxText );
+ rtl::Reference<SvxUnoText> pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextExportComponentPropertySet, mxText );
pUnoText->SetSelection( rSel );
mxText = pUnoText;
diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx
index ff5a1e9b6131..f5532f009196 100644
--- a/editeng/source/xml/xmltxtimp.cxx
+++ b/editeng/source/xml/xmltxtimp.cxx
@@ -157,9 +157,8 @@ EditPaM SvxReadXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection
ESelection aSel(rSel.nStartPara+1, 0, rSel.nEndPara+1, 0);
uno::Reference<text::XText > xParent;
- SvxUnoText* pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextImportComponentPropertySet, xParent );
+ rtl::Reference<SvxUnoText> pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextImportComponentPropertySet, xParent );
pUnoText->SetSelection( aSel );
- uno::Reference<text::XText > xText( pUnoText );
try
{
@@ -202,7 +201,7 @@ EditPaM SvxReadXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection
*/
// uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTextImportComponent( xText ) );
- rtl::Reference< SvxXMLXTextImportComponent > xImport( new SvxXMLXTextImportComponent( xContext, xText ) );
+ rtl::Reference< SvxXMLXTextImportComponent > xImport( new SvxXMLXTextImportComponent( xContext, pUnoText ) );
xml::sax::InputSource aParserInput;
aParserInput.aInputStream = xInputStream;
diff --git a/include/editeng/unolingu.hxx b/include/editeng/unolingu.hxx
index 3032b7b7dc74..3158af872e77 100644
--- a/include/editeng/unolingu.hxx
+++ b/include/editeng/unolingu.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_EDITENG_UNOLINGU_HXX
#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <editeng/editengdllapi.h>
@@ -52,7 +53,7 @@ class EDITENG_DLLPUBLIC LinguMgr
static css::uno::Reference< css::linguistic2::XDictionary > xIgnoreAll;
static css::uno::Reference< css::linguistic2::XDictionary > xChangeAll;
- static LinguMgrExitLstnr *pExitLstnr;
+ static rtl::Reference<LinguMgrExitLstnr> pExitLstnr;
static bool bExiting;
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpell();