[Libreoffice-commits] core.git: 2 commits - basic/source xmlscript/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 5 07:31:53 UTC 2018
basic/source/basmgr/basicmanagerrepository.cxx | 15 ++---
basic/source/inc/sbintern.hxx | 2
xmlscript/source/xml_helper/xml_impctx.cxx | 73 ++++++++++++-------------
3 files changed, 43 insertions(+), 47 deletions(-)
New commits:
commit 7a11e702569ab89eb7722c883ecc3cbbe1a19a65
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 4 12:30:32 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 5 09:31:40 2018 +0200
loplugin:useuniqueptr in DocumentHandlerImpl
Change-Id: I722f9a25040ab4ddd8a5d3e5b402c22e5cc3f454
Reviewed-on: https://gerrit.libreoffice.org/60002
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx
index 0ad0d17b8467..9c1df5f7cd92 100644
--- a/xmlscript/source/xml_helper/xml_impctx.cxx
+++ b/xmlscript/source/xml_helper/xml_impctx.cxx
@@ -112,7 +112,7 @@ class DocumentHandlerImpl :
sal_Int32 m_nLastPrefix_lookup;
OUString m_aLastPrefix_lookup;
- std::vector< ElementEntry * > m_elements;
+ std::vector< ElementEntry > m_elements;
sal_Int32 m_nSkipElements;
std::unique_ptr<Mutex> m_pMutex;
@@ -195,7 +195,7 @@ DocumentHandlerImpl::getCurrentElement() const
if (m_elements.empty())
return Reference< xml::input::XElement >();
else
- return m_elements.back()->m_xElement;
+ return m_elements.back().m_xElement;
}
inline sal_Int32 DocumentHandlerImpl::getUidByURI( OUString const & rURI )
@@ -426,7 +426,7 @@ void DocumentHandlerImpl::startElement(
Reference< xml::input::XAttributes > xAttributes;
sal_Int32 nUid;
OUString aLocalName;
- ::std::unique_ptr< ElementEntry > elementEntry( new ElementEntry );
+ ElementEntry elementEntry;
{ // guard start:
MGuard aGuard( m_pMutex );
@@ -442,7 +442,7 @@ void DocumentHandlerImpl::startElement(
// save all namespace ids
std::unique_ptr<sal_Int32[]> pUids(new sal_Int32[ nAttribs ]);
- OUString * pPrefixes = new OUString[ nAttribs ];
+ std::unique_ptr<OUString[]> pPrefixes(new OUString[ nAttribs ]);
std::unique_ptr<OUString[]> pLocalNames(new OUString[ nAttribs ]);
std::unique_ptr<OUString[]> pQNames(new OUString[ nAttribs ]);
@@ -465,7 +465,7 @@ void DocumentHandlerImpl::startElement(
pushPrefix(
aDefNamespacePrefix,
xAttribs->getValueByIndex( nPos ) );
- elementEntry->m_prefixes.push_back( aDefNamespacePrefix );
+ elementEntry.m_prefixes.push_back( aDefNamespacePrefix );
pUids[ nPos ] = UID_UNKNOWN;
pPrefixes[ nPos ] = g_sXMLNS;
pLocalNames[ nPos ] = aDefNamespacePrefix;
@@ -474,7 +474,7 @@ void DocumentHandlerImpl::startElement(
{
OUString aPrefix( rQAttributeName.copy( 6 ) );
pushPrefix( aPrefix, xAttribs->getValueByIndex( nPos ) );
- elementEntry->m_prefixes.push_back( aPrefix );
+ elementEntry.m_prefixes.push_back( aPrefix );
pUids[ nPos ] = UID_UNKNOWN;
pPrefixes[ nPos ] = g_sXMLNS;
pLocalNames[ nPos ] = aPrefix;
@@ -507,7 +507,7 @@ void DocumentHandlerImpl::startElement(
pUids[ nPos ] = getUidByPrefix( pPrefixes[ nPos ] );
}
}
- delete[] pPrefixes;
+ pPrefixes.reset();
// ownership of arrays belongs to attribute list
xAttributes = static_cast< xml::input::XAttributes * >(
new ExtendedAttributes(
@@ -518,33 +518,33 @@ void DocumentHandlerImpl::startElement(
// create new child context and append to list
if (! m_elements.empty())
- xCurrentElement = m_elements.back()->m_xElement;
+ xCurrentElement = m_elements.back().m_xElement;
} // :guard end
if (xCurrentElement.is())
{
- elementEntry->m_xElement =
+ elementEntry.m_xElement =
xCurrentElement->startChildElement( nUid, aLocalName, xAttributes );
}
else
{
- elementEntry->m_xElement =
+ elementEntry.m_xElement =
m_xRoot->startRootElement( nUid, aLocalName, xAttributes );
}
{
MGuard aGuard( m_pMutex );
- if (elementEntry->m_xElement.is())
+ if (elementEntry.m_xElement.is())
{
- m_elements.push_back( elementEntry.release() );
+ m_elements.push_back( std::move(elementEntry) );
}
else
{
++m_nSkipElements;
// pop prefixes
- for (sal_Int32 nPos = elementEntry->m_prefixes.size(); nPos--;)
- popPrefix(elementEntry->m_prefixes[nPos]);
+ for (sal_Int32 nPos = elementEntry.m_prefixes.size(); nPos--;)
+ popPrefix(elementEntry.m_prefixes[nPos]);
SAL_INFO("xmlscript.xmlhelper", " no context given on createChildElement() => ignoring element \"" << rQElementName << "\" ...");
}
@@ -556,34 +556,33 @@ void DocumentHandlerImpl::endElement(
{
Reference< xml::input::XElement > xCurrentElement;
{
- MGuard aGuard( m_pMutex );
- if (m_nSkipElements)
- {
- --m_nSkipElements;
- SAL_INFO("xmlscript.xmlhelper", "### received endElement() for \"" << rQElementName << "\".");
- return;
- }
+ MGuard aGuard( m_pMutex );
+ if (m_nSkipElements)
+ {
+ --m_nSkipElements;
+ SAL_INFO("xmlscript.xmlhelper", "### received endElement() for \"" << rQElementName << "\".");
+ return;
+ }
- // popping context
- SAL_WARN_IF( m_elements.empty(), "xmlscript.xmlhelper", "m_elements is empty" );
- ElementEntry * pEntry = m_elements.back();
- xCurrentElement = pEntry->m_xElement;
+ // popping context
+ SAL_WARN_IF( m_elements.empty(), "xmlscript.xmlhelper", "m_elements is empty" );
+ ElementEntry& rEntry = m_elements.back();
+ xCurrentElement = rEntry.m_xElement;
#if OSL_DEBUG_LEVEL > 0
- sal_Int32 nUid;
- OUString aLocalName;
- getElementName( rQElementName, &nUid, &aLocalName );
- SAL_WARN_IF( xCurrentElement->getLocalName() != aLocalName, "xmlscript.xmlhelper", "xCurrentElement->getLocalName() != aLocalName" );
- SAL_WARN_IF( xCurrentElement->getUid() != nUid, "xmlscript.xmlhelper", "xCurrentElement->getUid() != nUid" );
+ sal_Int32 nUid;
+ OUString aLocalName;
+ getElementName( rQElementName, &nUid, &aLocalName );
+ SAL_WARN_IF( xCurrentElement->getLocalName() != aLocalName, "xmlscript.xmlhelper", "xCurrentElement->getLocalName() != aLocalName" );
+ SAL_WARN_IF( xCurrentElement->getUid() != nUid, "xmlscript.xmlhelper", "xCurrentElement->getUid() != nUid" );
#endif
- // pop prefixes
- for ( sal_Int32 nPos = pEntry->m_prefixes.size(); nPos--; )
- {
- popPrefix( pEntry->m_prefixes[ nPos ] );
- }
- m_elements.pop_back();
- delete pEntry;
+ // pop prefixes
+ for ( sal_Int32 nPos = rEntry.m_prefixes.size(); nPos--; )
+ {
+ popPrefix( rEntry.m_prefixes[ nPos ] );
+ }
+ m_elements.pop_back();
}
xCurrentElement->endElement();
}
commit d02587d79d38997cf74bb0add7dfdf32f26c1fe1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 4 12:26:43 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 5 09:31:29 2018 +0200
loplugin:useuniqueptr in SbiGlobals
Change-Id: Icbf913058ada4714345d0251970e6420b315270c
Reviewed-on: https://gerrit.libreoffice.org/60001
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index 1f110f9b77e3..1cc6eab188cf 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -83,7 +83,7 @@ namespace basic
BasicManager* getDocumentBasicManager( const Reference< XModel >& _rxDocumentModel );
BasicManager* getOrCreateApplicationBasicManager();
static BasicManager* getApplicationBasicManager();
- static void setApplicationBasicManager( BasicManager* _pBasicManager );
+ static void setApplicationBasicManager( std::unique_ptr<BasicManager> _pBasicManager );
void registerCreationListener( BasicManagerCreationListener& _rListener );
void revokeCreationListener( BasicManagerCreationListener& _rListener );
@@ -241,7 +241,7 @@ namespace basic
{
SolarMutexGuard g;
- BasicManager* pAppManager = GetSbData()->pAppBasMgr;
+ BasicManager* pAppManager = GetSbData()->pAppBasMgr.get();
if (pAppManager == nullptr)
pAppManager = impl_createApplicationBasicManager();
return pAppManager;
@@ -251,17 +251,14 @@ namespace basic
{
SolarMutexGuard g;
- return GetSbData()->pAppBasMgr;
+ return GetSbData()->pAppBasMgr.get();
}
- void ImplRepository::setApplicationBasicManager( BasicManager* _pBasicManager )
+ void ImplRepository::setApplicationBasicManager( std::unique_ptr<BasicManager> _pBasicManager )
{
SolarMutexGuard g;
- BasicManager* pPreviousManager = getApplicationBasicManager();
- delete pPreviousManager;
-
- GetSbData()->pAppBasMgr = _pBasicManager;
+ GetSbData()->pAppBasMgr = std::move(_pBasicManager);
}
@@ -285,7 +282,7 @@ namespace basic
aAppBasic.insertName( Application::GetAppName() );
BasicManager* pBasicManager = new BasicManager( new StarBASIC, &aAppBasicDir );
- setApplicationBasicManager( pBasicManager );
+ setApplicationBasicManager( std::unique_ptr<BasicManager>(pBasicManager) );
// The first dir in the path as destination:
OUString aFileName( aAppBasic.getName() );
diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx
index 70e6e69a1e23..55345348cff4 100644
--- a/basic/source/inc/sbintern.hxx
+++ b/basic/source/inc/sbintern.hxx
@@ -100,7 +100,7 @@ struct SbiGlobals
OUString aErrMsg; // buffer for GetErrorText()
std::unique_ptr<::utl::TransliterationWrapper> pTransliterationWrapper; // For StrComp
bool bBlockCompilerError;
- BasicManager* pAppBasMgr;
+ std::unique_ptr<BasicManager> pAppBasMgr;
StarBASIC* pMSOMacroRuntimLib; // Lib containing MSO Macro Runtime API entry symbols
SbiGlobals();
More information about the Libreoffice-commits
mailing list