Kaydet (Commit) df18d587 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Some string literal clean up

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