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