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