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 <cassert>
23 : :
24 : : #include "boost/noncopyable.hpp"
25 : : #include "com/sun/star/beans/NamedValue.hpp"
26 : : #include "com/sun/star/beans/Property.hpp"
27 : : #include "com/sun/star/beans/XProperty.hpp"
28 : : #include "com/sun/star/container/NoSuchElementException.hpp"
29 : : #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
30 : : #include "com/sun/star/container/XNamed.hpp"
31 : : #include "com/sun/star/lang/XMultiComponentFactory.hpp"
32 : : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
33 : : #include "com/sun/star/lang/XServiceInfo.hpp"
34 : : #include "com/sun/star/registry/InvalidRegistryException.hpp"
35 : : #include "com/sun/star/registry/InvalidValueException.hpp"
36 : : #include "com/sun/star/registry/MergeConflictException.hpp"
37 : : #include "com/sun/star/registry/RegistryKeyType.hpp"
38 : : #include "com/sun/star/registry/RegistryValueType.hpp"
39 : : #include "com/sun/star/registry/XRegistryKey.hpp"
40 : : #include "com/sun/star/registry/XSimpleRegistry.hpp"
41 : : #include "com/sun/star/uno/Any.hxx"
42 : : #include "com/sun/star/uno/DeploymentException.hpp"
43 : : #include "com/sun/star/uno/Exception.hpp"
44 : : #include "com/sun/star/uno/Reference.hxx"
45 : : #include "com/sun/star/uno/RuntimeException.hpp"
46 : : #include "com/sun/star/uno/Sequence.hxx"
47 : : #include "com/sun/star/uno/Type.hxx"
48 : : #include "com/sun/star/uno/TypeClass.hpp"
49 : : #include "com/sun/star/uno/XComponentContext.hpp"
50 : : #include "com/sun/star/uno/XInterface.hpp"
51 : : #include "com/sun/star/util/XFlushable.hpp"
52 : : #include "cppu/unotype.hxx"
53 : : #include "cppuhelper/implbase1.hxx"
54 : : #include "cppuhelper/implbase3.hxx"
55 : : #include "cppuhelper/weak.hxx"
56 : : #include "osl/mutex.hxx"
57 : : #include "rtl/ustring.h"
58 : : #include "rtl/ustring.hxx"
59 : : #include "sal/types.h"
60 : :
61 : : #include "configurationregistry.hxx"
62 : :
63 : : namespace com { namespace sun { namespace star { namespace util {
64 : : class XFlushListener;
65 : : } } } }
66 : :
67 : : namespace configmgr { namespace configuration_registry {
68 : :
69 : : namespace {
70 : :
71 : : namespace css = com::sun::star;
72 : :
73 : : class Service:
74 : : public cppu::WeakImplHelper3<
75 : : css::lang::XServiceInfo, css::registry::XSimpleRegistry,
76 : : css::util::XFlushable >,
77 : : private boost::noncopyable
78 : : {
79 : : public:
80 : : Service(css::uno::Reference< css::uno::XComponentContext > const & context);
81 : :
82 : : private:
83 [ + - ][ - + ]: 24 : virtual ~Service() {}
84 : :
85 : 0 : virtual rtl::OUString SAL_CALL getImplementationName()
86 : : throw (css::uno::RuntimeException)
87 : 0 : { return configuration_registry::getImplementationName(); }
88 : :
89 : 0 : virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
90 : : throw (css::uno::RuntimeException)
91 [ # # ]: 0 : { return ServiceName == getSupportedServiceNames()[0]; } //TODO
92 : :
93 : : virtual css::uno::Sequence< rtl::OUString > SAL_CALL
94 : 0 : getSupportedServiceNames() throw (css::uno::RuntimeException)
95 : 0 : { return configuration_registry::getSupportedServiceNames(); }
96 : :
97 : : virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException);
98 : :
99 : : virtual void SAL_CALL open(
100 : : rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
101 : : throw (
102 : : css::registry::InvalidRegistryException,
103 : : css::uno::RuntimeException);
104 : :
105 : : virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException);
106 : :
107 : : virtual void SAL_CALL close()
108 : : throw (
109 : : css::registry::InvalidRegistryException,
110 : : css::uno::RuntimeException);
111 : :
112 : : virtual void SAL_CALL destroy()
113 : : throw (
114 : : css::registry::InvalidRegistryException,
115 : : css::uno::RuntimeException);
116 : :
117 : : virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
118 : : getRootKey()
119 : : throw (
120 : : css::registry::InvalidRegistryException,
121 : : css::uno::RuntimeException);
122 : :
123 : : virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException);
124 : :
125 : : virtual void SAL_CALL mergeKey(rtl::OUString const &, rtl::OUString const &)
126 : : throw (
127 : : css::registry::InvalidRegistryException,
128 : : css::registry::MergeConflictException, css::uno::RuntimeException);
129 : :
130 : : virtual void SAL_CALL flush() throw (css::uno::RuntimeException);
131 : :
132 : : virtual void SAL_CALL addFlushListener(
133 : : css::uno::Reference< css::util::XFlushListener > const &)
134 : : throw (css::uno::RuntimeException);
135 : :
136 : : virtual void SAL_CALL removeFlushListener(
137 : : css::uno::Reference< css::util::XFlushListener > const &)
138 : : throw (css::uno::RuntimeException);
139 : :
140 : : void checkValid();
141 : :
142 : : void checkValid_RuntimeException();
143 : :
144 : : void doClose();
145 : :
146 : : css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
147 : : osl::Mutex mutex_;
148 : : css::uno::Reference< css::uno::XInterface > access_;
149 : : rtl::OUString url_;
150 : : bool readOnly_;
151 : :
152 : : friend class RegistryKey;
153 : : };
154 : :
155 : : class RegistryKey:
156 : : public cppu::WeakImplHelper1< css::registry::XRegistryKey >,
157 : : private boost::noncopyable
158 : : {
159 : : public:
160 : 40 : RegistryKey(Service & service, css::uno::Any const & value):
161 : 40 : service_(service), value_(value) {}
162 : :
163 : : private:
164 [ - + ]: 80 : virtual ~RegistryKey() {}
165 : :
166 : : virtual rtl::OUString SAL_CALL getKeyName()
167 : : throw (css::uno::RuntimeException);
168 : :
169 : : virtual sal_Bool SAL_CALL isReadOnly()
170 : : throw (
171 : : css::registry::InvalidRegistryException,
172 : : css::uno::RuntimeException);
173 : :
174 : : virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException);
175 : :
176 : : virtual css::registry::RegistryKeyType SAL_CALL getKeyType(
177 : : rtl::OUString const &)
178 : : throw (
179 : : css::registry::InvalidRegistryException,
180 : : css::uno::RuntimeException);
181 : :
182 : : virtual css::registry::RegistryValueType SAL_CALL getValueType()
183 : : throw (
184 : : css::registry::InvalidRegistryException,
185 : : css::uno::RuntimeException);
186 : :
187 : : virtual sal_Int32 SAL_CALL getLongValue()
188 : : throw (
189 : : css::registry::InvalidRegistryException,
190 : : css::registry::InvalidValueException, css::uno::RuntimeException);
191 : :
192 : : virtual void SAL_CALL setLongValue(sal_Int32)
193 : : throw (
194 : : css::registry::InvalidRegistryException,
195 : : css::uno::RuntimeException);
196 : :
197 : : virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue()
198 : : throw (
199 : : css::registry::InvalidRegistryException,
200 : : css::registry::InvalidValueException, css::uno::RuntimeException);
201 : :
202 : : virtual void SAL_CALL setLongListValue(
203 : : css::uno::Sequence< sal_Int32 > const &)
204 : : throw (
205 : : css::registry::InvalidRegistryException,
206 : : css::uno::RuntimeException);
207 : :
208 : : virtual rtl::OUString SAL_CALL getAsciiValue()
209 : : throw (
210 : : css::registry::InvalidRegistryException,
211 : : css::registry::InvalidValueException, css::uno::RuntimeException);
212 : :
213 : : virtual void SAL_CALL setAsciiValue(rtl::OUString const &)
214 : : throw (
215 : : css::registry::InvalidRegistryException,
216 : : css::uno::RuntimeException);
217 : :
218 : : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue()
219 : : throw (
220 : : css::registry::InvalidRegistryException,
221 : : css::registry::InvalidValueException, css::uno::RuntimeException);
222 : :
223 : : virtual void SAL_CALL setAsciiListValue(
224 : : css::uno::Sequence< rtl::OUString > const &)
225 : : throw (
226 : : css::registry::InvalidRegistryException,
227 : : css::uno::RuntimeException);
228 : :
229 : : virtual rtl::OUString SAL_CALL getStringValue()
230 : : throw (
231 : : css::registry::InvalidRegistryException,
232 : : css::registry::InvalidValueException, css::uno::RuntimeException);
233 : :
234 : : virtual void SAL_CALL setStringValue(rtl::OUString const &)
235 : : throw (
236 : : css::registry::InvalidRegistryException,
237 : : css::uno::RuntimeException);
238 : :
239 : : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getStringListValue()
240 : : throw (
241 : : css::registry::InvalidRegistryException,
242 : : css::registry::InvalidValueException, css::uno::RuntimeException);
243 : :
244 : : virtual void SAL_CALL setStringListValue(
245 : : css::uno::Sequence< rtl::OUString > const &)
246 : : throw (
247 : : css::registry::InvalidRegistryException,
248 : : css::uno::RuntimeException);
249 : :
250 : : virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue()
251 : : throw (
252 : : css::registry::InvalidRegistryException,
253 : : css::registry::InvalidValueException, css::uno::RuntimeException);
254 : :
255 : : virtual void SAL_CALL setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
256 : : throw (
257 : : css::registry::InvalidRegistryException,
258 : : css::uno::RuntimeException);
259 : :
260 : : virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey(
261 : : rtl::OUString const & aKeyName)
262 : : throw (
263 : : css::registry::InvalidRegistryException,
264 : : css::uno::RuntimeException);
265 : :
266 : : virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
267 : : createKey(rtl::OUString const &)
268 : : throw (
269 : : css::registry::InvalidRegistryException,
270 : : css::uno::RuntimeException);
271 : :
272 : : virtual void SAL_CALL closeKey()
273 : : throw (
274 : : css::registry::InvalidRegistryException,
275 : : css::uno::RuntimeException);
276 : :
277 : : virtual void SAL_CALL deleteKey(rtl::OUString const &)
278 : : throw (
279 : : css::registry::InvalidRegistryException,
280 : : css::uno::RuntimeException);
281 : :
282 : : virtual
283 : : css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
284 : : SAL_CALL openKeys()
285 : : throw (
286 : : css::registry::InvalidRegistryException,
287 : : css::uno::RuntimeException);
288 : :
289 : : virtual css::uno::Sequence< rtl::OUString > SAL_CALL getKeyNames()
290 : : throw (
291 : : css::registry::InvalidRegistryException,
292 : : css::uno::RuntimeException);
293 : :
294 : : virtual sal_Bool SAL_CALL createLink(
295 : : rtl::OUString const &, rtl::OUString const &)
296 : : throw (
297 : : css::registry::InvalidRegistryException,
298 : : css::uno::RuntimeException);
299 : :
300 : : virtual void SAL_CALL deleteLink(rtl::OUString const &)
301 : : throw (
302 : : css::registry::InvalidRegistryException,
303 : : css::uno::RuntimeException);
304 : :
305 : : virtual rtl::OUString SAL_CALL getLinkTarget(rtl::OUString const &)
306 : : throw (
307 : : css::registry::InvalidRegistryException,
308 : : css::uno::RuntimeException);
309 : :
310 : : virtual rtl::OUString SAL_CALL getResolvedName(
311 : : rtl::OUString const & aKeyName)
312 : : throw (
313 : : css::registry::InvalidRegistryException,
314 : : css::uno::RuntimeException);
315 : :
316 : : Service & service_;
317 : : css::uno::Any value_;
318 : : };
319 : :
320 : 12 : Service::Service(
321 [ + - ]: 12 : css::uno::Reference< css::uno::XComponentContext > const & context)
322 : : {
323 : : assert(context.is());
324 : : try {
325 : : provider_ = css::uno::Reference< css::lang::XMultiServiceFactory >(
326 : : (css::uno::Reference< css::lang::XMultiComponentFactory >(
327 [ + - ][ + - ]: 24 : context->getServiceManager(), css::uno::UNO_SET_THROW)->
[ + - ][ + - ]
328 : : createInstanceWithContext(
329 : : rtl::OUString(
330 : : RTL_CONSTASCII_USTRINGPARAM(
331 : : "com.sun.star.configuration.DefaultProvider")),
332 : 12 : context)),
333 [ + - ][ + - ]: 12 : css::uno::UNO_QUERY_THROW);
[ + - ][ + - ]
334 : 0 : } catch (css::uno::RuntimeException &) {
335 : 0 : throw;
336 [ # # # ]: 0 : } catch (css::uno::Exception & e) {
337 : : throw css::uno::DeploymentException(
338 : : (rtl::OUString(
339 : : RTL_CONSTASCII_USTRINGPARAM(
340 : : "component context fails to supply service"
341 : : " com.sun.star.configuration.DefaultProvider of type"
342 : : " com.sun.star.lang.XMultiServiceFactory: ")) +
343 : : e.Message),
344 [ # # # # ]: 0 : context);
345 : : }
346 : 12 : }
347 : :
348 : 0 : rtl::OUString Service::getURL() throw (css::uno::RuntimeException) {
349 [ # # ]: 0 : osl::MutexGuard g(mutex_);
350 [ # # ]: 0 : checkValid_RuntimeException();
351 [ # # ]: 0 : return url_;
352 : : }
353 : :
354 : 12 : void Service::open(rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
355 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
356 : : {
357 : : //TODO: bCreate
358 [ + - ]: 12 : osl::MutexGuard g(mutex_);
359 [ - + ]: 12 : if (access_.is()) {
360 [ # # ]: 0 : doClose();
361 : : }
362 [ + - ]: 12 : css::uno::Sequence< css::uno::Any > args(1);
363 [ + - ]: 12 : args[0] <<= css::beans::NamedValue(
364 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
365 [ + - ][ + - ]: 24 : css::uno::makeAny(rURL));
[ + - ]
366 : : try {
367 [ + - ]: 12 : access_ = provider_->createInstanceWithArguments(
368 : : (bReadOnly
369 : : ? rtl::OUString(
370 : : RTL_CONSTASCII_USTRINGPARAM(
371 : : "com.sun.star.configuration.ConfigurationAccess"))
372 : : : rtl::OUString(
373 : : RTL_CONSTASCII_USTRINGPARAM(
374 : : "com.sun.star.configuration.ConfigurationUpdateAccess"))),
375 [ + - ][ + - ]: 12 : args);
[ # # ][ + - ]
[ + - ]
376 : 0 : } catch (css::uno::RuntimeException &) {
377 : 0 : throw;
378 [ # # # ]: 0 : } catch (css::uno::Exception & e) {
379 : : throw css::uno::RuntimeException(
380 : : (rtl::OUString(
381 : : RTL_CONSTASCII_USTRINGPARAM(
382 : : "com.sun.star.configuration.ConfigurationRegistry: open"
383 : : " failed: ")) +
384 : : e.Message),
385 [ # # # # : 0 : static_cast< cppu::OWeakObject * >(this));
# # ]
386 : : }
387 : 12 : url_ = rURL;
388 [ + - ][ + - ]: 12 : readOnly_ = bReadOnly;
389 : 12 : }
390 : :
391 : 0 : sal_Bool Service::isValid() throw (css::uno::RuntimeException) {
392 [ # # ]: 0 : osl::MutexGuard g(mutex_);
393 [ # # ]: 0 : return access_.is();
394 : : }
395 : :
396 : 8 : void Service::close()
397 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
398 : : {
399 [ + - ]: 8 : osl::MutexGuard g(mutex_);
400 [ + - ]: 8 : checkValid();
401 [ + - ][ + - ]: 8 : doClose();
402 : 8 : }
403 : :
404 : 0 : void Service::destroy()
405 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
406 : : {
407 : : throw css::uno::RuntimeException(
408 : : rtl::OUString(
409 : : RTL_CONSTASCII_USTRINGPARAM(
410 : : "com.sun.star.configuration.ConfigurationRegistry: not"
411 : : " implemented")),
412 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
413 : : }
414 : :
415 : 12 : css::uno::Reference< css::registry::XRegistryKey > Service::getRootKey()
416 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
417 : : {
418 [ + - ]: 12 : osl::MutexGuard g(mutex_);
419 [ + - ]: 12 : checkValid();
420 [ + - ][ + - ]: 12 : return new RegistryKey(*this, css::uno::makeAny(access_));
[ + - ][ + - ]
[ + - ]
421 : : }
422 : :
423 : 0 : sal_Bool Service::isReadOnly() throw (css::uno::RuntimeException) {
424 [ # # ]: 0 : osl::MutexGuard g(mutex_);
425 [ # # ]: 0 : checkValid_RuntimeException();
426 [ # # ]: 0 : return readOnly_;
427 : : }
428 : :
429 : 0 : void Service::mergeKey(rtl::OUString const &, rtl::OUString const &)
430 : : throw (
431 : : css::registry::InvalidRegistryException,
432 : : css::registry::MergeConflictException, css::uno::RuntimeException)
433 : : {
434 : : throw css::uno::RuntimeException(
435 : : rtl::OUString(
436 : : RTL_CONSTASCII_USTRINGPARAM(
437 : : "com.sun.star.configuration.ConfigurationRegistry: not"
438 : : " implemented")),
439 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
440 : : }
441 : :
442 : 0 : void Service::flush() throw (css::uno::RuntimeException)
443 : : {
444 : : throw css::uno::RuntimeException(
445 : : rtl::OUString(
446 : : RTL_CONSTASCII_USTRINGPARAM(
447 : : "com.sun.star.configuration.ConfigurationRegistry: not"
448 : : " implemented")),
449 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
450 : : }
451 : :
452 : 0 : void Service::addFlushListener(
453 : : css::uno::Reference< css::util::XFlushListener > const &)
454 : : throw (css::uno::RuntimeException)
455 : : {
456 : : throw css::uno::RuntimeException(
457 : : rtl::OUString(
458 : : RTL_CONSTASCII_USTRINGPARAM(
459 : : "com.sun.star.configuration.ConfigurationRegistry: not"
460 : : " implemented")),
461 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
462 : : }
463 : :
464 : 0 : void Service::removeFlushListener(
465 : : css::uno::Reference< css::util::XFlushListener > const &)
466 : : throw (css::uno::RuntimeException)
467 : : {
468 : : throw css::uno::RuntimeException(
469 : : rtl::OUString(
470 : : RTL_CONSTASCII_USTRINGPARAM(
471 : : "com.sun.star.configuration.ConfigurationRegistry: not"
472 : : " implemented")),
473 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
474 : : }
475 : :
476 : 60 : void Service::checkValid() {
477 [ - + ]: 60 : if (!access_.is()) {
478 : : throw css::registry::InvalidRegistryException(
479 : : rtl::OUString(
480 : : RTL_CONSTASCII_USTRINGPARAM(
481 : : "com.sun.star.configuration.ConfigurationRegistry: not"
482 : : " valid")),
483 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
484 : : }
485 : 60 : }
486 : :
487 : 28 : void Service::checkValid_RuntimeException() {
488 [ - + ]: 28 : if (!access_.is()) {
489 : : throw css::uno::RuntimeException(
490 : : rtl::OUString(
491 : : RTL_CONSTASCII_USTRINGPARAM(
492 : : "com.sun.star.configuration.ConfigurationRegistry: not"
493 : : " valid")),
494 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
495 : : }
496 : 28 : }
497 : :
498 : 8 : void Service::doClose() {
499 : 8 : access_.clear();
500 : 8 : }
501 : :
502 : 0 : rtl::OUString RegistryKey::getKeyName() throw (css::uno::RuntimeException) {
503 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
504 [ # # ]: 0 : service_.checkValid_RuntimeException();
505 : 0 : css::uno::Reference< css::container::XNamed > named;
506 [ # # ][ # # ]: 0 : if (value_ >>= named) {
507 [ # # ][ # # ]: 0 : return named->getName();
508 : : }
509 : : throw css::uno::RuntimeException(
510 : : rtl::OUString(
511 : : RTL_CONSTASCII_USTRINGPARAM(
512 : : "com.sun.star.configuration.ConfigurationRegistry: not"
513 : : " implemented")),
514 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ][ # # ]
515 : : }
516 : :
517 : 0 : sal_Bool RegistryKey::isReadOnly()
518 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
519 : : {
520 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
521 [ # # ]: 0 : service_.checkValid_RuntimeException();
522 [ # # ]: 0 : return service_.readOnly_; //TODO: read-only sub-nodes in update access?
523 : : }
524 : :
525 : 0 : sal_Bool RegistryKey::isValid() throw (css::uno::RuntimeException) {
526 : 0 : return service_.isValid();
527 : : }
528 : :
529 : 0 : css::registry::RegistryKeyType RegistryKey::getKeyType(rtl::OUString const &)
530 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
531 : : {
532 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
533 [ # # ]: 0 : service_.checkValid();
534 [ # # ]: 0 : return css::registry::RegistryKeyType_KEY;
535 : : }
536 : :
537 : 0 : css::registry::RegistryValueType RegistryKey::getValueType()
538 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
539 : : {
540 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
541 [ # # ]: 0 : service_.checkValid();
542 : 0 : css::uno::Type t(value_.getValueType());
543 [ # # # # ]: 0 : switch (t.getTypeClass()) {
544 : : case css::uno::TypeClass_LONG:
545 : 0 : return css::registry::RegistryValueType_LONG;
546 : : case css::uno::TypeClass_STRING:
547 : 0 : return css::registry::RegistryValueType_STRING;
548 : : case css::uno::TypeClass_SEQUENCE:
549 [ # # ][ # # ]: 0 : if (t == cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get()) {
550 : 0 : return css::registry::RegistryValueType_BINARY;
551 [ # # ][ # # ]: 0 : } else if (t == cppu::UnoType< css::uno::Sequence< sal_Int32 > >::get())
552 : : {
553 : 0 : return css::registry::RegistryValueType_LONGLIST;
554 [ # # ]: 0 : } else if (t ==
555 [ # # ]: 0 : cppu::UnoType< css::uno::Sequence< rtl::OUString > >::get())
556 : : {
557 : 0 : return css::registry::RegistryValueType_STRINGLIST;
558 : : }
559 : : // fall through
560 : : default:
561 : 0 : return css::registry::RegistryValueType_NOT_DEFINED;
562 [ # # ]: 0 : }
563 : : }
564 : :
565 : 8 : sal_Int32 RegistryKey::getLongValue()
566 : : throw (
567 : : css::registry::InvalidRegistryException,
568 : : css::registry::InvalidValueException, css::uno::RuntimeException)
569 : : {
570 [ + - ]: 8 : osl::MutexGuard g(service_.mutex_);
571 [ + - ]: 8 : service_.checkValid();
572 : 8 : sal_Int32 v = 0;
573 [ + + ]: 8 : if (value_ >>= v) {
574 : 4 : return v;
575 : : }
576 : : throw css::registry::InvalidValueException(
577 : : rtl::OUString(
578 : : RTL_CONSTASCII_USTRINGPARAM(
579 : : "com.sun.star.configuration.ConfigurationRegistry")),
580 [ + - ][ + - ]: 8 : static_cast< cppu::OWeakObject * >(this));
[ + - ][ + - ]
581 : : }
582 : :
583 : 0 : void RegistryKey::setLongValue(sal_Int32)
584 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
585 : : {
586 : : throw css::uno::RuntimeException(
587 : : rtl::OUString(
588 : : RTL_CONSTASCII_USTRINGPARAM(
589 : : "com.sun.star.configuration.ConfigurationRegistry: not"
590 : : " implemented")),
591 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
592 : : }
593 : :
594 : 0 : css::uno::Sequence< sal_Int32 > RegistryKey::getLongListValue()
595 : : throw (
596 : : css::registry::InvalidRegistryException,
597 : : css::registry::InvalidValueException, css::uno::RuntimeException)
598 : : {
599 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
600 [ # # ]: 0 : service_.checkValid();
601 [ # # ]: 0 : css::uno::Sequence< sal_Int32 > v;
602 [ # # ][ # # ]: 0 : if (value_ >>= v) {
603 : 0 : return v;
604 : : }
605 : : throw css::registry::InvalidValueException(
606 : : rtl::OUString(
607 : : RTL_CONSTASCII_USTRINGPARAM(
608 : : "com.sun.star.configuration.ConfigurationRegistry")),
609 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ][ # # ]
610 : : }
611 : :
612 : 0 : void RegistryKey::setLongListValue(css::uno::Sequence< sal_Int32 > const &)
613 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
614 : : {
615 : : throw css::uno::RuntimeException(
616 : : rtl::OUString(
617 : : RTL_CONSTASCII_USTRINGPARAM(
618 : : "com.sun.star.configuration.ConfigurationRegistry: not"
619 : : " implemented")),
620 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
621 : : }
622 : :
623 : 0 : rtl::OUString RegistryKey::getAsciiValue()
624 : : throw (
625 : : css::registry::InvalidRegistryException,
626 : : css::registry::InvalidValueException, css::uno::RuntimeException)
627 : : {
628 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
629 [ # # ]: 0 : service_.checkValid();
630 : 0 : rtl::OUString v;
631 [ # # ]: 0 : if (value_ >>= v) {
632 : 0 : return v;
633 : : }
634 : : throw css::registry::InvalidValueException(
635 : : rtl::OUString(
636 : : RTL_CONSTASCII_USTRINGPARAM(
637 : : "com.sun.star.configuration.ConfigurationRegistry")),
638 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ][ # # ]
639 : : }
640 : :
641 : 0 : void RegistryKey::setAsciiValue(rtl::OUString const &)
642 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
643 : : {
644 : : throw css::uno::RuntimeException(
645 : : rtl::OUString(
646 : : RTL_CONSTASCII_USTRINGPARAM(
647 : : "com.sun.star.configuration.ConfigurationRegistry: not"
648 : : " implemented")),
649 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
650 : : }
651 : :
652 : 0 : css::uno::Sequence< rtl::OUString > RegistryKey::getAsciiListValue()
653 : : throw (
654 : : css::registry::InvalidRegistryException,
655 : : css::registry::InvalidValueException, css::uno::RuntimeException)
656 : : {
657 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
658 [ # # ]: 0 : service_.checkValid();
659 [ # # ]: 0 : css::uno::Sequence< rtl::OUString > v;
660 [ # # ][ # # ]: 0 : if (value_ >>= v) {
661 : 0 : return v;
662 : : }
663 : : throw css::registry::InvalidValueException(
664 : : rtl::OUString(
665 : : RTL_CONSTASCII_USTRINGPARAM(
666 : : "com.sun.star.configuration.ConfigurationRegistry")),
667 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ][ # # ]
668 : : }
669 : :
670 : 0 : void RegistryKey::setAsciiListValue(css::uno::Sequence< rtl::OUString > const &)
671 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
672 : : {
673 : : throw css::uno::RuntimeException(
674 : : rtl::OUString(
675 : : RTL_CONSTASCII_USTRINGPARAM(
676 : : "com.sun.star.configuration.ConfigurationRegistry: not"
677 : : " implemented")),
678 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
679 : : }
680 : :
681 : 32 : rtl::OUString RegistryKey::getStringValue()
682 : : throw (
683 : : css::registry::InvalidRegistryException,
684 : : css::registry::InvalidValueException, css::uno::RuntimeException)
685 : : {
686 [ + - ]: 32 : osl::MutexGuard g(service_.mutex_);
687 [ + - ]: 32 : service_.checkValid();
688 : 32 : rtl::OUString v;
689 [ - + ]: 32 : if (value_ >>= v) {
690 : 32 : return v;
691 : : }
692 : : throw css::registry::InvalidValueException(
693 : : rtl::OUString(
694 : : RTL_CONSTASCII_USTRINGPARAM(
695 : : "com.sun.star.configuration.ConfigurationRegistry")),
696 [ # # ][ # # ]: 32 : static_cast< cppu::OWeakObject * >(this));
[ # # ][ + - ]
697 : : }
698 : :
699 : 0 : void RegistryKey::setStringValue(rtl::OUString const &)
700 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
701 : : {
702 : : throw css::uno::RuntimeException(
703 : : rtl::OUString(
704 : : RTL_CONSTASCII_USTRINGPARAM(
705 : : "com.sun.star.configuration.ConfigurationRegistry: not"
706 : : " implemented")),
707 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
708 : : }
709 : :
710 : 0 : css::uno::Sequence< rtl::OUString > RegistryKey::getStringListValue()
711 : : throw (
712 : : css::registry::InvalidRegistryException,
713 : : css::registry::InvalidValueException, css::uno::RuntimeException)
714 : : {
715 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
716 [ # # ]: 0 : service_.checkValid();
717 [ # # ]: 0 : css::uno::Sequence< rtl::OUString > v;
718 [ # # ][ # # ]: 0 : if (value_ >>= v) {
719 : 0 : return v;
720 : : }
721 : : throw css::registry::InvalidValueException(
722 : : rtl::OUString(
723 : : RTL_CONSTASCII_USTRINGPARAM(
724 : : "com.sun.star.configuration.ConfigurationRegistry")),
725 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ][ # # ]
726 : : }
727 : :
728 : 0 : void RegistryKey::setStringListValue(
729 : : css::uno::Sequence< rtl::OUString > const &)
730 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
731 : : {
732 : : throw css::uno::RuntimeException(
733 : : rtl::OUString(
734 : : RTL_CONSTASCII_USTRINGPARAM(
735 : : "com.sun.star.configuration.ConfigurationRegistry: not"
736 : : " implemented")),
737 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
738 : : }
739 : :
740 : 0 : css::uno::Sequence< sal_Int8 > RegistryKey::getBinaryValue()
741 : : throw (
742 : : css::registry::InvalidRegistryException,
743 : : css::registry::InvalidValueException, css::uno::RuntimeException)
744 : : {
745 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
746 [ # # ]: 0 : service_.checkValid();
747 [ # # ]: 0 : css::uno::Sequence< sal_Int8 > v;
748 [ # # ][ # # ]: 0 : if (value_ >>= v) {
749 : 0 : return v;
750 : : }
751 : : throw css::registry::InvalidValueException(
752 : : rtl::OUString(
753 : : RTL_CONSTASCII_USTRINGPARAM(
754 : : "com.sun.star.configuration.ConfigurationRegistry")),
755 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ][ # # ]
756 : : }
757 : :
758 : 0 : void RegistryKey::setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
759 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
760 : : {
761 : : throw css::uno::RuntimeException(
762 : : rtl::OUString(
763 : : RTL_CONSTASCII_USTRINGPARAM(
764 : : "com.sun.star.configuration.ConfigurationRegistry: not"
765 : : " implemented")),
766 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
767 : : }
768 : :
769 : 28 : css::uno::Reference< css::registry::XRegistryKey > RegistryKey::openKey(
770 : : rtl::OUString const & aKeyName)
771 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
772 : : {
773 [ + - ]: 28 : osl::MutexGuard g(service_.mutex_);
774 [ + - ]: 28 : service_.checkValid_RuntimeException();
775 : 28 : css::uno::Reference< css::container::XHierarchicalNameAccess > access;
776 [ + - ][ + - ]: 28 : if (value_ >>= access) {
777 : : try {
778 : : return new RegistryKey(
779 [ + - ][ + - ]: 28 : service_, access->getByHierarchicalName(aKeyName));
[ + - ][ + - ]
[ + - ][ # # ]
780 [ # # ]: 0 : } catch (css::container::NoSuchElementException &) {}
781 : : }
782 [ + - ]: 28 : return css::uno::Reference< css::registry::XRegistryKey >();
783 : : }
784 : :
785 : 0 : css::uno::Reference< css::registry::XRegistryKey > RegistryKey::createKey(
786 : : rtl::OUString const &)
787 : : throw (
788 : : css::registry::InvalidRegistryException, css::uno::RuntimeException)
789 : : {
790 : : throw css::uno::RuntimeException(
791 : : rtl::OUString(
792 : : RTL_CONSTASCII_USTRINGPARAM(
793 : : "com.sun.star.configuration.ConfigurationRegistry: not"
794 : : " implemented")),
795 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
796 : : }
797 : :
798 : 0 : void RegistryKey::closeKey()
799 : : throw (
800 : : css::registry::InvalidRegistryException, css::uno::RuntimeException)
801 : : {
802 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
803 [ # # ][ # # ]: 0 : service_.checkValid_RuntimeException();
804 : 0 : }
805 : :
806 : 0 : void RegistryKey::deleteKey(rtl::OUString const &)
807 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
808 : : {
809 : : throw css::uno::RuntimeException(
810 : : rtl::OUString(
811 : : RTL_CONSTASCII_USTRINGPARAM(
812 : : "com.sun.star.configuration.ConfigurationRegistry: not"
813 : : " implemented")),
814 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
815 : : }
816 : :
817 : : css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
818 : 0 : RegistryKey::openKeys()
819 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
820 : : {
821 : : throw css::uno::RuntimeException(
822 : : rtl::OUString(
823 : : RTL_CONSTASCII_USTRINGPARAM(
824 : : "com.sun.star.configuration.ConfigurationRegistry: not"
825 : : " implemented")),
826 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
827 : : }
828 : :
829 : 0 : css::uno::Sequence< rtl::OUString > RegistryKey::getKeyNames()
830 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
831 : : {
832 : : throw css::uno::RuntimeException(
833 : : rtl::OUString(
834 : : RTL_CONSTASCII_USTRINGPARAM(
835 : : "com.sun.star.configuration.ConfigurationRegistry: not"
836 : : " implemented")),
837 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
838 : : }
839 : :
840 : 0 : sal_Bool RegistryKey::createLink(rtl::OUString const &, rtl::OUString const &)
841 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
842 : : {
843 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
844 [ # # ]: 0 : service_.checkValid_RuntimeException();
845 [ # # ]: 0 : return false;
846 : : }
847 : :
848 : 0 : void RegistryKey::deleteLink(rtl::OUString const &)
849 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
850 : : {
851 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
852 [ # # ][ # # ]: 0 : service_.checkValid_RuntimeException();
853 : 0 : }
854 : :
855 : 0 : rtl::OUString RegistryKey::getLinkTarget(rtl::OUString const &)
856 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
857 : : {
858 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
859 [ # # ]: 0 : service_.checkValid_RuntimeException();
860 [ # # ]: 0 : return rtl::OUString();
861 : : }
862 : :
863 : 0 : rtl::OUString RegistryKey::getResolvedName(rtl::OUString const & aKeyName)
864 : : throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
865 : : {
866 [ # # ]: 0 : osl::MutexGuard g(service_.mutex_);
867 [ # # ]: 0 : service_.checkValid_RuntimeException();
868 [ # # ]: 0 : return aKeyName;
869 : : }
870 : :
871 : : }
872 : :
873 : 12 : css::uno::Reference< css::uno::XInterface > create(
874 : : css::uno::Reference< css::uno::XComponentContext > const & context)
875 : : {
876 [ + - ]: 12 : return static_cast< cppu::OWeakObject * >(new Service(context));
877 : : }
878 : :
879 : 954 : rtl::OUString getImplementationName() {
880 : : return rtl::OUString(
881 : : RTL_CONSTASCII_USTRINGPARAM(
882 : 954 : "com.sun.star.comp.configuration.ConfigurationRegistry"));
883 : : }
884 : :
885 : 4 : css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
886 : : rtl::OUString name(
887 : : RTL_CONSTASCII_USTRINGPARAM(
888 [ + - ]: 4 : "com.sun.star.configuration.ConfigurationRegistry"));
889 [ + - ]: 4 : return css::uno::Sequence< rtl::OUString >(&name, 1);
890 : : }
891 : :
892 : : } }
893 : :
894 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|