summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-19 14:33:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-20 10:21:07 +0100
commit7d7d4cf217e82db8839dbc49dcab1ab72c203b4e (patch)
tree02bf7659d9bb3fce41a54407ea890313ad9d6a30 /sw/source/core/unocore
parent6aecd49aa6de7c7f65c3c240ee3b7db36497df4d (diff)
loplugin:refcounting in sw
Change-Id: I56f2f5aa4d9105e93f28701b8352d1fb97829ead Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111215 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/unocore')
-rw-r--r--sw/source/core/unocore/unobkm.cxx4
-rw-r--r--sw/source/core/unocore/unochart.cxx9
-rw-r--r--sw/source/core/unocore/unocoll.cxx7
-rw-r--r--sw/source/core/unocore/unodraw.cxx29
-rw-r--r--sw/source/core/unocore/unoframe.cxx7
-rw-r--r--sw/source/core/unocore/unoftn.cxx6
-rw-r--r--sw/source/core/unocore/unoobj.cxx8
-rw-r--r--sw/source/core/unocore/unoportenum.cxx39
-rw-r--r--sw/source/core/unocore/unoredline.cxx10
-rw-r--r--sw/source/core/unocore/unorefmk.cxx4
-rw-r--r--sw/source/core/unocore/unosect.cxx2
-rw-r--r--sw/source/core/unocore/unotbl.cxx21
-rw-r--r--sw/source/core/unocore/unotext.cxx7
13 files changed, 66 insertions, 87 deletions
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index 853418742a72..99ddb365bf78 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -704,7 +704,7 @@ SwXFieldmark::CreateXFieldmark(SwDoc & rDoc, ::sw::mark::IMark *const pMark,
if (!xMark.is())
{
// FIXME: These belong in XTextFieldsSupplier
- SwXFieldmark* pXBkmk = nullptr;
+ rtl::Reference<SwXFieldmark> pXBkmk;
if (dynamic_cast< ::sw::mark::TextFieldmark* >(pMark))
pXBkmk = new SwXFieldmark(false, &rDoc);
else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(pMark))
@@ -716,7 +716,7 @@ SwXFieldmark::CreateXFieldmark(SwDoc & rDoc, ::sw::mark::IMark *const pMark,
else
pXBkmk = new SwXFieldmark(isReplacementObject, &rDoc);
- xMark.set(static_cast<::cppu::OWeakObject*>(pXBkmk), uno::UNO_QUERY); // work around ambiguous base
+ xMark.set(static_cast<::cppu::OWeakObject*>(pXBkmk.get()), uno::UNO_QUERY); // work around ambiguous base
pXBkmk->registerInMark(*pXBkmk, pMarkBase);
}
return xMark;
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 143f4e9eec61..6d06ad82b402 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -859,7 +859,7 @@ uno::Reference< chart2::data::XDataSource > SwChartDataProvider::Impl_createData
uno::Reference<chart2::data::XLabeledDataSequence>* pLDS = aLDS.getArray();
for (sal_Int32 i = 0; i < nNumLDS; ++i)
{
- SwChartLabeledDataSequence* pLabeledDtaSeq = new SwChartLabeledDataSequence;
+ rtl::Reference<SwChartLabeledDataSequence> pLabeledDtaSeq = new SwChartLabeledDataSequence;
pLabeledDtaSeq->setLabel(pLabelSeqs[i]);
pLabeledDtaSeq->setValues(pDataSeqs[i]);
pLDS[i] = pLabeledDtaSeq;
@@ -2604,11 +2604,9 @@ uno::Reference< util::XCloneable > SAL_CALL SwChartLabeledDataSequence::createCl
if (m_bDisposed)
throw lang::DisposedException();
- uno::Reference< util::XCloneable > xRes;
-
uno::Reference< util::XCloneable > xDataCloneable( m_xData, uno::UNO_QUERY );
uno::Reference< util::XCloneable > xLabelsCloneable( m_xLabels, uno::UNO_QUERY );
- SwChartLabeledDataSequence *pRes = new SwChartLabeledDataSequence();
+ rtl::Reference<SwChartLabeledDataSequence > pRes = new SwChartLabeledDataSequence();
if (xDataCloneable.is())
{
uno::Reference< chart2::data::XDataSequence > xDataClone( xDataCloneable->createClone(), uno::UNO_QUERY );
@@ -2620,8 +2618,7 @@ uno::Reference< util::XCloneable > SAL_CALL SwChartLabeledDataSequence::createCl
uno::Reference< chart2::data::XDataSequence > xLabelsClone( xLabelsCloneable->createClone(), uno::UNO_QUERY );
pRes->setLabel( xLabelsClone );
}
- xRes = pRes;
- return xRes;
+ return pRes;
}
OUString SAL_CALL SwChartLabeledDataSequence::getImplementationName( )
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index a6287cbd714d..9eaefe985b6f 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -555,9 +555,7 @@ SwXServiceProvider::MakeInstance(SwServiceType nObjectType, SwDoc & rDoc)
case SwServiceType::VbaObjectProvider :
#if HAVE_FEATURE_SCRIPTING
{
- SwVbaObjectForCodeNameProvider* pObjProv =
- new SwVbaObjectForCodeNameProvider(rDoc.GetDocShell());
- xRet = static_cast<cppu::OWeakObject*>(pObjProv);
+ xRet = static_cast<cppu::OWeakObject*>(new SwVbaObjectForCodeNameProvider(rDoc.GetDocShell()));
}
#endif
break;
@@ -566,8 +564,7 @@ SwXServiceProvider::MakeInstance(SwServiceType nObjectType, SwDoc & rDoc)
{
if (rDoc.GetDocShell() && ooo::vba::isAlienWordDoc(*rDoc.GetDocShell()))
{
- SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider(rDoc.GetDocShell());
- xRet = static_cast<cppu::OWeakObject*>(pObjProv);
+ xRet = static_cast<cppu::OWeakObject*>(new SwVbaCodeNameProvider(rDoc.GetDocShell()));
}
}
#endif
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 781a62d78a81..cf1059dd9fbc 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -360,7 +360,7 @@ uno::Reference< drawing::XShape > SwFmDrawPage::CreateShape( SdrObject *pObj ) c
}
uno::Reference< XUnoTunnel > xShapeTunnel(xRet, uno::UNO_QUERY);
//don't create an SwXShape if it already exists
- SwXShape* pShape = nullptr;
+ rtl::Reference<SwXShape> pShape;
if(xShapeTunnel.is())
pShape = reinterpret_cast< SwXShape * >(
sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
@@ -373,10 +373,9 @@ uno::Reference< drawing::XShape > SwFmDrawPage::CreateShape( SdrObject *pObj ) c
pShape = new SwXGroupShape(xCreate, nullptr);
else
pShape = new SwXShape(xCreate, nullptr);
- uno::Reference<beans::XPropertySet> xPrSet = pShape;
- xRet.set(xPrSet, uno::UNO_QUERY);
+ xRet = pShape;
}
- const_cast<std::vector<SwXShape*>*>(&m_vShapes)->push_back(pShape);
+ const_cast<std::vector<SwXShape*>*>(&m_vShapes)->push_back(pShape.get());
pShape->m_pPage = this;
}
return xRet;
@@ -472,17 +471,16 @@ uno::Sequence< OUString > SwXDrawPage::getSupportedServiceNames()
}
SwXDrawPage::SwXDrawPage(SwDoc* pDc) :
- m_pDoc(pDc),
- m_pDrawPage(nullptr)
+ m_pDoc(pDc)
{
}
SwXDrawPage::~SwXDrawPage()
{
- if(m_xPageAgg.is())
+ if(m_pDrawPage.is())
{
uno::Reference< uno::XInterface > xInt;
- m_xPageAgg->setDelegator(xInt);
+ m_pDrawPage->setDelegator(xInt);
}
}
@@ -756,7 +754,7 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference<
if(!m_pDoc || !xShapes.is())
throw uno::RuntimeException();
uno::Reference< drawing::XShapeGroup > xRet;
- if(m_xPageAgg.is())
+ if(m_pDrawPage.is())
{
SwFmDrawPage* pPage = GetSvxPage();
@@ -802,7 +800,7 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & rShapeG
SolarMutexGuard aGuard;
if(!m_pDoc)
throw uno::RuntimeException();
- if(!m_xPageAgg.is())
+ if(!m_pDrawPage.is())
return;
SwFmDrawPage* pPage = GetSvxPage();
@@ -823,7 +821,7 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & rShapeG
SwFmDrawPage* SwXDrawPage::GetSvxPage()
{
- if(!m_xPageAgg.is() && m_pDoc)
+ if(!m_pDrawPage.is() && m_pDoc)
{
SolarMutexGuard aGuard;
// #i52858#
@@ -834,14 +832,11 @@ SwFmDrawPage* SwXDrawPage::GetSvxPage()
// We need a Ref to the object during queryInterface or else
// it will be deleted
m_pDrawPage = new SwFmDrawPage(pPage);
- uno::Reference< drawing::XDrawPage > xPage = m_pDrawPage;
- uno::Any aAgg = xPage->queryInterface(cppu::UnoType<uno::XAggregation>::get());
- aAgg >>= m_xPageAgg;
}
- if( m_xPageAgg.is() )
- m_xPageAgg->setDelegator( static_cast<cppu::OWeakObject*>(this) );
+ if( m_pDrawPage.is() )
+ m_pDrawPage->setDelegator( static_cast<cppu::OWeakObject*>(this) );
}
- return m_pDrawPage;
+ return m_pDrawPage.get();
}
/**
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index c853a6653d3b..ee69f96187dd 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -3290,11 +3290,8 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor()
throw aExcept;
}
- SwXTextCursor *const pXCursor = new SwXTextCursor(
- *pFormat->GetDoc(), this, CursorType::Frame, *aPam.GetPoint());
- aRef = static_cast<text::XWordCursor*>(pXCursor);
-
- return aRef;
+ return static_cast<text::XWordCursor*>(new SwXTextCursor(
+ *pFormat->GetDoc(), this, CursorType::Frame, *aPam.GetPoint()));
}
uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextRange > & aTextPosition)
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index 2cf0d0b507f9..5d1923d799e8 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -423,13 +423,11 @@ SwXFootnote::createTextCursor()
SwTextFootnote const*const pTextFootnote = rFormat.GetTextFootnote();
SwPosition aPos( *pTextFootnote->GetStartNode() );
- SwXTextCursor *const pXCursor =
+ rtl::Reference<SwXTextCursor> pXCursor =
new SwXTextCursor(*GetDoc(), this, CursorType::Footnote, aPos);
auto& rUnoCursor(pXCursor->GetCursor());
rUnoCursor.Move(fnMoveForward, GoInNode);
- const uno::Reference< text::XTextCursor > xRet =
- static_cast<text::XWordCursor*>(pXCursor);
- return xRet;
+ return static_cast<text::XWordCursor*>(pXCursor.get());
}
uno::Reference< text::XTextCursor > SAL_CALL
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 964471ded48c..43d976a20dba 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -1658,11 +1658,11 @@ SwXTextCursor::getStart()
if (CursorType::Meta == m_pImpl->m_eType)
{
// return cursor to prevent modifying SwXTextRange for META
- SwXTextCursor * const pXCursor(
+ rtl::Reference<SwXTextCursor> pXCursor(
new SwXTextCursor(rUnoCursor.GetDoc(), xParent, CursorType::Meta,
*rUnoCursor.GetPoint()) );
pXCursor->gotoStart(false);
- xRet = static_cast<text::XWordCursor*>(pXCursor);
+ xRet = static_cast<text::XWordCursor*>(pXCursor.get());
}
else
{
@@ -1684,11 +1684,11 @@ SwXTextCursor::getEnd()
if (CursorType::Meta == m_pImpl->m_eType)
{
// return cursor to prevent modifying SwXTextRange for META
- SwXTextCursor * const pXCursor(
+ rtl::Reference<SwXTextCursor> pXCursor(
new SwXTextCursor(rUnoCursor.GetDoc(), xParent, CursorType::Meta,
*rUnoCursor.GetPoint()) );
pXCursor->gotoEnd(false);
- xRet = static_cast<text::XWordCursor*>(pXCursor);
+ xRet = static_cast<text::XWordCursor*>(pXCursor.get());
}
else
{
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 748091ff4252..cdfe6fa9b168 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -407,7 +407,7 @@ lcl_ExportFieldMark(
::sw::mark::IFieldmark* pFieldmark = nullptr;
pFieldmark = rDoc.getIDocumentMarkAccess()->
getFieldmarkAt(*pUnoCursor->GetMark());
- SwXTextPortion* pPortion = new SwXTextPortion(
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion(
pUnoCursor, i_xParentText, PORTION_FIELD_START);
xRef = pPortion;
if (pFieldmark)
@@ -419,16 +419,15 @@ lcl_ExportFieldMark(
else if (CH_TXT_ATR_FIELDSEP == Char)
{
// TODO how to get the field?
- SwXTextPortion* pPortion = new SwXTextPortion(
+ xRef = new SwXTextPortion(
pUnoCursor, i_xParentText, PORTION_FIELD_SEP);
- xRef = pPortion;
}
else if (CH_TXT_ATR_FIELDEND == Char)
{
::sw::mark::IFieldmark* pFieldmark = nullptr;
pFieldmark = rDoc.getIDocumentMarkAccess()->
getFieldmarkAt(*pUnoCursor->GetMark());
- SwXTextPortion* pPortion = new SwXTextPortion(
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion(
pUnoCursor, i_xParentText, PORTION_FIELD_END);
xRef = pPortion;
if (pFieldmark)
@@ -441,7 +440,7 @@ lcl_ExportFieldMark(
{
::sw::mark::IFieldmark* pFieldmark =
rDoc.getIDocumentMarkAccess()->getFieldmarkAt(*pUnoCursor->GetMark());
- SwXTextPortion* pPortion = new SwXTextPortion(
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion(
pUnoCursor, i_xParentText, PORTION_FIELD_START_END);
xRef = pPortion;
if (pFieldmark)
@@ -472,7 +471,7 @@ lcl_CreateRefMarkPortion(
xContent = SwXReferenceMark::CreateXReferenceMark(rDoc, &rRefMark);
}
- SwXTextPortion* pPortion = nullptr;
+ rtl::Reference<SwXTextPortion> pPortion;
if (!bEnd)
{
pPortion = new SwXTextPortion(pUnoCursor, xParent, PORTION_REFMARK_START);
@@ -494,7 +493,7 @@ lcl_InsertRubyPortion(
const SwUnoCursor * const pUnoCursor,
const SwTextAttr & rAttr, const bool bEnd)
{
- SwXTextPortion* pPortion = new SwXTextPortion(pUnoCursor,
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion(pUnoCursor,
static_txtattr_cast<const SwTextRuby&>(rAttr), xParent, bEnd);
rPortions.emplace_back(pPortion);
pPortion->SetCollapsed(rAttr.End() == nullptr);
@@ -512,7 +511,7 @@ lcl_CreateTOXMarkPortion(
const Reference<XTextContent> xContent =
SwXDocumentIndexMark::CreateXDocumentIndexMark(rDoc, & rTOXMark);
- SwXTextPortion* pPortion = nullptr;
+ rtl::Reference<SwXTextPortion> pPortion;
if (!bEnd)
{
pPortion = new SwXTextPortion(pUnoCursor, xParent, PORTION_TOXMARK_START);
@@ -536,7 +535,7 @@ lcl_CreateMetaPortion(
const uno::Reference<rdf::XMetadatable> xMeta( SwXMeta::CreateXMeta(
*static_cast<SwFormatMeta &>(rAttr.GetAttr()).GetMeta(),
xParent, std::move(pPortions)));
- SwXTextPortion * pPortion(nullptr);
+ rtl::Reference<SwXTextPortion> pPortion;
if (RES_TXTATR_META == rAttr.Which())
{
const uno::Reference<text::XTextContent> xContent(xMeta,
@@ -604,7 +603,7 @@ static void lcl_ExportBookmark(
// - this is the start or end (depending on bOnlyFrameStarts)
// of a collapsed bookmark at the same position as an at-char
// anchored frame
- SwXTextPortion* pPortion =
+ rtl::Reference<SwXTextPortion> pPortion =
new SwXTextPortion(pUnoCursor, xParent, bEnd ? PORTION_BOOKMARK_END : PORTION_BOOKMARK_START);
rPortions.emplace_back(pPortion);
pPortion->SetBookmark(pPtr->xBookmark);
@@ -613,7 +612,7 @@ static void lcl_ExportBookmark(
}
else if (BkmType::End == pPtr->nBkmType && !bOnlyFrameStarts)
{
- SwXTextPortion* pPortion =
+ rtl::Reference<SwXTextPortion> pPortion =
new SwXTextPortion(pUnoCursor, xParent, PORTION_BOOKMARK_END);
rPortions.emplace_back(pPortion);
pPortion->SetBookmark(pPtr->xBookmark);
@@ -812,10 +811,10 @@ lcl_ExportHints(
pUnoCursor->Right(1);
if( *pUnoCursor->GetMark() == *pUnoCursor->GetPoint() )
break;
- SwXTextPortion* pPortion;
- xRef = pPortion =
+ rtl::Reference<SwXTextPortion> pPortion =
new SwXTextPortion(
pUnoCursor, xParent, PORTION_FIELD);
+ xRef = pPortion;
Reference<XTextField> const xField =
SwXTextField::CreateXTextField(&rDoc,
&pAttr->GetFormatField());
@@ -834,14 +833,14 @@ lcl_ExportHints(
::sw::mark::IMark* pAnnotationMark = pTextAnnotationField ? pTextAnnotationField->GetAnnotationMark() : nullptr;
if ( pAnnotationMark != nullptr )
{
- SwXTextPortion* pPortion = new SwXTextPortion( pUnoCursor, xParent, PORTION_ANNOTATION_END );
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion( pUnoCursor, xParent, PORTION_ANNOTATION_END );
pPortion->SetBookmark(SwXBookmark::CreateXBookmark(
rDoc, pAnnotationMark));
xRef = pPortion;
}
else
{
- SwXTextPortion* pPortion = new SwXTextPortion( pUnoCursor, xParent, PORTION_ANNOTATION );
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion( pUnoCursor, xParent, PORTION_ANNOTATION );
Reference<XTextField> xField =
SwXTextField::CreateXTextField(&rDoc,
&pAttr->GetFormatField());
@@ -859,7 +858,7 @@ lcl_ExportHints(
pAttr->GetFormatField().GetField()->ExpandField(true, nullptr).getLength() + 2 );
if( *pUnoCursor->GetMark() == *pUnoCursor->GetPoint() )
break;
- SwXTextPortion* pPortion =
+ rtl::Reference<SwXTextPortion> pPortion =
new SwXTextPortion( pUnoCursor, xParent, PORTION_FIELD);
xRef = pPortion;
Reference<XTextField> xField =
@@ -892,9 +891,9 @@ lcl_ExportHints(
pUnoCursor->Right(1);
if( *pUnoCursor->GetMark() == *pUnoCursor->GetPoint() )
break;
- SwXTextPortion* pPortion;
- xRef = pPortion = new SwXTextPortion(
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion(
pUnoCursor, xParent, PORTION_FOOTNOTE);
+ xRef = pPortion;
Reference<XFootnote> xContent =
SwXFootnotes::GetObject(rDoc, pAttr->GetFootnote());
pPortion->SetFootnote(xContent);
@@ -1175,7 +1174,7 @@ static void lcl_ExportAnnotationStarts(
bool bFrameStart = rFramePositions.find(nIndex) != rFramePositions.end();
if (bFrameStart || !bOnlyFrame)
{
- SwXTextPortion* pPortion =
+ rtl::Reference<SwXTextPortion> pPortion =
new SwXTextPortion( pUnoCursor, xParent, PORTION_ANNOTATION );
pPortion->SetTextField( pPtr->mxAnnotationField );
rPortions.emplace_back(pPortion);
@@ -1238,7 +1237,7 @@ static sal_Int32 lcl_ExportFrames(
auto pFrame = static_cast<SwFrameFormat*>(i_rFrames.front().pFrameClient->GetRegisteredIn());
if (pFrame) // Frame could be disposed
{
- SwXTextPortion* pPortion = new SwXTextPortion(i_pUnoCursor, i_xParent, *pFrame );
+ rtl::Reference<SwXTextPortion> pPortion = new SwXTextPortion(i_pUnoCursor, i_xParent, *pFrame );
rPortions.emplace_back(pPortion);
}
i_rFrames.pop_front();
diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx
index df3ad38cfffd..f1c7a6d3fe10 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -94,7 +94,7 @@ uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor()
SolarMutexGuard aGuard;
SwPosition aPos(aNodeIndex);
- SwXTextCursor *const pXCursor =
+ rtl::Reference<SwXTextCursor> pXCursor =
new SwXTextCursor(*GetDoc(), this, CursorType::Redline, aPos);
auto& rUnoCursor(pXCursor->GetCursor());
rUnoCursor.Move(fnMoveForward, GoInNode);
@@ -128,7 +128,7 @@ uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor()
throw aExcept;
}
- return static_cast<text::XWordCursor*>(pXCursor);
+ return static_cast<text::XWordCursor*>(pXCursor.get());
}
uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursorByRange(
@@ -532,7 +532,6 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor()
if(!pDoc)
throw uno::RuntimeException();
- uno::Reference< text::XTextCursor > xRet;
SwNodeIndex* pNodeIndex = pRedline->GetContentIdx();
if(!pNodeIndex)
{
@@ -540,7 +539,7 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor()
}
SwPosition aPos(*pNodeIndex);
- SwXTextCursor *const pXCursor =
+ rtl::Reference<SwXTextCursor> pXCursor =
new SwXTextCursor(*pDoc, this, CursorType::Redline, aPos);
auto& rUnoCursor(pXCursor->GetCursor());
rUnoCursor.Move(fnMoveForward, GoInNode);
@@ -556,9 +555,8 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor()
}
if(pCont)
rUnoCursor.GetPoint()->nContent.Assign(pCont, 0);
- xRet = static_cast<text::XWordCursor*>(pXCursor);
- return xRet;
+ return static_cast<text::XWordCursor*>(pXCursor.get());
}
uno::Reference< text::XTextCursor > SwXRedline::createTextCursorByRange(
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index 62b34a61cd4f..a87dc245a8e3 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -137,8 +137,8 @@ SwXReferenceMark::CreateXReferenceMark(
}
if (!xMark.is())
{
- SwXReferenceMark *const pMark(new SwXReferenceMark(&rDoc, pMarkFormat));
- xMark.set(pMark);
+ rtl::Reference<SwXReferenceMark> pMark(new SwXReferenceMark(&rDoc, pMarkFormat));
+ xMark = pMark;
if (pMarkFormat)
{
pMarkFormat->SetXRefMark(xMark);
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 422619dae051..ada86e6df4ca 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -206,7 +206,7 @@ SwXTextSection::CreateXTextSection(
}
if ( !xSection.is() )
{
- SwXTextSection *const pNew = new SwXTextSection(pFormat, bIndexHeader);
+ rtl::Reference<SwXTextSection> pNew = new SwXTextSection(pFormat, bIndexHeader);
xSection.set(pNew);
if (pFormat)
{
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 6392d16cd786..b03f513a1e70 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -117,7 +117,7 @@ namespace
{
FindUnoInstanceHint(Tcoretype* pCore) : m_pCore(pCore), m_pResult(nullptr) {};
const Tcoretype* const m_pCore;
- mutable Tunotype* m_pResult;
+ mutable rtl::Reference<Tunotype> m_pResult;
};
SwFrameFormat* lcl_EnsureCoreConnected(SwFrameFormat* pFormat, cppu::OWeakObject* pObject)
{
@@ -551,7 +551,7 @@ void SwRangeDescriptor::Normalize()
std::swap(nLeft, nRight);
}
-static SwXCell* lcl_CreateXCell(SwFrameFormat* pFormat, sal_Int32 nColumn, sal_Int32 nRow)
+static rtl::Reference<SwXCell> lcl_CreateXCell(SwFrameFormat* pFormat, sal_Int32 nColumn, sal_Int32 nRow)
{
const OUString sCellName = sw_GetCellName(nColumn, nRow);
SwTable* pTable = SwTable::FindTable(pFormat);
@@ -941,11 +941,11 @@ uno::Reference<text::XTextCursor> SwXCell::createTextCursor()
throw uno::RuntimeException();
const SwStartNode* pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
SwPosition aPos(*pSttNd);
- SwXTextCursor* const pXCursor =
+ rtl::Reference<SwXTextCursor> const pXCursor =
new SwXTextCursor(*GetDoc(), this, CursorType::TableText, aPos);
auto& rUnoCursor(pXCursor->GetCursor());
rUnoCursor.Move(fnMoveForward, GoInNode);
- return static_cast<text::XWordCursor*>(pXCursor);
+ return static_cast<text::XWordCursor*>(pXCursor.get());
}
uno::Reference<text::XTextCursor> SwXCell::createTextCursorByRange(const uno::Reference< text::XTextRange > & xTextPosition)
@@ -1137,7 +1137,7 @@ void SwXCell::Notify(const SfxHint& rHint)
}
}
-SwXCell* SwXCell::CreateXCell(SwFrameFormat* pTableFormat, SwTableBox* pBox, SwTable *pTable )
+rtl::Reference<SwXCell> SwXCell::CreateXCell(SwFrameFormat* pTableFormat, SwTableBox* pBox, SwTable *pTable )
{
if(!pTableFormat || !pBox)
return nullptr;
@@ -1149,7 +1149,7 @@ SwXCell* SwXCell::CreateXCell(SwFrameFormat* pTableFormat, SwTableBox* pBox, SwT
size_t const nPos = it - pTable->GetTabSortBoxes().begin();
FindUnoInstanceHint<SwTableBox, SwXCell> aHint{pBox};
pTableFormat->GetNotifier().Broadcast(aHint);
- return aHint.m_pResult ? aHint.m_pResult : new SwXCell(pTableFormat, pBox, nPos);
+ return aHint.m_pResult ? aHint.m_pResult.get() : new SwXCell(pTableFormat, pBox, nPos);
}
/** search if a box exists in a table
@@ -3232,10 +3232,9 @@ rtl::Reference<SwXCellRange> SwXCellRange::CreateXCellRange(
sw::UnoCursorPointer const& pCursor, SwFrameFormat& rFrameFormat,
SwRangeDescriptor const & rDesc)
{
- SwXCellRange *const pCellRange(new SwXCellRange(pCursor, rFrameFormat, rDesc));
- uno::Reference<table::XCellRange> xCellRange(pCellRange);
+ rtl::Reference<SwXCellRange> pCellRange(new SwXCellRange(pCursor, rFrameFormat, rDesc));
// need a permanent Reference to initialize m_wThis
- pCellRange->m_pImpl->m_wThis = xCellRange;
+ pCellRange->m_pImpl->m_wThis = uno::Reference<table::XCellRange>(pCellRange);
return pCellRange;
}
@@ -3269,7 +3268,7 @@ SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
if(nColumn >= 0 && nRow >= 0 &&
m_pImpl->GetColumnCount() > nColumn && m_pImpl->GetRowCount() > nRow )
{
- SwXCell* pXCell = lcl_CreateXCell(pFormat,
+ rtl::Reference<SwXCell> pXCell = lcl_CreateXCell(pFormat,
m_pImpl->m_RangeDescriptor.nLeft + nColumn,
m_pImpl->m_RangeDescriptor.nTop + nRow);
if(pXCell)
@@ -3920,7 +3919,7 @@ uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex)
pFrameFormat->GetNotifier().Broadcast(aHint);
if(!aHint.m_pResult)
aHint.m_pResult = new SwXTextTableRow(pFrameFormat, pLine);
- uno::Reference<beans::XPropertySet> xRet = static_cast<beans::XPropertySet*>(aHint.m_pResult);
+ uno::Reference<beans::XPropertySet> xRet = static_cast<beans::XPropertySet*>(aHint.m_pResult.get());
return uno::makeAny(xRet);
}
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 4c0f0afda5f6..651413ad7929 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -2539,8 +2539,7 @@ uno::Reference<text::XText> SwXHeadFootText::CreateXHeadFootText(
uno::Reference<text::XText> xText(rHeadFootFormat.GetXObject(), uno::UNO_QUERY);
if(!xText.is())
{
- const auto pXHFT(new SwXHeadFootText(rHeadFootFormat, bIsHeader));
- xText.set(pXHFT);
+ xText = new SwXHeadFootText(rHeadFootFormat, bIsHeader);
rHeadFootFormat.SetXObject(xText);
}
return xText;
@@ -2624,7 +2623,7 @@ SwXHeadFootText::createTextCursor()
const SwFormatContent& rFlyContent = rHeadFootFormat.GetContent();
const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
SwPosition aPos(rNode);
- SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this,
+ rtl::Reference<SwXTextCursor> pXCursor = new SwXTextCursor(*GetDoc(), this,
(m_pImpl->m_bIsHeader) ? CursorType::Header : CursorType::Footer, aPos);
auto& rUnoCursor(pXCursor->GetCursor());
rUnoCursor.Move(fnMoveForward, GoInNode);
@@ -2654,7 +2653,7 @@ SwXHeadFootText::createTextCursor()
aExcept.Message = "no text available";
throw aExcept;
}
- return static_cast<text::XWordCursor*>(pXCursor);
+ return static_cast<text::XWordCursor*>(pXCursor.get());
}
uno::Reference<text::XTextCursor> SAL_CALL SwXHeadFootText::createTextCursorByRange(