diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-05-09 15:17:26 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-09 18:21:59 +0200 |
commit | fac093e5e63bd53bae3de552fedba927bd5c4561 (patch) | |
tree | 7b921dc813a6d6e0df55ef6d15edabb76e52bd40 /xmlscript/source/xmlflat_imexp | |
parent | 2479ab8b788ca000f2e979d0858de8d05de8e858 (diff) |
Simplify Sequence iterations in xmlscript, xmlsecurity
Use range-based loops or replace with comphelper or STL functions
Change-Id: I3d63811caf80c87a9d560087e1f0d933ebcc0d55
Reviewed-on: https://gerrit.libreoffice.org/72040
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlscript/source/xmlflat_imexp')
-rw-r--r-- | xmlscript/source/xmlflat_imexp/xmlbas_export.cxx | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx index 872f47a7e2df..74db5079a8cc 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx @@ -153,17 +153,13 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / if ( xLibContainer.is() ) { Sequence< OUString > aLibNames = xLibContainer->getElementNames(); - sal_Int32 nLibCount = aLibNames.getLength(); - const OUString* pLibNames = aLibNames.getConstArray(); - for ( sal_Int32 i = 0 ; i < nLibCount ; ++i ) + for ( const OUString& rLibName : aLibNames ) { - OUString aLibName( pLibNames[i] ); - - if ( xLibContainer->hasByName( aLibName ) ) + if ( xLibContainer->hasByName( rLibName ) ) { OUString aTrueStr( "true" ); - if ( xLibContainer->isLibraryLink( aLibName ) ) + if ( xLibContainer->isLibraryLink( rLibName ) ) { // ooo/script:library-linked element OUString aLibElementName( aPrefix ); @@ -173,9 +169,9 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / xLibAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement ); // ooo/script:name attribute - pLibElement->addAttribute( aPrefix + ":name", aLibName ); + pLibElement->addAttribute( aPrefix + ":name", rLibName ); - OUString aLinkURL( xLibContainer->getLibraryLinkURL( aLibName ) ); + OUString aLinkURL( xLibContainer->getLibraryLinkURL( rLibName ) ); if ( !aLinkURL.isEmpty() ) { // xlink:href attribute @@ -185,7 +181,7 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / pLibElement->addAttribute( XMLNS_XLINK_PREFIX ":type", "simple" ); } - if ( xLibContainer->isLibraryReadOnly( aLibName ) ) + if ( xLibContainer->isLibraryReadOnly( rLibName ) ) { // ooo/script:readonly attribute pLibElement->addAttribute( aPrefix + ":readonly", aTrueStr ); @@ -209,9 +205,9 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / xLibAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement ); // ooo/script:name attribute - pLibElement->addAttribute( aPrefix + ":name", aLibName ); + pLibElement->addAttribute( aPrefix + ":name", rLibName ); - if ( xLibContainer->isLibraryReadOnly( aLibName ) ) + if ( xLibContainer->isLibraryReadOnly( rLibName ) ) { // ooo/script:readonly attribute pLibElement->addAttribute( aPrefix + ":readonly", aTrueStr ); @@ -219,28 +215,25 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / // TODO: password protected libraries Reference< script::XLibraryContainerPassword > xPasswd( xLibContainer, UNO_QUERY ); - if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) ) + if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( rLibName ) ) continue; // <ooo/script:library-embedded... m_xHandler->ignorableWhitespace( OUString() ); m_xHandler->startElement( aLibElementName, xLibAttribs ); - if ( !xLibContainer->isLibraryLoaded( aLibName ) ) - xLibContainer->loadLibrary( aLibName ); + if ( !xLibContainer->isLibraryLoaded( rLibName ) ) + xLibContainer->loadLibrary( rLibName ); Reference< container::XNameContainer > xLib; - xLibContainer->getByName( aLibName ) >>= xLib; + xLibContainer->getByName( rLibName ) >>= xLib; if ( xLib.is() ) { Sequence< OUString > aModNames = xLib->getElementNames(); - sal_Int32 nModCount = aModNames.getLength(); - const OUString* pModNames = aModNames.getConstArray(); - for ( sal_Int32 j = 0 ; j < nModCount ; ++j ) + for ( const OUString& rModName : aModNames ) { - OUString aModName( pModNames[j] ); - if ( xLib->hasByName( aModName ) ) + if ( xLib->hasByName( rModName ) ) { // ooo/script:module element OUString aModElementName( aPrefix ); @@ -250,7 +243,7 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / xModAttribs = static_cast< xml::sax::XAttributeList* >( pModElement ); // ooo/script:name attribute - pModElement->addAttribute( aPrefix + ":name", aModName ); + pModElement->addAttribute( aPrefix + ":name", rModName ); // <ooo/script:module... m_xHandler->ignorableWhitespace( OUString() ); @@ -270,7 +263,7 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / // module data // TODO: write encrypted data for password protected libraries OUString aSource; - xLib->getByName( aModName ) >>= aSource; + xLib->getByName( rModName ) >>= aSource; m_xHandler->characters( aSource ); // TODO: <ooo/script:byte-code> |