xref: /AOO41X/main/stoc/source/simpleregistry/textualservices.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir *
3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir *
5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir *
7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir *
9*cdf0e10cSrcweir * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir *
11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir *
15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir *
21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir *
26*cdf0e10cSrcweir ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "precompiled_stoc.hxx"
29*cdf0e10cSrcweir #include "sal/config.h"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <cstddef>
32*cdf0e10cSrcweir #include <cstdlib>
33*cdf0e10cSrcweir #include <map>
34*cdf0e10cSrcweir #include <vector>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "boost/noncopyable.hpp"
37*cdf0e10cSrcweir #include "com/sun/star/container/NoSuchElementException.hpp"
38*cdf0e10cSrcweir #include "com/sun/star/registry/InvalidRegistryException.hpp"
39*cdf0e10cSrcweir #include "com/sun/star/registry/XRegistryKey.hpp"
40*cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
41*cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp"
42*cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx"
43*cdf0e10cSrcweir #include "osl/diagnose.h"
44*cdf0e10cSrcweir #include "rtl/malformeduriexception.hxx"
45*cdf0e10cSrcweir #include "rtl/ref.hxx"
46*cdf0e10cSrcweir #include "rtl/string.h"
47*cdf0e10cSrcweir #include "rtl/uri.hxx"
48*cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
49*cdf0e10cSrcweir #include "rtl/ustring.h"
50*cdf0e10cSrcweir #include "rtl/ustring.hxx"
51*cdf0e10cSrcweir #include "salhelper/simplereferenceobject.hxx"
52*cdf0e10cSrcweir #include "xmlreader/span.hxx"
53*cdf0e10cSrcweir #include "xmlreader/xmlreader.hxx"
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include "textualservices.hxx"
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir namespace stoc { namespace simpleregistry {
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir namespace {
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace css = com::sun::star;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir struct Implementation {
64*cdf0e10cSrcweir     rtl::OUString uri;
65*cdf0e10cSrcweir     rtl::OUString loader;
66*cdf0e10cSrcweir     std::vector< rtl::OUString > services;
67*cdf0e10cSrcweir     std::vector< rtl::OUString > singletons;
68*cdf0e10cSrcweir };
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir typedef std::map< rtl::OUString, Implementation > Implementations;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir typedef std::map< rtl::OUString, std::vector< rtl::OUString > >
73*cdf0e10cSrcweir     ImplementationMap;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir class Data: public salhelper::SimpleReferenceObject, private boost::noncopyable
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir public:
80*cdf0e10cSrcweir     Implementations implementations;
81*cdf0e10cSrcweir     ImplementationMap services;
82*cdf0e10cSrcweir     ImplementationMap singletons;
83*cdf0e10cSrcweir };
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir namespace {
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir class Parser: private boost::noncopyable {
88*cdf0e10cSrcweir public:
89*cdf0e10cSrcweir     Parser(rtl::OUString const & uri, rtl::Reference< Data > const & data);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir private:
92*cdf0e10cSrcweir     void handleComponent();
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     void handleImplementation();
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     void handleService();
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     void handleSingleton();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     rtl::OUString getNameAttribute();
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     xmlreader::XmlReader reader_;
103*cdf0e10cSrcweir     rtl::Reference< Data > data_;
104*cdf0e10cSrcweir     rtl::OUString attrUri_;
105*cdf0e10cSrcweir     rtl::OUString attrLoader_;
106*cdf0e10cSrcweir     rtl::OUString attrImplementation_;
107*cdf0e10cSrcweir };
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir Parser::Parser(rtl::OUString const & uri, rtl::Reference< Data > const & data):
110*cdf0e10cSrcweir     reader_(uri), data_(data)
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir     OSL_ASSERT(data.is());
113*cdf0e10cSrcweir     int ucNsId = reader_.registerNamespaceIri(
114*cdf0e10cSrcweir         xmlreader::Span(
115*cdf0e10cSrcweir             RTL_CONSTASCII_STRINGPARAM(
116*cdf0e10cSrcweir                 "http://openoffice.org/2010/uno-components")));
117*cdf0e10cSrcweir     enum State {
118*cdf0e10cSrcweir         STATE_BEGIN, STATE_END, STATE_COMPONENTS, STATE_COMPONENT_INITIAL,
119*cdf0e10cSrcweir         STATE_COMPONENT, STATE_IMPLEMENTATION, STATE_SERVICE, STATE_SINGLETON };
120*cdf0e10cSrcweir     for (State state = STATE_BEGIN;;) {
121*cdf0e10cSrcweir         xmlreader::Span name;
122*cdf0e10cSrcweir         int nsId;
123*cdf0e10cSrcweir         xmlreader::XmlReader::Result res = reader_.nextItem(
124*cdf0e10cSrcweir             xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
125*cdf0e10cSrcweir         switch (state) {
126*cdf0e10cSrcweir         case STATE_BEGIN:
127*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId &&
128*cdf0e10cSrcweir                 name.equals(RTL_CONSTASCII_STRINGPARAM("components")))
129*cdf0e10cSrcweir             {
130*cdf0e10cSrcweir                 state = STATE_COMPONENTS;
131*cdf0e10cSrcweir                 break;
132*cdf0e10cSrcweir             }
133*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
134*cdf0e10cSrcweir                 (reader_.getUrl() +
135*cdf0e10cSrcweir                  rtl::OUString(
136*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
137*cdf0e10cSrcweir                          ": unexpected item in outer level"))),
138*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
139*cdf0e10cSrcweir         case STATE_END:
140*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_DONE) {
141*cdf0e10cSrcweir                 return;
142*cdf0e10cSrcweir             }
143*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
144*cdf0e10cSrcweir                 (reader_.getUrl() +
145*cdf0e10cSrcweir                  rtl::OUString(
146*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
147*cdf0e10cSrcweir                          ": unexpected item in outer level"))),
148*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
149*cdf0e10cSrcweir         case STATE_COMPONENTS:
150*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_END) {
151*cdf0e10cSrcweir                 state = STATE_END;
152*cdf0e10cSrcweir                 break;
153*cdf0e10cSrcweir             }
154*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId &&
155*cdf0e10cSrcweir                 name.equals(RTL_CONSTASCII_STRINGPARAM("component")))
156*cdf0e10cSrcweir             {
157*cdf0e10cSrcweir                 handleComponent();
158*cdf0e10cSrcweir                 state = STATE_COMPONENT_INITIAL;
159*cdf0e10cSrcweir                 break;
160*cdf0e10cSrcweir             }
161*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
162*cdf0e10cSrcweir                 (reader_.getUrl() +
163*cdf0e10cSrcweir                  rtl::OUString(
164*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
165*cdf0e10cSrcweir                          ": unexpected item in <components>"))),
166*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
167*cdf0e10cSrcweir         case STATE_COMPONENT:
168*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_END) {
169*cdf0e10cSrcweir                 state = STATE_COMPONENTS;
170*cdf0e10cSrcweir                 break;
171*cdf0e10cSrcweir             }
172*cdf0e10cSrcweir             // fall through
173*cdf0e10cSrcweir         case STATE_COMPONENT_INITIAL:
174*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId &&
175*cdf0e10cSrcweir                 name.equals(RTL_CONSTASCII_STRINGPARAM("implementation")))
176*cdf0e10cSrcweir             {
177*cdf0e10cSrcweir                 handleImplementation();
178*cdf0e10cSrcweir                 state = STATE_IMPLEMENTATION;
179*cdf0e10cSrcweir                 break;
180*cdf0e10cSrcweir             }
181*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
182*cdf0e10cSrcweir                 (reader_.getUrl() +
183*cdf0e10cSrcweir                  rtl::OUString(
184*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
185*cdf0e10cSrcweir                          ": unexpected item in <component>"))),
186*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
187*cdf0e10cSrcweir         case STATE_IMPLEMENTATION:
188*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_END) {
189*cdf0e10cSrcweir                 state = STATE_COMPONENT;
190*cdf0e10cSrcweir                 break;
191*cdf0e10cSrcweir             }
192*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId &&
193*cdf0e10cSrcweir                 name.equals(RTL_CONSTASCII_STRINGPARAM("service")))
194*cdf0e10cSrcweir             {
195*cdf0e10cSrcweir                 handleService();
196*cdf0e10cSrcweir                 state = STATE_SERVICE;
197*cdf0e10cSrcweir                 break;
198*cdf0e10cSrcweir             }
199*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId &&
200*cdf0e10cSrcweir                 name.equals(RTL_CONSTASCII_STRINGPARAM("singleton")))
201*cdf0e10cSrcweir             {
202*cdf0e10cSrcweir                 handleSingleton();
203*cdf0e10cSrcweir                 state = STATE_SINGLETON;
204*cdf0e10cSrcweir                 break;
205*cdf0e10cSrcweir             }
206*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
207*cdf0e10cSrcweir                 (reader_.getUrl() +
208*cdf0e10cSrcweir                  rtl::OUString(
209*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
210*cdf0e10cSrcweir                          ": unexpected item in <implementation>"))),
211*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
212*cdf0e10cSrcweir         case STATE_SERVICE:
213*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_END) {
214*cdf0e10cSrcweir                 state = STATE_IMPLEMENTATION;
215*cdf0e10cSrcweir                 break;
216*cdf0e10cSrcweir             }
217*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
218*cdf0e10cSrcweir                 (reader_.getUrl() +
219*cdf0e10cSrcweir                  rtl::OUString(
220*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
221*cdf0e10cSrcweir                          ": unexpected item in <service>"))),
222*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
223*cdf0e10cSrcweir         case STATE_SINGLETON:
224*cdf0e10cSrcweir             if (res == xmlreader::XmlReader::RESULT_END) {
225*cdf0e10cSrcweir                 state = STATE_IMPLEMENTATION;
226*cdf0e10cSrcweir                 break;
227*cdf0e10cSrcweir             }
228*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
229*cdf0e10cSrcweir                 (reader_.getUrl() +
230*cdf0e10cSrcweir                  rtl::OUString(
231*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
232*cdf0e10cSrcweir                          ": unexpected item in <service>"))),
233*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
234*cdf0e10cSrcweir         }
235*cdf0e10cSrcweir     }
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir void Parser::handleComponent() {
239*cdf0e10cSrcweir     attrUri_ = rtl::OUString();
240*cdf0e10cSrcweir     attrLoader_ = rtl::OUString();
241*cdf0e10cSrcweir     xmlreader::Span name;
242*cdf0e10cSrcweir     int nsId;
243*cdf0e10cSrcweir     while (reader_.nextAttribute(&nsId, &name)) {
244*cdf0e10cSrcweir         if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
245*cdf0e10cSrcweir             name.equals(RTL_CONSTASCII_STRINGPARAM("uri")))
246*cdf0e10cSrcweir         {
247*cdf0e10cSrcweir             if (attrUri_.getLength() != 0) {
248*cdf0e10cSrcweir                 throw css::registry::InvalidRegistryException(
249*cdf0e10cSrcweir                     (reader_.getUrl() +
250*cdf0e10cSrcweir                      rtl::OUString(
251*cdf0e10cSrcweir                          RTL_CONSTASCII_USTRINGPARAM(
252*cdf0e10cSrcweir                              ": <component> has multiple \"uri\" attributes"))),
253*cdf0e10cSrcweir                     css::uno::Reference< css::uno::XInterface >());
254*cdf0e10cSrcweir             }
255*cdf0e10cSrcweir             attrUri_ = reader_.getAttributeValue(false).convertFromUtf8();
256*cdf0e10cSrcweir             if (attrUri_.getLength() == 0) {
257*cdf0e10cSrcweir                 throw css::registry::InvalidRegistryException(
258*cdf0e10cSrcweir                     (reader_.getUrl() +
259*cdf0e10cSrcweir                      rtl::OUString(
260*cdf0e10cSrcweir                          RTL_CONSTASCII_USTRINGPARAM(
261*cdf0e10cSrcweir                              ": <component> has empty \"uri\" attribute"))),
262*cdf0e10cSrcweir                     css::uno::Reference< css::uno::XInterface >());
263*cdf0e10cSrcweir             }
264*cdf0e10cSrcweir         } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
265*cdf0e10cSrcweir                    name.equals(RTL_CONSTASCII_STRINGPARAM("loader")))
266*cdf0e10cSrcweir         {
267*cdf0e10cSrcweir             if (attrLoader_.getLength() != 0) {
268*cdf0e10cSrcweir                 throw css::registry::InvalidRegistryException(
269*cdf0e10cSrcweir                     (reader_.getUrl() +
270*cdf0e10cSrcweir                      rtl::OUString(
271*cdf0e10cSrcweir                          RTL_CONSTASCII_USTRINGPARAM(
272*cdf0e10cSrcweir                              ": <component> has multiple \"loader\""
273*cdf0e10cSrcweir                              " attributes"))),
274*cdf0e10cSrcweir                     css::uno::Reference< css::uno::XInterface >());
275*cdf0e10cSrcweir             }
276*cdf0e10cSrcweir             attrLoader_ = reader_.getAttributeValue(false).convertFromUtf8();
277*cdf0e10cSrcweir             if (attrLoader_.getLength() == 0) {
278*cdf0e10cSrcweir                 throw css::registry::InvalidRegistryException(
279*cdf0e10cSrcweir                     (reader_.getUrl() +
280*cdf0e10cSrcweir                      rtl::OUString(
281*cdf0e10cSrcweir                          RTL_CONSTASCII_USTRINGPARAM(
282*cdf0e10cSrcweir                              ": <component> has empty \"loader\" attribute"))),
283*cdf0e10cSrcweir                     css::uno::Reference< css::uno::XInterface >());
284*cdf0e10cSrcweir             }
285*cdf0e10cSrcweir         } else {
286*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
287*cdf0e10cSrcweir                 (reader_.getUrl() +
288*cdf0e10cSrcweir                  rtl::OUString(
289*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
290*cdf0e10cSrcweir                          ": expected <component> attribute \"uri\" or"
291*cdf0e10cSrcweir                          " \"loader\""))),
292*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
293*cdf0e10cSrcweir         }
294*cdf0e10cSrcweir     }
295*cdf0e10cSrcweir     if (attrUri_.getLength() == 0) {
296*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
297*cdf0e10cSrcweir             (reader_.getUrl() +
298*cdf0e10cSrcweir              rtl::OUString(
299*cdf0e10cSrcweir                  RTL_CONSTASCII_USTRINGPARAM(
300*cdf0e10cSrcweir                      ": <component> is missing \"uri\" attribute"))),
301*cdf0e10cSrcweir             css::uno::Reference< css::uno::XInterface >());
302*cdf0e10cSrcweir     }
303*cdf0e10cSrcweir     if (attrLoader_.getLength() == 0) {
304*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
305*cdf0e10cSrcweir             (reader_.getUrl() +
306*cdf0e10cSrcweir              rtl::OUString(
307*cdf0e10cSrcweir                  RTL_CONSTASCII_USTRINGPARAM(
308*cdf0e10cSrcweir                      ": <component> is missing \"loader\" attribute"))),
309*cdf0e10cSrcweir             css::uno::Reference< css::uno::XInterface >());
310*cdf0e10cSrcweir     }
311*cdf0e10cSrcweir     try {
312*cdf0e10cSrcweir         attrUri_ = rtl::Uri::convertRelToAbs(reader_.getUrl(), attrUri_);
313*cdf0e10cSrcweir     } catch (rtl::MalformedUriException & e) {
314*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
315*cdf0e10cSrcweir             (reader_.getUrl() +
316*cdf0e10cSrcweir              rtl::OUString(
317*cdf0e10cSrcweir                  RTL_CONSTASCII_USTRINGPARAM(": bad \"uri\" attribute: ")) +
318*cdf0e10cSrcweir              e.getMessage()),
319*cdf0e10cSrcweir             css::uno::Reference< css::uno::XInterface >());
320*cdf0e10cSrcweir     }
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir void Parser::handleImplementation() {
324*cdf0e10cSrcweir     attrImplementation_ = getNameAttribute();
325*cdf0e10cSrcweir     if (data_->implementations.find(attrImplementation_) !=
326*cdf0e10cSrcweir         data_->implementations.end())
327*cdf0e10cSrcweir     {
328*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
329*cdf0e10cSrcweir             (reader_.getUrl() +
330*cdf0e10cSrcweir              rtl::OUString(
331*cdf0e10cSrcweir                  RTL_CONSTASCII_USTRINGPARAM(
332*cdf0e10cSrcweir                      ": duplicate <implementation name=\"")) +
333*cdf0e10cSrcweir              attrImplementation_ +
334*cdf0e10cSrcweir              rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\">"))),
335*cdf0e10cSrcweir             css::uno::Reference< css::uno::XInterface >());
336*cdf0e10cSrcweir     }
337*cdf0e10cSrcweir     data_->implementations[attrImplementation_].uri = attrUri_;
338*cdf0e10cSrcweir     data_->implementations[attrImplementation_].loader = attrLoader_;
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir void Parser::handleService() {
342*cdf0e10cSrcweir     rtl::OUString name = getNameAttribute();
343*cdf0e10cSrcweir     data_->implementations[attrImplementation_].services.push_back(name);
344*cdf0e10cSrcweir     data_->services[name].push_back(attrImplementation_);
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir void Parser::handleSingleton() {
348*cdf0e10cSrcweir     rtl::OUString name = getNameAttribute();
349*cdf0e10cSrcweir     data_->implementations[attrImplementation_].singletons.push_back(name);
350*cdf0e10cSrcweir     data_->singletons[name].push_back(attrImplementation_);
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir rtl::OUString Parser::getNameAttribute() {
354*cdf0e10cSrcweir     rtl::OUString attrName;
355*cdf0e10cSrcweir     xmlreader::Span name;
356*cdf0e10cSrcweir     int nsId;
357*cdf0e10cSrcweir     while (reader_.nextAttribute(&nsId, &name)) {
358*cdf0e10cSrcweir         if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
359*cdf0e10cSrcweir             name.equals(RTL_CONSTASCII_STRINGPARAM("name")))
360*cdf0e10cSrcweir         {
361*cdf0e10cSrcweir             if (attrName.getLength() != 0) {
362*cdf0e10cSrcweir                 throw css::registry::InvalidRegistryException(
363*cdf0e10cSrcweir                     (reader_.getUrl() +
364*cdf0e10cSrcweir                      rtl::OUString(
365*cdf0e10cSrcweir                          RTL_CONSTASCII_USTRINGPARAM(
366*cdf0e10cSrcweir                              ": element has multiple \"name\" attributes"))),
367*cdf0e10cSrcweir                     css::uno::Reference< css::uno::XInterface >());
368*cdf0e10cSrcweir             }
369*cdf0e10cSrcweir             attrName = reader_.getAttributeValue(false).convertFromUtf8();
370*cdf0e10cSrcweir             if (attrName.getLength() == 0) {
371*cdf0e10cSrcweir                 throw css::registry::InvalidRegistryException(
372*cdf0e10cSrcweir                     (reader_.getUrl() +
373*cdf0e10cSrcweir                      rtl::OUString(
374*cdf0e10cSrcweir                          RTL_CONSTASCII_USTRINGPARAM(
375*cdf0e10cSrcweir                              ": element has empty \"name\" attribute"))),
376*cdf0e10cSrcweir                     css::uno::Reference< css::uno::XInterface >());
377*cdf0e10cSrcweir             }
378*cdf0e10cSrcweir         } else {
379*cdf0e10cSrcweir             throw css::registry::InvalidRegistryException(
380*cdf0e10cSrcweir                 (reader_.getUrl() +
381*cdf0e10cSrcweir                  rtl::OUString(
382*cdf0e10cSrcweir                      RTL_CONSTASCII_USTRINGPARAM(
383*cdf0e10cSrcweir                          ": expected element attribute \"name\""))),
384*cdf0e10cSrcweir                 css::uno::Reference< css::uno::XInterface >());
385*cdf0e10cSrcweir         }
386*cdf0e10cSrcweir     }
387*cdf0e10cSrcweir     if (attrName.getLength() == 0) {
388*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
389*cdf0e10cSrcweir             (reader_.getUrl() +
390*cdf0e10cSrcweir              rtl::OUString(
391*cdf0e10cSrcweir                  RTL_CONSTASCII_USTRINGPARAM(
392*cdf0e10cSrcweir                      ": element is missing \"name\" attribute"))),
393*cdf0e10cSrcweir             css::uno::Reference< css::uno::XInterface >());
394*cdf0e10cSrcweir     }
395*cdf0e10cSrcweir     return attrName;
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir rtl::OUString pathToString(std::vector< rtl::OUString > const & path) {
399*cdf0e10cSrcweir     rtl::OUStringBuffer buf;
400*cdf0e10cSrcweir     for (std::vector< rtl::OUString >::const_iterator i(path.begin());
401*cdf0e10cSrcweir          i != path.end(); ++i)
402*cdf0e10cSrcweir     {
403*cdf0e10cSrcweir         buf.append(sal_Unicode('/'));
404*cdf0e10cSrcweir         buf.append(*i);
405*cdf0e10cSrcweir     }
406*cdf0e10cSrcweir     if (buf.getLength() == 0) {
407*cdf0e10cSrcweir         buf.append(sal_Unicode('/'));
408*cdf0e10cSrcweir     }
409*cdf0e10cSrcweir     return buf.makeStringAndClear();
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir class Key: public cppu::WeakImplHelper1< css::registry::XRegistryKey > {
413*cdf0e10cSrcweir public:
414*cdf0e10cSrcweir     Key(
415*cdf0e10cSrcweir         rtl::Reference< Data > const & data,
416*cdf0e10cSrcweir         std::vector< rtl::OUString > const & path):
417*cdf0e10cSrcweir         data_(data), path_(path) { OSL_ASSERT(data.is());
418*cdf0e10cSrcweir  }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir private:
421*cdf0e10cSrcweir     /*
422*cdf0e10cSrcweir       /
423*cdf0e10cSrcweir         IMPLEMENTATIONS
424*cdf0e10cSrcweir           <implementation>
425*cdf0e10cSrcweir             UNO
426*cdf0e10cSrcweir               LOCATION utf-8
427*cdf0e10cSrcweir               ACTIVATOR utf-8
428*cdf0e10cSrcweir               SERVICES
429*cdf0e10cSrcweir                 <service>
430*cdf0e10cSrcweir                 ...
431*cdf0e10cSrcweir               SINGLETONS
432*cdf0e10cSrcweir                 <singleton> utf-16
433*cdf0e10cSrcweir                 ...
434*cdf0e10cSrcweir           ...
435*cdf0e10cSrcweir         SERVICES
436*cdf0e10cSrcweir           <service> utf-8-list
437*cdf0e10cSrcweir           ...
438*cdf0e10cSrcweir         SINGLETONS
439*cdf0e10cSrcweir           <singleton> utf-16
440*cdf0e10cSrcweir             REGISTERED_BY utf-8-list
441*cdf0e10cSrcweir           ...
442*cdf0e10cSrcweir     */
443*cdf0e10cSrcweir     enum State {
444*cdf0e10cSrcweir         STATE_ROOT, STATE_IMPLEMENTATIONS, STATE_IMPLEMENTATION, STATE_UNO,
445*cdf0e10cSrcweir         STATE_LOCATION, STATE_ACTIVATOR, STATE_IMPLEMENTATION_SERVICES,
446*cdf0e10cSrcweir         STATE_IMPLEMENTATION_SERVICE, STATE_IMPLEMENTATION_SINGLETONS,
447*cdf0e10cSrcweir         STATE_IMPLEMENTATION_SINGLETON, STATE_SERVICES, STATE_SERVICE,
448*cdf0e10cSrcweir         STATE_SINGLETONS, STATE_SINGLETON, STATE_REGISTEREDBY };
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getKeyName()
451*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isReadOnly() throw (
454*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isValid() throw(css::uno::RuntimeException);
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     virtual css::registry::RegistryKeyType SAL_CALL getKeyType(
459*cdf0e10cSrcweir         rtl::OUString const & rKeyName)
460*cdf0e10cSrcweir         throw (
461*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
462*cdf0e10cSrcweir             css::uno::RuntimeException);
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir     virtual css::registry::RegistryValueType SAL_CALL getValueType() throw(
465*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getLongValue() throw (
468*cdf0e10cSrcweir         css::registry::InvalidRegistryException,
469*cdf0e10cSrcweir         css::registry::InvalidValueException, css::uno::RuntimeException);
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir     virtual void SAL_CALL setLongValue(sal_Int32 value) throw (
472*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir     virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue() throw(
475*cdf0e10cSrcweir         css::registry::InvalidRegistryException,
476*cdf0e10cSrcweir         css::registry::InvalidValueException, css::uno::RuntimeException);
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir     virtual void SAL_CALL setLongListValue(
479*cdf0e10cSrcweir         com::sun::star::uno::Sequence< sal_Int32 > const & seqValue)
480*cdf0e10cSrcweir         throw (
481*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
482*cdf0e10cSrcweir             css::uno::RuntimeException);
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getAsciiValue() throw (
485*cdf0e10cSrcweir         css::registry::InvalidRegistryException,
486*cdf0e10cSrcweir         css::registry::InvalidValueException, css::uno::RuntimeException);
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir     virtual void SAL_CALL setAsciiValue(rtl::OUString const & value) throw (
489*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir     virtual css::uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue()
492*cdf0e10cSrcweir         throw (
493*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
494*cdf0e10cSrcweir             css::registry::InvalidValueException, css::uno::RuntimeException);
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir     virtual void SAL_CALL setAsciiListValue(
497*cdf0e10cSrcweir         css::uno::Sequence< rtl::OUString > const & seqValue)
498*cdf0e10cSrcweir         throw (
499*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
500*cdf0e10cSrcweir             css::uno::RuntimeException);
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getStringValue() throw(
503*cdf0e10cSrcweir         css::registry::InvalidRegistryException,
504*cdf0e10cSrcweir         css::registry::InvalidValueException, css::uno::RuntimeException);
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir     virtual void SAL_CALL setStringValue(rtl::OUString const & value) throw (
507*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir     virtual css::uno::Sequence< rtl::OUString > SAL_CALL getStringListValue()
510*cdf0e10cSrcweir         throw (
511*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
512*cdf0e10cSrcweir             css::registry::InvalidValueException, css::uno::RuntimeException);
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir     virtual void SAL_CALL setStringListValue(
515*cdf0e10cSrcweir         css::uno::Sequence< rtl::OUString > const & seqValue)
516*cdf0e10cSrcweir         throw (
517*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
518*cdf0e10cSrcweir             css::uno::RuntimeException);
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue() throw (
521*cdf0e10cSrcweir         css::registry::InvalidRegistryException,
522*cdf0e10cSrcweir         css::registry::InvalidValueException, css::uno::RuntimeException);
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir     virtual void SAL_CALL setBinaryValue(
525*cdf0e10cSrcweir         css::uno::Sequence< sal_Int8 > const & value)
526*cdf0e10cSrcweir         throw (
527*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
528*cdf0e10cSrcweir             css::uno::RuntimeException);
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey(
531*cdf0e10cSrcweir         rtl::OUString const & aKeyName)
532*cdf0e10cSrcweir         throw (
533*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
534*cdf0e10cSrcweir             css::uno::RuntimeException);
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir     virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
537*cdf0e10cSrcweir     createKey(rtl::OUString const & aKeyName) throw (
538*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir     virtual void SAL_CALL closeKey() throw (
541*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir     virtual void SAL_CALL deleteKey(rtl::OUString const & rKeyName) throw (
544*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir     virtual
547*cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
548*cdf0e10cSrcweir     SAL_CALL openKeys() throw (
549*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir     virtual css::uno::Sequence< rtl::OUString > SAL_CALL getKeyNames() throw (
552*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL createLink(
555*cdf0e10cSrcweir         rtl::OUString const & aLinkName, rtl::OUString const & aLinkTarget)
556*cdf0e10cSrcweir         throw (
557*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
558*cdf0e10cSrcweir             css::uno::RuntimeException);
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir     virtual void SAL_CALL deleteLink(rtl::OUString const & rLinkName) throw (
561*cdf0e10cSrcweir         css::registry::InvalidRegistryException, css::uno::RuntimeException);
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getLinkTarget(
564*cdf0e10cSrcweir         rtl::OUString const & rLinkName)
565*cdf0e10cSrcweir         throw (
566*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
567*cdf0e10cSrcweir             css::uno::RuntimeException);
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getResolvedName(
570*cdf0e10cSrcweir         rtl::OUString const & aKeyName)
571*cdf0e10cSrcweir         throw (
572*cdf0e10cSrcweir             css::registry::InvalidRegistryException,
573*cdf0e10cSrcweir             css::uno::RuntimeException);
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir     bool find(
576*cdf0e10cSrcweir         rtl::OUString const & relative, std::vector< rtl::OUString > * path,
577*cdf0e10cSrcweir         State * state, css::registry::RegistryValueType * type) const;
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > getChildren();
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir     rtl::Reference< Data > data_;
582*cdf0e10cSrcweir     std::vector< rtl::OUString > path_;
583*cdf0e10cSrcweir };
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir rtl::OUString Key::getKeyName() throw (css::uno::RuntimeException) {
586*cdf0e10cSrcweir     return pathToString(path_);
587*cdf0e10cSrcweir }
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir sal_Bool Key::isReadOnly()
590*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir     return true;
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir sal_Bool Key::isValid() throw(css::uno::RuntimeException) {
596*cdf0e10cSrcweir     return true;
597*cdf0e10cSrcweir }
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir css::registry::RegistryKeyType Key::getKeyType(rtl::OUString const & rKeyName)
600*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
601*cdf0e10cSrcweir {
602*cdf0e10cSrcweir     if (!find(rtl::OUString(), 0, 0, 0)) {
603*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
604*cdf0e10cSrcweir             (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unknown key ")) +
605*cdf0e10cSrcweir              rKeyName),
606*cdf0e10cSrcweir             static_cast< cppu::OWeakObject * >(this));
607*cdf0e10cSrcweir     }
608*cdf0e10cSrcweir     return css::registry::RegistryKeyType_KEY;
609*cdf0e10cSrcweir }
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir css::registry::RegistryValueType Key::getValueType()
612*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir     css::registry::RegistryValueType type =
615*cdf0e10cSrcweir         css::registry::RegistryValueType_NOT_DEFINED;
616*cdf0e10cSrcweir     OSL_VERIFY(find(rtl::OUString(), 0, 0, &type));
617*cdf0e10cSrcweir     return type;
618*cdf0e10cSrcweir }
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir sal_Int32 Key::getLongValue() throw (
621*cdf0e10cSrcweir     css::registry::InvalidRegistryException,
622*cdf0e10cSrcweir     css::registry::InvalidValueException, css::uno::RuntimeException)
623*cdf0e10cSrcweir {
624*cdf0e10cSrcweir     throw css::registry::InvalidValueException(
625*cdf0e10cSrcweir         rtl::OUString(
626*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
627*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
628*cdf0e10cSrcweir                 " getLongValue not supported")),
629*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
630*cdf0e10cSrcweir }
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir void Key::setLongValue(sal_Int32)
633*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
636*cdf0e10cSrcweir         rtl::OUString(
637*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
638*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
639*cdf0e10cSrcweir                 " setLongValue not supported")),
640*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
641*cdf0e10cSrcweir }
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir css::uno::Sequence< sal_Int32 > Key::getLongListValue() throw (
644*cdf0e10cSrcweir     css::registry::InvalidRegistryException,
645*cdf0e10cSrcweir     css::registry::InvalidValueException, css::uno::RuntimeException)
646*cdf0e10cSrcweir {
647*cdf0e10cSrcweir     throw css::registry::InvalidValueException(
648*cdf0e10cSrcweir         rtl::OUString(
649*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
650*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
651*cdf0e10cSrcweir                 " getLongListValue not supported")),
652*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
653*cdf0e10cSrcweir }
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir void Key::setLongListValue(css::uno::Sequence< sal_Int32 > const &)
656*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
657*cdf0e10cSrcweir {
658*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
659*cdf0e10cSrcweir         rtl::OUString(
660*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
661*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
662*cdf0e10cSrcweir                 " setLongListValue not supported")),
663*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
664*cdf0e10cSrcweir }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir rtl::OUString Key::getAsciiValue() throw (
667*cdf0e10cSrcweir     css::registry::InvalidRegistryException,
668*cdf0e10cSrcweir     css::registry::InvalidValueException, css::uno::RuntimeException)
669*cdf0e10cSrcweir {
670*cdf0e10cSrcweir     State state = STATE_ROOT;
671*cdf0e10cSrcweir     OSL_VERIFY(find(rtl::OUString(), 0, &state, 0));
672*cdf0e10cSrcweir     switch (state) {
673*cdf0e10cSrcweir     case STATE_LOCATION:
674*cdf0e10cSrcweir         return data_->implementations[path_[1]].uri;
675*cdf0e10cSrcweir     case STATE_ACTIVATOR:
676*cdf0e10cSrcweir         return data_->implementations[path_[1]].loader;
677*cdf0e10cSrcweir     default:
678*cdf0e10cSrcweir         throw css::registry::InvalidValueException(
679*cdf0e10cSrcweir             rtl::OUString(
680*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
681*cdf0e10cSrcweir                     "com.sun.star.registry.SimpleRegistry textual services key"
682*cdf0e10cSrcweir                     " getAsciiValue: wrong type")),
683*cdf0e10cSrcweir             static_cast< OWeakObject * >(this));
684*cdf0e10cSrcweir     }
685*cdf0e10cSrcweir }
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir void Key::setAsciiValue(rtl::OUString const &)
688*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
689*cdf0e10cSrcweir {
690*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
691*cdf0e10cSrcweir         rtl::OUString(
692*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
693*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
694*cdf0e10cSrcweir                 " setAsciiValue not supported")),
695*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
696*cdf0e10cSrcweir }
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > Key::getAsciiListValue() throw (
699*cdf0e10cSrcweir     css::registry::InvalidRegistryException,
700*cdf0e10cSrcweir     css::registry::InvalidValueException, css::uno::RuntimeException)
701*cdf0e10cSrcweir {
702*cdf0e10cSrcweir     State state = STATE_ROOT;
703*cdf0e10cSrcweir     OSL_VERIFY(find(rtl::OUString(), 0, &state, 0));
704*cdf0e10cSrcweir     std::vector< rtl::OUString > const * list;
705*cdf0e10cSrcweir     switch (state) {
706*cdf0e10cSrcweir     case STATE_SERVICE:
707*cdf0e10cSrcweir         list = &data_->services[path_[1]];
708*cdf0e10cSrcweir         break;
709*cdf0e10cSrcweir     case STATE_REGISTEREDBY:
710*cdf0e10cSrcweir         list = &data_->singletons[path_[1]];
711*cdf0e10cSrcweir         break;
712*cdf0e10cSrcweir     default:
713*cdf0e10cSrcweir         throw css::registry::InvalidValueException(
714*cdf0e10cSrcweir             rtl::OUString(
715*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
716*cdf0e10cSrcweir                     "com.sun.star.registry.SimpleRegistry textual services key"
717*cdf0e10cSrcweir                     " getAsciiListValue: wrong type")),
718*cdf0e10cSrcweir             static_cast< OWeakObject * >(this));
719*cdf0e10cSrcweir     }
720*cdf0e10cSrcweir     if (list->size() > SAL_MAX_INT32) {
721*cdf0e10cSrcweir         throw css::registry::InvalidValueException(
722*cdf0e10cSrcweir             rtl::OUString(
723*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
724*cdf0e10cSrcweir                     "com.sun.star.registry.SimpleRegistry textual services key"
725*cdf0e10cSrcweir                     " getAsciiListValue: too large")),
726*cdf0e10cSrcweir             static_cast< OWeakObject * >(this));
727*cdf0e10cSrcweir     }
728*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > seq(
729*cdf0e10cSrcweir         static_cast< sal_Int32 >(list->size()));
730*cdf0e10cSrcweir     sal_Int32 i = 0;
731*cdf0e10cSrcweir     for (std::vector< rtl::OUString >::const_iterator j(list->begin());
732*cdf0e10cSrcweir          j != list->end(); ++j)
733*cdf0e10cSrcweir     {
734*cdf0e10cSrcweir         seq[i++] = *j;
735*cdf0e10cSrcweir     }
736*cdf0e10cSrcweir     return seq;
737*cdf0e10cSrcweir }
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir void Key::setAsciiListValue(css::uno::Sequence< rtl::OUString > const &)
740*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
741*cdf0e10cSrcweir {
742*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
743*cdf0e10cSrcweir         rtl::OUString(
744*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
745*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
746*cdf0e10cSrcweir                 " setAsciiListValue not supported")),
747*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
748*cdf0e10cSrcweir }
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir rtl::OUString Key::getStringValue() throw (
751*cdf0e10cSrcweir     css::registry::InvalidRegistryException,
752*cdf0e10cSrcweir     css::registry::InvalidValueException, css::uno::RuntimeException)
753*cdf0e10cSrcweir {
754*cdf0e10cSrcweir     State state = STATE_ROOT;
755*cdf0e10cSrcweir     OSL_VERIFY(find(rtl::OUString(), 0, &state, 0));
756*cdf0e10cSrcweir     switch (state) {
757*cdf0e10cSrcweir     case STATE_IMPLEMENTATION_SINGLETON:
758*cdf0e10cSrcweir     case STATE_SINGLETON:
759*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
760*cdf0e10cSrcweir             rtl::OUString(
761*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
762*cdf0e10cSrcweir                     "com.sun.star.registry.SimpleRegistry textual services key"
763*cdf0e10cSrcweir                     " getStringValue: does not associate singletons with"
764*cdf0e10cSrcweir                     " services")),
765*cdf0e10cSrcweir             static_cast< OWeakObject * >(this));
766*cdf0e10cSrcweir     default:
767*cdf0e10cSrcweir         break;
768*cdf0e10cSrcweir     }
769*cdf0e10cSrcweir     // default case extracted from switch to avoid erroneous compiler warnings
770*cdf0e10cSrcweir     // on Solaris:
771*cdf0e10cSrcweir     throw css::registry::InvalidValueException(
772*cdf0e10cSrcweir         rtl::OUString(
773*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
774*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
775*cdf0e10cSrcweir                 " getStringValue: wrong type")),
776*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
777*cdf0e10cSrcweir }
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir void Key::setStringValue(rtl::OUString const &)
780*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
781*cdf0e10cSrcweir {
782*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
783*cdf0e10cSrcweir         rtl::OUString(
784*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
785*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
786*cdf0e10cSrcweir                 " setStringValue not supported")),
787*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
788*cdf0e10cSrcweir }
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > Key::getStringListValue() throw (
791*cdf0e10cSrcweir     css::registry::InvalidRegistryException,
792*cdf0e10cSrcweir     css::registry::InvalidValueException, css::uno::RuntimeException)
793*cdf0e10cSrcweir {
794*cdf0e10cSrcweir     throw css::registry::InvalidValueException(
795*cdf0e10cSrcweir         rtl::OUString(
796*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
797*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
798*cdf0e10cSrcweir                 " getStringListValue not supported")),
799*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
800*cdf0e10cSrcweir }
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir void Key::setStringListValue(css::uno::Sequence< rtl::OUString > const &)
803*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
804*cdf0e10cSrcweir {
805*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
806*cdf0e10cSrcweir         rtl::OUString(
807*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
808*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
809*cdf0e10cSrcweir                 " setStringListValue not supported")),
810*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
811*cdf0e10cSrcweir }
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir css::uno::Sequence< sal_Int8 > Key::getBinaryValue()
814*cdf0e10cSrcweir     throw (
815*cdf0e10cSrcweir         css::registry::InvalidRegistryException,
816*cdf0e10cSrcweir         css::registry::InvalidValueException, css::uno::RuntimeException)
817*cdf0e10cSrcweir {
818*cdf0e10cSrcweir     throw css::registry::InvalidValueException(
819*cdf0e10cSrcweir         rtl::OUString(
820*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
821*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
822*cdf0e10cSrcweir                 " getBinarValue not supported")),
823*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
824*cdf0e10cSrcweir }
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir void Key::setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
827*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
828*cdf0e10cSrcweir {
829*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
830*cdf0e10cSrcweir         rtl::OUString(
831*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
832*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
833*cdf0e10cSrcweir                 " setBinaryValue not supported")),
834*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
835*cdf0e10cSrcweir }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir css::uno::Reference< css::registry::XRegistryKey > Key::openKey(
838*cdf0e10cSrcweir     rtl::OUString const & aKeyName)
839*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
840*cdf0e10cSrcweir {
841*cdf0e10cSrcweir     std::vector< rtl::OUString > path;
842*cdf0e10cSrcweir     if (!find(aKeyName, &path, 0, 0)) {
843*cdf0e10cSrcweir         return css::uno::Reference< css::registry::XRegistryKey >();
844*cdf0e10cSrcweir     }
845*cdf0e10cSrcweir     return new Key(data_, path);
846*cdf0e10cSrcweir }
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir css::uno::Reference< css::registry::XRegistryKey > Key::createKey(
849*cdf0e10cSrcweir     rtl::OUString const &)
850*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
851*cdf0e10cSrcweir {
852*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
853*cdf0e10cSrcweir         rtl::OUString(
854*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
855*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
856*cdf0e10cSrcweir                 " createKey not supported")),
857*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
858*cdf0e10cSrcweir }
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir void Key::closeKey()
861*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
862*cdf0e10cSrcweir {}
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir void Key::deleteKey(rtl::OUString const &)
865*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
866*cdf0e10cSrcweir {
867*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
868*cdf0e10cSrcweir         rtl::OUString(
869*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
870*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
871*cdf0e10cSrcweir                 " deleteKey not supported")),
872*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
873*cdf0e10cSrcweir }
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
876*cdf0e10cSrcweir Key::openKeys()
877*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
878*cdf0e10cSrcweir {
879*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > names(getChildren());
880*cdf0e10cSrcweir     css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
881*cdf0e10cSrcweir         keys(names.getLength());
882*cdf0e10cSrcweir     for (sal_Int32 i = 0; i < keys.getLength(); ++i) {
883*cdf0e10cSrcweir         keys[i] = openKey(names[i]);
884*cdf0e10cSrcweir         OSL_ASSERT(keys[i].is());
885*cdf0e10cSrcweir     }
886*cdf0e10cSrcweir     return keys;
887*cdf0e10cSrcweir }
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > Key::getKeyNames()
890*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
891*cdf0e10cSrcweir {
892*cdf0e10cSrcweir     css::uno::Sequence< rtl::OUString > names(getChildren());
893*cdf0e10cSrcweir     rtl::OUString prefix(pathToString(path_));
894*cdf0e10cSrcweir     prefix += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
895*cdf0e10cSrcweir     for (sal_Int32 i = 0; i < names.getLength(); ++i) {
896*cdf0e10cSrcweir         names[i] = prefix + names[i];
897*cdf0e10cSrcweir     }
898*cdf0e10cSrcweir     return names;
899*cdf0e10cSrcweir }
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir sal_Bool Key::createLink(rtl::OUString const &, rtl::OUString const &)
902*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
903*cdf0e10cSrcweir {
904*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
905*cdf0e10cSrcweir         rtl::OUString(
906*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
907*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
908*cdf0e10cSrcweir                 " createLink not supported")),
909*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
910*cdf0e10cSrcweir }
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir void Key::deleteLink(rtl::OUString const &)
913*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
914*cdf0e10cSrcweir {
915*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
916*cdf0e10cSrcweir         rtl::OUString(
917*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
918*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
919*cdf0e10cSrcweir                 " deleteLink not supported")),
920*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
921*cdf0e10cSrcweir }
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir rtl::OUString Key::getLinkTarget(rtl::OUString const &)
924*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
925*cdf0e10cSrcweir {
926*cdf0e10cSrcweir     throw css::registry::InvalidRegistryException(
927*cdf0e10cSrcweir         rtl::OUString(
928*cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM(
929*cdf0e10cSrcweir                 "com.sun.star.registry.SimpleRegistry textual services key"
930*cdf0e10cSrcweir                 " getLinkTarget not supported")),
931*cdf0e10cSrcweir         static_cast< OWeakObject * >(this));
932*cdf0e10cSrcweir }
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir rtl::OUString Key::getResolvedName(rtl::OUString const & aKeyName)
935*cdf0e10cSrcweir     throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
936*cdf0e10cSrcweir {
937*cdf0e10cSrcweir     std::vector< rtl::OUString > path;
938*cdf0e10cSrcweir     find(aKeyName, &path, 0, 0);
939*cdf0e10cSrcweir     return pathToString(path);
940*cdf0e10cSrcweir }
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir bool Key::find(
943*cdf0e10cSrcweir     rtl::OUString const & relative, std::vector< rtl::OUString > * path,
944*cdf0e10cSrcweir     State * state, css::registry::RegistryValueType * type) const
945*cdf0e10cSrcweir {
946*cdf0e10cSrcweir     std::vector< rtl::OUString > p(path_);
947*cdf0e10cSrcweir     sal_Int32 i = 0;
948*cdf0e10cSrcweir     do {
949*cdf0e10cSrcweir         rtl::OUString seg(relative.getToken(0, '/', i));
950*cdf0e10cSrcweir         if (seg.getLength() != 0) {
951*cdf0e10cSrcweir             p.push_back(seg);
952*cdf0e10cSrcweir         }
953*cdf0e10cSrcweir     } while (i >= 0);
954*cdf0e10cSrcweir     if (path != 0) {
955*cdf0e10cSrcweir         *path = p;
956*cdf0e10cSrcweir     }
957*cdf0e10cSrcweir     std::size_t const MAX_TRANSITIONS = 4;
958*cdf0e10cSrcweir     struct StateInfo {
959*cdf0e10cSrcweir         css::registry::RegistryValueType type;
960*cdf0e10cSrcweir         std::size_t count;
961*cdf0e10cSrcweir         struct { char const * segment; State state; }
962*cdf0e10cSrcweir             transitions[MAX_TRANSITIONS];
963*cdf0e10cSrcweir     };
964*cdf0e10cSrcweir     static StateInfo const info[] = {
965*cdf0e10cSrcweir         // STATE_ROOT:
966*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 3,
967*cdf0e10cSrcweir           { { "IMPLEMENTATIONS", STATE_IMPLEMENTATIONS },
968*cdf0e10cSrcweir             { "SERVICES", STATE_SERVICES },
969*cdf0e10cSrcweir             { "SINGLETONS", STATE_SINGLETONS } } },
970*cdf0e10cSrcweir         // STATE_IMPLEMENTATIONS:
971*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 1,
972*cdf0e10cSrcweir           { { 0, STATE_IMPLEMENTATION } } },
973*cdf0e10cSrcweir         // STATE_IMPLEMENTATION:
974*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 1,
975*cdf0e10cSrcweir           { { "UNO", STATE_UNO } } },
976*cdf0e10cSrcweir         // STATE_UNO:
977*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 4,
978*cdf0e10cSrcweir           { { "LOCATION", STATE_LOCATION },
979*cdf0e10cSrcweir             { "ACTIVATOR", STATE_ACTIVATOR },
980*cdf0e10cSrcweir             { "SERVICES", STATE_IMPLEMENTATION_SERVICES },
981*cdf0e10cSrcweir             { "SINGLETONS", STATE_IMPLEMENTATION_SINGLETONS } } },
982*cdf0e10cSrcweir         // STATE_LOCATION:
983*cdf0e10cSrcweir         { css::registry::RegistryValueType_ASCII, 0, {} },
984*cdf0e10cSrcweir         // STATE_ACTIVATOR:
985*cdf0e10cSrcweir         { css::registry::RegistryValueType_ASCII, 0, {} },
986*cdf0e10cSrcweir         // STATE_IMPLEMENTATION_SERVICES:
987*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 1,
988*cdf0e10cSrcweir           { { 0, STATE_IMPLEMENTATION_SERVICE } } },
989*cdf0e10cSrcweir         // STATE_IMPLEMENTATION_SERVICE:
990*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 0, {} },
991*cdf0e10cSrcweir         // STATE_IMPLEMENTATION_SINGLETONS:
992*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 1,
993*cdf0e10cSrcweir           { { 0, STATE_IMPLEMENTATION_SINGLETON } } },
994*cdf0e10cSrcweir         // STATE_IMPLEMENTATION_SINGLETON:
995*cdf0e10cSrcweir         { css::registry::RegistryValueType_STRING, 0, {} },
996*cdf0e10cSrcweir         // STATE_SERVICES:
997*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 1,
998*cdf0e10cSrcweir           { { 0, STATE_SERVICE } } },
999*cdf0e10cSrcweir         // STATE_SERVICE:
1000*cdf0e10cSrcweir         { css::registry::RegistryValueType_ASCIILIST, 0, {} },
1001*cdf0e10cSrcweir         // STATE_SINGLETONS:
1002*cdf0e10cSrcweir         { css::registry::RegistryValueType_NOT_DEFINED, 1,
1003*cdf0e10cSrcweir           { { 0, STATE_SINGLETON } } },
1004*cdf0e10cSrcweir         // STATE_SINGLETON:
1005*cdf0e10cSrcweir         { css::registry::RegistryValueType_STRING, 1,
1006*cdf0e10cSrcweir           { { "REGISTERED_BY", STATE_REGISTEREDBY } } },
1007*cdf0e10cSrcweir         // STATE_REGISTEREDBY:
1008*cdf0e10cSrcweir         { css::registry::RegistryValueType_ASCIILIST, 0, {} } };
1009*cdf0e10cSrcweir     State s = STATE_ROOT;
1010*cdf0e10cSrcweir     for (std::vector< rtl::OUString >::iterator j(p.begin()); j != p.end(); ++j)
1011*cdf0e10cSrcweir     {
1012*cdf0e10cSrcweir         bool found = false;
1013*cdf0e10cSrcweir         for (std::size_t k = 0; k < info[s].count; ++k) {
1014*cdf0e10cSrcweir             if (info[s].transitions[k].segment == 0) {
1015*cdf0e10cSrcweir                 switch (info[s].transitions[k].state) {
1016*cdf0e10cSrcweir                 case STATE_IMPLEMENTATION:
1017*cdf0e10cSrcweir                     found = data_->implementations.find(*j) !=
1018*cdf0e10cSrcweir                         data_->implementations.end();
1019*cdf0e10cSrcweir                     break;
1020*cdf0e10cSrcweir                 case STATE_IMPLEMENTATION_SERVICE:
1021*cdf0e10cSrcweir                 case STATE_IMPLEMENTATION_SINGLETON:
1022*cdf0e10cSrcweir                     found = true; //TODO
1023*cdf0e10cSrcweir                     break;
1024*cdf0e10cSrcweir                 case STATE_SERVICE:
1025*cdf0e10cSrcweir                     found = data_->services.find(*j) != data_->services.end();
1026*cdf0e10cSrcweir                     break;
1027*cdf0e10cSrcweir                 case STATE_SINGLETON:
1028*cdf0e10cSrcweir                     found = data_->singletons.find(*j) !=
1029*cdf0e10cSrcweir                         data_->singletons.end();
1030*cdf0e10cSrcweir                     break;
1031*cdf0e10cSrcweir                 default:
1032*cdf0e10cSrcweir                     std::abort(); // this cannot happen
1033*cdf0e10cSrcweir                 }
1034*cdf0e10cSrcweir             } else {
1035*cdf0e10cSrcweir                 found = j->equalsAscii(info[s].transitions[k].segment);
1036*cdf0e10cSrcweir             }
1037*cdf0e10cSrcweir             if (found) {
1038*cdf0e10cSrcweir                 s = info[s].transitions[k].state;
1039*cdf0e10cSrcweir                 break;
1040*cdf0e10cSrcweir             }
1041*cdf0e10cSrcweir         }
1042*cdf0e10cSrcweir         if (!found) {
1043*cdf0e10cSrcweir             return false;
1044*cdf0e10cSrcweir         }
1045*cdf0e10cSrcweir     }
1046*cdf0e10cSrcweir     if (state != 0) {
1047*cdf0e10cSrcweir         *state = s;
1048*cdf0e10cSrcweir     }
1049*cdf0e10cSrcweir     if (type != 0) {
1050*cdf0e10cSrcweir         *type = info[s].type;
1051*cdf0e10cSrcweir     }
1052*cdf0e10cSrcweir     return true;
1053*cdf0e10cSrcweir }
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > Key::getChildren() {
1056*cdf0e10cSrcweir     State state = STATE_ROOT;
1057*cdf0e10cSrcweir     OSL_VERIFY(find(rtl::OUString(), 0, &state, 0));
1058*cdf0e10cSrcweir     switch (state) {
1059*cdf0e10cSrcweir     default:
1060*cdf0e10cSrcweir         std::abort(); // this cannot happen
1061*cdf0e10cSrcweir         // pseudo-fall-through to avoid warnings on MSC
1062*cdf0e10cSrcweir     case STATE_ROOT:
1063*cdf0e10cSrcweir         {
1064*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(3);
1065*cdf0e10cSrcweir             seq[0] = rtl::OUString(
1066*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM("IMPLEMENTATIONS"));
1067*cdf0e10cSrcweir             seq[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SERVICES"));
1068*cdf0e10cSrcweir             seq[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SINGLETONS"));
1069*cdf0e10cSrcweir             return seq;
1070*cdf0e10cSrcweir         }
1071*cdf0e10cSrcweir     case STATE_IMPLEMENTATIONS:
1072*cdf0e10cSrcweir         {
1073*cdf0e10cSrcweir             if (data_->implementations.size() > SAL_MAX_INT32) {
1074*cdf0e10cSrcweir                 throw css::registry::InvalidValueException(
1075*cdf0e10cSrcweir                     rtl::OUString(
1076*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
1077*cdf0e10cSrcweir                             "com.sun.star.registry.SimpleRegistry textual"
1078*cdf0e10cSrcweir                             " services key openKeys: too large")),
1079*cdf0e10cSrcweir                     static_cast< OWeakObject * >(this));
1080*cdf0e10cSrcweir             }
1081*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(
1082*cdf0e10cSrcweir                     static_cast< sal_Int32 >(data_->implementations.size()));
1083*cdf0e10cSrcweir             sal_Int32 i = 0;
1084*cdf0e10cSrcweir             for (Implementations::iterator j(data_->implementations.begin());
1085*cdf0e10cSrcweir                  j != data_->implementations.end(); ++j)
1086*cdf0e10cSrcweir             {
1087*cdf0e10cSrcweir                 seq[i++] = j->first;
1088*cdf0e10cSrcweir             }
1089*cdf0e10cSrcweir             return seq;
1090*cdf0e10cSrcweir         }
1091*cdf0e10cSrcweir     case STATE_UNO:
1092*cdf0e10cSrcweir         {
1093*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(4);
1094*cdf0e10cSrcweir             seq[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCATION"));
1095*cdf0e10cSrcweir             seq[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ACTIVATOR"));
1096*cdf0e10cSrcweir             seq[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SERVICES"));
1097*cdf0e10cSrcweir             seq[3] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SINGLETONS"));
1098*cdf0e10cSrcweir             return seq;
1099*cdf0e10cSrcweir         }
1100*cdf0e10cSrcweir     case STATE_LOCATION:
1101*cdf0e10cSrcweir     case STATE_ACTIVATOR:
1102*cdf0e10cSrcweir     case STATE_IMPLEMENTATION_SERVICE:
1103*cdf0e10cSrcweir     case STATE_IMPLEMENTATION_SINGLETON:
1104*cdf0e10cSrcweir     case STATE_SERVICE:
1105*cdf0e10cSrcweir     case STATE_REGISTEREDBY:
1106*cdf0e10cSrcweir         return css::uno::Sequence< rtl::OUString >();
1107*cdf0e10cSrcweir     case STATE_IMPLEMENTATION_SERVICES:
1108*cdf0e10cSrcweir         {
1109*cdf0e10cSrcweir             if (data_->implementations[path_[1]].services.size() >
1110*cdf0e10cSrcweir                 SAL_MAX_INT32)
1111*cdf0e10cSrcweir             {
1112*cdf0e10cSrcweir                 throw css::registry::InvalidValueException(
1113*cdf0e10cSrcweir                     rtl::OUString(
1114*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
1115*cdf0e10cSrcweir                             "com.sun.star.registry.SimpleRegistry textual"
1116*cdf0e10cSrcweir                             " services key openKeys: too large")),
1117*cdf0e10cSrcweir                     static_cast< OWeakObject * >(this));
1118*cdf0e10cSrcweir             }
1119*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(
1120*cdf0e10cSrcweir                 static_cast< sal_Int32 >(
1121*cdf0e10cSrcweir                     data_->implementations[path_[1]].services.size()));
1122*cdf0e10cSrcweir             sal_Int32 i = 0;
1123*cdf0e10cSrcweir             for (std::vector< rtl::OUString >::iterator j(
1124*cdf0e10cSrcweir                      data_->implementations[path_[1]].services.begin());
1125*cdf0e10cSrcweir                  j != data_->implementations[path_[1]].services.end(); ++j)
1126*cdf0e10cSrcweir             {
1127*cdf0e10cSrcweir                 seq[i++] = *j;
1128*cdf0e10cSrcweir             }
1129*cdf0e10cSrcweir             return seq;
1130*cdf0e10cSrcweir         }
1131*cdf0e10cSrcweir     case STATE_IMPLEMENTATION_SINGLETONS:
1132*cdf0e10cSrcweir         {
1133*cdf0e10cSrcweir             if (data_->implementations[path_[1]].singletons.size() >
1134*cdf0e10cSrcweir                 SAL_MAX_INT32)
1135*cdf0e10cSrcweir             {
1136*cdf0e10cSrcweir                 throw css::registry::InvalidValueException(
1137*cdf0e10cSrcweir                     rtl::OUString(
1138*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
1139*cdf0e10cSrcweir                             "com.sun.star.registry.SimpleRegistry textual"
1140*cdf0e10cSrcweir                             " services key openKeys: too large")),
1141*cdf0e10cSrcweir                     static_cast< OWeakObject * >(this));
1142*cdf0e10cSrcweir             }
1143*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(
1144*cdf0e10cSrcweir                 static_cast< sal_Int32 >(
1145*cdf0e10cSrcweir                     data_->implementations[path_[1]].singletons.size()));
1146*cdf0e10cSrcweir             sal_Int32 i = 0;
1147*cdf0e10cSrcweir             for (std::vector< rtl::OUString >::iterator j(
1148*cdf0e10cSrcweir                      data_->implementations[path_[1]].singletons.begin());
1149*cdf0e10cSrcweir                  j != data_->implementations[path_[1]].singletons.end(); ++j)
1150*cdf0e10cSrcweir             {
1151*cdf0e10cSrcweir                 seq[i++] = *j;
1152*cdf0e10cSrcweir             }
1153*cdf0e10cSrcweir             return seq;
1154*cdf0e10cSrcweir         }
1155*cdf0e10cSrcweir     case STATE_SERVICES:
1156*cdf0e10cSrcweir         {
1157*cdf0e10cSrcweir             if (data_->services.size() > SAL_MAX_INT32) {
1158*cdf0e10cSrcweir                 throw css::registry::InvalidValueException(
1159*cdf0e10cSrcweir                     rtl::OUString(
1160*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
1161*cdf0e10cSrcweir                             "com.sun.star.registry.SimpleRegistry textual"
1162*cdf0e10cSrcweir                             " services key openKeys: too large")),
1163*cdf0e10cSrcweir                     static_cast< OWeakObject * >(this));
1164*cdf0e10cSrcweir             }
1165*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(
1166*cdf0e10cSrcweir                 static_cast< sal_Int32 >(data_->services.size()));
1167*cdf0e10cSrcweir             sal_Int32 i = 0;
1168*cdf0e10cSrcweir             for (ImplementationMap::iterator j(data_->services.begin());
1169*cdf0e10cSrcweir                  j != data_->services.end(); ++j)
1170*cdf0e10cSrcweir             {
1171*cdf0e10cSrcweir                 seq[i++] = j->first;
1172*cdf0e10cSrcweir             }
1173*cdf0e10cSrcweir             return seq;
1174*cdf0e10cSrcweir         }
1175*cdf0e10cSrcweir     case STATE_SINGLETONS:
1176*cdf0e10cSrcweir         {
1177*cdf0e10cSrcweir             if (data_->singletons.size() > SAL_MAX_INT32) {
1178*cdf0e10cSrcweir                 throw css::registry::InvalidValueException(
1179*cdf0e10cSrcweir                     rtl::OUString(
1180*cdf0e10cSrcweir                         RTL_CONSTASCII_USTRINGPARAM(
1181*cdf0e10cSrcweir                             "com.sun.star.registry.SimpleRegistry textual"
1182*cdf0e10cSrcweir                             " services key openKeys: too large")),
1183*cdf0e10cSrcweir                     static_cast< OWeakObject * >(this));
1184*cdf0e10cSrcweir             }
1185*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(
1186*cdf0e10cSrcweir                 static_cast< sal_Int32 >(data_->singletons.size()));
1187*cdf0e10cSrcweir             sal_Int32 i = 0;
1188*cdf0e10cSrcweir             for (ImplementationMap::iterator j(data_->singletons.begin());
1189*cdf0e10cSrcweir                  j != data_->singletons.end(); ++j)
1190*cdf0e10cSrcweir             {
1191*cdf0e10cSrcweir                 seq[i++] = j->first;
1192*cdf0e10cSrcweir             }
1193*cdf0e10cSrcweir             return seq;
1194*cdf0e10cSrcweir         }
1195*cdf0e10cSrcweir     case STATE_SINGLETON:
1196*cdf0e10cSrcweir         {
1197*cdf0e10cSrcweir             css::uno::Sequence< rtl::OUString > seq(1);
1198*cdf0e10cSrcweir             seq[0] = rtl::OUString(
1199*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM("REGISTERED_BY"));
1200*cdf0e10cSrcweir             return seq;
1201*cdf0e10cSrcweir         }
1202*cdf0e10cSrcweir     }
1203*cdf0e10cSrcweir }
1204*cdf0e10cSrcweir 
1205*cdf0e10cSrcweir }
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir TextualServices::TextualServices(rtl::OUString const & uri):
1208*cdf0e10cSrcweir     uri_(uri), data_(new Data)
1209*cdf0e10cSrcweir {
1210*cdf0e10cSrcweir     try {
1211*cdf0e10cSrcweir         Parser(uri, data_);
1212*cdf0e10cSrcweir     } catch (css::container::NoSuchElementException &) {
1213*cdf0e10cSrcweir         throw css::registry::InvalidRegistryException(
1214*cdf0e10cSrcweir             (uri +
1215*cdf0e10cSrcweir              rtl::OUString(
1216*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(": no such file"))),
1217*cdf0e10cSrcweir             css::uno::Reference< css::uno::XInterface >());
1218*cdf0e10cSrcweir     }
1219*cdf0e10cSrcweir }
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir TextualServices::~TextualServices() {}
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir css::uno::Reference< css::registry::XRegistryKey > TextualServices::getRootKey()
1224*cdf0e10cSrcweir {
1225*cdf0e10cSrcweir     return new Key(data_, std::vector< rtl::OUString >());
1226*cdf0e10cSrcweir }
1227*cdf0e10cSrcweir 
1228*cdf0e10cSrcweir } }
1229