diff options
Diffstat (limited to 'unotools/source/config/workingsetoptions.cxx')
-rw-r--r-- | unotools/source/config/workingsetoptions.cxx | 304 |
1 files changed, 0 insertions, 304 deletions
diff --git a/unotools/source/config/workingsetoptions.cxx b/unotools/source/config/workingsetoptions.cxx deleted file mode 100644 index 0ea5c47bbcb5..000000000000 --- a/unotools/source/config/workingsetoptions.cxx +++ /dev/null | |||
@@ -1,304 +0,0 @@ | |||
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
2 | /* | ||
3 | * This file is part of the LibreOffice project. | ||
4 | * | ||
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/. | ||
8 | * | ||
9 | * This file incorporates work covered by the following license notice: | ||
10 | * | ||
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 . | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include <unotools/workingsetoptions.hxx> | ||
22 | #include <unotools/configmgr.hxx> | ||
23 | #include <unotools/configitem.hxx> | ||
24 | #include <tools/debug.hxx> | ||
25 | #include <com/sun/star/uno/Any.hxx> | ||
26 | #include <com/sun/star/uno/Sequence.hxx> | ||
27 | |||
28 | #include <itemholder1.hxx> | ||
29 | |||
30 | //_________________________________________________________________________________________________________________ | ||
31 | // namespaces | ||
32 | //_________________________________________________________________________________________________________________ | ||
33 | |||
34 | using namespace ::utl ; | ||
35 | using namespace ::rtl ; | ||
36 | using namespace ::osl ; | ||
37 | using namespace ::com::sun::star::uno ; | ||
38 | |||
39 | #define ROOTNODE_WORKINGSET OUString("Office.Common/WorkingSet") | ||
40 | #define DEFAULT_WINDOWLIST Sequence< OUString >() | ||
41 | |||
42 | #define PROPERTYNAME_WINDOWLIST OUString("WindowList") | ||
43 | |||
44 | #define PROPERTYHANDLE_WINDOWLIST 0 | ||
45 | |||
46 | #define PROPERTYCOUNT 1 | ||
47 | |||
48 | //_________________________________________________________________________________________________________________ | ||
49 | // private declarations! | ||
50 | //_________________________________________________________________________________________________________________ | ||
51 | |||
52 | class SvtWorkingSetOptions_Impl : public ConfigItem | ||
53 | { | ||
54 | //------------------------------------------------------------------------------------------------------------- | ||
55 | // public methods | ||
56 | //------------------------------------------------------------------------------------------------------------- | ||
57 | |||
58 | public: | ||
59 | |||
60 | //--------------------------------------------------------------------------------------------------------- | ||
61 | // constructor / destructor | ||
62 | //--------------------------------------------------------------------------------------------------------- | ||
63 | |||
64 | SvtWorkingSetOptions_Impl(); | ||
65 | ~SvtWorkingSetOptions_Impl(); | ||
66 | |||
67 | //--------------------------------------------------------------------------------------------------------- | ||
68 | // overloaded methods of baseclass | ||
69 | //--------------------------------------------------------------------------------------------------------- | ||
70 | |||
71 | /*-****************************************************************************************************//** | ||
72 | @short called for notify of configmanager | ||
73 | @descr These method is called from the ConfigManager before application ends or from the | ||
74 | PropertyChangeListener if the sub tree broadcasts changes. You must update your | ||
75 | internal values. | ||
76 | |||
77 | @seealso baseclass ConfigItem | ||
78 | |||
79 | @param "seqPropertyNames" is the list of properties which should be updated. | ||
80 | @return - | ||
81 | |||
82 | @onerror - | ||
83 | *//*-*****************************************************************************************************/ | ||
84 | |||
85 | virtual void Notify( const Sequence< OUString >& seqPropertyNames ); | ||
86 | |||
87 | /*-****************************************************************************************************//** | ||
88 | @short write changes to configuration | ||
89 | @descr These method writes the changed values into the sub tree | ||
90 | and should always called in our destructor to guarantee consistency of config data. | ||
91 | |||
92 | @seealso baseclass ConfigItem | ||
93 | |||
94 | @param - | ||
95 | @return - | ||
96 | |||
97 | @onerror - | ||
98 | *//*-*****************************************************************************************************/ | ||
99 | |||
100 | virtual void Commit(); | ||
101 | |||
102 | //------------------------------------------------------------------------------------------------------------- | ||
103 | // private methods | ||
104 | //------------------------------------------------------------------------------------------------------------- | ||
105 | |||
106 | private: | ||
107 | |||
108 | /*-****************************************************************************************************//** | ||
109 | @short return list of key names of ouer configuration management which represent oue module tree | ||
110 | @descr These methods return a static const list of key names. We need it to get needed values from our | ||
111 | configuration management. | ||
112 | |||
113 | @seealso - | ||
114 | |||
115 | @param - | ||
116 | @return A list of needed configuration keys is returned. | ||
117 | |||
118 | @onerror - | ||
119 | *//*-*****************************************************************************************************/ | ||
120 | |||
121 | static Sequence< OUString > GetPropertyNames(); | ||
122 | |||
123 | //------------------------------------------------------------------------------------------------------------- | ||
124 | // private member | ||
125 | //------------------------------------------------------------------------------------------------------------- | ||
126 | |||
127 | private: | ||
128 | |||
129 | Sequence< OUString > m_seqWindowList ; | ||
130 | }; | ||
131 | |||
132 | //***************************************************************************************************************** | ||
133 | // constructor | ||
134 | //***************************************************************************************************************** | ||
135 | SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl() | ||
136 | // Init baseclasses first | ||
137 | : ConfigItem ( ROOTNODE_WORKINGSET ) | ||
138 | // Init member then. | ||
139 | , m_seqWindowList ( DEFAULT_WINDOWLIST ) | ||
140 | { | ||
141 | // Use our static list of configuration keys to get his values. | ||
142 | Sequence< OUString > seqNames = GetPropertyNames ( ); | ||
143 | Sequence< Any > seqValues = GetProperties ( seqNames ); | ||
144 | |||
145 | // Safe impossible cases. | ||
146 | // We need values from ALL configuration keys. | ||
147 | // Follow assignment use order of values in relation to our list of key names! | ||
148 | DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nI miss some values of configuration keys!\n" ); | ||
149 | |||
150 | // Copy values from list in right order to ouer internal member. | ||
151 | sal_Int32 nPropertyCount = seqValues.getLength(); | ||
152 | for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) | ||
153 | { | ||
154 | // Safe impossible cases. | ||
155 | // Check any for valid value. | ||
156 | DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nInvalid property value detected!\n" ); | ||
157 | switch( nProperty ) | ||
158 | { | ||
159 | case PROPERTYHANDLE_WINDOWLIST : { | ||
160 | DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" ); | ||
161 | seqValues[nProperty] >>= m_seqWindowList; | ||
162 | } | ||
163 | break; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | // Enable notification mechanism of ouer baseclass. | ||
168 | // We need it to get information about changes outside these class on ouer used configuration keys! | ||
169 | EnableNotification( seqNames ); | ||
170 | } | ||
171 | |||
172 | //***************************************************************************************************************** | ||
173 | // destructor | ||
174 | //***************************************************************************************************************** | ||
175 | SvtWorkingSetOptions_Impl::~SvtWorkingSetOptions_Impl() | ||
176 | { | ||
177 | // We must save our current values .. if user forget it! | ||
178 | if( IsModified() == sal_True ) | ||
179 | { | ||
180 | Commit(); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | //***************************************************************************************************************** | ||
185 | // public method | ||
186 | //***************************************************************************************************************** | ||
187 | void SvtWorkingSetOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames ) | ||
188 | { | ||
189 | // Use given list of updated properties to get his values from configuration directly! | ||
190 | Sequence< Any > seqValues = GetProperties( seqPropertyNames ); | ||
191 | // Safe impossible cases. | ||
192 | // We need values from ALL notified configuration keys. | ||
193 | DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::Notify()\nI miss some values of configuration keys!\n" ); | ||
194 | // Step over list of property names and get right value from coreesponding value list to set it on internal members! | ||
195 | sal_Int32 nCount = seqPropertyNames.getLength(); | ||
196 | for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) | ||
197 | { | ||
198 | if( seqPropertyNames[nProperty] == PROPERTYNAME_WINDOWLIST ) | ||
199 | { | ||
200 | DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" ); | ||
201 | seqValues[nProperty] >>= m_seqWindowList; | ||
202 | } | ||
203 | #if OSL_DEBUG_LEVEL > 1 | ||
204 | else DBG_ASSERT( sal_False, "SvtWorkingSetOptions_Impl::Notify()\nUnknown property detected ... I can't handle these!\n" ); | ||
205 | #endif | ||
206 | } | ||
207 | } | ||
208 | |||
209 | //***************************************************************************************************************** | ||
210 | // public method | ||
211 | //***************************************************************************************************************** | ||
212 | void SvtWorkingSetOptions_Impl::Commit() | ||
213 | { | ||
214 | // Get names of supported properties, create a list for values and copy current values to it. | ||
215 | Sequence< OUString > seqNames = GetPropertyNames (); | ||
216 | sal_Int32 nCount = seqNames.getLength(); | ||
217 | Sequence< Any > seqValues ( nCount ); | ||
218 | for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) | ||
219 | { | ||
220 | switch( nProperty ) | ||
221 | { | ||
222 | case PROPERTYHANDLE_WINDOWLIST : { | ||
223 | seqValues[nProperty] <<= m_seqWindowList; | ||
224 | } | ||
225 | break; | ||
226 | } | ||
227 | } | ||
228 | // Set properties in configuration. | ||
229 | PutProperties( seqNames, seqValues ); | ||
230 | } | ||
231 | |||
232 | //***************************************************************************************************************** | ||
233 | // private method | ||
234 | //***************************************************************************************************************** | ||
235 | Sequence< OUString > SvtWorkingSetOptions_Impl::GetPropertyNames() | ||
236 | { | ||
237 | // Build list of configuration key names. | ||
238 | const OUString pProperties[] = | ||
239 | { | ||
240 | PROPERTYNAME_WINDOWLIST , | ||
241 | }; | ||
242 | // Initialize return sequence with these list ... | ||
243 | const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); | ||
244 | // ... and return it. | ||
245 | return seqPropertyNames; | ||
246 | } | ||
247 | |||
248 | //***************************************************************************************************************** | ||
249 | // initialize static member | ||
250 | // DON'T DO IT IN YOUR HEADER! | ||
251 | // see definition for further informations | ||
252 | //***************************************************************************************************************** | ||
253 | SvtWorkingSetOptions_Impl* SvtWorkingSetOptions::m_pDataContainer = NULL ; | ||
254 | sal_Int32 SvtWorkingSetOptions::m_nRefCount = 0 ; | ||
255 | |||
256 | //***************************************************************************************************************** | ||
257 | // constructor | ||
258 | //***************************************************************************************************************** | ||
259 | SvtWorkingSetOptions::SvtWorkingSetOptions() | ||
260 | { | ||
261 | // Global access, must be guarded (multithreading!). | ||
262 | MutexGuard aGuard( GetOwnStaticMutex() ); | ||
263 | // Increase ouer refcount ... | ||
264 | ++m_nRefCount; | ||
265 | // ... and initialize ouer data container only if it not already exist! | ||
266 | if( m_pDataContainer == NULL ) | ||
267 | { | ||
268 | m_pDataContainer = new SvtWorkingSetOptions_Impl; | ||
269 | ItemHolder1::holdConfigItem(E_WORKINGSETOPTIONS); | ||
270 | } | ||
271 | } | ||
272 | |||
273 | //***************************************************************************************************************** | ||
274 | // destructor | ||
275 | //***************************************************************************************************************** | ||
276 | SvtWorkingSetOptions::~SvtWorkingSetOptions() | ||
277 | { | ||
278 | // Global access, must be guarded (multithreading!) | ||
279 | MutexGuard aGuard( GetOwnStaticMutex() ); | ||
280 | // Decrease ouer refcount. | ||
281 | --m_nRefCount; | ||
282 | // If last instance was deleted ... | ||
283 | // we must destroy ouer static data container! | ||
284 | if( m_nRefCount <= 0 ) | ||
285 | { | ||
286 | delete m_pDataContainer; | ||
287 | m_pDataContainer = NULL; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | namespace | ||
292 | { | ||
293 | class theWorkingSetOptionsMutex : public rtl::Static<osl::Mutex, theWorkingSetOptionsMutex>{}; | ||
294 | } | ||
295 | |||
296 | //***************************************************************************************************************** | ||
297 | // private method | ||
298 | //***************************************************************************************************************** | ||
299 | Mutex& SvtWorkingSetOptions::GetOwnStaticMutex() | ||
300 | { | ||
301 | return theWorkingSetOptionsMutex::get(); | ||
302 | } | ||
303 | |||
304 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ | ||