Line data Source code
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 : #ifndef __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_
20 : #define __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_
21 :
22 : #include <sal/types.h>
23 : #include <osl/mutex.hxx>
24 : #include <vcl/image.hxx>
25 : #include <vcl/bitmap.hxx>
26 : #include <vcl/svapp.hxx>
27 : #include <com/sun/star/uno/Sequence.h>
28 : #include <com/sun/star/beans/PropertyValue.hpp>
29 : #include <framework/fwedllapi.h>
30 : //_________________________________________________________________________________________________________________
31 : // types, enums, ...
32 : //_________________________________________________________________________________________________________________
33 :
34 : /*-************************************************************************************************************//**
35 : @descr The method GetAddonsMenu() returns a list of property values.
36 : Use follow defines to separate values by names.
37 : *//*-*************************************************************************************************************/
38 : #define ADDONSMENUITEM_STRING_URL "URL"
39 : #define ADDONSMENUITEM_STRING_TITLE "Title"
40 : #define ADDONSMENUITEM_STRING_TARGET "Target"
41 : #define ADDONSMENUITEM_STRING_IMAGEIDENTIFIER "ImageIdentifier"
42 : #define ADDONSMENUITEM_STRING_CONTEXT "Context"
43 : #define ADDONSMENUITEM_STRING_SUBMENU "Submenu"
44 : #define ADDONSMENUITEM_STRING_CONTROLTYPE "ControlType"
45 : #define ADDONSMENUITEM_STRING_WIDTH "Width"
46 :
47 : #define STATUSBARITEM_STRING_ALIGN "Alignment"
48 : #define STATUSBARITEM_STRING_AUTOSIZE "AutoSize"
49 : #define STATUSBARITEM_STRING_OWNERDRAW "OwnerDraw"
50 :
51 : #define ADDONSMENUITEM_URL_LEN 3
52 : #define ADDONSMENUITEM_TITLE_LEN 5
53 : #define ADDONSMENUITEM_TARGET_LEN 6
54 : #define ADDONSMENUITEM_SUBMENU_LEN 7
55 : #define ADDONSMENUITEM_CONTEXT_LEN 7
56 : #define ADDONSMENUITEM_IMAGEIDENTIFIER_LEN 15
57 :
58 : #define ADDONSMENUITEM_PROPERTYNAME_URL OUString(ADDONSMENUITEM_STRING_URL )
59 : #define ADDONSMENUITEM_PROPERTYNAME_TITLE OUString(ADDONSMENUITEM_STRING_TITLE )
60 : #define ADDONSMENUITEM_PROPERTYNAME_TARGET OUString(ADDONSMENUITEM_STRING_TARGET )
61 : #define ADDONSMENUITEM_PROPERTYNAME_IMAGEIDENTIFIER OUString(ADDONSMENUITEM_STRING_IMAGEIDENTIFIER )
62 : #define ADDONSMENUITEM_PROPERTYNAME_CONTEXT OUString(ADDONSMENUITEM_STRING_CONTEXT )
63 : #define ADDONSMENUITEM_PROPERTYNAME_SUBMENU OUString(ADDONSMENUITEM_STRING_SUBMENU )
64 : #define ADDONSMENUITEM_PROPERTYNAME_CONTROLTYPE OUString(ADDONSMENUITEM_STRING_CONTROLTYPE )
65 : #define ADDONSMENUITEM_PROPERTYNAME_WIDTH OUString(ADDONSMENUITEM_STRING_WIDTH )
66 :
67 : #define STATUSBARITEM_PROPERTYNAME_ALIGN OUString(STATUSBARITEM_STRING_ALIGN )
68 : #define STATUSBARITEM_PROPERTYNAME_AUTOSIZE OUString(STATUSBARITEM_STRING_AUTOSIZE )
69 : #define STATUSBARITEM_PROPERTYNAME_OWNERDRAW OUString(STATUSBARITEM_STRING_OWNERDRAW )
70 :
71 : #define ADDONSPOPUPMENU_URL_PREFIX_STR "private:menu/Addon"
72 :
73 : #define ADDONSPOPUPMENU_URL_PREFIX OUString( ADDONSPOPUPMENU_URL_PREFIX_STR )
74 :
75 : namespace framework
76 : {
77 :
78 : typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > MergeMenuDefinition;
79 :
80 2212 : struct FWE_DLLPUBLIC MergeMenuInstruction
81 : {
82 : OUString aMergePoint;
83 : OUString aMergeCommand;
84 : OUString aMergeCommandParameter;
85 : OUString aMergeFallback;
86 : OUString aMergeContext;
87 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > aMergeMenu;
88 : };
89 : typedef ::std::vector< MergeMenuInstruction > MergeMenuInstructionContainer;
90 :
91 0 : struct FWE_DLLPUBLIC MergeToolbarInstruction
92 : {
93 : OUString aMergeToolbar;
94 : OUString aMergePoint;
95 : OUString aMergeCommand;
96 : OUString aMergeCommandParameter;
97 : OUString aMergeFallback;
98 : OUString aMergeContext;
99 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > aMergeToolbarItems;
100 : };
101 :
102 : typedef ::std::vector< MergeToolbarInstruction > MergeToolbarInstructionContainer;
103 :
104 0 : struct FWE_DLLPUBLIC MergeStatusbarInstruction
105 : {
106 : ::rtl::OUString aMergePoint;
107 : ::rtl::OUString aMergeCommand;
108 : ::rtl::OUString aMergeCommandParameter;
109 : ::rtl::OUString aMergeFallback;
110 : ::rtl::OUString aMergeContext;
111 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > aMergeStatusbarItems;
112 : };
113 :
114 : typedef ::std::vector< MergeStatusbarInstruction > MergeStatusbarInstructionContainer;
115 :
116 : //_________________________________________________________________________________________________________________
117 : // forward declarations
118 : //_________________________________________________________________________________________________________________
119 :
120 : /*-************************************************************************************************************//**
121 : @short forward declaration to our private date container implementation
122 : @descr We use these class as internal member to support small memory requirements.
123 : You can create the container if it is neccessary. The class which use these mechanism
124 : is faster and smaller then a complete implementation!
125 : *//*-*************************************************************************************************************/
126 :
127 : class AddonsOptions_Impl;
128 :
129 : /*-************************************************************************************************************//**
130 : @short collect information about menu features
131 : @descr -
132 :
133 : @implements -
134 : @base -
135 :
136 : @devstatus ready to use
137 : *//*-*************************************************************************************************************/
138 :
139 : class FWE_DLLPUBLIC AddonsOptions
140 : {
141 : //-------------------------------------------------------------------------------------------------------------
142 : // public methods
143 : //-------------------------------------------------------------------------------------------------------------
144 :
145 : public:
146 : //---------------------------------------------------------------------------------------------------------
147 : // constructor / destructor
148 : //---------------------------------------------------------------------------------------------------------
149 :
150 : /*-****************************************************************************************************//**
151 : @short standard constructor and destructor
152 : @descr This will initialize an instance with default values.
153 : We implement these class with a refcount mechanism! Every instance of this class increase it
154 : at create and decrease it at delete time - but all instances use the same data container!
155 : He is implemented as a static member ...
156 :
157 : @seealso member m_nRefCount
158 : @seealso member m_pDataContainer
159 :
160 : @param -
161 : @return -
162 :
163 : @onerror -
164 : *//*-*****************************************************************************************************/
165 :
166 : AddonsOptions();
167 : ~AddonsOptions();
168 :
169 : //---------------------------------------------------------------------------------------------------------
170 : // interface
171 : //---------------------------------------------------------------------------------------------------------
172 :
173 : /*-****************************************************************************************************//**
174 : @short clears completely the addons menu
175 : @descr Call this methods to clear the addons menu
176 : To fill it again use AppendItem().
177 :
178 : @seealso -
179 :
180 : @param "eMenu" select right menu to clear.
181 : @return -
182 :
183 : @onerror -
184 : *//*-*****************************************************************************************************/
185 :
186 : void Clear();
187 :
188 : /*-****************************************************************************************************//**
189 : @short returns if an addons menu is available
190 : @descr Call to retrieve if a addons menu is available
191 :
192 :
193 : @return sal_True if there is a menu otherwise sal_False
194 : *//*-*****************************************************************************************************/
195 :
196 : sal_Bool HasAddonsMenu() const;
197 :
198 : /*-****************************************************************************************************//**
199 : @short returns number of addons toolbars
200 : @descr Call to retrieve the number of addons toolbars
201 :
202 :
203 : @return number of addons toolbars
204 : *//*-*****************************************************************************************************/
205 : sal_Int32 GetAddonsToolBarCount() const ;
206 :
207 : /*-****************************************************************************************************//**
208 : @short returns the complete addons menu
209 : @descr Call it to get all entries of the addon menu.
210 : We return a list of all nodes with his names and properties.
211 :
212 : @seealso -
213 :
214 : @return A list of menu items is returned.
215 :
216 : @onerror We return an empty list.
217 : *//*-*****************************************************************************************************/
218 :
219 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsMenu() const;
220 :
221 : /*-****************************************************************************************************//**
222 : @short Gets the menu bar part of all addon components registered
223 : @descr -
224 :
225 : @seealso -
226 :
227 : @return A complete
228 :
229 : @onerror We return sal_False
230 : *//*-*****************************************************************************************************/
231 :
232 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsMenuBarPart() const;
233 :
234 : /*-****************************************************************************************************//**
235 : @short Gets a toolbar part of an single addon
236 : @descr -
237 :
238 : @seealso -
239 :
240 : @return A complete
241 :
242 : @onerror We return sal_False
243 : *//*-*****************************************************************************************************/
244 :
245 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsToolBarPart( sal_uInt32 nIndex ) const;
246 :
247 : /*-****************************************************************************************************//**
248 : @short Gets a unique toolbar resource name of an single addon
249 : @descr -
250 :
251 : @seealso -
252 :
253 : @return A complete
254 :
255 : @onerror We return sal_False
256 : *//*-*****************************************************************************************************/
257 :
258 : const OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;
259 :
260 : /*-****************************************************************************************************//**
261 : @short Retrieves all available merge instructions for the Office menu bar
262 : @descr -
263 :
264 : @seealso -
265 :
266 : @return The filled MergeMenuDefinitionContaier
267 :
268 : @onerror We return sal_False
269 : *//*-*****************************************************************************************************/
270 :
271 : const MergeMenuInstructionContainer& GetMergeMenuInstructions() const;
272 :
273 : /*-****************************************************************************************************//**
274 : @short Retrieves all available merge instructions for a single toolbar
275 : @descr -
276 :
277 : @seealso -
278 :
279 : @return The filled
280 :
281 : @onerror We return sal_False
282 : *//*-*****************************************************************************************************/
283 : bool GetMergeToolbarInstructions( const OUString& rToolbarName, MergeToolbarInstructionContainer& rToolbar ) const;
284 :
285 : /**
286 : * @short Gets the UI name of a single addon toolbar
287 : * @return The UI name of the toolbar as specified in the Addons.xcu configuration
288 : * @onerror Returns an empty string
289 : */
290 : const ::rtl::OUString GetAddonsToolbarUIName( sal_uInt32 nIndex ) const;
291 :
292 : /*-****************************************************************************************************//**
293 : @short Gets the Add-On help menu part of all addon components registered
294 : @descr -
295 :
296 : @seealso -
297 :
298 : @return A complete
299 :
300 : @onerror We return sal_False
301 : *//*-*****************************************************************************************************/
302 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsHelpMenu() const;
303 :
304 : const MergeStatusbarInstructionContainer& GetMergeStatusbarInstructions() const;
305 :
306 : /*-****************************************************************************************************//**
307 : @short Retrieve an image for a command URL which is defined inside the addon menu configuration
308 : @descr Call it to retrieve an image for a command URL which is defined inside the addon menu configuration
309 :
310 : @seealso -
311 :
312 : @return An image which was defined in the configuration for the menu item. The image can be empty
313 : no bitmap was defined for the request image properties.
314 :
315 : @onerror An empty image
316 : *//*-*****************************************************************************************************/
317 :
318 : Image GetImageFromURL( const OUString& aURL, sal_Bool bBig, sal_Bool bNoScale ) const;
319 : Image GetImageFromURL( const OUString& aURL, sal_Bool bBig ) const;
320 :
321 : //-------------------------------------------------------------------------------------------------------------
322 : // private methods
323 : //-------------------------------------------------------------------------------------------------------------
324 :
325 : /*-****************************************************************************************************//**
326 : @short return a reference to a static mutex
327 : @descr These class is partially threadsafe (for de-/initialization only).
328 : All access methods are'nt safe!
329 : We create a static mutex only for one ime and use at different times.
330 :
331 : @seealso -
332 :
333 : @param -
334 : @return A reference to a static mutex member.
335 :
336 : @onerror -
337 : *//*-*****************************************************************************************************/
338 :
339 : static ::osl::Mutex& GetOwnStaticMutex();
340 :
341 : /*-****************************************************************************************************//**
342 : @short return a reference to a static mutex
343 : @descr These class is partially threadsafe (for de-/initialization only).
344 : All access methods are'nt safe!
345 : We create a static mutex only for one ime and use at different times.
346 :
347 : @seealso -
348 :
349 : @param -
350 : @return A reference to a static mutex member.
351 :
352 : @onerror -
353 : *//*-*****************************************************************************************************/
354 : DECL_STATIC_LINK( AddonsOptions, Notify, void* );
355 :
356 : //-------------------------------------------------------------------------------------------------------------
357 : // private member
358 : //-------------------------------------------------------------------------------------------------------------
359 :
360 : private:
361 :
362 : /*Attention
363 :
364 : Don't initialize these static member in these header!
365 : a) Double dfined symbols will be detected ...
366 : b) and unresolved externals exist at linking time.
367 : Do it in your source only.
368 : */
369 :
370 : static AddonsOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements!
371 : static sal_Int32 m_nRefCount ; /// internal ref count mechanism
372 :
373 : }; // class SvtMenuOptions
374 :
375 : }
376 :
377 : #endif // #ifndef __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_
378 :
379 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|