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_SVTOOLS_HISTORYOPTIONS_HXX 24 #define INCLUDED_SVTOOLS_HISTORYOPTIONS_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/beans/PropertyValue.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 47 #define HISTORY_PROPERTYNAME_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL" )) 48 #define HISTORY_PROPERTYNAME_FILTER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Filter" )) 49 #define HISTORY_PROPERTYNAME_TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title" )) 50 #define HISTORY_PROPERTYNAME_PASSWORD ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Password" )) 51 52 /*-************************************************************************************************************//** 53 @descr You can use these enum values to specify right history if you call our interface methods. 54 *//*-*************************************************************************************************************/ 55 56 enum EHistoryType 57 { 58 ePICKLIST = 0, 59 eHISTORY = 1, 60 eHELPBOOKMARKS = 2 61 }; 62 63 //_________________________________________________________________________________________________________________ 64 // forward declarations 65 //_________________________________________________________________________________________________________________ 66 67 /*-************************************************************************************************************//** 68 @short forward declaration to our private date container implementation 69 @descr We use these class as internal member to support small memory requirements. 70 You can create the container if it is necessary. The class which use these mechanism 71 is faster and smaller then a complete implementation! 72 *//*-*************************************************************************************************************/ 73 74 class SvtHistoryOptions_Impl; 75 76 //_________________________________________________________________________________________________________________ 77 // declarations 78 //_________________________________________________________________________________________________________________ 79 80 /*-************************************************************************************************************//** 81 @short collect informations about history features 82 @descr - 83 84 @implements - 85 @base - 86 87 @devstatus ready to use 88 *//*-*************************************************************************************************************/ 89 90 class UNOTOOLS_DLLPUBLIC SvtHistoryOptions: public utl::detail::Options 91 { 92 //------------------------------------------------------------------------------------------------------------- 93 // public methods 94 //------------------------------------------------------------------------------------------------------------- 95 96 public: 97 98 //--------------------------------------------------------------------------------------------------------- 99 // constructor / destructor 100 //--------------------------------------------------------------------------------------------------------- 101 102 /*-****************************************************************************************************//** 103 @short standard constructor and destructor 104 @descr This will initialize an instance with default values. 105 We implement these class with a refcount mechanism! Every instance of this class increase it 106 at create and decrease it at delete time - but all instances use the same data container! 107 He is implemented as a static member ... 108 109 @seealso member m_nRefCount 110 @seealso member m_pDataContainer 111 112 @param - 113 @return - 114 115 @onerror - 116 *//*-*****************************************************************************************************/ 117 118 SvtHistoryOptions(); 119 virtual ~SvtHistoryOptions(); 120 121 //--------------------------------------------------------------------------------------------------------- 122 // interface 123 //--------------------------------------------------------------------------------------------------------- 124 125 /*-****************************************************************************************************//** 126 @short interface methods to get and set value of config key "org.openoffice.Office.Common/History/..." 127 @descr key "PickList" : The last used documents displayed in the file menu. 128 key "History" : The last opened documents general. 129 *//*-*****************************************************************************************************/ 130 131 /*-****************************************************************************************************//** 132 @short set/get max size of specified history 133 @descr Call this methods to get information about max. size of specified list. 134 These value lay down the max count of items in these history. If a new one 135 is add to it the oldest one is deleted automatically! 136 137 @seealso - 138 139 @param "eHistory" select right history. 140 @param "nSize" is the new max size of specified list. If new size smaller then the old one 141 some oldest entries will be destroyed automatically! 142 @return Current max size of specified list. 143 144 @onerror - 145 *//*-*****************************************************************************************************/ 146 147 sal_uInt32 GetSize( EHistoryType eHistory ) const ; 148 void SetSize( EHistoryType eHistory, sal_uInt32 nSize ) ; 149 150 /*-****************************************************************************************************//** 151 @short clear complete sepcified list 152 @descr Call this methods to clear the whole list. After that GetItemCount() will return 0 ... 153 but GetSize() will return the old value! 154 155 @seealso - 156 157 @param "eHistory" select right history. 158 @return - 159 160 @onerror - 161 *//*-*****************************************************************************************************/ 162 163 void Clear( EHistoryType eHistory ); 164 165 /*-****************************************************************************************************//** 166 @short return complete sepcified list 167 @descr If you will show the whole list call this method to get it completly. 168 169 @seealso - 170 171 @param "eHistory" select right history. 172 @return A list of history items is returned. 173 174 @onerror - 175 *//*-*****************************************************************************************************/ 176 177 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > GetList( EHistoryType eHistory ) const ; 178 179 /*-****************************************************************************************************//** 180 @short append a new item to specified list 181 @descr You can append items to a list only - removing isn't allowed for a special item! 182 The oldest entry is deleted automatically if max size arrived or you can call Clear() ... 183 It exist two different overload methods to do this. 184 One for user which have an complete history item and another one for uncompletly data sets! 185 186 @seealso method SetSize() 187 @seealso method Clear() 188 189 @param "eHistory" select right history. 190 @param "sURL" URL to save in history 191 @param "sFilter" filter name to save in history 192 @param "sTitle" document title to save in history 193 @param "sPassword" password to save in history 194 @return - 195 196 @onerror - 197 *//*-*****************************************************************************************************/ 198 199 void AppendItem( EHistoryType eHistory , 200 const ::rtl::OUString& sURL , 201 const ::rtl::OUString& sFilter , 202 const ::rtl::OUString& sTitle , 203 const ::rtl::OUString& sPassword ); 204 205 //------------------------------------------------------------------------------------------------------------- 206 // private methods 207 //------------------------------------------------------------------------------------------------------------- 208 209 private: 210 211 /*-****************************************************************************************************//** 212 @short return a reference to a static mutex 213 @descr Make these class threadsafe. 214 215 @seealso - 216 217 @param - 218 @return A reference to a static mutex member. 219 220 @onerror - 221 *//*-*****************************************************************************************************/ 222 223 UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); 224 225 //------------------------------------------------------------------------------------------------------------- 226 // private member 227 //------------------------------------------------------------------------------------------------------------- 228 229 private: 230 231 /*Attention 232 233 Don't initialize these static member in these header! 234 a) Double dfined symbols will be detected ... 235 b) and unresolved externals exist at linking time. 236 Do it in your source only. 237 */ 238 239 static SvtHistoryOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! 240 static sal_Int32 m_nRefCount ; /// internal ref count mechanism 241 242 }; // class SvtHistoryOptions 243 244 #endif // #ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX 245