24#include <osl/diagnose.h>
26#include <com/sun/star/registry/XRegistryKey.hpp>
31using namespace css::uno;
44 Link( OUString name, OUString target )
56 Reference< registry::XRegistryKey >
const & xDest,
57 Reference< registry::XRegistryKey >
const & xSource,
61 if (!xSource.is() || !xSource->isValid()) {
62 throw registry::InvalidRegistryException(
63 "source key is null or invalid!" );
65 if (!xDest.is() || !xDest->isValid()) {
66 throw registry::InvalidRegistryException(
67 "destination key is null or invalid!" );
71 switch (xSource->getValueType())
73 case registry::RegistryValueType_NOT_DEFINED:
75 case registry::RegistryValueType_LONG:
76 xDest->setLongValue( xSource->getLongValue() );
78 case registry::RegistryValueType_ASCII:
79 xDest->setAsciiValue( xSource->getAsciiValue() );
81 case registry::RegistryValueType_STRING:
82 xDest->setStringValue( xSource->getStringValue() );
84 case registry::RegistryValueType_BINARY:
85 xDest->setBinaryValue( xSource->getBinaryValue() );
87 case registry::RegistryValueType_LONGLIST:
88 xDest->setLongListValue( xSource->getLongListValue() );
90 case registry::RegistryValueType_ASCIILIST:
91 xDest->setAsciiListValue( xSource->getAsciiListValue() );
93 case registry::RegistryValueType_STRINGLIST:
94 xDest->setStringListValue( xSource->getStringListValue() );
102 Sequence< OUString > sourceKeys( xSource->getKeyNames() );
103 OUString
const * pSourceKeys = sourceKeys.getConstArray();
104 for ( sal_Int32
nPos = sourceKeys.getLength();
nPos--; )
107 OUString
name( pSourceKeys[
nPos ] );
108 sal_Int32 nSlash =
name.lastIndexOf(
'/' );
114 if (xSource->getKeyType(
name ) == registry::RegistryKeyType_KEY)
117 Reference< registry::XRegistryKey > xDestKey( xDest->createKey(
name ) );
118 Reference< registry::XRegistryKey > xSourceKey( xSource->openKey(
name ) );
119 mergeKeys( xDestKey, xSourceKey, links );
120 xSourceKey->closeKey();
121 xDestKey->closeKey();
126 Reference< registry::XRegistryKey > xDestKey( xDest->openKey(
name ) );
127 if (xDestKey.is() && xDestKey->isValid())
129 xDestKey->closeKey();
130 if (xDest->getKeyType(
name ) == registry::RegistryKeyType_LINK)
132 xDest->deleteLink(
name );
136 xDest->deleteKey(
name );
140 links.push_back(
Link(
142 xSource->getResolvedName(
name )
150 Reference< registry::XRegistryKey >
const & xDest,
151 Reference< registry::XRegistryKey >
const & xSource )
154 if (!xDest.is() || !xDest->isValid()) {
155 throw registry::InvalidRegistryException(
156 "destination key is null or invalid!" );
158 if (xDest->isReadOnly())
160 throw registry::InvalidRegistryException(
161 "destination registry is read-only! cannot merge!" );
168 for (
size_t nPos = links.size();
nPos--; )
171 OSL_VERIFY( xDest->createLink( r.m_name, r.m_target ) );
::std::vector< Link > t_links
static void mergeKeys(Reference< registry::XRegistryKey > const &xDest, Reference< registry::XRegistryKey > const &xSource, t_links &links)