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