28#include <com/sun/star/lang/XServiceInfo.hpp>
29#include <com/sun/star/registry/InvalidRegistryException.hpp>
30#include <com/sun/star/registry/InvalidValueException.hpp>
31#include <com/sun/star/registry/RegistryKeyType.hpp>
32#include <com/sun/star/registry/XRegistryKey.hpp>
33#include <com/sun/star/registry/XSimpleRegistry.hpp>
34#include <com/sun/star/uno/Reference.hxx>
35#include <com/sun/star/uno/RuntimeException.hpp>
36#include <com/sun/star/uno/XInterface.hpp>
37#include <com/sun/star/uno/Sequence.hxx>
45#include <rtl/string.h>
46#include <rtl/string.hxx>
47#include <rtl/textcvt.h>
48#include <rtl/textenc.h>
49#include <rtl/ustring.h>
50#include <rtl/ustring.hxx>
58 public cppu::WeakImplHelper<
59 css::registry::XSimpleRegistry, css::lang::XServiceInfo >
62 SimpleRegistry(): registry_(
Registry()) {}
65 std::scoped_lock guard(mutex_);
72 virtual OUString SAL_CALL getURL()
override;
74 virtual void SAL_CALL open(
77 virtual sal_Bool SAL_CALL isValid()
override;
79 virtual void SAL_CALL
close()
override;
81 virtual void SAL_CALL destroy()
override;
83 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
84 getRootKey()
override;
86 virtual sal_Bool SAL_CALL isReadOnly()
override;
88 virtual void SAL_CALL mergeKey(
89 OUString
const & aKeyName, OUString
const & aUrl)
override;
92 {
return "com.sun.star.comp.stoc.SimpleRegistry"; }
97 virtual css::uno::Sequence< OUString > SAL_CALL
100 css::uno::Sequence< OUString > names {
"com.sun.star.registry.SimpleRegistry" };
104 std::optional<Registry> registry_;
107class Key:
public cppu::WeakImplHelper< css::registry::XRegistryKey > {
112 registry_(
std::move(registry)),
key_(key) {}
115 std::scoped_lock guard(registry_->mutex_);
120 virtual OUString SAL_CALL
getKeyName()
override;
122 virtual sal_Bool SAL_CALL isReadOnly()
override;
124 virtual sal_Bool SAL_CALL isValid()
override;
126 virtual css::registry::RegistryKeyType SAL_CALL getKeyType(
127 OUString
const & rKeyName)
override;
129 virtual css::registry::RegistryValueType SAL_CALL getValueType()
override;
131 virtual sal_Int32 SAL_CALL getLongValue()
override;
133 virtual void SAL_CALL setLongValue(sal_Int32 value)
override;
135 virtual css::uno::Sequence< sal_Int32 > SAL_CALL
getLongListValue()
override;
138 css::uno::Sequence< sal_Int32 >
const & seqValue)
override;
140 virtual OUString SAL_CALL getAsciiValue()
override;
142 virtual void SAL_CALL setAsciiValue(OUString
const & value)
override;
144 virtual css::uno::Sequence< OUString > SAL_CALL getAsciiListValue()
override;
146 virtual void SAL_CALL setAsciiListValue(
147 css::uno::Sequence< OUString >
const & seqValue)
override;
149 virtual OUString SAL_CALL getStringValue()
override;
151 virtual void SAL_CALL setStringValue(OUString
const & value)
override;
156 css::uno::Sequence< OUString >
const & seqValue)
override;
158 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue()
override;
160 virtual void SAL_CALL setBinaryValue(
161 css::uno::Sequence< sal_Int8 >
const & value)
override;
163 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
openKey(
164 OUString
const & aKeyName)
override;
166 virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL
167 createKey(OUString
const & aKeyName)
override;
169 virtual void SAL_CALL
closeKey()
override;
171 virtual void SAL_CALL
deleteKey(OUString
const & rKeyName)
override;
174 css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
175 SAL_CALL openKeys()
override;
177 virtual css::uno::Sequence< OUString > SAL_CALL
getKeyNames()
override;
179 virtual sal_Bool SAL_CALL createLink(
180 OUString
const & aLinkName, OUString
const & aLinkTarget)
override;
182 virtual void SAL_CALL deleteLink(OUString
const & rLinkName)
override;
184 virtual OUString SAL_CALL getLinkTarget(OUString
const & rLinkName)
override;
186 virtual OUString SAL_CALL getResolvedName(OUString
const & aKeyName)
override;
189 std::optional<RegistryKey>
key_;
192OUString Key::getKeyName() {
193 std::scoped_lock guard(registry_->mutex_);
199 std::scoped_lock guard(registry_->mutex_);
204 std::scoped_lock guard(registry_->mutex_);
208css::registry::RegistryKeyType Key::getKeyType(OUString
const & )
210 return css::registry::RegistryKeyType_KEY;
213css::registry::RegistryValueType Key::getValueType()
215 std::scoped_lock guard(registry_->mutex_);
220 case RegError::NO_ERROR:
222 case RegError::INVALID_VALUE:
223 type = RegValueType::NOT_DEFINED;
226 throw css::registry::InvalidRegistryException(
227 "com.sun.star.registry.SimpleRegistry key getValueType:"
228 " underlying RegistryKey::getValueInfo() = " + OUString::number(
static_cast<int>(err)),
235 case RegValueType::NOT_DEFINED:
236 return css::registry::RegistryValueType_NOT_DEFINED;
237 case RegValueType::LONG:
238 return css::registry::RegistryValueType_LONG;
239 case RegValueType::STRING:
240 return css::registry::RegistryValueType_ASCII;
241 case RegValueType::UNICODE:
242 return css::registry::RegistryValueType_STRING;
243 case RegValueType::BINARY:
244 return css::registry::RegistryValueType_BINARY;
245 case RegValueType::LONGLIST:
246 return css::registry::RegistryValueType_LONGLIST;
247 case RegValueType::STRINGLIST:
248 return css::registry::RegistryValueType_ASCIILIST;
249 case RegValueType::UNICODELIST:
250 return css::registry::RegistryValueType_STRINGLIST;
254sal_Int32 Key::getLongValue()
256 std::scoped_lock guard(registry_->mutex_);
260 case RegError::NO_ERROR:
262 case RegError::INVALID_VALUE:
263 throw css::registry::InvalidValueException(
264 "com.sun.star.registry.SimpleRegistry key getLongValue:"
265 " underlying RegistryKey::getValue() = RegError::INVALID_VALUE",
268 throw css::registry::InvalidRegistryException(
269 "com.sun.star.registry.SimpleRegistry key getLongValue:"
270 " underlying RegistryKey::getValue() = " + OUString::number(
static_cast<int>(err)),
276void Key::setLongValue(sal_Int32 value)
278 std::scoped_lock guard(registry_->mutex_);
280 OUString(), RegValueType::LONG, &value,
sizeof (sal_Int32));
281 if (err != RegError::NO_ERROR) {
282 throw css::registry::InvalidRegistryException(
283 "com.sun.star.registry.SimpleRegistry key setLongValue:"
284 " underlying RegistryKey::setValue() = " + OUString::number(
static_cast<int>(err)),
289css::uno::Sequence< sal_Int32 > Key::getLongListValue()
291 std::scoped_lock guard(registry_->mutex_);
295 case RegError::NO_ERROR:
297 case RegError::VALUE_NOT_EXISTS:
298 return css::uno::Sequence< sal_Int32 >();
299 case RegError::INVALID_VALUE:
300 throw css::registry::InvalidValueException(
301 "com.sun.star.registry.SimpleRegistry key getLongListValue:"
302 " underlying RegistryKey::getLongListValue() ="
303 " RegError::INVALID_VALUE",
306 throw css::registry::InvalidRegistryException(
307 "com.sun.star.registry.SimpleRegistry key getLongListValue:"
308 " underlying RegistryKey::getLongListValue() = " + OUString::number(
static_cast<int>(err)),
312 if (n > SAL_MAX_INT32) {
313 throw css::registry::InvalidValueException(
314 "com.sun.star.registry.SimpleRegistry key getLongListValue:"
315 " underlying RegistryKey::getLongListValue() too large",
318 css::uno::Sequence< sal_Int32 >
value(
static_cast< sal_Int32
>(n));
319 auto aValueRange = asNonConstRange(value);
320 for (sal_uInt32 i = 0;
i <
n; ++
i) {
321 aValueRange[
static_cast< sal_Int32
>(
i)] = list.
getElement(i);
326void Key::setLongListValue(css::uno::Sequence< sal_Int32 >
const & seqValue)
328 std::scoped_lock guard(registry_->mutex_);
330 OUString(), seqValue.getConstArray(),
static_cast< sal_uInt32
>(seqValue.getLength()));
331 if (err != RegError::NO_ERROR) {
332 throw css::registry::InvalidRegistryException(
333 "com.sun.star.registry.SimpleRegistry key setLongListValue:"
334 " underlying RegistryKey::setLongListValue() = " + OUString::number(
static_cast<int>(err)),
339OUString Key::getAsciiValue()
341 std::scoped_lock guard(registry_->mutex_);
345 if (err != RegError::NO_ERROR) {
346 throw css::registry::InvalidRegistryException(
347 "com.sun.star.registry.SimpleRegistry key getAsciiValue:"
348 " underlying RegistryKey::getValueInfo() = " + OUString::number(
static_cast<int>(err)),
351 if (type != RegValueType::STRING) {
352 throw css::registry::InvalidValueException(
353 "com.sun.star.registry.SimpleRegistry key getAsciiValue:"
354 " underlying RegistryKey type = " + OUString::number(
static_cast<int>(type)),
359 throw css::registry::InvalidValueException(
360 "com.sun.star.registry.SimpleRegistry key getAsciiValue:"
361 " underlying RegistryKey size 0 cannot happen due to"
365 if (size > SAL_MAX_INT32) {
366 throw css::registry::InvalidValueException(
367 "com.sun.star.registry.SimpleRegistry key getAsciiValue:"
368 " underlying RegistryKey size too large",
371 std::vector< char > list(size);
373 if (err != RegError::NO_ERROR) {
374 throw css::registry::InvalidRegistryException(
375 "com.sun.star.registry.SimpleRegistry key getAsciiValue:"
376 " underlying RegistryKey::getValue() = " + OUString::number(
static_cast<int>(err)),
379 if (list[size - 1] !=
'\0') {
380 throw css::registry::InvalidValueException(
381 "com.sun.star.registry.SimpleRegistry key getAsciiValue:"
382 " underlying RegistryKey value must be null-terminated due"
387 if (!rtl_convertStringToUString(
388 &
value.pData, list.data(),
389 static_cast< sal_Int32
>(size - 1), RTL_TEXTENCODING_UTF8,
390 (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
391 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
392 RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
394 throw css::registry::InvalidValueException(
395 "com.sun.star.registry.SimpleRegistry key getAsciiValue:"
396 " underlying RegistryKey not UTF-8",
402void Key::setAsciiValue(OUString
const & value)
404 std::scoped_lock guard(registry_->mutex_);
406 if (!
value.convertToString(
407 &utf8, RTL_TEXTENCODING_UTF8,
408 (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
409 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
411 throw css::uno::RuntimeException(
412 "com.sun.star.registry.SimpleRegistry key setAsciiValue:"
417 OUString(), RegValueType::STRING,
418 const_cast< char *
>(utf8.getStr()), utf8.getLength() + 1);
420 if (err != RegError::NO_ERROR) {
421 throw css::registry::InvalidRegistryException(
422 "com.sun.star.registry.SimpleRegistry key setAsciiValue:"
423 " underlying RegistryKey::setValue() = " + OUString::number(
static_cast<int>(err)),
428css::uno::Sequence< OUString > Key::getAsciiListValue()
430 std::scoped_lock guard(registry_->mutex_);
434 case RegError::NO_ERROR:
436 case RegError::VALUE_NOT_EXISTS:
437 return css::uno::Sequence< OUString >();
438 case RegError::INVALID_VALUE:
439 throw css::registry::InvalidValueException(
440 "com.sun.star.registry.SimpleRegistry key"
441 " getAsciiListValue: underlying"
442 " RegistryKey::getStringListValue() = RegError::INVALID_VALUE",
445 throw css::registry::InvalidRegistryException(
446 "com.sun.star.registry.SimpleRegistry key"
447 " getAsciiListValue: underlying"
448 " RegistryKey::getStringListValue() = " + OUString::number(
static_cast<int>(err)),
452 if (n > SAL_MAX_INT32) {
453 throw css::registry::InvalidValueException(
454 "com.sun.star.registry.SimpleRegistry key"
455 " getAsciiListValue: underlying"
456 " RegistryKey::getStringListValue() too large",
459 css::uno::Sequence< OUString >
value(
static_cast< sal_Int32
>(n));
460 auto aValueRange = asNonConstRange(value);
461 for (sal_uInt32 i = 0;
i <
n; ++
i) {
463 sal_Int32
size = rtl_str_getLength(el);
464 if (!rtl_convertStringToUString(
465 &aValueRange[
static_cast< sal_Int32
>(i)].pData, el, size,
466 RTL_TEXTENCODING_UTF8,
467 (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
468 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
469 RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
471 throw css::registry::InvalidValueException(
472 "com.sun.star.registry.SimpleRegistry key"
473 " getAsciiListValue: underlying RegistryKey not"
481void Key::setAsciiListValue(
482 css::uno::Sequence< OUString >
const & seqValue)
484 std::scoped_lock guard(registry_->mutex_);
485 std::vector< OString > list;
486 for (
const auto& rValue : seqValue) {
488 if (!rValue.convertToString(
489 &utf8, RTL_TEXTENCODING_UTF8,
490 (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
491 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
493 throw css::uno::RuntimeException(
494 "com.sun.star.registry.SimpleRegistry key"
495 " setAsciiListValue: value not UTF-16",
498 list.push_back(utf8);
500 std::vector< char * > list2;
501 for (
const auto& rItem : list)
503 list2.push_back(
const_cast< char *
>(rItem.getStr()));
506 OUString(), list2.data(),
static_cast< sal_uInt32
>(list2.size()));
507 if (err != RegError::NO_ERROR) {
508 throw css::registry::InvalidRegistryException(
509 "com.sun.star.registry.SimpleRegistry key"
510 " setAsciiListValue: underlying"
511 " RegistryKey::setStringListValue() = " + OUString::number(
static_cast<int>(err)),
516OUString Key::getStringValue()
518 std::scoped_lock guard(registry_->mutex_);
522 if (err != RegError::NO_ERROR) {
523 throw css::registry::InvalidRegistryException(
524 "com.sun.star.registry.SimpleRegistry key getStringValue:"
525 " underlying RegistryKey::getValueInfo() = " + OUString::number(
static_cast<int>(err)),
528 if (type != RegValueType::UNICODE) {
529 throw css::registry::InvalidValueException(
530 "com.sun.star.registry.SimpleRegistry key getStringValue:"
531 " underlying RegistryKey type = " + OUString::number(
static_cast<int>(type)),
536 if (size == 0 || (size & 1) == 1) {
537 throw css::registry::InvalidValueException(
538 "com.sun.star.registry.SimpleRegistry key getStringValue:"
539 " underlying RegistryKey size 0 or odd cannot happen due to"
543 if (size > SAL_MAX_INT32) {
544 throw css::registry::InvalidValueException(
545 "com.sun.star.registry.SimpleRegistry key getStringValue:"
546 " underlying RegistryKey size too large",
549 std::vector< sal_Unicode > list(size);
551 if (err != RegError::NO_ERROR) {
552 throw css::registry::InvalidRegistryException(
553 "com.sun.star.registry.SimpleRegistry key getStringValue:"
554 " underlying RegistryKey::getValue() = " + OUString::number(
static_cast<int>(err)),
557 if (list[size/2 - 1] != 0) {
558 throw css::registry::InvalidValueException(
559 "com.sun.star.registry.SimpleRegistry key getStringValue:"
560 " underlying RegistryKey value must be null-terminated due"
564 return OUString(list.data(),
static_cast< sal_Int32
>(size/2 - 1));
567void Key::setStringValue(OUString
const & value)
569 std::scoped_lock guard(registry_->mutex_);
571 OUString(), RegValueType::UNICODE,
575 if (err != RegError::NO_ERROR) {
576 throw css::registry::InvalidRegistryException(
577 "com.sun.star.registry.SimpleRegistry key setStringValue:"
578 " underlying RegistryKey::setValue() = " + OUString::number(
static_cast<int>(err)),
583css::uno::Sequence< OUString > Key::getStringListValue()
585 std::scoped_lock guard(registry_->mutex_);
589 case RegError::NO_ERROR:
591 case RegError::VALUE_NOT_EXISTS:
592 return css::uno::Sequence< OUString >();
593 case RegError::INVALID_VALUE:
594 throw css::registry::InvalidValueException(
595 "com.sun.star.registry.SimpleRegistry key"
596 " getStringListValue: underlying"
597 " RegistryKey::getUnicodeListValue() = RegError::INVALID_VALUE",
600 throw css::registry::InvalidRegistryException(
601 "com.sun.star.registry.SimpleRegistry key"
602 " getStringListValue: underlying"
603 " RegistryKey::getUnicodeListValue() = " + OUString::number(
static_cast<int>(err)),
607 if (n > SAL_MAX_INT32) {
608 throw css::registry::InvalidValueException(
609 "com.sun.star.registry.SimpleRegistry key"
610 " getStringListValue: underlying"
611 " RegistryKey::getUnicodeListValue() too large",
614 css::uno::Sequence< OUString >
value(
static_cast< sal_Int32
>(n));
615 auto aValueRange = asNonConstRange(value);
616 for (sal_uInt32 i = 0;
i <
n; ++
i) {
617 aValueRange[
static_cast< sal_Int32
>(
i)] = list.
getElement(i);
622void Key::setStringListValue(
623 css::uno::Sequence< OUString >
const & seqValue)
625 std::scoped_lock guard(registry_->mutex_);
626 std::vector< sal_Unicode * > list;
627 list.reserve(seqValue.getLength());
628 std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(list),
629 [](
const OUString& rValue) ->
sal_Unicode* { return const_cast<sal_Unicode*>(rValue.getStr()); });
631 OUString(), list.data(),
static_cast< sal_uInt32
>(list.size()));
632 if (err != RegError::NO_ERROR) {
633 throw css::registry::InvalidRegistryException(
634 "com.sun.star.registry.SimpleRegistry key"
635 " setStringListValue: underlying"
636 " RegistryKey::setUnicodeListValue() = " + OUString::number(
static_cast<int>(err)),
641css::uno::Sequence< sal_Int8 > Key::getBinaryValue()
643 std::scoped_lock guard(registry_->mutex_);
647 if (err != RegError::NO_ERROR) {
648 throw css::registry::InvalidRegistryException(
649 "com.sun.star.registry.SimpleRegistry key getBinaryValue:"
650 " underlying RegistryKey::getValueInfo() = " + OUString::number(
static_cast<int>(err)),
653 if (type != RegValueType::BINARY) {
654 throw css::registry::InvalidValueException(
655 "com.sun.star.registry.SimpleRegistry key getBinaryValue:"
656 " underlying RegistryKey type = " + OUString::number(
static_cast<int>(type)),
659 if (size > SAL_MAX_INT32) {
660 throw css::registry::InvalidValueException(
661 "com.sun.star.registry.SimpleRegistry key getBinaryValue:"
662 " underlying RegistryKey size too large",
665 css::uno::Sequence< sal_Int8 >
value(
static_cast< sal_Int32
>(size));
667 if (err != RegError::NO_ERROR) {
668 throw css::registry::InvalidRegistryException(
669 "com.sun.star.registry.SimpleRegistry key getBinaryValue:"
670 " underlying RegistryKey::getValue() = " + OUString::number(
static_cast<int>(err)),
676void Key::setBinaryValue(css::uno::Sequence< sal_Int8 >
const & value)
678 std::scoped_lock guard(registry_->mutex_);
680 OUString(), RegValueType::BINARY,
682 static_cast< sal_uInt32
>(
value.getLength()));
683 if (err != RegError::NO_ERROR) {
684 throw css::registry::InvalidRegistryException(
685 "com.sun.star.registry.SimpleRegistry key setBinaryValue:"
686 " underlying RegistryKey::setValue() = " + OUString::number(
static_cast<int>(err)),
691css::uno::Reference< css::registry::XRegistryKey > Key::openKey(
692 OUString
const & aKeyName)
694 std::scoped_lock guard(registry_->mutex_);
698 case RegError::NO_ERROR:
699 return new Key(registry_, key);
700 case RegError::KEY_NOT_EXISTS:
701 return css::uno::Reference< css::registry::XRegistryKey >();
703 throw css::registry::InvalidRegistryException(
704 "com.sun.star.registry.SimpleRegistry key openKey:"
705 " underlying RegistryKey::openKey() = " + OUString::number(
static_cast<int>(err)),
710css::uno::Reference< css::registry::XRegistryKey > Key::createKey(
711 OUString
const & aKeyName)
713 std::scoped_lock guard(registry_->mutex_);
717 case RegError::NO_ERROR:
718 return new Key(registry_, key);
719 case RegError::INVALID_KEYNAME:
720 return css::uno::Reference< css::registry::XRegistryKey >();
722 throw css::registry::InvalidRegistryException(
723 "com.sun.star.registry.SimpleRegistry key createKey:"
724 " underlying RegistryKey::createKey() = " + OUString::number(
static_cast<int>(err)),
731 std::scoped_lock guard(registry_->mutex_);
733 if (err != RegError::NO_ERROR) {
734 throw css::registry::InvalidRegistryException(
735 "com.sun.star.registry.SimpleRegistry key closeKey:"
736 " underlying RegistryKey::closeKey() = " + OUString::number(
static_cast<int>(err)),
741void Key::deleteKey(OUString
const & rKeyName)
743 std::scoped_lock guard(registry_->mutex_);
745 if (err != RegError::NO_ERROR) {
746 throw css::registry::InvalidRegistryException(
747 "com.sun.star.registry.SimpleRegistry key deleteKey:"
748 " underlying RegistryKey::deleteKey() = " + OUString::number(
static_cast<int>(err)),
753css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
756 std::scoped_lock guard(registry_->mutex_);
759 if (err != RegError::NO_ERROR) {
760 throw css::registry::InvalidRegistryException(
761 "com.sun.star.registry.SimpleRegistry key openKeys:"
762 " underlying RegistryKey::openSubKeys() = " + OUString::number(
static_cast<int>(err)),
766 if (n > SAL_MAX_INT32) {
767 throw css::registry::InvalidRegistryException(
768 "com.sun.star.registry.SimpleRegistry key getKeyNames:"
769 " underlying RegistryKey::getKeyNames() too large",
772 css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
773 keys(
static_cast< sal_Int32
>(n));
774 auto aKeysRange = asNonConstRange(keys);
775 for (sal_uInt32 i = 0;
i <
n; ++
i) {
776 aKeysRange[
static_cast< sal_Int32
>(
i)] =
new Key(
782css::uno::Sequence< OUString > Key::getKeyNames()
784 std::scoped_lock guard(registry_->mutex_);
787 if (err != RegError::NO_ERROR) {
788 throw css::registry::InvalidRegistryException(
789 "com.sun.star.registry.SimpleRegistry key getKeyNames:"
790 " underlying RegistryKey::getKeyNames() = " + OUString::number(
static_cast<int>(err)),
794 if (n > SAL_MAX_INT32) {
795 throw css::registry::InvalidRegistryException(
796 "com.sun.star.registry.SimpleRegistry key getKeyNames:"
797 " underlying RegistryKey::getKeyNames() too large",
800 css::uno::Sequence< OUString > names(
static_cast< sal_Int32
>(n));
801 auto aNamesRange = asNonConstRange(names);
802 for (sal_uInt32 i = 0;
i <
n; ++
i) {
803 aNamesRange[
static_cast< sal_Int32
>(
i)] = list.
getElement(i);
809 OUString
const & , OUString
const & )
811 throw css::registry::InvalidRegistryException(
812 "com.sun.star.registry.SimpleRegistry key createLink: links are no longer supported",
816void Key::deleteLink(OUString
const & )
818 throw css::registry::InvalidRegistryException(
819 "com.sun.star.registry.SimpleRegistry key deleteLink: links are no longer supported",
823OUString Key::getLinkTarget(OUString
const & )
825 throw css::registry::InvalidRegistryException(
826 "com.sun.star.registry.SimpleRegistry key getLinkTarget: links are no longer supported",
830OUString Key::getResolvedName(OUString
const & aKeyName)
832 std::scoped_lock guard(registry_->mutex_);
835 if (err != RegError::NO_ERROR) {
836 throw css::registry::InvalidRegistryException(
837 "com.sun.star.registry.SimpleRegistry key getResolvedName:"
838 " underlying RegistryKey::getResolvedName() = " + OUString::number(
static_cast<int>(err)),
844OUString SimpleRegistry::getURL() {
845 std::scoped_lock guard(mutex_);
846 return registry_->getName();
849void SimpleRegistry::open(
852 std::scoped_lock guard(mutex_);
854 ? RegError::REGISTRY_NOT_EXISTS
855 : registry_->open(rURL, bReadOnly ? RegAccessMode::READONLY : RegAccessMode::READWRITE);
856 if (err == RegError::REGISTRY_NOT_EXISTS && bCreate) {
857 err = registry_->create(rURL);
859 if (err != RegError::NO_ERROR) {
860 throw css::registry::InvalidRegistryException(
861 "com.sun.star.registry.SimpleRegistry.open(" + rURL +
862 "): underlying Registry::open/create() = " + OUString::number(
static_cast<int>(err)),
868 std::scoped_lock guard(mutex_);
869 return registry_->isValid();
872void SimpleRegistry::close()
874 std::scoped_lock guard(mutex_);
876 if (err != RegError::NO_ERROR) {
877 throw css::registry::InvalidRegistryException(
878 "com.sun.star.registry.SimpleRegistry.close:"
879 " underlying Registry::close() = " + OUString::number(
static_cast<int>(err)),
884void SimpleRegistry::destroy()
886 std::scoped_lock guard(mutex_);
888 if (err != RegError::NO_ERROR) {
889 throw css::registry::InvalidRegistryException(
890 "com.sun.star.registry.SimpleRegistry.destroy:"
891 " underlying Registry::destroy() = " + OUString::number(
static_cast<int>(err)),
896css::uno::Reference< css::registry::XRegistryKey > SimpleRegistry::getRootKey()
898 std::scoped_lock guard(mutex_);
901 if (err != RegError::NO_ERROR) {
902 throw css::registry::InvalidRegistryException(
903 "com.sun.star.registry.SimpleRegistry.getRootKey:"
904 " underlying Registry::getRootKey() = " + OUString::number(
static_cast<int>(err)),
907 return new Key(
this, root);
910sal_Bool SimpleRegistry::isReadOnly()
912 std::scoped_lock guard(mutex_);
913 return registry_->isReadOnly();
916void SimpleRegistry::mergeKey(
917 OUString
const &, OUString
const &)
919 throw css::uno::RuntimeException(
"css.registry.SimpleRegistry::mergeKey: not implemented");
924extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
926 SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
927 css::uno::Sequence<css::uno::Any>
const &)
929 return cppu::acquire(
new SimpleRegistry);
sal_uInt32 getLength() const
RegistryKey getElement(sal_uInt32 index)
OUString getElement(sal_uInt32 index)
sal_uInt32 getLength() const
RegError getKeyNames(const OUString &keyName, RegistryKeyNames &rSubKeyNames)
RegError openKey(const OUString &keyName, RegistryKey &rOpenKey)
RegError deleteKey(const OUString &keyName)
RegError getResolvedKeyName(const OUString &keyName, OUString &rResolvedName) const
RegError getLongListValue(const OUString &keyName, RegistryValueList< sal_Int32 > &rValueList)
RegError getValueInfo(const OUString &keyName, RegValueType *pValueType, sal_uInt32 *pValueSize)
RegError getUnicodeListValue(const OUString &keyName, RegistryValueList< sal_Unicode * > &rValueList)
RegError setValue(const OUString &keyName, RegValueType valueType, RegValue pValue, sal_uInt32 valueSize)
RegError setStringListValue(const OUString &keyName, char **pValueList, sal_uInt32 len)
RegError getValue(const OUString &keyName, RegValue pValue)
RegError openSubKeys(const OUString &keyName, RegistryKeyArray &rSubKeys)
RegError setLongListValue(const OUString &keyName, sal_Int32 const *pValueList, sal_uInt32 len)
RegError setUnicodeListValue(const OUString &keyName, sal_Unicode **pValueList, sal_uInt32 len)
RegError createKey(const OUString &keyName, RegistryKey &rNewKey)
RegError getStringListValue(const OUString &keyName, RegistryValueList< char * > &rValueList)
ValueType getElement(sal_uInt32 index)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
RegError REGISTRY_CALLTYPE setLongListValue(RegKeyHandle hKey, rtl_uString *keyName, sal_Int32 const *pValueList, sal_uInt32 len)
RegError REGISTRY_CALLTYPE createKey(RegKeyHandle hKey, rtl_uString *keyName, RegKeyHandle *phNewKey)
RegError REGISTRY_CALLTYPE setStringListValue(RegKeyHandle hKey, rtl_uString *keyName, char **pValueList, sal_uInt32 len)
RegError REGISTRY_CALLTYPE getStringListValue(RegKeyHandle hKey, rtl_uString *keyName, char ***pValueList, sal_uInt32 *pLen)
RegError REGISTRY_CALLTYPE getKeyNames(RegKeyHandle hKey, rtl_uString *keyName, rtl_uString ***pSubKeyNames, sal_uInt32 *pnSubKeys)
RegError REGISTRY_CALLTYPE getLongListValue(RegKeyHandle hKey, rtl_uString *keyName, sal_Int32 **pValueList, sal_uInt32 *pLen)
RegError REGISTRY_CALLTYPE getKeyName(RegKeyHandle hKey, rtl_uString **pKeyName)
RegError REGISTRY_CALLTYPE deleteKey(RegKeyHandle hKey, rtl_uString *keyName)
RegError REGISTRY_CALLTYPE openKey(RegKeyHandle hKey, rtl_uString *keyName, RegKeyHandle *phOpenKey)
RegError REGISTRY_CALLTYPE closeKey(RegKeyHandle hKey)
enum SAL_DLLPUBLIC_RTTI RegValueType
enum SAL_DLLPUBLIC_RTTI RegError
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_stoc_SimpleRegistry_get_implementation(SAL_UNUSED_PARAMETER css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)