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 INCLUDED_FRAMEWORK_ADDONSOPTIONS_HXX
20 : #define INCLUDED_FRAMEWORK_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 0 : 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 necessary. 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 : @devstatus ready to use
132 : *//*-*************************************************************************************************************/
133 :
134 : class FWE_DLLPUBLIC AddonsOptions
135 : {
136 :
137 : // public methods
138 :
139 :
140 : public:
141 :
142 : // constructor / destructor
143 :
144 :
145 : /*-****************************************************************************************************
146 : @short standard constructor and destructor
147 : @descr This will initialize an instance with default values.
148 : We implement these class with a refcount mechanism! Every instance of this class increase it
149 : at create and decrease it at delete time - but all instances use the same data container!
150 : He is implemented as a static member ...
151 :
152 : @seealso member m_nRefCount
153 : @seealso member m_pDataContainer
154 : *//*-*****************************************************************************************************/
155 :
156 : AddonsOptions();
157 : ~AddonsOptions();
158 :
159 :
160 : // interface
161 :
162 :
163 : /*-****************************************************************************************************
164 : @short clears completely the addons menu
165 : @descr Call this methods to clear the addons menu
166 : To fill it again use AppendItem().
167 : @param "eMenu" select right menu to clear.
168 : *//*-*****************************************************************************************************/
169 :
170 : void Clear();
171 :
172 : /*-****************************************************************************************************
173 : @short returns if an addons menu is available
174 : @descr Call to retrieve if a addons menu is available
175 :
176 :
177 : @return true if there is a menu otherwise false
178 : *//*-*****************************************************************************************************/
179 :
180 : bool HasAddonsMenu() const;
181 :
182 : /*-****************************************************************************************************
183 : @short returns number of addons toolbars
184 : @descr Call to retrieve the number of addons toolbars
185 :
186 :
187 : @return number of addons toolbars
188 : *//*-*****************************************************************************************************/
189 : sal_Int32 GetAddonsToolBarCount() const ;
190 :
191 : /*-****************************************************************************************************
192 : @short returns the complete addons menu
193 : @descr Call it to get all entries of the addon menu.
194 : We return a list of all nodes with his names and properties.
195 : @return A list of menu items is returned.
196 :
197 : @onerror We return an empty list.
198 : *//*-*****************************************************************************************************/
199 :
200 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsMenu() const;
201 :
202 : /*-****************************************************************************************************
203 : @short Gets the menu bar part of all addon components registered
204 : @return A complete
205 :
206 : @onerror We return sal_False
207 : *//*-*****************************************************************************************************/
208 :
209 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsMenuBarPart() const;
210 :
211 : /*-****************************************************************************************************
212 : @short Gets a toolbar part of an single addon
213 : @return A complete
214 :
215 : @onerror We return sal_False
216 : *//*-*****************************************************************************************************/
217 :
218 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsToolBarPart( sal_uInt32 nIndex ) const;
219 :
220 : /*-****************************************************************************************************
221 : @short Gets a unique toolbar resource name of an single addon
222 : @return A complete
223 :
224 : @onerror We return sal_False
225 : *//*-*****************************************************************************************************/
226 :
227 : const OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;
228 :
229 : /*-****************************************************************************************************
230 : @short Retrieves all available merge instructions for the Office menu bar
231 : @return The filled MergeMenuDefinitionContaier
232 :
233 : @onerror We return sal_False
234 : *//*-*****************************************************************************************************/
235 :
236 : const MergeMenuInstructionContainer& GetMergeMenuInstructions() const;
237 :
238 : /*-****************************************************************************************************
239 : @short Retrieves all available merge instructions for a single toolbar
240 : @return The filled
241 :
242 : @onerror We return sal_False
243 : *//*-*****************************************************************************************************/
244 : bool GetMergeToolbarInstructions( const OUString& rToolbarName, MergeToolbarInstructionContainer& rToolbar ) const;
245 :
246 : /*-****************************************************************************************************
247 : @short Gets the Add-On help menu part of all addon components registered
248 : @return A complete
249 :
250 : @onerror We return sal_False
251 : *//*-*****************************************************************************************************/
252 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsHelpMenu() const;
253 :
254 : const MergeStatusbarInstructionContainer& GetMergeStatusbarInstructions() const;
255 :
256 : /*-****************************************************************************************************
257 : @short Retrieve an image for a command URL which is defined inside the addon menu configuration
258 : @descr Call it to retrieve an image for a command URL which is defined inside the addon menu configuration
259 : @return An image which was defined in the configuration for the menu item. The image can be empty
260 : no bitmap was defined for the request image properties.
261 :
262 : @onerror An empty image
263 : *//*-*****************************************************************************************************/
264 :
265 : Image GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale ) const;
266 : Image GetImageFromURL( const OUString& aURL, bool bBig ) const;
267 :
268 :
269 : // private methods
270 :
271 :
272 : /*-****************************************************************************************************
273 : @short return a reference to a static mutex
274 : @descr These class is partially threadsafe (for de-/initialization only).
275 : All access methods are'nt safe!
276 : We create a static mutex only for one ime and use at different times.
277 : @return A reference to a static mutex member.
278 : *//*-*****************************************************************************************************/
279 :
280 : static ::osl::Mutex& GetOwnStaticMutex();
281 :
282 : /*-****************************************************************************************************
283 : @short return a reference to a static mutex
284 : @descr These class is partially threadsafe (for de-/initialization only).
285 : All access methods are'nt safe!
286 : We create a static mutex only for one ime and use at different times.
287 : @return A reference to a static mutex member.
288 : *//*-*****************************************************************************************************/
289 : DECL_STATIC_LINK( AddonsOptions, Notify, void* );
290 :
291 :
292 : // private member
293 :
294 :
295 : private:
296 :
297 : /*Attention
298 :
299 : Don't initialize these static member in these header!
300 : a) Double dfined symbols will be detected ...
301 : b) and unresolved externals exist at linking time.
302 : Do it in your source only.
303 : */
304 :
305 : static AddonsOptions_Impl* m_pDataContainer ;
306 : static sal_Int32 m_nRefCount ;
307 :
308 : }; // class SvtMenuOptions
309 :
310 : }
311 :
312 : #endif // INCLUDED_FRAMEWORK_ADDONSOPTIONS_HXX
313 :
314 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|