bump product version to 5.0.4.1
[LibreOffice.git] / configmgr / source / configurationregistry.cxx
blob9a9ad9d596baf26f55bbd3f234c4cc093ef3a767
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 <com/sun/star/beans/NamedValue.hpp>
25 #include <com/sun/star/beans/Property.hpp>
26 #include <com/sun/star/beans/XProperty.hpp>
27 #include <com/sun/star/container/NoSuchElementException.hpp>
28 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
29 #include <com/sun/star/container/XNamed.hpp>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/registry/InvalidRegistryException.hpp>
33 #include <com/sun/star/registry/InvalidValueException.hpp>
34 #include <com/sun/star/registry/MergeConflictException.hpp>
35 #include <com/sun/star/registry/RegistryKeyType.hpp>
36 #include <com/sun/star/registry/RegistryValueType.hpp>
37 #include <com/sun/star/registry/XRegistryKey.hpp>
38 #include <com/sun/star/registry/XSimpleRegistry.hpp>
39 #include <com/sun/star/uno/Any.hxx>
40 #include <com/sun/star/uno/DeploymentException.hpp>
41 #include <com/sun/star/uno/Exception.hpp>
42 #include <com/sun/star/uno/Reference.hxx>
43 #include <com/sun/star/uno/RuntimeException.hpp>
44 #include <com/sun/star/uno/Sequence.hxx>
45 #include <com/sun/star/uno/Type.hxx>
46 #include <com/sun/star/uno/TypeClass.hpp>
47 #include <com/sun/star/uno/XComponentContext.hpp>
48 #include <com/sun/star/uno/XInterface.hpp>
49 #include <com/sun/star/util/XFlushable.hpp>
50 #include <cppu/unotype.hxx>
51 #include <cppuhelper/implbase1.hxx>
52 #include <cppuhelper/implbase3.hxx>
53 #include <cppuhelper/supportsservice.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 >
75 public:
76 Service(css::uno::Reference< css::uno::XComponentContext > const & context);
78 private:
79 Service(const Service&) SAL_DELETED_FUNCTION;
80 Service& operator=(const Service&) SAL_DELETED_FUNCTION;
82 virtual ~Service() {}
84 virtual OUString SAL_CALL getImplementationName()
85 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
86 { return configuration_registry::getImplementationName(); }
88 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
89 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
90 { return cppu::supportsService(this, ServiceName); }
92 virtual css::uno::Sequence< OUString > SAL_CALL
93 getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
94 { return configuration_registry::getSupportedServiceNames(); }
96 virtual OUString SAL_CALL getURL() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 virtual void SAL_CALL open(
99 OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
100 throw (
101 css::registry::InvalidRegistryException,
102 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 virtual void SAL_CALL close()
107 throw (
108 css::registry::InvalidRegistryException,
109 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 virtual void SAL_CALL destroy()
112 throw (
113 css::registry::InvalidRegistryException,
114 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
117 getRootKey()
118 throw (
119 css::registry::InvalidRegistryException,
120 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 virtual sal_Bool SAL_CALL isReadOnly() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 virtual void SAL_CALL mergeKey(OUString const &, OUString const &)
125 throw (
126 css::registry::InvalidRegistryException,
127 css::registry::MergeConflictException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 virtual void SAL_CALL flush() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 virtual void SAL_CALL addFlushListener(
132 css::uno::Reference< css::util::XFlushListener > const &)
133 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 virtual void SAL_CALL removeFlushListener(
136 css::uno::Reference< css::util::XFlushListener > const &)
137 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 void checkValid();
141 void checkValid_RuntimeException();
143 void doClose();
145 css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
146 osl::Mutex mutex_;
147 css::uno::Reference< css::uno::XInterface > access_;
148 OUString url_;
149 bool readOnly_;
151 friend class RegistryKey;
154 class RegistryKey:
155 public cppu::WeakImplHelper1< css::registry::XRegistryKey >
157 public:
158 RegistryKey(Service & service, css::uno::Any const & value):
159 service_(service), value_(value) {}
161 private:
162 RegistryKey(const RegistryKey&) SAL_DELETED_FUNCTION;
163 RegistryKey& operator=(const RegistryKey&) SAL_DELETED_FUNCTION;
165 virtual ~RegistryKey() {}
167 virtual OUString SAL_CALL getKeyName()
168 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 virtual sal_Bool SAL_CALL isReadOnly()
171 throw (
172 css::registry::InvalidRegistryException,
173 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 virtual css::registry::RegistryKeyType SAL_CALL getKeyType(
178 OUString const &)
179 throw (
180 css::registry::InvalidRegistryException,
181 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 virtual css::registry::RegistryValueType SAL_CALL getValueType()
184 throw (
185 css::registry::InvalidRegistryException,
186 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
188 virtual sal_Int32 SAL_CALL getLongValue()
189 throw (
190 css::registry::InvalidRegistryException,
191 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 virtual void SAL_CALL setLongValue(sal_Int32)
194 throw (
195 css::registry::InvalidRegistryException,
196 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue()
199 throw (
200 css::registry::InvalidRegistryException,
201 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
203 virtual void SAL_CALL setLongListValue(
204 css::uno::Sequence< sal_Int32 > const &)
205 throw (
206 css::registry::InvalidRegistryException,
207 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 virtual OUString SAL_CALL getAsciiValue()
210 throw (
211 css::registry::InvalidRegistryException,
212 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
214 virtual void SAL_CALL setAsciiValue(OUString const &)
215 throw (
216 css::registry::InvalidRegistryException,
217 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
219 virtual css::uno::Sequence< OUString > SAL_CALL getAsciiListValue()
220 throw (
221 css::registry::InvalidRegistryException,
222 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
224 virtual void SAL_CALL setAsciiListValue(
225 css::uno::Sequence< OUString > const &)
226 throw (
227 css::registry::InvalidRegistryException,
228 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
230 virtual OUString SAL_CALL getStringValue()
231 throw (
232 css::registry::InvalidRegistryException,
233 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
235 virtual void SAL_CALL setStringValue(OUString const &)
236 throw (
237 css::registry::InvalidRegistryException,
238 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
240 virtual css::uno::Sequence< OUString > SAL_CALL getStringListValue()
241 throw (
242 css::registry::InvalidRegistryException,
243 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
245 virtual void SAL_CALL setStringListValue(
246 css::uno::Sequence< OUString > const &)
247 throw (
248 css::registry::InvalidRegistryException,
249 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
251 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue()
252 throw (
253 css::registry::InvalidRegistryException,
254 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
256 virtual void SAL_CALL setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
257 throw (
258 css::registry::InvalidRegistryException,
259 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
261 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey(
262 OUString const & aKeyName)
263 throw (
264 css::registry::InvalidRegistryException,
265 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
267 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
268 createKey(OUString const &)
269 throw (
270 css::registry::InvalidRegistryException,
271 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
273 virtual void SAL_CALL closeKey()
274 throw (
275 css::registry::InvalidRegistryException,
276 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
278 virtual void SAL_CALL deleteKey(OUString const &)
279 throw (
280 css::registry::InvalidRegistryException,
281 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
283 virtual
284 css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
285 SAL_CALL openKeys()
286 throw (
287 css::registry::InvalidRegistryException,
288 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
290 virtual css::uno::Sequence< OUString > SAL_CALL getKeyNames()
291 throw (
292 css::registry::InvalidRegistryException,
293 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
295 virtual sal_Bool SAL_CALL createLink(
296 OUString const &, OUString const &)
297 throw (
298 css::registry::InvalidRegistryException,
299 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
301 virtual void SAL_CALL deleteLink(OUString const &)
302 throw (
303 css::registry::InvalidRegistryException,
304 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
306 virtual OUString SAL_CALL getLinkTarget(OUString const &)
307 throw (
308 css::registry::InvalidRegistryException,
309 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
311 virtual OUString SAL_CALL getResolvedName(
312 OUString const & aKeyName)
313 throw (
314 css::registry::InvalidRegistryException,
315 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
317 Service & service_;
318 css::uno::Any value_;
321 Service::Service(
322 css::uno::Reference< css::uno::XComponentContext > const & context)
323 : readOnly_(false)
325 assert(context.is());
326 try {
327 provider_ = css::uno::Reference< css::lang::XMultiServiceFactory >(
328 context->getServiceManager()->createInstanceWithContext(
329 "com.sun.star.configuration.DefaultProvider", context),
330 css::uno::UNO_QUERY_THROW);
331 } catch (css::uno::RuntimeException &) {
332 throw;
333 } catch (css::uno::Exception & e) {
334 throw css::uno::DeploymentException(
335 ("component context fails to supply service"
336 " com.sun.star.configuration.DefaultProvider of type"
337 " com.sun.star.lang.XMultiServiceFactory: " + e.Message),
338 context);
342 OUString Service::getURL() throw (css::uno::RuntimeException, std::exception) {
343 osl::MutexGuard g(mutex_);
344 checkValid_RuntimeException();
345 return url_;
348 void Service::open(OUString const & rURL, sal_Bool bReadOnly, sal_Bool)
349 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
351 //TODO: bCreate
352 osl::MutexGuard g(mutex_);
353 if (access_.is()) {
354 doClose();
356 css::uno::Sequence< css::uno::Any > args(1);
357 args[0] <<= css::beans::NamedValue("nodepath", css::uno::makeAny(rURL));
358 try {
359 access_ = provider_->createInstanceWithArguments(
360 (bReadOnly
361 ? OUString("com.sun.star.configuration.ConfigurationAccess")
362 : OUString(
363 "com.sun.star.configuration.ConfigurationUpdateAccess")),
364 args);
365 } catch (css::uno::RuntimeException &) {
366 throw;
367 } catch (css::uno::Exception & e) {
368 throw css::uno::RuntimeException(
369 ("com.sun.star.configuration.ConfigurationRegistry: open failed: " +
370 e.Message),
371 static_cast< cppu::OWeakObject * >(this));
373 url_ = rURL;
374 readOnly_ = bReadOnly;
377 sal_Bool Service::isValid() throw (css::uno::RuntimeException, std::exception) {
378 osl::MutexGuard g(mutex_);
379 return access_.is();
382 void Service::close()
383 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
385 osl::MutexGuard g(mutex_);
386 checkValid();
387 doClose();
390 void Service::destroy()
391 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
393 throw css::uno::RuntimeException(
394 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
395 static_cast< cppu::OWeakObject * >(this));
398 css::uno::Reference< css::registry::XRegistryKey > Service::getRootKey()
399 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
401 osl::MutexGuard g(mutex_);
402 checkValid();
403 return new RegistryKey(*this, css::uno::makeAny(access_));
406 sal_Bool Service::isReadOnly() throw (css::uno::RuntimeException, std::exception) {
407 osl::MutexGuard g(mutex_);
408 checkValid_RuntimeException();
409 return readOnly_;
412 void Service::mergeKey(OUString const &, OUString const &)
413 throw (
414 css::registry::InvalidRegistryException,
415 css::registry::MergeConflictException, css::uno::RuntimeException, std::exception)
417 throw css::uno::RuntimeException(
418 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
419 static_cast< cppu::OWeakObject * >(this));
422 void Service::flush() throw (css::uno::RuntimeException, std::exception)
424 throw css::uno::RuntimeException(
425 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
426 static_cast< cppu::OWeakObject * >(this));
429 void Service::addFlushListener(
430 css::uno::Reference< css::util::XFlushListener > const &)
431 throw (css::uno::RuntimeException, std::exception)
433 throw css::uno::RuntimeException(
434 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
435 static_cast< cppu::OWeakObject * >(this));
438 void Service::removeFlushListener(
439 css::uno::Reference< css::util::XFlushListener > const &)
440 throw (css::uno::RuntimeException, std::exception)
442 throw css::uno::RuntimeException(
443 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
444 static_cast< cppu::OWeakObject * >(this));
447 void Service::checkValid() {
448 if (!access_.is()) {
449 throw css::registry::InvalidRegistryException(
450 "com.sun.star.configuration.ConfigurationRegistry: not valid",
451 static_cast< cppu::OWeakObject * >(this));
455 void Service::checkValid_RuntimeException() {
456 if (!access_.is()) {
457 throw css::uno::RuntimeException(
458 "com.sun.star.configuration.ConfigurationRegistry: not valid",
459 static_cast< cppu::OWeakObject * >(this));
463 void Service::doClose() {
464 access_.clear();
467 OUString RegistryKey::getKeyName() throw (css::uno::RuntimeException, std::exception) {
468 osl::MutexGuard g(service_.mutex_);
469 service_.checkValid_RuntimeException();
470 css::uno::Reference< css::container::XNamed > named;
471 if (value_ >>= named) {
472 return named->getName();
474 throw css::uno::RuntimeException(
475 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
476 static_cast< cppu::OWeakObject * >(this));
479 sal_Bool RegistryKey::isReadOnly()
480 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
482 osl::MutexGuard g(service_.mutex_);
483 service_.checkValid_RuntimeException();
484 return service_.readOnly_; //TODO: read-only sub-nodes in update access?
487 sal_Bool RegistryKey::isValid() throw (css::uno::RuntimeException, std::exception) {
488 return service_.isValid();
491 css::registry::RegistryKeyType RegistryKey::getKeyType(OUString const &)
492 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
494 osl::MutexGuard g(service_.mutex_);
495 service_.checkValid();
496 return css::registry::RegistryKeyType_KEY;
499 css::registry::RegistryValueType RegistryKey::getValueType()
500 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
502 osl::MutexGuard g(service_.mutex_);
503 service_.checkValid();
504 css::uno::Type t(value_.getValueType());
505 switch (t.getTypeClass()) {
506 case css::uno::TypeClass_LONG:
507 return css::registry::RegistryValueType_LONG;
508 case css::uno::TypeClass_STRING:
509 return css::registry::RegistryValueType_STRING;
510 case css::uno::TypeClass_SEQUENCE:
511 if (t == cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get()) {
512 return css::registry::RegistryValueType_BINARY;
513 } else if (t == cppu::UnoType< css::uno::Sequence< sal_Int32 > >::get())
515 return css::registry::RegistryValueType_LONGLIST;
516 } else if (t ==
517 cppu::UnoType< css::uno::Sequence< OUString > >::get())
519 return css::registry::RegistryValueType_STRINGLIST;
521 // fall through
522 default:
523 return css::registry::RegistryValueType_NOT_DEFINED;
527 sal_Int32 RegistryKey::getLongValue()
528 throw (
529 css::registry::InvalidRegistryException,
530 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
532 osl::MutexGuard g(service_.mutex_);
533 service_.checkValid();
534 sal_Int32 v = 0;
535 if (value_ >>= v) {
536 return v;
538 throw css::registry::InvalidValueException(
539 "com.sun.star.configuration.ConfigurationRegistry",
540 static_cast< cppu::OWeakObject * >(this));
543 void RegistryKey::setLongValue(sal_Int32)
544 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
546 throw css::uno::RuntimeException(
547 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
548 static_cast< cppu::OWeakObject * >(this));
551 css::uno::Sequence< sal_Int32 > RegistryKey::getLongListValue()
552 throw (
553 css::registry::InvalidRegistryException,
554 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
556 osl::MutexGuard g(service_.mutex_);
557 service_.checkValid();
558 css::uno::Sequence< sal_Int32 > v;
559 if (value_ >>= v) {
560 return v;
562 throw css::registry::InvalidValueException(
563 "com.sun.star.configuration.ConfigurationRegistry",
564 static_cast< cppu::OWeakObject * >(this));
567 void RegistryKey::setLongListValue(css::uno::Sequence< sal_Int32 > const &)
568 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
570 throw css::uno::RuntimeException(
571 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
572 static_cast< cppu::OWeakObject * >(this));
575 OUString RegistryKey::getAsciiValue()
576 throw (
577 css::registry::InvalidRegistryException,
578 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
580 osl::MutexGuard g(service_.mutex_);
581 service_.checkValid();
582 OUString v;
583 if (value_ >>= v) {
584 return v;
586 throw css::registry::InvalidValueException(
587 "com.sun.star.configuration.ConfigurationRegistry",
588 static_cast< cppu::OWeakObject * >(this));
591 void RegistryKey::setAsciiValue(OUString const &)
592 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
594 throw css::uno::RuntimeException(
595 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
596 static_cast< cppu::OWeakObject * >(this));
599 css::uno::Sequence< OUString > RegistryKey::getAsciiListValue()
600 throw (
601 css::registry::InvalidRegistryException,
602 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
604 osl::MutexGuard g(service_.mutex_);
605 service_.checkValid();
606 css::uno::Sequence< OUString > v;
607 if (value_ >>= v) {
608 return v;
610 throw css::registry::InvalidValueException(
611 "com.sun.star.configuration.ConfigurationRegistry",
612 static_cast< cppu::OWeakObject * >(this));
615 void RegistryKey::setAsciiListValue(css::uno::Sequence< OUString > const &)
616 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
618 throw css::uno::RuntimeException(
619 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
620 static_cast< cppu::OWeakObject * >(this));
623 OUString RegistryKey::getStringValue()
624 throw (
625 css::registry::InvalidRegistryException,
626 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
628 osl::MutexGuard g(service_.mutex_);
629 service_.checkValid();
630 OUString v;
631 if (value_ >>= v) {
632 return v;
634 throw css::registry::InvalidValueException(
635 "com.sun.star.configuration.ConfigurationRegistry",
636 static_cast< cppu::OWeakObject * >(this));
639 void RegistryKey::setStringValue(OUString const &)
640 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
642 throw css::uno::RuntimeException(
643 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
644 static_cast< cppu::OWeakObject * >(this));
647 css::uno::Sequence< OUString > RegistryKey::getStringListValue()
648 throw (
649 css::registry::InvalidRegistryException,
650 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
652 osl::MutexGuard g(service_.mutex_);
653 service_.checkValid();
654 css::uno::Sequence< OUString > v;
655 if (value_ >>= v) {
656 return v;
658 throw css::registry::InvalidValueException(
659 "com.sun.star.configuration.ConfigurationRegistry",
660 static_cast< cppu::OWeakObject * >(this));
663 void RegistryKey::setStringListValue(
664 css::uno::Sequence< OUString > const &)
665 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
667 throw css::uno::RuntimeException(
668 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
669 static_cast< cppu::OWeakObject * >(this));
672 css::uno::Sequence< sal_Int8 > RegistryKey::getBinaryValue()
673 throw (
674 css::registry::InvalidRegistryException,
675 css::registry::InvalidValueException, css::uno::RuntimeException, std::exception)
677 osl::MutexGuard g(service_.mutex_);
678 service_.checkValid();
679 css::uno::Sequence< sal_Int8 > v;
680 if (value_ >>= v) {
681 return v;
683 throw css::registry::InvalidValueException(
684 "com.sun.star.configuration.ConfigurationRegistry",
685 static_cast< cppu::OWeakObject * >(this));
688 void RegistryKey::setBinaryValue(css::uno::Sequence< sal_Int8 > const &)
689 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
691 throw css::uno::RuntimeException(
692 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
693 static_cast< cppu::OWeakObject * >(this));
696 css::uno::Reference< css::registry::XRegistryKey > RegistryKey::openKey(
697 OUString const & aKeyName)
698 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
700 osl::MutexGuard g(service_.mutex_);
701 service_.checkValid_RuntimeException();
702 css::uno::Reference< css::container::XHierarchicalNameAccess > access;
703 if (value_ >>= access) {
704 try {
705 return new RegistryKey(
706 service_, access->getByHierarchicalName(aKeyName));
707 } catch (css::container::NoSuchElementException &) {}
709 return css::uno::Reference< css::registry::XRegistryKey >();
712 css::uno::Reference< css::registry::XRegistryKey > RegistryKey::createKey(
713 OUString const &)
714 throw (
715 css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
717 throw css::uno::RuntimeException(
718 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
719 static_cast< cppu::OWeakObject * >(this));
722 void RegistryKey::closeKey()
723 throw (
724 css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
726 osl::MutexGuard g(service_.mutex_);
727 service_.checkValid_RuntimeException();
730 void RegistryKey::deleteKey(OUString const &)
731 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
733 throw css::uno::RuntimeException(
734 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
735 static_cast< cppu::OWeakObject * >(this));
738 css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
739 RegistryKey::openKeys()
740 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
742 throw css::uno::RuntimeException(
743 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
744 static_cast< cppu::OWeakObject * >(this));
747 css::uno::Sequence< OUString > RegistryKey::getKeyNames()
748 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
750 throw css::uno::RuntimeException(
751 "com.sun.star.configuration.ConfigurationRegistry: not implemented",
752 static_cast< cppu::OWeakObject * >(this));
755 sal_Bool RegistryKey::createLink(OUString const &, OUString const &)
756 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
758 osl::MutexGuard g(service_.mutex_);
759 service_.checkValid_RuntimeException();
760 return false;
763 void RegistryKey::deleteLink(OUString const &)
764 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
766 osl::MutexGuard g(service_.mutex_);
767 service_.checkValid_RuntimeException();
770 OUString RegistryKey::getLinkTarget(OUString const &)
771 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
773 osl::MutexGuard g(service_.mutex_);
774 service_.checkValid_RuntimeException();
775 return OUString();
778 OUString RegistryKey::getResolvedName(OUString const & aKeyName)
779 throw (css::registry::InvalidRegistryException, css::uno::RuntimeException, std::exception)
781 osl::MutexGuard g(service_.mutex_);
782 service_.checkValid_RuntimeException();
783 return aKeyName;
788 css::uno::Reference< css::uno::XInterface > create(
789 css::uno::Reference< css::uno::XComponentContext > const & context)
791 return static_cast< cppu::OWeakObject * >(new Service(context));
794 OUString getImplementationName() {
795 return OUString("com.sun.star.comp.configuration.ConfigurationRegistry");
798 css::uno::Sequence< OUString > getSupportedServiceNames() {
799 OUString name("com.sun.star.configuration.ConfigurationRegistry");
800 return css::uno::Sequence< OUString >(&name, 1);
805 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */