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 INCLUDED_unotools_CMDOPTIONS_HXX 28 #define INCLUDED_unotools_CMDOPTIONS_HXX 29 30 //_________________________________________________________________________________________________________________ 31 // includes 32 //_________________________________________________________________________________________________________________ 33 34 #include "unotools/unotoolsdllapi.h" 35 #include <sal/types.h> 36 #include <osl/mutex.hxx> 37 #include <com/sun/star/uno/Sequence.h> 38 #include <com/sun/star/frame/XFrame.hpp> 39 #include <rtl/ustring.hxx> 40 #include <unotools/options.hxx> 41 42 //_________________________________________________________________________________________________________________ 43 // types, enums, ... 44 //_________________________________________________________________________________________________________________ 45 46 /*-************************************************************************************************************//** 47 @descr The method GetList() returns a list of property values. 48 Use follow defines to seperate values by names. 49 *//*-*************************************************************************************************************/ 50 #define CMDOPTIONS_PROPERTYNAME_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CommandURL" )) 51 52 //_________________________________________________________________________________________________________________ 53 // forward declarations 54 //_________________________________________________________________________________________________________________ 55 56 /*-************************************************************************************************************//** 57 @short forward declaration to our private date container implementation 58 @descr We use these class as internal member to support small memory requirements. 59 You can create the container if it is neccessary. The class which use these mechanism 60 is faster and smaller then a complete implementation! 61 *//*-*************************************************************************************************************/ 62 63 class SvtCommandOptions_Impl; 64 65 //_________________________________________________________________________________________________________________ 66 // declarations 67 //_________________________________________________________________________________________________________________ 68 69 /*-************************************************************************************************************//** 70 @short collect informations about dynamic menus 71 @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard". 72 73 @implements - 74 @base - 75 76 @devstatus ready to use 77 *//*-*************************************************************************************************************/ 78 79 class UNOTOOLS_DLLPUBLIC SvtCommandOptions: public utl::detail::Options 80 { 81 friend class SvtCommandOptions_Impl; 82 83 //------------------------------------------------------------------------------------------------------------- 84 // public methods 85 //------------------------------------------------------------------------------------------------------------- 86 87 public: 88 89 enum CmdOption 90 { 91 CMDOPTION_DISABLED, 92 CMDOPTION_NONE 93 }; 94 95 //--------------------------------------------------------------------------------------------------------- 96 // constructor / destructor 97 //--------------------------------------------------------------------------------------------------------- 98 99 /*-****************************************************************************************************//** 100 @short standard constructor and destructor 101 @descr This will initialize an instance with default values. 102 We implement these class with a refcount mechanism! Every instance of this class increase it 103 at create and decrease it at delete time - but all instances use the same data container! 104 He is implemented as a static member ... 105 106 @seealso member m_nRefCount 107 @seealso member m_pDataContainer 108 109 @param - 110 @return - 111 112 @onerror - 113 *//*-*****************************************************************************************************/ 114 115 SvtCommandOptions(); 116 virtual ~SvtCommandOptions(); 117 118 //--------------------------------------------------------------------------------------------------------- 119 // interface 120 //--------------------------------------------------------------------------------------------------------- 121 122 /*-****************************************************************************************************//** 123 @short clear complete sepcified list 124 @descr Call this methods to clear the whole list. 125 To fill it again use AppendItem(). 126 127 @seealso - 128 129 @param "eMenu" select right menu to clear. 130 @return - 131 132 @onerror - 133 *//*-*****************************************************************************************************/ 134 135 void Clear( CmdOption eOption ); 136 137 /*-****************************************************************************************************//** 138 @short return complete specified list 139 @descr Call it to get all entries of an dynamic menu. 140 We return a list of all nodes with his names and properties. 141 142 @seealso - 143 144 @param "eOption" select the list to retrieve. 145 @return A list of command strings is returned. 146 147 @onerror We return an empty list. 148 *//*-*****************************************************************************************************/ 149 150 sal_Bool HasEntries( CmdOption eOption ) const; 151 152 /*-****************************************************************************************************//** 153 @short Lookup if a command URL is inside a given list 154 @descr Lookup if a command URL is inside a given lst 155 156 @seealso - 157 158 @param "eOption" select right command list 159 @param "aCommandURL" a command URL that is used for the look up 160 @return "sal_True" if the command is inside the list otherwise "sal_False" 161 162 @onerror - 163 *//*-*****************************************************************************************************/ 164 165 sal_Bool Lookup( CmdOption eOption, const ::rtl::OUString& aCommandURL ) const; 166 167 /*-****************************************************************************************************//** 168 @short return complete specified list 169 @descr Call it to get all entries of an dynamic menu. 170 We return a list of all nodes with his names and properties. 171 172 @seealso - 173 174 @param "eOption" select the list to retrieve. 175 @return A list of command strings is returned. 176 177 @onerror We return an empty list. 178 *//*-*****************************************************************************************************/ 179 180 ::com::sun::star::uno::Sequence< ::rtl::OUString > GetList( CmdOption eOption ) const; 181 182 /*-****************************************************************************************************//** 183 @short adds a new command to specified options list 184 @descr You can add a command to specified options list! 185 186 @seealso method Clear() 187 188 @param "eOption" specifies the command list 189 @param "sURL" URL for dispatch 190 @return - 191 192 @onerror - 193 *//*-*****************************************************************************************************/ 194 195 void AddCommand( CmdOption eOption, const ::rtl::OUString& sURL ); 196 197 /*-****************************************************************************************************//** 198 @short register an office frame, which must update its dispatches if 199 the underlying configuration was changed. 200 201 @descr To avoid using of "dead" frame objects or implementing 202 deregistration mechanism too, we use weak references to 203 the given frames. 204 205 @param "xFrame" points to the frame, which wish to be 206 notified, if configuration was changed. 207 @return - 208 209 @onerror - 210 *//*-*****************************************************************************************************/ 211 212 void EstablisFrameCallback(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame); 213 214 //------------------------------------------------------------------------------------------------------------- 215 // private methods 216 //------------------------------------------------------------------------------------------------------------- 217 218 private: 219 220 /*-****************************************************************************************************//** 221 @short return a reference to a static mutex 222 @descr These class is partially threadsafe (for de-/initialization only). 223 All access methods are'nt safe! 224 We create a static mutex only for one ime and use at different times. 225 226 @seealso - 227 228 @param - 229 @return A reference to a static mutex member. 230 231 @onerror - 232 *//*-*****************************************************************************************************/ 233 234 UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); 235 236 //------------------------------------------------------------------------------------------------------------- 237 // private member 238 //------------------------------------------------------------------------------------------------------------- 239 240 private: 241 242 /*Attention 243 244 Don't initialize these static member in these header! 245 a) Double dfined symbols will be detected ... 246 b) and unresolved externals exist at linking time. 247 Do it in your source only. 248 */ 249 250 static SvtCommandOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! 251 static sal_Int32 m_nRefCount ; /// internal ref count mechanism 252 253 }; // class SvtCmdOptions 254 255 #endif // #ifndef INCLUDED_unotools_CMDOPTIONS_HXX 256