From df18d5878c71d8d38a43dd04c0e907f9385addb4 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 16 May 2013 09:24:31 +0200 Subject: Some string literal clean up Change-Id: I108882af13fa97fa094547ec4efb468f988f337d --- configmgr/source/valueparser.cxx | 16 +-- configmgr/source/xcdparser.cxx | 17 +-- configmgr/source/xcsparser.cxx | 74 ++++++------- configmgr/source/xcuparser.cxx | 230 ++++++++++++++------------------------- configmgr/source/xmldata.cxx | 45 ++++---- include/xmlreader/pad.hxx | 6 + include/xmlreader/span.hxx | 29 ++--- sw/source/ui/envelp/labelcfg.cxx | 26 +++-- xmlreader/source/pad.cxx | 3 +- xmlreader/source/span.cxx | 2 +- xmlreader/source/xmlreader.cxx | 109 ++++++++----------- 11 files changed, 225 insertions(+), 332 deletions(-) diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx index 15b756c30dca..a8dad1922df9 100644 --- a/configmgr/source/valueparser.cxx +++ b/configmgr/source/valueparser.cxx @@ -30,7 +30,6 @@ #include "comphelper/sequenceasvector.hxx" #include "rtl/string.h" #include "rtl/string.hxx" -#include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" #include "xmlreader/span.hxx" @@ -68,15 +67,11 @@ bool parseHexDigit(char c, int * value) { bool parseValue(xmlreader::Span const & text, sal_Bool * value) { assert(text.is() && value != 0); - if (text.equals(RTL_CONSTASCII_STRINGPARAM("true")) || - text.equals(RTL_CONSTASCII_STRINGPARAM("1"))) - { + if (text.equals("true") || text.equals("1")) { *value = true; return true; } - if (text.equals(RTL_CONSTASCII_STRINGPARAM("false")) || - text.equals(RTL_CONSTASCII_STRINGPARAM("0"))) - { + if (text.equals("false") || text.equals("0")) { *value = false; return true; } @@ -293,8 +288,7 @@ bool ValueParser::startElement( } switch (state_) { case STATE_TEXT: - if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("it")) && + if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && name.equals("it") && isListType(type_) && separator_.isEmpty()) { pad_.clear(); @@ -306,7 +300,7 @@ bool ValueParser::startElement( // fall through case STATE_IT: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("unicode")) && + name.equals("unicode") && (type_ == TYPE_STRING || type_ == TYPE_STRING_LIST)) { sal_Int32 scalar = -1; @@ -317,7 +311,7 @@ bool ValueParser::startElement( break; } if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("scalar"))) + attrLn.equals("scalar")) { if (!parseValue(reader.getAttributeValue(true), &scalar)) { scalar = -1; diff --git a/configmgr/source/xcdparser.cxx b/configmgr/source/xcdparser.cxx index 4213f6cb3839..ebf14feda7f2 100644 --- a/configmgr/source/xcdparser.cxx +++ b/configmgr/source/xcdparser.cxx @@ -26,8 +26,6 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/XInterface.hpp" -#include "rtl/string.h" -#include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "xmlreader/span.hxx" #include "xmlreader/xmlreader.hxx" @@ -65,16 +63,14 @@ bool XcdParser::startElement( } switch (state_) { case STATE_START: - if (nsId == ParseManager::NAMESPACE_OOR && - name.equals(RTL_CONSTASCII_STRINGPARAM("data"))) - { + if (nsId == ParseManager::NAMESPACE_OOR && name.equals("data")) { state_ = STATE_DEPENDENCIES; return true; } break; case STATE_DEPENDENCIES: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("dependency"))) + name.equals("dependency")) { if (dependencyFile_.isEmpty()) { dependencyOptional_ = false; @@ -87,13 +83,12 @@ bool XcdParser::startElement( } if (attrNsId == xmlreader::XmlReader::NAMESPACE_NONE && //TODO: _OOR - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("file"))) + attrLn.equals("file")) { attrFile = reader.getAttributeValue(false); } else if ((attrNsId == xmlreader::XmlReader::NAMESPACE_NONE) && - attrLn.equals( - RTL_CONSTASCII_STRINGPARAM("optional"))) + attrLn.equals("optional")) { dependencyOptional_ = xmldata::parseBoolean( reader.getAttributeValue(true)); @@ -129,7 +124,7 @@ bool XcdParser::startElement( // fall through case STATE_COMPONENTS: if (nsId == ParseManager::NAMESPACE_OOR && - name.equals(RTL_CONSTASCII_STRINGPARAM("component-schema"))) + name.equals("component-schema")) { nestedParser_ = new XcsParser(layer_, data_); nesting_ = 1; @@ -137,7 +132,7 @@ bool XcdParser::startElement( reader, nsId, name, existingDependencies); } if (nsId == ParseManager::NAMESPACE_OOR && - name.equals(RTL_CONSTASCII_STRINGPARAM("component-data"))) + name.equals("component-data")) { nestedParser_ = new XcuParser(layer_ + 1, data_, 0, 0, 0); nesting_ = 1; diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx index c0b4296d4dda..b60cb1d5145e 100644 --- a/configmgr/source/xcsparser.cxx +++ b/configmgr/source/xcsparser.cxx @@ -29,9 +29,7 @@ #include "com/sun/star/uno/XInterface.hpp" #include "rtl/ref.hxx" #include "rtl/strbuf.hxx" -#include "rtl/string.h" #include "rtl/string.hxx" -#include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "xmlreader/span.hxx" #include "xmlreader/xmlreader.hxx" @@ -134,7 +132,8 @@ bool XcsParser::startElement( } if (state_ == STATE_START) { if (nsId == ParseManager::NAMESPACE_OOR && - name.equals(RTL_CONSTASCII_STRINGPARAM("component-schema"))) { + name.equals("component-schema")) + { handleComponentSchema(reader); state_ = STATE_COMPONENT_SCHEMA; ignoring_ = 0; @@ -146,10 +145,8 @@ bool XcsParser::startElement( // illegal content): if (ignoring_ > 0 || (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - (name.equals(RTL_CONSTASCII_STRINGPARAM("info")) || - name.equals(RTL_CONSTASCII_STRINGPARAM("import")) || - name.equals(RTL_CONSTASCII_STRINGPARAM("uses")) || - name.equals(RTL_CONSTASCII_STRINGPARAM("constraints"))))) + (name.equals("info") || name.equals("import") || + name.equals("uses") || name.equals("constraints")))) { assert(ignoring_ < LONG_MAX); ++ignoring_; @@ -158,7 +155,7 @@ bool XcsParser::startElement( switch (state_) { case STATE_COMPONENT_SCHEMA: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("templates"))) + name.equals("templates")) { state_ = STATE_TEMPLATES; return true; @@ -166,7 +163,7 @@ bool XcsParser::startElement( // fall through case STATE_TEMPLATES_DONE: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("component"))) + name.equals("component")) { state_ = STATE_COMPONENT; assert(elements_.empty()); @@ -181,13 +178,13 @@ bool XcsParser::startElement( case STATE_TEMPLATES: if (elements_.empty()) { if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("group"))) + name.equals("group")) { handleGroup(reader, true); return true; } if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("set"))) + name.equals("set")) { handleSet(reader, true); return true; @@ -201,7 +198,7 @@ bool XcsParser::startElement( case Node::KIND_PROPERTY: case Node::KIND_LOCALIZED_PROPERTY: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("value"))) + name.equals("value")) { handlePropValue(reader, elements_.top().node); return true; @@ -209,25 +206,25 @@ bool XcsParser::startElement( break; case Node::KIND_GROUP: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("prop"))) + name.equals("prop")) { handleProp(reader); return true; } if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("node-ref"))) + name.equals("node-ref")) { handleNodeRef(reader); return true; } if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("group"))) + name.equals("group")) { handleGroup(reader, false); return true; } if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("set"))) + name.equals("set")) { handleSet(reader, false); return true; @@ -235,7 +232,7 @@ bool XcsParser::startElement( break; case Node::KIND_SET: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("item"))) + name.equals("item")) { handleSetItem( reader, @@ -356,8 +353,7 @@ void XcsParser::handleComponentSchema(xmlreader::XmlReader & reader) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("package"))) + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("package")) { if (hasPackage) { throw css::uno::RuntimeException( @@ -370,7 +366,7 @@ void XcsParser::handleComponentSchema(xmlreader::XmlReader & reader) { xmlreader::Span s(reader.getAttributeValue(false)); buf.insert(0, s.begin, s.length); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) + attrLn.equals("name")) { if (hasName) { throw css::uno::RuntimeException( @@ -411,17 +407,15 @@ void XcsParser::handleNodeRef(xmlreader::XmlReader & reader) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("name")) { hasName = true; name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component"))) + attrLn.equals("component")) { component = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type"))) + attrLn.equals("node-type")) { hasNodeType = true; nodeType = reader.getAttributeValue(false).convertFromUtf8(); @@ -464,22 +458,20 @@ void XcsParser::handleProp(xmlreader::XmlReader & reader) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("name")) { hasName = true; name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type"))) + attrLn.equals("type")) { valueParser_.type_ = xmldata::parseType( reader, reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("localized"))) + attrLn.equals("localized")) { localized = xmldata::parseBoolean(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("nillable"))) + attrLn.equals("nillable")) { nillable = xmldata::parseBoolean(reader.getAttributeValue(true)); } @@ -520,7 +512,7 @@ void XcsParser::handlePropValue( break; } if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("separator"))) + attrLn.equals("separator")) { attrSeparator = reader.getAttributeValue(false); if (attrSeparator.length == 0) { @@ -546,13 +538,11 @@ void XcsParser::handleGroup(xmlreader::XmlReader & reader, bool isTemplate) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("name")) { hasName = true; name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("extensible"))) + attrLn.equals("extensible")) { extensible = xmldata::parseBoolean(reader.getAttributeValue(true)); } @@ -586,17 +576,15 @@ void XcsParser::handleSet(xmlreader::XmlReader & reader, bool isTemplate) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("name")) { hasName = true; name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component"))) + attrLn.equals("component")) { component = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type"))) + attrLn.equals("node-type")) { hasNodeType = true; nodeType = reader.getAttributeValue(false).convertFromUtf8(); @@ -632,11 +620,11 @@ void XcsParser::handleSetItem(xmlreader::XmlReader & reader, SetNode * set) { break; } if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component"))) + attrLn.equals("component")) { component = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type"))) + attrLn.equals("node-type")) { hasNodeType = true; nodeType = reader.getAttributeValue(false).convertFromUtf8(); diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index c8a2acfd1850..e77025fb70b2 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -80,33 +80,27 @@ bool XcuParser::startElement( } if (state_.empty()) { if (nsId == ParseManager::NAMESPACE_OOR && - name.equals(RTL_CONSTASCII_STRINGPARAM("component-data"))) + name.equals("component-data")) { handleComponentData(reader); - } else if (nsId == ParseManager::NAMESPACE_OOR && - name.equals(RTL_CONSTASCII_STRINGPARAM("items"))) + } else if (nsId == ParseManager::NAMESPACE_OOR && name.equals("items")) { state_.push(State(rtl::Reference< Node >(), false)); } else { throw css::uno::RuntimeException( - (OUString("bad root element <") + - name.convertFromUtf8() + - OUString("> in ") + + ("bad root element <" + name.convertFromUtf8() + "> in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } } else if (state_.top().ignore) { state_.push(State(false)); } else if (!state_.top().node.is()) { - if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("item"))) + if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && name.equals("item")) { handleItem(reader); } else { throw css::uno::RuntimeException( - (OUString("bad items node member <") + - name.convertFromUtf8() + - OUString("> in ") + + ("bad items node member <" + name.convertFromUtf8() + "> in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } @@ -114,23 +108,21 @@ bool XcuParser::startElement( switch (state_.top().node->kind()) { case Node::KIND_PROPERTY: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("value"))) + name.equals("value")) { handlePropValue( reader, dynamic_cast< PropertyNode * >(state_.top().node.get())); } else { throw css::uno::RuntimeException( - (OUString("bad property node member <") + - name.convertFromUtf8() + - OUString("> in ") + - reader.getUrl()), + ("bad property node member <" + name.convertFromUtf8() + + "> in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } break; case Node::KIND_LOCALIZED_PROPERTY: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("value"))) + name.equals("value")) { handleLocpropValue( reader, @@ -138,48 +130,42 @@ bool XcuParser::startElement( state_.top().node.get())); } else { throw css::uno::RuntimeException( - (OUString("bad localized property node member <") + - name.convertFromUtf8() + - OUString("> in ") + - reader.getUrl()), + ("bad localized property node member <" + + name.convertFromUtf8() + "> in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } break; case Node::KIND_LOCALIZED_VALUE: throw css::uno::RuntimeException( - (OUString("bad member <") + - name.convertFromUtf8() + - OUString("> in ") + + ("bad member <" + name.convertFromUtf8() + "> in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); case Node::KIND_GROUP: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("prop"))) + name.equals("prop")) { handleGroupProp( reader, dynamic_cast< GroupNode * >(state_.top().node.get())); } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("node"))) + name.equals("node")) { handleGroupNode(reader, state_.top().node); } else { throw css::uno::RuntimeException( - (OUString("bad group node member <") + - name.convertFromUtf8() + - OUString("> in ") + - reader.getUrl()), + ("bad group node member <" + name.convertFromUtf8() + + "> in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } break; case Node::KIND_SET: if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("node"))) + name.equals("node")) { handleSetNode( reader, dynamic_cast< SetNode * >(state_.top().node.get())); } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("prop"))) + name.equals("prop")) { SAL_WARN( "configmgr", @@ -188,10 +174,8 @@ bool XcuParser::startElement( state_.push(State(true)); // ignored } else { throw css::uno::RuntimeException( - (OUString("bad set node member <") + - name.convertFromUtf8() + - OUString("> in ") + - reader.getUrl()), + ("bad set node member <" + name.convertFromUtf8() + + "> in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } break; @@ -234,21 +218,20 @@ void XcuParser::characters(xmlreader::Span const & text) { XcuParser::Operation XcuParser::parseOperation(xmlreader::Span const & text) { assert(text.is()); - if (text.equals(RTL_CONSTASCII_STRINGPARAM("modify"))) { + if (text.equals("modify")) { return OPERATION_MODIFY; } - if (text.equals(RTL_CONSTASCII_STRINGPARAM("replace"))) { + if (text.equals("replace")) { return OPERATION_REPLACE; } - if (text.equals(RTL_CONSTASCII_STRINGPARAM("fuse"))) { + if (text.equals("fuse")) { return OPERATION_FUSE; } - if (text.equals(RTL_CONSTASCII_STRINGPARAM("remove"))) { + if (text.equals("remove")) { return OPERATION_REMOVE; } throw css::uno::RuntimeException( - (OUString("invalid op ") + - text.convertFromUtf8()), + "invalid op " + text.convertFromUtf8(), css::uno::Reference< css::uno::XInterface >()); } @@ -265,13 +248,11 @@ void XcuParser::handleComponentData(xmlreader::XmlReader & reader) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("package"))) + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("package")) { if (hasPackage) { throw css::uno::RuntimeException( - (OUString("multiple component-update package attributes" - " in ") + + ("multiple component-update package attributes in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } @@ -279,11 +260,11 @@ void XcuParser::handleComponentData(xmlreader::XmlReader & reader) { xmlreader::Span s(reader.getAttributeValue(false)); buf.insert(0, s.begin, s.length); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) + attrLn.equals("name")) { if (hasName) { throw css::uno::RuntimeException( - (OUString("multiple component-update name attributes in ") + + ("multiple component-update name attributes in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } @@ -291,25 +272,23 @@ void XcuParser::handleComponentData(xmlreader::XmlReader & reader) { xmlreader::Span s(reader.getAttributeValue(false)); buf.append(s.begin, s.length); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op"))) + attrLn.equals("op")) { op = parseOperation(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized"))) + attrLn.equals("finalized")) { finalized = xmldata::parseBoolean(reader.getAttributeValue(true)); } } if (!hasPackage) { throw css::uno::RuntimeException( - (OUString("no component-data package attribute in ") + - reader.getUrl()), + "no component-data package attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } if (!hasName) { throw css::uno::RuntimeException( - (OUString("no component-data name attribute in ") + - reader.getUrl()), + "no component-data name attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } componentName_ = xmlreader::Span(buf.getStr(), buf.getLength()). @@ -340,8 +319,7 @@ void XcuParser::handleComponentData(xmlreader::XmlReader & reader) { break; default: throw css::uno::RuntimeException( - (OUString("invalid operation on root node in ") + - reader.getUrl()), + "invalid operation on root node in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } int finalizedLayer = std::min( @@ -359,16 +337,13 @@ void XcuParser::handleItem(xmlreader::XmlReader & reader) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("path"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("path")) { attrPath = reader.getAttributeValue(false); } } if (!attrPath.is()) { throw css::uno::RuntimeException( - (OUString("missing path attribute in ") + - reader.getUrl()), + "missing path attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } OUString path(attrPath.convertFromUtf8()); @@ -425,41 +400,36 @@ void XcuParser::handlePropValue( if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_XSI && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("nil"))) - { + if (attrNsId == ParseManager::NAMESPACE_XSI && attrLn.equals("nil")) { nil = xmldata::parseBoolean(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type"))) + attrLn.equals("type")) { Type type = xmldata::parseType( reader, reader.getAttributeValue(true)); if (valueParser_.type_ != TYPE_ANY && type != valueParser_.type_) { throw css::uno::RuntimeException( - (OUString("invalid value type in ") + - reader.getUrl()), + "invalid value type in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } valueParser_.type_ = type; } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("separator"))) + attrLn.equals("separator")) { xmlreader::Span s(reader.getAttributeValue(false)); if (s.length == 0) { throw css::uno::RuntimeException( - (OUString("bad oor:separator attribute in ") + - reader.getUrl()), + "bad oor:separator attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } separator = OString(s.begin, s.length); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("external"))) + attrLn.equals("external")) { external = reader.getAttributeValue(true).convertFromUtf8(); if (external.isEmpty()) { throw css::uno::RuntimeException( - (OUString("bad oor:external attribute value in ") + - reader.getUrl()), + "bad oor:external attribute value in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } } @@ -467,13 +437,12 @@ void XcuParser::handlePropValue( if (nil) { if (!prop->isNillable()) { throw css::uno::RuntimeException( - (OUString("xsi:nil attribute for non-nillable prop in ") + - reader.getUrl()), + "xsi:nil attribute for non-nillable prop in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } if (!external.isEmpty()) { throw css::uno::RuntimeException( - (OUString("xsi:nil and oor:external attributes for prop in ") + + ("xsi:nil and oor:external attributes for prop in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } @@ -502,38 +471,36 @@ void XcuParser::handleLocpropValue( break; } if (attrNsId == xmlreader::XmlReader::NAMESPACE_XML && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("lang"))) + attrLn.equals("lang")) { name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_XSI && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("nil"))) + attrLn.equals("nil")) { nil = xmldata::parseBoolean(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type"))) + attrLn.equals("type")) { Type type = xmldata::parseType( reader, reader.getAttributeValue(true)); if (valueParser_.type_ != TYPE_ANY && type != valueParser_.type_) { throw css::uno::RuntimeException( - (OUString("invalid value type in ") + - reader.getUrl()), + "invalid value type in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } valueParser_.type_ = type; } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("separator"))) + attrLn.equals("separator")) { xmlreader::Span s(reader.getAttributeValue(false)); if (s.length == 0) { throw css::uno::RuntimeException( - (OUString("bad oor:separator attribute in ") + - reader.getUrl()), + "bad oor:separator attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } separator = OString(s.begin, s.length); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op"))) + attrLn.equals("op")) { op = parseOperation(reader.getAttributeValue(true)); } @@ -555,8 +522,7 @@ void XcuParser::handleLocpropValue( } if (nil && !locprop->isNillable()) { throw css::uno::RuntimeException( - (OUString("xsi:nil attribute for non-nillable prop in ") + - reader.getUrl()), + "xsi:nil attribute for non-nillable prop in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } switch (op) { @@ -597,8 +563,7 @@ void XcuParser::handleLocpropValue( break; default: throw css::uno::RuntimeException( - (OUString("bad op attribute for value element in ") + - reader.getUrl()), + "bad op attribute for value element in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } } @@ -617,29 +582,26 @@ void XcuParser::handleGroupProp( if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("name")) { hasName = true; name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type"))) + attrLn.equals("type")) { type = xmldata::parseType(reader, reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op"))) + attrLn.equals("op")) { op = parseOperation(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized"))) + attrLn.equals("finalized")) { finalized = xmldata::parseBoolean(reader.getAttributeValue(true)); } } if (!hasName) { throw css::uno::RuntimeException( - (OUString("no prop name attribute in ") + - reader.getUrl()), + "no prop name attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } if (trackPath_) { @@ -670,9 +632,7 @@ void XcuParser::handleGroupProp( break; default: throw css::uno::RuntimeException( - (OUString("inappropriate prop ") + - name + OUString(" in ") + - reader.getUrl()), + "inappropriate prop " + name + " in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } } @@ -688,10 +648,9 @@ void XcuParser::handleUnknownGroupProp( if (group->isExtensible()) { if (type == TYPE_ERROR) { throw css::uno::RuntimeException( - (OUString("missing type attribute for prop ") + - name + OUString(" in ") + - reader.getUrl()), - css::uno::Reference< css::uno::XInterface >()); + ("missing type attribute for prop " + name + " in " + + reader.getUrl()), + css::uno::Reference< css::uno::XInterface >()); } valueParser_.type_ = type; rtl::Reference< Node > prop( @@ -735,9 +694,7 @@ void XcuParser::handlePlainGroupProp( type != property->getStaticType()) { throw css::uno::RuntimeException( - (OUString("invalid type for prop ") + - name + OUString(" in ") + - reader.getUrl()), + "invalid type for prop " + name + " in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } valueParser_.type_ = type == TYPE_ERROR ? property->getStaticType() : type; @@ -755,8 +712,7 @@ void XcuParser::handlePlainGroupProp( case OPERATION_REMOVE: if (!property->isExtension()) { throw css::uno::RuntimeException( - (OUString("invalid remove of non-extension prop ") + - name + OUString(" in ") + + ("invalid remove of non-extension prop " + name + " in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } @@ -783,9 +739,7 @@ void XcuParser::handleLocalizedGroupProp( type != property->getStaticType()) { throw css::uno::RuntimeException( - (OUString("invalid type for prop ") + - name + OUString(" in ") + - reader.getUrl()), + "invalid type for prop " + name + " in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } valueParser_.type_ = type == TYPE_ERROR ? property->getStaticType() : type; @@ -815,8 +769,7 @@ void XcuParser::handleLocalizedGroupProp( break; case OPERATION_REMOVE: throw css::uno::RuntimeException( - (OUString("invalid remove of non-extension prop ") + - name + OUString(" in ") + + ("invalid remove of non-extension prop " + name + " in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } @@ -835,25 +788,22 @@ void XcuParser::handleGroupNode( if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("name")) { hasName = true; name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op"))) + attrLn.equals("op")) { op = parseOperation(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized"))) + attrLn.equals("finalized")) { finalized = xmldata::parseBoolean(reader.getAttributeValue(true)); } } if (!hasName) { throw css::uno::RuntimeException( - (OUString("no node name attribute in ") + - reader.getUrl()), + "no node name attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } if (trackPath_) { @@ -876,16 +826,13 @@ void XcuParser::handleGroupNode( Node::Kind kind = child->kind(); if (kind != Node::KIND_GROUP && kind != Node::KIND_SET) { throw css::uno::RuntimeException( - (OUString("bad \"") + - name + - OUString("\" of non group/set kind in ") + + ("bad \"" + name + "\" of non group/set kind in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } if (op != OPERATION_MODIFY && op != OPERATION_FUSE) { throw css::uno::RuntimeException( - (OUString("invalid operation on group node in ") + - reader.getUrl()), + "invalid operation on group node in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } int finalizedLayer = std::min( @@ -913,38 +860,35 @@ void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) { if (!reader.nextAttribute(&attrNsId, &attrLn)) { break; } - if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name"))) - { + if (attrNsId == ParseManager::NAMESPACE_OOR && attrLn.equals("name")) { hasName = true; name = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component"))) + attrLn.equals("component")) { component = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type"))) + attrLn.equals("node-type")) { hasNodeType = true; nodeType = reader.getAttributeValue(false).convertFromUtf8(); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op"))) + attrLn.equals("op")) { op = parseOperation(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized"))) + attrLn.equals("finalized")) { finalized = xmldata::parseBoolean(reader.getAttributeValue(true)); } else if (attrNsId == ParseManager::NAMESPACE_OOR && - attrLn.equals(RTL_CONSTASCII_STRINGPARAM("mandatory"))) + attrLn.equals("mandatory")) { mandatory = xmldata::parseBoolean(reader.getAttributeValue(true)); } } if (!hasName) { throw css::uno::RuntimeException( - (OUString("no node name attribute in ") + - reader.getUrl()), + "no node name attribute in " + reader.getUrl(), css::uno::Reference< css::uno::XInterface >()); } if (trackPath_) { @@ -960,22 +904,16 @@ void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) { component, hasNodeType, nodeType, &set->getDefaultTemplateName())); if (!set->isValidTemplate(templateName)) { throw css::uno::RuntimeException( - (OUString("set member node ") + - name + - OUString(" references invalid template ") + - templateName + OUString(" in ") + - reader.getUrl()), + ("set member node " + name + " references invalid template " + + templateName + " in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } rtl::Reference< Node > tmpl( data_.getTemplate(valueParser_.getLayer(), templateName)); if (!tmpl.is()) { throw css::uno::RuntimeException( - (OUString("set member node ") + - name + - OUString(" references undefined template ") + - templateName + OUString(" in ") + - reader.getUrl()), + ("set member node " + name + " references undefined template " + + templateName + " in " + reader.getUrl()), css::uno::Reference< css::uno::XInterface >()); } int finalizedLayer = finalized ? valueParser_.getLayer() : Data::NO_LAYER; diff --git a/configmgr/source/xmldata.cxx b/configmgr/source/xmldata.cxx index a5dc0896a05f..577e1e68d38b 100644 --- a/configmgr/source/xmldata.cxx +++ b/configmgr/source/xmldata.cxx @@ -29,10 +29,7 @@ #include "com/sun/star/uno/XInterface.hpp" #include "osl/file.hxx" #include "rtl/ref.hxx" -#include "rtl/strbuf.hxx" #include "rtl/string.h" -#include "rtl/ustrbuf.hxx" -#include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" #include "xmlreader/span.hxx" @@ -63,79 +60,79 @@ Type parseType( switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) { case ParseManager::NAMESPACE_OOR: if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("any"))) + equals("any")) { return TYPE_ANY; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("boolean-list"))) + equals("boolean-list")) { return TYPE_BOOLEAN_LIST; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("short-list"))) + equals("short-list")) { return TYPE_SHORT_LIST; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("int-list"))) + equals("int-list")) { return TYPE_INT_LIST; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("long-list"))) + equals("long-list")) { return TYPE_LONG_LIST; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("double-list"))) + equals("double-list")) { return TYPE_DOUBLE_LIST; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("string-list"))) + equals("string-list")) { return TYPE_STRING_LIST; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("hexBinary-list"))) + equals("hexBinary-list")) { return TYPE_HEXBINARY_LIST; } break; case ParseManager::NAMESPACE_XS: if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("boolean"))) + equals("boolean")) { return TYPE_BOOLEAN; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("short"))) + equals("short")) { return TYPE_SHORT; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("int"))) + equals("int")) { return TYPE_INT; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("long"))) + equals("long")) { return TYPE_LONG; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("double"))) + equals("double")) { return TYPE_DOUBLE; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("string"))) + equals("string")) { return TYPE_STRING; } else if (xmlreader::Span( text.begin + i + 1, text.length - (i + 1)). - equals(RTL_CONSTASCII_STRINGPARAM("hexBinary"))) + equals("hexBinary")) { return TYPE_HEXBINARY; } @@ -145,22 +142,20 @@ Type parseType( } } throw css::uno::RuntimeException( - (OUString("invalid type ") + - text.convertFromUtf8()), + "invalid type " + text.convertFromUtf8(), css::uno::Reference< css::uno::XInterface >()); } bool parseBoolean(xmlreader::Span const & text) { assert(text.is()); - if (text.equals(RTL_CONSTASCII_STRINGPARAM("true"))) { + if (text.equals("true")) { return true; } - if (text.equals(RTL_CONSTASCII_STRINGPARAM("false"))) { + if (text.equals("false")) { return false; } throw css::uno::RuntimeException( - (OUString("invalid boolean ") + - text.convertFromUtf8()), + "invalid boolean " + text.convertFromUtf8(), css::uno::Reference< css::uno::XInterface >()); } @@ -173,7 +168,7 @@ OUString parseTemplateReference( return *defaultTemplateName; } throw css::uno::RuntimeException( - OUString("missing node-type attribute"), + "missing node-type attribute", css::uno::Reference< css::uno::XInterface >()); } return Data::fullTemplateName(component, nodeType); diff --git a/include/xmlreader/pad.hxx b/include/xmlreader/pad.hxx index 0b8e1f3b7453..728a702d0a9e 100644 --- a/include/xmlreader/pad.hxx +++ b/include/xmlreader/pad.hxx @@ -22,6 +22,8 @@ #include "sal/config.h" +#include + #include "rtl/strbuf.hxx" #include "sal/types.h" #include "xmlreader/detail/xmlreaderdllapi.hxx" @@ -33,6 +35,10 @@ class OOO_DLLPUBLIC_XMLREADER Pad { public: void add(char const * begin, sal_Int32 length); + template< std::size_t N > void add(char const (& literal)[N]) { + add(literal, N - 1); + } + void addEphemeral(char const * begin, sal_Int32 length); void clear(); diff --git a/include/xmlreader/span.hxx b/include/xmlreader/span.hxx index 4f3e4d1c285d..26c6648bf329 100644 --- a/include/xmlreader/span.hxx +++ b/include/xmlreader/span.hxx @@ -22,12 +22,13 @@ #include "sal/config.h" -#include "rtl/string.hxx" -#include "rtl/stringutils.hxx" -#include "rtl/ustring.hxx" +#include + #include "sal/types.h" #include "xmlreader/detail/xmlreaderdllapi.hxx" +namespace rtl { class OUString; } + namespace xmlreader { struct OOO_DLLPUBLIC_XMLREADER Span { @@ -40,6 +41,10 @@ struct OOO_DLLPUBLIC_XMLREADER Span { inline Span(char const * theBegin, sal_Int32 theLength): begin(theBegin), length(theLength) {} + template< std::size_t N > explicit inline Span(char const (& literal)[N]): + begin(literal), length(N - 1) + {} + inline void clear() throw() { begin = 0; } inline bool is() const { return begin != 0; } @@ -53,23 +58,13 @@ struct OOO_DLLPUBLIC_XMLREADER Span { return equals(Span(textBegin, textLength)); } - inline bool equals(OString const & text) const { - return rtl_str_compare_WithLength( - begin, length, text.getStr(), text.getLength()) == 0; - } - - /** - @overload - This function accepts an ASCII string literal as its argument. - */ - template< typename T > bool - equals( T& literal, typename rtl::internal::ConstCharArrayDetector< T, rtl::internal::Dummy >::Type = rtl::internal::Dummy() ) SAL_THROW(()) + template< std::size_t N > inline bool equals(char const (& literal)[N]) + const { - assert( strlen( literal ) == rtl::internal::ConstCharArrayDetector< T >::size - 1 ); - return rtl_str_compare_WithLength( begin, length, literal, rtl::internal::ConstCharArrayDetector< T, void >::size - 1 ) == 0; + return equals(Span(literal, N - 1)); } - OUString convertFromUtf8() const; + rtl::OUString convertFromUtf8() const; }; } diff --git a/sw/source/ui/envelp/labelcfg.cxx b/sw/source/ui/envelp/labelcfg.cxx index 6aaee0be304b..dc815c7a5a5d 100644 --- a/sw/source/ui/envelp/labelcfg.cxx +++ b/sw/source/ui/envelp/labelcfg.cxx @@ -87,19 +87,22 @@ SwLabelConfig::SwLabelConfig() : // fill m_aLabels and m_aManufacturers with the predefined labels res = reader.nextItem( xmlreader::XmlReader::TEXT_NONE, &name, &nsId); - assert(res == xmlreader::XmlReader::RESULT_BEGIN && - name.equals(RTL_CONSTASCII_STRINGPARAM("manufacturers"))); + assert( + res == xmlreader::XmlReader::RESULT_BEGIN + && name.equals("manufacturers")); res = reader.nextItem( xmlreader::XmlReader::TEXT_NONE, &name, &nsId); while (res != xmlreader::XmlReader::RESULT_END) { // Opening manufacturer - assert(res == xmlreader::XmlReader::RESULT_BEGIN && - name.equals(RTL_CONSTASCII_STRINGPARAM("manufacturer"))); + assert( + res == xmlreader::XmlReader::RESULT_BEGIN + && name.equals("manufacturer")); // Get the name reader.nextAttribute(&nsId, &name); - assert(nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals(RTL_CONSTASCII_STRINGPARAM("name"))); + assert( + nsId == xmlreader::XmlReader::NAMESPACE_NONE + && name.equals("name")); sManufacturer = reader.getAttributeValue(false).convertFromUtf8(); for(;;) { @@ -108,14 +111,13 @@ SwLabelConfig::SwLabelConfig() : xmlreader::XmlReader::TEXT_NONE, &name, &nsId); if (res == xmlreader::XmlReader::RESULT_END) break; - assert(res == xmlreader::XmlReader::RESULT_BEGIN && - name.equals(RTL_CONSTASCII_STRINGPARAM("label"))); + assert( + res == xmlreader::XmlReader::RESULT_BEGIN + && name.equals("label")); // Get name value - sName = lcl_getValue(reader, - xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("name"))); + sName = lcl_getValue(reader, xmlreader::Span("name")); // Get measure value - sMeasure = lcl_getValue(reader, - xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("measure"))); + sMeasure = lcl_getValue(reader, xmlreader::Span("measure")); // Ending label mark lcl_assertEndingItem(reader); if ( m_aLabels.find( sManufacturer ) == m_aLabels.end() ) diff --git a/xmlreader/source/pad.cxx b/xmlreader/source/pad.cxx index 98ff5cb6e96d..d48915702784 100644 --- a/xmlreader/source/pad.cxx +++ b/xmlreader/source/pad.cxx @@ -21,7 +21,6 @@ #include -#include "rtl/string.h" #include "sal/types.h" #include "xmlreader/pad.hxx" #include "xmlreader/span.hxx" @@ -61,7 +60,7 @@ Span Pad::get() const { if (span_.is()) { return span_; } else if (buffer_.getLength() == 0) { - return Span(RTL_CONSTASCII_STRINGPARAM("")); + return Span(""); } else { return Span(buffer_.getStr(), buffer_.getLength()); } diff --git a/xmlreader/source/span.cxx b/xmlreader/source/span.cxx index 92a218f1941e..8863d23dccf8 100644 --- a/xmlreader/source/span.cxx +++ b/xmlreader/source/span.cxx @@ -42,7 +42,7 @@ OUString Span::convertFromUtf8() const { RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) { throw css::uno::RuntimeException( - OUString("cannot convert from UTF-8"), + "cannot convert from UTF-8", css::uno::Reference< css::uno::XInterface >()); } return OUString(s, SAL_NO_ACQUIRE); diff --git a/xmlreader/source/xmlreader.cxx b/xmlreader/source/xmlreader.cxx index 51db85f59c03..a014892590fa 100644 --- a/xmlreader/source/xmlreader.cxx +++ b/xmlreader/source/xmlreader.cxx @@ -29,7 +29,6 @@ #include "com/sun/star/uno/XInterface.hpp" #include "osl/file.h" #include "rtl/string.h" -#include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/log.hxx" #include "sal/types.h" @@ -71,9 +70,7 @@ XmlReader::XmlReader(OUString const & fileUrl) fileUrl_, css::uno::Reference< css::uno::XInterface >()); default: throw css::uno::RuntimeException( - (OUString("cannot open ") + - fileUrl_ + OUString(": ") + - OUString::number(e)), + "cannot open " + fileUrl_ + ": " + OUString::number(e), css::uno::Reference< css::uno::XInterface >()); } e = osl_getFileSize(fileHandle_, &fileSize_); @@ -90,16 +87,11 @@ XmlReader::XmlReader(OUString const & fileUrl) "osl_closeFile of \"" << fileUrl_ << "\" failed with " << +e2); } throw css::uno::RuntimeException( - ("cannot mmap " + fileUrl_ + " (" + - OUString::number(e) + ")"), + "cannot mmap " + fileUrl_ + " (" + OUString::number(e) + ")", css::uno::Reference< css::uno::XInterface >()); } - namespaceIris_.push_back( - Span( - RTL_CONSTASCII_STRINGPARAM( - "http://www.w3.org/XML/1998/namespace"))); - namespaces_.push_back( - NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML)); + namespaceIris_.push_back(Span("http://www.w3.org/XML/1998/namespace")); + namespaces_.push_back(NamespaceData(Span("xml"), NAMESPACE_XML)); pos_ = static_cast< char * >(fileAddress_); end_ = pos_ + fileSize_; state_ = STATE_CONTENT; @@ -124,18 +116,13 @@ XmlReader::~XmlReader() { int XmlReader::registerNamespaceIri(Span const & iri) { int id = toNamespaceId(namespaceIris_.size()); namespaceIris_.push_back(iri); - if (iri.equals( - Span( - RTL_CONSTASCII_STRINGPARAM( - "http://www.w3.org/2001/XMLSchema-instance")))) - { + if (iri.equals("http://www.w3.org/2001/XMLSchema-instance")) { // Old user layer .xcu files used the xsi namespace prefix without // declaring a corresponding namespace binding, see issue 77174; reading // those files during migration would fail without this hack that can be // removed once migration is no longer relevant (see // configmgr::Components::parseModificationLayer): - namespaces_.push_back( - NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xsi")), id)); + namespaces_.push_back(NamespaceData(Span("xsi"), id)); } return id; } @@ -225,7 +212,7 @@ void XmlReader::normalizeLineEnds(Span const & text) { p += i + 1; n -= i + 1; if (n == 0 || *p != '\x0A') { - pad_.add(RTL_CONSTASCII_STRINGPARAM("\x0A")); + pad_.add("\x0A"); } } pad_.add(p, n); @@ -250,13 +237,13 @@ bool XmlReader::skipComment() { pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("--")); if (i < 0) { throw css::uno::RuntimeException( - (OUString("premature end (within comment) of ") + fileUrl_), + "premature end (within comment) of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } pos_ += i + RTL_CONSTASCII_LENGTH("--"); if (read() != '>') { throw css::uno::RuntimeException( - (OUString("illegal \"--\" within comment in ") + fileUrl_), + "illegal \"--\" within comment in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } return true; @@ -267,7 +254,7 @@ void XmlReader::skipProcessingInstruction() { pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("?>")); if (i < 0) { throw css::uno::RuntimeException( - (OUString("bad '()); } pos_ += i + RTL_CONSTASCII_LENGTH("?>"); @@ -281,7 +268,7 @@ void XmlReader::skipDocumentTypeDeclaration() { switch (c) { case '\0': // i.e., EOF throw css::uno::RuntimeException( - (OUString("premature end (within DTD) of ") + fileUrl_), + "premature end (within DTD) of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); case '"': case '\'': @@ -290,7 +277,7 @@ void XmlReader::skipDocumentTypeDeclaration() { pos_, end_ - pos_, c); if (i < 0) { throw css::uno::RuntimeException( - (OUString("premature end (within DTD) of ") + fileUrl_), + "premature end (within DTD) of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } pos_ += i + 1; @@ -304,7 +291,7 @@ void XmlReader::skipDocumentTypeDeclaration() { switch (c) { case '\0': // i.e., EOF throw css::uno::RuntimeException( - (OUString("premature end (within DTD) of ") + fileUrl_), + "premature end (within DTD) of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); case '"': case '\'': @@ -313,9 +300,8 @@ void XmlReader::skipDocumentTypeDeclaration() { pos_, end_ - pos_, c); if (i < 0) { throw css::uno::RuntimeException( - (OUString("premature end (within DTD) of ") + - fileUrl_), - css::uno::Reference< css::uno::XInterface >()); + "premature end (within DTD) of " + fileUrl_, + css::uno::Reference< css::uno::XInterface >()); } pos_ += i + 1; } @@ -324,8 +310,7 @@ void XmlReader::skipDocumentTypeDeclaration() { switch (read()) { case '\0': // i.e., EOF throw css::uno::RuntimeException( - (OUString("premature end (within DTD) of ") + - fileUrl_), + "premature end (within DTD) of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); case '!': skipComment(); @@ -341,7 +326,7 @@ void XmlReader::skipDocumentTypeDeclaration() { skipSpace(); if (read() != '>') { throw css::uno::RuntimeException( - (OUString("missing \">\" of DTD in ") + fileUrl_), + "missing \">\" of DTD in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } return; @@ -369,7 +354,7 @@ Span XmlReader::scanCdataSection() { pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("]]>")); if (i < 0) { throw css::uno::RuntimeException( - (OUString("premature end (within CDATA section) of ") + fileUrl_), + "premature end (within CDATA section) of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } pos_ += i + RTL_CONSTASCII_LENGTH("]]>"); @@ -433,7 +418,7 @@ char const * XmlReader::handleReference(char const * position, char const * end) } if (val > 0x10FFFF) { // avoid overflow throw css::uno::RuntimeException( - (OUString("'&#x...' too large in ") + fileUrl_), + "'&#x...' too large in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } } @@ -448,15 +433,14 @@ char const * XmlReader::handleReference(char const * position, char const * end) } if (val > 0x10FFFF) { // avoid overflow throw css::uno::RuntimeException( - (OUString("'&#...' too large in ") + fileUrl_), + "'&#...' too large in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } } } if (position == p || *position++ != ';') { throw css::uno::RuntimeException( - (OUString("'&#...' missing ';' in ") + - fileUrl_), + "'&#...' missing ';' in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } assert(val >= 0 && val <= 0x10FFFF); @@ -464,8 +448,7 @@ char const * XmlReader::handleReference(char const * position, char const * end) (val >= 0xD800 && val <= 0xDFFF) || val == 0xFFFE || val == 0xFFFF) { throw css::uno::RuntimeException( - (OUString("character reference denoting invalid character in ") + - fileUrl_), + "character reference denoting invalid character in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } char buf[4]; @@ -521,7 +504,7 @@ char const * XmlReader::handleReference(char const * position, char const * end) } } throw css::uno::RuntimeException( - (OUString("unknown entity reference in ") + fileUrl_), + "unknown entity reference in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } } @@ -550,7 +533,7 @@ Span XmlReader::handleAttributeValue( switch (space) { case SPACE_NONE: pad_.add(begin, p - begin); - pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + pad_.add(" "); space = SPACE_BREAK; break; case SPACE_SPAN: @@ -599,7 +582,7 @@ Span XmlReader::handleAttributeValue( case '\x0A': pad_.add(begin, p - begin); begin = ++p; - pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + pad_.add(" "); break; case '\x0D': pad_.add(begin, p - begin); @@ -608,7 +591,7 @@ Span XmlReader::handleAttributeValue( ++p; } begin = p; - pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + pad_.add(" "); break; case '&': pad_.add(begin, p - begin); @@ -631,7 +614,7 @@ XmlReader::Result XmlReader::handleStartTag(int * nsId, Span * localName) { char const * nameColon = 0; if (!scanName(&nameColon)) { throw css::uno::RuntimeException( - (OUString("bad tag name in ") + fileUrl_), + "bad tag name in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } char const * nameEnd = pos_; @@ -647,49 +630,47 @@ XmlReader::Result XmlReader::handleStartTag(int * nsId, Span * localName) { } if (pos_ == p) { throw css::uno::RuntimeException( - (OUString("missing whitespace before attribute in ") + - fileUrl_), + "missing whitespace before attribute in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } char const * attrNameBegin = pos_; char const * attrNameColon = 0; if (!scanName(&attrNameColon)) { throw css::uno::RuntimeException( - (OUString("bad attribute name in ") + fileUrl_), + "bad attribute name in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } char const * attrNameEnd = pos_; skipSpace(); if (read() != '=') { throw css::uno::RuntimeException( - (OUString("missing '=' in ") + fileUrl_), + "missing '=' in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } skipSpace(); char del = read(); if (del != '\'' && del != '"') { throw css::uno::RuntimeException( - (OUString("bad attribute value in ") + fileUrl_), + "bad attribute value in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } char const * valueBegin = pos_; sal_Int32 i = rtl_str_indexOfChar_WithLength(pos_, end_ - pos_, del); if (i < 0) { throw css::uno::RuntimeException( - (OUString("unterminated attribute value in ") + fileUrl_), + "unterminated attribute value in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } char const * valueEnd = pos_ + i; pos_ += i + 1; if (attrNameColon == 0 && - Span(attrNameBegin, attrNameEnd - attrNameBegin).equals( - RTL_CONSTASCII_STRINGPARAM("xmlns"))) + Span(attrNameBegin, attrNameEnd - attrNameBegin).equals("xmlns")) { hasDefaultNs = true; defaultNsId = scanNamespaceIri(valueBegin, valueEnd); } else if (attrNameColon != 0 && Span(attrNameBegin, attrNameColon - attrNameBegin).equals( - RTL_CONSTASCII_STRINGPARAM("xmlns"))) + "xmlns")) { namespaces_.push_back( NamespaceData( @@ -714,7 +695,7 @@ XmlReader::Result XmlReader::handleStartTag(int * nsId, Span * localName) { } if (peek() != '>') { throw css::uno::RuntimeException( - (OUString("missing '>' in ") + fileUrl_), + "missing '>' in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } ++pos_; @@ -735,7 +716,7 @@ XmlReader::Result XmlReader::handleStartTag(int * nsId, Span * localName) { XmlReader::Result XmlReader::handleEndTag() { if (elements_.empty()) { throw css::uno::RuntimeException( - (OUString("spurious end tag in ") + fileUrl_), + "spurious end tag in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } char const * nameBegin = pos_; @@ -744,14 +725,14 @@ XmlReader::Result XmlReader::handleEndTag() { !elements_.top().name.equals(nameBegin, pos_ - nameBegin)) { throw css::uno::RuntimeException( - (OUString("tag mismatch in ") + fileUrl_), + "tag mismatch in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } handleElementEnd(); skipSpace(); if (peek() != '>') { throw css::uno::RuntimeException( - (OUString("missing '>' in ") + fileUrl_), + "missing '>' in " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } ++pos_; @@ -770,7 +751,7 @@ XmlReader::Result XmlReader::handleSkippedText(Span * data, int * nsId) { sal_Int32 i = rtl_str_indexOfChar_WithLength(pos_, end_ - pos_, '<'); if (i < 0) { throw css::uno::RuntimeException( - (OUString("premature end of ") + fileUrl_), + "premature end of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); } pos_ += i + 1; @@ -800,13 +781,13 @@ XmlReader::Result XmlReader::handleRawText(Span * text) { switch (peek()) { case '\0': // i.e., EOF throw css::uno::RuntimeException( - (OUString("premature end of ") + fileUrl_), + "premature end of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); case '\x0D': pad_.add(begin, pos_ - begin); ++pos_; if (peek() != '\x0A') { - pad_.add(RTL_CONSTASCII_STRINGPARAM("\x0A")); + pad_.add("\x0A"); } begin = pos_; break; @@ -866,7 +847,7 @@ XmlReader::Result XmlReader::handleNormalizedText(Span * text) { switch (peek()) { case '\0': // i.e., EOF throw css::uno::RuntimeException( - (OUString("premature end of ") + fileUrl_), + "premature end of " + fileUrl_, css::uno::Reference< css::uno::XInterface >()); case '\x09': case '\x0A': @@ -906,7 +887,7 @@ XmlReader::Result XmlReader::handleNormalizedText(Span * text) { break; case SPACE_BREAK: pad_.add(flowBegin, flowEnd - flowBegin); - pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + pad_.add(" "); break; } pos_ = handleReference(pos_, end_); @@ -936,7 +917,7 @@ XmlReader::Result XmlReader::handleNormalizedText(Span * text) { break; case SPACE_BREAK: pad_.add(flowBegin, flowEnd - flowBegin); - pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + pad_.add(" "); break; } normalizeLineEnds(cdata); @@ -976,7 +957,7 @@ XmlReader::Result XmlReader::handleNormalizedText(Span * text) { break; case SPACE_BREAK: pad_.add(flowBegin, flowEnd - flowBegin); - pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + pad_.add(" "); flowBegin = pos_; break; } -- cgit