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