summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-07-13 16:17:00 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-08-03 06:37:16 +0000
commit2660d24a07866e083c5135ea263030f3e3a2e729 (patch)
tree0089d6018d4fc33a7fde955e585e77191cdd258b /editeng
parentbaba1d14766282bd2c592bffd79ed69f9078cfe1 (diff)
new loplugin: refcounting
This was a feature requested by mmeeks, as a result of tdf#92611. It validates that things that extend XInterface are not directly heap/stack-allocated, but have their lifecycle managed via css::uno::Reference or rtl::Reference. Change-Id: I28e3b8b236f6a4a56d0a6d6f26ad54e44b36e692 Reviewed-on: https://gerrit.libreoffice.org/16924 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/qa/unit/core-test.cxx56
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx48
-rw-r--r--editeng/source/misc/svxacorr.cxx8
-rw-r--r--editeng/source/xml/xmltxtexp.cxx4
4 files changed, 58 insertions, 58 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index efb82d83ad4e..8d5fcf7056c9 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -110,112 +110,112 @@ void Test::testUnoTextFields()
{
{
// DATE
- SvxUnoTextField aField(text::textfield::Type::DATE);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::DATE));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// URL
- SvxUnoTextField aField(text::textfield::Type::URL);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::URL));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.URL");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// PAGE
- SvxUnoTextField aField(text::textfield::Type::PAGE);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PAGE));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageNumber");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// PAGES
- SvxUnoTextField aField(text::textfield::Type::PAGES);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PAGES));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageCount");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// TIME
- SvxUnoTextField aField(text::textfield::Type::TIME);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::TIME));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// FILE
- SvxUnoTextField aField(text::textfield::Type::DOCINFO_TITLE);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::DOCINFO_TITLE));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.docinfo.Title");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// TABLE
- SvxUnoTextField aField(text::textfield::Type::TABLE);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::TABLE));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.SheetName");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// EXTENDED TIME
- SvxUnoTextField aField(text::textfield::Type::EXTENDED_TIME);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::EXTENDED_TIME));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// EXTENDED FILE
- SvxUnoTextField aField(text::textfield::Type::EXTENDED_FILE);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::EXTENDED_FILE));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.FileName");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// AUTHOR
- SvxUnoTextField aField(text::textfield::Type::AUTHOR);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::AUTHOR));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Author");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// MEASURE
- SvxUnoTextField aField(text::textfield::Type::MEASURE);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::MEASURE));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Measure");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// PRESENTATION HEADER
- SvxUnoTextField aField(text::textfield::Type::PRESENTATION_HEADER);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_HEADER));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Header");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// PRESENTATION FOOTER
- SvxUnoTextField aField(text::textfield::Type::PRESENTATION_FOOTER);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_FOOTER));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Footer");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
{
// PRESENTATION DATE TIME
- SvxUnoTextField aField(text::textfield::Type::PRESENTATION_DATE_TIME);
- uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
+ uno::Reference<SvxUnoTextField> xField(new SvxUnoTextField(text::textfield::Type::PRESENTATION_DATE_TIME));
+ uno::Sequence<OUString> aSvcs = xField->getSupportedServiceNames();
bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.DateTime");
CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
}
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 8ce55d8010a6..87886f4d7e77 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -1612,11 +1612,11 @@ namespace accessibility
// SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
// ImplGetSvxCharAndParaPropertiesMap() );
// MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
- SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
+ uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ) );
- aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
- rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
- rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
+ xPropSet->SetSelection( MakeSelection( 0, GetTextLen() ) );
+ rRes.Value = xPropSet->_getPropertyValue( rRes.Name, mnParagraphIndex );
+ rRes.State = xPropSet->_getPropertyState( rRes.Name, mnParagraphIndex );
rRes.Handle = -1;
}
continue;
@@ -1635,10 +1635,10 @@ namespace accessibility
else
{
// MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
- SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
- aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
- rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
- rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
+ uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ) );
+ xPropSet->SetSelection( MakeSelection( 0, GetTextLen() ) );
+ rRes.Value = xPropSet->_getPropertyValue( rRes.Name, mnParagraphIndex );
+ rRes.State = xPropSet->_getPropertyState( rRes.Name, mnParagraphIndex );
rRes.Handle = -1;
}
continue;
@@ -2416,13 +2416,13 @@ namespace accessibility
// do the indices span the whole paragraph? Then use the outliner map
// TODO: hold it as a member?
- SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
+ uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(),
0 == nStartIndex &&
rCacheTF.GetTextLen(nPara) == nEndIndex ?
ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() :
- ImplGetSvxTextPortionSvxPropertySet() );
+ ImplGetSvxTextPortionSvxPropertySet() ) );
- aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
+ xPropSet->SetSelection( MakeSelection(nStartIndex, nEndIndex) );
// convert from PropertyValue to Any
sal_Int32 i, nLength( aAttributeSet.getLength() );
@@ -2431,7 +2431,7 @@ namespace accessibility
{
try
{
- aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value);
+ xPropSet->setPropertyValue(pPropArray->Name, pPropArray->Value);
}
catch (const uno::Exception&)
{
@@ -2481,10 +2481,10 @@ namespace accessibility
// get XPropertySetInfo for paragraph attributes and
// character attributes that span all the paragraphs text.
- SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
- ImplGetSvxCharAndParaPropertiesSet() );
- aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
+ uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(),
+ ImplGetSvxCharAndParaPropertiesSet() ) );
+ xPropSet->SetSelection( MakeSelection( 0, GetTextLen() ) );
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
if (!xPropSetInfo.is())
throw uno::RuntimeException("Cannot query XPropertySetInfo",
uno::Reference< uno::XInterface >
@@ -2530,7 +2530,7 @@ namespace accessibility
// calling implementation functions:
// _getPropertyState and _getPropertyValue (see below) to provide
// the proper paragraph number when retrieving paragraph attributes
- PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex );
+ PropertyState eState = xPropSet->_getPropertyState( pProperties->Name, mnParagraphIndex );
if ( eState == PropertyState_AMBIGUOUS_VALUE )
{
OSL_FAIL( "ambiguous property value encountered" );
@@ -2543,7 +2543,7 @@ namespace accessibility
{
pOutSequence->Name = pProperties->Name;
pOutSequence->Handle = pProperties->Handle;
- pOutSequence->Value = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex );
+ pOutSequence->Value = xPropSet->_getPropertyValue( pProperties->Name, mnParagraphIndex );
pOutSequence->State = PropertyState_DEFAULT_VALUE;
++pOutSequence;
@@ -2583,10 +2583,10 @@ namespace accessibility
else
CheckPosition(nIndex);
- SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
- ImplGetSvxCharAndParaPropertiesSet() );
- aPropSet.SetSelection( MakeSelection( nIndex ) );
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
+ uno::Reference< SvxAccessibleTextPropertySet > xPropSet( new SvxAccessibleTextPropertySet( &GetEditSource(),
+ ImplGetSvxCharAndParaPropertiesSet() ) );
+ xPropSet->SetSelection( MakeSelection( nIndex ) );
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
if (!xPropSetInfo.is())
throw uno::RuntimeException("Cannot query XPropertySetInfo",
uno::Reference< uno::XInterface >
@@ -2630,12 +2630,12 @@ namespace accessibility
for (sal_Int32 i = 0; i < nLength; ++i)
{
// calling 'regular' functions that will operate on the selection
- PropertyState eState = aPropSet.getPropertyState( pProperties->Name );
+ PropertyState eState = xPropSet->getPropertyState( pProperties->Name );
if (eState == PropertyState_DIRECT_VALUE)
{
pOutSequence->Name = pProperties->Name;
pOutSequence->Handle = pProperties->Handle;
- pOutSequence->Value = aPropSet.getPropertyValue( pProperties->Name );
+ pOutSequence->Value = xPropSet->getPropertyValue( pProperties->Name );
pOutSequence->State = eState;
++pOutSequence;
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index cfeea481d447..3007ba034ee0 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -2091,9 +2091,9 @@ void SvxAutoCorrectLanguageLists::SaveExceptList_Imp(
xWriter->setOutputStream(xOut);
uno::Reference < xml::sax::XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);
- SvXMLExceptionListExport aExp( xContext, rLst, sStrmName, xHandler );
+ uno::Reference< SvXMLExceptionListExport > xExp( new SvXMLExceptionListExport( xContext, rLst, sStrmName, xHandler ) );
- aExp.exportDoc( XML_BLOCK_LIST );
+ xExp->exportDoc( XML_BLOCK_LIST );
xStrm->Commit();
if( xStrm->GetError() == SVSTREAM_OK )
@@ -2462,9 +2462,9 @@ bool SvxAutoCorrectLanguageLists::MakeBlocklist_Imp( SotStorage& rStg )
xWriter->setOutputStream(xOut);
uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY);
- SvXMLAutoCorrectExport aExp( xContext, pAutocorr_List, sStrmName, xHandler );
+ uno::Reference< SvXMLAutoCorrectExport > xExp( new SvXMLAutoCorrectExport( xContext, pAutocorr_List, sStrmName, xHandler ) );
- aExp.exportDoc( XML_BLOCK_LIST );
+ xExp->exportDoc( XML_BLOCK_LIST );
refList->Commit();
bRet = SVSTREAM_OK == refList->GetError();
diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx
index 401472f27aff..5d575a1d7d60 100644
--- a/editeng/source/xml/xmltxtexp.cxx
+++ b/editeng/source/xml/xmltxtexp.cxx
@@ -429,9 +429,9 @@ void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection&
// SvxXMLTextExportComponent aExporter( &rEditEngine, rSel, aName, xHandler );
uno::Reference< xml::sax::XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);
- SvxXMLTextExportComponent aExporter( xContext, &rEditEngine, rSel, aName, xHandler );
+ uno::Reference< SvxXMLTextExportComponent > xExporter( new SvxXMLTextExportComponent( xContext, &rEditEngine, rSel, aName, xHandler ) );
- aExporter.exportDoc();
+ xExporter->exportDoc();
/* testcode
aMedium.Commit();