1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: iahndl.cxx,v $
10 * $Revision: 1.67.22.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include "osl/diagnose.h"
36 #include "osl/conditn.hxx"
37 #include "rtl/digest.h"
38 #include "rtl/ustrbuf.hxx"
39 #include "com/sun/star/beans/PropertyValue.hpp"
40 #include "com/sun/star/beans/XPropertyAccess.hpp"
41 #include "com/sun/star/configuration/backend/MergeRecoveryRequest.hpp"
42 #include "com/sun/star/configuration/backend/StratumCreationException.hpp"
43 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
44 #include "com/sun/star/container/XContainerQuery.hpp"
45 #include "com/sun/star/container/XNameAccess.hpp"
46 #include "com/sun/star/container/XNameContainer.hpp"
47 #include "com/sun/star/document/BrokenPackageRequest.hpp"
48 #include "com/sun/star/document/FilterOptionsRequest.hpp"
49 #include "com/sun/star/document/NoSuchFilterRequest.hpp"
50 #include "com/sun/star/document/AmbigousFilterRequest.hpp"
51 #include "com/sun/star/document/LockedDocumentRequest.hpp"
52 #include "com/sun/star/document/OwnLockOnDocumentRequest.hpp"
53 #include "com/sun/star/document/LockedOnSavingRequest.hpp"
54 #include "com/sun/star/document/ChangedByOthersRequest.hpp"
55 #include "com/sun/star/document/LockFileIgnoreRequest.hpp"
56 #include "com/sun/star/document/XImporter.hpp"
57 #include "com/sun/star/document/XInteractionFilterOptions.hpp"
58 #include "com/sun/star/document/XInteractionFilterSelect.hpp"
59 #include "com/sun/star/java/WrongJavaVersionException.hpp"
60 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
61 #include "com/sun/star/script/ModuleSizeExceededRequest.hpp"
62 #include "com/sun/star/sync2/BadPartnershipException.hpp"
63 #include "com/sun/star/task/XInteractionHandler.hpp"
64 #include "com/sun/star/task/XInteractionHandler2.hpp"
65 #include "com/sun/star/task/DocumentPasswordRequest.hpp"
66 #include "com/sun/star/task/DocumentMSPasswordRequest.hpp"
67 #include "com/sun/star/task/ErrorCodeIOException.hpp"
68 #include "com/sun/star/task/ErrorCodeRequest.hpp"
69 #include "com/sun/star/task/MasterPasswordRequest.hpp"
70 #include "com/sun/star/task/NoMasterException.hpp"
71 #include "com/sun/star/task/XInteractionAbort.hpp"
72 #include "com/sun/star/task/XInteractionApprove.hpp"
73 #include "com/sun/star/task/XInteractionDisapprove.hpp"
74 #include "com/sun/star/task/XInteractionPassword.hpp"
75 #include "com/sun/star/task/XInteractionRequest.hpp"
76 #include "com/sun/star/task/XInteractionRetry.hpp"
77 #include "com/sun/star/task/XPasswordContainer.hpp"
78 #include "com/sun/star/task/XInteractionAskLater.hpp"
79 #include "com/sun/star/ucb/AuthenticationRequest.hpp"
80 #include "com/sun/star/ucb/CertificateValidationRequest.hpp"
81 #include "com/sun/star/ucb/HandleCookiesRequest.hpp"
82 #include "com/sun/star/ucb/InteractiveAppException.hpp"
83 #include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
84 #include "com/sun/star/ucb/InteractiveCHAOSException.hpp"
85 #include "com/sun/star/ucb/InteractiveNetworkConnectException.hpp"
86 #include "com/sun/star/ucb/InteractiveNetworkException.hpp"
87 #include "com/sun/star/ucb/InteractiveNetworkGeneralException.hpp"
88 #include "com/sun/star/ucb/InteractiveNetworkOffLineException.hpp"
89 #include "com/sun/star/ucb/InteractiveNetworkReadException.hpp"
90 #include "com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp"
91 #include "com/sun/star/ucb/InteractiveNetworkWriteException.hpp"
92 #include "com/sun/star/ucb/InteractiveWrongMediumException.hpp"
93 #include "com/sun/star/ucb/IOErrorCode.hpp"
94 #include "com/sun/star/ucb/NameClashException.hpp"
95 #include "com/sun/star/ucb/NameClashResolveRequest.hpp"
96 #include "com/sun/star/ucb/UnsupportedNameClashException.hpp"
97 #include "com/sun/star/ucb/XInteractionCookieHandling.hpp"
98 #include "com/sun/star/ucb/XInteractionReplaceExistingData.hpp"
99 #include "com/sun/star/ucb/XInteractionSupplyAuthentication.hpp"
100 #include "com/sun/star/ucb/XInteractionSupplyName.hpp"
101 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
102 #include "com/sun/star/uno/RuntimeException.hpp"
103 #include "com/sun/star/xforms/InvalidDataOnSubmitException.hpp"
104 #include <com/sun/star/security/CertificateValidity.hpp>
107 #include "vos/mutex.hxx"
108 #include "tools/rcid.h"
109 #include "vcl/svapp.hxx"
110 #include "svtools/svtools.hrc"
111 #include "svtools/loginerr.hxx"
112 #include "svtools/httpcook.hxx"
113 #include "svtools/sfxecode.hxx"
114 #include "toolkit/helper/vclunohelper.hxx"
115 #include "comphelper/sequenceashashmap.hxx"
116 #include "unotools/configmgr.hxx"
119 #include "cookiedg.hxx"
120 #include "secmacrowarnings.hxx"
121 #include "masterpasscrtdlg.hxx"
122 #include "masterpassworddlg.hxx"
123 #include "logindlg.hxx"
124 #include "passcrtdlg.hxx"
125 #include "passworddlg.hxx"
126 #include "unknownauthdlg.hxx"
127 #include "sslwarndlg.hxx"
128 #include "openlocked.hxx"
129 #include "newerverwarn.hxx"
130 #include "alreadyopen.hxx"
131 #include "filechanged.hxx"
132 #include "trylater.hxx"
133 #include "lockfailed.hxx"
134 #include <comphelper/processfactory.hxx>
135 #include <svtools/zforlist.hxx>
136 using namespace com::sun
;
138 namespace csss
= ::com::sun::star::security
;
140 using ::com::sun::star::uno::Sequence
;
141 using ::com::sun::star::uno::UNO_QUERY
;
142 using ::com::sun::star::uno::Reference
;
143 using ::com::sun::star::task::XInteractionContinuation
;
144 using ::com::sun::star::task::XInteractionAbort
;
145 using ::com::sun::star::task::XInteractionApprove
;
146 using ::com::sun::star::task::XInteractionAskLater
;
147 using ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest
;
150 #define CONFIG_INTERACTIONHANDLERS_KEY "/org.openoffice.ucb.InteractionHandler/InteractionHandlers"
154 class CookieList
: public List
157 ~CookieList() SAL_THROW(());
160 CookieList::~CookieList() SAL_THROW(())
163 delete static_cast< CntHTTPCookie
* >(Remove(Count() - 1));
166 class ErrorResource
: private Resource
169 inline ErrorResource(ResId
& rResId
) SAL_THROW(()): Resource(rResId
) {}
171 inline ~ErrorResource() SAL_THROW(()) { FreeResource(); }
173 bool getString(ErrCode nErrorCode
, rtl::OUString
* pString
) const
177 bool ErrorResource::getString(ErrCode nErrorCode
, rtl::OUString
* pString
)
180 OSL_ENSURE(pString
, "specification violation");
181 ResId
aResId(static_cast< USHORT
>(nErrorCode
& ERRCODE_RES_MASK
), *m_pResMgr
);
182 aResId
.SetRT(RSC_STRING
);
183 if (!IsAvailableRes(aResId
))
185 aResId
.SetAutoRelease(false);
186 *pString
= UniString(aResId
);
187 m_pResMgr
->PopContext();
193 star::uno::Sequence
< star::uno::Reference
<
194 star::task::XInteractionContinuation
> > const & rContinuations
,
195 star::uno::Reference
< star::task::XInteractionApprove
> * pApprove
,
196 star::uno::Reference
< star::task::XInteractionDisapprove
> * pDisapprove
,
197 star::uno::Reference
< star::task::XInteractionRetry
> * pRetry
,
198 star::uno::Reference
< star::task::XInteractionAbort
> * pAbort
,
199 star::uno::Reference
< star::ucb::XInteractionSupplyAuthentication
> *
200 pSupplyAuthentication
,
201 star::uno::Reference
< star::task::XInteractionPassword
> * pPassword
,
202 star::uno::Reference
< star::ucb::XInteractionSupplyName
> *
204 star::uno::Reference
< star::ucb::XInteractionReplaceExistingData
> *
205 pReplaceExistingData
)
206 SAL_THROW((star::uno::RuntimeException
))
208 for (sal_Int32 i
= 0; i
< rContinuations
.getLength(); ++i
)
210 if (pApprove
&& !pApprove
->is())
213 = star::uno::Reference
< star::task::XInteractionApprove
>(
214 rContinuations
[i
], star::uno::UNO_QUERY
);
218 if (pDisapprove
&& !pDisapprove
->is())
221 = star::uno::Reference
< star::task::XInteractionDisapprove
>(
222 rContinuations
[i
], star::uno::UNO_QUERY
);
223 if (pDisapprove
->is())
226 if (pRetry
&& !pRetry
->is())
228 *pRetry
= star::uno::Reference
< star::task::XInteractionRetry
>(
229 rContinuations
[i
], star::uno::UNO_QUERY
);
233 if (pAbort
&& !pAbort
->is())
235 *pAbort
= star::uno::Reference
< star::task::XInteractionAbort
>(
236 rContinuations
[i
], star::uno::UNO_QUERY
);
240 if (pSupplyAuthentication
&& !pSupplyAuthentication
->is())
242 *pSupplyAuthentication
243 = star::uno::Reference
<
244 star::ucb::XInteractionSupplyAuthentication
>(
245 rContinuations
[i
], star::uno::UNO_QUERY
);
246 if (pSupplyAuthentication
->is())
249 if (pPassword
&& !pPassword
->is())
252 = star::uno::Reference
< star::task::XInteractionPassword
>(
253 rContinuations
[i
], star::uno::UNO_QUERY
);
257 if (pSupplyName
&& !pSupplyName
->is())
260 = star::uno::Reference
< star::ucb::XInteractionSupplyName
>(
261 rContinuations
[i
], star::uno::UNO_QUERY
);
262 if (pSupplyName
->is())
265 if (pReplaceExistingData
&& !pReplaceExistingData
->is())
267 *pReplaceExistingData
268 = star::uno::Reference
<
269 star::ucb::XInteractionReplaceExistingData
>(
270 rContinuations
[i
], star::uno::UNO_QUERY
);
271 if (pReplaceExistingData
->is())
277 ::rtl::OUString
replaceMessageWithArguments(
278 ::rtl::OUString aMessage
,
279 std::vector
< rtl::OUString
> const & rArguments
)
281 for (sal_Int32 i
= 0;;)
284 indexOf(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$(ARG")), i
);
287 if (aMessage
.getLength() - i
>= RTL_CONSTASCII_LENGTH("$(ARGx)")
288 && aMessage
.getStr()[i
+ RTL_CONSTASCII_LENGTH("$(ARGx")] == ')')
291 = aMessage
.getStr()[i
+ RTL_CONSTASCII_LENGTH("$(ARG")];
292 if (c
>= '1' && c
<= '2')
294 std::vector
< rtl::OUString
>::size_type nIndex
295 = static_cast< std::vector
< rtl::OUString
>::size_type
>(
297 if (nIndex
< rArguments
.size())
300 = aMessage
.replaceAt(i
,
301 RTL_CONSTASCII_LENGTH("$(ARGx)"),
303 i
+= rArguments
[nIndex
].getLength();
316 getStringRequestArgument(star::uno::Sequence
< star::uno::Any
> const &
318 rtl::OUString
const & rKey
,
319 rtl::OUString
* pValue
)
322 for (sal_Int32 i
= 0; i
< rArguments
.getLength(); ++i
)
324 star::beans::PropertyValue aProperty
;
325 if ((rArguments
[i
] >>= aProperty
) && aProperty
.Name
== rKey
)
327 rtl::OUString aValue
;
328 if (aProperty
.Value
>>= aValue
)
340 getBoolRequestArgument(star::uno::Sequence
< star::uno::Any
> const &
342 rtl::OUString
const & rKey
,
346 for (sal_Int32 i
= 0; i
< rArguments
.getLength(); ++i
)
348 star::beans::PropertyValue aProperty
;
349 if ((rArguments
[i
] >>= aProperty
) && aProperty
.Name
== rKey
)
351 sal_Bool bValue
= sal_Bool();
352 if (aProperty
.Value
>>= bValue
)
364 getResourceNameRequestArgument(star::uno::Sequence
< star::uno::Any
> const &
366 rtl::OUString
* pValue
)
369 if (!getStringRequestArgument(rArguments
,
370 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
374 // Use the resource name only for file URLs, to avoid confusion:
375 //TODO! work with ucp locality concept instead of hardcoded "file"?
377 && pValue
->matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM(
379 getStringRequestArgument(rArguments
,
380 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
386 bool isInformationalErrorMessageRequest(
387 star::uno::Sequence
< star::uno::Reference
<
388 star::task::XInteractionContinuation
> > const &
391 // Only requests with a single continuation (user has no choice, request
392 // is just informational)
393 if (rContinuations
.getLength() != 1 )
396 // user can only abort or approve, all other continuations are not
397 // considered to be informational.
398 star::uno::Reference
< star::task::XInteractionApprove
> xApprove(
399 rContinuations
[0], star::uno::UNO_QUERY
);
403 star::uno::Reference
< star::task::XInteractionAbort
> xAbort(
404 rContinuations
[0], star::uno::UNO_QUERY
);
413 UUIInteractionHelper::UUIInteractionHelper(
414 star::uno::Reference
< star::lang::XMultiServiceFactory
> const &
416 star::uno::Sequence
< star::uno::Any
> const & rArguments
)
418 m_xServiceFactory(rServiceFactory
),
419 m_aProperties(rArguments
)
423 UUIInteractionHelper::UUIInteractionHelper(
424 star::uno::Reference
< star::lang::XMultiServiceFactory
> const &
427 m_xServiceFactory(rServiceFactory
)
431 UUIInteractionHelper::~UUIInteractionHelper()
435 class HandleData
: public osl::Condition
{
438 star::uno::Reference
< star::task::XInteractionRequest
> const &
444 star::uno::Reference
< star::task::XInteractionRequest
> m_rRequest
;
445 star::beans::Optional
< rtl::OUString
> m_aResult
;
448 long UUIInteractionHelper::handlerequest(
449 void* pHandleData
,void* pInteractionHelper
)
451 HandleData
* pHND
= (HandleData
*) pHandleData
;
452 UUIInteractionHelper
* pUUI
= (UUIInteractionHelper
*) pInteractionHelper
;
453 pUUI
->handle_impl(pHND
->m_rRequest
);
460 UUIInteractionHelper::handleRequest(
461 star::uno::Reference
< star::task::XInteractionRequest
> const & rRequest
)
462 throw (star::uno::RuntimeException
)
464 Application
* pApp
= 0;
466 // be aware,it is the same type
467 ((oslThreadIdentifier
) Application::GetMainThreadIdentifier())
468 != osl_getThreadIdentifier(NULL
)
473 // we are not in the main thread, let it handle that stuff
474 HandleData
aHD(rRequest
);
475 Link
aLink(&aHD
,handlerequest
);
476 pApp
->PostUserEvent(aLink
,this);
477 ULONG locks
= Application::ReleaseSolarMutex();
479 Application::AcquireSolarMutex(locks
);
482 handle_impl(rRequest
);
485 long UUIInteractionHelper::getstringfromrequest(
486 void* pHandleData
,void* pInteractionHelper
)
488 HandleData
* pHND
= (HandleData
*) pHandleData
;
489 UUIInteractionHelper
* pUUI
= (UUIInteractionHelper
*) pInteractionHelper
;
490 pHND
->m_aResult
= pUUI
->getStringFromRequest_impl(pHND
->m_rRequest
);
495 star::beans::Optional
< rtl::OUString
>
496 UUIInteractionHelper::getStringFromRequest_impl(
497 star::uno::Reference
< star::task::XInteractionRequest
> const & rRequest
)
498 throw (star::uno::RuntimeException
)
500 bool bSuccess
= false;
501 rtl::OUString aMessage
;
502 handleMessageboxRequests(rRequest
, true, bSuccess
, aMessage
);
505 handleErrorHandlerRequests(rRequest
, true, bSuccess
, aMessage
);
507 return star::beans::Optional
< rtl::OUString
>(bSuccess
, aMessage
);
510 star::beans::Optional
< rtl::OUString
>
511 UUIInteractionHelper::getStringFromRequest(
512 star::uno::Reference
< star::task::XInteractionRequest
> const & rRequest
)
513 throw (star::uno::RuntimeException
)
515 Application
* pApp
= 0;
517 // be aware,it is the same type
518 ((oslThreadIdentifier
) Application::GetMainThreadIdentifier())
519 != osl_getThreadIdentifier(NULL
)
524 // we are not in the main thread, let it handle that stuff
525 HandleData
aHD(rRequest
);
526 Link
aLink(&aHD
,getstringfromrequest
);
527 pApp
->PostUserEvent(aLink
,this);
528 ULONG locks
= Application::ReleaseSolarMutex();
530 Application::AcquireSolarMutex(locks
);
531 return aHD
.m_aResult
;
534 return getStringFromRequest_impl(rRequest
);
537 bool UUIInteractionHelper::handleMessageboxRequests(
538 star::uno::Reference
< star::task::XInteractionRequest
> const & rRequest
,
539 bool bObtainErrorStringOnly
,
540 bool & bHasErrorString
,
541 rtl::OUString
& rErrorString
)
543 star::uno::Any
aAnyRequest(rRequest
->getRequest());
545 star::script::ModuleSizeExceededRequest aModSizeException
;
546 if (aAnyRequest
>>= aModSizeException
)
548 ErrCode nErrorCode
= ERRCODE_UUI_IO_MODULESIZEEXCEEDED
;
549 std::vector
< rtl::OUString
> aArguments
;
550 star::uno::Sequence
< rtl::OUString
> sModules
551 = aModSizeException
.Names
;
552 if ( sModules
.getLength() )
555 for ( sal_Int32 index
=0; index
< sModules
.getLength(); ++index
)
558 aName
= aName
+ rtl::OUString( ',' ) + sModules
[index
];
560 aName
= sModules
[index
]; // 1st name
562 aArguments
.push_back( aName
);
564 handleErrorRequest( star::task::InteractionClassification_WARNING
,
567 rRequest
->getContinuations(),
568 bObtainErrorStringOnly
,
574 star::ucb::NameClashException aNCException
;
575 if (aAnyRequest
>>= aNCException
)
577 ErrCode nErrorCode
= ERRCODE_UUI_IO_TARGETALREADYEXISTS
;
578 std::vector
< rtl::OUString
> aArguments
;
580 if( aNCException
.Name
.getLength() )
582 nErrorCode
= ERRCODE_UUI_IO_ALREADYEXISTS
;
583 aArguments
.push_back( aNCException
.Name
);
586 handleErrorRequest( aNCException
.Classification
,
589 rRequest
->getContinuations(),
590 bObtainErrorStringOnly
,
596 star::ucb::UnsupportedNameClashException aUORequest
;
597 if (aAnyRequest
>>= aUORequest
)
599 ErrCode nErrorCode
= ERRCODE_UUI_IO_UNSUPPORTEDOVERWRITE
;
600 std::vector
< rtl::OUString
> aArguments
;
602 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
603 star::uno::Reference
<
604 star::task::XInteractionDisapprove
> xDisapprove
;
606 rRequest
->getContinuations(),
607 &xApprove
, &xDisapprove
, 0, 0, 0, 0, 0, 0);
609 if( xApprove
.is() && xDisapprove
.is() )
611 handleErrorRequest( star::task::InteractionClassification_QUERY
,
614 rRequest
->getContinuations(),
615 bObtainErrorStringOnly
,
622 star::document::BrokenPackageRequest aBrokenPackageRequest
;
623 if (aAnyRequest
>>= aBrokenPackageRequest
)
625 std::vector
< rtl::OUString
> aArguments
;
627 if( aBrokenPackageRequest
.aName
.getLength() )
628 aArguments
.push_back( aBrokenPackageRequest
.aName
);
630 handleBrokenPackageRequest( aArguments
,
631 rRequest
->getContinuations(),
632 bObtainErrorStringOnly
,
638 star::ucb::InteractiveIOException aIoException
;
639 if (aAnyRequest
>>= aIoException
)
641 star::uno::Sequence
< star::uno::Any
> aRequestArguments
;
642 star::ucb::InteractiveAugmentedIOException aAugmentedIoException
;
643 if (aAnyRequest
>>= aAugmentedIoException
)
644 aRequestArguments
= aAugmentedIoException
.Arguments
;
647 std::vector
< rtl::OUString
> aArguments
;
649 aErrorCode
[star::ucb::IOErrorCode_WRONG_VERSION
+ 1][2]
650 = { { ERRCODE_IO_ABORT
, ERRCODE_UUI_IO_ABORT
}, // ABORT
651 { ERRCODE_IO_ACCESSDENIED
, ERRCODE_UUI_IO_ACCESSDENIED
},
653 { ERRCODE_IO_ALREADYEXISTS
,
654 ERRCODE_UUI_IO_ALREADYEXISTS
}, // ALREADY_EXISTING
655 { ERRCODE_IO_BADCRC
, ERRCODE_UUI_IO_BADCRC
}, // BAD_CRC
656 { ERRCODE_IO_CANTCREATE
, ERRCODE_UUI_IO_CANTCREATE
},
658 { ERRCODE_IO_CANTREAD
, ERRCODE_UUI_IO_CANTREAD
},
660 { ERRCODE_IO_CANTSEEK
, ERRCODE_UUI_IO_CANTSEEK
},
662 { ERRCODE_IO_CANTTELL
, ERRCODE_UUI_IO_CANTTELL
},
664 { ERRCODE_IO_CANTWRITE
, ERRCODE_UUI_IO_CANTWRITE
},
666 { ERRCODE_IO_CURRENTDIR
, ERRCODE_UUI_IO_CURRENTDIR
},
668 { ERRCODE_IO_DEVICENOTREADY
, ERRCODE_UUI_IO_NOTREADY
},
670 { ERRCODE_IO_NOTSAMEDEVICE
,
671 ERRCODE_UUI_IO_NOTSAMEDEVICE
}, // DIFFERENT_DEVICES
672 { ERRCODE_IO_GENERAL
, ERRCODE_UUI_IO_GENERAL
}, // GENERAL
673 { ERRCODE_IO_INVALIDACCESS
,
674 ERRCODE_UUI_IO_INVALIDACCESS
}, // INVALID_ACCESS
675 { ERRCODE_IO_INVALIDCHAR
, ERRCODE_UUI_IO_INVALIDCHAR
},
677 { ERRCODE_IO_INVALIDDEVICE
,
678 ERRCODE_UUI_IO_INVALIDDEVICE
}, // INVALID_DEVICE
679 { ERRCODE_IO_INVALIDLENGTH
,
680 ERRCODE_UUI_IO_INVALIDLENGTH
}, // INVALID_LENGTH
681 { ERRCODE_IO_INVALIDPARAMETER
,
682 ERRCODE_UUI_IO_INVALIDPARAMETER
}, // INVALID_PARAMETER
683 { ERRCODE_IO_ISWILDCARD
, ERRCODE_UUI_IO_ISWILDCARD
},
685 { ERRCODE_IO_LOCKVIOLATION
,
686 ERRCODE_UUI_IO_LOCKVIOLATION
}, // LOCKING_VIOLATION
687 { ERRCODE_IO_MISPLACEDCHAR
,
688 ERRCODE_UUI_IO_MISPLACEDCHAR
}, // MISPLACED_CHARACTER
689 { ERRCODE_IO_NAMETOOLONG
, ERRCODE_UUI_IO_NAMETOOLONG
},
691 { ERRCODE_IO_NOTEXISTS
, ERRCODE_UUI_IO_NOTEXISTS
},
693 { ERRCODE_IO_NOTEXISTSPATH
,
694 ERRCODE_UUI_IO_NOTEXISTSPATH
}, // NOT_EXISTING_PATH
695 { ERRCODE_IO_NOTSUPPORTED
, ERRCODE_UUI_IO_NOTSUPPORTED
},
697 { ERRCODE_IO_NOTADIRECTORY
,
698 ERRCODE_UUI_IO_NOTADIRECTORY
}, // NO_DIRECTORY
699 { ERRCODE_IO_NOTAFILE
, ERRCODE_UUI_IO_NOTAFILE
},
701 { ERRCODE_IO_OUTOFSPACE
, ERRCODE_UUI_IO_OUTOFSPACE
},
703 { ERRCODE_IO_TOOMANYOPENFILES
,
704 ERRCODE_UUI_IO_TOOMANYOPENFILES
},
705 // OUT_OF_FILE_HANDLES
706 { ERRCODE_IO_OUTOFMEMORY
, ERRCODE_UUI_IO_OUTOFMEMORY
},
708 { ERRCODE_IO_PENDING
, ERRCODE_UUI_IO_PENDING
}, // PENDING
709 { ERRCODE_IO_RECURSIVE
, ERRCODE_UUI_IO_RECURSIVE
},
711 { ERRCODE_IO_UNKNOWN
, ERRCODE_UUI_IO_UNKNOWN
}, // UNKNOWN
712 { ERRCODE_IO_WRITEPROTECTED
,
713 ERRCODE_UUI_IO_WRITEPROTECTED
}, // WRITE_PROTECTED
714 { ERRCODE_IO_WRONGFORMAT
, ERRCODE_UUI_IO_WRONGFORMAT
},
716 { ERRCODE_IO_WRONGVERSION
,
717 ERRCODE_UUI_IO_WRONGVERSION
} }; // WRONG_VERSION
718 switch (aIoException
.Code
)
720 case star::ucb::IOErrorCode_CANT_CREATE
:
722 rtl::OUString aArgFolder
;
723 if (getStringRequestArgument(
725 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
729 rtl::OUString aArgUri
;
730 if (getResourceNameRequestArgument(aRequestArguments
,
733 nErrorCode
= ERRCODE_UUI_IO_CANTCREATE
;
734 aArguments
.reserve(2);
735 aArguments
.push_back(aArgUri
);
736 aArguments
.push_back(aArgFolder
);
740 nErrorCode
= ERRCODE_UUI_IO_CANTCREATE_NONAME
;
741 aArguments
.push_back(aArgFolder
);
745 nErrorCode
= aErrorCode
[aIoException
.Code
][0];
749 case star::ucb::IOErrorCode_DEVICE_NOT_READY
:
751 rtl::OUString aArgUri
;
752 if (getResourceNameRequestArgument(aRequestArguments
,
755 rtl::OUString aResourceType
;
756 getStringRequestArgument(
758 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
761 bool bRemovable
= false;
762 getBoolRequestArgument(aRequestArguments
,
764 RTL_CONSTASCII_USTRINGPARAM(
768 = aResourceType
.equalsAsciiL(
769 RTL_CONSTASCII_STRINGPARAM("volume"))
771 ? ERRCODE_UUI_IO_NOTREADY_VOLUME_REMOVABLE
772 : ERRCODE_UUI_IO_NOTREADY_VOLUME
)
774 ? ERRCODE_UUI_IO_NOTREADY_REMOVABLE
775 : ERRCODE_UUI_IO_NOTREADY
);
776 aArguments
.push_back(aArgUri
);
779 nErrorCode
= aErrorCode
[aIoException
.Code
][0];
783 case star::ucb::IOErrorCode_DIFFERENT_DEVICES
:
785 rtl::OUString aArgVolume
;
786 rtl::OUString aArgOtherVolume
;
787 if (getStringRequestArgument(
789 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
792 && getStringRequestArgument(
794 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
798 nErrorCode
= aErrorCode
[aIoException
.Code
][1];
799 aArguments
.reserve(2);
800 aArguments
.push_back(aArgVolume
);
801 aArguments
.push_back(aArgOtherVolume
);
804 nErrorCode
= aErrorCode
[aIoException
.Code
][0];
808 case star::ucb::IOErrorCode_NOT_EXISTING
:
810 rtl::OUString aArgUri
;
811 if (getResourceNameRequestArgument(aRequestArguments
,
814 rtl::OUString aResourceType
;
815 getStringRequestArgument(
817 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
821 = aResourceType
.equalsAsciiL(
822 RTL_CONSTASCII_STRINGPARAM("volume"))
823 ? ERRCODE_UUI_IO_NOTEXISTS_VOLUME
824 : (aResourceType
.equalsAsciiL(
825 RTL_CONSTASCII_STRINGPARAM("folder"))
826 ? ERRCODE_UUI_IO_NOTEXISTS_FOLDER
827 : ERRCODE_UUI_IO_NOTEXISTS
);
828 aArguments
.push_back(aArgUri
);
831 nErrorCode
= aErrorCode
[aIoException
.Code
][0];
837 rtl::OUString aArgUri
;
838 if (getResourceNameRequestArgument(aRequestArguments
,
841 nErrorCode
= aErrorCode
[aIoException
.Code
][1];
842 aArguments
.push_back(aArgUri
);
845 nErrorCode
= aErrorCode
[aIoException
.Code
][0];
850 handleErrorRequest(aIoException
.Classification
,
853 rRequest
->getContinuations(),
854 bObtainErrorStringOnly
,
860 star::ucb::InteractiveAppException aAppException
;
861 if (aAnyRequest
>>= aAppException
)
863 std::vector
< rtl::OUString
> aArguments
;
864 handleErrorRequest( aAppException
.Classification
,
867 rRequest
->getContinuations(),
868 bObtainErrorStringOnly
,
874 star::ucb::InteractiveNetworkException aNetworkException
;
875 if (aAnyRequest
>>= aNetworkException
)
878 std::vector
< rtl::OUString
> aArguments
;
879 star::ucb::InteractiveNetworkOffLineException aOffLineException
;
880 star::ucb::InteractiveNetworkResolveNameException
881 aResolveNameException
;
882 star::ucb::InteractiveNetworkConnectException aConnectException
;
883 star::ucb::InteractiveNetworkReadException aReadException
;
884 star::ucb::InteractiveNetworkWriteException aWriteException
;
885 if (aAnyRequest
>>= aOffLineException
)
886 nErrorCode
= ERRCODE_INET_OFFLINE
;
887 else if (aAnyRequest
>>= aResolveNameException
)
889 nErrorCode
= ERRCODE_INET_NAME_RESOLVE
;
890 aArguments
.push_back(aResolveNameException
.Server
);
892 else if (aAnyRequest
>>= aConnectException
)
894 nErrorCode
= ERRCODE_INET_CONNECT
;
895 aArguments
.push_back(aConnectException
.Server
);
897 else if (aAnyRequest
>>= aReadException
)
899 nErrorCode
= ERRCODE_INET_READ
;
900 aArguments
.push_back(aReadException
.Diagnostic
);
902 else if (aAnyRequest
>>= aWriteException
)
904 nErrorCode
= ERRCODE_INET_WRITE
;
905 aArguments
.push_back(aWriteException
.Diagnostic
);
908 nErrorCode
= ERRCODE_INET_GENERAL
;
910 handleErrorRequest(aNetworkException
.Classification
,
913 rRequest
->getContinuations(),
914 bObtainErrorStringOnly
,
920 star::ucb::InteractiveCHAOSException aChaosException
;
921 if (aAnyRequest
>>= aChaosException
)
923 std::vector
< rtl::OUString
> aArguments
;
925 = std::min
< sal_Int32
>(aChaosException
.Arguments
.getLength(),
929 static_cast< std::vector
< rtl::OUString
>::size_type
>(
931 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
932 aArguments
.push_back(aChaosException
.Arguments
[i
]);
933 handleErrorRequest(aChaosException
.Classification
,
936 rRequest
->getContinuations(),
937 bObtainErrorStringOnly
,
943 star::ucb::InteractiveWrongMediumException aWrongMediumException
;
944 if (aAnyRequest
>>= aWrongMediumException
)
946 sal_Int32 nMedium
= 0;
947 aWrongMediumException
.Medium
>>= nMedium
;
948 std::vector
< rtl::OUString
> aArguments
;
949 aArguments
.push_back(UniString::CreateFromInt32(nMedium
+ 1));
950 handleErrorRequest(aWrongMediumException
.Classification
,
951 ERRCODE_UUI_WRONGMEDIUM
,
953 rRequest
->getContinuations(),
954 bObtainErrorStringOnly
,
960 star::java::WrongJavaVersionException aWrongJavaVersionException
;
961 if (aAnyRequest
>>= aWrongJavaVersionException
)
964 std::vector
< rtl::OUString
> aArguments
;
965 if (aWrongJavaVersionException
.DetectedVersion
.getLength() == 0)
966 if (aWrongJavaVersionException
.LowestSupportedVersion
.
969 nErrorCode
= ERRCODE_UUI_WRONGJAVA
;
972 nErrorCode
= ERRCODE_UUI_WRONGJAVA_MIN
;
973 aArguments
.push_back(aWrongJavaVersionException
.
974 LowestSupportedVersion
);
976 else if (aWrongJavaVersionException
.LowestSupportedVersion
.
980 nErrorCode
= ERRCODE_UUI_WRONGJAVA_VERSION
;
981 aArguments
.push_back(aWrongJavaVersionException
.
986 nErrorCode
= ERRCODE_UUI_WRONGJAVA_VERSION_MIN
;
987 aArguments
.reserve(2);
988 aArguments
.push_back(aWrongJavaVersionException
.
990 aArguments
.push_back(aWrongJavaVersionException
.
991 LowestSupportedVersion
);
993 handleErrorRequest(star::task::InteractionClassification_ERROR
,
996 rRequest
->getContinuations(),
997 bObtainErrorStringOnly
,
1003 star::sync2::BadPartnershipException aBadPartnershipException
;
1004 if (aAnyRequest
>>= aBadPartnershipException
)
1007 std::vector
< rtl::OUString
> aArguments
;
1008 if (aBadPartnershipException
.Partnership
.getLength() == 0)
1009 nErrorCode
= ERRCODE_UUI_BADPARTNERSHIP
;
1012 nErrorCode
= ERRCODE_UUI_BADPARTNERSHIP_NAME
;
1013 aArguments
.push_back(aBadPartnershipException
.Partnership
);
1015 handleErrorRequest(star::task::InteractionClassification_ERROR
,
1018 rRequest
->getContinuations(),
1019 bObtainErrorStringOnly
,
1025 star::configuration::backend::MergeRecoveryRequest aMergeRecoveryRequest
;
1026 if (aAnyRequest
>>= aMergeRecoveryRequest
)
1028 ErrCode nErrorCode
= aMergeRecoveryRequest
.IsRemovalRequest
1029 ? ERRCODE_UUI_CONFIGURATION_BROKENDATA_WITHREMOVE
1030 : ERRCODE_UUI_CONFIGURATION_BROKENDATA_NOREMOVE
;
1032 std::vector
< rtl::OUString
> aArguments
;
1033 aArguments
.push_back(aMergeRecoveryRequest
.ErrorLayerId
);
1035 handleErrorRequest(star::task::InteractionClassification_ERROR
,
1038 rRequest
->getContinuations(),
1039 bObtainErrorStringOnly
,
1045 star::configuration::backend::StratumCreationException
1046 aStratumCreationException
;
1048 if (aAnyRequest
>>= aStratumCreationException
)
1050 const ErrCode nErrorCode
= ERRCODE_UUI_CONFIGURATION_BACKENDMISSING
;
1052 rtl::OUString aStratum
= aStratumCreationException
.StratumData
;
1053 if (aStratum
.getLength() == 0)
1054 aStratum
= aStratumCreationException
.StratumService
;
1056 std::vector
< rtl::OUString
> aArguments
;
1057 aArguments
.push_back(aStratum
);
1059 handleErrorRequest(star::task::InteractionClassification_ERROR
,
1062 rRequest
->getContinuations(),
1063 bObtainErrorStringOnly
,
1069 star::xforms::InvalidDataOnSubmitException aInvalidDataOnSubmitException
;
1070 if (aAnyRequest
>>= aInvalidDataOnSubmitException
)
1072 const ErrCode nErrorCode
= ERRCODE_UUI_INVALID_XFORMS_SUBMISSION_DATA
;
1074 std::vector
< rtl::OUString
> aArguments
;
1076 handleErrorRequest(star::task::InteractionClassification_QUERY
,
1079 rRequest
->getContinuations(),
1080 bObtainErrorStringOnly
,
1089 bool UUIInteractionHelper::handleDialogRequests(
1090 star::uno::Reference
< star::task::XInteractionRequest
> const & rRequest
)
1092 star::uno::Any
aAnyRequest(rRequest
->getRequest());
1094 star::ucb::AuthenticationRequest aAuthenticationRequest
;
1095 if (aAnyRequest
>>= aAuthenticationRequest
)
1097 handleAuthenticationRequest(aAuthenticationRequest
,
1098 rRequest
->getContinuations());
1102 star::ucb::CertificateValidationRequest aCertificateValidationRequest
;
1103 if (aAnyRequest
>>= aCertificateValidationRequest
)
1105 handleCertificateValidationRequest(aCertificateValidationRequest
,
1106 rRequest
->getContinuations());
1110 // @@@ Todo #i29340#: activate!
1111 // star::ucb::NameClashResolveRequest aNameClashResolveRequest;
1112 // if (aAnyRequest >>= aNameClashResolveRequest)
1114 // handleNameClashResolveRequest(aNameClashResolveRequest,
1115 // rRequest->getContinuations());
1119 star::task::MasterPasswordRequest aMasterPasswordRequest
;
1120 if (aAnyRequest
>>= aMasterPasswordRequest
)
1122 handleMasterPasswordRequest(aMasterPasswordRequest
.Mode
,
1123 rRequest
->getContinuations());
1127 star::task::DocumentPasswordRequest aDocumentPasswordRequest
;
1128 if (aAnyRequest
>>= aDocumentPasswordRequest
)
1130 handlePasswordRequest(aDocumentPasswordRequest
.Mode
,
1131 rRequest
->getContinuations(),
1132 aDocumentPasswordRequest
.Name
);
1136 star::task::DocumentMSPasswordRequest aDocumentMSPasswordRequest
;
1137 if (aAnyRequest
>>= aDocumentMSPasswordRequest
)
1139 handleMSPasswordRequest(aDocumentMSPasswordRequest
.Mode
,
1140 rRequest
->getContinuations(),
1141 aDocumentMSPasswordRequest
.Name
);
1145 star::task::PasswordRequest aPasswordRequest
;
1146 if (aAnyRequest
>>= aPasswordRequest
)
1148 handlePasswordRequest(aPasswordRequest
.Mode
,
1149 rRequest
->getContinuations());
1153 star::ucb::HandleCookiesRequest aCookiesRequest
;
1154 if (aAnyRequest
>>= aCookiesRequest
)
1156 handleCookiesRequest(aCookiesRequest
,
1157 rRequest
->getContinuations());
1161 star::document::NoSuchFilterRequest aNoSuchFilterRequest
;
1162 if (aAnyRequest
>>= aNoSuchFilterRequest
)
1164 handleNoSuchFilterRequest(aNoSuchFilterRequest
,
1165 rRequest
->getContinuations());
1169 star::document::AmbigousFilterRequest aAmbigousFilterRequest
;
1170 if (aAnyRequest
>>= aAmbigousFilterRequest
)
1172 handleAmbigousFilterRequest(aAmbigousFilterRequest
,
1173 rRequest
->getContinuations());
1177 star::document::FilterOptionsRequest aFilterOptionsRequest
;
1178 if (aAnyRequest
>>= aFilterOptionsRequest
)
1180 handleFilterOptionsRequest(aFilterOptionsRequest
,
1181 rRequest
->getContinuations());
1185 star::document::LockedDocumentRequest aLockedDocumentRequest
;
1186 if (aAnyRequest
>>= aLockedDocumentRequest
)
1188 handleLockedDocumentRequest( aLockedDocumentRequest
.DocumentURL
,
1189 aLockedDocumentRequest
.UserInfo
,
1190 rRequest
->getContinuations(),
1191 UUI_DOC_LOAD_LOCK
);
1195 star::document::OwnLockOnDocumentRequest aOwnLockOnDocumentRequest
;
1196 if (aAnyRequest
>>= aOwnLockOnDocumentRequest
)
1198 handleLockedDocumentRequest( aOwnLockOnDocumentRequest
.DocumentURL
,
1199 aOwnLockOnDocumentRequest
.TimeInfo
,
1200 rRequest
->getContinuations(),
1201 aOwnLockOnDocumentRequest
.IsStoring
? UUI_DOC_OWN_SAVE_LOCK
: UUI_DOC_OWN_LOAD_LOCK
);
1205 star::document::LockedOnSavingRequest aLockedOnSavingRequest
;
1206 if (aAnyRequest
>>= aLockedOnSavingRequest
)
1208 handleLockedDocumentRequest( aLockedOnSavingRequest
.DocumentURL
,
1209 aLockedOnSavingRequest
.UserInfo
,
1210 rRequest
->getContinuations(),
1211 UUI_DOC_SAVE_LOCK
);
1215 star::document::ChangedByOthersRequest aChangedByOthersRequest
;
1216 if (aAnyRequest
>>= aChangedByOthersRequest
)
1218 handleChangedByOthersRequest( rRequest
->getContinuations() );
1222 star::document::LockFileIgnoreRequest aLockFileIgnoreRequest
;
1223 if (aAnyRequest
>>= aLockFileIgnoreRequest
)
1225 handleLockFileIgnoreRequest( rRequest
->getContinuations() );
1232 bool UUIInteractionHelper::handleErrorHandlerRequests(
1233 star::uno::Reference
< star::task::XInteractionRequest
> const & rRequest
,
1234 bool bObtainErrorStringOnly
,
1235 bool & bHasErrorString
,
1236 rtl::OUString
& rErrorString
)
1238 star::uno::Any
aAnyRequest(rRequest
->getRequest());
1240 star::task::ErrorCodeRequest aErrorCodeRequest
;
1241 if (aAnyRequest
>>= aErrorCodeRequest
)
1243 handleGenericErrorRequest( aErrorCodeRequest
.ErrCode
,
1244 rRequest
->getContinuations(),
1245 bObtainErrorStringOnly
,
1251 star::task::DocumentMacroConfirmationRequest aMacroConfirmRequest
;
1252 if (aAnyRequest
>>= aMacroConfirmRequest
)
1254 handleMacroConfirmRequest(
1255 aMacroConfirmRequest
,
1256 rRequest
->getContinuations()
1261 FutureDocumentVersionProductUpdateRequest aProductUpdateRequest
;
1262 if (aAnyRequest
>>= aProductUpdateRequest
)
1264 handleFutureDocumentVersionUpdateRequest(
1265 aProductUpdateRequest
,
1266 rRequest
->getContinuations()
1271 star::task::ErrorCodeIOException aErrorCodeIOException
;
1272 if (aAnyRequest
>>= aErrorCodeIOException
)
1274 handleGenericErrorRequest( aErrorCodeIOException
.ErrCode
,
1275 rRequest
->getContinuations(),
1276 bObtainErrorStringOnly
,
1286 UUIInteractionHelper::handle_impl(
1287 star::uno::Reference
< star::task::XInteractionRequest
> const & rRequest
)
1288 throw (star::uno::RuntimeException
)
1295 ////////////////////////////////////////////////////////////
1296 // Display Messagebox
1297 ////////////////////////////////////////////////////////////
1298 bool bDummy
= false;
1299 rtl::OUString aDummy
;
1300 if (! handleMessageboxRequests(rRequest
, false, bDummy
, aDummy
))
1302 ////////////////////////////////////////////////////////////
1303 // Use ErrorHandler::HandleError
1304 ////////////////////////////////////////////////////////////
1305 if (!handleErrorHandlerRequests(rRequest
, false, bDummy
, aDummy
))
1307 ////////////////////////////////////////////////////////////
1308 // Display Special Dialog
1309 ////////////////////////////////////////////////////////////
1310 if (!handleDialogRequests(rRequest
))
1312 ////////////////////////////////////////////////////////////
1313 // Use customized InteractionHandler from configuration
1314 ////////////////////////////////////////////////////////////
1315 InteractionHandlerDataList dataList
;
1317 GetInteractionHandlerList(dataList
);
1319 InteractionHandlerDataList::const_iterator
aEnd(dataList
.end());
1320 for (InteractionHandlerDataList::const_iterator
aIt(dataList
.begin());
1323 Reference
< uno::XInterface
> xIfc
=
1324 m_xServiceFactory
->createInstance(aIt
->ServiceName
);
1326 Reference
< com::sun::star::task::XInteractionHandler2
> xInteractionHandler
=
1327 Reference
< com::sun::star::task::XInteractionHandler2
>( xIfc
, UNO_QUERY
);
1329 OSL_ENSURE( xInteractionHandler
.is(), "Custom Interactionhandler does not implement mandatory interface XInteractionHandler2!" );
1330 if (xInteractionHandler
.is())
1331 if (xInteractionHandler
->handleInteractionRequest(rRequest
))
1338 catch (std::bad_alloc
const &)
1340 throw star::uno::RuntimeException(
1341 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1342 star::uno::Reference
< star::uno::XInterface
>());
1346 void UUIInteractionHelper::GetInteractionHandlerList(InteractionHandlerDataList
&rdataList
)
1348 uno::Reference
< lang::XMultiServiceFactory
> xConfigProv(
1349 m_xServiceFactory
->createInstance(
1350 rtl::OUString::createFromAscii(
1351 "com.sun.star.configuration.ConfigurationProvider" ) ),
1354 if ( !xConfigProv
.is() )
1357 "GetInteractionHandlerList - No config provider!" );
1361 rtl::OUStringBuffer aFullPath
;
1362 aFullPath
.appendAscii( CONFIG_INTERACTIONHANDLERS_KEY
);
1364 uno::Sequence
< uno::Any
> aArguments( 1 );
1365 beans::PropertyValue aProperty
;
1367 = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
1368 aProperty
.Value
<<= aFullPath
.makeStringAndClear();
1369 aArguments
[ 0 ] <<= aProperty
;
1371 uno::Reference
< uno::XInterface
> xInterface(
1372 xConfigProv
->createInstanceWithArguments(
1373 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
1374 "com.sun.star.configuration.ConfigurationAccess" ) ),
1377 if ( !xInterface
.is() )
1380 "GetInteractionHandlerList - No config access!" );
1384 uno::Reference
< container::XNameAccess
> xNameAccess(
1385 xInterface
, uno::UNO_QUERY
);
1387 if ( !xNameAccess
.is() )
1390 "GetInteractionHandlerList - No XNameAccess!" );
1394 uno::Sequence
< rtl::OUString
> aElems
= xNameAccess
->getElementNames();
1395 const rtl::OUString
* pElems
= aElems
.getConstArray();
1396 sal_Int32 nCount
= aElems
.getLength();
1400 uno::Reference
< container::XHierarchicalNameAccess
>
1401 xHierNameAccess( xInterface
, uno::UNO_QUERY
);
1403 if ( !xHierNameAccess
.is() )
1406 "GetInteractionHandlerList - "
1407 "No XHierarchicalNameAccess!" );
1411 // Iterate over children.
1412 for ( sal_Int32 n
= 0; n
< nCount
; ++n
)
1414 rtl::OUStringBuffer aElemBuffer
;
1415 aElemBuffer
.appendAscii( "['" );
1416 aElemBuffer
.append( pElems
[ n
] );
1420 InteractionHandlerData aInfo
;
1422 // Obtain service name.
1423 rtl::OUStringBuffer aKeyBuffer
= aElemBuffer
;
1424 aKeyBuffer
.appendAscii( "']/ServiceName" );
1426 rtl::OUString aValue
;
1427 if ( !( xHierNameAccess
->getByHierarchicalName(
1428 aKeyBuffer
.makeStringAndClear() ) >>= aValue
) )
1431 "GetInteractionHandlerList - "
1432 "Error getting item value!" );
1436 aInfo
.ServiceName
= aValue
;
1438 // Append info to list.
1439 rdataList
.push_back( aInfo
);
1441 catch ( container::NoSuchElementException
& )
1443 // getByHierarchicalName
1446 "GetInteractionHandlerList - "
1447 "caught NoSuchElementException!" );
1453 Window
* UUIInteractionHelper::getParentProperty() SAL_THROW(())
1455 osl::MutexGuard
aGuard(m_aPropertyMutex
);
1456 for (sal_Int32 i
= 0; i
< m_aProperties
.getLength(); ++i
)
1458 star::beans::PropertyValue aProperty
;
1459 if ((m_aProperties
[i
] >>= aProperty
)
1461 Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Parent")))
1463 star::uno::Reference
< star::awt::XWindow
> xWindow
;
1464 aProperty
.Value
>>= xWindow
;
1465 return VCLUnoHelper::GetWindow(xWindow
);
1471 rtl::OUString
UUIInteractionHelper::getContextProperty() SAL_THROW(())
1473 osl::MutexGuard
aGuard(m_aPropertyMutex
);
1474 for (sal_Int32 i
= 0; i
< m_aProperties
.getLength(); ++i
)
1476 star::beans::PropertyValue aProperty
;
1477 if ((m_aProperties
[i
] >>= aProperty
)
1479 Name
.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Context")))
1481 rtl::OUString aContext
;
1482 aProperty
.Value
>>= aContext
;
1486 return rtl::OUString();
1490 UUIInteractionHelper::initPasswordContainer(
1491 star::uno::Reference
< star::task::XPasswordContainer
> * pContainer
)
1494 OSL_ENSURE(pContainer
, "specification violation");
1495 if (!pContainer
->is() && m_xServiceFactory
.is())
1499 = star::uno::Reference
< star::task::XPasswordContainer
>(
1503 RTL_CONSTASCII_USTRINGPARAM(
1504 "com.sun.star.task.PasswordContainer"))),
1505 star::uno::UNO_QUERY
);
1507 catch (star::uno::Exception
const &)
1509 OSL_ENSURE(pContainer
->is(), "unexpected situation");
1510 return pContainer
->is();
1514 String
GetContentPart( const String
& _rRawString
)
1516 // search over some parts to find a string
1517 //static char* aIDs[] = { "CN", "OU", "O", "E", NULL };
1518 static char const * aIDs
[] = { "CN=", "OU=", "O=", "E=", NULL
};// By CP
1523 String sPartId
= String::CreateFromAscii( aIDs
[i
++] );
1524 xub_StrLen nContStart
= _rRawString
.Search( sPartId
);
1525 if ( nContStart
!= STRING_NOTFOUND
)
1527 nContStart
= nContStart
+ sPartId
.Len();
1528 //++nContStart; // now it's start of content, directly after Id // delete By CP
1529 xub_StrLen nContEnd
= _rRawString
.Search( sal_Unicode( ',' ), nContStart
);
1530 sPart
= String( _rRawString
, nContStart
, nContEnd
- nContStart
);
1539 sal_Bool
UUIInteractionHelper::executeUnknownAuthDialog( const cssu::Reference
< dcss::security::XCertificate
>& rXCert
)
1540 SAL_THROW((star::uno::RuntimeException
))
1544 vos::OGuard
aGuard(Application::GetSolarMutex());
1546 std::auto_ptr
< ResMgr
>
1547 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1548 std::auto_ptr
< UnknownAuthDialog
>
1549 xDialog(new UnknownAuthDialog( getParentProperty(),
1554 // Get correct ressource string
1555 rtl::OUString aMessage
;
1557 std::vector
< rtl::OUString
> aArguments
;
1558 aArguments
.push_back( GetContentPart( rXCert
.get()->getSubjectName()) );
1559 //aArguments.push_back( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")) );
1563 ResId
aResId(RID_UUI_ERRHDL
, *xManager
.get());
1564 if (ErrorResource(aResId
).getString(ERRCODE_UUI_UNKNOWNAUTH_UNTRUSTED
, &aMessage
))
1566 aMessage
= replaceMessageWithArguments( aMessage
, aArguments
);
1567 xDialog
->setDescriptionText( aMessage
);
1571 return static_cast<sal_Bool
> (xDialog
->Execute());
1573 catch (std::bad_alloc
const &)
1575 throw star::uno::RuntimeException(
1576 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1577 star::uno::Reference
< star::uno::XInterface
>());
1582 UUIInteractionHelper::getLocalizedDatTimeStr( ::com::sun::star::util::DateTime aDateTime
)
1586 rtl::OUString aDateTimeStr
;
1590 aDate
= Date( aDateTime
.Day
, aDateTime
.Month
, aDateTime
.Year
);
1591 aTime
= Time( aDateTime
.Hours
, aDateTime
.Minutes
, aDateTime
.Seconds
);
1593 LanguageType eUILang
= Application::GetSettings().GetUILanguage();
1594 SvNumberFormatter
*pNumberFormatter
= new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), eUILang
);
1596 Color
* pColor
= NULL
;
1597 Date
* pNullDate
= pNumberFormatter
->GetNullDate();
1598 sal_uInt32 nFormat
= pNumberFormatter
->GetStandardFormat( NUMBERFORMAT_DATE
, eUILang
);
1600 pNumberFormatter
->GetOutputString( aDate
- *pNullDate
, nFormat
, aTmpStr
, &pColor
);
1601 aDateTimeStr
= aTmpStr
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
1603 nFormat
= pNumberFormatter
->GetStandardFormat( NUMBERFORMAT_TIME
, eUILang
);
1604 pNumberFormatter
->GetOutputString( aTime
.GetTimeInDays(), nFormat
, aTmpStr
, &pColor
);
1605 aDateTimeStr
+= aTmpStr
;
1607 return aDateTimeStr
;
1610 sal_Bool
UUIInteractionHelper::executeSSLWarnDialog( const cssu::Reference
< dcss::security::XCertificate
>& rXCert
,
1611 sal_Int32
const & failure
,
1612 const rtl::OUString
& hostName
)
1613 SAL_THROW((star::uno::RuntimeException
))
1617 vos::OGuard
aGuard(Application::GetSolarMutex());
1619 std::auto_ptr
< ResMgr
>
1620 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1621 std::auto_ptr
< SSLWarnDialog
>
1622 xDialog(new SSLWarnDialog( getParentProperty(),
1627 // Get correct ressource string
1628 rtl::OUString aMessage_1
;
1629 std::vector
< rtl::OUString
> aArguments_1
;
1633 case SSLWARN_TYPE_DOMAINMISMATCH
:
1634 aArguments_1
.push_back( hostName
);
1635 aArguments_1
.push_back( GetContentPart( rXCert
.get()->getSubjectName()) );
1636 aArguments_1
.push_back( hostName
);
1638 case SSLWARN_TYPE_EXPIRED
:
1639 aArguments_1
.push_back( GetContentPart( rXCert
.get()->getSubjectName()) );
1640 aArguments_1
.push_back( getLocalizedDatTimeStr( rXCert
.get()->getNotValidAfter() ) );
1641 aArguments_1
.push_back( getLocalizedDatTimeStr( rXCert
.get()->getNotValidAfter() ) );
1643 case SSLWARN_TYPE_INVALID
:
1649 //aArguments.push_back( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")) );
1653 ResId
aResId(RID_UUI_ERRHDL
, *xManager
.get());
1654 if (ErrorResource(aResId
).getString( ERRCODE_AREA_UUI_UNKNOWNAUTH
+ failure
+ DESCRIPTION_1
, &aMessage_1
))
1656 aMessage_1
= replaceMessageWithArguments( aMessage_1
, aArguments_1
);
1657 xDialog
->setDescription1Text( aMessage_1
);
1660 rtl::OUString aTitle
;
1661 ErrorResource(aResId
).getString( ERRCODE_AREA_UUI_UNKNOWNAUTH
+ failure
+ TITLE
, &aTitle
);
1662 xDialog
->SetText( aTitle
);
1667 return static_cast<sal_Bool
> (xDialog
->Execute());
1669 catch (std::bad_alloc
const &)
1671 throw star::uno::RuntimeException(
1672 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1673 star::uno::Reference
< star::uno::XInterface
>());
1677 void UUIInteractionHelper::executeLoginDialog(LoginErrorInfo
& rInfo
,
1678 rtl::OUString
const & rRealm
)
1679 SAL_THROW((star::uno::RuntimeException
))
1683 vos::OGuard
aGuard(Application::GetSolarMutex());
1685 bool bAccount
= (rInfo
.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT
)
1687 bool bSavePassword
= rInfo
.GetIsPersistentPassword()
1688 || rInfo
.GetIsSavePassword();
1690 sal_uInt16 nFlags
= 0;
1691 if (rInfo
.GetPath().Len() == 0)
1692 nFlags
|= LF_NO_PATH
;
1693 if (rInfo
.GetErrorText().Len() == 0)
1694 nFlags
|= LF_NO_ERRORTEXT
;
1696 nFlags
|= LF_NO_ACCOUNT
;
1697 if (!(rInfo
.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME
))
1698 nFlags
|= LF_USERNAME_READONLY
;
1701 nFlags
|= LF_NO_SAVEPASSWORD
;
1703 std::auto_ptr
< ResMgr
>
1704 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1705 UniString
aRealm(rRealm
); // Forte compiler needs it spelled out...
1706 std::auto_ptr
< LoginDialog
>
1707 xDialog(new LoginDialog(getParentProperty(),
1712 if (rInfo
.GetErrorText().Len() != 0)
1713 xDialog
->SetErrorText(rInfo
.GetErrorText());
1714 xDialog
->SetName(rInfo
.GetUserName());
1716 xDialog
->ClearAccount();
1718 xDialog
->ClearPassword();
1719 xDialog
->SetPassword(rInfo
.GetPassword());
1724 SetSavePasswordText(ResId(rInfo
.GetIsPersistentPassword() ?
1728 xDialog
->SetSavePassword(rInfo
.GetIsSavePassword());
1731 rInfo
.SetResult(xDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
:
1732 ERRCODE_BUTTON_CANCEL
);
1733 rInfo
.SetUserName(xDialog
->GetName());
1734 rInfo
.SetPassword(xDialog
->GetPassword());
1735 rInfo
.SetAccount(xDialog
->GetAccount());
1736 rInfo
.SetSavePassword(xDialog
->IsSavePassword());
1738 catch (std::bad_alloc
const &)
1740 throw star::uno::RuntimeException(
1741 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1742 star::uno::Reference
< star::uno::XInterface
>());
1747 UUIInteractionHelper::executeMasterPasswordDialog(
1748 LoginErrorInfo
& rInfo
,
1749 star::task::PasswordRequestMode nMode
)
1750 SAL_THROW((star::uno::RuntimeException
))
1752 rtl::OString aMaster
;
1755 vos::OGuard
aGuard(Application::GetSolarMutex());
1757 std::auto_ptr
< ResMgr
>
1758 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1759 if( nMode
== star::task::PasswordRequestMode_PASSWORD_CREATE
)
1761 std::auto_ptr
< MasterPasswordCreateDialog
>
1762 xDialog(new MasterPasswordCreateDialog(
1763 getParentProperty(), xManager
.get()));
1764 rInfo
.SetResult(xDialog
->Execute()
1765 == RET_OK
? ERRCODE_BUTTON_OK
1766 : ERRCODE_BUTTON_CANCEL
);
1767 aMaster
= rtl::OUStringToOString(xDialog
->GetMasterPassword(),
1768 RTL_TEXTENCODING_UTF8
);
1772 std::auto_ptr
< MasterPasswordDialog
>
1773 xDialog(new MasterPasswordDialog(
1774 getParentProperty(), nMode
, xManager
.get()));
1775 rInfo
.SetResult(xDialog
->Execute()
1776 == RET_OK
? ERRCODE_BUTTON_OK
1777 : ERRCODE_BUTTON_CANCEL
);
1778 aMaster
= rtl::OUStringToOString(xDialog
->GetMasterPassword(),
1779 RTL_TEXTENCODING_UTF8
);
1783 catch (std::bad_alloc
const &)
1785 throw star::uno::RuntimeException(
1786 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1787 star::uno::Reference
< star::uno::XInterface
>());
1790 sal_uInt8 aKey
[RTL_DIGEST_LENGTH_MD5
];
1791 rtl_digest_PBKDF2(aKey
,
1792 RTL_DIGEST_LENGTH_MD5
,
1793 reinterpret_cast< sal_uInt8
const * >(aMaster
.getStr()),
1794 aMaster
.getLength(),
1795 reinterpret_cast< sal_uInt8
const * >(
1796 "3B5509ABA6BC42D9A3A1F3DAD49E56A51"),
1800 rtl::OUStringBuffer aBuffer
;
1801 for (int i
= 0; i
< RTL_DIGEST_LENGTH_MD5
; ++i
)
1803 aBuffer
.append(static_cast< sal_Unicode
>('a' + (aKey
[i
] >> 4)));
1804 aBuffer
.append(static_cast< sal_Unicode
>('a' + (aKey
[i
] & 15)));
1806 rInfo
.SetPassword(aBuffer
.makeStringAndClear());
1810 UUIInteractionHelper::executePasswordDialog(
1811 LoginErrorInfo
& rInfo
,
1812 star::task::PasswordRequestMode nMode
,
1813 ::rtl::OUString aDocName
)
1814 SAL_THROW((star::uno::RuntimeException
))
1818 vos::OGuard
aGuard(Application::GetSolarMutex());
1820 std::auto_ptr
< ResMgr
>
1821 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1822 if( nMode
== star::task::PasswordRequestMode_PASSWORD_CREATE
)
1824 std::auto_ptr
< PasswordCreateDialog
>
1825 xDialog(new PasswordCreateDialog(
1826 getParentProperty(), xManager
.get()));
1828 rInfo
.SetResult(xDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
:
1829 ERRCODE_BUTTON_CANCEL
);
1830 rInfo
.SetPassword( xDialog
->GetPassword() );
1834 std::auto_ptr
< PasswordDialog
>
1835 xDialog(new PasswordDialog(
1836 getParentProperty(), nMode
, xManager
.get(), aDocName
));
1838 rInfo
.SetResult(xDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
:
1839 ERRCODE_BUTTON_CANCEL
);
1840 rInfo
.SetPassword( xDialog
->GetPassword() );
1843 catch (std::bad_alloc
const &)
1845 throw star::uno::RuntimeException(
1846 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1847 star::uno::Reference
< star::uno::XInterface
>());
1852 UUIInteractionHelper::executeMSPasswordDialog(
1853 LoginErrorInfo
& rInfo
,
1854 star::task::PasswordRequestMode nMode
,
1855 ::rtl::OUString aDocName
)
1856 SAL_THROW((star::uno::RuntimeException
))
1860 vos::OGuard
aGuard(Application::GetSolarMutex());
1862 std::auto_ptr
< ResMgr
>
1863 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1864 if( nMode
== star::task::PasswordRequestMode_PASSWORD_CREATE
)
1866 std::auto_ptr
< PasswordCreateDialog
>
1867 xDialog(new PasswordCreateDialog(
1868 getParentProperty(), xManager
.get(), true));
1870 rInfo
.SetResult(xDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
:
1871 ERRCODE_BUTTON_CANCEL
);
1872 rInfo
.SetPassword( xDialog
->GetPassword() );
1876 std::auto_ptr
< PasswordDialog
>
1877 xDialog(new PasswordDialog(
1878 getParentProperty(), nMode
, xManager
.get(), aDocName
));
1880 rInfo
.SetResult(xDialog
->Execute() == RET_OK
? ERRCODE_BUTTON_OK
:
1881 ERRCODE_BUTTON_CANCEL
);
1882 rInfo
.SetPassword( xDialog
->GetPassword() );
1885 catch (std::bad_alloc
const &)
1887 throw star::uno::RuntimeException(
1888 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1889 star::uno::Reference
< star::uno::XInterface
>());
1894 UUIInteractionHelper::executeCookieDialog(CntHTTPCookieRequest
& rRequest
)
1895 SAL_THROW((star::uno::RuntimeException
))
1899 vos::OGuard
aGuard(Application::GetSolarMutex());
1901 std::auto_ptr
< ResMgr
>
1902 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1903 std::auto_ptr
< CookiesDialog
>
1904 xDialog(new CookiesDialog(
1905 getParentProperty(), &rRequest
, xManager
.get()));
1908 catch (std::bad_alloc
const &)
1910 throw star::uno::RuntimeException(
1911 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1912 star::uno::Reference
< star::uno::XInterface
>());
1916 void UUIInteractionHelper::executeFilterDialog(
1917 rtl::OUString
const & rURL
,
1918 uui::FilterNameList
const & rFilters
,
1919 rtl::OUString
& rFilter
)
1920 SAL_THROW((star::uno::RuntimeException
))
1924 vos::OGuard
aGuard(Application::GetSolarMutex());
1926 std::auto_ptr
< ResMgr
>
1927 xManager(ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
1929 std::auto_ptr
< uui::FilterDialog
>
1930 xDialog(new uui::FilterDialog(getParentProperty(),
1933 xDialog
->SetURL(rURL
);
1934 xDialog
->ChangeFilters(&rFilters
);
1936 uui::FilterNameListPtr pSelected
= rFilters
.end();
1937 if( xDialog
->AskForFilter( pSelected
) )
1939 rFilter
= pSelected
->sInternal
;
1942 catch (std::bad_alloc
const &)
1944 throw star::uno::RuntimeException(
1945 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
1946 star::uno::Reference
< star::uno::XInterface
>());
1951 UUIInteractionHelper::executeErrorDialog(
1952 star::task::InteractionClassification eClassification
,
1953 rtl::OUString
const & rContext
,
1954 rtl::OUString
const & rMessage
,
1955 WinBits nButtonMask
)
1956 SAL_THROW((star::uno::RuntimeException
))
1959 vos::OGuard
aGuard(Application::GetSolarMutex());
1961 rtl::OUStringBuffer
aText(rContext
);
1962 if (rContext
.getLength() != 0 && rMessage
.getLength() != 0)
1963 aText
.appendAscii(RTL_CONSTASCII_STRINGPARAM(":\n"));
1964 //TODO! must be internationalized
1965 aText
.append(rMessage
);
1967 std::auto_ptr
< MessBox
> xBox
;
1970 switch (eClassification
)
1972 case star::task::InteractionClassification_ERROR
:
1973 xBox
.reset(new ErrorBox(getParentProperty(),
1975 aText
.makeStringAndClear()));
1978 case star::task::InteractionClassification_WARNING
:
1979 xBox
.reset(new WarningBox(getParentProperty(),
1981 aText
.makeStringAndClear()));
1984 case star::task::InteractionClassification_INFO
:
1985 if ((nButtonMask
& 0x01F00000) == WB_DEF_OK
)
1986 //TODO! missing win bit button mask define (want to ignore
1987 // any default button settings)...
1988 xBox
.reset(new InfoBox(getParentProperty(),
1989 aText
.makeStringAndClear()));
1991 xBox
.reset(new ErrorBox(getParentProperty(),
1993 aText
.makeStringAndClear()));
1996 case star::task::InteractionClassification_QUERY
:
1997 xBox
.reset(new QueryBox(getParentProperty(),
1999 aText
.makeStringAndClear()));
2007 catch (std::bad_alloc
const &)
2009 throw star::uno::RuntimeException(
2010 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
2011 star::uno::Reference
< star::uno::XInterface
>());
2014 USHORT aResult
= xBox
->Execute();
2018 aResult
= ERRCODE_BUTTON_OK
;
2020 case BUTTONID_CANCEL
:
2021 aResult
= ERRCODE_BUTTON_CANCEL
;
2024 aResult
= ERRCODE_BUTTON_YES
;
2027 aResult
= ERRCODE_BUTTON_NO
;
2029 case BUTTONID_RETRY
:
2030 aResult
= ERRCODE_BUTTON_RETRY
;
2038 UUIInteractionHelper::executeMessageBox(
2039 rtl::OUString
const & rTitle
,
2040 rtl::OUString
const & rMessage
,
2041 WinBits nButtonMask
)
2042 SAL_THROW((star::uno::RuntimeException
))
2045 vos::OGuard
aGuard(Application::GetSolarMutex());
2047 MessBox
xBox( getParentProperty(), nButtonMask
, rTitle
, rMessage
);
2049 USHORT aResult
= xBox
.Execute();
2053 aResult
= ERRCODE_BUTTON_OK
;
2055 case BUTTONID_CANCEL
:
2056 aResult
= ERRCODE_BUTTON_CANCEL
;
2059 aResult
= ERRCODE_BUTTON_YES
;
2062 aResult
= ERRCODE_BUTTON_NO
;
2064 case BUTTONID_RETRY
:
2065 aResult
= ERRCODE_BUTTON_RETRY
;
2071 star::uno::Reference
< star::task::XInteractionHandler
>
2072 UUIInteractionHelper::getInteractionHandler() const
2073 SAL_THROW((star::uno::RuntimeException
))
2075 star::uno::Reference
< star::task::XInteractionHandler
> xIH
;
2078 xIH
= star::uno::Reference
< star::task::XInteractionHandler
>(
2079 m_xServiceFactory
->createInstanceWithArguments(
2081 RTL_CONSTASCII_USTRINGPARAM(
2082 "com.sun.star.task.InteractionHandler")),
2084 star::uno::UNO_QUERY
);
2086 catch (star::uno::Exception
const &)
2090 throw star::uno::RuntimeException(
2092 RTL_CONSTASCII_USTRINGPARAM(
2093 "unable to instanciate Interaction Handler service")),
2094 star::uno::Reference
< star::uno::XInterface
>());
2099 UUIInteractionHelper::handleAuthenticationRequest(
2100 star::ucb::AuthenticationRequest
const & rRequest
,
2101 star::uno::Sequence
< star::uno::Reference
<
2102 star::task::XInteractionContinuation
> > const &
2104 SAL_THROW((star::uno::RuntimeException
))
2106 star::uno::Reference
< star::task::XInteractionHandler
> xIH
;
2108 star::uno::Reference
< star::task::XInteractionRetry
> xRetry
;
2109 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
2110 star::uno::Reference
< star::ucb::XInteractionSupplyAuthentication
>
2111 xSupplyAuthentication
;
2114 0, 0, &xRetry
, &xAbort
, &xSupplyAuthentication
, 0, 0, 0 );
2116 bool bRememberPersistent
;
2117 if (xSupplyAuthentication
.is())
2119 star::ucb::RememberAuthentication eDefault
;
2120 star::uno::Sequence
< star::ucb::RememberAuthentication
>
2121 aModes(xSupplyAuthentication
->getRememberPasswordModes(eDefault
));
2122 bRemember
= eDefault
!= star::ucb::RememberAuthentication_NO
;
2123 bRememberPersistent
= false;
2124 for (sal_Int32 i
= 0; i
< aModes
.getLength(); ++i
)
2125 if (aModes
[i
] == star::ucb::RememberAuthentication_PERSISTENT
)
2127 bRememberPersistent
= true;
2134 bRememberPersistent
= false;
2137 com::sun::star::uno::Reference
< com::sun::star::task::XPasswordContainer
>
2140 // xContainer works with userName passwdSequences pairs:
2141 if (rRequest
.HasUserName
2142 && rRequest
.HasPassword
2143 && initPasswordContainer(&xContainer
))
2145 xIH
= getInteractionHandler();
2148 if (rRequest
.UserName
.getLength() == 0)
2150 star::task::UrlRecord
2151 aRec(xContainer
->find(rRequest
.ServerName
, xIH
));
2152 if (aRec
.UserList
.getLength() != 0)
2154 if (xSupplyAuthentication
->canSetUserName())
2155 xSupplyAuthentication
->
2156 setUserName(aRec
.UserList
[0].UserName
.getStr());
2157 if (xSupplyAuthentication
->canSetPassword())
2159 OSL_ENSURE(aRec
.UserList
[0].Passwords
.getLength() != 0,
2160 "empty password list");
2161 xSupplyAuthentication
->
2163 aRec
.UserList
[0].Passwords
[0].getStr());
2165 if (aRec
.UserList
[0].Passwords
.getLength() > 1)
2167 if (rRequest
.HasRealm
)
2169 if (xSupplyAuthentication
->canSetRealm())
2170 xSupplyAuthentication
->
2171 setRealm(aRec
.UserList
[0].Passwords
[1].
2174 else if (xSupplyAuthentication
->canSetAccount())
2175 xSupplyAuthentication
->
2176 setAccount(aRec
.UserList
[0].Passwords
[1].
2179 xSupplyAuthentication
->select();
2185 star::task::UrlRecord
2186 aRec(xContainer
->findForName(rRequest
.ServerName
,
2189 if (aRec
.UserList
.getLength() != 0)
2191 OSL_ENSURE(aRec
.UserList
[0].Passwords
.getLength() != 0,
2192 "empty password list");
2193 if (!rRequest
.HasPassword
2194 || rRequest
.Password
!= aRec
.UserList
[0].Passwords
[0])
2196 if (xSupplyAuthentication
->canSetUserName())
2197 xSupplyAuthentication
->
2199 aRec
.UserList
[0].UserName
.getStr());
2200 if (xSupplyAuthentication
->canSetPassword())
2201 xSupplyAuthentication
->
2202 setPassword(aRec
.UserList
[0].Passwords
[0].
2204 if (aRec
.UserList
[0].Passwords
.getLength() > 1)
2206 if (rRequest
.HasRealm
)
2208 if (xSupplyAuthentication
->canSetRealm())
2209 xSupplyAuthentication
->
2210 setRealm(aRec
.UserList
[0].Passwords
[1].
2213 else if (xSupplyAuthentication
->canSetAccount())
2214 xSupplyAuthentication
->
2215 setAccount(aRec
.UserList
[0].Passwords
[1].
2218 xSupplyAuthentication
->select();
2224 catch (star::task::NoMasterException
const &)
2225 {} // user did not enter master password
2228 LoginErrorInfo aInfo
;
2229 aInfo
.SetTitle(rRequest
.ServerName
);
2230 aInfo
.SetServer(rRequest
.ServerName
);
2231 if (rRequest
.HasAccount
)
2232 aInfo
.SetAccount(rRequest
.Account
);
2233 if (rRequest
.HasUserName
)
2234 aInfo
.SetUserName(rRequest
.UserName
);
2235 if (rRequest
.HasPassword
)
2236 aInfo
.SetPassword(rRequest
.Password
);
2237 aInfo
.SetErrorText(rRequest
.Diagnostic
);
2238 aInfo
.SetPersistentPassword(bRememberPersistent
);
2239 aInfo
.SetSavePassword(bRemember
);
2240 aInfo
.SetModifyAccount(rRequest
.HasAccount
2241 && xSupplyAuthentication
.is()
2242 && xSupplyAuthentication
->canSetAccount());
2243 aInfo
.SetModifyUserName(rRequest
.HasUserName
2244 && xSupplyAuthentication
.is()
2245 && xSupplyAuthentication
->canSetUserName());
2246 executeLoginDialog(aInfo
,
2247 rRequest
.HasRealm
? rRequest
.Realm
: rtl::OUString());
2248 switch (aInfo
.GetResult())
2250 case ERRCODE_BUTTON_OK
:
2251 if (xSupplyAuthentication
.is())
2253 if (xSupplyAuthentication
->canSetUserName())
2254 xSupplyAuthentication
->setUserName(aInfo
.GetUserName());
2255 if (xSupplyAuthentication
->canSetPassword())
2256 xSupplyAuthentication
->setPassword(aInfo
.GetPassword());
2257 xSupplyAuthentication
->
2258 setRememberPassword(
2259 aInfo
.GetIsSavePassword() ?
2260 bRememberPersistent
?
2261 star::ucb::RememberAuthentication_PERSISTENT
:
2262 star::ucb::RememberAuthentication_SESSION
:
2263 star::ucb::RememberAuthentication_NO
);
2264 if (rRequest
.HasRealm
)
2266 if (xSupplyAuthentication
->canSetRealm())
2267 xSupplyAuthentication
->setRealm(aInfo
.GetAccount());
2269 else if (xSupplyAuthentication
->canSetAccount())
2270 xSupplyAuthentication
->setAccount(aInfo
.GetAccount());
2272 xSupplyAuthentication
->select();
2274 // Empty user name can not be valid:
2275 if (aInfo
.GetUserName().Len() != 0
2276 && initPasswordContainer(&xContainer
))
2278 star::uno::Sequence
< rtl::OUString
>
2279 aPassList(aInfo
.GetAccount().Len() == 0 ? 1 : 2);
2280 aPassList
[0] = aInfo
.GetPassword();
2281 if (aInfo
.GetAccount().Len() != 0)
2282 aPassList
[1] = aInfo
.GetAccount();
2285 if (aInfo
.GetIsSavePassword())
2288 xIH
= getInteractionHandler();
2290 if (bRememberPersistent
)
2291 xContainer
->addPersistent(rRequest
.ServerName
,
2292 aInfo
.GetUserName(),
2296 xContainer
->add(rRequest
.ServerName
,
2297 aInfo
.GetUserName(),
2302 catch (star::task::NoMasterException
const &)
2303 {} // user did not enter master password
2307 case ERRCODE_BUTTON_RETRY
:
2320 UUIInteractionHelper::isDomainMatch( rtl::OUString hostName
, rtl::OUString certHostName
)
2322 if (hostName
.equalsIgnoreAsciiCase( certHostName
))
2327 if ( 0 == certHostName
.indexOf( rtl::OUString::createFromAscii( "*" ) ) && hostName
.getLength() >= certHostName
.getLength() )
2329 rtl::OUString cmpStr
= certHostName
.copy( 1 );
2331 if ( hostName
.matchIgnoreAsciiCase( cmpStr
, hostName
.getLength( ) - cmpStr
.getLength()) )
2341 UUIInteractionHelper::handleCertificateValidationRequest(
2342 star::ucb::CertificateValidationRequest
const & rRequest
,
2343 star::uno::Sequence
< star::uno::Reference
<
2344 star::task::XInteractionContinuation
> > const &
2346 SAL_THROW((star::uno::RuntimeException
))
2348 star::uno::Reference
< star::task::XInteractionHandler
> xIH
= getInteractionHandler();
2350 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
2351 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
2354 rContinuations
, &xApprove
, 0, 0, &xAbort
, 0, 0, 0, 0);
2356 sal_Int32 failures
= rRequest
.CertificateValidity
;
2358 sal_Bool trustCert
= sal_True
;
2361 if ( ((failures
& csss::CertificateValidity::UNTRUSTED
) == csss::CertificateValidity::UNTRUSTED
) ||
2362 ((failures
& csss::CertificateValidity::ISSUER_UNTRUSTED
) == csss::CertificateValidity::ISSUER_UNTRUSTED
) ||
2363 ((failures
& csss::CertificateValidity::ROOT_UNTRUSTED
) == csss::CertificateValidity::ROOT_UNTRUSTED
) )
2365 if ( executeUnknownAuthDialog( rRequest
.Certificate
) )
2366 trustCert
= sal_True
;
2368 trustCert
= sal_False
;
2371 if ( (!isDomainMatch( rRequest
.HostName
, GetContentPart( rRequest
.Certificate
.get()->getSubjectName()) )) &&
2374 if ( executeSSLWarnDialog( rRequest
.Certificate
, SSLWARN_TYPE_DOMAINMISMATCH
, rRequest
.HostName
) )
2375 trustCert
= sal_True
;
2377 trustCert
= sal_False
;
2380 if ( (((failures
& csss::CertificateValidity::TIME_INVALID
) == csss::CertificateValidity::TIME_INVALID
) ||
2381 ((failures
& csss::CertificateValidity::NOT_TIME_NESTED
) == csss::CertificateValidity::NOT_TIME_NESTED
)) &&
2384 if ( executeSSLWarnDialog( rRequest
.Certificate
, SSLWARN_TYPE_EXPIRED
, rRequest
.HostName
) )
2385 trustCert
= sal_True
;
2387 trustCert
= sal_False
;
2390 if ( (((failures
& csss::CertificateValidity::REVOKED
) == csss::CertificateValidity::REVOKED
) ||
2391 ((failures
& csss::CertificateValidity::SIGNATURE_INVALID
) == csss::CertificateValidity::SIGNATURE_INVALID
) ||
2392 ((failures
& csss::CertificateValidity::EXTENSION_INVALID
) == csss::CertificateValidity::EXTENSION_INVALID
) ||
2393 ((failures
& csss::CertificateValidity::INVALID
) == csss::CertificateValidity::INVALID
)) &&
2396 if ( executeSSLWarnDialog( rRequest
.Certificate
, SSLWARN_TYPE_INVALID
, rRequest
.HostName
) )
2397 trustCert
= sal_True
;
2399 trustCert
= sal_False
;
2414 switch (executeMessageBox( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dialog1")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dummy dialog")), WB_YES_NO | WB_DEF_YES ))
2416 case ERRCODE_BUTTON_YES:
2430 enum NameClashResolveDialogResult
{ ABORT
, RENAME
, OVERWRITE
};
2432 NameClashResolveDialogResult
2433 executeNameClashResolveDialog(
2434 rtl::OUString
const & /*rTargetFolderURL*/,
2435 rtl::OUString
const & /*rClashingName*/,
2436 rtl::OUString
& /*rProposedNewName*/)
2438 // @@@ Todo DV: execute overwrite-rename dialog, deliver result
2440 "executeNameClashResolveDialog not yet implemented!" );
2444 NameClashResolveDialogResult
2445 executeSimpleNameClashResolveDialog(
2446 rtl::OUString
const & /*rTargetFolderURL*/,
2447 rtl::OUString
const & /*rClashingName*/,
2448 rtl::OUString
& /*rProposedNewName*/)
2450 // @@@ Todo DV: execute rename-only dialog, deliver result
2452 "executeSimpleNameClashResolveDialog not yet implemented!" );
2459 UUIInteractionHelper::handleNameClashResolveRequest(
2460 star::ucb::NameClashResolveRequest
const & rRequest
,
2461 star::uno::Sequence
< star::uno::Reference
<
2462 star::task::XInteractionContinuation
> > const & rContinuations
)
2463 SAL_THROW((star::uno::RuntimeException
))
2466 rRequest
.TargetFolderURL
.getLength() > 0,
2467 "NameClashResolveRequest must not contain empty TargetFolderURL" );
2470 rRequest
.ClashingName
.getLength() > 0,
2471 "NameClashResolveRequest must not contain empty ClashingName" );
2473 star::uno::Reference
< star::task::XInteractionAbort
>
2475 star::uno::Reference
< star::ucb::XInteractionSupplyName
>
2477 star::uno::Reference
< star::ucb::XInteractionReplaceExistingData
>
2478 xReplaceExistingData
;
2481 0, 0, 0, &xAbort
, 0, 0, &xSupplyName
, &xReplaceExistingData
);
2483 OSL_ENSURE( xAbort
.is(),
2484 "NameClashResolveRequest must contain Abort continuation" );
2486 OSL_ENSURE( xSupplyName
.is(),
2487 "NameClashResolveRequest must contain SupplyName continuation" );
2489 NameClashResolveDialogResult eResult
= ABORT
;
2490 rtl::OUString
aProposedNewName( rRequest
.ProposedNewName
);
2491 if ( xReplaceExistingData
.is() )
2492 eResult
= executeNameClashResolveDialog(
2493 rRequest
.TargetFolderURL
,
2494 rRequest
.ClashingName
,
2497 eResult
= executeSimpleNameClashResolveDialog(
2498 rRequest
.TargetFolderURL
,
2499 rRequest
.ClashingName
,
2509 xSupplyName
->setName( aProposedNewName
);
2510 xSupplyName
->select();
2515 xReplaceExistingData
.is(),
2516 "Invalid NameClashResolveDialogResult: OVERWRITE - "
2517 "No ReplaceExistingData continuation available!" );
2518 xReplaceExistingData
->select();
2522 OSL_ENSURE( false, "Unknown NameClashResolveDialogResult value. "
2523 "Interaction Request not handled!" );
2529 UUIInteractionHelper::handleMasterPasswordRequest(
2530 star::task::PasswordRequestMode nMode
,
2531 star::uno::Sequence
< star::uno::Reference
<
2532 star::task::XInteractionContinuation
> > const &
2534 SAL_THROW((star::uno::RuntimeException
))
2536 star::uno::Reference
< star::task::XInteractionRetry
> xRetry
;
2537 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
2538 star::uno::Reference
< star::ucb::XInteractionSupplyAuthentication
>
2539 xSupplyAuthentication
;
2542 0, 0, &xRetry
, &xAbort
, &xSupplyAuthentication
, 0, 0, 0);
2543 LoginErrorInfo aInfo
;
2545 // in case of master password a hash code is returned
2546 executeMasterPasswordDialog(aInfo
, nMode
);
2548 switch (aInfo
.GetResult())
2550 case ERRCODE_BUTTON_OK
:
2551 if (xSupplyAuthentication
.is())
2553 if (xSupplyAuthentication
->canSetPassword())
2554 xSupplyAuthentication
->setPassword(aInfo
.GetPassword());
2555 xSupplyAuthentication
->select();
2559 case ERRCODE_BUTTON_RETRY
:
2572 UUIInteractionHelper::handlePasswordRequest(
2573 star::task::PasswordRequestMode nMode
,
2574 star::uno::Sequence
< star::uno::Reference
<
2575 star::task::XInteractionContinuation
> > const &
2577 ::rtl::OUString aDocumentName
)
2578 SAL_THROW((star::uno::RuntimeException
))
2580 star::uno::Reference
< star::task::XInteractionRetry
> xRetry
;
2581 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
2582 star::uno::Reference
< star::task::XInteractionPassword
>
2585 rContinuations
, 0, 0, &xRetry
, &xAbort
, 0, &xPassword
, 0, 0);
2586 LoginErrorInfo aInfo
;
2588 executePasswordDialog(aInfo
, nMode
, aDocumentName
);
2590 switch (aInfo
.GetResult())
2592 case ERRCODE_BUTTON_OK
:
2595 xPassword
->setPassword(aInfo
.GetPassword());
2596 xPassword
->select();
2600 case ERRCODE_BUTTON_RETRY
:
2613 UUIInteractionHelper::handleMSPasswordRequest(
2614 star::task::PasswordRequestMode nMode
,
2615 star::uno::Sequence
< star::uno::Reference
<
2616 star::task::XInteractionContinuation
> > const &
2618 ::rtl::OUString aDocumentName
)
2619 SAL_THROW((star::uno::RuntimeException
))
2621 star::uno::Reference
< star::task::XInteractionRetry
> xRetry
;
2622 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
2623 star::uno::Reference
< star::task::XInteractionPassword
>
2626 rContinuations
, 0, 0, &xRetry
, &xAbort
, 0, &xPassword
, 0, 0);
2627 LoginErrorInfo aInfo
;
2629 executeMSPasswordDialog(aInfo
, nMode
, aDocumentName
);
2631 switch (aInfo
.GetResult())
2633 case ERRCODE_BUTTON_OK
:
2636 xPassword
->setPassword(aInfo
.GetPassword());
2637 xPassword
->select();
2641 case ERRCODE_BUTTON_RETRY
:
2654 UUIInteractionHelper::handleCookiesRequest(
2655 star::ucb::HandleCookiesRequest
const & rRequest
,
2656 star::uno::Sequence
< star::uno::Reference
<
2657 star::task::XInteractionContinuation
> > const &
2659 SAL_THROW((star::uno::RuntimeException
))
2661 CookieList aCookies
;
2662 for (sal_Int32 i
= 0; i
< rRequest
.Cookies
.getLength(); ++i
)
2666 std::auto_ptr
< CntHTTPCookie
> xCookie(new CntHTTPCookie
);
2667 xCookie
->m_aName
= UniString(rRequest
.Cookies
[i
].Name
);
2668 xCookie
->m_aValue
= UniString(rRequest
.Cookies
[i
].Value
);
2669 xCookie
->m_aDomain
= UniString(rRequest
.Cookies
[i
].Domain
);
2670 xCookie
->m_aPath
= UniString(rRequest
.Cookies
[i
].Path
);
2672 = DateTime(Date(rRequest
.Cookies
[i
].Expires
.Day
,
2673 rRequest
.Cookies
[i
].Expires
.Month
,
2674 rRequest
.Cookies
[i
].Expires
.Year
),
2675 Time(rRequest
.Cookies
[i
].Expires
.Hours
,
2676 rRequest
.Cookies
[i
].Expires
.Minutes
,
2677 rRequest
.Cookies
[i
].Expires
.Seconds
,
2678 rRequest
.Cookies
[i
].Expires
.
2681 = rRequest
.Cookies
[i
].Secure
? CNTHTTP_COOKIE_FLAG_SECURE
: 0;
2682 switch (rRequest
.Cookies
[i
].Policy
)
2684 case star::ucb::CookiePolicy_CONFIRM
:
2685 xCookie
->m_nPolicy
= CNTHTTP_COOKIE_POLICY_INTERACTIVE
;
2688 case star::ucb::CookiePolicy_ACCEPT
:
2689 xCookie
->m_nPolicy
= CNTHTTP_COOKIE_POLICY_ACCEPTED
;
2692 case star::ucb::CookiePolicy_IGNORE
:
2693 xCookie
->m_nPolicy
= CNTHTTP_COOKIE_POLICY_BANNED
;
2700 aCookies
.Insert(xCookie
.get(), LIST_APPEND
);
2703 catch (std::bad_alloc
const &)
2705 throw star::uno::RuntimeException(
2706 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
2708 star::uno::Reference
< star::uno::XInterface
>());
2712 CntHTTPCookieRequest
2713 aRequest(rRequest
.URL
,
2715 rRequest
.Request
== star::ucb::CookieRequest_RECEIVE
?
2716 CNTHTTP_COOKIE_REQUEST_RECV
:
2717 CNTHTTP_COOKIE_REQUEST_SEND
);
2718 executeCookieDialog(aRequest
);
2719 for (sal_Int32 i
= 0; i
< rContinuations
.getLength(); ++i
)
2721 star::uno::Reference
< star::ucb::XInteractionCookieHandling
>
2722 xCookieHandling(rContinuations
[i
], star::uno::UNO_QUERY
);
2723 if (xCookieHandling
.is())
2725 switch (aRequest
.m_nRet
)
2727 case CNTHTTP_COOKIE_POLICY_INTERACTIVE
:
2729 setGeneralPolicy(star::ucb::CookiePolicy_CONFIRM
);
2732 case CNTHTTP_COOKIE_POLICY_ACCEPTED
:
2734 setGeneralPolicy(star::ucb::CookiePolicy_ACCEPT
);
2737 case CNTHTTP_COOKIE_POLICY_BANNED
:
2739 setGeneralPolicy(star::ucb::CookiePolicy_IGNORE
);
2742 for (sal_Int32 j
= 0; j
< rRequest
.Cookies
.getLength(); ++j
)
2743 if (rRequest
.Cookies
[j
].Policy
2744 == star::ucb::CookiePolicy_CONFIRM
)
2745 switch (static_cast< CntHTTPCookie
* >(aCookies
.
2749 case CNTHTTP_COOKIE_POLICY_ACCEPTED
:
2751 setSpecificPolicy(rRequest
.Cookies
[j
], true);
2754 case CNTHTTP_COOKIE_POLICY_BANNED
:
2756 setSpecificPolicy(rRequest
.Cookies
[j
], false);
2759 xCookieHandling
->select();
2766 UUIInteractionHelper::handleNoSuchFilterRequest(
2767 star::document::NoSuchFilterRequest
const & rRequest
,
2768 star::uno::Sequence
<
2769 star::uno::Reference
< star::task::XInteractionContinuation
> > const &
2771 SAL_THROW((star::uno::RuntimeException
))
2773 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
2774 star::uno::Reference
<
2775 star::document::XInteractionFilterSelect
> xFilterTransport
;
2777 sal_Int32 nCount
= rContinuations
.getLength();
2778 for( sal_Int32 nStep
=0; nStep
<nCount
; ++nStep
)
2781 xAbort
= star::uno::Reference
< star::task::XInteractionAbort
>(
2782 rContinuations
[nStep
], star::uno::UNO_QUERY
);
2784 if( ! xFilterTransport
.is() )
2785 xFilterTransport
= star::uno::Reference
<
2786 star::document::XInteractionFilterSelect
>(
2787 rContinuations
[nStep
], star::uno::UNO_QUERY
);
2790 // check neccessary ressources - if they doesn't exist - abort or
2791 // break this operation
2795 if (!xFilterTransport
.is() || !m_xServiceFactory
.is())
2801 star::uno::Reference
< star::container::XContainerQuery
>
2802 xFilterContainer( m_xServiceFactory
->createInstance(
2803 ::rtl::OUString::createFromAscii(
2804 "com.sun.star.document.FilterFactory") ),
2805 star::uno::UNO_QUERY
);
2806 if (!xFilterContainer
.is())
2812 uui::FilterNameList lNames
;
2814 // Note: We look for all filters here which match the following criteria:
2815 // - they are import filters as minimum (of course they can
2816 // support export too)
2817 // - we don't show any filter which are flaged as "don't show it
2818 // at the UI" or "they are not installed"
2819 // - we ignore filters, which have not set any valid
2820 // DocumentService (e.g. our pure graphic filters)
2821 // - we show it sorted by her UIName's
2822 // - We don't use the order flag or prefer default filters.
2823 // (Because this list shows all filters and the user should
2824 // find his filter vry easy by his UIName ...)
2825 // - We use "_query_all" here ... but we filter graphic filters
2826 // out by using DocumentService property later!
2827 star::uno::Reference
< star::container::XEnumeration
> xFilters
2828 = xFilterContainer
->createSubSetEnumerationByQuery(
2829 ::rtl::OUString::createFromAscii(
2830 "_query_all:sort_prop=uiname:iflags=1:eflags=143360"));
2831 while (xFilters
->hasMoreElements())
2835 ::comphelper::SequenceAsHashMap
lProps(xFilters
->nextElement());
2836 uui::FilterNamePair aPair
;
2838 aPair
.sInternal
= lProps
.getUnpackedValueOrDefault(
2839 rtl::OUString::createFromAscii("Name"), ::rtl::OUString());
2840 aPair
.sUI
= lProps
.getUnpackedValueOrDefault(
2841 rtl::OUString::createFromAscii("UIName"), ::rtl::OUString());
2843 (!aPair
.sInternal
.Len()) ||
2849 lNames
.push_back( aPair
);
2851 catch(const star::uno::RuntimeException
&)
2855 catch(const star::uno::Exception
&)
2861 // no list available for showing
2862 // -> abort operation
2863 if (lNames
.size()<1)
2869 // let the user select the right filter
2870 rtl::OUString sSelectedFilter
;
2871 executeFilterDialog( rRequest
.URL
, lNames
, sSelectedFilter
);
2873 // If he doesn't select anyone
2874 // -> abort operation
2875 if (sSelectedFilter
.getLength()<1)
2881 // otherwhise set it for return
2882 xFilterTransport
->setFilter( sSelectedFilter
);
2883 xFilterTransport
->select();
2887 UUIInteractionHelper::handleAmbigousFilterRequest(
2888 star::document::AmbigousFilterRequest
const & rRequest
,
2889 star::uno::Sequence
<
2890 star::uno::Reference
<
2891 star::task::XInteractionContinuation
> > const & rContinuations
)
2892 SAL_THROW((star::uno::RuntimeException
))
2894 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
2895 star::uno::Reference
<
2896 star::document::XInteractionFilterSelect
> xFilterTransport
;
2898 sal_Int32 nCount
= rContinuations
.getLength();
2899 for( sal_Int32 nStep
=0; nStep
<nCount
; ++nStep
)
2902 xAbort
= star::uno::Reference
< star::task::XInteractionAbort
>(
2903 rContinuations
[nStep
], star::uno::UNO_QUERY
);
2905 if( ! xFilterTransport
.is() )
2906 xFilterTransport
= star::uno::Reference
<
2907 star::document::XInteractionFilterSelect
>(
2908 rContinuations
[nStep
], star::uno::UNO_QUERY
);
2911 uui::FilterNameList lNames
;
2913 if( m_xServiceFactory
.is() == sal_True
)
2915 star::uno::Reference
< star::container::XNameContainer
>
2916 xFilterContainer( m_xServiceFactory
->createInstance(
2917 ::rtl::OUString::createFromAscii(
2918 "com.sun.star.document.FilterFactory") ),
2919 star::uno::UNO_QUERY
);
2920 if( xFilterContainer
.is() == sal_True
)
2922 star::uno::Any aPackedSet
;
2923 star::uno::Sequence
< star::beans::PropertyValue
> lProps
;
2925 uui::FilterNamePair aPair
;
2930 = xFilterContainer
->getByName( rRequest
.SelectedFilter
);
2932 catch(const ::com::sun::star::container::NoSuchElementException
&)
2936 aPackedSet
>>= lProps
;
2937 for( nStep
=0; nStep
<lProps
.getLength(); ++nStep
)
2939 if( lProps
[nStep
].Name
.compareToAscii("UIName") == 0 )
2941 ::rtl::OUString sTemp
;
2942 lProps
[nStep
].Value
>>= sTemp
;
2944 aPair
.sInternal
= rRequest
.SelectedFilter
;
2945 lNames
.push_back( aPair
);
2953 = xFilterContainer
->getByName( rRequest
.DetectedFilter
);
2955 catch(const ::com::sun::star::container::NoSuchElementException
&)
2959 aPackedSet
>>= lProps
;
2960 for( nStep
=0; nStep
<lProps
.getLength(); ++nStep
)
2962 if( lProps
[nStep
].Name
.compareToAscii("UIName") == 0 )
2964 ::rtl::OUString sTemp
;
2965 lProps
[nStep
].Value
>>= sTemp
;
2967 aPair
.sInternal
= rRequest
.DetectedFilter
;
2968 lNames
.push_back( aPair
);
2975 if( xAbort
.is() && xFilterTransport
.is() )
2977 if( lNames
.size() < 1 )
2983 rtl::OUString sFilter
;
2984 executeFilterDialog( rRequest
.URL
, lNames
, sFilter
);
2986 if( sFilter
.getLength() > 0 )
2988 xFilterTransport
->setFilter( sFilter
);
2989 xFilterTransport
->select();
2998 UUIInteractionHelper::handleGenericErrorRequest(
2999 sal_Int32 nErrorCode
,
3000 star::uno::Sequence
< star::uno::Reference
<
3001 star::task::XInteractionContinuation
> > const & rContinuations
,
3002 bool bObtainErrorStringOnly
,
3003 bool & bHasErrorString
,
3004 rtl::OUString
& rErrorString
)
3005 SAL_THROW((star::uno::RuntimeException
))
3007 if (bObtainErrorStringOnly
)
3009 bHasErrorString
= isInformationalErrorMessageRequest(rContinuations
);
3010 if (bHasErrorString
)
3012 String aErrorString
;
3013 ErrorHandler::GetErrorString(nErrorCode
, aErrorString
);
3014 rErrorString
= aErrorString
;
3019 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
3020 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
3022 sal_Int32 nCount
= rContinuations
.getLength();
3023 for( sal_Int32 nStep
=0; nStep
<nCount
; ++nStep
)
3027 = star::uno::Reference
< star::task::XInteractionAbort
>(
3028 rContinuations
[nStep
], star::uno::UNO_QUERY
);
3030 if( ! xApprove
.is() )
3032 = star::uno::Reference
< star::task::XInteractionApprove
>(
3033 rContinuations
[nStep
], star::uno::UNO_QUERY
);
3036 // Note: It's important to convert the transported long to the
3037 // required unsigned long value. Otherwhise using as flag field
3039 ErrCode nError
= (ErrCode
)nErrorCode
;
3040 sal_Bool bWarning
= !ERRCODE_TOERROR(nError
);
3042 if ( nError
== ERRCODE_SFX_BROKENSIGNATURE
)
3044 // the broken signature warning needs a special title
3045 String aErrorString
;
3046 ErrorHandler::GetErrorString( nErrorCode
, aErrorString
);
3049 std::auto_ptr
< ResMgr
>
3050 xManager( ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( uui
) ) );
3051 ::rtl::OUString aTitle
;
3055 star::uno::Any aProductNameAny
=
3056 ::utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty(
3057 ::utl::ConfigManager::PRODUCTNAME
);
3058 aProductNameAny
>>= aTitle
;
3059 } catch( star::uno::Exception
& )
3062 ::rtl::OUString aErrTitle
= String( ResId( STR_WARNING_BROKENSIGNATURE_TITLE
, *xManager
.get() ) );
3063 if ( aTitle
.getLength() && aErrTitle
.getLength() )
3064 aTitle
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " - " ) );
3065 aTitle
+= aErrTitle
;
3067 executeMessageBox( aTitle
, aErrorString
, WB_OK
);
3070 ErrorHandler::HandleError(nErrorCode
);
3072 if (xApprove
.is() && bWarning
)
3074 else if (xAbort
.is())
3081 template< class INTERACTION_TYPE
>
3082 bool lcl_findContinuation( const Sequence
< Reference
< XInteractionContinuation
> >& _rContinuations
,
3083 Reference
< INTERACTION_TYPE
>& _rContinuation
)
3085 const Reference
< XInteractionContinuation
>* pContinuation
= _rContinuations
.getConstArray();
3086 const Reference
< XInteractionContinuation
>* pContinuationEnd
= _rContinuations
.getConstArray() + _rContinuations
.getLength();
3087 while ( pContinuation
!= pContinuationEnd
)
3089 if ( _rContinuation
.set( *pContinuation
++, UNO_QUERY
) )
3097 UUIInteractionHelper::handleMacroConfirmRequest(
3098 const star::task::DocumentMacroConfirmationRequest
& _rRequest
,
3099 star::uno::Sequence
< star::uno::Reference
<
3100 star::task::XInteractionContinuation
> > const & rContinuations
3102 SAL_THROW((star::uno::RuntimeException
))
3104 Reference
< XInteractionAbort
> xAbort
; lcl_findContinuation( rContinuations
, xAbort
);
3105 Reference
< XInteractionApprove
> xApprove
; lcl_findContinuation( rContinuations
, xApprove
);
3107 bool bApprove
= false;
3109 std::auto_ptr
< ResMgr
> pResMgr( ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( uui
) ) );
3110 if ( pResMgr
.get() )
3112 bool bShowSignatures
= _rRequest
.DocumentSignatureInformation
.getLength() > 0;
3113 MacroWarning
aWarning( getParentProperty(), bShowSignatures
, *pResMgr
.get() );
3115 aWarning
.SetDocumentURL( _rRequest
.DocumentURL
);
3116 if ( _rRequest
.DocumentSignatureInformation
.getLength() > 1 )
3118 aWarning
.SetStorage( _rRequest
.DocumentStorage
, _rRequest
.DocumentSignatureInformation
);
3120 else if ( _rRequest
.DocumentSignatureInformation
.getLength() == 1 )
3122 aWarning
.SetCertificate( _rRequest
.DocumentSignatureInformation
[ 0 ].Signer
);
3125 bApprove
= aWarning
.Execute() == RET_OK
;
3128 if ( bApprove
&& xApprove
.is() )
3130 else if ( xAbort
.is() )
3135 UUIInteractionHelper::handleFutureDocumentVersionUpdateRequest(
3136 const FutureDocumentVersionProductUpdateRequest
& _rRequest
,
3137 Sequence
< Reference
< XInteractionContinuation
> > const & rContinuations
3139 SAL_THROW((star::uno::RuntimeException
))
3141 Reference
< XInteractionAbort
> xAbort
; lcl_findContinuation( rContinuations
, xAbort
);
3142 Reference
< XInteractionApprove
> xApprove
; lcl_findContinuation( rContinuations
, xApprove
);
3143 Reference
< XInteractionApprove
> xAskLater
; lcl_findContinuation( rContinuations
, xAskLater
);
3145 short nResult
= RET_CANCEL
;
3147 static bool s_bDeferredToNextSession
= false;
3148 // TODO: this static variable is somewhat hacky. Formerly (before the dialog was moved from SFX2 to the
3149 // interaction handler implementation), this was stored in SFX_APP()'s impl structure, in member
3150 // bODFVersionWarningLater. Of course, we do not have access to it here.
3152 // A proper solution which I would envision would be:
3153 // - There's a central implementation (this one here) of css.task.InteractionHandler
3154 // - There's a configuration which maps UNO names to service names
3155 // - If the handler is confronted with a request, it tries to find the name of the UNO structure describing
3156 // the request in the said configuration.
3157 // - If an entry is found, then
3158 // - the respective service is instantiated
3159 // - the component is queried for css.task.XInteractionHandler, and the request is delegated
3160 // - if no entry is found, then the request is silenced (with calling the AbortContinuation, if possible)
3161 // This way, the FutureDocumentVersionProductUpdateRequest could be handled in SFX (or any other
3162 // suitable place), again, and we would only have one place where we remember the s_bDeferredToNextSession
3165 // The side effect (well, actually the more important effect) would be that we do not need to burden
3166 // this central implementation with all interactions which are possible. Instead, separate parts of OOo
3167 // can define/implement different requests. (for instance, everything which today is done in the
3168 // css.sdb.InteractionHandler can then be routed through a "normal" interaction handler, where today we
3169 // always need to tell people to instantiate the SDB-version of the handler, not the normal one.)
3171 if ( !s_bDeferredToNextSession
)
3173 std::auto_ptr
< ResMgr
> pResMgr( ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( uui
) ) );
3174 if ( pResMgr
.get() )
3176 ::uui::NewerVersionWarningDialog
aDialog( getParentProperty(), _rRequest
.DocumentODFVersion
, *pResMgr
.get() );
3177 nResult
= aDialog
.Execute();
3183 case RET_OK
: if ( xApprove
.is() ) xApprove
->select(); break;
3184 case RET_CANCEL
: if ( xAbort
.is() ) xAbort
->select(); break;
3185 case RET_ASK_LATER
: if ( xAskLater
.is() ) xAskLater
->select(); s_bDeferredToNextSession
= true; break;
3187 OSL_ENSURE( false, "UUIInteractionHelper::handleFutureDocumentVersionUpdateRequest: unexpected dialog return value!" );
3193 UUIInteractionHelper::handleFilterOptionsRequest(
3194 star::document::FilterOptionsRequest
const & rRequest
,
3195 star::uno::Sequence
< star::uno::Reference
<
3196 star::task::XInteractionContinuation
> > const & rContinuations
)
3197 SAL_THROW((com::sun::star::uno::RuntimeException
))
3199 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
3200 star::uno::Reference
<
3201 star::document::XInteractionFilterOptions
> xFilterOptions
;
3203 sal_Int32 nCount
= rContinuations
.getLength();
3204 for( sal_Int32 nStep
=0; nStep
<nCount
; ++nStep
)
3207 xAbort
= star::uno::Reference
< star::task::XInteractionAbort
>(
3208 rContinuations
[nStep
], star::uno::UNO_QUERY
);
3210 if( ! xFilterOptions
.is() )
3211 xFilterOptions
= star::uno::Reference
<
3212 star::document::XInteractionFilterOptions
>(
3213 rContinuations
[nStep
], star::uno::UNO_QUERY
);
3216 star::uno::Reference
< star::container::XNameAccess
> xFilterCFG
;
3217 if( m_xServiceFactory
.is() )
3219 xFilterCFG
= star::uno::Reference
< star::container::XNameAccess
>(
3220 m_xServiceFactory
->createInstance(
3221 ::rtl::OUString::createFromAscii(
3222 "com.sun.star.document.FilterFactory" ) ),
3223 star::uno::UNO_QUERY
);
3226 if( xFilterCFG
.is() && rRequest
.rProperties
.getLength() )
3229 ::rtl::OUString aFilterName
;
3230 sal_Int32 nPropCount
= rRequest
.rProperties
.getLength();
3231 for( sal_Int32 ind
= 0; ind
< nPropCount
; ++ind
)
3233 rtl::OUString tmp
= rRequest
.rProperties
[ind
].Name
;
3234 if( rRequest
.rProperties
[ind
].Name
.equals(
3235 ::rtl::OUString::createFromAscii("FilterName")) )
3237 rRequest
.rProperties
[ind
].Value
>>= aFilterName
;
3242 star::uno::Sequence
< star::beans::PropertyValue
> aProps
;
3243 if ( xFilterCFG
->getByName( aFilterName
) >>= aProps
)
3245 sal_Int32 nPropertyCount
= aProps
.getLength();
3246 for( sal_Int32 nProperty
=0;
3247 nProperty
< nPropertyCount
;
3249 if( aProps
[nProperty
].Name
.equals(
3250 ::rtl::OUString::createFromAscii("UIComponent")) )
3252 ::rtl::OUString aServiceName
;
3253 aProps
[nProperty
].Value
>>= aServiceName
;
3254 if( aServiceName
.getLength() )
3256 star::uno::Reference
<
3257 star::ui::dialogs::XExecutableDialog
>
3259 m_xServiceFactory
->createInstance(
3261 star::uno::UNO_QUERY
);
3262 star::uno::Reference
<
3263 star::beans::XPropertyAccess
>
3266 star::uno::UNO_QUERY
);
3268 if( xFilterDialog
.is() && xFilterProperties
.is() )
3270 star::uno::Reference
<
3271 star::document::XImporter
> xImporter(
3273 star::uno::UNO_QUERY
);
3274 if( xImporter
.is() )
3275 xImporter
->setTargetDocument(
3276 star::uno::Reference
<
3277 star::lang::XComponent
>(
3279 star::uno::UNO_QUERY
) );
3281 xFilterProperties
->setPropertyValues(
3282 rRequest
.rProperties
);
3284 if( xFilterDialog
->execute() )
3286 xFilterOptions
->setFilterOptions(
3288 ->getPropertyValues() );
3289 xFilterOptions
->select();
3299 catch( star::container::NoSuchElementException
& )
3301 // the filter name is unknown
3303 catch( star::uno::Exception
& )
3312 UUIInteractionHelper::handleErrorRequest(
3313 star::task::InteractionClassification eClassification
,
3315 std::vector
< rtl::OUString
> const & rArguments
,
3316 star::uno::Sequence
< star::uno::Reference
<
3317 star::task::XInteractionContinuation
> > const & rContinuations
,
3318 bool bObtainErrorStringOnly
,
3319 bool & bHasErrorString
,
3320 rtl::OUString
& rErrorString
)
3321 SAL_THROW((star::uno::RuntimeException
))
3323 rtl::OUString aMessage
;
3325 enum Source
{ SOURCE_DEFAULT
, SOURCE_CNT
, SOURCE_SVX
, SOURCE_UUI
};
3326 static char const * const aManager
[4]
3327 = { CREATEVERSIONRESMGR_NAME(ofa
),
3328 CREATEVERSIONRESMGR_NAME(cnt
),
3329 CREATEVERSIONRESMGR_NAME(svx
),
3330 CREATEVERSIONRESMGR_NAME(uui
) };
3331 static USHORT
const aId
[4]
3333 RID_CHAOS_START
+ 12,
3334 // cf. chaos/source/inc/cntrids.hrc, where
3335 // #define RID_CHAOS_ERRHDL (RID_CHAOS_START + 12)
3336 RID_SVX_START
+ 350, // RID_SVXERRCODE
3338 ErrCode nErrorId
= nErrorCode
& ~ERRCODE_WARNING_MASK
;
3339 Source eSource
= nErrorId
< ERRCODE_AREA_LIB1
?
3341 nErrorId
>= ERRCODE_AREA_CHAOS
3342 && nErrorId
< ERRCODE_AREA_CHAOS_END
?
3344 nErrorId
>= ERRCODE_AREA_SVX
3345 && nErrorId
<= ERRCODE_AREA_SVX_END
?
3349 vos::OGuard
aGuard(Application::GetSolarMutex());
3350 std::auto_ptr
< ResMgr
> xManager
;
3351 xManager
.reset(ResMgr::CreateResMgr(aManager
[eSource
]));
3352 if (!xManager
.get())
3354 ResId
aResId(aId
[eSource
], *xManager
.get());
3355 if (!ErrorResource(aResId
). getString(nErrorCode
, &aMessage
))
3359 aMessage
= replaceMessageWithArguments( aMessage
, rArguments
);
3361 if (bObtainErrorStringOnly
)
3363 bHasErrorString
= isInformationalErrorMessageRequest(rContinuations
);
3364 if (bHasErrorString
)
3365 rErrorString
= aMessage
;
3370 //TODO! It can happen that the buttons calculated below do not match
3371 // the error text from the resource (e.g., some text that is not a
3372 // question, but YES and NO buttons). Some error texts have
3373 // ExtraData that specifies a set of buttons, but that data is not
3374 // really useful, because a single error text may well make sense
3375 // both with only an OK button and with RETRY and CANCEL buttons.
3377 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
3378 star::uno::Reference
< star::task::XInteractionDisapprove
> xDisapprove
;
3379 star::uno::Reference
< star::task::XInteractionRetry
> xRetry
;
3380 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
3383 &xApprove
, &xDisapprove
, &xRetry
, &xAbort
, 0, 0, 0, 0);
3385 // The following mapping uses the bit mask
3391 // The mapping has five properties on which the code to select the
3392 // correct continuation relies:
3393 // 1 The OK button is mapped to Approve if that is available,
3394 // otherwise to Abort if that is available, otherwise to none.
3395 // 2 The CANCEL button is always mapped to Abort.
3396 // 3 The RETRY button is always mapped to Retry.
3397 // 4 The NO button is always mapped to Disapprove.
3398 // 5 The YES button is always mapped to Approve.
3400 // Because the WinBits button combinations are quite restricted, not
3401 // every request can be served here.
3403 // Finally, it seems to be better to leave default button
3404 // determination to VCL (the favouring of CANCEL as default button
3405 // seems to not always be what the user wants)...
3406 WinBits
const aButtonMask
[16]
3408 WB_OK
/*| WB_DEF_OK*/, // Abort
3410 WB_RETRY_CANCEL
/*| WB_DEF_CANCEL*/, // Retry, Abort
3415 WB_OK
/*| WB_DEF_OK*/, // Approve
3416 WB_OK_CANCEL
/*| WB_DEF_CANCEL*/, // Approve, Abort
3419 WB_YES_NO
/*| WB_DEF_NO*/, // Approve, Disapprove
3420 WB_YES_NO_CANCEL
/*| WB_DEF_CANCEL*/,
3421 // Approve, Disapprove, Abort
3425 WinBits nButtonMask
= aButtonMask
[(xApprove
.is() ? 8 : 0)
3426 | (xDisapprove
.is() ? 4 : 0)
3427 | (xRetry
.is() ? 2 : 0)
3428 | (xAbort
.is() ? 1 : 0)];
3429 if (nButtonMask
== 0)
3432 //TODO! remove this backwards compatibility?
3433 rtl::OUString
aContext(getContextProperty());
3434 if (aContext
.getLength() == 0 && nErrorCode
!= 0)
3436 vos::OGuard
aGuard(Application::GetSolarMutex());
3437 ErrorContext
* pContext
= ErrorContext::GetContext();
3440 UniString aContextString
;
3441 if (pContext
->GetString(nErrorCode
, aContextString
))
3442 aContext
= aContextString
;
3446 USHORT nResult
= executeErrorDialog(
3447 eClassification
, aContext
, aMessage
, nButtonMask
);
3450 case ERRCODE_BUTTON_OK
:
3451 OSL_ENSURE(xApprove
.is() || xAbort
.is(), "unexpected situation");
3454 else if (xAbort
.is())
3458 case ERRCODE_BUTTON_CANCEL
:
3459 OSL_ENSURE(xAbort
.is(), "unexpected situation");
3464 case ERRCODE_BUTTON_RETRY
:
3465 OSL_ENSURE(xRetry
.is(), "unexpected situation");
3470 case ERRCODE_BUTTON_NO
:
3471 OSL_ENSURE(xDisapprove
.is(), "unexpected situation");
3472 if (xDisapprove
.is())
3473 xDisapprove
->select();
3476 case ERRCODE_BUTTON_YES
:
3477 OSL_ENSURE(xApprove
.is(), "unexpected situation");
3487 UUIInteractionHelper::handleBrokenPackageRequest(
3488 std::vector
< rtl::OUString
> const & rArguments
,
3489 star::uno::Sequence
< star::uno::Reference
<
3490 star::task::XInteractionContinuation
> > const &
3492 bool bObtainErrorStringOnly
,
3493 bool & bHasErrorString
,
3494 rtl::OUString
& rErrorString
)
3495 SAL_THROW((star::uno::RuntimeException
))
3497 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
3498 star::uno::Reference
< star::task::XInteractionDisapprove
> xDisapprove
;
3499 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
3501 rContinuations
, &xApprove
, &xDisapprove
, 0, &xAbort
, 0, 0, 0, 0);
3504 if( xApprove
.is() && xDisapprove
.is() )
3506 nErrorCode
= ERRCODE_UUI_IO_BROKENPACKAGE
;
3508 else if ( xAbort
.is() )
3510 nErrorCode
= ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR
;
3515 ::rtl::OUString aMessage
;
3517 vos::OGuard
aGuard(Application::GetSolarMutex());
3518 std::auto_ptr
< ResMgr
> xManager(
3519 ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
3520 if (!xManager
.get())
3523 ResId
aResId( RID_UUI_ERRHDL
, *xManager
.get() );
3524 if ( !ErrorResource(aResId
).getString(nErrorCode
, &aMessage
) )
3528 aMessage
= replaceMessageWithArguments( aMessage
, rArguments
);
3530 if (bObtainErrorStringOnly
)
3532 bHasErrorString
= isInformationalErrorMessageRequest(rContinuations
);
3533 if (bHasErrorString
)
3534 rErrorString
= aMessage
;
3539 WinBits nButtonMask
;
3540 if( xApprove
.is() && xDisapprove
.is() )
3542 nButtonMask
= WB_YES_NO
| WB_DEF_YES
;
3544 else if ( xAbort
.is() )
3546 nButtonMask
= WB_OK
;
3551 star::uno::Any aProductNameAny
=
3552 ::utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty(
3553 ::utl::ConfigManager::PRODUCTNAME
);
3554 star::uno::Any aProductVersionAny
=
3555 ::utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty(
3556 ::utl::ConfigManager::PRODUCTVERSION
);
3557 ::rtl::OUString aProductName
, aProductVersion
;
3558 if ( !( aProductNameAny
>>= aProductName
) )
3560 = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StarOffice") );
3562 ::rtl::OUString
aTitle( aProductName
);
3563 if( aProductVersionAny
>>= aProductVersion
)
3565 aTitle
+= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" ") );
3566 aTitle
+= aProductVersion
;
3569 switch ( executeMessageBox( aTitle
, aMessage
, nButtonMask
))
3571 case ERRCODE_BUTTON_OK
:
3572 OSL_ENSURE( xAbort
.is(), "unexpected situation" );
3577 case ERRCODE_BUTTON_NO
:
3578 OSL_ENSURE(xDisapprove
.is(), "unexpected situation");
3579 if (xDisapprove
.is())
3580 xDisapprove
->select();
3583 case ERRCODE_BUTTON_YES
:
3584 OSL_ENSURE(xApprove
.is(), "unexpected situation");
3593 UUIInteractionHelper::handleLockedDocumentRequest(
3594 const ::rtl::OUString
& aDocumentURL
,
3595 const ::rtl::OUString
& aInfo
,
3596 star::uno::Sequence
< star::uno::Reference
<
3597 star::task::XInteractionContinuation
> > const &
3600 SAL_THROW((star::uno::RuntimeException
))
3602 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
3603 star::uno::Reference
< star::task::XInteractionDisapprove
> xDisapprove
;
3604 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
3606 rContinuations
, &xApprove
, &xDisapprove
, 0, &xAbort
, 0, 0, 0, 0);
3608 if ( !xApprove
.is() || !xDisapprove
.is() || !xAbort
.is() )
3613 vos::OGuard
aGuard(Application::GetSolarMutex());
3614 std::auto_ptr
< ResMgr
> xManager(
3615 ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
3616 if (!xManager
.get())
3619 ::rtl::OUString aMessage
;
3620 std::vector
< rtl::OUString
> aArguments
;
3621 aArguments
.push_back( aDocumentURL
);
3623 sal_Int32 nResult
= RET_CANCEL
;
3624 if ( nMode
== UUI_DOC_LOAD_LOCK
)
3626 aArguments
.push_back( aInfo
.getLength()
3628 : ::rtl::OUString( String( ResId( STR_UNKNOWNUSER
, *xManager
.get() ) ) ) );
3629 aMessage
= String( ResId( STR_OPENLOCKED_MSG
, *xManager
.get() ) );
3630 aMessage
= replaceMessageWithArguments( aMessage
, aArguments
);
3632 std::auto_ptr
< OpenLockedQueryBox
> xDialog(new OpenLockedQueryBox(
3633 getParentProperty(), xManager
.get(), aMessage
) );
3634 nResult
= xDialog
->Execute();
3636 else if ( nMode
== UUI_DOC_SAVE_LOCK
)
3638 aArguments
.push_back( aInfo
.getLength()
3640 : ::rtl::OUString( String( ResId( STR_UNKNOWNUSER
, *xManager
.get() ) ) ) );
3641 aMessage
= String( ResId( STR_TRYLATER_MSG
, *xManager
.get() ) );
3642 aMessage
= replaceMessageWithArguments( aMessage
, aArguments
);
3644 std::auto_ptr
< TryLaterQueryBox
> xDialog(new TryLaterQueryBox(
3645 getParentProperty(), xManager
.get(), aMessage
) );
3646 nResult
= xDialog
->Execute();
3648 else if ( nMode
== UUI_DOC_OWN_LOAD_LOCK
|| nMode
== UUI_DOC_OWN_SAVE_LOCK
)
3650 aArguments
.push_back( aInfo
);
3651 aMessage
= String( ResId( nMode
== UUI_DOC_OWN_SAVE_LOCK
? STR_ALREADYOPEN_SAVE_MSG
: STR_ALREADYOPEN_MSG
, *xManager
.get() ) );
3652 aMessage
= replaceMessageWithArguments( aMessage
, aArguments
);
3654 std::auto_ptr
< AlreadyOpenQueryBox
> xDialog(new AlreadyOpenQueryBox(
3655 getParentProperty(), xManager
.get(), aMessage
, nMode
== UUI_DOC_OWN_SAVE_LOCK
) );
3656 nResult
= xDialog
->Execute();
3659 if ( nResult
== RET_YES
)
3661 else if ( nResult
== RET_NO
)
3662 xDisapprove
->select();
3666 catch (std::bad_alloc
const &)
3668 throw star::uno::RuntimeException(
3669 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
3670 star::uno::Reference
< star::uno::XInterface
>());
3675 UUIInteractionHelper::handleChangedByOthersRequest(
3676 star::uno::Sequence
< star::uno::Reference
<
3677 star::task::XInteractionContinuation
> > const &
3679 SAL_THROW((star::uno::RuntimeException
))
3681 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
3682 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
3684 rContinuations
, &xApprove
, 0, 0, &xAbort
, 0, 0, 0, 0);
3686 if ( !xApprove
.is() || !xAbort
.is() )
3691 vos::OGuard
aGuard(Application::GetSolarMutex());
3692 std::auto_ptr
< ResMgr
> xManager(
3693 ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
3694 if (!xManager
.get())
3697 std::auto_ptr
< FileChangedQueryBox
> xDialog(new FileChangedQueryBox(
3698 getParentProperty(), xManager
.get() ) );
3699 sal_Int32 nResult
= xDialog
->Execute();
3701 if ( nResult
== RET_YES
)
3706 catch (std::bad_alloc
const &)
3708 throw star::uno::RuntimeException(
3709 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
3710 star::uno::Reference
< star::uno::XInterface
>());
3715 UUIInteractionHelper::handleLockFileIgnoreRequest(
3716 star::uno::Sequence
< star::uno::Reference
<
3717 star::task::XInteractionContinuation
> > const &
3719 SAL_THROW((star::uno::RuntimeException
))
3721 star::uno::Reference
< star::task::XInteractionApprove
> xApprove
;
3722 star::uno::Reference
< star::task::XInteractionAbort
> xAbort
;
3724 rContinuations
, &xApprove
, 0, 0, &xAbort
, 0, 0, 0, 0);
3726 if ( !xApprove
.is() || !xAbort
.is() )
3731 vos::OGuard
aGuard(Application::GetSolarMutex());
3732 std::auto_ptr
< ResMgr
> xManager(
3733 ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui
)));
3734 if (!xManager
.get())
3737 std::auto_ptr
< LockFailedQueryBox
> xDialog(new LockFailedQueryBox(
3738 getParentProperty(), xManager
.get() ) );
3739 sal_Int32 nResult
= xDialog
->Execute();
3741 if ( nResult
== RET_OK
)
3746 catch (std::bad_alloc
const &)
3748 throw star::uno::RuntimeException(
3749 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
3750 star::uno::Reference
< star::uno::XInterface
>());