summaryrefslogtreecommitdiff
path: root/xmlscript/source/xmldlg_imexp
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-19 08:38:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-19 08:46:06 +0100
commit85e51d1fb5ed3019ef2409c8c8a7721148bb4178 (patch)
tree4a27a3de9cf6560acd2b78a7e2b978786575f78e /xmlscript/source/xmldlg_imexp
parentefb093893ffe9aa6340bde72e12d0512200d2100 (diff)
loplugin:refcounting in xmlscript
Change-Id: I82e3fe7ec8f45d9e99ec51688df97a0e5a33f58c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111169 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlscript/source/xmldlg_imexp')
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx27
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_export.cxx22
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx12
3 files changed, 28 insertions, 33 deletions
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
index 0646be0cc824..be5899fb72d9 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <o3tl/any.hxx>
+#include <rtl/ref.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -87,7 +88,7 @@ void ElementDescriptor::readMultiPageModel( StyleBag * all_styles )
uno::Reference< container::XNameContainer > xPagesContainer( _xProps, uno::UNO_QUERY );
if ( xPagesContainer.is() && xPagesContainer->getElementNames().hasElements() )
{
- ElementDescriptor * pElem = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", _xDocument );
+ rtl::Reference<ElementDescriptor> pElem = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", _xDocument );
pElem->readBullitinBoard( all_styles );
addSubElement( pElem );
}
@@ -115,14 +116,14 @@ void ElementDescriptor::readFrameModel( StyleBag * all_styles )
if ( readProp( "Label" ) >>= aTitle)
{
- ElementDescriptor * title = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":title", _xDocument );
+ rtl::Reference<ElementDescriptor> title = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":title", _xDocument );
title->addAttribute( XMLNS_DIALOGS_PREFIX ":value", aTitle );
addSubElement( title );
}
uno::Reference< container::XNameContainer > xControlContainer( _xProps, uno::UNO_QUERY );
if ( xControlContainer.is() && xControlContainer->getElementNames().hasElements() )
{
- ElementDescriptor * pElem = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", _xDocument );
+ rtl::Reference<ElementDescriptor> pElem = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", _xDocument );
pElem->readBullitinBoard( all_styles );
addSubElement( pElem );
}
@@ -152,7 +153,7 @@ void ElementDescriptor::readPageModel( StyleBag * all_styles )
uno::Reference< container::XNameContainer > xControlContainer( _xProps, uno::UNO_QUERY );
if ( xControlContainer.is() && xControlContainer->getElementNames().hasElements() )
{
- ElementDescriptor * pElem = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", _xDocument );
+ rtl::Reference<ElementDescriptor> pElem = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", _xDocument );
pElem->readBullitinBoard( all_styles );
addSubElement( pElem );
}
@@ -312,11 +313,11 @@ void ElementDescriptor::readComboBoxModel( StyleBag * all_styles )
Sequence< OUString > itemValues;
if ((readProp( "StringItemList" ) >>= itemValues) && itemValues.hasElements())
{
- ElementDescriptor * popup = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menupopup", _xDocument );
+ rtl::Reference<ElementDescriptor> popup = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menupopup", _xDocument );
for ( const auto& rItemValue : std::as_const(itemValues) )
{
- ElementDescriptor * item = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menuitem", _xDocument );
+ rtl::Reference<ElementDescriptor> item = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menuitem", _xDocument );
item->addAttribute( XMLNS_DIALOGS_PREFIX ":value", rItemValue );
popup->addSubElement( item );
}
@@ -359,11 +360,11 @@ void ElementDescriptor::readListBoxModel( StyleBag * all_styles )
Sequence< OUString > itemValues;
if ((readProp( "StringItemList" ) >>= itemValues) && itemValues.hasElements())
{
- ElementDescriptor * popup = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menupopup", _xDocument );
+ rtl::Reference<ElementDescriptor> popup = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menupopup", _xDocument );
for ( const auto& rItemValue : std::as_const(itemValues) )
{
- ElementDescriptor * item = new ElementDescriptor(_xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menuitem", _xDocument );
+ rtl::Reference<ElementDescriptor> item = new ElementDescriptor(_xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":menuitem", _xDocument );
item->addAttribute( XMLNS_DIALOGS_PREFIX ":value", rItemValue );
popup->addSubElement( item );
}
@@ -456,7 +457,7 @@ void ElementDescriptor::readGroupBoxModel( StyleBag * all_styles )
OUString aTitle;
if (readProp( "Label" ) >>= aTitle)
{
- ElementDescriptor * title = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":title", _xDocument );
+ rtl::Reference<ElementDescriptor> title = new ElementDescriptor( _xProps, _xPropState, XMLNS_DIALOGS_PREFIX ":title", _xDocument );
title->addAttribute( XMLNS_DIALOGS_PREFIX ":value", aTitle );
addSubElement( title );
}
@@ -1077,14 +1078,14 @@ void ElementDescriptor::readDialogModel( StyleBag * all_styles )
void ElementDescriptor::readBullitinBoard( StyleBag * all_styles )
{
// collect elements
- ::std::vector< ElementDescriptor* > all_elements;
+ ::std::vector< rtl::Reference<ElementDescriptor> > all_elements;
// read out all props
Reference< container::XNameContainer > xDialogModel( _xProps, UNO_QUERY );
if ( !xDialogModel.is() )
return; // #TODO throw???
const Sequence< OUString > aElements( xDialogModel->getElementNames() );
- ElementDescriptor * pRadioGroup = nullptr;
+ rtl::Reference<ElementDescriptor> pRadioGroup;
for ( const auto& rElement : aElements )
{
@@ -1102,7 +1103,7 @@ void ElementDescriptor::readBullitinBoard( StyleBag * all_styles )
if (! xServiceInfo.is())
continue;
- ElementDescriptor * pElem = nullptr;
+ rtl::Reference<ElementDescriptor> pElem;
// group up radio buttons
if ( xServiceInfo->supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) )
@@ -1259,7 +1260,7 @@ void ElementDescriptor::readBullitinBoard( StyleBag * all_styles )
}
}
}
- for (ElementDescriptor* p : all_elements)
+ for (rtl::Reference<ElementDescriptor> & p : all_elements)
{
addSubElement( p );
}
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
index 77f606728d0a..55ee293bc464 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
@@ -68,6 +68,7 @@
#include <comphelper/processfactory.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <rtl/ref.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -77,7 +78,7 @@ namespace xmlscript
Reference< xml::sax::XAttributeList > Style::createElement()
{
- ElementDescriptor * pStyle = new ElementDescriptor( XMLNS_DIALOGS_PREFIX ":style" );
+ rtl::Reference<ElementDescriptor> pStyle = new ElementDescriptor( XMLNS_DIALOGS_PREFIX ":style" );
// style-id
pStyle->addAttribute( XMLNS_DIALOGS_PREFIX ":style-id", _id );
@@ -1188,21 +1189,16 @@ void ElementDescriptor::readEvents()
}
}
- ElementDescriptor * pElem;
- Reference< xml::sax::XAttributeList > xElem;
+ rtl::Reference<ElementDescriptor> pElem;
if (!aEventName.isEmpty()) // script:event
{
pElem = new ElementDescriptor( XMLNS_SCRIPT_PREFIX ":event" );
- xElem = pElem;
-
pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":event-name", aEventName );
}
else // script:listener-event
{
pElem = new ElementDescriptor( XMLNS_SCRIPT_PREFIX ":listener-event" );
- xElem = pElem;
-
pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-type", descr.ListenerType );
pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":listener-method", descr.EventMethod );
@@ -1233,7 +1229,7 @@ void ElementDescriptor::readEvents()
// language
pElem->addAttribute( XMLNS_SCRIPT_PREFIX ":language", descr.ScriptType );
- addSubElement( xElem );
+ addSubElement( pElem );
}
else
{
@@ -1378,8 +1374,7 @@ void exportDialogModel(
Reference< beans::XPropertyState > xPropState( xProps, UNO_QUERY );
OSL_ASSERT( xPropState.is() );
- ElementDescriptor * pElem = new ElementDescriptor( xProps, xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", xDocument );
- Reference< xml::sax::XAttributeList > xElem( pElem );
+ rtl::Reference<ElementDescriptor> pElem = new ElementDescriptor( xProps, xPropState, XMLNS_DIALOGS_PREFIX ":bulletinboard", xDocument );
pElem->readBullitinBoard( &all_styles );
xOut->startDocument();
@@ -1390,11 +1385,10 @@ void exportDialogModel(
xOut->ignorableWhitespace( OUString() );
OUString aWindowName( XMLNS_DIALOGS_PREFIX ":window" );
- ElementDescriptor * pWindow = new ElementDescriptor( xProps, xPropState, aWindowName, xDocument );
- Reference< xml::sax::XAttributeList > xWindow( pWindow );
+ rtl::Reference<ElementDescriptor> pWindow = new ElementDescriptor( xProps, xPropState, aWindowName, xDocument );
pWindow->readDialogModel( &all_styles );
xOut->ignorableWhitespace( OUString() );
- xOut->startElement( aWindowName, xWindow );
+ xOut->startElement( aWindowName, pWindow );
// dump out events
pWindow->dumpSubElements( xOut );
// dump out stylebag
@@ -1405,7 +1399,7 @@ void exportDialogModel(
// open up bulletinboard
OUString aBBoardName( XMLNS_DIALOGS_PREFIX ":bulletinboard" );
xOut->ignorableWhitespace( OUString() );
- xOut->startElement( aBBoardName, xElem );
+ xOut->startElement( aBBoardName, pElem );
pElem->dumpSubElements( xOut );
// end bulletinboard
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
index 9f324465cf48..424058cd28fa 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
@@ -47,9 +47,9 @@ Reference< xml::input::XElement > Frame::startChildElement(
else if ( rLocalName == "bulletinboard" )
{
// Create new DialogImport for this container
- DialogImport* pFrameImport = new DialogImport( *m_xImport );
+ rtl::Reference<DialogImport> pFrameImport = new DialogImport( *m_xImport );
pFrameImport->_xDialogModel = m_xContainer;
- return new BulletinBoardElement( rLocalName, xAttributes, this, pFrameImport );
+ return new BulletinBoardElement( rLocalName, xAttributes, this, pFrameImport.get() );
}
else if ( rLocalName == "title" )
{
@@ -111,9 +111,9 @@ Reference< xml::input::XElement > MultiPage::startChildElement(
{
// Create new DialogImport for this container
- DialogImport* pMultiPageImport = new DialogImport( *m_xImport );
+ rtl::Reference<DialogImport> pMultiPageImport = new DialogImport( *m_xImport );
pMultiPageImport->_xDialogModel = m_xContainer;
- return new BulletinBoardElement( rLocalName, xAttributes, this, pMultiPageImport );
+ return new BulletinBoardElement( rLocalName, xAttributes, this, pMultiPageImport.get() );
}
else
{
@@ -164,9 +164,9 @@ Reference< xml::input::XElement > Page::startChildElement(
else if ( rLocalName == "bulletinboard" )
{
- DialogImport* pPageImport = new DialogImport( *m_xImport );
+ rtl::Reference<DialogImport> pPageImport = new DialogImport( *m_xImport );
pPageImport->_xDialogModel = m_xContainer;
- return new BulletinBoardElement( rLocalName, xAttributes, this, pPageImport );
+ return new BulletinBoardElement( rLocalName, xAttributes, this, pPageImport.get() );
}
else
{