From e9a6e7712a22a7308adc3851fa072af9b566f233 Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 21 Jun 2010 16:48:25 +0200 Subject: sb126: #i110006# removed unused configmgr::Pad::is() --- configmgr/source/pad.cxx | 5 ----- configmgr/source/pad.hxx | 2 -- 2 files changed, 7 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/pad.cxx b/configmgr/source/pad.cxx index c8c7218b6da6..a8169b271bb4 100644 --- a/configmgr/source/pad.cxx +++ b/configmgr/source/pad.cxx @@ -65,11 +65,6 @@ void Pad::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()) { diff --git a/configmgr/source/pad.hxx b/configmgr/source/pad.hxx index 66a51f480023..9f6fbebcda43 100644 --- a/configmgr/source/pad.hxx +++ b/configmgr/source/pad.hxx @@ -45,8 +45,6 @@ public: void clear(); - bool is() const; - Span get() const; private: -- cgit From 4740aded6eb2e45c3565e2b70b29e691d190bad7 Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 21 Jun 2010 17:41:23 +0200 Subject: sb126: #i111970# accept and ignore EnableAsync --- configmgr/source/configurationprovider.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'configmgr') 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( -- cgit From 7a54dffcfbdb0d2e004ad070c35f511cee6642b5 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 10 Sep 2010 13:09:38 +0200 Subject: sb129: #i113189# move XmlReader from configmgr to URE --- configmgr/prj/build.lst | 2 +- configmgr/source/README | 3 - configmgr/source/components.cxx | 4 +- configmgr/source/makefile.mk | 7 +- configmgr/source/pad.cxx | 91 ---- configmgr/source/pad.hxx | 61 --- configmgr/source/parsemanager.cxx | 31 +- configmgr/source/parsemanager.hxx | 13 +- configmgr/source/parser.hxx | 14 +- configmgr/source/span.hxx | 64 --- configmgr/source/valueparser.cxx | 68 +-- configmgr/source/valueparser.hxx | 14 +- configmgr/source/writemodfile.cxx | 35 +- configmgr/source/xcdparser.cxx | 44 +- configmgr/source/xcdparser.hxx | 13 +- configmgr/source/xcsparser.cxx | 167 +++--- configmgr/source/xcsparser.hxx | 27 +- configmgr/source/xcuparser.cxx | 205 ++++---- configmgr/source/xcuparser.hxx | 38 +- configmgr/source/xmldata.cxx | 112 ++-- configmgr/source/xmldata.hxx | 14 +- configmgr/source/xmlreader.cxx | 1054 ------------------------------------- configmgr/source/xmlreader.hxx | 186 ------- 23 files changed, 416 insertions(+), 1851 deletions(-) delete mode 100644 configmgr/source/pad.cxx delete mode 100644 configmgr/source/pad.hxx delete mode 100644 configmgr/source/span.hxx delete mode 100644 configmgr/source/xmlreader.cxx delete mode 100644 configmgr/source/xmlreader.hxx (limited to 'configmgr') diff --git a/configmgr/prj/build.lst b/configmgr/prj/build.lst index 9fcccbc73b4c..bbd0d7f34a9a 100644 --- a/configmgr/prj/build.lst +++ b/configmgr/prj/build.lst @@ -1,4 +1,4 @@ -cg configmgr : BOOST:boost comphelper cppu cppuhelper offuh sal salhelper stlport NULL +cg configmgr : BOOST:boost comphelper cppu cppuhelper offuh sal salhelper stlport xmlreader NULL cg configmgr\inc nmake - all cg_inc NULL cg configmgr\source nmake - all cg_source cg_inc NULL cg configmgr\qa\unoapi nmake - all cg_qa_unoapi NULL diff --git a/configmgr/source/README b/configmgr/source/README index b731043d34ed..e662dd2fd577 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 04e6317c959d..918c80f0a2a6 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -655,8 +655,8 @@ void Components::parseModificationLayer() { OSL_TRACE( "configmgr user registrymodifications.xcu does not (yet) exist"); // Migrate old user layer data (can be removed once migration is no - // longer relevant; also see hack for xsi namespace in XmlReader - // constructor): + // longer relevant; also see hack for xsi namespace in + // xmlreader::XmlReader constructor): parseFiles( Data::NO_LAYER, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".xcu")), &parseXcuFile, diff --git a/configmgr/source/makefile.mk b/configmgr/source/makefile.mk index 777fed3323d8..37235a726ce4 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,7 +74,8 @@ SHL1STDLIBS = \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALHELPERLIB) \ - $(SALLIB) + $(SALLIB) \ + $(XMLREADERLIB) SHL1TARGET = configmgr.uno SHL1USE_EXPORTS = name DEF1NAME = $(SHL1TARGET) 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 -* -* 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/pad.hxx b/configmgr/source/pad.hxx deleted file mode 100644 index 66a51f480023..000000000000 --- a/configmgr/source/pad.hxx +++ /dev/null @@ -1,61 +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 -* -* 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 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 #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/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 -* -* 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 498254b35644..b8092866cb4e 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); 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 79e122759fc8..1c9cd53d7b9a 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; } @@ -338,23 +339,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) { @@ -367,9 +368,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) { @@ -381,7 +382,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); } } @@ -401,38 +402,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) { @@ -461,33 +460,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)); @@ -521,16 +520,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); @@ -549,22 +548,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)); @@ -588,34 +587,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) { @@ -638,27 +635,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 cd1e6e55d085..8a39a3a231ec 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 { @@ -78,22 +79,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)); @@ -101,7 +102,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 >()); @@ -109,7 +110,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); @@ -117,7 +118,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 >()); @@ -125,7 +126,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( @@ -136,14 +137,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( @@ -155,7 +156,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 >()); @@ -164,18 +165,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); @@ -184,19 +185,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( @@ -208,7 +209,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 >()); @@ -219,7 +220,7 @@ bool XcuParser::startElement( return true; } -void XcuParser::endElement(XmlReader const &) { +void XcuParser::endElement(xmlreader::XmlReader const &) { if (valueParser_.endElement()) { return; } @@ -244,11 +245,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; @@ -264,11 +265,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; @@ -276,12 +277,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) { @@ -294,9 +295,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) { @@ -308,13 +309,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)); @@ -336,8 +337,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_); @@ -379,15 +380,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); @@ -400,7 +401,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( @@ -445,21 +446,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( @@ -472,10 +475,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( @@ -485,10 +488,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( @@ -528,27 +531,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( @@ -561,10 +564,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( @@ -574,7 +577,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)); @@ -650,32 +653,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)); @@ -725,8 +730,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: @@ -766,7 +771,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) { @@ -820,7 +825,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()) { @@ -878,28 +883,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)); @@ -949,7 +954,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_); @@ -959,36 +964,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 64108451b4ef..802ed1cd8e50 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 "node.hxx" #include "nodemap.hxx" @@ -42,7 +43,8 @@ #include "type.hxx" #include "valueparser.hxx" #include "xmldata.hxx" -#include "xmlreader.hxx" + +namespace xmlreader { struct Span; } namespace configmgr { @@ -53,7 +55,6 @@ class Partial; class PropertyNode; class SetNode; struct Data; -struct Span; class XcuParser: public Parser { public: @@ -64,49 +65,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(); 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 -* -* for a copy of the LGPLv3 License. -* -************************************************************************/ - -#include "precompiled_configmgr.hxx" -#include "sal/config.h" - -#include - -#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 '()); - } - 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 -* -* for a copy of the LGPLv3 License. -* -************************************************************************/ - -#ifndef INCLUDED_CONFIGMGR_SOURCE_XMLREADER_HXX -#define INCLUDED_CONFIGMGR_SOURCE_XMLREADER_HXX - -#include "sal/config.h" - -#include -#include - -#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 -- cgit From 9551bf5a1ee5c9275a26f8ec4021e0b7f5665176 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 10 Sep 2010 13:10:07 +0200 Subject: sb129: #i113189# change UNO components to use passive registration --- configmgr/prj/d.lst | 1 + configmgr/source/configmgr.component | 45 +++++++++++++++++++++++++++++++++ configmgr/source/makefile.mk | 8 ++++++ configmgr/source/services.cxx | 48 ------------------------------------ 4 files changed, 54 insertions(+), 48 deletions(-) create mode 100644 configmgr/source/configmgr.component (limited to 'configmgr') diff --git a/configmgr/prj/d.lst b/configmgr/prj/d.lst index 17ccdbe86a08..34b6cf3e0010 100644 --- a/configmgr/prj/d.lst +++ b/configmgr/prj/d.lst @@ -1,3 +1,4 @@ ..\%__SRC%\bin\configmgr.uno.dll %_DEST%\bin%_EXT%\configmgr.uno.dll ..\%__SRC%\lib\configmgr.uno.dylib %_DEST%\lib%_EXT%\configmgr.uno.dylib ..\%__SRC%\lib\configmgr.uno.so %_DEST%\lib%_EXT%\configmgr.uno.so +..\%__SRC%\misc\configmgr.component %_DEST%\xml%_EXT%\configmgr.component diff --git a/configmgr/source/configmgr.component b/configmgr/source/configmgr.component new file mode 100644 index 000000000000..6ed51257005d --- /dev/null +++ b/configmgr/source/configmgr.component @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + diff --git a/configmgr/source/makefile.mk b/configmgr/source/makefile.mk index 37235a726ce4..94747d9dd803 100644 --- a/configmgr/source/makefile.mk +++ b/configmgr/source/makefile.mk @@ -81,3 +81,11 @@ 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/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; -} -- cgit From b72a3cc8522b078022b5ae437807970a342fd10c Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 16 Sep 2010 11:00:47 +0200 Subject: sb129: #i113189# adjusted comments --- configmgr/source/components.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configmgr') diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 918c80f0a2a6..64e57a5ddebe 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -656,7 +656,7 @@ void Components::parseModificationLayer() { "configmgr user registrymodifications.xcu does not (yet) exist"); // Migrate old user layer data (can be removed once migration is no // longer relevant; also see hack for xsi namespace in - // xmlreader::XmlReader constructor): + // xmlreader::XmlReader::registerNamespaceIri): parseFiles( Data::NO_LAYER, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".xcu")), &parseXcuFile, -- cgit From afe2be5bf8b540c3211f11bb5dbf02361d6374d6 Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 23 Sep 2010 15:06:54 +0200 Subject: sb132: #i113833# removed unused configmgr::Node::findMember --- configmgr/source/node.cxx | 4 ---- configmgr/source/node.hxx | 5 ++--- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/node.cxx b/configmgr/source/node.cxx index a5a089106b2a..5473b6b1de0c 100644 --- a/configmgr/source/node.cxx +++ b/configmgr/source/node.cxx @@ -101,8 +101,4 @@ Node::~Node() {} void Node::clear() {} -rtl::Reference< Node > Node::findMember(rtl::OUString const &) { - return rtl::Reference< Node >(); -} - } diff --git a/configmgr/source/node.hxx b/configmgr/source/node.hxx index 7c9417e68ea9..f79e7ba296fa 100644 --- a/configmgr/source/node.hxx +++ b/configmgr/source/node.hxx @@ -31,11 +31,12 @@ #include "sal/config.h" #include "rtl/ref.hxx" -#include "rtl/ustring.hxx" #include "salhelper/simplereferenceobject.hxx" #include "nodemap.hxx" +namespace rtl { class OUString; } + namespace configmgr { class Node: public salhelper::SimpleReferenceObject { @@ -75,8 +76,6 @@ protected: virtual void clear(); - virtual rtl::Reference< Node > findMember(rtl::OUString const & name); - int layer_; int finalized_; }; -- cgit From aa04a0319281bd20dec664c146aa920d8a13c5f6 Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 23 Sep 2010 16:17:38 +0200 Subject: sb132: #i114155# use "en" as additional fallback locale after "en-US" --- configmgr/source/childaccess.cxx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx index ef2b213d4ef1..c20fa49fb18c 100644 --- a/configmgr/source/childaccess.cxx +++ b/configmgr/source/childaccess.cxx @@ -283,8 +283,9 @@ css::uno::Any ChildAccess::asValue() { // Find best match using an adaption of RFC 4647 lookup matching // rules, removing "-" or "_" delimited segments from the end; // defaults are the empty string locale, the "en-US" locale, the - // first child (if any), or a nil value (even though it may be - // illegal for the given property), in that order: + // "en" locale, the first child (if any), or a nil value (even + // though it may be illegal for the given property), in that + // order: rtl::Reference< ChildAccess > child; for (;;) { child = getChild(locale); @@ -301,10 +302,14 @@ css::uno::Any ChildAccess::asValue() { child = getChild( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en-US"))); if (!child.is()) { - std::vector< rtl::Reference< ChildAccess > > all( - getAllChildren()); - if (!all.empty()) { - child = all.front(); + child = getChild( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"))); + if (!child.is()) { + std::vector< rtl::Reference< ChildAccess > > all( + getAllChildren()); + if (!all.empty()) { + child = all.front(); + } } } } -- cgit From 1885dddbdd2382f95aef15df15d4cd110f8d7854 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 22 Oct 2010 10:37:46 +0200 Subject: sb131: #i115124# $(XSLTPROC) implies LIBXSLT:libxslt --- configmgr/prj/build.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configmgr') diff --git a/configmgr/prj/build.lst b/configmgr/prj/build.lst index bbd0d7f34a9a..6043290f0914 100644 --- a/configmgr/prj/build.lst +++ b/configmgr/prj/build.lst @@ -1,4 +1,4 @@ -cg configmgr : BOOST:boost comphelper cppu cppuhelper offuh sal salhelper stlport xmlreader NULL +cg configmgr : BOOST:boost LIBXSLT:libxslt comphelper cppu cppuhelper offuh sal salhelper stlport xmlreader NULL cg configmgr\inc nmake - all cg_inc NULL cg configmgr\source nmake - all cg_source cg_inc NULL cg configmgr\qa\unoapi nmake - all cg_qa_unoapi NULL -- cgit From cc065c4937433f944cd7f6e4332f599d5346a5e9 Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 25 Oct 2010 13:41:57 +0200 Subject: sb132: #i112107# getImplementationName should not throw --- configmgr/source/access.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index eda60e6d612a..3602f3cd73c5 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -909,11 +909,8 @@ rtl::OUString Access::getImplementationName() throw (css::uno::RuntimeException) OSL_ASSERT(thisIs(IS_ANY)); osl::MutexGuard g(lock); checkLocalizedPropertyAccess(); - throw css::uno::RuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "configmgr Access has no service implementation name")), - static_cast< cppu::OWeakObject * >(this)); + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("org.openoffice-configmgr::Access")); } sal_Bool Access::supportsService(rtl::OUString const & ServiceName) -- cgit From 7e5eda3334b1fb465e957e00c11c26f0375ce1ca Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 25 Oct 2010 14:43:41 +0200 Subject: sb132: #i115142# component factories should implement XServiceInfo --- configmgr/source/configurationprovider.cxx | 18 ++++++-- configmgr/source/configurationregistry.cxx | 58 ++----------------------- configmgr/source/configurationregistry.hxx | 22 +++++----- configmgr/source/defaultprovider.cxx | 68 +++--------------------------- configmgr/source/defaultprovider.hxx | 22 +++++----- configmgr/source/services.cxx | 15 ++++--- configmgr/source/update.cxx | 56 +----------------------- configmgr/source/update.hxx | 22 +++++----- 8 files changed, 66 insertions(+), 215 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx index 3cd58b145bff..d636737a299e 100644 --- a/configmgr/source/configurationprovider.cxx +++ b/configmgr/source/configurationprovider.cxx @@ -55,7 +55,7 @@ #include "cppu/unotype.hxx" #include "cppuhelper/compbase5.hxx" #include "cppuhelper/factory.hxx" -#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implbase2.hxx" #include "cppuhelper/interfacecontainer.hxx" #include "cppuhelper/weak.hxx" #include "osl/diagnose.h" @@ -127,7 +127,6 @@ private: virtual css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException) { return configuration_provider::getSupportedServiceNames(); } - //TODO: DefaultProvider? virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( rtl::OUString const & aServiceSpecifier) @@ -395,7 +394,8 @@ void Service::flushModifications() const { } class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, + public cppu::WeakImplHelper2< + css::lang::XSingleComponentFactory, css::lang::XServiceInfo >, private boost::noncopyable { public: @@ -414,6 +414,18 @@ private: css::uno::Sequence< css::uno::Any > const & Arguments, css::uno::Reference< css::uno::XComponentContext > const & Context) throw (css::uno::Exception, css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return configuration_provider::getImplementationName(); } + + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } //TODO + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return configuration_provider::getSupportedServiceNames(); } }; css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( diff --git a/configmgr/source/configurationregistry.cxx b/configmgr/source/configurationregistry.cxx index ffd7174c0ad7..f4810eb34ff8 100644 --- a/configmgr/source/configurationregistry.cxx +++ b/configmgr/source/configurationregistry.cxx @@ -36,7 +36,6 @@ #include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/lang/XServiceInfo.hpp" -#include "com/sun/star/lang/XSingleComponentFactory.hpp" #include "com/sun/star/registry/InvalidRegistryException.hpp" #include "com/sun/star/registry/InvalidValueException.hpp" #include "com/sun/star/registry/MergeConflictException.hpp" @@ -56,13 +55,11 @@ #include "com/sun/star/uno/XInterface.hpp" #include "com/sun/star/util/XFlushable.hpp" #include "cppu/unotype.hxx" -#include "cppuhelper/factory.hxx" #include "cppuhelper/implbase1.hxx" #include "cppuhelper/implbase3.hxx" #include "cppuhelper/weak.hxx" #include "osl/diagnose.h" #include "osl/mutex.hxx" -#include "rtl/unload.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" @@ -877,53 +874,12 @@ rtl::OUString RegistryKey::getResolvedName(rtl::OUString const & aKeyName) return aKeyName; } -class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, - private boost::noncopyable -{ -public: - Factory() {} - -private: - virtual ~Factory() {} - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); -}; - -css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) -{ - return createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any >(), Context); } -css::uno::Reference< css::uno::XInterface > -Factory::createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) +css::uno::Reference< css::uno::XInterface > create( + css::uno::Reference< css::uno::XComponentContext > const & context) { - if (Arguments.getLength() != 0) { - throw css::uno::Exception( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationRegistry must be" - " instantiated without arguments")), - static_cast< cppu::OWeakObject * >(this)); - } - return static_cast< cppu::OWeakObject * >(new Service(Context)); -} - + return static_cast< cppu::OWeakObject * >(new Service(context)); } rtl::OUString getImplementationName() { @@ -939,12 +895,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { return css::uno::Sequence< rtl::OUString >(&name, 1); } -css::uno::Reference< css::lang::XSingleComponentFactory > createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()) -{ - return new Factory; -} - } } diff --git a/configmgr/source/configurationregistry.hxx b/configmgr/source/configurationregistry.hxx index 6cba122188b1..417c519b97f4 100644 --- a/configmgr/source/configurationregistry.hxx +++ b/configmgr/source/configurationregistry.hxx @@ -30,28 +30,28 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Sequence.hxx" -#include "cppuhelper/factory.hxx" -#include "rtl/unload.h" #include "sal/types.h" -namespace com { namespace sun { namespace star { namespace lang { - class XSingleComponentFactory; -} } } } +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + class XInterface; + } +} } } namespace rtl { class OUString; } namespace configmgr { namespace configuration_registry { +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL +create( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context); + rtl::OUString SAL_CALL getImplementationName(); com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(); -com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()); - } } #endif diff --git a/configmgr/source/defaultprovider.cxx b/configmgr/source/defaultprovider.cxx index d069663290e8..9079d4736a6c 100644 --- a/configmgr/source/defaultprovider.cxx +++ b/configmgr/source/defaultprovider.cxx @@ -28,24 +28,16 @@ #include "precompiled_configmgr.hxx" #include "sal/config.h" -#include "boost/noncopyable.hpp" -#include "com/sun/star/lang/XSingleComponentFactory.hpp" -#include "com/sun/star/uno/Any.hxx" -#include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Reference.hxx" -#include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" -#include "cppuhelper/factory.hxx" -#include "cppuhelper/implbase1.hxx" -#include "cppuhelper/weak.hxx" -#include "sal/types.h" -#include "rtl/unload.h" +#include "osl/mutex.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "configurationprovider.hxx" +#include "defaultprovider.hxx" #include "lock.hxx" namespace configmgr { namespace default_provider { @@ -54,58 +46,17 @@ namespace { namespace css = com::sun::star; -class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, - private boost::noncopyable -{ -public: - Factory() {} - -private: - virtual ~Factory() {} - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); -}; - -css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) -{ - return createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any >(), Context); } -css::uno::Reference< css::uno::XInterface > -Factory::createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) +css::uno::Reference< css::uno::XInterface > create( + css::uno::Reference< css::uno::XComponentContext > const & context) { - if (Arguments.getLength() != 0) { - throw css::uno::Exception( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.DefaultProvider must be" - " instantiated without arguments")), - static_cast< cppu::OWeakObject * >(this)); - } osl::MutexGuard guard(lock); static css::uno::Reference< css::uno::XInterface > singleton( - configuration_provider::createDefault(Context)); + configuration_provider::createDefault(context)); return singleton; } -} - rtl::OUString getImplementationName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( @@ -119,13 +70,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { return css::uno::Sequence< rtl::OUString >(&name, 1); } -css::uno::Reference< css::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()) -{ - return new Factory; -} - } } diff --git a/configmgr/source/defaultprovider.hxx b/configmgr/source/defaultprovider.hxx index 7b267a80b42e..f678931d35fe 100644 --- a/configmgr/source/defaultprovider.hxx +++ b/configmgr/source/defaultprovider.hxx @@ -32,28 +32,28 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Sequence.hxx" -#include "cppuhelper/factory.hxx" -#include "rtl/unload.h" #include "sal/types.h" -namespace com { namespace sun { namespace star { namespace lang { - class XSingleComponentFactory; -} } } } +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + class XInterface; + } +} } } namespace rtl { class OUString; } namespace configmgr { namespace default_provider { +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL +create( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context); + rtl::OUString SAL_CALL getImplementationName(); com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(); -com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()); - } } #endif diff --git a/configmgr/source/services.cxx b/configmgr/source/services.cxx index b1ef8d2169bb..dd01189be6e2 100644 --- a/configmgr/source/services.cxx +++ b/configmgr/source/services.cxx @@ -32,6 +32,7 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/factory.hxx" #include "cppuhelper/implementationentry.hxx" #include "osl/diagnose.h" #include "uno/lbnames.h" @@ -58,15 +59,17 @@ static cppu::ImplementationEntry const services[] = { { &dummy, &configmgr::configuration_provider::getImplementationName, &configmgr::configuration_provider::getSupportedServiceNames, &configmgr::configuration_provider::createFactory, 0, 0 }, - { &dummy, &configmgr::default_provider::getImplementationName, + { &configmgr::default_provider::create, + &configmgr::default_provider::getImplementationName, &configmgr::default_provider::getSupportedServiceNames, - &configmgr::default_provider::createFactory, 0, 0 }, - { &dummy, &configmgr::configuration_registry::getImplementationName, + &cppu::createSingleComponentFactory, 0, 0 }, + { &configmgr::configuration_registry::create, + &configmgr::configuration_registry::getImplementationName, &configmgr::configuration_registry::getSupportedServiceNames, - &configmgr::configuration_registry::createFactory, 0, 0 }, - { &dummy, &configmgr::update::getImplementationName, + &cppu::createSingleComponentFactory, 0, 0 }, + { &configmgr::update::create, &configmgr::update::getImplementationName, &configmgr::update::getSupportedServiceNames, - &configmgr::update::createFactory, 0, 0 }, + &cppu::createSingleComponentFactory, 0, 0 }, { 0, 0, 0, 0, 0, 0 } }; diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx index 403b761a5abd..73074aa7c338 100644 --- a/configmgr/source/update.cxx +++ b/configmgr/source/update.cxx @@ -32,20 +32,15 @@ #include "boost/noncopyable.hpp" #include "com/sun/star/configuration/XUpdate.hpp" -#include "com/sun/star/lang/XSingleComponentFactory.hpp" -#include "com/sun/star/uno/Any.hxx" -#include "com/sun/star/uno/Exception.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" -#include "cppuhelper/factory.hxx" #include "cppuhelper/implbase1.hxx" #include "cppuhelper/weak.hxx" #include "osl/mutex.hxx" #include "rtl/ref.hxx" -#include "rtl/unload.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" #include "sal/types.h" @@ -155,55 +150,14 @@ void Service::insertModificationXcuFile( bc.send(); } -class Factory: - public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >, - private boost::noncopyable -{ -public: - Factory() {} - -private: - virtual ~Factory() {} - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); - - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException); -}; - -css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext( - css::uno::Reference< css::uno::XComponentContext > const & Context) - throw (css::uno::Exception, css::uno::RuntimeException) -{ - return createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any >(), Context); } -css::uno::Reference< css::uno::XInterface > -Factory::createInstanceWithArgumentsAndContext( - css::uno::Sequence< css::uno::Any > const & Arguments, +css::uno::Reference< css::uno::XInterface > create( css::uno::Reference< css::uno::XComponentContext > const &) - throw (css::uno::Exception, css::uno::RuntimeException) { - if (Arguments.getLength() != 0) { - throw css::uno::Exception( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.configuration.Update must be" - " instantiated without arguments")), - static_cast< cppu::OWeakObject * >(this)); - } return static_cast< cppu::OWeakObject * >(new Service); } -} - rtl::OUString getImplementationName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.Update")); @@ -216,12 +170,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() { return css::uno::Sequence< rtl::OUString >(&name, 1); } -css::uno::Reference< css::lang::XSingleComponentFactory > createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()) -{ - return new Factory; -} - } } diff --git a/configmgr/source/update.hxx b/configmgr/source/update.hxx index faa5c86b15fa..a60264e67ac3 100644 --- a/configmgr/source/update.hxx +++ b/configmgr/source/update.hxx @@ -32,28 +32,28 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/Sequence.hxx" -#include "cppuhelper/factory.hxx" -#include "rtl/unload.h" #include "sal/types.h" -namespace com { namespace sun { namespace star { namespace lang { - class XSingleComponentFactory; -} } } } +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + class XInterface; + } +} } } namespace rtl { class OUString; } namespace configmgr { namespace update { +com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL +create( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const &); + rtl::OUString SAL_CALL getImplementationName(); com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(); -com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory > -SAL_CALL createFactory( - cppu::ComponentFactoryFunc, rtl::OUString const &, - com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *) - SAL_THROW(()); - } } #endif -- cgit From 9bb0061938a0c76a1b221a214dff8afe0bcdcb4e Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 28 Oct 2010 16:37:27 +0200 Subject: sb132: #i114877# combined configmgr::Components::{init,get}Singleton --- configmgr/source/components.cxx | 6 +----- configmgr/source/components.hxx | 4 +--- configmgr/source/configurationprovider.cxx | 6 ++---- configmgr/source/update.cxx | 30 +++++++++++++++++++----------- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 32478e96813d..2d148959edfc 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -214,7 +214,7 @@ void Components::WriteThread::run() { reference_->clear(); } -void Components::initSingleton( +Components & Components::getSingleton( css::uno::Reference< css::uno::XComponentContext > const & context) { OSL_ASSERT(context.is()); @@ -223,10 +223,6 @@ void Components::initSingleton( static Components theSingleton(context); singleton = &theSingleton; } -} - -Components & Components::getSingleton() { - OSL_ASSERT(singletonCreated); if (singleton == 0) { throw css::uno::RuntimeException( rtl::OUString( diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx index 1c735efca6ba..34b693c7e585 100644 --- a/configmgr/source/components.hxx +++ b/configmgr/source/components.hxx @@ -65,12 +65,10 @@ class RootAccess; class Components: private boost::noncopyable { public: - static void initSingleton( + static Components & getSingleton( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context); - static Components & getSingleton(); - static bool allLocales(rtl::OUString const & locale); rtl::Reference< Node > resolvePathRepresentation( diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx index d636737a299e..999253118f11 100644 --- a/configmgr/source/configurationprovider.cxx +++ b/configmgr/source/configurationprovider.cxx @@ -275,8 +275,7 @@ Service::createInstanceWithArguments( static_cast< cppu::OWeakObject * >(this)); } osl::MutexGuard guard(lock); - Components::initSingleton(context_); - Components & components = Components::getSingleton(); + Components & components = Components::getSingleton(context_); rtl::Reference< RootAccess > root( new RootAccess(components, nodepath, locale, update)); if (root->isValue()) { @@ -387,8 +386,7 @@ void Service::flushModifications() const { Components * components; { osl::MutexGuard guard(lock); - Components::initSingleton(context_); - components = &Components::getSingleton(); + components = &Components::getSingleton(context_); } components->flushModifications(); } diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx index 73074aa7c338..258765158aa3 100644 --- a/configmgr/source/update.cxx +++ b/configmgr/source/update.cxx @@ -71,7 +71,11 @@ class Service: private boost::noncopyable { public: - Service() {} + Service(css::uno::Reference< css::uno::XComponentContext > const context): + context_(context) + { + OSL_ASSERT(context.is()); + } private: virtual ~Service() {} @@ -92,6 +96,8 @@ private: css::uno::Sequence< rtl::OUString > const & includedPaths, css::uno::Sequence< rtl::OUString > const & excludedPaths) throw (css::uno::RuntimeException); + + css::uno::Reference< css::uno::XComponentContext > context_; }; void Service::insertExtensionXcsFile( @@ -99,7 +105,7 @@ void Service::insertExtensionXcsFile( throw (css::uno::RuntimeException) { osl::MutexGuard g(lock); - Components::getSingleton().insertExtensionXcsFile(shared, fileUri); + Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri); } void Service::insertExtensionXcuFile( @@ -109,10 +115,10 @@ void Service::insertExtensionXcuFile( Broadcaster bc; { osl::MutexGuard g(lock); + Components & components = Components::getSingleton(context_); Modifications mods; - Components::getSingleton().insertExtensionXcuFile( - shared, fileUri, &mods); - Components::getSingleton().initGlobalBroadcaster( + components.insertExtensionXcuFile(shared, fileUri, &mods); + components.initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } bc.send(); @@ -124,9 +130,10 @@ void Service::removeExtensionXcuFile(rtl::OUString const & fileUri) Broadcaster bc; { osl::MutexGuard g(lock); + Components & components = Components::getSingleton(context_); Modifications mods; - Components::getSingleton().removeExtensionXcuFile(fileUri, &mods); - Components::getSingleton().initGlobalBroadcaster( + components.removeExtensionXcuFile(fileUri, &mods); + components.initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } bc.send(); @@ -141,10 +148,11 @@ void Service::insertModificationXcuFile( Broadcaster bc; { osl::MutexGuard g(lock); + Components & components = Components::getSingleton(context_); Modifications mods; - Components::getSingleton().insertModificationXcuFile( + components.insertModificationXcuFile( fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods); - Components::getSingleton().initGlobalBroadcaster( + components.initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } bc.send(); @@ -153,9 +161,9 @@ void Service::insertModificationXcuFile( } css::uno::Reference< css::uno::XInterface > create( - css::uno::Reference< css::uno::XComponentContext > const &) + css::uno::Reference< css::uno::XComponentContext > const & context) { - return static_cast< cppu::OWeakObject * >(new Service); + return static_cast< cppu::OWeakObject * >(new Service(context)); } rtl::OUString getImplementationName() { -- cgit From de8fef0d3ff128ca58c1da252f3a1a44931bd9ba Mon Sep 17 00:00:00 2001 From: sb Date: Wed, 3 Nov 2010 16:15:15 +0100 Subject: sb132: #i112107# handle configmgr::Access::asProperty being called on an access w/o parent --- configmgr/source/access.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'configmgr') diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 3602f3cd73c5..933a414d331c 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -2089,7 +2089,8 @@ css::beans::Property Access::asProperty() { default: type = cppu::UnoType< css::uno::XInterface >::get(); //TODO: correct? nillable = false; - removable = getParentNode()->kind() == Node::KIND_SET; + rtl::Reference< Node > parent(getParentNode()); + removable = parent.is() && parent->kind() == Node::KIND_SET; break; } return css::beans::Property( -- cgit From 64dcaa7199870f0c03403df10a5ae9d028b9c7b6 Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 10 Jan 2011 13:49:30 +0100 Subject: sb139: #i77102# forget about configmgr user-layer removals that no longer remove anything --- configmgr/source/xcuparser.cxx | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index 1a9575bb6726..dc5d08cb4e08 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -1099,17 +1099,25 @@ void XcuParser::handleSetNode(xmlreader::XmlReader & reader, SetNode * set) { } break; case OPERATION_REMOVE: - // Ignore removal of unknown members, members finalized in a lower - // layer, and members made mandatory in this or a lower layer: - if (i != set->getMembers().end() && !state_.top().locked && - finalizedLayer >= valueParser_.getLayer() && - mandatoryLayer > valueParser_.getLayer()) { - set->getMembers().erase(i); + // Ignore removal of unknown members, members finalized in a lower + // layer, and members made mandatory in this or a lower layer; + // forget about user-layer removals that no longer remove anything + // (so that paired additions/removals in the user layer do not grow + // registrymodifications.xcu unbounded): + bool known = i != set->getMembers().end(); + if (known && !state_.top().locked && + finalizedLayer >= valueParser_.getLayer() && + mandatoryLayer > valueParser_.getLayer()) + { + set->getMembers().erase(i); + } + state_.push(State(true)); + if (known) { + recordModification(false); + } + break; } - state_.push(State(true)); - recordModification(false); - break; } } -- cgit From 93f059dfb6d817afaff56694f242dba3a1897c3b Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 10 Jan 2011 16:45:42 +0100 Subject: sb139: #i116391# for backwards compatibility, allow absolute paths in configmgr getByHierarchicalName et al --- configmgr/source/access.cxx | 100 ++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 31 deletions(-) (limited to 'configmgr') diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 933a414d331c..2548643c7ce1 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -1993,45 +1993,83 @@ rtl::Reference< ChildAccess > Access::getUnmodifiedChild( } rtl::Reference< ChildAccess > Access::getSubChild(rtl::OUString const & path) { - rtl::OUString name; - bool setElement; - rtl::OUString templateName; - sal_Int32 i = Data::parseSegment( - path, 0, &name, &setElement, &templateName); - if (i == -1 || (i != path.getLength() && path[i] != '/')) { - return rtl::Reference< ChildAccess >(); - } - rtl::Reference< ChildAccess > child(getChild(name)); - if (!child.is()) { - return rtl::Reference< ChildAccess >(); - } - if (setElement) { - rtl::Reference< Node > p(getNode()); - switch (p->kind()) { - case Node::KIND_LOCALIZED_PROPERTY: - if (!Components::allLocales(getRootAccess()->getLocale()) || - templateName.getLength() != 0) - { + sal_Int32 i = 0; + // For backwards compatibility, allow absolute paths where meaningful: + if (path.getLength() != 0 && path[0] == '/') { + ++i; + if (!getRootAccess().is()) { + return rtl::Reference< ChildAccess >(); + } + Path abs(getAbsolutePath()); + for (Path::iterator j(abs.begin()); j != abs.end(); ++j) { + rtl::OUString name1; + bool setElement1; + rtl::OUString templateName1; + i = Data::parseSegment( + path, i, &name1, &setElement1, &templateName1); + if (i == -1 || (i != path.getLength() && path[i] != '/')) { return rtl::Reference< ChildAccess >(); } - break; - case Node::KIND_SET: - if (templateName.getLength() != 0 && - !dynamic_cast< SetNode * >(p.get())->isValidTemplate( - templateName)) + rtl::OUString name2; + bool setElement2; + rtl::OUString templateName2; + Data::parseSegment(*j, 0, &name2, &setElement2, &templateName2); + if (name1 != name2 || setElement1 != setElement2 || + (setElement1 && + !Data::equalTemplateNames(templateName1, templateName2))) { return rtl::Reference< ChildAccess >(); } - break; - default: + if (i != path.getLength()) { + ++i; + } + } + } + for (rtl::Reference< Access > parent(this);;) { + rtl::OUString name; + bool setElement; + rtl::OUString templateName; + i = Data::parseSegment(path, i, &name, &setElement, &templateName); + if (i == -1 || (i != path.getLength() && path[i] != '/')) { return rtl::Reference< ChildAccess >(); } + rtl::Reference< ChildAccess > child(parent->getChild(name)); + if (!child.is()) { + return rtl::Reference< ChildAccess >(); + } + if (setElement) { + rtl::Reference< Node > p(parent->getNode()); + switch (p->kind()) { + case Node::KIND_LOCALIZED_PROPERTY: + if (!Components::allLocales(getRootAccess()->getLocale()) || + templateName.getLength() != 0) + { + return rtl::Reference< ChildAccess >(); + } + break; + case Node::KIND_SET: + if (templateName.getLength() != 0 && + !dynamic_cast< SetNode * >(p.get())->isValidTemplate( + templateName)) + { + return rtl::Reference< ChildAccess >(); + } + break; + default: + return rtl::Reference< ChildAccess >(); + } + } + // For backwards compatibility, ignore a final slash after non-value + // nodes: + if (child->isValue()) { + return i == path.getLength() + ? child : rtl::Reference< ChildAccess >(); + } else if (i >= path.getLength() - 1) { + return child; + } + ++i; + parent = child.get(); } - // For backwards compatibility, ignore a final slash after non-value nodes: - return child->isValue() - ? (i == path.getLength() ? child : rtl::Reference< ChildAccess >()) - : (i >= path.getLength() - 1 - ? child : child->getSubChild(path.copy(i + 1))); } bool Access::setChildProperty( -- cgit