1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_
20 #define __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_
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 //_________________________________________________________________________________________________________________
32 //_________________________________________________________________________________________________________________
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"
47 #define STATUSBARITEM_STRING_ALIGN "Alignment"
48 #define STATUSBARITEM_STRING_AUTOSIZE "AutoSize"
49 #define STATUSBARITEM_STRING_OWNERDRAW "OwnerDraw"
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
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 )
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 )
71 #define ADDONSPOPUPMENU_URL_PREFIX_STR "private:menu/Addon"
73 #define ADDONSPOPUPMENU_URL_PREFIX OUString( ADDONSPOPUPMENU_URL_PREFIX_STR )
78 typedef ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> > MergeMenuDefinition
;
80 struct FWE_DLLPUBLIC MergeMenuInstruction
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
;
89 typedef ::std::vector
< MergeMenuInstruction
> MergeMenuInstructionContainer
;
91 struct FWE_DLLPUBLIC MergeToolbarInstruction
93 OUString aMergeToolbar
;
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
;
102 typedef ::std::vector
< MergeToolbarInstruction
> MergeToolbarInstructionContainer
;
104 struct FWE_DLLPUBLIC MergeStatusbarInstruction
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
;
114 typedef ::std::vector
< MergeStatusbarInstruction
> MergeStatusbarInstructionContainer
;
116 //_________________________________________________________________________________________________________________
117 // forward declarations
118 //_________________________________________________________________________________________________________________
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 *//*-*************************************************************************************************************/
127 class AddonsOptions_Impl
;
129 /*-************************************************************************************************************//**
130 @short collect information about menu features
136 @devstatus ready to use
137 *//*-*************************************************************************************************************/
139 class FWE_DLLPUBLIC AddonsOptions
141 //-------------------------------------------------------------------------------------------------------------
143 //-------------------------------------------------------------------------------------------------------------
146 //---------------------------------------------------------------------------------------------------------
147 // constructor / destructor
148 //---------------------------------------------------------------------------------------------------------
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 ...
157 @seealso member m_nRefCount
158 @seealso member m_pDataContainer
164 *//*-*****************************************************************************************************/
169 //---------------------------------------------------------------------------------------------------------
171 //---------------------------------------------------------------------------------------------------------
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().
180 @param "eMenu" select right menu to clear.
184 *//*-*****************************************************************************************************/
188 /*-****************************************************************************************************//**
189 @short returns if an addons menu is available
190 @descr Call to retrieve if a addons menu is available
193 @return sal_True if there is a menu otherwise sal_False
194 *//*-*****************************************************************************************************/
196 sal_Bool
HasAddonsMenu() const;
198 /*-****************************************************************************************************//**
199 @short returns number of addons toolbars
200 @descr Call to retrieve the number of addons toolbars
203 @return number of addons toolbars
204 *//*-*****************************************************************************************************/
205 sal_Int32
GetAddonsToolBarCount() const ;
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.
214 @return A list of menu items is returned.
216 @onerror We return an empty list.
217 *//*-*****************************************************************************************************/
219 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> >& GetAddonsMenu() const;
221 /*-****************************************************************************************************//**
222 @short Gets the menu bar part of all addon components registered
229 @onerror We return sal_False
230 *//*-*****************************************************************************************************/
232 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> >& GetAddonsMenuBarPart() const;
234 /*-****************************************************************************************************//**
235 @short Gets a toolbar part of an single addon
242 @onerror We return sal_False
243 *//*-*****************************************************************************************************/
245 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> >& GetAddonsToolBarPart( sal_uInt32 nIndex
) const;
247 /*-****************************************************************************************************//**
248 @short Gets a unique toolbar resource name of an single addon
255 @onerror We return sal_False
256 *//*-*****************************************************************************************************/
258 const OUString
GetAddonsToolbarResourceName( sal_uInt32 nIndex
) const;
260 /*-****************************************************************************************************//**
261 @short Retrieves all available merge instructions for the Office menu bar
266 @return The filled MergeMenuDefinitionContaier
268 @onerror We return sal_False
269 *//*-*****************************************************************************************************/
271 const MergeMenuInstructionContainer
& GetMergeMenuInstructions() const;
273 /*-****************************************************************************************************//**
274 @short Retrieves all available merge instructions for a single toolbar
281 @onerror We return sal_False
282 *//*-*****************************************************************************************************/
283 bool GetMergeToolbarInstructions( const OUString
& rToolbarName
, MergeToolbarInstructionContainer
& rToolbar
) const;
285 /*-****************************************************************************************************//**
286 @short Gets the Add-On help menu part of all addon components registered
293 @onerror We return sal_False
294 *//*-*****************************************************************************************************/
295 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> >& GetAddonsHelpMenu() const;
297 const MergeStatusbarInstructionContainer
& GetMergeStatusbarInstructions() const;
299 /*-****************************************************************************************************//**
300 @short Retrieve an image for a command URL which is defined inside the addon menu configuration
301 @descr Call it to retrieve an image for a command URL which is defined inside the addon menu configuration
305 @return An image which was defined in the configuration for the menu item. The image can be empty
306 no bitmap was defined for the request image properties.
308 @onerror An empty image
309 *//*-*****************************************************************************************************/
311 Image
GetImageFromURL( const OUString
& aURL
, sal_Bool bBig
, sal_Bool bNoScale
) const;
312 Image
GetImageFromURL( const OUString
& aURL
, sal_Bool bBig
) const;
314 //-------------------------------------------------------------------------------------------------------------
316 //-------------------------------------------------------------------------------------------------------------
318 /*-****************************************************************************************************//**
319 @short return a reference to a static mutex
320 @descr These class is partially threadsafe (for de-/initialization only).
321 All access methods are'nt safe!
322 We create a static mutex only for one ime and use at different times.
327 @return A reference to a static mutex member.
330 *//*-*****************************************************************************************************/
332 static ::osl::Mutex
& GetOwnStaticMutex();
334 /*-****************************************************************************************************//**
335 @short return a reference to a static mutex
336 @descr These class is partially threadsafe (for de-/initialization only).
337 All access methods are'nt safe!
338 We create a static mutex only for one ime and use at different times.
343 @return A reference to a static mutex member.
346 *//*-*****************************************************************************************************/
347 DECL_STATIC_LINK( AddonsOptions
, Notify
, void* );
349 //-------------------------------------------------------------------------------------------------------------
351 //-------------------------------------------------------------------------------------------------------------
357 Don't initialize these static member in these header!
358 a) Double dfined symbols will be detected ...
359 b) and unresolved externals exist at linking time.
360 Do it in your source only.
363 static AddonsOptions_Impl
* m_pDataContainer
; /// impl. data container as dynamic pointer for smaller memory requirements!
364 static sal_Int32 m_nRefCount
; /// internal ref count mechanism
366 }; // class SvtMenuOptions
370 #endif // #ifndef __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */