summaryrefslogtreecommitdiff
path: root/configmgr/source
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source')
-rw-r--r--configmgr/source/README3
-rw-r--r--configmgr/source/components.cxx47
-rw-r--r--configmgr/source/components.hxx5
-rw-r--r--configmgr/source/configmgr.component (renamed from configmgr/source/pad.hxx)58
-rw-r--r--configmgr/source/configurationprovider.cxx10
-rw-r--r--configmgr/source/makefile.mk15
-rw-r--r--configmgr/source/pad.cxx91
-rw-r--r--configmgr/source/parsemanager.cxx31
-rw-r--r--configmgr/source/parsemanager.hxx13
-rw-r--r--configmgr/source/parser.hxx14
-rw-r--r--configmgr/source/services.cxx48
-rw-r--r--configmgr/source/span.hxx64
-rw-r--r--configmgr/source/valueparser.cxx68
-rw-r--r--configmgr/source/valueparser.hxx14
-rw-r--r--configmgr/source/writemodfile.cxx35
-rw-r--r--configmgr/source/xcdparser.cxx44
-rw-r--r--configmgr/source/xcdparser.hxx13
-rw-r--r--configmgr/source/xcsparser.cxx167
-rw-r--r--configmgr/source/xcsparser.hxx27
-rw-r--r--configmgr/source/xcuparser.cxx205
-rw-r--r--configmgr/source/xcuparser.hxx38
-rw-r--r--configmgr/source/xmldata.cxx112
-rw-r--r--configmgr/source/xmldata.hxx14
-rw-r--r--configmgr/source/xmlreader.cxx1054
-rw-r--r--configmgr/source/xmlreader.hxx186
25 files changed, 485 insertions, 1891 deletions
diff --git a/configmgr/source/README b/configmgr/source/README
index b00990d1eeb2..f26c68ecf7c0 100644
--- a/configmgr/source/README
+++ b/configmgr/source/README
@@ -51,16 +51,13 @@ propertynode.cxx
setnode.cxx
Internal representations of data nodes.
-pad.cxx
parsemanager.cxx
parser.hxx
-span.hxx
valueparser.cxx
xcdparser.cxx
xcsparser.cxx
xcuparser.cxx
xmldata.cxx
-xmlreader.cxx
XML file reading.
modifications.cxx
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index 33b0eca3f65f..14102f56281f 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -334,12 +334,14 @@ void Components::insertModificationXcuFile(
Modifications * modifications)
{
OSL_ASSERT(modifications != 0);
+ Partial part(includedPaths, excludedPaths);
try {
- Partial part(includedPaths, excludedPaths);
- parseXcuFile(fileUri, Data::NO_LAYER, data_, &part, modifications, 0);
- } catch (css::uno::Exception & e) { //TODO: more specific exception catching
+ parseFileLeniently(
+ &parseXcuFile, fileUri, Data::NO_LAYER, data_, &part, modifications,
+ 0);
+ } catch (css::container::NoSuchElementException & e) {
OSL_TRACE(
- "configmgr error inserting %s: %s",
+ "configmgr error inserting non-existing %s: %s",
rtl::OUStringToOString(fileUri, RTL_TEXTENCODING_UTF8).getStr(),
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
}
@@ -492,20 +494,32 @@ Components::Components(
"com.sun.star.comp.deployment.configuration."
"PackageRegistryBackend/configmgr.ini"))),
true);
+ parseModificationLayer();
+ RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "end parsing");
+}
+
+Components::~Components() {}
+
+void Components::parseFileLeniently(
+ FileParser * parseFile, rtl::OUString const & url, int layer, Data & data,
+ Partial const * partial, Modifications * modifications,
+ Additions * additions)
+{
+ OSL_ASSERT(parseFile != 0);
try {
- parseModificationLayer();
+ (*parseFile)(url, layer, data, partial, modifications, additions);
+ } catch (css::container::NoSuchElementException &) {
+ throw;
} catch (css::uno::Exception & e) { //TODO: more specific exception catching
- // Silently ignore unreadable parts of a corrupted user modification
- // layer, instead of completely preventing OOo from starting:
+ // Silently ignore invalid XML files, instead of completely preventing
+ // OOo from starting:
OSL_TRACE(
- "configmgr error reading user modification layer: %s",
+ "configmgr error reading %s: %s",
+ rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr(),
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
}
- RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "end parsing");
}
-Components::~Components() {}
-
void Components::parseFiles(
int layer, rtl::OUString const & extension, FileParser * parseFile,
rtl::OUString const & url, bool recursive)
@@ -557,7 +571,8 @@ void Components::parseFiles(
file.match(extension, file.getLength() - extension.getLength()))
{
try {
- (*parseFile)(stat.getFileURL(), layer, data_, 0, 0, 0);
+ parseFileLeniently(
+ parseFile, stat.getFileURL(), layer, data_, 0, 0, 0);
} catch (css::container::NoSuchElementException & e) {
throw css::uno::RuntimeException(
(rtl::OUString(
@@ -584,7 +599,7 @@ void Components::parseFileList(
adds = data_.addExtensionXcuAdditions(url, layer);
}
try {
- (*parseFile)(url, layer, data_, 0, 0, adds);
+ parseFileLeniently(parseFile, url, layer, data_, 0, 0, adds);
} catch (css::container::NoSuchElementException & e) {
OSL_TRACE(
"configmgr file does not exist: %s",
@@ -746,13 +761,15 @@ rtl::OUString Components::getModificationFileUrl() const {
void Components::parseModificationLayer() {
try {
- parseXcuFile(getModificationFileUrl(), Data::NO_LAYER, data_, 0, 0, 0);
+ parseFileLeniently(
+ &parseXcuFile, getModificationFileUrl(), Data::NO_LAYER, data_, 0,
+ 0, 0);
} catch (css::container::NoSuchElementException &) {
OSL_TRACE(
"configmgr user registrymodifications.xcu does not (yet) exist");
// Migrate old user layer data (can be removed once migration is no
// longer relevant, probably OOo 4; also see hack for xsi namespace in
- // XmlReader constructor):
+ // xmlreader::XmlReader::registerNamespaceIri):
parseFiles(
Data::NO_LAYER, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".xcu")),
&parseXcuFile,
diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx
index 880ac95d34a8..4fc47f791821 100644
--- a/configmgr/source/components.hxx
+++ b/configmgr/source/components.hxx
@@ -123,6 +123,11 @@ private:
~Components();
+ void parseFileLeniently(
+ FileParser * parseFile, rtl::OUString const & url, int layer,
+ Data & data, Partial const * partial, Modifications * modifications,
+ Additions * additions);
+
void parseFiles(
int layer, rtl::OUString const & extension, FileParser * parseFile,
rtl::OUString const & url, bool recursive);
diff --git a/configmgr/source/pad.hxx b/configmgr/source/configmgr.component
index 66a51f480023..6ed51257005d 100644
--- a/configmgr/source/pad.hxx
+++ b/configmgr/source/configmgr.component
@@ -1,4 +1,5 @@
-/*************************************************************************
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -23,39 +24,22 @@
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
-************************************************************************/
-
-#ifndef INCLUDED_CONFIGMGR_SOURCE_PAD_HXX
-#define INCLUDED_CONFIGMGR_SOURCE_PAD_HXX
-
-#include "sal/config.h"
-
-#include "rtl/strbuf.hxx"
-#include "sal/types.h"
-
-#include "span.hxx"
-
-namespace configmgr {
-
-class Pad {
-public:
- void add(char const * begin, sal_Int32 length);
-
- void addEphemeral(char const * begin, sal_Int32 length);
-
- void clear();
-
- bool is() const;
-
- Span get() const;
-
-private:
- void flushSpan();
-
- Span span_;
- rtl::OStringBuffer buffer_;
-};
-
-}
-
-#endif
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.configuration.ConfigurationProvider">
+ <service name="com.sun.star.configuration.ConfigurationProvider"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.configuration.ConfigurationRegistry">
+ <service name="com.sun.star.configuration.ConfigurationRegistry"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.configuration.DefaultProvider">
+ <service name="com.sun.star.configuration.DefaultProvider"/>
+ <singleton name="com.sun.star.configuration.theDefaultProvider"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.configuration.Update">
+ <service name="com.sun.star.configuration.Update_Service"/>
+ <singleton name="com.sun.star.configuration.Update"/>
+ </implementation>
+</component>
diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx
index a89540a88158..78d71e73e7d5 100644
--- a/configmgr/source/configurationprovider.cxx
+++ b/configmgr/source/configurationprovider.cxx
@@ -241,7 +241,7 @@ Service::createInstanceWithArguments(
if (nodepath.getLength() == 0) {
badNodePath();
}
- // For backwards compatibility, allow a notepath that misses the leading
+ // For backwards compatibility, allow a nodepath that misses the leading
// slash:
if (nodepath[0] != '/') {
nodepath = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + nodepath;
@@ -456,7 +456,8 @@ Factory::createInstanceWithArgumentsAndContext(
" arguments")),
0);
}
- // For backwards compatibility, allow "Locale" in any case:
+ // For backwards compatibility, allow "Locale" and (ignored)
+ // "EnableAsync" in any case:
if (name.equalsIgnoreAsciiCaseAsciiL(
RTL_CONSTASCII_STRINGPARAM("locale")))
{
@@ -471,8 +472,9 @@ Factory::createInstanceWithArgumentsAndContext(
" one, non-empty, string Locale argument")),
0);
}
- } else {
- //TODO
+ } else if (!name.equalsIgnoreAsciiCaseAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("enableasync")))
+ {
throw css::uno::Exception(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
diff --git a/configmgr/source/makefile.mk b/configmgr/source/makefile.mk
index 777fed3323d8..94747d9dd803 100644
--- a/configmgr/source/makefile.mk
+++ b/configmgr/source/makefile.mk
@@ -52,7 +52,6 @@ SLOFILES = \
$(SLO)/modifications.obj \
$(SLO)/node.obj \
$(SLO)/nodemap.obj \
- $(SLO)/pad.obj \
$(SLO)/parsemanager.obj \
$(SLO)/partial.obj \
$(SLO)/propertynode.obj \
@@ -66,8 +65,7 @@ SLOFILES = \
$(SLO)/xcdparser.obj \
$(SLO)/xcsparser.obj \
$(SLO)/xcuparser.obj \
- $(SLO)/xmldata.obj \
- $(SLO)/xmlreader.obj
+ $(SLO)/xmldata.obj
SHL1IMPLIB = i$(SHL1TARGET)
SHL1OBJS = $(SLOFILES)
@@ -76,9 +74,18 @@ SHL1STDLIBS = \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALHELPERLIB) \
- $(SALLIB)
+ $(SALLIB) \
+ $(XMLREADERLIB)
SHL1TARGET = configmgr.uno
SHL1USE_EXPORTS = name
DEF1NAME = $(SHL1TARGET)
.INCLUDE: target.mk
+
+ALLTAR : $(MISC)/configmgr.component
+
+$(MISC)/configmgr.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ configmgr.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt configmgr.component
diff --git a/configmgr/source/pad.cxx b/configmgr/source/pad.cxx
deleted file mode 100644
index c8c7218b6da6..000000000000
--- a/configmgr/source/pad.cxx
+++ /dev/null
@@ -1,91 +0,0 @@
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#include "precompiled_configmgr.hxx"
-#include "sal/config.h"
-
-#include "osl/diagnose.h"
-#include "rtl/string.h"
-#include "sal/types.h"
-
-#include "pad.hxx"
-#include "span.hxx"
-
-namespace configmgr {
-
-void Pad::add(char const * begin, sal_Int32 length) {
- OSL_ASSERT(
- begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0));
- if (length != 0) {
- flushSpan();
- if (buffer_.getLength() == 0) {
- span_ = Span(begin, length);
- } else {
- buffer_.append(begin, length);
- }
- }
-}
-
-void Pad::addEphemeral(char const * begin, sal_Int32 length) {
- OSL_ASSERT(
- begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0));
- if (length != 0) {
- flushSpan();
- buffer_.append(begin, length);
- }
-}
-
-void Pad::clear() {
- OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0));
- span_.clear();
- buffer_.setLength(0);
-}
-
-bool Pad::is() const {
- OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0));
- return span_.is() || buffer_.getLength() != 0;
-}
-
-Span Pad::get() const {
- OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0));
- if (span_.is()) {
- return span_;
- } else if (buffer_.getLength() == 0) {
- return Span(RTL_CONSTASCII_STRINGPARAM(""));
- } else {
- return Span(buffer_.getStr(), buffer_.getLength());
- }
-}
-
-void Pad::flushSpan() {
- if (span_.is()) {
- buffer_.append(span_.begin, span_.length);
- span_.clear();
- }
-}
-
-}
diff --git a/configmgr/source/parsemanager.cxx b/configmgr/source/parsemanager.cxx
index 69a5515b977c..c17eddd2976f 100644
--- a/configmgr/source/parsemanager.cxx
+++ b/configmgr/source/parsemanager.cxx
@@ -32,10 +32,11 @@
#include "com/sun/star/uno/RuntimeException.hpp"
#include "osl/diagnose.h"
#include "sal/types.h"
+#include "xmlreader/span.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "parsemanager.hxx"
#include "parser.hxx"
-#include "xmlreader.hxx"
namespace configmgr {
@@ -52,28 +53,42 @@ ParseManager::ParseManager(
reader_(url), parser_(parser)
{
OSL_ASSERT(parser.is());
+ int id;
+ id = reader_.registerNamespaceIri(
+ xmlreader::Span(
+ RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry")));
+ OSL_ASSERT(id == NAMESPACE_OOR);
+ id = reader_.registerNamespaceIri(
+ xmlreader::Span(
+ RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema")));
+ OSL_ASSERT(id == NAMESPACE_XS);
+ id = reader_.registerNamespaceIri(
+ xmlreader::Span(
+ RTL_CONSTASCII_STRINGPARAM(
+ "http://www.w3.org/2001/XMLSchema-instance")));
+ OSL_ASSERT(id == NAMESPACE_XSI);
}
bool ParseManager::parse() {
for (;;) {
switch (itemData_.is()
- ? XmlReader::RESULT_BEGIN
+ ? xmlreader::XmlReader::RESULT_BEGIN
: reader_.nextItem(
- parser_->getTextMode(), &itemData_, &itemNamespace_))
+ parser_->getTextMode(), &itemData_, &itemNamespaceId_))
{
- case XmlReader::RESULT_BEGIN:
- if (!parser_->startElement(reader_, itemNamespace_, itemData_))
+ case xmlreader::XmlReader::RESULT_BEGIN:
+ if (!parser_->startElement(reader_, itemNamespaceId_, itemData_))
{
return false;
}
break;
- case XmlReader::RESULT_END:
+ case xmlreader::XmlReader::RESULT_END:
parser_->endElement(reader_);
break;
- case XmlReader::RESULT_TEXT:
+ case xmlreader::XmlReader::RESULT_TEXT:
parser_->characters(itemData_);
break;
- case XmlReader::RESULT_DONE:
+ case xmlreader::XmlReader::RESULT_DONE:
return true;
}
itemData_.clear();
diff --git a/configmgr/source/parsemanager.hxx b/configmgr/source/parsemanager.hxx
index 18292859ab98..19d16c74621a 100644
--- a/configmgr/source/parsemanager.hxx
+++ b/configmgr/source/parsemanager.hxx
@@ -35,9 +35,8 @@
#include "rtl/ref.hxx"
#include "sal/types.h"
#include "salhelper/simplereferenceobject.hxx"
-
-#include "span.hxx"
-#include "xmlreader.hxx"
+#include "xmlreader/span.hxx"
+#include "xmlreader/xmlreader.hxx"
namespace rtl { class OUString; }
@@ -55,13 +54,15 @@ public:
bool parse();
+ enum { NAMESPACE_OOR = 1, NAMESPACE_XS = 2, NAMESPACE_XSI = 3 };
+
private:
virtual ~ParseManager();
- XmlReader reader_;
+ xmlreader::XmlReader reader_;
rtl::Reference< Parser > parser_;
- Span itemData_;
- XmlReader::Namespace itemNamespace_;
+ xmlreader::Span itemData_;
+ int itemNamespaceId_;
};
}
diff --git a/configmgr/source/parser.hxx b/configmgr/source/parser.hxx
index da29941953b5..f782e0dbc151 100644
--- a/configmgr/source/parser.hxx
+++ b/configmgr/source/parser.hxx
@@ -33,23 +33,23 @@
#include <memory>
#include "salhelper/simplereferenceobject.hxx"
+#include "xmlreader/xmlreader.hxx"
-#include "xmlreader.hxx"
+namespace xmlreader { struct Span; }
namespace configmgr {
-struct Span;
-
class Parser: public salhelper::SimpleReferenceObject {
public:
- virtual XmlReader::Text getTextMode() = 0;
+ virtual xmlreader::XmlReader::Text getTextMode() = 0;
virtual bool startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name) = 0;
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name)
+ = 0;
- virtual void endElement(XmlReader const & reader) = 0;
+ virtual void endElement(xmlreader::XmlReader const & reader) = 0;
- virtual void characters(Span const & text) = 0;
+ virtual void characters(xmlreader::Span const & text) = 0;
protected:
Parser() {}
diff --git a/configmgr/source/services.cxx b/configmgr/source/services.cxx
index f8c3289664ef..b1ef8d2169bb 100644
--- a/configmgr/source/services.cxx
+++ b/configmgr/source/services.cxx
@@ -28,7 +28,6 @@
#include "precompiled_configmgr.hxx"
#include "sal/config.h"
-#include "com/sun/star/registry/XRegistryKey.hpp"
#include "com/sun/star/uno/Exception.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
@@ -36,9 +35,6 @@
#include "cppuhelper/implementationentry.hxx"
#include "osl/diagnose.h"
#include "uno/lbnames.h"
-#include "rtl/textenc.h"
-#include "rtl/ustring.h"
-#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "configurationprovider.hxx"
@@ -89,47 +85,3 @@ component_getImplementationEnvironment(
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
-
-extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
- void * pServiceManager, void * pRegistryKey)
-{
- if (!component_writeInfoHelper(pServiceManager, pRegistryKey, services)) {
- return false;
- }
- try {
- css::uno::Reference< css::registry::XRegistryKey >(
- (css::uno::Reference< css::registry::XRegistryKey >(
- static_cast< css::registry::XRegistryKey * >(pRegistryKey))->
- createKey(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "/com.sun.star.comp.configuration.DefaultProvider/UNO/"
- "SINGLETONS/"
- "com.sun.star.configuration.theDefaultProvider")))),
- css::uno::UNO_SET_THROW)->
- setStringValue(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.configuration.DefaultProvider")));
- css::uno::Reference< css::registry::XRegistryKey >(
- (css::uno::Reference< css::registry::XRegistryKey >(
- static_cast< css::registry::XRegistryKey * >(pRegistryKey))->
- createKey(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "/com.sun.star.comp.configuration.Update/UNO/"
- "SINGLETONS/com.sun.star.configuration.Update")))),
- css::uno::UNO_SET_THROW)->
- setStringValue(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.configuration.Update_Service")));
- } catch (css::uno::Exception & e) {
- (void) e;
- OSL_TRACE(
- "configmgr component_writeInfo exception: %s",
- rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
- return false;
- }
- return true;
-}
diff --git a/configmgr/source/span.hxx b/configmgr/source/span.hxx
deleted file mode 100644
index 689618613700..000000000000
--- a/configmgr/source/span.hxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#ifndef INCLUDED_CONFIGMGR_SOURCE_SPAN_HXX
-#define INCLUDED_CONFIGMGR_SOURCE_SPAN_HXX
-
-#include "sal/config.h"
-
-#include "rtl/string.h"
-#include "sal/types.h"
-
-namespace configmgr {
-
-struct Span {
- char const * begin;
- sal_Int32 length;
-
- inline Span(): begin(0), length(0) {}
- // init length to avoid compiler warnings
-
- inline Span(char const * theBegin, sal_Int32 theLength):
- begin(theBegin), length(theLength) {}
-
- inline void clear() throw() { begin = 0; }
-
- inline bool is() const { return begin != 0; }
-
- inline bool equals(Span const & text) const {
- return rtl_str_compare_WithLength(
- begin, length, text.begin, text.length) == 0;
- }
-
- inline bool equals(char const * textBegin, sal_Int32 textLength) const {
- return equals(Span(textBegin, textLength));
- }
-};
-
-}
-
-#endif
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index 4adf452c409b..0be173f74919 100644
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -40,16 +40,17 @@
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+#include "xmlreader/span.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "localizedvaluenode.hxx"
#include "node.hxx"
#include "nodemap.hxx"
+#include "parsemanager.hxx"
#include "propertynode.hxx"
-#include "span.hxx"
#include "type.hxx"
#include "valueparser.hxx"
#include "xmldata.hxx"
-#include "xmlreader.hxx"
namespace configmgr {
@@ -74,7 +75,7 @@ bool parseHexDigit(char c, int * value) {
return false;
}
-bool parseValue(Span const & text, sal_Bool * value) {
+bool parseValue(xmlreader::Span const & text, sal_Bool * value) {
OSL_ASSERT(text.is() && value != 0);
if (text.equals(RTL_CONSTASCII_STRINGPARAM("true")) ||
text.equals(RTL_CONSTASCII_STRINGPARAM("1")))
@@ -91,7 +92,7 @@ bool parseValue(Span const & text, sal_Bool * value) {
return false;
}
-bool parseValue(Span const & text, sal_Int16 * value) {
+bool parseValue(xmlreader::Span const & text, sal_Int16 * value) {
OSL_ASSERT(text.is() && value != 0);
// For backwards compatibility, support hexadecimal values:
sal_Int32 n =
@@ -110,7 +111,7 @@ bool parseValue(Span const & text, sal_Int16 * value) {
return false;
}
-bool parseValue(Span const & text, sal_Int32 * value) {
+bool parseValue(xmlreader::Span const & text, sal_Int32 * value) {
OSL_ASSERT(text.is() && value != 0);
// For backwards compatibility, support hexadecimal values:
*value =
@@ -125,7 +126,7 @@ bool parseValue(Span const & text, sal_Int32 * value) {
return true;
}
-bool parseValue(Span const & text, sal_Int64 * value) {
+bool parseValue(xmlreader::Span const & text, sal_Int64 * value) {
OSL_ASSERT(text.is() && value != 0);
// For backwards compatibility, support hexadecimal values:
*value =
@@ -140,20 +141,22 @@ bool parseValue(Span const & text, sal_Int64 * value) {
return true;
}
-bool parseValue(Span const & text, double * value) {
+bool parseValue(xmlreader::Span const & text, double * value) {
OSL_ASSERT(text.is() && value != 0);
*value = rtl::OString(text.begin, text.length).toDouble();
//TODO: check valid lexical representation
return true;
}
-bool parseValue(Span const & text, rtl::OUString * value) {
+bool parseValue(xmlreader::Span const & text, rtl::OUString * value) {
OSL_ASSERT(text.is() && value != 0);
- *value = xmldata::convertFromUtf8(text);
+ *value = text.convertFromUtf8();
return true;
}
-bool parseValue(Span const & text, css::uno::Sequence< sal_Int8 > * value) {
+bool parseValue(
+ xmlreader::Span const & text, css::uno::Sequence< sal_Int8 > * value)
+{
OSL_ASSERT(text.is() && value != 0);
if ((text.length & 1) != 0) {
return false;
@@ -173,7 +176,9 @@ bool parseValue(Span const & text, css::uno::Sequence< sal_Int8 > * value) {
return true;
}
-template< typename T > css::uno::Any parseSingleValue(Span const & text) {
+template< typename T > css::uno::Any parseSingleValue(
+ xmlreader::Span const & text)
+{
T val;
if (!parseValue(text, &val)) {
throw css::uno::RuntimeException(
@@ -184,21 +189,23 @@ template< typename T > css::uno::Any parseSingleValue(Span const & text) {
}
template< typename T > css::uno::Any parseListValue(
- rtl::OString const & separator, Span const & text)
+ rtl::OString const & separator, xmlreader::Span const & text)
{
comphelper::SequenceAsVector< T > seq;
- Span sep;
+ xmlreader::Span sep;
if (separator.getLength() == 0) {
- sep = Span(RTL_CONSTASCII_STRINGPARAM(" "));
+ sep = xmlreader::Span(RTL_CONSTASCII_STRINGPARAM(" "));
} else {
- sep = Span(separator.getStr(), separator.getLength());
+ sep = xmlreader::Span(separator.getStr(), separator.getLength());
}
if (text.length != 0) {
- for (Span t(text);;) {
+ for (xmlreader::Span t(text);;) {
sal_Int32 i = rtl_str_indexOfStr_WithLength(
t.begin, t.length, sep.begin, sep.length);
T val;
- if (!parseValue(Span(t.begin, i == -1 ? t.length : i), &val)) {
+ if (!parseValue(
+ xmlreader::Span(t.begin, i == -1 ? t.length : i), &val))
+ {
throw css::uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid value")),
css::uno::Reference< css::uno::XInterface >());
@@ -215,7 +222,7 @@ template< typename T > css::uno::Any parseListValue(
}
css::uno::Any parseValue(
- rtl::OString const & separator, Span const & text, Type type)
+ rtl::OString const & separator, xmlreader::Span const & text, Type type)
{
switch (type) {
case TYPE_ANY:
@@ -266,7 +273,7 @@ ValueParser::ValueParser(int layer): layer_(layer) {}
ValueParser::~ValueParser() {}
-XmlReader::Text ValueParser::getTextMode() const {
+xmlreader::XmlReader::Text ValueParser::getTextMode() const {
if (node_.is()) {
switch (state_) {
case STATE_TEXT:
@@ -278,23 +285,24 @@ XmlReader::Text ValueParser::getTextMode() const {
return
(type_ == TYPE_STRING || type_ == TYPE_STRING_LIST ||
separator_.getLength() != 0)
- ? XmlReader::TEXT_RAW : XmlReader::TEXT_NORMALIZED;
+ ? xmlreader::XmlReader::TEXT_RAW
+ : xmlreader::XmlReader::TEXT_NORMALIZED;
default:
break;
}
}
- return XmlReader::TEXT_NONE;
+ return xmlreader::XmlReader::TEXT_NONE;
}
bool ValueParser::startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name)
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name)
{
if (!node_.is()) {
return false;
}
switch (state_) {
case STATE_TEXT:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("it")) &&
isListType(type_) && separator_.getLength() == 0)
{
@@ -306,18 +314,18 @@ bool ValueParser::startElement(
}
// fall through
case STATE_IT:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("unicode")) &&
(type_ == TYPE_STRING || type_ == TYPE_STRING_LIST))
{
sal_Int32 scalar = -1;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("scalar")))
{
if (!parseValue(reader.getAttributeValue(true), &scalar)) {
@@ -352,7 +360,7 @@ bool ValueParser::startElement(
}
throw css::uno::RuntimeException(
(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) + reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
@@ -439,7 +447,7 @@ bool ValueParser::endElement() {
return true;
}
-void ValueParser::characters(Span const & text) {
+void ValueParser::characters(xmlreader::Span const & text) {
if (node_.is()) {
OSL_ASSERT(state_ == STATE_TEXT || state_ == STATE_IT);
pad_.add(text.begin, text.length);
diff --git a/configmgr/source/valueparser.hxx b/configmgr/source/valueparser.hxx
index 4e899f4632dd..c5e1d0a0a45f 100644
--- a/configmgr/source/valueparser.hxx
+++ b/configmgr/source/valueparser.hxx
@@ -36,19 +36,19 @@
#include "rtl/ref.hxx"
#include "rtl/string.hxx"
#include "rtl/ustring.hxx"
+#include "xmlreader/pad.hxx"
+#include "xmlreader/xmlreader.hxx"
-#include "pad.hxx"
#include "type.hxx"
-#include "xmlreader.hxx"
namespace com { namespace sun { namespace star { namespace uno {
class Any;
} } } }
+namespace xmlreader { struct Span; }
namespace configmgr {
class Node;
-struct Span;
class ValueParser: private boost::noncopyable {
public:
@@ -56,14 +56,14 @@ public:
~ValueParser();
- XmlReader::Text getTextMode() const;
+ xmlreader::XmlReader::Text getTextMode() const;
bool startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name);
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
bool endElement();
- void characters(Span const & text);
+ void characters(xmlreader::Span const & text);
void start(
rtl::Reference< Node > const & property,
@@ -83,7 +83,7 @@ private:
rtl::Reference< Node > node_;
rtl::OUString localizedName_;
State state_;
- Pad pad_;
+ xmlreader::Pad pad_;
std::vector< com::sun::star::uno::Any > items_;
};
diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx
index c2573ab67439..5616833abf3d 100644
--- a/configmgr/source/writemodfile.cxx
+++ b/configmgr/source/writemodfile.cxx
@@ -45,6 +45,7 @@
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+#include "xmlreader/span.hxx"
#include "data.hxx"
#include "groupnode.hxx"
@@ -54,7 +55,6 @@
#include "node.hxx"
#include "nodemap.hxx"
#include "propertynode.hxx"
-#include "span.hxx"
#include "type.hxx"
#include "writemodfile.hxx"
@@ -341,22 +341,23 @@ void writeNode(
rtl::Reference< Node > const & parent, rtl::OUString const & name,
rtl::Reference< Node > const & node)
{
- static Span const typeNames[] = {
- Span(), Span(), Span(), // TYPE_ERROR, TYPE_NIL, TYPE_ANY
- Span(RTL_CONSTASCII_STRINGPARAM("xs:boolean")),
- Span(RTL_CONSTASCII_STRINGPARAM("xs:short")),
- Span(RTL_CONSTASCII_STRINGPARAM("xs:int")),
- Span(RTL_CONSTASCII_STRINGPARAM("xs:long")),
- Span(RTL_CONSTASCII_STRINGPARAM("xs:double")),
- Span(RTL_CONSTASCII_STRINGPARAM("xs:string")),
- Span(RTL_CONSTASCII_STRINGPARAM("xs:hexBinary")),
- Span(RTL_CONSTASCII_STRINGPARAM("oor:boolean-list")),
- Span(RTL_CONSTASCII_STRINGPARAM("oor:short-list")),
- Span(RTL_CONSTASCII_STRINGPARAM("oor:int-list")),
- Span(RTL_CONSTASCII_STRINGPARAM("oor:long-list")),
- Span(RTL_CONSTASCII_STRINGPARAM("oor:double-list")),
- Span(RTL_CONSTASCII_STRINGPARAM("oor:string-list")),
- Span(RTL_CONSTASCII_STRINGPARAM("oor:hexBinary-list")) };
+ static xmlreader::Span const typeNames[] = {
+ xmlreader::Span(), xmlreader::Span(), xmlreader::Span(),
+ // TYPE_ERROR, TYPE_NIL, TYPE_ANY
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("xs:boolean")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("xs:short")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("xs:int")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("xs:long")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("xs:double")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("xs:string")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("xs:hexBinary")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("oor:boolean-list")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("oor:short-list")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("oor:int-list")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("oor:long-list")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("oor:double-list")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("oor:string-list")),
+ xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("oor:hexBinary-list")) };
switch (node->kind()) {
case Node::KIND_PROPERTY:
{
diff --git a/configmgr/source/xcdparser.cxx b/configmgr/source/xcdparser.cxx
index ad774d5ca3e3..a7b66fe60157 100644
--- a/configmgr/source/xcdparser.cxx
+++ b/configmgr/source/xcdparser.cxx
@@ -37,13 +37,14 @@
#include "rtl/string.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
+#include "xmlreader/span.hxx"
+#include "xmlreader/xmlreader.hxx"
-#include "span.hxx"
+#include "parsemanager.hxx"
#include "xcdparser.hxx"
#include "xcsparser.hxx"
#include "xcuparser.hxx"
#include "xmldata.hxx"
-#include "xmlreader.hxx"
namespace configmgr {
@@ -59,22 +60,22 @@ XcdParser::XcdParser(int layer, Dependencies const & dependencies, Data & data):
XcdParser::~XcdParser() {}
-XmlReader::Text XcdParser::getTextMode() {
+xmlreader::XmlReader::Text XcdParser::getTextMode() {
return nestedParser_.is()
- ? nestedParser_->getTextMode() : XmlReader::TEXT_NONE;
+ ? nestedParser_->getTextMode() : xmlreader::XmlReader::TEXT_NONE;
}
bool XcdParser::startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name)
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name)
{
if (nestedParser_.is()) {
OSL_ASSERT(nesting_ != LONG_MAX);
++nesting_;
- return nestedParser_->startElement(reader, ns, name);
+ return nestedParser_->startElement(reader, nsId, name);
}
switch (state_) {
case STATE_START:
- if (ns == XmlReader::NAMESPACE_OOR &&
+ if (nsId == ParseManager::NAMESPACE_OOR &&
name.equals(RTL_CONSTASCII_STRINGPARAM("data")))
{
state_ = STATE_DEPENDENCIES;
@@ -82,18 +83,19 @@ bool XcdParser::startElement(
}
break;
case STATE_DEPENDENCIES:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("dependency")))
{
if (dependency_.getLength() == 0) {
- Span attrFile;
+ xmlreader::Span attrFile;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_NONE && //TODO: _OOR
+ if (attrNsId == xmlreader::XmlReader::NAMESPACE_NONE &&
+ //TODO: _OOR
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("file")))
{
attrFile = reader.getAttributeValue(false);
@@ -107,7 +109,7 @@ bool XcdParser::startElement(
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
- dependency_ = xmldata::convertFromUtf8(attrFile);
+ dependency_ = attrFile.convertFromUtf8();
if (dependency_.getLength() == 0) {
throw css::uno::RuntimeException(
(rtl::OUString(
@@ -127,19 +129,19 @@ bool XcdParser::startElement(
state_ = STATE_COMPONENTS;
// fall through
case STATE_COMPONENTS:
- if (ns == XmlReader::NAMESPACE_OOR &&
+ if (nsId == ParseManager::NAMESPACE_OOR &&
name.equals(RTL_CONSTASCII_STRINGPARAM("component-schema")))
{
nestedParser_ = new XcsParser(layer_, data_);
nesting_ = 1;
- return nestedParser_->startElement(reader, ns, name);
+ return nestedParser_->startElement(reader, nsId, name);
}
- if (ns == XmlReader::NAMESPACE_OOR &&
+ if (nsId == ParseManager::NAMESPACE_OOR &&
name.equals(RTL_CONSTASCII_STRINGPARAM("component-data")))
{
nestedParser_ = new XcuParser(layer_ + 1, data_, 0, 0, 0);
nesting_ = 1;
- return nestedParser_->startElement(reader, ns, name);
+ return nestedParser_->startElement(reader, nsId, name);
}
break;
default: // STATE_DEPENDENCY
@@ -148,12 +150,12 @@ bool XcdParser::startElement(
}
throw css::uno::RuntimeException(
(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) + reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
-void XcdParser::endElement(XmlReader const & reader) {
+void XcdParser::endElement(xmlreader::XmlReader const & reader) {
if (nestedParser_.is()) {
nestedParser_->endElement(reader);
if (--nesting_ == 0) {
@@ -174,7 +176,7 @@ void XcdParser::endElement(XmlReader const & reader) {
}
}
-void XcdParser::characters(Span const & text) {
+void XcdParser::characters(xmlreader::Span const & text) {
if (nestedParser_.is()) {
nestedParser_->characters(text);
}
diff --git a/configmgr/source/xcdparser.hxx b/configmgr/source/xcdparser.hxx
index 2ad8ecea7f93..a807e011b244 100644
--- a/configmgr/source/xcdparser.hxx
+++ b/configmgr/source/xcdparser.hxx
@@ -34,14 +34,15 @@
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "parser.hxx"
-#include "xmlreader.hxx"
+
+namespace xmlreader { struct Span; }
namespace configmgr {
struct Data;
-struct Span;
class XcdParser: public Parser {
public:
@@ -52,14 +53,14 @@ public:
private:
virtual ~XcdParser();
- virtual XmlReader::Text getTextMode();
+ virtual xmlreader::XmlReader::Text getTextMode();
virtual bool startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name);
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
- virtual void endElement(XmlReader const & reader);
+ virtual void endElement(xmlreader::XmlReader const & reader);
- virtual void characters(Span const & text);
+ virtual void characters(xmlreader::Span const & text);
enum State {
STATE_START, STATE_DEPENDENCIES, STATE_DEPENDENCY, STATE_COMPONENTS };
diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx
index 37b46494c6a7..1deb8e9f3029 100644
--- a/configmgr/source/xcsparser.cxx
+++ b/configmgr/source/xcsparser.cxx
@@ -41,18 +41,19 @@
#include "rtl/string.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
+#include "xmlreader/span.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "data.hxx"
#include "localizedpropertynode.hxx"
#include "groupnode.hxx"
#include "node.hxx"
#include "nodemap.hxx"
+#include "parsemanager.hxx"
#include "propertynode.hxx"
#include "setnode.hxx"
-#include "span.hxx"
#include "xcsparser.hxx"
#include "xmldata.hxx"
-#include "xmlreader.hxx"
namespace configmgr {
@@ -125,18 +126,18 @@ XcsParser::XcsParser(int layer, Data & data):
XcsParser::~XcsParser() {}
-XmlReader::Text XcsParser::getTextMode() {
+xmlreader::XmlReader::Text XcsParser::getTextMode() {
return valueParser_.getTextMode();
}
bool XcsParser::startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name)
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name)
{
- if (valueParser_.startElement(reader, ns, name)) {
+ if (valueParser_.startElement(reader, nsId, name)) {
return true;
}
if (state_ == STATE_START) {
- if (ns == XmlReader::NAMESPACE_OOR &&
+ if (nsId == ParseManager::NAMESPACE_OOR &&
name.equals(RTL_CONSTASCII_STRINGPARAM("component-schema"))) {
handleComponentSchema(reader);
state_ = STATE_COMPONENT_SCHEMA;
@@ -148,7 +149,7 @@ bool XcsParser::startElement(
// prop constraints; accepting all four at illegal places (and with
// illegal content):
if (ignoring_ > 0 ||
- (ns == XmlReader::NAMESPACE_NONE &&
+ (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
(name.equals(RTL_CONSTASCII_STRINGPARAM("info")) ||
name.equals(RTL_CONSTASCII_STRINGPARAM("import")) ||
name.equals(RTL_CONSTASCII_STRINGPARAM("uses")) ||
@@ -160,7 +161,7 @@ bool XcsParser::startElement(
}
switch (state_) {
case STATE_COMPONENT_SCHEMA:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("templates")))
{
state_ = STATE_TEMPLATES;
@@ -168,7 +169,7 @@ bool XcsParser::startElement(
}
// fall through
case STATE_TEMPLATES_DONE:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("component")))
{
state_ = STATE_COMPONENT;
@@ -183,13 +184,13 @@ bool XcsParser::startElement(
break;
case STATE_TEMPLATES:
if (elements_.empty()) {
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("group")))
{
handleGroup(reader, true);
return true;
}
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("set")))
{
handleSet(reader, true);
@@ -203,7 +204,7 @@ bool XcsParser::startElement(
switch (elements_.top().node->kind()) {
case Node::KIND_PROPERTY:
case Node::KIND_LOCALIZED_PROPERTY:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("value")))
{
handlePropValue(reader, elements_.top().node);
@@ -211,25 +212,25 @@ bool XcsParser::startElement(
}
break;
case Node::KIND_GROUP:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("prop")))
{
handleProp(reader);
return true;
}
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("node-ref")))
{
handleNodeRef(reader);
return true;
}
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("group")))
{
handleGroup(reader, false);
return true;
}
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("set")))
{
handleSet(reader, false);
@@ -237,7 +238,7 @@ bool XcsParser::startElement(
}
break;
case Node::KIND_SET:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("item")))
{
handleSetItem(
@@ -260,12 +261,12 @@ bool XcsParser::startElement(
}
throw css::uno::RuntimeException(
(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) + reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
-void XcsParser::endElement(XmlReader const & reader) {
+void XcsParser::endElement(xmlreader::XmlReader const & reader) {
if (valueParser_.endElement()) {
return;
}
@@ -342,23 +343,23 @@ void XcsParser::endElement(XmlReader const & reader) {
}
}
-void XcsParser::characters(Span const & text) {
+void XcsParser::characters(xmlreader::Span const & text) {
valueParser_.characters(text);
}
-void XcsParser::handleComponentSchema(XmlReader & reader) {
+void XcsParser::handleComponentSchema(xmlreader::XmlReader & reader) {
//TODO: oor:version, xml:lang attributes
rtl::OStringBuffer buf;
buf.append('.');
bool hasPackage = false;
bool hasName = false;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("package")))
{
if (hasPackage) {
@@ -371,9 +372,9 @@ void XcsParser::handleComponentSchema(XmlReader & reader) {
css::uno::Reference< css::uno::XInterface >());
}
hasPackage = true;
- Span s(reader.getAttributeValue(false));
+ xmlreader::Span s(reader.getAttributeValue(false));
buf.insert(0, s.begin, s.length);
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
if (hasName) {
@@ -385,7 +386,7 @@ void XcsParser::handleComponentSchema(XmlReader & reader) {
css::uno::Reference< css::uno::XInterface >());
}
hasName = true;
- Span s(reader.getAttributeValue(false));
+ xmlreader::Span s(reader.getAttributeValue(false));
buf.append(s.begin, s.length);
}
}
@@ -405,38 +406,36 @@ void XcsParser::handleComponentSchema(XmlReader & reader) {
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
- componentName_ = xmldata::convertFromUtf8(
- Span(buf.getStr(), buf.getLength()));
+ componentName_ = xmlreader::Span(buf.getStr(), buf.getLength()).
+ convertFromUtf8();
}
-void XcsParser::handleNodeRef(XmlReader & reader) {
+void XcsParser::handleNodeRef(xmlreader::XmlReader & reader) {
bool hasName = false;
rtl::OUString name;
rtl::OUString component(componentName_);
bool hasNodeType = false;
rtl::OUString nodeType;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
hasName = true;
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component")))
{
- component = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ component = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type")))
{
hasNodeType = true;
- nodeType = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
+ nodeType = reader.getAttributeValue(false).convertFromUtf8();
}
}
if (!hasName) {
@@ -465,33 +464,33 @@ void XcsParser::handleNodeRef(XmlReader & reader) {
elements_.push(Element(node, name));
}
-void XcsParser::handleProp(XmlReader & reader) {
+void XcsParser::handleProp(xmlreader::XmlReader & reader) {
bool hasName = false;
rtl::OUString name;
valueParser_.type_ = TYPE_ERROR;
bool localized = false;
bool nillable = true;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
hasName = true;
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type")))
{
valueParser_.type_ = xmldata::parseType(
reader, reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("localized")))
{
localized = xmldata::parseBoolean(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("nillable")))
{
nillable = xmldata::parseBoolean(reader.getAttributeValue(true));
@@ -525,16 +524,16 @@ void XcsParser::handleProp(XmlReader & reader) {
}
void XcsParser::handlePropValue(
- XmlReader & reader, rtl::Reference< Node > const & property)
+ xmlreader::XmlReader & reader, rtl::Reference< Node > const & property)
{
- Span attrSeparator;
+ xmlreader::Span attrSeparator;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("separator")))
{
attrSeparator = reader.getAttributeValue(false);
@@ -553,22 +552,22 @@ void XcsParser::handlePropValue(
valueParser_.start(property);
}
-void XcsParser::handleGroup(XmlReader & reader, bool isTemplate) {
+void XcsParser::handleGroup(xmlreader::XmlReader & reader, bool isTemplate) {
bool hasName = false;
rtl::OUString name;
bool extensible = false;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
hasName = true;
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("extensible")))
{
extensible = xmldata::parseBoolean(reader.getAttributeValue(true));
@@ -592,34 +591,32 @@ void XcsParser::handleGroup(XmlReader & reader, bool isTemplate) {
name));
}
-void XcsParser::handleSet(XmlReader & reader, bool isTemplate) {
+void XcsParser::handleSet(xmlreader::XmlReader & reader, bool isTemplate) {
bool hasName = false;
rtl::OUString name;
rtl::OUString component(componentName_);
bool hasNodeType = false;
rtl::OUString nodeType;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
hasName = true;
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component")))
{
- component = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ component = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type")))
{
hasNodeType = true;
- nodeType = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
+ nodeType = reader.getAttributeValue(false).convertFromUtf8();
}
}
if (!hasName) {
@@ -642,27 +639,25 @@ void XcsParser::handleSet(XmlReader & reader, bool isTemplate) {
name));
}
-void XcsParser::handleSetItem(XmlReader & reader, SetNode * set) {
+void XcsParser::handleSetItem(xmlreader::XmlReader & reader, SetNode * set) {
rtl::OUString component(componentName_);
bool hasNodeType = false;
rtl::OUString nodeType;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component")))
{
- component = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ component = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type")))
{
hasNodeType = true;
- nodeType = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
+ nodeType = reader.getAttributeValue(false).convertFromUtf8();
}
}
set->getAdditionalTemplateNames().push_back(
diff --git a/configmgr/source/xcsparser.hxx b/configmgr/source/xcsparser.hxx
index 196add9a826a..1fac315c0783 100644
--- a/configmgr/source/xcsparser.hxx
+++ b/configmgr/source/xcsparser.hxx
@@ -34,17 +34,18 @@
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "node.hxx"
#include "parser.hxx"
#include "valueparser.hxx"
-#include "xmlreader.hxx"
+
+namespace xmlreader { struct Span; }
namespace configmgr {
class SetNode;
struct Data;
-struct Span;
class XcsParser: public Parser {
public:
@@ -53,29 +54,29 @@ public:
private:
virtual ~XcsParser();
- virtual XmlReader::Text getTextMode();
+ virtual xmlreader::XmlReader::Text getTextMode();
virtual bool startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name);
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
- virtual void endElement(XmlReader const & reader);
+ virtual void endElement(xmlreader::XmlReader const & reader);
- virtual void characters(Span const & text);
+ virtual void characters(xmlreader::Span const & text);
- void handleComponentSchema(XmlReader & reader);
+ void handleComponentSchema(xmlreader::XmlReader & reader);
- void handleNodeRef(XmlReader & reader);
+ void handleNodeRef(xmlreader::XmlReader & reader);
- void handleProp(XmlReader & reader);
+ void handleProp(xmlreader::XmlReader & reader);
void handlePropValue(
- XmlReader & reader, rtl::Reference< Node > const & property);
+ xmlreader::XmlReader & reader, rtl::Reference< Node > const & property);
- void handleGroup(XmlReader & reader, bool isTemplate);
+ void handleGroup(xmlreader::XmlReader & reader, bool isTemplate);
- void handleSet(XmlReader & reader, bool isTemplate);
+ void handleSet(xmlreader::XmlReader & reader, bool isTemplate);
- void handleSetItem(XmlReader & reader, SetNode * set);
+ void handleSetItem(xmlreader::XmlReader & reader, SetNode * set);
enum State {
STATE_START, STATE_COMPONENT_SCHEMA, STATE_TEMPLATES,
diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx
index 91f3b244c5a8..1a9575bb6726 100644
--- a/configmgr/source/xcuparser.cxx
+++ b/configmgr/source/xcuparser.cxx
@@ -41,6 +41,8 @@
#include "rtl/string.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
+#include "xmlreader/span.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "data.hxx"
#include "localizedpropertynode.hxx"
@@ -49,14 +51,13 @@
#include "modifications.hxx"
#include "node.hxx"
#include "nodemap.hxx"
+#include "parsemanager.hxx"
#include "partial.hxx"
#include "path.hxx"
#include "propertynode.hxx"
#include "setnode.hxx"
-#include "span.hxx"
#include "xcuparser.hxx"
#include "xmldata.hxx"
-#include "xmlreader.hxx"
namespace configmgr {
@@ -79,22 +80,22 @@ XcuParser::XcuParser(
XcuParser::~XcuParser() {}
-XmlReader::Text XcuParser::getTextMode() {
+xmlreader::XmlReader::Text XcuParser::getTextMode() {
return valueParser_.getTextMode();
}
bool XcuParser::startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name)
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name)
{
- if (valueParser_.startElement(reader, ns, name)) {
+ if (valueParser_.startElement(reader, nsId, name)) {
return true;
}
if (state_.empty()) {
- if (ns == XmlReader::NAMESPACE_OOR &&
+ if (nsId == ParseManager::NAMESPACE_OOR &&
name.equals(RTL_CONSTASCII_STRINGPARAM("component-data")))
{
handleComponentData(reader);
- } else if (ns == XmlReader::NAMESPACE_OOR &&
+ } else if (nsId == ParseManager::NAMESPACE_OOR &&
name.equals(RTL_CONSTASCII_STRINGPARAM("items")))
{
state_.push(State(rtl::Reference< Node >(), false));
@@ -102,7 +103,7 @@ bool XcuParser::startElement(
throw css::uno::RuntimeException(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("bad root element <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) +
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
@@ -110,7 +111,7 @@ bool XcuParser::startElement(
} else if (state_.top().ignore) {
state_.push(State(false));
} else if (!state_.top().node.is()) {
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("item")))
{
handleItem(reader);
@@ -118,7 +119,7 @@ bool XcuParser::startElement(
throw css::uno::RuntimeException(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("bad items node member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) +
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
@@ -126,7 +127,7 @@ bool XcuParser::startElement(
} else {
switch (state_.top().node->kind()) {
case Node::KIND_PROPERTY:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("value")))
{
handlePropValue(
@@ -137,14 +138,14 @@ bool XcuParser::startElement(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"bad property node member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) +
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
break;
case Node::KIND_LOCALIZED_PROPERTY:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("value")))
{
handleLocpropValue(
@@ -156,7 +157,7 @@ bool XcuParser::startElement(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"bad localized property node member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) +
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
@@ -165,18 +166,18 @@ bool XcuParser::startElement(
case Node::KIND_LOCALIZED_VALUE:
throw css::uno::RuntimeException(
(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) +
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
case Node::KIND_GROUP:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("prop")))
{
handleGroupProp(
reader,
dynamic_cast< GroupNode * >(state_.top().node.get()));
- } else if (ns == XmlReader::NAMESPACE_NONE &&
+ } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("node")))
{
handleGroupNode(reader, state_.top().node);
@@ -185,19 +186,19 @@ bool XcuParser::startElement(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"bad group node member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) +
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
break;
case Node::KIND_SET:
- if (ns == XmlReader::NAMESPACE_NONE &&
+ if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("node")))
{
handleSetNode(
reader, dynamic_cast< SetNode * >(state_.top().node.get()));
- } else if (ns == XmlReader::NAMESPACE_NONE &&
+ } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals(RTL_CONSTASCII_STRINGPARAM("prop")))
{
OSL_TRACE(
@@ -209,7 +210,7 @@ bool XcuParser::startElement(
throw css::uno::RuntimeException(
(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("bad set node member <")) +
- xmldata::convertFromUtf8(name) +
+ name.convertFromUtf8() +
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) +
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
@@ -220,7 +221,7 @@ bool XcuParser::startElement(
return true;
}
-void XcuParser::endElement(XmlReader const &) {
+void XcuParser::endElement(xmlreader::XmlReader const &) {
if (valueParser_.endElement()) {
return;
}
@@ -245,11 +246,11 @@ void XcuParser::endElement(XmlReader const &) {
}
}
-void XcuParser::characters(Span const & text) {
+void XcuParser::characters(xmlreader::Span const & text) {
valueParser_.characters(text);
}
-XcuParser::Operation XcuParser::parseOperation(Span const & text) {
+XcuParser::Operation XcuParser::parseOperation(xmlreader::Span const & text) {
OSL_ASSERT(text.is());
if (text.equals(RTL_CONSTASCII_STRINGPARAM("modify"))) {
return OPERATION_MODIFY;
@@ -265,11 +266,11 @@ XcuParser::Operation XcuParser::parseOperation(Span const & text) {
}
throw css::uno::RuntimeException(
(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid op ")) +
- xmldata::convertFromUtf8(text)),
+ text.convertFromUtf8()),
css::uno::Reference< css::uno::XInterface >());
}
-void XcuParser::handleComponentData(XmlReader & reader) {
+void XcuParser::handleComponentData(xmlreader::XmlReader & reader) {
rtl::OStringBuffer buf;
buf.append('.');
bool hasPackage = false;
@@ -277,12 +278,12 @@ void XcuParser::handleComponentData(XmlReader & reader) {
Operation op = OPERATION_MODIFY;
bool finalized = false;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("package")))
{
if (hasPackage) {
@@ -295,9 +296,9 @@ void XcuParser::handleComponentData(XmlReader & reader) {
css::uno::Reference< css::uno::XInterface >());
}
hasPackage = true;
- Span s(reader.getAttributeValue(false));
+ xmlreader::Span s(reader.getAttributeValue(false));
buf.insert(0, s.begin, s.length);
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
if (hasName) {
@@ -309,13 +310,13 @@ void XcuParser::handleComponentData(XmlReader & reader) {
css::uno::Reference< css::uno::XInterface >());
}
hasName = true;
- Span s(reader.getAttributeValue(false));
+ xmlreader::Span s(reader.getAttributeValue(false));
buf.append(s.begin, s.length);
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op")))
{
op = parseOperation(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized")))
{
finalized = xmldata::parseBoolean(reader.getAttributeValue(true));
@@ -337,8 +338,8 @@ void XcuParser::handleComponentData(XmlReader & reader) {
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
- componentName_ = xmldata::convertFromUtf8(
- Span(buf.getStr(), buf.getLength()));
+ componentName_ = xmlreader::Span(buf.getStr(), buf.getLength()).
+ convertFromUtf8();
if (trackPath_) {
OSL_ASSERT(path_.empty());
path_.push_back(componentName_);
@@ -380,15 +381,15 @@ void XcuParser::handleComponentData(XmlReader & reader) {
state_.push(State(node, finalizedLayer < valueParser_.getLayer()));
}
-void XcuParser::handleItem(XmlReader & reader) {
- Span attrPath;
+void XcuParser::handleItem(xmlreader::XmlReader & reader) {
+ xmlreader::Span attrPath;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("path")))
{
attrPath = reader.getAttributeValue(false);
@@ -401,7 +402,7 @@ void XcuParser::handleItem(XmlReader & reader) {
reader.getUrl()),
css::uno::Reference< css::uno::XInterface >());
}
- rtl::OUString path(xmldata::convertFromUtf8(attrPath));
+ rtl::OUString path(attrPath.convertFromUtf8());
int finalizedLayer;
rtl::Reference< Node > node(
data_.resolvePathRepresentation(
@@ -446,21 +447,23 @@ void XcuParser::handleItem(XmlReader & reader) {
state_.push(State(node, finalizedLayer < valueParser_.getLayer()));
}
-void XcuParser::handlePropValue(XmlReader & reader, PropertyNode * prop) {
+void XcuParser::handlePropValue(
+ xmlreader::XmlReader & reader, PropertyNode * prop)
+ {
bool nil = false;
rtl::OString separator;
rtl::OUString external;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_XSI &&
+ if (attrNsId == ParseManager::NAMESPACE_XSI &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("nil")))
{
nil = xmldata::parseBoolean(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type")))
{
Type type = xmldata::parseType(
@@ -473,10 +476,10 @@ void XcuParser::handlePropValue(XmlReader & reader, PropertyNode * prop) {
css::uno::Reference< css::uno::XInterface >());
}
valueParser_.type_ = type;
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("separator")))
{
- Span s(reader.getAttributeValue(false));
+ xmlreader::Span s(reader.getAttributeValue(false));
if (s.length == 0) {
throw css::uno::RuntimeException(
(rtl::OUString(
@@ -486,10 +489,10 @@ void XcuParser::handlePropValue(XmlReader & reader, PropertyNode * prop) {
css::uno::Reference< css::uno::XInterface >());
}
separator = rtl::OString(s.begin, s.length);
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("external")))
{
- external = xmldata::convertFromUtf8(reader.getAttributeValue(true));
+ external = reader.getAttributeValue(true).convertFromUtf8();
if (external.getLength() == 0) {
throw css::uno::RuntimeException(
(rtl::OUString(
@@ -529,27 +532,27 @@ void XcuParser::handlePropValue(XmlReader & reader, PropertyNode * prop) {
}
void XcuParser::handleLocpropValue(
- XmlReader & reader, LocalizedPropertyNode * locprop)
+ xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop)
{
rtl::OUString name;
bool nil = false;
rtl::OString separator;
Operation op = OPERATION_FUSE;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_XML &&
+ if (attrNsId == xmlreader::XmlReader::NAMESPACE_XML &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("lang")))
{
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_XSI &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_XSI &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("nil")))
{
nil = xmldata::parseBoolean(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type")))
{
Type type = xmldata::parseType(
@@ -562,10 +565,10 @@ void XcuParser::handleLocpropValue(
css::uno::Reference< css::uno::XInterface >());
}
valueParser_.type_ = type;
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("separator")))
{
- Span s(reader.getAttributeValue(false));
+ xmlreader::Span s(reader.getAttributeValue(false));
if (s.length == 0) {
throw css::uno::RuntimeException(
(rtl::OUString(
@@ -575,7 +578,7 @@ void XcuParser::handleLocpropValue(
css::uno::Reference< css::uno::XInterface >());
}
separator = rtl::OString(s.begin, s.length);
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op")))
{
op = parseOperation(reader.getAttributeValue(true));
@@ -651,32 +654,34 @@ void XcuParser::handleLocpropValue(
}
}
-void XcuParser::handleGroupProp(XmlReader & reader, GroupNode * group) {
+void XcuParser::handleGroupProp(
+ xmlreader::XmlReader & reader, GroupNode * group)
+{
bool hasName = false;
rtl::OUString name;
Type type = TYPE_ERROR;
Operation op = OPERATION_MODIFY;
bool finalized = false;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
hasName = true;
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("type")))
{
type = xmldata::parseType(reader, reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op")))
{
op = parseOperation(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized")))
{
finalized = xmldata::parseBoolean(reader.getAttributeValue(true));
@@ -726,8 +731,8 @@ void XcuParser::handleGroupProp(XmlReader & reader, GroupNode * group) {
}
void XcuParser::handleUnknownGroupProp(
- XmlReader const & reader, GroupNode * group, rtl::OUString const & name,
- Type type, Operation operation, bool finalized)
+ xmlreader::XmlReader const & reader, GroupNode * group,
+ rtl::OUString const & name, Type type, Operation operation, bool finalized)
{
switch (operation) {
case OPERATION_REPLACE:
@@ -767,7 +772,7 @@ void XcuParser::handleUnknownGroupProp(
}
void XcuParser::handlePlainGroupProp(
- XmlReader const & reader, GroupNode * group,
+ xmlreader::XmlReader const & reader, GroupNode * group,
NodeMap::iterator const & propertyIndex, rtl::OUString const & name,
Type type, Operation operation, bool finalized)
{
@@ -821,7 +826,7 @@ void XcuParser::handlePlainGroupProp(
}
void XcuParser::handleLocalizedGroupProp(
- XmlReader const & reader, LocalizedPropertyNode * property,
+ xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
rtl::OUString const & name, Type type, Operation operation, bool finalized)
{
if (property->getLayer() > valueParser_.getLayer()) {
@@ -879,28 +884,28 @@ void XcuParser::handleLocalizedGroupProp(
}
void XcuParser::handleGroupNode(
- XmlReader & reader, rtl::Reference< Node > const & group)
+ xmlreader::XmlReader & reader, rtl::Reference< Node > const & group)
{
bool hasName = false;
rtl::OUString name;
Operation op = OPERATION_MODIFY;
bool finalized = false;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
hasName = true;
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op")))
{
op = parseOperation(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized")))
{
finalized = xmldata::parseBoolean(reader.getAttributeValue(true));
@@ -950,7 +955,7 @@ void XcuParser::handleGroupNode(
state_.top().locked || finalizedLayer < valueParser_.getLayer()));
}
-void XcuParser::handleSetNode(XmlReader & reader, SetNode * set) {
+void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) {
bool hasName = false;
rtl::OUString name;
rtl::OUString component(componentName_);
@@ -960,36 +965,34 @@ void XcuParser::handleSetNode(XmlReader & reader, SetNode * set) {
bool finalized = false;
bool mandatory = false;
for (;;) {
- XmlReader::Namespace attrNs;
- Span attrLn;
- if (!reader.nextAttribute(&attrNs, &attrLn)) {
+ int attrNsId;
+ xmlreader::Span attrLn;
+ if (!reader.nextAttribute(&attrNsId, &attrLn)) {
break;
}
- if (attrNs == XmlReader::NAMESPACE_OOR &&
+ if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
hasName = true;
- name = xmldata::convertFromUtf8(reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ name = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("component")))
{
- component = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ component = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("node-type")))
{
hasNodeType = true;
- nodeType = xmldata::convertFromUtf8(
- reader.getAttributeValue(false));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ nodeType = reader.getAttributeValue(false).convertFromUtf8();
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("op")))
{
op = parseOperation(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("finalized")))
{
finalized = xmldata::parseBoolean(reader.getAttributeValue(true));
- } else if (attrNs == XmlReader::NAMESPACE_OOR &&
+ } else if (attrNsId == ParseManager::NAMESPACE_OOR &&
attrLn.equals(RTL_CONSTASCII_STRINGPARAM("mandatory")))
{
mandatory = xmldata::parseBoolean(reader.getAttributeValue(true));
diff --git a/configmgr/source/xcuparser.hxx b/configmgr/source/xcuparser.hxx
index 02ef4e5ff117..6cd600c8aab1 100644
--- a/configmgr/source/xcuparser.hxx
+++ b/configmgr/source/xcuparser.hxx
@@ -34,6 +34,7 @@
#include "rtl/ref.hxx"
#include "rtl/ustring.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "additions.hxx"
#include "node.hxx"
@@ -43,7 +44,8 @@
#include "type.hxx"
#include "valueparser.hxx"
#include "xmldata.hxx"
-#include "xmlreader.hxx"
+
+namespace xmlreader { struct Span; }
namespace configmgr {
@@ -54,7 +56,6 @@ class Partial;
class PropertyNode;
class SetNode;
struct Data;
-struct Span;
class XcuParser: public Parser {
public:
@@ -65,49 +66,50 @@ public:
private:
virtual ~XcuParser();
- virtual XmlReader::Text getTextMode();
+ virtual xmlreader::XmlReader::Text getTextMode();
virtual bool startElement(
- XmlReader & reader, XmlReader::Namespace ns, Span const & name);
+ xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
- virtual void endElement(XmlReader const & reader);
+ virtual void endElement(xmlreader::XmlReader const & reader);
- virtual void characters(Span const & span);
+ virtual void characters(xmlreader::Span const & span);
enum Operation {
OPERATION_MODIFY, OPERATION_REPLACE, OPERATION_FUSE, OPERATION_REMOVE };
- static Operation parseOperation(Span const & text);
+ static Operation parseOperation(xmlreader::Span const & text);
- void handleComponentData(XmlReader & reader);
+ void handleComponentData(xmlreader::XmlReader & reader);
- void handleItem(XmlReader & reader);
+ void handleItem(xmlreader::XmlReader & reader);
- void handlePropValue(XmlReader & reader, PropertyNode * prop);
+ void handlePropValue(xmlreader::XmlReader & reader, PropertyNode * prop);
void handleLocpropValue(
- XmlReader & reader, LocalizedPropertyNode * locprop);
+ xmlreader::XmlReader & reader, LocalizedPropertyNode * locprop);
- void handleGroupProp(XmlReader & reader, GroupNode * group);
+ void handleGroupProp(xmlreader::XmlReader & reader, GroupNode * group);
void handleUnknownGroupProp(
- XmlReader const & reader, GroupNode * group, rtl::OUString const & name,
- Type type, Operation operation, bool finalized);
+ xmlreader::XmlReader const & reader, GroupNode * group,
+ rtl::OUString const & name, Type type, Operation operation,
+ bool finalized);
void handlePlainGroupProp(
- XmlReader const & reader, GroupNode * group,
+ xmlreader::XmlReader const & reader, GroupNode * group,
NodeMap::iterator const & propertyIndex, rtl::OUString const & name,
Type type, Operation operation, bool finalized);
void handleLocalizedGroupProp(
- XmlReader const & reader, LocalizedPropertyNode * property,
+ xmlreader::XmlReader const & reader, LocalizedPropertyNode * property,
rtl::OUString const & name, Type type, Operation operation,
bool finalized);
void handleGroupNode(
- XmlReader & reader, rtl::Reference< Node > const & group);
+ xmlreader::XmlReader & reader, rtl::Reference< Node > const & group);
- void handleSetNode(XmlReader & reader, SetNode * set);
+ void handleSetNode(xmlreader::XmlReader & reader, SetNode * set);
void recordModification(bool addition);
diff --git a/configmgr/source/xmldata.cxx b/configmgr/source/xmldata.cxx
index 07ad4d17a345..7d3d9ead3d2c 100644
--- a/configmgr/source/xmldata.cxx
+++ b/configmgr/source/xmldata.cxx
@@ -40,12 +40,12 @@
#include "rtl/ref.hxx"
#include "rtl/strbuf.hxx"
#include "rtl/string.h"
-#include "rtl/textcvt.h"
-#include "rtl/textenc.h"
#include "rtl/ustrbuf.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
+#include "xmlreader/span.hxx"
+#include "xmlreader/xmlreader.hxx"
#include "data.hxx"
#include "groupnode.hxx"
@@ -57,9 +57,7 @@
#include "parser.hxx"
#include "propertynode.hxx"
#include "setnode.hxx"
-#include "span.hxx"
#include "type.hxx"
-#include "xmlreader.hxx"
namespace configmgr {
@@ -71,90 +69,88 @@ namespace css = com::sun::star;
}
-rtl::OUString convertFromUtf8(Span const & text) {
- OSL_ASSERT(text.is());
- rtl_uString * s = 0;
- if (!rtl_convertStringToUString(
- &s, text.begin, text.length, RTL_TEXTENCODING_UTF8,
- (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
- RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
- RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
- {
- throw css::uno::RuntimeException(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("cannot convert from UTF-8")),
- css::uno::Reference< css::uno::XInterface >());
- }
- return rtl::OUString(s, SAL_NO_ACQUIRE);
-}
-
-Type parseType(XmlReader const & reader, Span const & text) {
+Type parseType(
+ xmlreader::XmlReader const & reader, xmlreader::Span const & text)
+{
OSL_ASSERT(text.is());
sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
if (i >= 0) {
- switch (reader.getNamespace(Span(text.begin, i))) {
- case XmlReader::NAMESPACE_OOR:
- if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("any")))
+ 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")))
{
return TYPE_ANY;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("boolean-list")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("boolean-list")))
{
return TYPE_BOOLEAN_LIST;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("short-list")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("short-list")))
{
return TYPE_SHORT_LIST;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("int-list")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("int-list")))
{
return TYPE_INT_LIST;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("long-list")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("long-list")))
{
return TYPE_LONG_LIST;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("double-list")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("double-list")))
{
return TYPE_DOUBLE_LIST;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("string-list")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("string-list")))
{
return TYPE_STRING_LIST;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("hexBinary-list")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("hexBinary-list")))
{
return TYPE_HEXBINARY_LIST;
}
break;
- case XmlReader::NAMESPACE_XS:
- if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("boolean")))
+ case ParseManager::NAMESPACE_XS:
+ if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("boolean")))
{
return TYPE_BOOLEAN;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("short")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("short")))
{
return TYPE_SHORT;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("int")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("int")))
{
return TYPE_INT;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("long")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("long")))
{
return TYPE_LONG;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("double")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("double")))
{
return TYPE_DOUBLE;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("string")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("string")))
{
return TYPE_STRING;
- } else if (Span(text.begin + i + 1, text.length - (i + 1)).equals(
- RTL_CONSTASCII_STRINGPARAM("hexBinary")))
+ } else if (xmlreader::Span(
+ text.begin + i + 1, text.length - (i + 1)).
+ equals(RTL_CONSTASCII_STRINGPARAM("hexBinary")))
{
return TYPE_HEXBINARY;
}
@@ -165,11 +161,11 @@ Type parseType(XmlReader const & reader, Span const & text) {
}
throw css::uno::RuntimeException(
(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid type ")) +
- convertFromUtf8(text)),
+ text.convertFromUtf8()),
css::uno::Reference< css::uno::XInterface >());
}
-bool parseBoolean(Span const & text) {
+bool parseBoolean(xmlreader::Span const & text) {
OSL_ASSERT(text.is());
if (text.equals(RTL_CONSTASCII_STRINGPARAM("true"))) {
return true;
@@ -179,7 +175,7 @@ bool parseBoolean(Span const & text) {
}
throw css::uno::RuntimeException(
(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid boolean ")) +
- convertFromUtf8(text)),
+ text.convertFromUtf8()),
css::uno::Reference< css::uno::XInterface >());
}
diff --git a/configmgr/source/xmldata.hxx b/configmgr/source/xmldata.hxx
index 15a0a36336ad..e60e1082cabb 100644
--- a/configmgr/source/xmldata.hxx
+++ b/configmgr/source/xmldata.hxx
@@ -33,19 +33,19 @@
#include "type.hxx"
namespace rtl { class OUString; }
+namespace xmlreader {
+ class XmlReader;
+ struct Span;
+}
namespace configmgr {
-class XmlReader;
-struct Span;
-
namespace xmldata {
-rtl::OUString convertFromUtf8(Span const & text);
-
-Type parseType(XmlReader const & reader, Span const & text);
+Type parseType(
+ xmlreader::XmlReader const & reader, xmlreader::Span const & text);
-bool parseBoolean(Span const & text);
+bool parseBoolean(xmlreader::Span const & text);
rtl::OUString parseTemplateReference(
rtl::OUString const & component, bool hasNodeType,
diff --git a/configmgr/source/xmlreader.cxx b/configmgr/source/xmlreader.cxx
deleted file mode 100644
index ac6a08d18604..000000000000
--- a/configmgr/source/xmlreader.cxx
+++ /dev/null
@@ -1,1054 +0,0 @@
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#include "precompiled_configmgr.hxx"
-#include "sal/config.h"
-
-#include <cstddef>
-
-#include "com/sun/star/container/NoSuchElementException.hpp"
-#include "com/sun/star/uno/Reference.hxx"
-#include "com/sun/star/uno/RuntimeException.hpp"
-#include "com/sun/star/uno/XInterface.hpp"
-#include "osl/diagnose.h"
-#include "osl/file.h"
-#include "rtl/string.h"
-#include "rtl/ustring.h"
-#include "rtl/ustring.hxx"
-#include "sal/types.h"
-
-#include "pad.hxx"
-#include "span.hxx"
-#include "xmlreader.hxx"
-
-namespace configmgr {
-
-namespace {
-
-namespace css = com::sun::star;
-
-bool isSpace(char c) {
- switch (c) {
- case '\x09':
- case '\x0A':
- case '\x0D':
- case ' ':
- return true;
- default:
- return false;
- }
-}
-
-}
-
-XmlReader::XmlReader(rtl::OUString const & fileUrl)
- SAL_THROW((
- css::container::NoSuchElementException, css::uno::RuntimeException)):
- fileUrl_(fileUrl)
-{
- switch (osl_openFile(fileUrl_.pData, &fileHandle_, osl_File_OpenFlag_Read))
- {
- case osl_File_E_None:
- break;
- case osl_File_E_NOENT:
- throw css::container::NoSuchElementException(
- fileUrl_, css::uno::Reference< css::uno::XInterface >());
- default:
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cannot open ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- oslFileError e = osl_getFileSize(fileHandle_, &fileSize_);
- if (e == osl_File_E_None) {
- e = osl_mapFile(
- fileHandle_, &fileAddress_, fileSize_, 0,
- osl_File_MapFlag_WillNeed);
- }
- if (e != osl_File_E_None) {
- e = osl_closeFile(fileHandle_);
- if (e != osl_File_E_None) {
- OSL_TRACE("osl_closeFile failed with %ld", static_cast< long >(e));
- }
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cannot mmap ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- namespaces_.push_back(
- NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML));
- namespaces_.push_back(
- NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xsi")), NAMESPACE_XSI));
- // 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
- // Components::parseModificationLayer)
- pos_ = static_cast< char * >(fileAddress_);
- end_ = pos_ + fileSize_;
- state_ = STATE_CONTENT;
-}
-
-XmlReader::~XmlReader() {
- oslFileError e = osl_unmapFile(fileAddress_, fileSize_);
- if (e != osl_File_E_None) {
- OSL_TRACE("osl_unmapFile failed with %ld", static_cast< long >(e));
- }
- e = osl_closeFile(fileHandle_);
- if (e != osl_File_E_None) {
- OSL_TRACE("osl_closeFile failed with %ld", static_cast< long >(e));
- }
-}
-
-XmlReader::Result XmlReader::nextItem(
- Text reportText, Span * data, Namespace * ns)
-{
- switch (state_) {
- case STATE_CONTENT:
- switch (reportText) {
- case TEXT_NONE:
- return handleSkippedText(data, ns);
- case TEXT_RAW:
- return handleRawText(data);
- case TEXT_NORMALIZED:
- return handleNormalizedText(data);
- }
- case STATE_START_TAG:
- return handleStartTag(ns, data);
- case STATE_END_TAG:
- return handleEndTag();
- case STATE_EMPTY_ELEMENT_TAG:
- handleElementEnd();
- return RESULT_END;
- default: // STATE_DONE
- return RESULT_DONE;
- }
-}
-
-bool XmlReader::nextAttribute(Namespace * ns, Span * localName) {
- OSL_ASSERT(ns != 0 && localName != 0);
- if (firstAttribute_) {
- currentAttribute_ = attributes_.begin();
- firstAttribute_ = false;
- } else {
- ++currentAttribute_;
- }
- if (currentAttribute_ == attributes_.end()) {
- return false;
- }
- if (currentAttribute_->nameColon == 0) {
- *ns = NAMESPACE_NONE;
- *localName = Span(
- currentAttribute_->nameBegin,
- currentAttribute_->nameEnd - currentAttribute_->nameBegin);
- } else {
- *ns = getNamespace(
- Span(
- currentAttribute_->nameBegin,
- currentAttribute_->nameColon - currentAttribute_->nameBegin));
- *localName = Span(
- currentAttribute_->nameColon + 1,
- currentAttribute_->nameEnd - (currentAttribute_->nameColon + 1));
- }
- return true;
-}
-
-Span XmlReader::getAttributeValue(bool fullyNormalize) {
- return handleAttributeValue(
- currentAttribute_->valueBegin, currentAttribute_->valueEnd,
- fullyNormalize);
-}
-
-XmlReader::Namespace XmlReader::getNamespace(Span const & prefix) const {
- for (NamespaceList::const_reverse_iterator i(namespaces_.rbegin());
- i != namespaces_.rend(); ++i)
- {
- if (prefix.equals(i->prefix)) {
- return i->ns;
- }
- }
- return NAMESPACE_OTHER;
-}
-
-rtl::OUString XmlReader::getUrl() const {
- return fileUrl_;
-}
-
-void XmlReader::normalizeLineEnds(Span const & text) {
- char const * p = text.begin;
- sal_Int32 n = text.length;
- for (;;) {
- sal_Int32 i = rtl_str_indexOfChar_WithLength(p, n, '\x0D');
- if (i < 0) {
- break;
- }
- pad_.add(p, i);
- p += i + 1;
- n -= i + 1;
- if (n == 0 || *p != '\x0A') {
- pad_.add(RTL_CONSTASCII_STRINGPARAM("\x0A"));
- }
- }
- pad_.add(p, n);
-}
-
-void XmlReader::skipSpace() {
- while (isSpace(peek())) {
- ++pos_;
- }
-}
-
-bool XmlReader::skipComment() {
- if (rtl_str_shortenedCompare_WithLength(
- pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("--"),
- RTL_CONSTASCII_LENGTH("--")) !=
- 0)
- {
- return false;
- }
- pos_ += RTL_CONSTASCII_LENGTH("--");
- sal_Int32 i = rtl_str_indexOfStr_WithLength(
- pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("--"));
- if (i < 0) {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "premature end (within comment) of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- pos_ += i + RTL_CONSTASCII_LENGTH("--");
- if (read() != '>') {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "illegal \"--\" within comment in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- return true;
-}
-
-void XmlReader::skipProcessingInstruction() {
- sal_Int32 i = rtl_str_indexOfStr_WithLength(
- pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("?>"));
- if (i < 0) {
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad '<?' in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- pos_ += i + RTL_CONSTASCII_LENGTH("?>");
-}
-
-void XmlReader::skipDocumentTypeDeclaration() {
- // Neither is it checked that the doctypedecl is at the correct position in
- // the document, nor that it is well-formed:
- for (;;) {
- char c = read();
- switch (c) {
- case '\0': // i.e., EOF
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "premature end (within DTD) of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- case '"':
- case '\'':
- {
- sal_Int32 i = rtl_str_indexOfChar_WithLength(
- pos_, end_ - pos_, c);
- if (i < 0) {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "premature end (within DTD) of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- pos_ += i + 1;
- }
- break;
- case '>':
- return;
- case '[':
- for (;;) {
- c = read();
- switch (c) {
- case '\0': // i.e., EOF
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "premature end (within DTD) of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- case '"':
- case '\'':
- {
- sal_Int32 i = rtl_str_indexOfChar_WithLength(
- pos_, end_ - pos_, c);
- if (i < 0) {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "premature end (within DTD) of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- pos_ += i + 1;
- }
- break;
- case '<':
- switch (read()) {
- case '\0': // i.e., EOF
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "premature end (within DTD) of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- case '!':
- skipComment();
- break;
- case '?':
- skipProcessingInstruction();
- break;
- default:
- break;
- }
- break;
- case ']':
- skipSpace();
- if (read() != '>') {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "missing \">\" of DTD in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- return;
- default:
- break;
- }
- }
- default:
- break;
- }
- }
-}
-
-Span XmlReader::scanCdataSection() {
- if (rtl_str_shortenedCompare_WithLength(
- pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("[CDATA["),
- RTL_CONSTASCII_LENGTH("[CDATA[")) !=
- 0)
- {
- return Span();
- }
- pos_ += RTL_CONSTASCII_LENGTH("[CDATA[");
- char const * begin = pos_;
- sal_Int32 i = rtl_str_indexOfStr_WithLength(
- pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("]]>"));
- if (i < 0) {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "premature end (within CDATA section) of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- pos_ += i + RTL_CONSTASCII_LENGTH("]]>");
- return Span(begin, i);
-}
-
-bool XmlReader::scanName(char const ** nameColon) {
- OSL_ASSERT(nameColon != 0 && *nameColon == 0);
- for (char const * begin = pos_;; ++pos_) {
- switch (peek()) {
- case '\0': // i.e., EOF
- case '\x09':
- case '\x0A':
- case '\x0D':
- case ' ':
- case '/':
- case '=':
- case '>':
- return pos_ != begin;
- case ':':
- *nameColon = pos_;
- break;
- default:
- break;
- }
- }
-}
-
-XmlReader::Namespace XmlReader::scanNamespaceIri(
- char const * begin, char const * end)
-{
- OSL_ASSERT(begin != 0 && begin <= end);
- Span iri(handleAttributeValue(begin, end, false));
- struct Iri {
- char const * begin;
- sal_Int32 length;
- XmlReader::Namespace ns;
- };
- static Iri const iris[] = {
- { RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry"),
- XmlReader::NAMESPACE_OOR },
- { RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema"),
- XmlReader::NAMESPACE_XS },
- { RTL_CONSTASCII_STRINGPARAM(
- "http://www.w3.org/2001/XMLSchema-instance"),
- XmlReader::NAMESPACE_XSI },
- { RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/XML/1998/namespace"),
- XmlReader::NAMESPACE_XML } };
- for (std::size_t i = 0; i < sizeof iris / sizeof iris[0]; ++i) {
- if (rtl_str_compare_WithLength(
- iri.begin, iri.length, iris[i].begin, iris[i].length) ==
- 0)
- {
- return iris[i].ns;
- }
- }
- return XmlReader::NAMESPACE_OTHER;
-}
-
-char const * XmlReader::handleReference(char const * position, char const * end)
-{
- OSL_ASSERT(position != 0 && *position == '&' && position < end);
- ++position;
- if (*position == '#') {
- ++position;
- sal_Int32 val = 0;
- char const * p;
- if (*position == 'x') {
- ++position;
- p = position;
- for (;; ++position) {
- char c = *position;
- if (c >= '0' && c <= '9') {
- val = 16 * val + (c - '0');
- } else if (c >= 'A' && c <= 'F') {
- val = 16 * val + (c - 'A') + 10;
- } else if (c >= 'a' && c <= 'f') {
- val = 16 * val + (c - 'a') + 10;
- } else {
- break;
- }
- if (val > 0x10FFFF) { // avoid overflow
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "'&#x...' too large in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- }
- } else {
- p = position;
- for (;; ++position) {
- char c = *position;
- if (c >= '0' && c <= '9') {
- val = 10 * val + (c - '0');
- } else {
- break;
- }
- if (val > 0x10FFFF) { // avoid overflow
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "'&#...' too large in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- }
- }
- if (position == p || *position++ != ';') {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("'&#...' missing ';' in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- OSL_ASSERT(val >= 0 && val <= 0x10FFFF);
- if ((val < 0x20 && val != 0x9 && val != 0xA && val != 0xD) ||
- (val >= 0xD800 && val <= 0xDFFF) || val == 0xFFFE || val == 0xFFFF)
- {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "character reference denoting invalid character in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- char buf[4];
- sal_Int32 len;
- if (val < 0x80) {
- buf[0] = static_cast< char >(val);
- len = 1;
- } else if (val < 0x800) {
- buf[0] = static_cast< char >((val >> 6) | 0xC0);
- buf[1] = static_cast< char >((val & 0x3F) | 0x80);
- len = 2;
- } else if (val < 0x10000) {
- buf[0] = static_cast< char >((val >> 12) | 0xE0);
- buf[1] = static_cast< char >(((val >> 6) & 0x3F) | 0x80);
- buf[2] = static_cast< char >((val & 0x3F) | 0x80);
- len = 3;
- } else {
- buf[0] = static_cast< char >((val >> 18) | 0xF0);
- buf[1] = static_cast< char >(((val >> 12) & 0x3F) | 0x80);
- buf[2] = static_cast< char >(((val >> 6) & 0x3F) | 0x80);
- buf[3] = static_cast< char >((val & 0x3F) | 0x80);
- len = 4;
- }
- pad_.addEphemeral(buf, len);
- return position;
- } else {
- struct EntityRef {
- char const * inBegin;
- sal_Int32 inLength;
- char const * outBegin;
- sal_Int32 outLength;
- };
- static EntityRef const refs[] = {
- { RTL_CONSTASCII_STRINGPARAM("amp;"),
- RTL_CONSTASCII_STRINGPARAM("&") },
- { RTL_CONSTASCII_STRINGPARAM("lt;"),
- RTL_CONSTASCII_STRINGPARAM("<") },
- { RTL_CONSTASCII_STRINGPARAM("gt;"),
- RTL_CONSTASCII_STRINGPARAM(">") },
- { RTL_CONSTASCII_STRINGPARAM("apos;"),
- RTL_CONSTASCII_STRINGPARAM("'") },
- { RTL_CONSTASCII_STRINGPARAM("quot;"),
- RTL_CONSTASCII_STRINGPARAM("\"") } };
- for (std::size_t i = 0; i < sizeof refs / sizeof refs[0]; ++i) {
- if (rtl_str_shortenedCompare_WithLength(
- position, end - position, refs[i].inBegin, refs[i].inLength,
- refs[i].inLength) ==
- 0)
- {
- position += refs[i].inLength;
- pad_.add(refs[i].outBegin, refs[i].outLength);
- return position;
- }
- }
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("unknown entity reference in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
-}
-
-Span XmlReader::handleAttributeValue(
- char const * begin, char const * end, bool fullyNormalize)
-{
- pad_.clear();
- if (fullyNormalize) {
- while (begin != end && isSpace(*begin)) {
- ++begin;
- }
- while (end != begin && isSpace(end[-1])) {
- --end;
- }
- char const * p = begin;
- enum Space { SPACE_NONE, SPACE_SPAN, SPACE_BREAK };
- // a single true space character can go into the current span,
- // everything else breaks the span
- Space space = SPACE_NONE;
- while (p != end) {
- switch (*p) {
- case '\x09':
- case '\x0A':
- case '\x0D':
- switch (space) {
- case SPACE_NONE:
- pad_.add(begin, p - begin);
- pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
- space = SPACE_BREAK;
- break;
- case SPACE_SPAN:
- pad_.add(begin, p - begin);
- space = SPACE_BREAK;
- break;
- case SPACE_BREAK:
- break;
- }
- begin = ++p;
- break;
- case ' ':
- switch (space) {
- case SPACE_NONE:
- ++p;
- space = SPACE_SPAN;
- break;
- case SPACE_SPAN:
- pad_.add(begin, p - begin);
- begin = ++p;
- space = SPACE_BREAK;
- break;
- case SPACE_BREAK:
- begin = ++p;
- break;
- }
- break;
- case '&':
- pad_.add(begin, p - begin);
- p = handleReference(p, end);
- begin = p;
- space = SPACE_NONE;
- break;
- default:
- ++p;
- space = SPACE_NONE;
- break;
- }
- }
- pad_.add(begin, p - begin);
- } else {
- char const * p = begin;
- while (p != end) {
- switch (*p) {
- case '\x09':
- case '\x0A':
- pad_.add(begin, p - begin);
- begin = ++p;
- pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
- break;
- case '\x0D':
- pad_.add(begin, p - begin);
- ++p;
- if (peek() == '\x0A') {
- ++p;
- }
- begin = p;
- pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
- break;
- case '&':
- pad_.add(begin, p - begin);
- p = handleReference(p, end);
- begin = p;
- break;
- default:
- ++p;
- break;
- }
- }
- pad_.add(begin, p - begin);
- }
- return pad_.get();
-}
-
-XmlReader::Result XmlReader::handleStartTag(Namespace * ns, Span * localName) {
- OSL_ASSERT(ns != 0 && localName);
- char const * nameBegin = pos_;
- char const * nameColon = 0;
- if (!scanName(&nameColon)) {
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad tag name in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- char const * nameEnd = pos_;
- NamespaceList::size_type inheritedNamespaces = namespaces_.size();
- bool hasDefaultNs = false;
- Namespace defaultNs = NAMESPACE_NONE;
- attributes_.clear();
- for (;;) {
- char const * p = pos_;
- skipSpace();
- if (peek() == '/' || peek() == '>') {
- break;
- }
- if (pos_ == p) {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "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(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("bad attribute name in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- char const * attrNameEnd = pos_;
- skipSpace();
- if (read() != '=') {
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '=' in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- skipSpace();
- char del = read();
- if (del != '\'' && del != '"') {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("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(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "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")))
- {
- hasDefaultNs = true;
- defaultNs = scanNamespaceIri(valueBegin, valueEnd);
- } else if (attrNameColon != 0 &&
- Span(attrNameBegin, attrNameColon - attrNameBegin).equals(
- RTL_CONSTASCII_STRINGPARAM("xmlns")))
- {
- namespaces_.push_back(
- NamespaceData(
- Span(attrNameColon + 1, attrNameEnd - (attrNameColon + 1)),
- scanNamespaceIri(valueBegin, valueEnd)));
- } else {
- attributes_.push_back(
- AttributeData(
- attrNameBegin, attrNameEnd, attrNameColon, valueBegin,
- valueEnd));
- }
- }
- if (!hasDefaultNs && !elements_.empty()) {
- defaultNs = elements_.top().defaultNamespace;
- }
- firstAttribute_ = true;
- if (peek() == '/') {
- state_ = STATE_EMPTY_ELEMENT_TAG;
- ++pos_;
- } else {
- state_ = STATE_CONTENT;
- }
- if (peek() != '>') {
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '>' in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- ++pos_;
- elements_.push(
- ElementData(
- Span(nameBegin, nameEnd - nameBegin), inheritedNamespaces,
- defaultNs));
- if (nameColon == 0) {
- *ns = defaultNs;
- *localName = Span(nameBegin, nameEnd - nameBegin);
- } else {
- *ns = getNamespace(Span(nameBegin, nameColon - nameBegin));
- *localName = Span(nameColon + 1, nameEnd - (nameColon + 1));
- }
- return RESULT_BEGIN;
-}
-
-XmlReader::Result XmlReader::handleEndTag() {
- if (elements_.empty()) {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("spurious end tag in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- char const * nameBegin = pos_;
- char const * nameColon = 0;
- if (!scanName(&nameColon) ||
- !elements_.top().name.equals(nameBegin, pos_ - nameBegin))
- {
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("tag mismatch in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- handleElementEnd();
- skipSpace();
- if (peek() != '>') {
- throw css::uno::RuntimeException(
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '>' in ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- ++pos_;
- return RESULT_END;
-}
-
-void XmlReader::handleElementEnd() {
- OSL_ASSERT(!elements_.empty());
- namespaces_.resize(elements_.top().inheritedNamespaces);
- elements_.pop();
- state_ = elements_.empty() ? STATE_DONE : STATE_CONTENT;
-}
-
-XmlReader::Result XmlReader::handleSkippedText(Span * data, Namespace * ns) {
- for (;;) {
- sal_Int32 i = rtl_str_indexOfChar_WithLength(pos_, end_ - pos_, '<');
- if (i < 0) {
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("premature end of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- }
- pos_ += i + 1;
- switch (peek()) {
- case '!':
- ++pos_;
- if (!skipComment() && !scanCdataSection().is()) {
- skipDocumentTypeDeclaration();
- }
- break;
- case '/':
- ++pos_;
- return handleEndTag();
- case '?':
- ++pos_;
- skipProcessingInstruction();
- break;
- default:
- return handleStartTag(ns, data);
- }
- }
-}
-
-XmlReader::Result XmlReader::handleRawText(Span * text) {
- pad_.clear();
- for (char const * begin = pos_;;) {
- switch (peek()) {
- case '\0': // i.e., EOF
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("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"));
- }
- begin = pos_;
- break;
- case '&':
- pad_.add(begin, pos_ - begin);
- pos_ = handleReference(pos_, end_);
- begin = pos_;
- break;
- case '<':
- pad_.add(begin, pos_ - begin);
- ++pos_;
- switch (peek()) {
- case '!':
- ++pos_;
- if (!skipComment()) {
- Span cdata(scanCdataSection());
- if (cdata.is()) {
- normalizeLineEnds(cdata);
- } else {
- skipDocumentTypeDeclaration();
- }
- }
- begin = pos_;
- break;
- case '/':
- *text = pad_.get();
- ++pos_;
- state_ = STATE_END_TAG;
- return RESULT_TEXT;
- case '?':
- ++pos_;
- skipProcessingInstruction();
- begin = pos_;
- break;
- default:
- *text = pad_.get();
- state_ = STATE_START_TAG;
- return RESULT_TEXT;
- }
- break;
- default:
- ++pos_;
- break;
- }
- }
-}
-
-XmlReader::Result XmlReader::handleNormalizedText(Span * text) {
- pad_.clear();
- char const * flowBegin = pos_;
- char const * flowEnd = pos_;
- enum Space { SPACE_START, SPACE_NONE, SPACE_SPAN, SPACE_BREAK };
- // a single true space character can go into the current flow,
- // everything else breaks the flow
- Space space = SPACE_START;
- for (;;) {
- switch (peek()) {
- case '\0': // i.e., EOF
- throw css::uno::RuntimeException(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("premature end of ")) +
- fileUrl_),
- css::uno::Reference< css::uno::XInterface >());
- case '\x09':
- case '\x0A':
- case '\x0D':
- switch (space) {
- case SPACE_START:
- case SPACE_BREAK:
- break;
- case SPACE_NONE:
- case SPACE_SPAN:
- space = SPACE_BREAK;
- break;
- }
- ++pos_;
- break;
- case ' ':
- switch (space) {
- case SPACE_START:
- case SPACE_BREAK:
- break;
- case SPACE_NONE:
- space = SPACE_SPAN;
- break;
- case SPACE_SPAN:
- space = SPACE_BREAK;
- break;
- }
- ++pos_;
- break;
- case '&':
- switch (space) {
- case SPACE_START:
- break;
- case SPACE_NONE:
- case SPACE_SPAN:
- pad_.add(flowBegin, pos_ - flowBegin);
- break;
- case SPACE_BREAK:
- pad_.add(flowBegin, flowEnd - flowBegin);
- pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
- break;
- }
- pos_ = handleReference(pos_, end_);
- flowBegin = pos_;
- flowEnd = pos_;
- space = SPACE_NONE;
- break;
- case '<':
- ++pos_;
- switch (peek()) {
- case '!':
- ++pos_;
- if (skipComment()) {
- space = SPACE_BREAK;
- } else {
- Span cdata(scanCdataSection());
- if (cdata.is()) {
- // CDATA is not normalized (similar to character
- // references; it keeps the code simple), but it might
- // arguably be better to normalize it:
- switch (space) {
- case SPACE_START:
- break;
- case SPACE_NONE:
- case SPACE_SPAN:
- pad_.add(flowBegin, pos_ - flowBegin);
- break;
- case SPACE_BREAK:
- pad_.add(flowBegin, flowEnd - flowBegin);
- pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
- break;
- }
- normalizeLineEnds(cdata);
- flowBegin = pos_;
- flowEnd = pos_;
- space = SPACE_NONE;
- } else {
- skipDocumentTypeDeclaration();
- }
- }
- break;
- case '/':
- ++pos_;
- pad_.add(flowBegin, flowEnd - flowBegin);
- *text = pad_.get();
- state_ = STATE_END_TAG;
- return RESULT_TEXT;
- case '?':
- ++pos_;
- skipProcessingInstruction();
- space = SPACE_BREAK;
- break;
- default:
- pad_.add(flowBegin, flowEnd - flowBegin);
- *text = pad_.get();
- state_ = STATE_START_TAG;
- return RESULT_TEXT;
- }
- break;
- default:
- switch (space) {
- case SPACE_START:
- flowBegin = pos_;
- break;
- case SPACE_NONE:
- case SPACE_SPAN:
- break;
- case SPACE_BREAK:
- pad_.add(flowBegin, flowEnd - flowBegin);
- pad_.add(RTL_CONSTASCII_STRINGPARAM(" "));
- flowBegin = pos_;
- break;
- }
- flowEnd = ++pos_;
- space = SPACE_NONE;
- break;
- }
- }
-}
-
-}
diff --git a/configmgr/source/xmlreader.hxx b/configmgr/source/xmlreader.hxx
deleted file mode 100644
index 83ccac148cd4..000000000000
--- a/configmgr/source/xmlreader.hxx
+++ /dev/null
@@ -1,186 +0,0 @@
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#ifndef INCLUDED_CONFIGMGR_SOURCE_XMLREADER_HXX
-#define INCLUDED_CONFIGMGR_SOURCE_XMLREADER_HXX
-
-#include "sal/config.h"
-
-#include <stack>
-#include <vector>
-
-#include "boost/noncopyable.hpp"
-#include "com/sun/star/container/NoSuchElementException.hpp"
-#include "com/sun/star/uno/RuntimeException.hpp"
-#include "osl/file.h"
-#include "rtl/ustring.hxx"
-#include "sal/types.h"
-
-#include "pad.hxx"
-#include "span.hxx"
-
-namespace configmgr {
-
-class XmlReader: private boost::noncopyable {
-public:
- explicit XmlReader(rtl::OUString const & fileUrl)
- SAL_THROW((
- com::sun::star::container::NoSuchElementException,
- com::sun::star::uno::RuntimeException));
-
- ~XmlReader();
-
- enum Namespace {
- NAMESPACE_NONE, NAMESPACE_XML, NAMESPACE_OOR, NAMESPACE_XS,
- NAMESPACE_XSI, NAMESPACE_OTHER };
-
- enum Text { TEXT_NONE, TEXT_RAW, TEXT_NORMALIZED };
-
- enum Result { RESULT_BEGIN, RESULT_END, RESULT_TEXT, RESULT_DONE };
-
- // RESULT_BEGIN: data = localName, ns = ns
- // RESULT_END: data, ns unused
- // RESULT_TEXT: data = text, ns unused
- Result nextItem(Text reportText, Span * data, Namespace * ns);
-
- bool nextAttribute(Namespace * ns, Span * localName);
-
- // the span returned by getAttributeValue is only valid until the next call
- // to nextItem or getAttributeValue
- Span getAttributeValue(bool fullyNormalize);
-
- Namespace getNamespace(Span const & prefix) const;
-
- rtl::OUString getUrl() const;
-
-private:
- inline char read() { return pos_ == end_ ? '\0' : *pos_++; }
-
- inline char peek() { return pos_ == end_ ? '\0' : *pos_; }
-
- void normalizeLineEnds(Span const & text);
-
- void skipSpace();
-
- bool skipComment();
-
- void skipProcessingInstruction();
-
- void skipDocumentTypeDeclaration();
-
- Span scanCdataSection();
-
- bool scanName(char const ** nameColon);
-
- Namespace scanNamespaceIri(char const * begin, char const * end);
-
- char const * handleReference(char const * position, char const * end);
-
- Span handleAttributeValue(
- char const * begin, char const * end, bool fullyNormalize);
-
- Result handleStartTag(Namespace * ns, Span * localName);
-
- Result handleEndTag();
-
- void handleElementEnd();
-
- Result handleSkippedText(Span * data, Namespace * ns);
-
- Result handleRawText(Span * text);
-
- Result handleNormalizedText(Span * text);
-
- struct NamespaceData {
- Span prefix;
- Namespace ns;
-
- NamespaceData() {}
-
- NamespaceData(Span const & thePrefix, Namespace theNs):
- prefix(thePrefix), ns(theNs) {}
- };
-
- typedef std::vector< NamespaceData > NamespaceList;
-
- struct ElementData {
- Span name;
- NamespaceList::size_type inheritedNamespaces;
- Namespace defaultNamespace;
-
- ElementData(
- Span const & theName,
- NamespaceList::size_type theInheritedNamespaces,
- Namespace theDefaultNamespace):
- name(theName), inheritedNamespaces(theInheritedNamespaces),
- defaultNamespace(theDefaultNamespace)
- {}
- };
-
- typedef std::stack< ElementData > ElementStack;
-
- struct AttributeData {
- char const * nameBegin;
- char const * nameEnd;
- char const * nameColon;
- char const * valueBegin;
- char const * valueEnd;
-
- AttributeData(
- char const * theNameBegin, char const * theNameEnd,
- char const * theNameColon, char const * theValueBegin,
- char const * theValueEnd):
- nameBegin(theNameBegin), nameEnd(theNameEnd),
- nameColon(theNameColon), valueBegin(theValueBegin),
- valueEnd(theValueEnd)
- {}
- };
-
- typedef std::vector< AttributeData > Attributes;
-
- enum State {
- STATE_CONTENT, STATE_START_TAG, STATE_END_TAG, STATE_EMPTY_ELEMENT_TAG,
- STATE_DONE };
-
- rtl::OUString fileUrl_;
- oslFileHandle fileHandle_;
- sal_uInt64 fileSize_;
- void * fileAddress_;
- NamespaceList namespaces_;
- ElementStack elements_;
- char const * pos_;
- char const * end_;
- State state_;
- Attributes attributes_;
- Attributes::iterator currentAttribute_;
- bool firstAttribute_;
- Pad pad_;
-};
-
-}
-
-#endif