merge the formfield patch from ooo-build
[ooovba.git] / registry / source / regimpl.hxx
blob57507674e4cf21ac2701bfb3ae2e95e64ddb6e79
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: regimpl.hxx,v $
10 * $Revision: 1.5.10.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _REGIMPL_HXX_
32 #define _REGIMPL_HXX_
34 #include <set>
36 #include <hash_map>
38 #include <registry/registry.h>
39 #include <osl/mutex.hxx>
40 #include <store/store.hxx>
42 #define REG_PAGESIZE 512
44 #define REG_MODE_CREATE store_AccessCreate
45 #define REG_MODE_OPEN store_AccessReadWrite
46 #define REG_MODE_OPENREAD store_AccessReadOnly
48 #define KEY_MODE_CREATE store_AccessCreate
49 #define KEY_MODE_OPEN store_AccessReadWrite
50 #define KEY_MODE_OPENREAD store_AccessReadOnly
53 #define VALUE_MODE_CREATE store_AccessCreate
54 #define VALUE_MODE_OPEN store_AccessReadWrite
55 #define VALUE_MODE_OPENREAD store_AccessReadOnly
57 // 5 Bytes = 1 (Byte fuer den Typ) + 4 (Bytes fuer die Groesse der Daten)
58 #define VALUE_HEADERSIZE 5
59 #define VALUE_TYPEOFFSET 1
60 #define VALUE_HEADEROFFSET 5
62 #define REG_CREATE 0x0004 // allow write accesses
64 #define REG_GUARD(mutex) \
65 Guard< Mutex > aGuard( mutex );
67 using namespace rtl;
68 using namespace osl;
69 using namespace store;
71 class ORegKey;
72 class RegistryTypeReader;
74 class ORegistry
76 public:
77 ORegistry();
79 sal_uInt32 acquire()
80 { return ++m_refCount; }
82 sal_uInt32 release()
83 { return --m_refCount; }
85 RegError initRegistry(const OUString& name,
86 RegAccessMode accessMode);
88 RegError closeRegistry();
90 RegError destroyRegistry(const OUString& name);
92 RegError createKey(RegKeyHandle hKey,
93 const OUString& keyName,
94 RegKeyHandle* phNewKey);
96 RegError openKey(RegKeyHandle hKey,
97 const OUString& keyName,
98 RegKeyHandle* phOpenKey);
100 RegError closeKey(RegKeyHandle hKey);
102 RegError deleteKey(RegKeyHandle hKey, const OUString& keyName);
104 RegError loadKey(RegKeyHandle hKey,
105 const OUString& regFileName,
106 sal_Bool bWarings=sal_False,
107 sal_Bool bReport=sal_False);
109 RegError saveKey(RegKeyHandle hKey,
110 const OUString& regFileName,
111 sal_Bool bWarings=sal_False,
112 sal_Bool bReport=sal_False);
114 RegError dumpRegistry(RegKeyHandle hKey) const;
116 ~ORegistry();
118 sal_Bool isReadOnly() const
119 { return m_readOnly; }
121 sal_Bool isOpen() const
122 { return m_isOpen; }
124 ORegKey* getRootKey();
126 const OStoreFile& getStoreFile()
127 { return m_file; }
129 const OUString& getName() const
130 { return m_name; }
132 friend class ORegKey;
134 private:
135 RegError eraseKey(ORegKey* pKey, const OUString& keyName);
137 RegError deleteSubkeysAndValues(ORegKey* pKey);
139 RegError loadAndSaveValue(ORegKey* pTargetKey,
140 ORegKey* pSourceKey,
141 const OUString& valueName,
142 sal_uInt32 nCut,
143 sal_Bool bWarnings=sal_False,
144 sal_Bool bReport=sal_False);
146 RegError checkBlop(OStoreStream& rValue,
147 const OUString& sTargetPath,
148 sal_uInt32 srcValueSize,
149 sal_uInt8* pSrcBuffer,
150 sal_Bool bReport=sal_False);
152 RegError mergeModuleValue(OStoreStream& rTargetValue,
153 RegistryTypeReader& reader,
154 RegistryTypeReader& reader2);
156 RegError loadAndSaveKeys(ORegKey* pTargetKey,
157 ORegKey* pSourceKey,
158 const OUString& keyName,
159 sal_uInt32 nCut,
160 sal_Bool bWarnings=sal_False,
161 sal_Bool bReport=sal_False);
163 RegError dumpValue(const OUString& sPath,
164 const OUString& sName,
165 sal_Int16 nSpace) const;
167 RegError dumpKey(const OUString& sPath,
168 const OUString& sName,
169 sal_Int16 nSpace) const;
171 typedef std::hash_map< OUString, ORegKey*, OUStringHash > KeyMap;
173 sal_uInt32 m_refCount;
174 Mutex m_mutex;
175 sal_Bool m_readOnly;
176 sal_Bool m_isOpen;
177 OUString m_name;
178 OStoreFile m_file;
179 KeyMap m_openKeyTable;
181 const OUString ROOT;
184 #endif