Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / configmgr / source / configurationregistry.cxx
blob7df357e728b8f2cae0f284c6c9d072a388d30411
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "sal/config.h"
22 #include <cassert>
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/XMultiServiceFactory.hpp"
32 #include "com/sun/star/lang/XServiceInfo.hpp"
33 #include "com/sun/star/registry/InvalidRegistryException.hpp"
34 #include "com/sun/star/registry/InvalidValueException.hpp"
35 #include "com/sun/star/registry/MergeConflictException.hpp"
36 #include "com/sun/star/registry/RegistryKeyType.hpp"
37 #include "com/sun/star/registry/RegistryValueType.hpp"
38 #include "com/sun/star/registry/XRegistryKey.hpp"
39 #include "com/sun/star/registry/XSimpleRegistry.hpp"
40 #include "com/sun/star/uno/Any.hxx"
41 #include "com/sun/star/uno/DeploymentException.hpp"
42 #include "com/sun/star/uno/Exception.hpp"
43 #include "com/sun/star/uno/Reference.hxx"
44 #include "com/sun/star/uno/RuntimeException.hpp"
45 #include "com/sun/star/uno/Sequence.hxx"
46 #include "com/sun/star/uno/Type.hxx"
47 #include "com/sun/star/uno/TypeClass.hpp"
48 #include "com/sun/star/uno/XComponentContext.hpp"
49 #include "com/sun/star/uno/XInterface.hpp"
50 #include "com/sun/star/util/XFlushable.hpp"
51 #include "cppu/unotype.hxx"
52 #include "cppuhelper/implbase1.hxx"
53 #include "cppuhelper/implbase3.hxx"
54 #include "cppuhelper/weak.hxx"
55 #include "osl/mutex.hxx"
56 #include "rtl/ustring.h"
57 #include "rtl/ustring.hxx"
58 #include "sal/types.h"
60 #include "configurationregistry.hxx"
62 namespace com { namespace sun { namespace star { namespace util {
63 class XFlushListener;
64 } } } }
66 namespace configmgr { namespace configuration_registry {
68 namespace {
70 class Service:
71 public cppu::WeakImplHelper3<
72 css::lang::XServiceInfo, css::registry::XSimpleRegistry,
73 css::util::XFlushable >,
74 private boost::noncopyable
76 public:
77 Service(css::uno::Reference< css::uno::XComponentContext > const & context);
79 private:
80 virtual ~Service() {}
82 virtual rtl::OUString SAL_CALL getImplementationName()
83 throw (css::uno::RuntimeException)
84 { return configuration_registry::getImplementationName(); }
86 virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
87 throw (css::uno::RuntimeException)
88 { return ServiceName == getSupportedServiceNames()[0]; } //TODO
90 virtual css::uno::Sequence< rtl::OUString > SAL_CALL
91 getSupportedServiceNames() throw (css::uno::RuntimeException)
92 { return configuration_registry::getSupportedServiceNames(); }
94 virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException);
96 virtual void SAL_CALL open(
97 rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
98 throw (
99 css::registry::InvalidRegistryException,
100 css::uno::RuntimeException);
102 virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException);
104 virtual void SAL_CALL close()
105 throw (
106 css::registry::InvalidRegistryException,
107 css::uno::RuntimeException);
109 virtual void SAL_CALL destroy()
110 throw (
111 css::registry::InvalidRegistryException,
112 css::uno::RuntimeException);
114 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
115 getRootKey()
116 throw (
117 css::registry::InvalidRegistryException,
118 css::uno::RuntimeException);
120 virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException);
122 virtual void SAL_CALL mergeKey(rtl::OUString const &, rtl::OUString const &)
123 throw (
124 css::registry::InvalidRegistryException,
125 css::registry::MergeConflictException, css::uno::RuntimeException);
127 virtual void SAL_CALL flush() throw (css::uno::RuntimeException);
129 virtual void SAL_CALL addFlushListener(
130 css::uno::Reference< css::util::XFlushListener > const &)
131 throw (css::uno::RuntimeException);
133 virtual void SAL_CALL removeFlushListener(
134 css::uno::Reference< css::util::XFlushListener > const &)
135 throw (css::uno::RuntimeException);
137 void checkValid();
139 void checkValid_RuntimeException();
141 void doClose();
143 css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
144 osl::Mutex mutex_;
145 css::uno::Reference< css::uno::XInterface > access_;
146 rtl::OUString url_;
147 bool readOnly_;
149 friend class RegistryKey;
152 class RegistryKey:
153 public cppu::WeakImplHelper1< css::registry::XRegistryKey >,
154 private boost::noncopyable
156 public:
157 RegistryKey(Service & service, css::uno::Any const & value):
158 service_(service), value_(value) {}
160 private:
161 virtual ~RegistryKey() {}
163 virtual rtl::OUString SAL_CALL getKeyName()
164 throw (css::uno::RuntimeException);
166 virtual sal_Bool SAL_CALL isReadOnly()
167 throw (
168 css::registry::InvalidRegistryException,
169 css::uno::RuntimeException);
171 virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException);
173 virtual css::registry::RegistryKeyType SAL_CALL getKeyType(
174 rtl::OUString const &)
175 throw (
176 css::registry::InvalidRegistryException,
177 css::uno::RuntimeException);
179 virtual css::registry::RegistryValueType SAL_CALL getValueType()
180 throw (
181 css::registry::InvalidRegistryException,
182 css::uno::RuntimeException);
184 virtual sal_Int32 SAL_CALL getLongValue()
185 throw (
186 css::registry::InvalidRegistryException,
187 css::registry::InvalidValueException, css::uno::RuntimeException);
189 virtual void SAL_CALL setLongValue(sal_Int32)
190 throw (
191 css::registry::InvalidRegistryException,
192 css::uno::RuntimeException);
194 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue()
195 throw (
196 css::registry::InvalidRegistryException,
197 css::registry::InvalidValueException, css::uno::RuntimeException);
199 virtual void SAL_CALL setLongListValue(
200 css::uno::Sequence< sal_Int32 > const &)
201 throw (
202 css::registry::InvalidRegistryException,
203 css::uno::RuntimeException);
205 virtual rtl::OUString SAL_CALL getAsciiValue()
206 throw (
207 css::registry::InvalidRegistryException,
208 css::registry::InvalidValueException, css::uno::RuntimeException);
210 virtual void SAL_CALL setAsciiValue(rtl::OUString const &)
211 throw (
212 css::registry::InvalidRegistryException,
213 css::uno::RuntimeException);
215 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue()
216 throw (
217 css::registry::InvalidRegistryException,
218 css::registry::InvalidValueException, css::uno::RuntimeException);
220 virtual void SAL_CALL setAsciiListValue(
221 css::uno::Sequence< rtl::OUString > const &)
222 throw (
223 css::registry::InvalidRegistryException,
224 css::uno::RuntimeException);
226 virtual rtl::OUString SAL_CALL getStringValue()
227 throw (
228 css::registry::InvalidRegistryException,
229 css::registry::InvalidValueException, css::uno::RuntimeException);
231 virtual void SAL_CALL setStringValue(rtl::OUString const &)
232 throw (
233 css::registry::InvalidRegistryException,
234 css::uno::RuntimeException);
236 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getStringListValue()
237 throw (
238 css::registry::InvalidRegistryException,
239 css::registry::InvalidValueException, css::uno::RuntimeException);
241 virtual void SAL_CALL setStringListValue(
242 css::uno::Sequence< rtl::OUString > const &)
243 throw (
244 css::registry::InvalidRegistryException,
245 css::uno::RuntimeException);
247 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue()
248 throw (
249 css::registry::InvalidRegistryException,
250 css::registry::InvalidValueException, css::uno::RuntimeException);
252 virtual void SAL_CALL setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
253 throw (
254 css::registry::InvalidRegistryException,
255 css::uno::RuntimeException);
257 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey(
258 rtl::OUString const & aKeyName)
259 throw (
260 css::registry::InvalidRegistryException,
261 css::uno::RuntimeException);
263 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
264 createKey(rtl::OUString const &)
265 throw (
266 css::registry::InvalidRegistryException,
267 css::uno::RuntimeException);
269 virtual void SAL_CALL closeKey()
270 throw (
271 css::registry::InvalidRegistryException,
272 css::uno::RuntimeException);
274 virtual void SAL_CALL deleteKey(rtl::OUString const &)
275 throw (
276 css::registry::InvalidRegistryException,
277 css::uno::RuntimeException);
279 virtual
280 css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
281 SAL_CALL openKeys()
282 throw (
283 css::registry::InvalidRegistryException,
284 css::uno::RuntimeException);
286 virtual css::uno::Sequence< rtl::OUString > SAL_CALL getKeyNames()
287 throw (
288 css::registry::InvalidRegistryException,
289 css::uno::RuntimeException);
291 virtual sal_Bool SAL_CALL createLink(
292 rtl::OUString const &, rtl::OUString const &)
293 throw (
294 css::registry::InvalidRegistryException,
295 css::uno::RuntimeException);
297 virtual void SAL_CALL deleteLink(rtl::OUString const &)
298 throw (
299 css::registry::InvalidRegistryException,
300 css::uno::RuntimeException);
302 virtual rtl::OUString SAL_CALL getLinkTarget(rtl::OUString const &)
303 throw (
304 css::registry::InvalidRegistryException,
305 css::uno::RuntimeException);
307 virtual rtl::OUString SAL_CALL getResolvedName(
308 rtl::OUString const & aKeyName)
309 throw (
310 css::registry::InvalidRegistryException,
311 css::uno::RuntimeException);
313 Service & service_;
314 css::uno::Any value_;
317 Service::Service(
318 css::uno::Reference< css::uno::XComponentContext > const & context)
320 assert(context.is());
321 try {
322 provider_ = css::uno::Reference< css::lang::XMultiServiceFactory >(
323 context->getServiceManager()->createInstanceWithContext(
324 rtl::OUString(
325 RTL_CONSTASCII_USTRINGPARAM(
326 "com.sun.star.configuration.DefaultProvider")),
327 context),
328 css::uno::UNO_QUERY_THROW);
329 } catch (css::uno::RuntimeException &) {
330 throw;
331 } catch (css::uno::Exception & e) {
332 throw css::uno::DeploymentException(
333 (rtl::OUString(
334 RTL_CONSTASCII_USTRINGPARAM(
335 "component context fails to supply service"
336 " com.sun.star.configuration.DefaultProvider of type"
337 " com.sun.star.lang.XMultiServiceFactory: ")) +
338 e.Message),
339 context);
343 rtl::OUString Service::getURL() throw (css::uno::RuntimeException) {
344 osl::MutexGuard g(mutex_);
345 checkValid_RuntimeException();
346 return url_;
349 void Service::open(rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
350 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
352 //TODO: bCreate
353 osl::MutexGuard g(mutex_);
354 if (access_.is()) {
355 doClose();
357 css::uno::Sequence< css::uno::Any > args(1);
358 args[0] <<= css::beans::NamedValue(
359 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
360 css::uno::makeAny(rURL));
361 try {
362 access_ = provider_->createInstanceWithArguments(
363 (bReadOnly
364 ? rtl::OUString(
365 RTL_CONSTASCII_USTRINGPARAM(
366 "com.sun.star.configuration.ConfigurationAccess"))
367 : rtl::OUString(
368 RTL_CONSTASCII_USTRINGPARAM(
369 "com.sun.star.configuration.ConfigurationUpdateAccess"))),
370 args);
371 } catch (css::uno::RuntimeException &) {
372 throw;
373 } catch (css::uno::Exception & e) {
374 throw css::uno::RuntimeException(
375 (rtl::OUString(
376 RTL_CONSTASCII_USTRINGPARAM(
377 "com.sun.star.configuration.ConfigurationRegistry: open"
378 " failed: ")) +
379 e.Message),
380 static_cast< cppu::OWeakObject * >(this));
382 url_ = rURL;
383 readOnly_ = bReadOnly;
386 sal_Bool Service::isValid() throw (css::uno::RuntimeException) {
387 osl::MutexGuard g(mutex_);
388 return access_.is();
391 void Service::close()
392 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
394 osl::MutexGuard g(mutex_);
395 checkValid();
396 doClose();
399 void Service::destroy()
400 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
402 throw css::uno::RuntimeException(
403 rtl::OUString(
404 RTL_CONSTASCII_USTRINGPARAM(
405 "com.sun.star.configuration.ConfigurationRegistry: not"
406 " implemented")),
407 static_cast< cppu::OWeakObject * >(this));
410 css::uno::Reference< css::registry::XRegistryKey > Service::getRootKey()
411 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
413 osl::MutexGuard g(mutex_);
414 checkValid();
415 return new RegistryKey(*this, css::uno::makeAny(access_));
418 sal_Bool Service::isReadOnly() throw (css::uno::RuntimeException) {
419 osl::MutexGuard g(mutex_);
420 checkValid_RuntimeException();
421 return readOnly_;
424 void Service::mergeKey(rtl::OUString const &, rtl::OUString const &)
425 throw (
426 css::registry::InvalidRegistryException,
427 css::registry::MergeConflictException, css::uno::RuntimeException)
429 throw css::uno::RuntimeException(
430 rtl::OUString(
431 RTL_CONSTASCII_USTRINGPARAM(
432 "com.sun.star.configuration.ConfigurationRegistry: not"
433 " implemented")),
434 static_cast< cppu::OWeakObject * >(this));
437 void Service::flush() throw (css::uno::RuntimeException)
439 throw css::uno::RuntimeException(
440 rtl::OUString(
441 RTL_CONSTASCII_USTRINGPARAM(
442 "com.sun.star.configuration.ConfigurationRegistry: not"
443 " implemented")),
444 static_cast< cppu::OWeakObject * >(this));
447 void Service::addFlushListener(
448 css::uno::Reference< css::util::XFlushListener > const &)
449 throw (css::uno::RuntimeException)
451 throw css::uno::RuntimeException(
452 rtl::OUString(
453 RTL_CONSTASCII_USTRINGPARAM(
454 "com.sun.star.configuration.ConfigurationRegistry: not"
455 " implemented")),
456 static_cast< cppu::OWeakObject * >(this));
459 void Service::removeFlushListener(
460 css::uno::Reference< css::util::XFlushListener > const &)
461 throw (css::uno::RuntimeException)
463 throw css::uno::RuntimeException(
464 rtl::OUString(
465 RTL_CONSTASCII_USTRINGPARAM(
466 "com.sun.star.configuration.ConfigurationRegistry: not"
467 " implemented")),
468 static_cast< cppu::OWeakObject * >(this));
471 void Service::checkValid() {
472 if (!access_.is()) {
473 throw css::registry::InvalidRegistryException(
474 rtl::OUString(
475 RTL_CONSTASCII_USTRINGPARAM(
476 "com.sun.star.configuration.ConfigurationRegistry: not"
477 " valid")),
478 static_cast< cppu::OWeakObject * >(this));
482 void Service::checkValid_RuntimeException() {
483 if (!access_.is()) {
484 throw css::uno::RuntimeException(
485 rtl::OUString(
486 RTL_CONSTASCII_USTRINGPARAM(
487 "com.sun.star.configuration.ConfigurationRegistry: not"
488 " valid")),
489 static_cast< cppu::OWeakObject * >(this));
493 void Service::doClose() {
494 access_.clear();
497 rtl::OUString RegistryKey::getKeyName() throw (css::uno::RuntimeException) {
498 osl::MutexGuard g(service_.mutex_);
499 service_.checkValid_RuntimeException();
500 css::uno::Reference< css::container::XNamed > named;
501 if (value_ >>= named) {
502 return named->getName();
504 throw css::uno::RuntimeException(
505 rtl::OUString(
506 RTL_CONSTASCII_USTRINGPARAM(
507 "com.sun.star.configuration.ConfigurationRegistry: not"
508 " implemented")),
509 static_cast< cppu::OWeakObject * >(this));
512 sal_Bool RegistryKey::isReadOnly()
513 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
515 osl::MutexGuard g(service_.mutex_);
516 service_.checkValid_RuntimeException();
517 return service_.readOnly_; //TODO: read-only sub-nodes in update access?
520 sal_Bool RegistryKey::isValid() throw (css::uno::RuntimeException) {
521 return service_.isValid();
524 css::registry::RegistryKeyType RegistryKey::getKeyType(rtl::OUString const &)
525 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
527 osl::MutexGuard g(service_.mutex_);
528 service_.checkValid();
529 return css::registry::RegistryKeyType_KEY;
532 css::registry::RegistryValueType RegistryKey::getValueType()
533 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
535 osl::MutexGuard g(service_.mutex_);
536 service_.checkValid();
537 css::uno::Type t(value_.getValueType());
538 switch (t.getTypeClass()) {
539 case css::uno::TypeClass_LONG:
540 return css::registry::RegistryValueType_LONG;
541 case css::uno::TypeClass_STRING:
542 return css::registry::RegistryValueType_STRING;
543 case css::uno::TypeClass_SEQUENCE:
544 if (t == cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get()) {
545 return css::registry::RegistryValueType_BINARY;
546 } else if (t == cppu::UnoType< css::uno::Sequence< sal_Int32 > >::get())
548 return css::registry::RegistryValueType_LONGLIST;
549 } else if (t ==
550 cppu::UnoType< css::uno::Sequence< rtl::OUString > >::get())
552 return css::registry::RegistryValueType_STRINGLIST;
554 // fall through
555 default:
556 return css::registry::RegistryValueType_NOT_DEFINED;
560 sal_Int32 RegistryKey::getLongValue()
561 throw (
562 css::registry::InvalidRegistryException,
563 css::registry::InvalidValueException, css::uno::RuntimeException)
565 osl::MutexGuard g(service_.mutex_);
566 service_.checkValid();
567 sal_Int32 v = 0;
568 if (value_ >>= v) {
569 return v;
571 throw css::registry::InvalidValueException(
572 rtl::OUString(
573 RTL_CONSTASCII_USTRINGPARAM(
574 "com.sun.star.configuration.ConfigurationRegistry")),
575 static_cast< cppu::OWeakObject * >(this));
578 void RegistryKey::setLongValue(sal_Int32)
579 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
581 throw css::uno::RuntimeException(
582 rtl::OUString(
583 RTL_CONSTASCII_USTRINGPARAM(
584 "com.sun.star.configuration.ConfigurationRegistry: not"
585 " implemented")),
586 static_cast< cppu::OWeakObject * >(this));
589 css::uno::Sequence< sal_Int32 > RegistryKey::getLongListValue()
590 throw (
591 css::registry::InvalidRegistryException,
592 css::registry::InvalidValueException, css::uno::RuntimeException)
594 osl::MutexGuard g(service_.mutex_);
595 service_.checkValid();
596 css::uno::Sequence< sal_Int32 > v;
597 if (value_ >>= v) {
598 return v;
600 throw css::registry::InvalidValueException(
601 rtl::OUString(
602 RTL_CONSTASCII_USTRINGPARAM(
603 "com.sun.star.configuration.ConfigurationRegistry")),
604 static_cast< cppu::OWeakObject * >(this));
607 void RegistryKey::setLongListValue(css::uno::Sequence< sal_Int32 > const &)
608 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
610 throw css::uno::RuntimeException(
611 rtl::OUString(
612 RTL_CONSTASCII_USTRINGPARAM(
613 "com.sun.star.configuration.ConfigurationRegistry: not"
614 " implemented")),
615 static_cast< cppu::OWeakObject * >(this));
618 rtl::OUString RegistryKey::getAsciiValue()
619 throw (
620 css::registry::InvalidRegistryException,
621 css::registry::InvalidValueException, css::uno::RuntimeException)
623 osl::MutexGuard g(service_.mutex_);
624 service_.checkValid();
625 rtl::OUString v;
626 if (value_ >>= v) {
627 return v;
629 throw css::registry::InvalidValueException(
630 rtl::OUString(
631 RTL_CONSTASCII_USTRINGPARAM(
632 "com.sun.star.configuration.ConfigurationRegistry")),
633 static_cast< cppu::OWeakObject * >(this));
636 void RegistryKey::setAsciiValue(rtl::OUString const &)
637 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
639 throw css::uno::RuntimeException(
640 rtl::OUString(
641 RTL_CONSTASCII_USTRINGPARAM(
642 "com.sun.star.configuration.ConfigurationRegistry: not"
643 " implemented")),
644 static_cast< cppu::OWeakObject * >(this));
647 css::uno::Sequence< rtl::OUString > RegistryKey::getAsciiListValue()
648 throw (
649 css::registry::InvalidRegistryException,
650 css::registry::InvalidValueException, css::uno::RuntimeException)
652 osl::MutexGuard g(service_.mutex_);
653 service_.checkValid();
654 css::uno::Sequence< rtl::OUString > v;
655 if (value_ >>= v) {
656 return v;
658 throw css::registry::InvalidValueException(
659 rtl::OUString(
660 RTL_CONSTASCII_USTRINGPARAM(
661 "com.sun.star.configuration.ConfigurationRegistry")),
662 static_cast< cppu::OWeakObject * >(this));
665 void RegistryKey::setAsciiListValue(css::uno::Sequence< rtl::OUString > const &)
666 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
668 throw css::uno::RuntimeException(
669 rtl::OUString(
670 RTL_CONSTASCII_USTRINGPARAM(
671 "com.sun.star.configuration.ConfigurationRegistry: not"
672 " implemented")),
673 static_cast< cppu::OWeakObject * >(this));
676 rtl::OUString RegistryKey::getStringValue()
677 throw (
678 css::registry::InvalidRegistryException,
679 css::registry::InvalidValueException, css::uno::RuntimeException)
681 osl::MutexGuard g(service_.mutex_);
682 service_.checkValid();
683 rtl::OUString v;
684 if (value_ >>= v) {
685 return v;
687 throw css::registry::InvalidValueException(
688 rtl::OUString(
689 RTL_CONSTASCII_USTRINGPARAM(
690 "com.sun.star.configuration.ConfigurationRegistry")),
691 static_cast< cppu::OWeakObject * >(this));
694 void RegistryKey::setStringValue(rtl::OUString const &)
695 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
697 throw css::uno::RuntimeException(
698 rtl::OUString(
699 RTL_CONSTASCII_USTRINGPARAM(
700 "com.sun.star.configuration.ConfigurationRegistry: not"
701 " implemented")),
702 static_cast< cppu::OWeakObject * >(this));
705 css::uno::Sequence< rtl::OUString > RegistryKey::getStringListValue()
706 throw (
707 css::registry::InvalidRegistryException,
708 css::registry::InvalidValueException, css::uno::RuntimeException)
710 osl::MutexGuard g(service_.mutex_);
711 service_.checkValid();
712 css::uno::Sequence< rtl::OUString > v;
713 if (value_ >>= v) {
714 return v;
716 throw css::registry::InvalidValueException(
717 rtl::OUString(
718 RTL_CONSTASCII_USTRINGPARAM(
719 "com.sun.star.configuration.ConfigurationRegistry")),
720 static_cast< cppu::OWeakObject * >(this));
723 void RegistryKey::setStringListValue(
724 css::uno::Sequence< rtl::OUString > const &)
725 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
727 throw css::uno::RuntimeException(
728 rtl::OUString(
729 RTL_CONSTASCII_USTRINGPARAM(
730 "com.sun.star.configuration.ConfigurationRegistry: not"
731 " implemented")),
732 static_cast< cppu::OWeakObject * >(this));
735 css::uno::Sequence< sal_Int8 > RegistryKey::getBinaryValue()
736 throw (
737 css::registry::InvalidRegistryException,
738 css::registry::InvalidValueException, css::uno::RuntimeException)
740 osl::MutexGuard g(service_.mutex_);
741 service_.checkValid();
742 css::uno::Sequence< sal_Int8 > v;
743 if (value_ >>= v) {
744 return v;
746 throw css::registry::InvalidValueException(
747 rtl::OUString(
748 RTL_CONSTASCII_USTRINGPARAM(
749 "com.sun.star.configuration.ConfigurationRegistry")),
750 static_cast< cppu::OWeakObject * >(this));
753 void RegistryKey::setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
754 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
756 throw css::uno::RuntimeException(
757 rtl::OUString(
758 RTL_CONSTASCII_USTRINGPARAM(
759 "com.sun.star.configuration.ConfigurationRegistry: not"
760 " implemented")),
761 static_cast< cppu::OWeakObject * >(this));
764 css::uno::Reference< css::registry::XRegistryKey > RegistryKey::openKey(
765 rtl::OUString const & aKeyName)
766 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
768 osl::MutexGuard g(service_.mutex_);
769 service_.checkValid_RuntimeException();
770 css::uno::Reference< css::container::XHierarchicalNameAccess > access;
771 if (value_ >>= access) {
772 try {
773 return new RegistryKey(
774 service_, access->getByHierarchicalName(aKeyName));
775 } catch (css::container::NoSuchElementException &) {}
777 return css::uno::Reference< css::registry::XRegistryKey >();
780 css::uno::Reference< css::registry::XRegistryKey > RegistryKey::createKey(
781 rtl::OUString const &)
782 throw (
783 css::registry::InvalidRegistryException, css::uno::RuntimeException)
785 throw css::uno::RuntimeException(
786 rtl::OUString(
787 RTL_CONSTASCII_USTRINGPARAM(
788 "com.sun.star.configuration.ConfigurationRegistry: not"
789 " implemented")),
790 static_cast< cppu::OWeakObject * >(this));
793 void RegistryKey::closeKey()
794 throw (
795 css::registry::InvalidRegistryException, css::uno::RuntimeException)
797 osl::MutexGuard g(service_.mutex_);
798 service_.checkValid_RuntimeException();
801 void RegistryKey::deleteKey(rtl::OUString const &)
802 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
804 throw css::uno::RuntimeException(
805 rtl::OUString(
806 RTL_CONSTASCII_USTRINGPARAM(
807 "com.sun.star.configuration.ConfigurationRegistry: not"
808 " implemented")),
809 static_cast< cppu::OWeakObject * >(this));
812 css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
813 RegistryKey::openKeys()
814 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
816 throw css::uno::RuntimeException(
817 rtl::OUString(
818 RTL_CONSTASCII_USTRINGPARAM(
819 "com.sun.star.configuration.ConfigurationRegistry: not"
820 " implemented")),
821 static_cast< cppu::OWeakObject * >(this));
824 css::uno::Sequence< rtl::OUString > RegistryKey::getKeyNames()
825 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
827 throw css::uno::RuntimeException(
828 rtl::OUString(
829 RTL_CONSTASCII_USTRINGPARAM(
830 "com.sun.star.configuration.ConfigurationRegistry: not"
831 " implemented")),
832 static_cast< cppu::OWeakObject * >(this));
835 sal_Bool RegistryKey::createLink(rtl::OUString const &, rtl::OUString const &)
836 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
838 osl::MutexGuard g(service_.mutex_);
839 service_.checkValid_RuntimeException();
840 return false;
843 void RegistryKey::deleteLink(rtl::OUString const &)
844 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
846 osl::MutexGuard g(service_.mutex_);
847 service_.checkValid_RuntimeException();
850 rtl::OUString RegistryKey::getLinkTarget(rtl::OUString const &)
851 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
853 osl::MutexGuard g(service_.mutex_);
854 service_.checkValid_RuntimeException();
855 return rtl::OUString();
858 rtl::OUString RegistryKey::getResolvedName(rtl::OUString const & aKeyName)
859 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
861 osl::MutexGuard g(service_.mutex_);
862 service_.checkValid_RuntimeException();
863 return aKeyName;
868 css::uno::Reference< css::uno::XInterface > create(
869 css::uno::Reference< css::uno::XComponentContext > const & context)
871 return static_cast< cppu::OWeakObject * >(new Service(context));
874 rtl::OUString getImplementationName() {
875 return rtl::OUString(
876 RTL_CONSTASCII_USTRINGPARAM(
877 "com.sun.star.comp.configuration.ConfigurationRegistry"));
880 css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
881 rtl::OUString name(
882 RTL_CONSTASCII_USTRINGPARAM(
883 "com.sun.star.configuration.ConfigurationRegistry"));
884 return css::uno::Sequence< rtl::OUString >(&name, 1);
889 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */