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 #ifndef INCLUDED_unotools_VIEWOPTIONS_HXX
24 #define INCLUDED_unotools_VIEWOPTIONS_HXX
25 
26 //_________________________________________________________________________________________________________________
27 //	includes
28 //_________________________________________________________________________________________________________________
29 
30 #include "unotools/unotoolsdllapi.h"
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <com/sun/star/beans/NamedValue.hpp>
33 #include <unotools/configmgr.hxx>
34 #include <unotools/configitem.hxx>
35 #include <sal/types.h>
36 #include <osl/mutex.hxx>
37 #include <rtl/ustring.hxx>
38 #include <unotools/options.hxx>
39 
40 //_________________________________________________________________________________________________________________
41 //	forward declarations
42 //_________________________________________________________________________________________________________________
43 
44 class SvtViewOptionsBase_Impl;
45 
46 //_________________________________________________________________________________________________________________
47 //	declarations
48 //_________________________________________________________________________________________________________________
49 
50 /*-************************************************************************************************************//**
51 	@descr			Use these enum values to specify right list in configuration in which your view data are saved.
52 *//*-*************************************************************************************************************/
53 
54 enum EViewType
55 {
56 	E_DIALOG	=	0,
57 	E_TABDIALOG	=	1,
58 	E_TABPAGE	=	2,
59 	E_WINDOW	=	3
60 };
61 
62 /*-************************************************************************************************************//**
63 	@short			collect informations about view features
64 	@descr          We support different basetypes of views like dialogs, tab-dialogs, tab-pages and normal windows.
65 					You must specify your basetype by using right enum value and must give us a valid name for your
66 					subkey in registry! We support some fix features for some bastypes and user data as string for all!
67 					see also configuration package "org.openoffice.Office.Views/..." for further informations.
68 
69 					template of configuration:
70 						DialogType
71                             /WindowState    [string]
72                             /UserData       [set of any scalar types]
73 						TabDialogType
74                             /WindowState    [string]
75                             /UserData       [set of any scalar types]
76                             /PageID         [int]
77 						TabPageType
78                             /WindowState    [string]
79                             /UserData       [set of any scalar types]
80 						WindowType
81                             /WindowState    [string]
82                             /UserData       [set of any scalar types]
83                             /Visible        [boolean]
84 
85 					structure of configuration:
86 
87 						org.openoffice.Office.Views	[package]
88 													/Dialogs	[set]
89 																/Dialog_FileOpen			[DialogType]
90 																/Dialog_ImportGraphics		[DialogType]
91 																...
92 																/Dialog_<YourName>			[DialogType]
93 
94 													/TabDialogs	[set]
95 																/TabDialog_001				[TabDialogType]
96 																/TabDialog_Blubber			[TabDialogType]
97 																...
98 																/TabDialog_<YourName>		[TabDialogType]
99 
100 													/TabPages	[set]
101 																/TabPage_XXX				[TabPageType]
102 																/TabPage_Date				[TabPageType]
103 																...
104 																/TabPage_<YourName>			[TabPageType]
105 
106 													/Windows	[set]
107 																/Window_User				[WindowType]
108 																/Window_Options				[WindowType]
109 																...
110 																/Window_<YourName>			[WindowType]
111 
112 	@implements		-
113 	@base			-
114 
115 	@devstatus		ready to use
116 *//*-*************************************************************************************************************/
117 
118 class UNOTOOLS_DLLPUBLIC SvtViewOptions: public utl::detail::Options
119 {
120     /*
121     #ifdef TF_OLDVIEW
122     public:
123         void                                                                        GetPosition     (       sal_Int32&                                                                  nX              ,
124                                                                                                             sal_Int32&                                                                  nY              ) const;
125         void                                                                        SetPosition     (       sal_Int32                                                                   nX              ,
126                                                                                                             sal_Int32                                                                   nY              );
127         void                                                                        GetSize         (       sal_Int32&                                                                  nWidth          ,
128                                                                                                             sal_Int32&                                                                  nHeight         ) const;
129         void                                                                        SetSize         (       sal_Int32                                                                   nWidth          ,
130                                                                                                             sal_Int32                                                                   nHeight         );
131         ::rtl::OUString                                                             GetUserData     (                                                                                                   ) const;
132         void                                                                        SetUserData     ( const ::rtl::OUString&                                                            sData           );
133         static ::com::sun::star::uno::Sequence< ::rtl::OUString >                   SeperateUserData( const ::rtl::OUString&                                                            sData           ,
134                                                                                                             sal_Unicode                                                                 cSeperator=';'  );
135         static ::rtl::OUString                                                      GenerateUserData( const ::com::sun::star::uno::Sequence< ::rtl::OUString >&                         seqData         ,
136                                                                                                             sal_Unicode                                                                 cSeperator=';'  );
137         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >   GetAnyData      (                                                                                                   ) const;
138         void                                                                        SetAnyData      ( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&  lData           );
139     #endif
140     */
141 
142 	//-------------------------------------------------------------------------------------------------------------
143 	//	public methods
144 	//-------------------------------------------------------------------------------------------------------------
145 
146 	public:
147 
148 		//---------------------------------------------------------------------------------------------------------
149 		//	constructor / destructor
150 		//---------------------------------------------------------------------------------------------------------
151 
152 		/*-****************************************************************************************************//**
153 			@short		standard constructor and destructor
154 			@descr		This will de-/initialize an instance with default values.
155 						You must give us the basic type of your view and a name which specify right entry
156 						in dynamical configuration list. If entry not exist, we create a new one!
157 
158 			@seealso	enum EViewType
159 
160 			@param		"eType" specify type of your view and is used to use right data container!
161 			@param		"sViewName" specify the name of your view and is the key name in data list too.
162 			@return		-
163 
164 			@onerror	An assertion is thrown in debug version. Otherwise we do nothing!
165 		*//*-*****************************************************************************************************/
166 
167          SvtViewOptions(       EViewType        eType     ,
168                          const ::rtl::OUString& sViewName );
169         virtual ~SvtViewOptions();
170 
171 		/*-****************************************************************************************************//**
172             @short      support preload of these config item
173             @descr      Sometimes we need preloading of these configuration data without real using of it.
174 
175             @seealso    -
176 
177             @param      -
178 			@return		-
179 
180             @onerror    -
181 		*//*-*****************************************************************************************************/
182 
183         static void AcquireOptions();
184         static void ReleaseOptions();
185 
186 		//---------------------------------------------------------------------------------------------------------
187 		//	interface
188 		//---------------------------------------------------------------------------------------------------------
189 
190 		/*-****************************************************************************************************//**
191 			@short		use it to get information about existing entries in configuration
192 			@descr		The methods to set/get the position or size will create a new entry automatically if
193 						it not already exist and work with default values!
194 						If this a problem for you - you MUST call these method before and
195 						you must make up your own mind about that.
196 
197             @seealso    -
198 
199 			@onerror	No error should occur.
200 		*//*-*****************************************************************************************************/
201 
202 		sal_Bool Exists() const;
203 
204 		/*-****************************************************************************************************//**
205 			@short		use it to delete an entry of dynamic view set
206 			@descr		You can use this method to delete anexisting node in configuration.
207 						But if you call a Set- or Get- method again on this instance
208 						the item is created again! If you do nothing after this call
209 						your view will die relay in configuration ...
210 
211 			@seealso	method Exist()
212 
213 			@return		True if delete OK, False otherwise.
214 
215 			@onerror	We return sal_False.
216 		*//*-*****************************************************************************************************/
217 
218 		sal_Bool Delete();
219 
220 		/*-****************************************************************************************************//**
221             @short      use it to set/get the window state of your view
222             @descr      These value describe position/size and some other states of a window.
223                         Use it with right vcl methods directly. Normally it's not necessary to
224                         parse given string!
225 
226             @seealso    vcl methods
227 
228             @onerror    -
229 		*//*-*****************************************************************************************************/
230 
231         ::rtl::OUString GetWindowState(                               ) const;
232         void            SetWindowState( const ::rtl::OUString& sState );
233 
234 		/*-****************************************************************************************************//**
235 			@short		use it to set/get the page number which was the last active one
236 			@descr		It's only supported for:	- tab-dialogs
237 						If you call it for other ones you will get an assertion in debug version.
238 						In a product version we do nothing!
239 
240 			@seealso	-
241 
242 			@onerror	An assertion is thrown in debug version. Otherwise we do nothing!
243 		*//*-*****************************************************************************************************/
244 
245         sal_Int32 GetPageID(               ) const;
246         void      SetPageID( sal_Int32 nID );
247 
248 		/*-****************************************************************************************************//**
249 			@short		use it to set/get the visual state of a window
250 			@descr		It's only supported for:	- windows
251 						If you call it for other ones you will get an assertion in debug version.
252 						In a product version we do nothing!
253 
254 			@seealso	-
255 
256 			@onerror	An assertion is thrown in debug version. Otherwise we do nothing!
257 		*//*-*****************************************************************************************************/
258 
259         sal_Bool IsVisible (                 ) const;
260         void     SetVisible( sal_Bool bState );
261 
262 		/*-****************************************************************************************************//**
263 			@short		use it to set/get the extended user data (consisting of a set of named scalar values)
264 			@descr		It's supported for ALL types!
265 						Every view can handle its own user defined data set.
266 
267             @seealso    -
268 
269 			@onerror	In the non-product version, an assertion is made. In a product version, errors are silently ignored.
270 		*//*-*****************************************************************************************************/
271 /*
272 #ifdef TF_OLDVIEW
273         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GetUserData( sal_Bool bMakeItDifferent ) const;
274 #else
275 */
276         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GetUserData(                                                                                     ) const;
277 //#endif
278         void                                                                   SetUserData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& lData );
279 
280 		/*-****************************************************************************************************//**
281             @short      use it to set/get ONE special user data item directly
282             @descr      Normally you can work on full user data list by using "Set/GetUserData()".
283                         With this function you have an access on special list entries directly without any
284 
285             @seealso    -
286 
287 			@onerror	In the non-product version, an assertion is made. In a product version, errors are silently ignored.
288 		*//*-*****************************************************************************************************/
289 
290         ::com::sun::star::uno::Any GetUserItem( const ::rtl::OUString&            sName  ) const;
291         void                       SetUserItem( const ::rtl::OUString&            sName  ,
292                                                 const ::com::sun::star::uno::Any& aValue );
293 
294 	//-------------------------------------------------------------------------------------------------------------
295 	//	private methods
296 	//-------------------------------------------------------------------------------------------------------------
297 
298     private:
299 
300 		/*-****************************************************************************************************//**
301 			@short		return a reference to a static mutex
302 			@descr		These class is threadsafe.
303 						We create a static mutex only for one time and use it to protect our refcount and container
304 						member!
305 
306 			@seealso	-
307 
308 			@param		-
309 			@return		A reference to a static mutex member.
310 
311 			@onerror	-
312 		*//*-*****************************************************************************************************/
313 
314         UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex();
315 
316 	//-------------------------------------------------------------------------------------------------------------
317 	//	private member
318 	//-------------------------------------------------------------------------------------------------------------
319 
320 	private:
321 
322 		/// specify which list of views in configuration is used! This can't be a static value!!!
323 		/// ... because we need this value to work with right static data container.
324 		EViewType			m_eViewType		;
325 		::rtl::OUString		m_sViewName		;
326 
327 		/// - impl. data container as dynamic pointer for smaller memory requirements!
328 		/// - internal ref count mechanism
329 
330 		/*Attention
331 
332 			Don't initialize these static member in these header!
333 			a) Double defined symbols will be detected ...
334 			b) and unresolved externals exist at linking time.
335 			Do it in your source only.
336 		 */
337 
338         static SvtViewOptionsBase_Impl*    m_pDataContainer_Dialogs    ;   /// hold data for all dialogs
339         static sal_Int32                   m_nRefCount_Dialogs         ;
340         static SvtViewOptionsBase_Impl*    m_pDataContainer_TabDialogs ;   /// hold data for all tab-dialogs
341         static sal_Int32                   m_nRefCount_TabDialogs      ;
342         static SvtViewOptionsBase_Impl*    m_pDataContainer_TabPages   ;   /// hold data for all tab-pages
343         static sal_Int32                   m_nRefCount_TabPages        ;
344         static SvtViewOptionsBase_Impl*    m_pDataContainer_Windows    ;   /// hold data for all windows
345         static sal_Int32                   m_nRefCount_Windows         ;
346 
347 };		// class SvtViewOptions
348 
349 #endif  // #ifndef INCLUDED_unotools_VIEWOPTIONS_HXX
350