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 24 #ifndef UUI_IAHNDL_HXX 25 #define UUI_IAHNDL_HXX 26 27 #include <vector> 28 29 #include "osl/mutex.hxx" 30 #include "rtl/ustring.hxx" 31 32 #include "com/sun/star/uno/Reference.hxx" 33 #include "com/sun/star/uno/Sequence.hxx" 34 35 #include "com/sun/star/beans/Optional.hpp" 36 #include "com/sun/star/task/InteractionClassification.hpp" 37 38 #include "tools/solar.h" // sal_uInt16 39 #include "tools/errcode.hxx" // ErrCode 40 #include "tools/rc.hxx" // Resource 41 #include "tools/wintypes.hxx" // WinBits 42 43 namespace com { namespace sun { namespace star { 44 namespace awt { 45 class XWindow; 46 } 47 namespace embed { 48 class XStorage; 49 } 50 namespace lang { 51 class XMultiServiceFactory; 52 } 53 namespace security { 54 struct DocumentSignatureInformation; 55 } 56 namespace task { 57 class FutureDocumentVersionProductUpdateRequest; 58 class XInteractionContinuation; 59 class XInteractionHandler; 60 class XInteractionRequest; 61 } 62 namespace ucb { 63 class NameClashResolveRequest; 64 } 65 } } } 66 67 #include <hash_map> 68 69 class Window; 70 71 //============================================================================ 72 struct InteractionHandlerData 73 { 74 /** The UNO service name to use to instanciate the content provider. 75 */ 76 rtl::OUString ServiceName; 77 InteractionHandlerDataInteractionHandlerData78 InteractionHandlerData() {}; InteractionHandlerDataInteractionHandlerData79 InteractionHandlerData(const rtl::OUString & rService) 80 : ServiceName( rService ){} 81 }; 82 83 typedef std::vector< InteractionHandlerData > InteractionHandlerDataList; 84 85 typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > Continuations; 86 87 typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > StringHashMap; 88 89 //============================================================================ 90 class UUIInteractionHelper 91 { 92 private: 93 mutable osl::Mutex m_aPropertyMutex; 94 ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory; 95 ::com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_aProperties; 96 StringHashMap m_aTypedCustomHandlers; 97 UUIInteractionHelper(UUIInteractionHelper &); // not implemented 98 void operator =(UUIInteractionHelper); // not implemented 99 100 public: 101 UUIInteractionHelper( 102 com::sun::star::uno::Reference< 103 com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory, 104 com::sun::star::uno::Sequence< 105 com::sun::star::uno::Any > const & rArguments) 106 SAL_THROW(()); 107 UUIInteractionHelper( 108 com::sun::star::uno::Reference< 109 com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory) 110 SAL_THROW(()); 111 112 ~UUIInteractionHelper() SAL_THROW(()); 113 114 bool 115 handleRequest( 116 com::sun::star::uno::Reference< 117 com::sun::star::task::XInteractionRequest > const & rRequest) 118 SAL_THROW((com::sun::star::uno::RuntimeException)); 119 120 com::sun::star::beans::Optional< rtl::OUString > 121 getStringFromRequest( 122 com::sun::star::uno::Reference< 123 com::sun::star::task::XInteractionRequest > const & rRequest) 124 SAL_THROW((com::sun::star::uno::RuntimeException)); 125 126 // Helper. 127 static ::rtl::OUString 128 replaceMessageWithArguments( 129 ::rtl::OUString aMessage, 130 std::vector< rtl::OUString > const & rArguments ); 131 132 private: 133 bool 134 handleRequest_impl( 135 com::sun::star::uno::Reference< 136 com::sun::star::task::XInteractionRequest > const & rRequest, 137 bool bObtainErrorStringOnly, 138 bool & bHasErrorString, 139 rtl::OUString & rErrorString) 140 SAL_THROW((com::sun::star::uno::RuntimeException)); 141 142 static long 143 handlerequest(void* pHandleData, void* pInteractionHandler); 144 145 com::sun::star::beans::Optional< rtl::OUString > 146 getStringFromRequest_impl( 147 com::sun::star::uno::Reference< 148 com::sun::star::task::XInteractionRequest > const & rRequest) 149 SAL_THROW((com::sun::star::uno::RuntimeException)); 150 151 static long 152 getstringfromrequest(void* pHandleData, void* pInteractionHandler); 153 154 Window * 155 getParentProperty() 156 SAL_THROW(()); 157 158 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> 159 getParentXWindow() const 160 SAL_THROW(()); 161 162 rtl::OUString 163 getContextProperty() 164 SAL_THROW(()); 165 166 com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > 167 getInteractionHandler() 168 SAL_THROW((com::sun::star::uno::RuntimeException)); 169 170 bool handleTypedHandlerImplementations( 171 ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & rRequest 172 ); 173 174 bool 175 tryOtherInteractionHandler( 176 com::sun::star::uno::Reference< 177 com::sun::star::task::XInteractionRequest > const & rRequest) 178 SAL_THROW((com::sun::star::uno::RuntimeException)); 179 180 void 181 getInteractionHandlerList(InteractionHandlerDataList &rdataList) 182 SAL_THROW((com::sun::star::uno::RuntimeException)); 183 184 static bool 185 isInformationalErrorMessageRequest( 186 com::sun::star::uno::Sequence< 187 com::sun::star::uno::Reference< 188 com::sun::star::task::XInteractionContinuation > > const & 189 rContinuations); 190 191 //===================================================================== 192 193 bool 194 handleInteractiveIOException( 195 com::sun::star::uno::Reference< 196 com::sun::star::task::XInteractionRequest > const & rRequest, 197 bool bObtainErrorStringOnly, 198 bool & bHasErrorString, 199 rtl::OUString & rErrorString) 200 SAL_THROW((com::sun::star::uno::RuntimeException)); 201 202 bool 203 handleAuthenticationRequest( 204 com::sun::star::uno::Reference< 205 com::sun::star::task::XInteractionRequest > const & rRequest) 206 SAL_THROW((com::sun::star::uno::RuntimeException)); 207 208 bool 209 handleCertificateValidationRequest( 210 com::sun::star::uno::Reference< 211 com::sun::star::task::XInteractionRequest > const & rRequest) 212 SAL_THROW((com::sun::star::uno::RuntimeException)); 213 214 void 215 handleNameClashResolveRequest( 216 com::sun::star::ucb::NameClashResolveRequest const & rRequest, 217 com::sun::star::uno::Sequence< 218 com::sun::star::uno::Reference< 219 com::sun::star::task::XInteractionContinuation > > const & 220 rContinuations) 221 SAL_THROW((com::sun::star::uno::RuntimeException)); 222 223 bool 224 handleMasterPasswordRequest( 225 com::sun::star::uno::Reference< 226 com::sun::star::task::XInteractionRequest > const & rRequest) 227 SAL_THROW((com::sun::star::uno::RuntimeException)); 228 229 bool 230 handlePasswordRequest( 231 com::sun::star::uno::Reference< 232 com::sun::star::task::XInteractionRequest > const & rRequest) 233 SAL_THROW((com::sun::star::uno::RuntimeException)); 234 235 bool 236 handleCookiesRequest( 237 com::sun::star::uno::Reference< 238 com::sun::star::task::XInteractionRequest > const & rRequest) 239 SAL_THROW((com::sun::star::uno::RuntimeException)); 240 241 bool 242 handleNoSuchFilterRequest( 243 com::sun::star::uno::Reference< 244 com::sun::star::task::XInteractionRequest > const & rRequest) 245 SAL_THROW((com::sun::star::uno::RuntimeException)); 246 247 bool 248 handleAmbigousFilterRequest( 249 com::sun::star::uno::Reference< 250 com::sun::star::task::XInteractionRequest > const & rRequest) 251 SAL_THROW((com::sun::star::uno::RuntimeException)); 252 253 bool 254 handleFilterOptionsRequest( 255 com::sun::star::uno::Reference< 256 com::sun::star::task::XInteractionRequest > const & rRequest) 257 SAL_THROW((com::sun::star::uno::RuntimeException)); 258 259 void 260 handleErrorHandlerRequest( 261 com::sun::star::task::InteractionClassification eClassification, 262 ErrCode nErrorCode, 263 std::vector< rtl::OUString > const & rArguments, 264 com::sun::star::uno::Sequence< 265 com::sun::star::uno::Reference< 266 com::sun::star::task::XInteractionContinuation > > const & 267 rContinuations, 268 bool bObtainErrorStringOnly, 269 bool & bHasErrorString, 270 rtl::OUString & rErrorString) 271 SAL_THROW((com::sun::star::uno::RuntimeException)); 272 273 void 274 handleGenericErrorRequest( 275 sal_Int32 nErrorCode, 276 com::sun::star::uno::Sequence< 277 com::sun::star::uno::Reference< 278 com::sun::star::task::XInteractionContinuation > > const & 279 rContinuations, 280 bool bObtainErrorStringOnly, 281 bool & bHasErrorString, 282 rtl::OUString & rErrorString) 283 SAL_THROW((com::sun::star::uno::RuntimeException)); 284 285 void 286 handleMacroConfirmRequest( 287 const ::rtl::OUString& aDocumentURL, 288 const ::com::sun::star::uno::Reference< 289 ::com::sun::star::embed::XStorage >& xZipStorage, 290 const ::rtl::OUString& aDocumentVersion, 291 const ::com::sun::star::uno::Sequence< 292 ::com::sun::star::security::DocumentSignatureInformation > 293 aSignInfo, 294 com::sun::star::uno::Sequence< 295 com::sun::star::uno::Reference< 296 com::sun::star::task::XInteractionContinuation > > const & 297 rContinuations) 298 SAL_THROW((com::sun::star::uno::RuntimeException)); 299 300 void 301 handleFutureDocumentVersionUpdateRequest( 302 const ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest& 303 _rRequest, 304 com::sun::star::uno::Sequence< 305 com::sun::star::uno::Reference< 306 com::sun::star::task::XInteractionContinuation > > const & 307 rContinuations) 308 SAL_THROW((com::sun::star::uno::RuntimeException)); 309 310 void 311 handleBrokenPackageRequest( 312 std::vector< rtl::OUString > const & rArguments, 313 ::com::sun::star::uno::Sequence< 314 ::com::sun::star::uno::Reference< 315 ::com::sun::star::task::XInteractionContinuation > > const & 316 rContinuations, 317 bool bObtainErrorStringOnly, 318 bool & bHasErrorString, 319 rtl::OUString & rErrorString) 320 SAL_THROW((::com::sun::star::uno::RuntimeException)); 321 322 bool handleLockedDocumentRequest( 323 com::sun::star::uno::Reference< 324 com::sun::star::task::XInteractionRequest > const & rRequest) 325 SAL_THROW((::com::sun::star::uno::RuntimeException)); 326 327 bool handleChangedByOthersRequest( 328 com::sun::star::uno::Reference< 329 com::sun::star::task::XInteractionRequest > const & rRequest) 330 SAL_THROW((::com::sun::star::uno::RuntimeException)); 331 332 bool handleLockFileIgnoreRequest( 333 com::sun::star::uno::Reference< 334 com::sun::star::task::XInteractionRequest > const & rRequest) 335 SAL_THROW((::com::sun::star::uno::RuntimeException)); 336 337 bool handleCustomRequest( 338 const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& i_rRequest, 339 const ::rtl::OUString& i_rServiceName 340 ) const; 341 }; 342 343 class ErrorResource: private Resource 344 { 345 public: 346 inline ErrorResource(ResId & rResId) SAL_THROW(()): Resource(rResId) {} 347 348 inline ~ErrorResource() SAL_THROW(()) { FreeResource(); } 349 350 bool getString(ErrCode nErrorCode, rtl::OUString * pString) const 351 SAL_THROW(()); 352 }; 353 354 /* 355 class InteractionRequest 356 { 357 public: 358 InteractionRequest( 359 com::sun::star::uno::Reference< 360 com::sun::star::task::XInteractionRequest > const & rRequest) 361 : m_aRequest( rRequest ) {} 362 363 virtual bool toString( rtl::OUString & rString ) = 0; 364 virtual bool handle( rtl::OUString & rString ) = 0; 365 366 private: 367 com::sun::star::uno::Reference< 368 com::sun::star::task::XInteractionRequest > m_aRequest; 369 }; 370 */ 371 372 #endif // UUI_IAHNDL_HXX 373