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