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_DYNAMICMENUOPTIONS_HXX
24 #define INCLUDED_unotools_DYNAMICMENUOPTIONS_HXX
25 
26 //_________________________________________________________________________________________________________________
27 //	includes
28 //_________________________________________________________________________________________________________________
29 
30 #include "unotools/unotoolsdllapi.h"
31 #include <sal/types.h>
32 #include <osl/mutex.hxx>
33 #include <com/sun/star/uno/Sequence.h>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <unotools/options.hxx>
36 
37 //_________________________________________________________________________________________________________________
38 //	types, enums, ...
39 //_________________________________________________________________________________________________________________
40 
41 /*-************************************************************************************************************//**
42 	@descr			The method GetList() returns a list of property values.
43 					Use follow defines to seperate values by names.
44 *//*-*************************************************************************************************************/
45 #define DYNAMICMENU_PROPERTYNAME_URL                    ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"             ))
46 #define DYNAMICMENU_PROPERTYNAME_TITLE                  ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"           ))
47 #define DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageIdentifier" ))
48 #define DYNAMICMENU_PROPERTYNAME_TARGETNAME             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TargetName"      ))
49 
50 /*-************************************************************************************************************//**
51     @descr          You can use these enum values to specify right menu if you call our interface methods.
52 *//*-*************************************************************************************************************/
53 enum EDynamicMenuType
54 {
55     E_NEWMENU       =   0,
56     E_WIZARDMENU    =   1,
57     E_HELPBOOKMARKS =   2
58 };
59 //_________________________________________________________________________________________________________________
60 //	forward declarations
61 //_________________________________________________________________________________________________________________
62 
63 /*-************************************************************************************************************//**
64 	@short			forward declaration to our private date container implementation
65 	@descr			We use these class as internal member to support small memory requirements.
66 					You can create the container if it is neccessary. The class which use these mechanism
67 					is faster and smaller then a complete implementation!
68 *//*-*************************************************************************************************************/
69 
70 class SvtDynamicMenuOptions_Impl;
71 
72 //_________________________________________________________________________________________________________________
73 //	declarations
74 //_________________________________________________________________________________________________________________
75 
76 /*-************************************************************************************************************//**
77     @short          collect informations about dynamic menus
78     @descr          Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
79 
80 	@implements		-
81 	@base			-
82 
83 	@devstatus		ready to use
84 *//*-*************************************************************************************************************/
85 
86 class UNOTOOLS_DLLPUBLIC SvtDynamicMenuOptions: public utl::detail::Options
87 {
88 	//-------------------------------------------------------------------------------------------------------------
89 	//	public methods
90 	//-------------------------------------------------------------------------------------------------------------
91 
92 	public:
93 
94 		//---------------------------------------------------------------------------------------------------------
95 		//	constructor / destructor
96 		//---------------------------------------------------------------------------------------------------------
97 
98 		/*-****************************************************************************************************//**
99 			@short		standard constructor and destructor
100 			@descr		This will initialize an instance with default values.
101 						We implement these class with a refcount mechanism! Every instance of this class increase it
102 						at create and decrease it at delete time - but all instances use the same data container!
103 						He is implemented as a static member ...
104 
105 			@seealso	member m_nRefCount
106 			@seealso	member m_pDataContainer
107 
108 			@param		-
109 			@return		-
110 
111 			@onerror	-
112 		*//*-*****************************************************************************************************/
113 
114          SvtDynamicMenuOptions();
115         virtual ~SvtDynamicMenuOptions();
116 
117 		//---------------------------------------------------------------------------------------------------------
118 		//	interface
119 		//---------------------------------------------------------------------------------------------------------
120 
121         /*-****************************************************************************************************//**
122 			@short		clear complete sepcified list
123             @descr      Call this methods to clear the whole list.
124                         To fill it again use AppendItem().
125 
126 			@seealso	-
127 
128             @param      "eMenu" select right menu to clear.
129 			@return		-
130 
131 			@onerror	-
132 		*//*-*****************************************************************************************************/
133 
134         void Clear( EDynamicMenuType eMenu );
135 
136 		/*-****************************************************************************************************//**
137             @short      return complete specified list
138             @descr      Call it to get all entries of an dynamic menu.
139                         We return a list of all nodes with his names and properties.
140 
141 			@seealso	-
142 
143             @param      "eMenu" select right menu.
144             @return     A list of menu items is returned.
145 
146             @onerror    We return an empty list.
147 		*//*-*****************************************************************************************************/
148 
149         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > GetMenu( EDynamicMenuType eMenu ) const;
150 
151 		/*-****************************************************************************************************//**
152             @short      append a new item to specified menu
153             @descr      You can append items to a menu only - removing isn't allowed for a special item!
154                         We support a nothing or all mechanism only! Clear all or append something ...
155 
156 			@seealso	method Clear()
157 
158             @param      "eMenu"             select right menu.
159             @param      "sURL"              URL for dispatch
160             @param      "sTitle"            label of menu entry
161             @param      "sImageIdentifier"  icon identifier
162             @param      "sTargetName"       target for dispatch
163 			@return		-
164 
165 			@onerror	-
166 		*//*-*****************************************************************************************************/
167 
168         void AppendItem(            EDynamicMenuType    eMenu            ,
169                             const   ::rtl::OUString&    sURL             ,
170                             const   ::rtl::OUString&    sTitle           ,
171                             const   ::rtl::OUString&    sImageIdentifier ,
172                             const   ::rtl::OUString&    sTargetName      );
173 
174 	//-------------------------------------------------------------------------------------------------------------
175 	//	private methods
176 	//-------------------------------------------------------------------------------------------------------------
177 
178 	private:
179 
180 		/*-****************************************************************************************************//**
181 			@short		return a reference to a static mutex
182 			@descr		These class is partially threadsafe (for de-/initialization only).
183 						All access methods are'nt safe!
184 						We create a static mutex only for one ime and use at different times.
185 
186 			@seealso	-
187 
188 			@param		-
189 			@return		A reference to a static mutex member.
190 
191 			@onerror	-
192 		*//*-*****************************************************************************************************/
193 
194         UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex();
195 
196 	//-------------------------------------------------------------------------------------------------------------
197 	//	private member
198 	//-------------------------------------------------------------------------------------------------------------
199 
200 	private:
201 
202 		/*Attention
203 
204 			Don't initialize these static member in these header!
205 			a) Double dfined symbols will be detected ...
206 			b) and unresolved externals exist at linking time.
207 			Do it in your source only.
208 		 */
209 
210         static SvtDynamicMenuOptions_Impl* m_pDataContainer    ;   /// impl. data container as dynamic pointer for smaller memory requirements!
211         static sal_Int32             m_nRefCount         ;   /// internal ref count mechanism
212 
213 };      // class SvtDynamicMenuOptions
214 
215 #endif  // #ifndef INCLUDED_unotools_DYNAMICMENUOPTIONS_HXX
216