diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-12-16 17:16:13 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-12-17 16:13:43 +0000 |
commit | 9ca34fa4514dd90de5383f7329a424486161bdbe (patch) | |
tree | a1a66b0f99f37ddab8ff56c10fef35af922dfd06 /xmloff | |
parent | 5c2f401a5f07065dd9ae06e0a80911beb6fd9ac4 (diff) |
Minor simplification
(the explicit OUStringLiteral ctors in aServiceMap are needed at least by GCC 4.8
used by <http://ci.libreoffice.org/job/lo_gerrit/Config=linux_gcc_release_64/>)
Change-Id: I16721317ef4fd47ca6f2905a9387a77fbf54086a
Reviewed-on: https://gerrit.libreoffice.org/32100
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/XMLEmbeddedObjectImportContext.cxx | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx index f25d02c8dd0c..c9fc928ea58a 100644 --- a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx +++ b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx @@ -41,29 +41,6 @@ using namespace ::com::sun::star::document; using namespace ::com::sun::star::xml::sax; using namespace ::xmloff::token; -namespace { - -struct XMLServiceMapEntry_Impl -{ - enum XMLTokenEnum eClass; - const sal_Char *sFilterService; -}; - -const XMLServiceMapEntry_Impl aServiceMap[] = -{ - { XML_TEXT, XML_IMPORT_FILTER_WRITER }, - { XML_ONLINE_TEXT, XML_IMPORT_FILTER_WRITER }, - { XML_SPREADSHEET, XML_IMPORT_FILTER_CALC }, - { XML_DRAWING, XML_IMPORT_FILTER_DRAW }, - { XML_GRAPHICS, XML_IMPORT_FILTER_DRAW }, - { XML_PRESENTATION, XML_IMPORT_FILTER_IMPRESS }, - { XML_CHART, XML_IMPORT_FILTER_CHART }, - { XML_TOKEN_INVALID, nullptr } - -}; - -} - class XMLEmbeddedObjectImportContext_Impl : public SvXMLImportContext { css::uno::Reference< css::xml::sax::XDocumentHandler > xHandler; @@ -190,34 +167,37 @@ XMLEmbeddedObjectImportContext::XMLEmbeddedObjectImportContext( } OUString sClass; - static const char * aTmp[] = - { + static OUStringLiteral const prefixes[] = { "application/vnd.oasis.openoffice.", "application/x-vnd.oasis.openoffice.", "application/vnd.oasis.opendocument.", - "application/x-vnd.oasis.opendocument.", - nullptr - }; - for (int k=0; aTmp[k]; k++) + "application/x-vnd.oasis.opendocument."}; + for (auto const & p: prefixes) { - OUString sTmpString = OUString::createFromAscii(aTmp[k]); - if( sMime.matchAsciiL( aTmp[k], sTmpString.getLength() ) ) + if (sMime.startsWith(p, &sClass)) { - sClass = sMime.copy( sTmpString.getLength() ); break; } } if( !sClass.isEmpty() ) { - const XMLServiceMapEntry_Impl *pEntry = aServiceMap; - while( pEntry->eClass != XML_TOKEN_INVALID ) + static struct { XMLTokenEnum eClass; OUStringLiteral sFilterService; + } const aServiceMap[] = { + { XML_TEXT, OUStringLiteral(XML_IMPORT_FILTER_WRITER) }, + { XML_ONLINE_TEXT, OUStringLiteral(XML_IMPORT_FILTER_WRITER) }, + { XML_SPREADSHEET, OUStringLiteral(XML_IMPORT_FILTER_CALC) }, + { XML_DRAWING, OUStringLiteral(XML_IMPORT_FILTER_DRAW) }, + { XML_GRAPHICS, OUStringLiteral(XML_IMPORT_FILTER_DRAW) }, + { XML_PRESENTATION, OUStringLiteral(XML_IMPORT_FILTER_IMPRESS) }, + { XML_CHART, OUStringLiteral(XML_IMPORT_FILTER_CHART) }}; + for (auto const & entry: aServiceMap) { - if( IsXMLToken( sClass, pEntry->eClass ) ) + if( IsXMLToken( sClass, entry.eClass ) ) { - sFilterService = OUString::createFromAscii( pEntry->sFilterService ); + sFilterService = entry.sFilterService; - switch( pEntry->eClass ) + switch( entry.eClass ) { case XML_TEXT: aName = SvGlobalName(SO3_SW_CLASSID); break; case XML_ONLINE_TEXT: aName = SvGlobalName(SO3_SWWEB_CLASSID); break; @@ -233,7 +213,6 @@ XMLEmbeddedObjectImportContext::XMLEmbeddedObjectImportContext( break; } - pEntry++; } } } |