use more string_view in xml*

Change-Id: Ie219cb3feb98660463858d00f82f882881946ad0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133072
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2022-04-15 16:43:40 +02:00
parent ba74c925a5
commit 558aaa9ed2
4 changed files with 35 additions and 33 deletions

View file

@ -567,35 +567,36 @@ namespace chelp {
KeywordInfo::KeywordElement::KeywordElement( Databases const *pDatabases,
helpdatafileproxy::Hdf* pHdf,
OUString const & ky,
OUString const & data )
std::u16string_view data )
: key( ky )
{
pDatabases->replaceName( key );
init( pDatabases,pHdf,data );
}
void KeywordInfo::KeywordElement::init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf,const OUString& ids )
void KeywordInfo::KeywordElement::init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf, std::u16string_view ids )
{
std::vector< OUString > id,anchor;
int idx = -1,k;
size_t idx = std::u16string_view::npos;
size_t k = 0;
for (;;)
{
k = ++idx;
idx = ids.indexOf( ';', k );
if( idx == -1 )
idx = ids.find( ';', k );
if( idx == std::u16string_view::npos )
break;
int h = ids.indexOf( '#', k );
if( h < idx )
size_t h = ids.find( '#', k );
if( h == std::u16string_view::npos || h < idx )
{
// found an anchor
id.push_back( ids.copy( k, h-k ) );
anchor.push_back( ids.copy( h+1, idx-h-1 ) );
id.push_back( OUString(ids.substr( k, h-k )) );
anchor.push_back( OUString(ids.substr( h+1, idx-h-1 )) );
}
else
{
id.push_back( ids.copy( k, idx-k ) );
id.push_back( OUString(ids.substr( k, idx-k )) );
anchor.emplace_back( );
}
k = ++idx;
}
listId.realloc( id.size() );
@ -775,10 +776,10 @@ KeywordInfo* Databases::getKeyword( const OUString& Database,
return it->second.get();
}
Reference< XHierarchicalNameAccess > Databases::jarFile( const OUString& jar,
Reference< XHierarchicalNameAccess > Databases::jarFile( std::u16string_view jar,
const OUString& Language )
{
if( jar.isEmpty() || Language.isEmpty() )
if( jar.empty() || Language.isEmpty() )
{
return Reference< XHierarchicalNameAccess >( nullptr );
}
@ -795,14 +796,14 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( const OUString& jar,
{
OUString zipFile;
// Extension jar file? Search for ?
sal_Int32 nQuestionMark1 = jar.indexOf( '?' );
sal_Int32 nQuestionMark2 = jar.lastIndexOf( '?' );
if( nQuestionMark1 != -1 && nQuestionMark2 != -1 && nQuestionMark1 != nQuestionMark2 )
size_t nQuestionMark1 = jar.find( '?' );
size_t nQuestionMark2 = jar.rfind( '?' );
if( nQuestionMark1 != std::u16string_view::npos && nQuestionMark2 != std::u16string_view::npos && nQuestionMark1 != nQuestionMark2 )
{
OUString aExtensionPath = jar.copy( nQuestionMark1 + 1, nQuestionMark2 - nQuestionMark1 - 1 );
OUString aPureJar = jar.copy( nQuestionMark2 + 1 );
std::u16string_view aExtensionPath = jar.substr( nQuestionMark1 + 1, nQuestionMark2 - nQuestionMark1 - 1 );
std::u16string_view aPureJar = jar.substr( nQuestionMark2 + 1 );
zipFile = expandURL( aExtensionPath + "/" + aPureJar );
zipFile = expandURL( OUString::Concat(aExtensionPath) + "/" + aPureJar );
}
else
{
@ -1795,12 +1796,12 @@ OUString IndexFolderIterator::implGetIndexFolderFromPackage( bool& o_rbTemporary
return aIndexFolder;
}
void IndexFolderIterator::deleteTempIndexFolder( const OUString& aIndexFolder )
void IndexFolderIterator::deleteTempIndexFolder( std::u16string_view aIndexFolder )
{
sal_Int32 nLastSlash = aIndexFolder.lastIndexOf( '/' );
if( nLastSlash != -1 )
size_t nLastSlash = aIndexFolder.rfind( '/' );
if( nLastSlash != std::u16string_view::npos )
{
OUString aTmpFolder = aIndexFolder.copy( 0, nLastSlash );
OUString aTmpFolder( aIndexFolder.substr( 0, nLastSlash ) );
try
{
m_xSFA->kill( aTmpFolder );

View file

@ -93,7 +93,7 @@ namespace chelp {
KeywordElement( Databases const * pDatabases,
helpdatafileproxy::Hdf* pHdf,
OUString const & key,
OUString const & ids );
std::u16string_view ids );
private:
@ -102,7 +102,7 @@ namespace chelp {
css::uno::Sequence< OUString > listAnchor;
css::uno::Sequence< OUString > listTitle;
void init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf,const OUString& ids );
void init( Databases const *pDatabases,helpdatafileproxy::Hdf* pHdf, std::u16string_view ids );
};
explicit KeywordInfo( const std::vector< KeywordElement >& aVector );
@ -193,7 +193,7 @@ namespace chelp {
*/
css::uno::Reference< css::container::XHierarchicalNameAccess >
jarFile( const OUString& jar,
jarFile( std::u16string_view jar,
const OUString& Language );
css::uno::Reference< css::container::XHierarchicalNameAccess >
@ -423,7 +423,7 @@ namespace chelp {
{}
OUString nextIndexFolder( bool& o_rbExtension, bool& o_rbTemporary );
void deleteTempIndexFolder( const OUString& aIndexFolder );
void deleteTempIndexFolder( std::u16string_view aIndexFolder );
private:
OUString implGetIndexFolderFromPackage( bool& o_rbTemporary,

View file

@ -84,7 +84,7 @@ public:
* Checks if a particular stream is a valid xml stream. Those are treated
* differently when they are signed (c14n transformation)
*/
bool isXML(const OUString& rURI);
bool isXML(std::u16string_view rURI);
bool readManifest();
SignatureStreamHelper ImplOpenSignatureStream(sal_Int32 nStreamOpenMode, bool bTempStream);

View file

@ -41,6 +41,7 @@
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <tools/datetime.hxx>
#include <o3tl/string_view.hxx>
#include <certificate.hxx>
#include <biginteger.hxx>
@ -166,7 +167,7 @@ bool DocumentSignatureManager::readManifest()
The parameter is an encoded uri. However, the manifest contains paths. Therefore
the path is encoded as uri, so they can be compared.
*/
bool DocumentSignatureManager::isXML(const OUString& rURI)
bool DocumentSignatureManager::isXML(std::u16string_view rURI)
{
SAL_WARN_IF(!mxStore.is(), "xmlsecurity.helper", "empty storage reference");
@ -207,11 +208,11 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
//Files can only be encrypted if they are in the manifest.xml.
//That is, the current file cannot be encrypted, otherwise bPropsAvailable
//would be true.
sal_Int32 nSep = rURI.lastIndexOf('.');
if (nSep != -1)
size_t nSep = rURI.rfind('.');
if (nSep != std::u16string_view::npos)
{
OUString aExt = rURI.copy(nSep + 1);
if (aExt.equalsIgnoreAsciiCase("XML"))
std::u16string_view aExt = rURI.substr(nSep + 1);
if (o3tl::equalsIgnoreAsciiCase(aExt, u"XML"))
bIsXML = true;
}
}