diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-21 12:33:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-21 16:13:31 +0100 |
commit | 78040af9acea0ab681aa54ff23844b647bc9b4f3 (patch) | |
tree | 6fb704389c3e98594d6bf2f187bf295aa42c77ef /sc | |
parent | 8f231fc5df201c45d16bce0b4b17f727842b2121 (diff) |
loplugin:refcounting in sc
Change-Id: Id0ba24985aab36b931fa74b266dc5bf0bef62bb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111273
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
40 files changed, 115 insertions, 158 deletions
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx index ee6b59eec1ab..3c19e9ff88de 100644 --- a/sc/inc/cellsuno.hxx +++ b/sc/inc/cellsuno.hxx @@ -1096,7 +1096,7 @@ private: ScRange aTotalRange; private: - ScCellRangeObj* GetObjectByIndex_Impl(tools::Long nIndex) const; + rtl::Reference<ScCellRangeObj> GetObjectByIndex_Impl(tools::Long nIndex) const; public: ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rR); @@ -1137,7 +1137,7 @@ private: private: void Advance_Impl(); - ScCellRangeObj* NextObject_Impl(); + rtl::Reference<ScCellRangeObj> NextObject_Impl(); public: ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rR); diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index f9951cb8da04..b31d9045f79e 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -751,8 +751,7 @@ void ScDPObject::CreateObjects() pData->SetEmptyFlags(pSaveData->GetIgnoreEmptyRows(), pSaveData->GetRepeatIfEmpty()); pData->ReloadCacheTable(); - ScDPSource* pSource = new ScDPSource( pData ); - xSource = pSource; + xSource = new ScDPSource( pData ); } } diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx index 02e0b7b2cbec..772d59a9d65f 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx @@ -41,8 +41,7 @@ using namespace xmloff::token; ScChangeTrackingExportHelper::ScChangeTrackingExportHelper(ScXMLExport& rTempExport) : rExport(rTempExport), - pChangeTrack(nullptr), - pEditTextObj(nullptr) + pChangeTrack(nullptr) { pChangeTrack = rExport.GetDocument() ? rExport.GetDocument()->GetChangeTrack() : nullptr; } @@ -287,13 +286,9 @@ void ScChangeTrackingExportHelper::WriteEditCell(const ScCellValue& rCell) if (rCell.mpEditText && !sString.isEmpty()) { if (!pEditTextObj) - { pEditTextObj = new ScEditEngineTextObj(); - xText.set(pEditTextObj); - } pEditTextObj->SetText(*rCell.mpEditText); - if (xText.is()) - rExport.GetTextParagraphExport()->exportText(xText, false, false); + rExport.GetTextParagraphExport()->exportText(pEditTextObj, false, false); } } @@ -597,14 +592,10 @@ void ScChangeTrackingExportHelper::CollectCellAutoStyles(const ScCellValue& rCel return; if (!pEditTextObj) - { pEditTextObj = new ScEditEngineTextObj(); - xText.set(pEditTextObj); - } pEditTextObj->SetText(*rCell.mpEditText); - if (xText.is()) - rExport.GetTextParagraphExport()->collectTextAutoStyles(xText, false, false); + rExport.GetTextParagraphExport()->collectTextAutoStyles(pEditTextObj, false, false); } void ScChangeTrackingExportHelper::CollectActionAutoStyles(const ScChangeAction* pAction) diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx index fa7c3a941176..c9c12c217653 100644 --- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx +++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SC_SOURCE_FILTER_XML_XMLCHANGETRACKINGEXPORTHELPER_HXX #include <xmloff/xmltoken.hxx> +#include <rtl/ref.hxx> namespace com::sun::star::text { @@ -40,8 +41,7 @@ class ScChangeTrackingExportHelper ScXMLExport& rExport; ScChangeTrack* pChangeTrack; - ScEditEngineTextObj* pEditTextObj; - css::uno::Reference<css::text::XText> xText; + rtl::Reference<ScEditEngineTextObj> pEditTextObj; static OUString GetChangeID(const sal_uInt32 nActionNumber); void GetAcceptanceState(const ScChangeAction* pAction); diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 171d36e02ffb..7e95ae713000 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3380,10 +3380,10 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, if ( !sRanges.isEmpty() ) { bIsChart = true; - SvXMLAttributeList* pAttrList = new SvXMLAttributeList(); + rtl::Reference<SvXMLAttributeList> pAttrList = new SvXMLAttributeList(); pAttrList->AddAttribute( GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken( XML_NOTIFY_ON_UPDATE_OF_RANGES ) ), sRanges ); - GetShapeExport()->exportShape( xShape, SEF_DEFAULT, pPoint, pAttrList ); + GetShapeExport()->exportShape( xShape, SEF_DEFAULT, pPoint, pAttrList.get() ); } } } @@ -3405,7 +3405,7 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, bIsChart = true; uno::Sequence< OUString > aRepresentations( xReceiver->getUsedRangeRepresentations()); - SvXMLAttributeList* pAttrList = nullptr; + rtl::Reference<SvXMLAttributeList> pAttrList; if(aRepresentations.hasElements()) { // add the ranges used by the chart to the shape @@ -3417,7 +3417,7 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, pAttrList->AddAttribute( GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges ); } - GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint, pAttrList); + GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint, pAttrList.get()); } } } diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index 734e9e085302..bb434037438a 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -227,7 +227,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else @@ -277,13 +277,13 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL { SolarMutexGuard aGuard; IsObjectValid(); - utl::AccessibleRelationSetHelper* pRelationSet = nullptr; + rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSet; if (mpAccDoc) pRelationSet = mpAccDoc->GetRelationSet(&maCellAddress); if (!pRelationSet) pRelationSet = new utl::AccessibleRelationSetHelper(); - FillDependents(pRelationSet); - FillPrecedents(pRelationSet); + FillDependents(pRelationSet.get()); + FillPrecedents(pRelationSet.get()); return pRelationSet; } diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx index fc3157cf57a0..6c5867c12093 100644 --- a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx +++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx @@ -158,10 +158,10 @@ ScCsvControl& ScAccessibleCsvControl::implGetControl() const return *mpControl; } -AccessibleStateSetHelper* ScAccessibleCsvControl::implCreateStateSet() +rtl::Reference<AccessibleStateSetHelper> ScAccessibleCsvControl::implCreateStateSet() { SolarMutexGuard aGuard; - AccessibleStateSetHelper* pStateSet = new AccessibleStateSetHelper(); + rtl::Reference<AccessibleStateSetHelper> pStateSet = new AccessibleStateSetHelper(); if (isAlive()) { const ScCsvControl& rCtrl = implGetControl(); @@ -291,7 +291,7 @@ Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvRuler::getAccessible { SolarMutexGuard aGuard; ensureAlive(); - AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper(); + rtl::Reference<AccessibleRelationSetHelper> pRelationSet = new AccessibleRelationSetHelper(); ScCsvRuler& rRuler = implGetRuler(); ScCsvTableBox* pTableBox = rRuler.GetTableBox(); @@ -311,7 +311,7 @@ Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvRuler::getAccessible Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleStateSet() { SolarMutexGuard aGuard; - AccessibleStateSetHelper* pStateSet = implCreateStateSet(); + rtl::Reference<AccessibleStateSetHelper> pStateSet = implCreateStateSet(); if( isAlive() ) { pStateSet->AddState( AccessibleStateType::FOCUSABLE ); @@ -851,7 +851,7 @@ Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleR { SolarMutexGuard aGuard; ensureAlive(); - AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper(); + rtl::Reference<AccessibleRelationSetHelper> pRelationSet = new AccessibleRelationSetHelper(); ScCsvGrid& rGrid = implGetGrid(); ScCsvTableBox* pTableBox = rGrid.GetTableBox(); @@ -874,7 +874,7 @@ Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleR Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleStateSet() { SolarMutexGuard aGuard; - AccessibleStateSetHelper* pStateSet = implCreateStateSet(); + rtl::Reference<AccessibleStateSetHelper> pStateSet = implCreateStateSet(); if( isAlive() ) { pStateSet->AddState( AccessibleStateType::FOCUSABLE ); @@ -1358,7 +1358,7 @@ Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvCell::getAccessibleR Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvCell::getAccessibleStateSet() { SolarMutexGuard aGuard; - AccessibleStateSetHelper* pStateSet = implCreateStateSet(); + rtl::Reference<AccessibleStateSetHelper> pStateSet = implCreateStateSet(); if( isAlive() ) { const ScCsvGrid& rGrid = implGetGrid(); diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index ef0dd31d337a..2fcd982ae3a2 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -247,7 +247,7 @@ public: SdrPage* GetDrawPage() const; - utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const; + rtl::Reference<utl::AccessibleRelationSetHelper> GetRelationSet(const ScAddress* pAddress) const; void VisAreaChanged() const; private: @@ -887,9 +887,9 @@ SdrPage* ScChildrenShapes::GetDrawPage() const return pDrawPage; } -utl::AccessibleRelationSetHelper* ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const +rtl::Reference<utl::AccessibleRelationSetHelper> ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const { - utl::AccessibleRelationSetHelper* pRelationSet = nullptr; + rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSet; for (const ScAccessibleShapeData* pAccShapeData : maZOrderedShapes) { if (pAccShapeData && @@ -1136,7 +1136,7 @@ std::optional<ScAddress> ScChildrenShapes::GetAnchor(const uno::Reference<drawin uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const ScAccessibleShapeData* pData) const { - utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper(); + rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSet = new utl::AccessibleRelationSetHelper(); if (pData && mpAccessibleDocument) { @@ -1327,7 +1327,6 @@ ScAccessibleDocument::ScAccessibleDocument( : ScAccessibleDocumentBase(rxParent), mpViewShell(pViewShell), meSplitPos(eSplitPos), - mpTempAccEdit(nullptr), mbCompleteSheetSelected(false) { maVisArea = GetVisibleArea_Impl(); @@ -1739,7 +1738,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else @@ -2034,9 +2033,9 @@ Size ScAccessibleDocument::LogicToPixel (const Size& rSize) const //===== internal ======================================================== -utl::AccessibleRelationSetHelper* ScAccessibleDocument::GetRelationSet(const ScAddress* pAddress) const +rtl::Reference<utl::AccessibleRelationSetHelper> ScAccessibleDocument::GetRelationSet(const ScAddress* pAddress) const { - utl::AccessibleRelationSetHelper* pRelationSet = nullptr; + rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSet; if (mpChildrenShapes) pRelationSet = mpChildrenShapes->GetRelationSet(pAddress); return pRelationSet; diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx index 44c36c2a5d77..336fd112af8b 100644 --- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx @@ -1429,7 +1429,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDocumentPagePreview::ge uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else diff --git a/sc/source/ui/Accessibility/AccessibleEditObject.cxx b/sc/source/ui/Accessibility/AccessibleEditObject.cxx index d0afd2c8196c..d416b452ddfa 100644 --- a/sc/source/ui/Accessibility/AccessibleEditObject.cxx +++ b/sc/source/ui/Accessibility/AccessibleEditObject.cxx @@ -274,7 +274,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else @@ -516,8 +516,7 @@ uno::Reference< XAccessibleRelationSet > ScAccessibleEditObject::getAccessibleRe { SolarMutexGuard aGuard; vcl::Window* pWindow = mpWindow; - utl::AccessibleRelationSetHelper* rRelationSet = new utl::AccessibleRelationSetHelper; - uno::Reference< XAccessibleRelationSet > rSet = rRelationSet; + rtl::Reference<utl::AccessibleRelationSetHelper> rRelationSet = new utl::AccessibleRelationSetHelper; if ( pWindow ) { vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); @@ -532,7 +531,7 @@ uno::Reference< XAccessibleRelationSet > ScAccessibleEditObject::getAccessibleRe uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() }; rRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) ); } - return rSet; + return rRelationSet; } return uno::Reference< XAccessibleRelationSet >(); } diff --git a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx index 41d189325f3a..473835441a6e 100644 --- a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx +++ b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx @@ -258,7 +258,7 @@ uno::Reference< XAccessibleStateSet > SAL_CALL ScAccessiblePageHeader::getAccess uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else diff --git a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx index f3e8e0c962f3..9ea60780bfea 100644 --- a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx +++ b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx @@ -149,7 +149,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc()) pStateSet->AddState(AccessibleStateType::DEFUNC); else diff --git a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx index e6d28dc83531..544775e79a7a 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx @@ -149,7 +149,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessiblePreviewCell::getAccessi uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else diff --git a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx index 8d2b6cafcf68..c99fb36e8864 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx @@ -233,7 +233,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessiblePreviewHeaderCell::getA uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else diff --git a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx index aced9a883d98..7eea5d79ebc2 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx @@ -507,7 +507,7 @@ uno::Reference< XAccessibleStateSet > SAL_CALL ScAccessiblePreviewTable::getAcce uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx index 23de41a4bec4..aee01834103e 100644 --- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx +++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx @@ -1002,12 +1002,12 @@ sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getBackground( ) uno::Reference<XAccessibleRelationSet> SAL_CALL ScAccessibleSpreadsheet::getAccessibleRelationSet() { - utl::AccessibleRelationSetHelper* pRelationSet = nullptr; + rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSet; if(mpAccDoc) pRelationSet = mpAccDoc->GetRelationSet(nullptr); - if (!pRelationSet) - pRelationSet = new utl::AccessibleRelationSetHelper(); - return pRelationSet; + if (pRelationSet) + return pRelationSet; + return new utl::AccessibleRelationSetHelper(); } uno::Reference<XAccessibleStateSet> SAL_CALL @@ -1020,7 +1020,7 @@ uno::Reference<XAccessibleStateSet> SAL_CALL uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); xParentStates = xParentContext->getAccessibleStateSet(); } - utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); + rtl::Reference<utl::AccessibleStateSetHelper> pStateSet = new utl::AccessibleStateSetHelper(); if (IsDefunc(xParentStates)) pStateSet->AddState(AccessibleStateType::DEFUNC); else diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index a3526cebb19d..e76b0e783734 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -668,7 +668,7 @@ void ScDrawTransferObj::CreateOLEData() // No OLE object present. return; - SvEmbedTransferHelper* pEmbedTransfer = + rtl::Reference<SvEmbedTransferHelper> pEmbedTransfer = new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect()); diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index cd9961bc364b..0429da49731c 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1551,7 +1551,6 @@ void ScTextWnd::InitEditEngine() } ScTextWnd::ScTextWnd(ScTextWndGroup& rParent, ScTabViewShell* pViewSh) : - pAcc(nullptr), bIsRTL(AllSettings::GetLayoutRTL()), bIsInsertMode(true), bFormulaMode (false), diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx index 193113429fb8..ce3624b27c85 100644 --- a/sc/source/ui/app/seltrans.cxx +++ b/sc/source/ui/app/seltrans.cxx @@ -66,9 +66,9 @@ static bool lcl_IsURLButton( SdrObject* pObject ) return bRet; } -ScSelectionTransferObj* ScSelectionTransferObj::CreateFromView( ScTabView* pView ) +rtl::Reference<ScSelectionTransferObj> ScSelectionTransferObj::CreateFromView( ScTabView* pView ) { - ScSelectionTransferObj* pRet = nullptr; + rtl::Reference<ScSelectionTransferObj> pRet; try { diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx index 680e91765af5..3b46a14e190d 100644 --- a/sc/source/ui/drawfunc/fuins2.cxx +++ b/sc/source/ui/drawfunc/fuins2.cxx @@ -670,11 +670,10 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV } pView->AddUndo(std::make_unique<SdrUndoNewObj>(*pObj)); - ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener(); + rtl::Reference<::svt::DialogClosedListener> pListener = new ::svt::DialogClosedListener(); pListener->SetDialogClosedLink( rLink ); - css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener ); - xDialog->startExecuteModal( xListener ); + xDialog->startExecuteModal( pListener ); } else { diff --git a/sc/source/ui/inc/AccessibleCsvControl.hxx b/sc/source/ui/inc/AccessibleCsvControl.hxx index 975698d94dde..9cdd4c021d7d 100644 --- a/sc/source/ui/inc/AccessibleCsvControl.hxx +++ b/sc/source/ui/inc/AccessibleCsvControl.hxx @@ -80,7 +80,7 @@ protected: ScCsvControl& implGetControl() const; /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */ - ::utl::AccessibleStateSetHelper* implCreateStateSet(); + rtl::Reference<::utl::AccessibleStateSetHelper> implCreateStateSet(); }; class ScCsvRuler; diff --git a/sc/source/ui/inc/AccessibleDocument.hxx b/sc/source/ui/inc/AccessibleDocument.hxx index 975046b55be5..acff21367fcf 100644 --- a/sc/source/ui/inc/AccessibleDocument.hxx +++ b/sc/source/ui/inc/AccessibleDocument.hxx @@ -204,7 +204,7 @@ public: ///======== internal ===================================================== - utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const; + rtl::Reference<utl::AccessibleRelationSetHelper> GetRelationSet(const ScAddress* pAddress) const; css::uno::Reference< css::accessibility::XAccessible > GetAccessibleSpreadsheet(); @@ -229,7 +229,7 @@ private: ScSplitPos meSplitPos; rtl::Reference<ScAccessibleSpreadsheet> mpAccessibleSpreadsheet; std::unique_ptr<ScChildrenShapes> mpChildrenShapes; - ScAccessibleEditObject* mpTempAccEdit; + rtl::Reference<ScAccessibleEditObject> mpTempAccEdit; css::uno::Reference<css::accessibility::XAccessible> mxTempAcc; tools::Rectangle maVisArea; bool mbCompleteSheetSelected; diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx index eb1e138b24e2..382c31b0efb0 100644 --- a/sc/source/ui/inc/inputwin.hxx +++ b/sc/source/ui/inc/inputwin.hxx @@ -139,7 +139,7 @@ private: typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector; - ScAccessibleEditObject* pAcc; + rtl::Reference<ScAccessibleEditObject> pAcc; OUString aString; vcl::Font aTextFont; diff --git a/sc/source/ui/inc/seltrans.hxx b/sc/source/ui/inc/seltrans.hxx index 83adb2c11eb2..108a0dab2f35 100644 --- a/sc/source/ui/inc/seltrans.hxx +++ b/sc/source/ui/inc/seltrans.hxx @@ -54,7 +54,7 @@ private: public: // creates an object if the view has a valid selection, // returns NULL otherwise - static ScSelectionTransferObj* CreateFromView( ScTabView* pSource ); + static rtl::Reference<ScSelectionTransferObj> CreateFromView( ScTabView* pSource ); virtual ~ScSelectionTransferObj() override; diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx index 7d67a7500297..5bce89b41f4a 100644 --- a/sc/source/ui/inc/tphfedit.hxx +++ b/sc/source/ui/inc/tphfedit.hxx @@ -25,6 +25,7 @@ #include <cppuhelper/weakref.hxx> #include <svx/weldeditview.hxx> #include <editeng/svxenum.hxx> +#include <unotools/weakref.hxx> #include <functional> @@ -78,8 +79,7 @@ private: bool mbRTL; weld::Window* mpDialog; - css::uno::WeakReference< css::accessibility::XAccessible > xAcc; - ScAccessibleEditObject* pAcc; + unotools::WeakReference<ScAccessibleEditObject> mxAcc; Link<ScEditWindow&,void> aObjectSelectLink; std::function<void (ScEditWindow&)> m_GetFocusLink; diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 2e90c8b5cc4e..9431c9aa16da 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -116,7 +116,7 @@ public: bool bIncludeObjects ); bool CopyToClipMultiRange( const ScDocument* pClipDoc, const ScRangeList& rRanges, bool bCut, bool bApi, bool bIncludeObjects ); - ScTransferObj* CopyToTransferable(); + rtl::Reference<ScTransferObj> CopyToTransferable(); SC_DLLPUBLIC bool PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, ScPasteFunc nFunction = ScPasteFunc::NONE, bool bSkipEmpty = false, bool bTranspose = false, bool bAsLink = false, diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx index 16be645815ac..c2c6ac4f16f1 100644 --- a/sc/source/ui/pagedlg/tphfedit.cxx +++ b/sc/source/ui/pagedlg/tphfedit.cxx @@ -59,7 +59,6 @@ ScEditWindow::ScEditWindow(ScEditWindowLocation eLoc, weld::Window* pDialog) : eLocation(eLoc) , mbRTL(ScGlobal::IsSystemRTL()) , mpDialog(pDialog) - , pAcc(nullptr) { } @@ -88,7 +87,8 @@ void ScEditWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea) if (mbRTL) m_xEditEngine->SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::R2L); - if (!pAcc) + auto tmpAcc = mxAcc.get(); + if (!tmpAcc) return; OUString sName; @@ -105,19 +105,15 @@ void ScEditWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea) break; } - pAcc->InitAcc(nullptr, m_xEditView.get(), nullptr, nullptr, + tmpAcc->InitAcc(nullptr, m_xEditView.get(), nullptr, nullptr, sName, pDrawingArea->get_tooltip_text()); } ScEditWindow::~ScEditWindow() { // delete Accessible object before deleting EditEngine and EditView - if (pAcc) - { - css::uno::Reference< css::accessibility::XAccessible > xTemp = xAcc; - if (xTemp.is()) - pAcc->dispose(); - } + if (auto tmp = mxAcc.get()) + tmp->dispose(); } void ScEditWindow::SetNumType(SvxNumType eNumType) @@ -224,26 +220,18 @@ void ScEditWindow::GetFocus() assert(m_GetFocusLink); m_GetFocusLink(*this); - css::uno::Reference< css::accessibility::XAccessible > xTemp = xAcc; - if (xTemp.is() && pAcc) - { - pAcc->GotFocus(); - } - else - pAcc = nullptr; + if (auto tmp = mxAcc.get()) + tmp->GotFocus(); WeldEditView::GetFocus(); } void ScEditWindow::LoseFocus() { - css::uno::Reference< css::accessibility::XAccessible > xTemp = xAcc; - if (xTemp.is() && pAcc) - { - pAcc->LostFocus(); - } + if (auto xTemp = mxAcc.get()) + xTemp->LostFocus(); else - pAcc = nullptr; + mxAcc = nullptr; WeldEditView::LoseFocus(); } @@ -261,10 +249,9 @@ bool ScEditWindow::MouseButtonDown(const MouseEvent& rMEvt) css::uno::Reference< css::accessibility::XAccessible > ScEditWindow::CreateAccessible() { - pAcc = new ScAccessibleEditControlObject(this, ScAccessibleEditObject::EditControl); - css::uno::Reference< css::accessibility::XAccessible > xAccessible = pAcc; - xAcc = xAccessible; - return pAcc; + rtl::Reference<ScAccessibleEditControlObject> tmp = new ScAccessibleEditControlObject(this, ScAccessibleEditObject::EditControl); + mxAcc = tmp.get(); + return css::uno::Reference<css::accessibility::XAccessible>(static_cast<cppu::OWeakObject*>(tmp.get()), css::uno::UNO_QUERY_THROW); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 94b3dea9b100..993cc5babce5 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -5372,7 +5372,7 @@ uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFil { SolarMutexGuard aGuard; ScDocShell* pDocSh = GetDocShell(); - ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); + rtl::Reference<ScFilterDescriptor> pNew = new ScFilterDescriptor(pDocSh); if ( !bEmpty && pDocSh ) { // create DB-Area only during execution; API always the exact area @@ -5533,7 +5533,7 @@ uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTot sal_Bool bEmpty ) { SolarMutexGuard aGuard; - ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor; + rtl::Reference<ScSubTotalDescriptor> pNew = new ScSubTotalDescriptor; ScDocShell* pDocSh = GetDocShell(); if ( !bEmpty && pDocSh ) { @@ -6005,8 +6005,7 @@ uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange( const uno::Reference<text::XTextRange>& aTextPosition ) { SolarMutexGuard aGuard; - SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this ); - uno::Reference<text::XTextCursor> xCursor(pCursor); + rtl::Reference<SvxUnoTextCursor> pCursor = new ScCellTextCursor( *this ); SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( aTextPosition ); if(pRange) @@ -6021,7 +6020,7 @@ uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange( } - return xCursor; + return pCursor; } OUString SAL_CALL ScCellObj::getString() @@ -8858,11 +8857,11 @@ void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) } } -ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(tools::Long nIndex) const +rtl::Reference<ScCellRangeObj> ScCellFormatsObj::GetObjectByIndex_Impl(tools::Long nIndex) const { //! access the AttrArrays directly !!!! - ScCellRangeObj* pRet = nullptr; + rtl::Reference<ScCellRangeObj> pRet; if (pDocShell) { ScDocument& rDoc = pDocShell->GetDocument(); @@ -8996,9 +8995,9 @@ void ScCellFormatsEnumeration::Advance_Impl() bAtEnd = true; // document vanished or so } -ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl() +rtl::Reference<ScCellRangeObj> ScCellFormatsEnumeration::NextObject_Impl() { - ScCellRangeObj* pRet = nullptr; + rtl::Reference<ScCellRangeObj> pRet; if (pDocShell && !bAtEnd) { if ( aNext.aStart == aNext.aEnd ) diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 0f385b6729b4..708833db0b1f 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -1478,7 +1478,7 @@ ScChart2DataProvider::createDataSource( // No chart position map instance. Bail out. return xResult; - ScChart2DataSource* pDS = nullptr; + rtl::Reference<ScChart2DataSource> pDS; ::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqs; // Fill Categories diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 6af98b387a1b..1cfcb23aad8e 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -834,10 +834,7 @@ uno::Reference<datatransfer::XTransferable> ScModelObj::getSelection() else if ( ScDrawShell * pDrawShell = dynamic_cast<ScDrawShell*>( pViewData->GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) ) ) xTransferable = pDrawShell->GetDrawView()->CopyToTransferable(); else - { - ScTransferObj* pObj = pViewData->GetViewShell()->CopyToTransferable(); - xTransferable.set( pObj ); - } + xTransferable = pViewData->GetViewShell()->CopyToTransferable(); if (!xTransferable.is()) xTransferable.set( aDataHelper.GetTransferable() ); @@ -2498,7 +2495,7 @@ uno::Reference<sheet::XConsolidationDescriptor> SAL_CALL ScModelObj::createConso sal_Bool bEmpty ) { SolarMutexGuard aGuard; - ScConsolidationDescriptor* pNew = new ScConsolidationDescriptor; + rtl::Reference<ScConsolidationDescriptor> pNew = new ScConsolidationDescriptor; if ( pDocShell && !bEmpty ) { ScDocument& rDoc = pDocShell->GetDocument(); @@ -2894,7 +2891,7 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName ) } else if ( aPropertyName == SC_UNO_REFERENCEDEVICE ) { - VCLXDevice* pXDev = new VCLXDevice(); + rtl::Reference<VCLXDevice> pXDev = new VCLXDevice(); pXDev->SetOutputDevice( rDoc.GetRefDevice() ); aRet <<= uno::Reference< awt::XDevice >( pXDev ); } diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 7497cd77892d..3534f7cea2ec 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -236,7 +236,7 @@ ScTableConditionalFormat::~ScTableConditionalFormat() void ScTableConditionalFormat::AddEntry_Impl(const ScCondFormatEntryItem& aEntry) { - ScTableConditionalEntry* pNew = new ScTableConditionalEntry(aEntry); + rtl::Reference<ScTableConditionalEntry> pNew = new ScTableConditionalEntry(aEntry); maEntries.emplace_back(pNew); } diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx index 6dbd130e2e56..7f26e409866c 100644 --- a/sc/source/ui/unoobj/shapeuno.cxx +++ b/sc/source/ui/unoobj/shapeuno.cxx @@ -1097,7 +1097,7 @@ void SAL_CALL ScShapeObj::insertTextContent( const uno::Reference<text::XTextRan // To insert it into drawing text, a SvxUnoTextField is needed instead. // The ScCellFieldObj object is left in non-inserted state. - SvxUnoTextField* pDrawField = new SvxUnoTextField( text::textfield::Type::URL ); + rtl::Reference<SvxUnoTextField> pDrawField = new SvxUnoTextField( text::textfield::Type::URL ); xEffContent.set(pDrawField); lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_URL ); lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_REPR ); @@ -1154,10 +1154,9 @@ uno::Reference<text::XTextCursor> SAL_CALL ScShapeObj::createTextCursorByRange( SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( aTextPosition ); if ( pText && pRange ) { - SvxUnoTextCursor* pCursor = new ScDrawTextCursor( this, *pText ); - uno::Reference<text::XTextCursor> xCursor( pCursor ); + rtl::Reference<SvxUnoTextCursor> pCursor = new ScDrawTextCursor( this, *pText ); pCursor->SetSelection( pRange->GetSelection() ); - return xCursor; + return pCursor; } } diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx index 17168e04461a..8af20f45485b 100644 --- a/sc/source/ui/unoobj/textuno.cxx +++ b/sc/source/ui/unoobj/textuno.cxx @@ -567,15 +567,14 @@ uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getStart() //! use other object for range than cursor? - ScCellTextCursor* pNew = new ScCellTextCursor( *this ); - uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); + rtl::Reference<ScCellTextCursor> pNew = new ScCellTextCursor( *this ); ESelection aNewSel(GetSelection()); aNewSel.nEndPara = aNewSel.nStartPara; aNewSel.nEndPos = aNewSel.nStartPos; pNew->SetSelection( aNewSel ); - return xRange; + return static_cast<SvxUnoTextRangeBase*>(pNew.get()); } uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getEnd() @@ -584,15 +583,14 @@ uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getEnd() //! use other object for range than cursor? - ScCellTextCursor* pNew = new ScCellTextCursor( *this ); - uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); + rtl::Reference<ScCellTextCursor> pNew = new ScCellTextCursor( *this ); ESelection aNewSel(GetSelection()); aNewSel.nStartPara = aNewSel.nEndPara; aNewSel.nStartPos = aNewSel.nEndPos; pNew->SetSelection( aNewSel ); - return xRange; + return static_cast<SvxUnoTextRangeBase*>(pNew.get()); } // XUnoTunnel @@ -620,15 +618,14 @@ uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getStart() //! use other object for range than cursor? - ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this ); - uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); + rtl::Reference<ScHeaderFooterTextCursor> pNew = new ScHeaderFooterTextCursor( *this ); ESelection aNewSel(GetSelection()); aNewSel.nEndPara = aNewSel.nStartPara; aNewSel.nEndPos = aNewSel.nStartPos; pNew->SetSelection( aNewSel ); - return xRange; + return static_cast<SvxUnoTextRangeBase*>(pNew.get()); } uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getEnd() @@ -637,15 +634,14 @@ uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getEnd() //! use other object for range than cursor? - ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this ); - uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); + rtl::Reference<ScHeaderFooterTextCursor> pNew = new ScHeaderFooterTextCursor( *this ); ESelection aNewSel(GetSelection()); aNewSel.nStartPara = aNewSel.nEndPara; aNewSel.nStartPos = aNewSel.nEndPos; pNew->SetSelection( aNewSel ); - return xRange; + return static_cast<SvxUnoTextRangeBase*>(pNew.get()); } // XUnoTunnel @@ -678,15 +674,14 @@ uno::Reference<text::XTextRange> SAL_CALL ScDrawTextCursor::getStart() //! use other object for range than cursor? - ScDrawTextCursor* pNew = new ScDrawTextCursor( *this ); - uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); + rtl::Reference<ScDrawTextCursor> pNew = new ScDrawTextCursor( *this ); ESelection aNewSel(GetSelection()); aNewSel.nEndPara = aNewSel.nStartPara; aNewSel.nEndPos = aNewSel.nStartPos; pNew->SetSelection( aNewSel ); - return xRange; + return static_cast<SvxUnoTextRangeBase*>(pNew.get()); } uno::Reference<text::XTextRange> SAL_CALL ScDrawTextCursor::getEnd() @@ -695,15 +690,14 @@ uno::Reference<text::XTextRange> SAL_CALL ScDrawTextCursor::getEnd() //! use other object for range than cursor? - ScDrawTextCursor* pNew = new ScDrawTextCursor( *this ); - uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); + rtl::Reference<ScDrawTextCursor> pNew = new ScDrawTextCursor( *this ); ESelection aNewSel(GetSelection()); aNewSel.nStartPara = aNewSel.nEndPara; aNewSel.nStartPos = aNewSel.nEndPos; pNew->SetSelection( aNewSel ); - return xRange; + return static_cast<SvxUnoTextRangeBase*>(pNew.get()); } // XUnoTunnel diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 8f10ffc1e0e2..5007ae4eda39 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -851,7 +851,7 @@ uno::Any SAL_CALL ScTabViewObj::getSelection() { SolarMutexGuard aGuard; ScTabViewShell* pViewSh = GetViewShell(); - ScCellRangesBase* pObj = nullptr; + rtl::Reference<ScCellRangesBase> pObj; if (pViewSh) { // is something selected in drawing layer? @@ -925,7 +925,7 @@ uno::Any SAL_CALL ScTabViewObj::getSelection() } } - return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj))); + return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj.get()))); } // XEnumerationAccess @@ -1077,7 +1077,7 @@ uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rP rData.GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY); ScAddress aCellPos (nX, nY, nTab); - ScCellObj* pCellObj = new ScCellObj(rData.GetDocShell(), aCellPos); + rtl::Reference<ScCellObj> pCellObj = new ScCellObj(rData.GetDocShell(), aCellPos); xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY); @@ -2076,9 +2076,7 @@ css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL ScTabViewObj::g if (pDrawShell) return pDrawShell->GetDrawView()->CopyToTransferable(); - ScTransferObj* pObj = GetViewShell()->CopyToTransferable(); - uno::Reference<datatransfer::XTransferable> xTransferable( pObj ); - return xTransferable; + return GetViewShell()->CopyToTransferable(); } void SAL_CALL ScTabViewObj::insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans ) diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 7cdc61b65b98..0b8316824033 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -31,6 +31,8 @@ #include <vbahelper/vbahelper.hxx> #include <osl/file.hxx> +#include <rtl/ref.hxx> + using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -52,7 +54,7 @@ getWorkbook( const uno::Reference< uno::XComponentContext >& xContext, return uno::Any( xWb ); } - ScVbaWorkbook *pWb = new ScVbaWorkbook( xParent, xContext, xModel ); + rtl::Reference<ScVbaWorkbook> pWb = new ScVbaWorkbook( xParent, xContext, xModel ); return uno::Any( uno::Reference< excel::XWorkbook > (pWb) ); } diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index bce240b10b12..b7d7af5fcc48 100644 --- a/sc/source/ui/view/drawvie4.cxx +++ b/sc/source/ui/view/drawvie4.cxx @@ -395,15 +395,14 @@ uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable() aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScDrawTransferObj ctor - ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc ); - uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj ); + rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc ); if ( ScGlobal::xDrawClipDocShellRef.is() ) { pTransferObj->SetDrawPersist( ScGlobal::xDrawClipDocShellRef.get() ); // keep persist for ole objects alive } - return xTransferable; + return pTransferObj; } // Calculate correction for 100%, regardless of current settings diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx index b0f1e92ca679..47e77a788357 100644 --- a/sc/source/ui/view/gridwin5.cxx +++ b/sc/source/ui/view/gridwin5.cxx @@ -377,7 +377,7 @@ css::uno::Reference< css::accessibility::XAccessible > return xAcc; } - ScAccessibleDocument* pAccessibleDocument = + rtl::Reference<ScAccessibleDocument> pAccessibleDocument = new ScAccessibleDocument(GetAccessibleParentWindow()->GetAccessible(), mrViewData.GetViewShell(), eWhich); pAccessibleDocument->PreInit(); diff --git a/sc/source/ui/view/hintwin.cxx b/sc/source/ui/view/hintwin.cxx index d690ab33d002..f66fe8db67ec 100644 --- a/sc/source/ui/view/hintwin.cxx +++ b/sc/source/ui/view/hintwin.cxx @@ -78,21 +78,19 @@ drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlaySequ aFontSize.getX(), aFontSize.getY(), aTextPos.X(), aTextPos.Y())); - drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pTitle = + rtl::Reference<drawinglayer::primitive2d::TextSimplePortionPrimitive2D> pTitle = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( aTextMatrix, m_aTitle, 0, m_aTitle.getLength(), std::vector<double>(), aFontAttr, css::lang::Locale(), rColor.getBColor()); - const drawinglayer::primitive2d::Primitive2DReference aTitle(pTitle); - Point aTextStart(nLeft + aHintMargin.Width() + aIndent.Width(), nTop + aHintMargin.Height() + aFontMetric.GetLineHeight() + aIndent.Height()); drawinglayer::geometry::ViewInformation2D aDummy; rRange.expand(pTitle->getB2DRange(aDummy)); - drawinglayer::primitive2d::Primitive2DContainer aSeq { aTitle }; + drawinglayer::primitive2d::Primitive2DContainer aSeq { pTitle }; aFontMetric = pDefaultDev->GetFontMetric(aTextFont); pDefaultDev->SetMapMode(aOld); @@ -113,7 +111,7 @@ drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlaySequ aLineStart.X(), aLineStart.Y() + nTextOffsetY); // Create the text primitive for each line of text - drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pMessage = + rtl::Reference<drawinglayer::primitive2d::TextSimplePortionPrimitive2D> pMessage = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( aTextMatrix, aLine, 0, aLine.getLength(), std::vector<double>(), aFontAttr, css::lang::Locale(), @@ -121,8 +119,7 @@ drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlaySequ rRange.expand(pMessage->getB2DRange(aDummy)); - const drawinglayer::primitive2d::Primitive2DReference aMessage(pMessage); - aSeq.push_back(aMessage); + aSeq.push_back(pMessage); aLineStart.AdjustY(nLineHeight ); } diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index da60252f99c5..40180e6d5a6b 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -1510,7 +1510,7 @@ css::uno::Reference<css::accessibility::XAccessible> ScPreview::CreateAccessible return xAcc; } - ScAccessibleDocumentPagePreview* pAccessible = + rtl::Reference<ScAccessibleDocumentPagePreview> pAccessible = new ScAccessibleDocumentPagePreview( GetAccessibleParentWindow()->GetAccessible(), pViewShell ); xAcc = pAccessible; diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index f8c8e5770d57..e4ba7302799e 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -426,7 +426,7 @@ bool ScViewFunc::CopyToClipMultiRange( const ScDocument* pInputClipDoc, const Sc return bDone; } -ScTransferObj* ScViewFunc::CopyToTransferable() +rtl::Reference<ScTransferObj> ScViewFunc::CopyToTransferable() { ScRange aRange; if ( GetViewData().GetSimpleArea( aRange ) == SC_MARK_SIMPLE ) @@ -453,8 +453,7 @@ ScTransferObj* ScViewFunc::CopyToTransferable() TransferableObjectDescriptor aObjDesc; pDocSh->FillTransferableObjectDescriptor( aObjDesc ); aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); - ScTransferObj* pTransferObj = new ScTransferObj( std::move(pClipDoc), aObjDesc ); - return pTransferObj; + return new ScTransferObj( std::move(pClipDoc), aObjDesc ); } } |