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