[Libreoffice-commits] core.git: 4 commits - include/xmloff xmloff/source
David Tardon
dtardon at redhat.com
Tue Sep 6 12:38:55 UTC 2016
include/xmloff/xmlimp.hxx | 18 +++---
xmloff/source/core/xmlimp.cxx | 116 ++++++++++++++--------------------------
xmloff/source/draw/ximpstyl.cxx | 2
3 files changed, 52 insertions(+), 84 deletions(-)
New commits:
commit c6383758c7f22071346b25f0d3e45d17d73b5a64
Author: David Tardon <dtardon at redhat.com>
Date: Tue Sep 6 14:09:40 2016 +0200
use std::unique_ptr
Change-Id: I0cc84cc6b18849118a2b7824a8e4b37ca063cd50
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 4ece8c1..a20ac8b 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -176,13 +176,13 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public ::cppu::WeakImplHelper8<
std::unique_ptr<SvXMLImport_Impl> mpImpl; // dummy
SvXMLNamespaceMap *mpNamespaceMap;
- SvXMLUnitConverter *mpUnitConv;
+ std::unique_ptr<SvXMLUnitConverter> mpUnitConv;
SvXMLImportContexts_Impl maContexts;
FastSvXMLImportContexts_Impl maFastContexts;
- SvXMLNumFmtHelper *mpNumImport;
- ProgressBarHelper *mpProgressBarHelper;
- XMLEventImportHelper *mpEventImportHelper;
- XMLErrors *mpXMLErrors;
+ std::unique_ptr<SvXMLNumFmtHelper> mpNumImport;
+ std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
+ std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
+ std::unique_ptr<XMLErrors> mpXMLErrors;
rtl::Reference<StyleMap> mpStyleMap;
OUString msPackageProtocol;
@@ -629,10 +629,10 @@ inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::G
inline SvXMLNumFmtHelper* SvXMLImport::GetDataStylesImport()
{
- if ( mpNumImport == nullptr)
+ if ( !mpNumImport )
CreateDataStylesImport_();
- return mpNumImport;
+ return mpNumImport.get();
}
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index e02424f..c9c5c8b 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -409,7 +409,7 @@ void SvXMLImport::InitCtor_()
msPackageProtocol = "vnd.sun.star.Package:";
if (mxNumberFormatsSupplier.is())
- mpNumImport = new SvXMLNumFmtHelper(mxNumberFormatsSupplier, GetComponentContext());
+ mpNumImport = o3tl::make_unique<SvXMLNumFmtHelper>(mxNumberFormatsSupplier, GetComponentContext());
if (mxModel.is() && !mxEventListener.is())
{
@@ -427,10 +427,6 @@ SvXMLImport::SvXMLImport(
mpUnitConv( new SvXMLUnitConverter( xContext,
util::MeasureUnit::MM_100TH, util::MeasureUnit::MM_100TH) ),
- mpNumImport( nullptr ),
- mpProgressBarHelper( nullptr ),
- mpEventImportHelper( nullptr ),
- mpXMLErrors( nullptr ),
mnImportFlags( nImportFlags ),
mnErrorFlags(SvXMLErrorFlags::NO),
isFastContext( false ),
@@ -451,24 +447,13 @@ SvXMLImport::SvXMLImport(
SvXMLImport::~SvXMLImport() throw ()
{
- delete mpXMLErrors;
delete mpNamespaceMap;
- delete mpUnitConv;
- delete mpEventImportHelper;
for ( SvXMLImportContext *pContext : maContexts )
{
if( pContext )
pContext->ReleaseRef();
}
- // #i9518# the import component might not be deleted until after the document has been closed,
- // so the stuff that accesses the document has been moved to endDocument.
-
- // pNumImport is allocated in the ctor, so it must also be deleted here in case the component
- // is created and deleted without actually importing.
- delete mpNumImport;
- delete mpProgressBarHelper;
-
if (mxEventListener.is() && mxModel.is())
mxModel->removeEventListener(mxEventListener);
}
@@ -611,17 +596,13 @@ void SAL_CALL SvXMLImport::endDocument()
}
}
- if (mpNumImport)
- {
- delete mpNumImport;
- mpNumImport = nullptr;
- }
+ mpNumImport.reset();
if (mxImportInfo.is())
{
uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
if (xPropertySetInfo.is())
{
- if (mpProgressBarHelper)
+ if (bool(mpProgressBarHelper))
{
OUString sProgressMax(XML_PROGRESSMAX);
OUString sProgressCurrent(XML_PROGRESSCURRENT);
@@ -677,7 +658,7 @@ void SAL_CALL SvXMLImport::endDocument()
}
mpStyleMap.clear();
- if ( mpXMLErrors != nullptr )
+ if ( bool( mpXMLErrors ) )
{
mpXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE );
}
@@ -1044,12 +1025,8 @@ void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XCompo
mxModel->addEventListener(mxEventListener);
}
- SAL_WARN_IF( mpNumImport, "xmloff.core", "number format import already exists." );
- if( mpNumImport )
- {
- delete mpNumImport;
- mpNumImport = nullptr;
- }
+ SAL_WARN_IF( bool(mpNumImport), "xmloff.core", "number format import already exists." );
+ mpNumImport.reset();
}
// XFilter
@@ -1571,7 +1548,7 @@ ProgressBarHelper* SvXMLImport::GetProgressBarHelper()
{
if (!mpProgressBarHelper)
{
- mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, false);
+ mpProgressBarHelper = o3tl::make_unique<ProgressBarHelper>(mxStatusIndicator, false);
if (mxImportInfo.is())
{
@@ -1612,7 +1589,7 @@ ProgressBarHelper* SvXMLImport::GetProgressBarHelper()
}
}
}
- return mpProgressBarHelper;
+ return mpProgressBarHelper.get();
}
void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
@@ -1643,7 +1620,7 @@ XMLEventImportHelper& SvXMLImport::GetEventImport()
{
// construct event helper and register StarBasic handler and standard
// event tables
- mpEventImportHelper = new XMLEventImportHelper();
+ mpEventImportHelper = o3tl::make_unique<XMLEventImportHelper>();
const OUString& sStarBasic(GetXMLToken(XML_STARBASIC));
mpEventImportHelper->RegisterFactory(sStarBasic,
new XMLStarBasicContextFactory());
@@ -1823,11 +1800,11 @@ void SvXMLImport::CreateNumberFormatsSupplier_()
void SvXMLImport::CreateDataStylesImport_()
{
- SAL_WARN_IF( mpNumImport != nullptr, "xmloff.core", "data styles import already exists!" );
+ SAL_WARN_IF( bool(mpNumImport), "xmloff.core", "data styles import already exists!" );
uno::Reference<util::XNumberFormatsSupplier> xNum =
GetNumberFormatsSupplier();
if ( xNum.is() )
- mpNumImport = new SvXMLNumFmtHelper(xNum, GetComponentContext() );
+ mpNumImport = o3tl::make_unique<SvXMLNumFmtHelper>(xNum, GetComponentContext() );
}
sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
@@ -1881,8 +1858,8 @@ void SvXMLImport::SetError(
mnErrorFlags |= SvXMLErrorFlags::DO_NOTHING;
// create error list on demand
- if ( mpXMLErrors == nullptr )
- mpXMLErrors = new XMLErrors();
+ if ( !mpXMLErrors )
+ mpXMLErrors = o3tl::make_unique<XMLErrors>();
// save error information
// use document locator (if none supplied)
commit 7571242f793200379bf90f605f21225e03df85fe
Author: David Tardon <dtardon at redhat.com>
Date: Tue Sep 6 13:07:30 2016 +0200
rewrite using a for loop
Change-Id: Ia58651d011064e4d324e5e7851b681f4d13d41a7
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index ec0bb36..e02424f 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -455,10 +455,8 @@ SvXMLImport::~SvXMLImport() throw ()
delete mpNamespaceMap;
delete mpUnitConv;
delete mpEventImportHelper;
- while( !maContexts.empty() )
+ for ( SvXMLImportContext *pContext : maContexts )
{
- SvXMLImportContext *pContext = maContexts.back();
- maContexts.pop_back();
if( pContext )
pContext->ReleaseRef();
}
commit 7e4d1521058916cf0facdba91f5b0ae1e95d318a
Author: David Tardon <dtardon at redhat.com>
Date: Tue Sep 6 13:06:38 2016 +0200
drop unneeded dynamic allocation
Change-Id: I9e19c33998137ee0065f92ccb980d1ff5a82115b
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 415ca40..4ece8c1 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -177,8 +177,8 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public ::cppu::WeakImplHelper8<
SvXMLNamespaceMap *mpNamespaceMap;
SvXMLUnitConverter *mpUnitConv;
- SvXMLImportContexts_Impl *mpContexts;
- FastSvXMLImportContexts_Impl *mpFastContexts;
+ SvXMLImportContexts_Impl maContexts;
+ FastSvXMLImportContexts_Impl maFastContexts;
SvXMLNumFmtHelper *mpNumImport;
ProgressBarHelper *mpProgressBarHelper;
XMLEventImportHelper *mpEventImportHelper;
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 7a1fd79..ec0bb36 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -427,8 +427,6 @@ SvXMLImport::SvXMLImport(
mpUnitConv( new SvXMLUnitConverter( xContext,
util::MeasureUnit::MM_100TH, util::MeasureUnit::MM_100TH) ),
- mpContexts( new SvXMLImportContexts_Impl ),
- mpFastContexts( new FastSvXMLImportContexts_Impl ),
mpNumImport( nullptr ),
mpProgressBarHelper( nullptr ),
mpEventImportHelper( nullptr ),
@@ -457,17 +455,12 @@ SvXMLImport::~SvXMLImport() throw ()
delete mpNamespaceMap;
delete mpUnitConv;
delete mpEventImportHelper;
- delete mpFastContexts;
- if( mpContexts )
+ while( !maContexts.empty() )
{
- while( !mpContexts->empty() )
- {
- SvXMLImportContext *pContext = mpContexts->back();
- mpContexts->pop_back();
- if( pContext )
- pContext->ReleaseRef();
- }
- delete mpContexts;
+ SvXMLImportContext *pContext = maContexts.back();
+ maContexts.pop_back();
+ if( pContext )
+ pContext->ReleaseRef();
}
// #i9518# the import component might not be deleted until after the document has been closed,
@@ -762,10 +755,10 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName,
// If there are contexts already, call a CreateChildContext at the topmost
// context. Otherwise, create a default context.
SvXMLImportContext *pContext;
- sal_uInt16 nCount = mpContexts->size();
+ sal_uInt16 nCount = maContexts.size();
if( nCount > 0 )
{
- pContext = (*mpContexts)[nCount - 1]->CreateChildContext( nPrefix,
+ pContext = maContexts[nCount - 1]->CreateChildContext( nPrefix,
aLocalName,
xAttrList );
SAL_WARN_IF( !pContext || (pContext->GetPrefix() != nPrefix), "xmloff.core",
@@ -800,7 +793,7 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName,
pContext->StartElement( xAttrList );
// Push context on stack.
- mpContexts->push_back( pContext );
+ maContexts.push_back( pContext );
}
void SAL_CALL SvXMLImport::endElement( const OUString&
@@ -810,13 +803,13 @@ rName
)
throw(xml::sax::SAXException, uno::RuntimeException, std::exception)
{
- sal_uInt16 nCount = mpContexts->size();
+ sal_uInt16 nCount = maContexts.size();
SAL_WARN_IF( nCount == 0, "xmloff.core", "SvXMLImport::endElement: no context left" );
if( nCount > 0 )
{
// Get topmost context and remove it from the stack.
- SvXMLImportContext *pContext = mpContexts->back();
- mpContexts->pop_back();
+ SvXMLImportContext *pContext = maContexts.back();
+ maContexts.pop_back();
#ifdef DBG_UTIL
// Non product only: check if endElement call matches startELement call.
@@ -849,21 +842,21 @@ rName
void SAL_CALL SvXMLImport::characters( const OUString& rChars )
throw(xml::sax::SAXException, uno::RuntimeException, std::exception)
{
- if ( !mpFastContexts->empty() )
+ if ( !maFastContexts.empty() )
{
- mpFastContexts->back()->characters( rChars );
+ maFastContexts.back()->characters( rChars );
}
- else if( !mpContexts->empty() )
+ else if( !maContexts.empty() )
{
- mpContexts->back()->Characters( rChars );
+ maContexts.back()->Characters( rChars );
}
}
void SvXMLImport::Characters( const OUString& rChars )
{
- if( !mpContexts->empty() )
+ if( !maContexts.empty() )
{
- mpContexts->back()->Characters( rChars );
+ maContexts.back()->Characters( rChars );
}
}
@@ -891,10 +884,10 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
{
//Namespace handling is unnecessary. It is done by the fastparser itself.
uno::Reference<XFastContextHandler> xContext;
- sal_uInt16 nCount = mpFastContexts->size();
+ sal_uInt16 nCount = maFastContexts.size();
if( nCount > 0 )
{
- uno::Reference< XFastContextHandler > pHandler = (*mpFastContexts)[nCount - 1];
+ uno::Reference< XFastContextHandler > pHandler = maFastContexts[nCount - 1];
xContext = pHandler->createFastChildContext( Element, Attribs );
}
else
@@ -917,11 +910,11 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
SvXMLImportContext *pContext = dynamic_cast<SvXMLImportContext*>( xContext.get() );
if( pContext && pRewindMap )
pContext->PutRewindMap( pRewindMap );
- mpContexts->push_back( pContext );
+ maContexts.push_back( pContext );
}
// Push context on stack.
- mpFastContexts->push_back( xContext );
+ maFastContexts.push_back( xContext );
}
void SAL_CALL SvXMLImport::startUnknownElement (const OUString & rPrefix, const OUString & rLocalName,
@@ -929,10 +922,10 @@ void SAL_CALL SvXMLImport::startUnknownElement (const OUString & rPrefix, const
throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
uno::Reference<XFastContextHandler> xContext;
- sal_uInt16 nCount = mpFastContexts->size();
+ sal_uInt16 nCount = maFastContexts.size();
if( nCount > 0 )
{
- uno::Reference< XFastContextHandler > pHandler = (*mpFastContexts)[nCount - 1];
+ uno::Reference< XFastContextHandler > pHandler = maFastContexts[nCount - 1];
xContext = pHandler->createUnknownChildContext( rPrefix, rLocalName, Attribs );
}
else
@@ -942,21 +935,21 @@ void SAL_CALL SvXMLImport::startUnknownElement (const OUString & rPrefix, const
xContext.set( new SvXMLImportContext( *this ) );
xContext->startUnknownElement( rPrefix, rLocalName, Attribs );
- mpFastContexts->push_back( xContext );
+ maFastContexts.push_back( xContext );
}
void SAL_CALL SvXMLImport::endFastElement (sal_Int32 Element)
throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- sal_uInt16 nCount = mpFastContexts->size();
+ sal_uInt16 nCount = maFastContexts.size();
if( nCount > 0 )
{
- uno::Reference< XFastContextHandler > xContext = mpFastContexts->back();
- mpFastContexts->pop_back();
+ uno::Reference< XFastContextHandler > xContext = maFastContexts.back();
+ maFastContexts.pop_back();
isFastContext = true;
xContext->endFastElement( Element );
if ( isFastContext )
- mpContexts->pop_back();
+ maContexts.pop_back();
xContext = nullptr;
}
@@ -965,11 +958,11 @@ void SAL_CALL SvXMLImport::endFastElement (sal_Int32 Element)
void SAL_CALL SvXMLImport::endUnknownElement (const OUString & rPrefix, const OUString & rLocalName)
throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- sal_uInt16 nCount = mpFastContexts->size();
+ sal_uInt16 nCount = maFastContexts.size();
if( nCount > 0 )
{
- uno::Reference< XFastContextHandler > xContext = mpFastContexts->back();
- mpFastContexts->pop_back();
+ uno::Reference< XFastContextHandler > xContext = maFastContexts.back();
+ maFastContexts.pop_back();
xContext->endUnknownElement( rPrefix, rLocalName );
xContext = nullptr;
}
commit 9f965900a8a22cdf9dcd10f962e27b9ffc3ed8b8
Author: David Tardon <dtardon at redhat.com>
Date: Tue Aug 30 17:17:27 2016 +0200
remove extra whitespace
Change-Id: I07dd8be5e74c0776d24222d8af2628535c9ba980
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index 44c7989..aee1d7b 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -1510,7 +1510,7 @@ SvXMLImportContext* SdXMLMasterStylesContext::CreateChildContext(
}
}
}
- else if(nPrefix == XML_NAMESPACE_STYLE
+ else if(nPrefix == XML_NAMESPACE_STYLE
&& IsXMLToken( rLocalName, XML_HANDOUT_MASTER ) )
{
uno::Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetSdImport().GetModel(), uno::UNO_QUERY );
More information about the Libreoffice-commits
mailing list