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