1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "fpinteraction.hxx"
21 #include <com/sun/star/ucb/InteractiveIOException.hpp>
22 #include <com/sun/star/task/XInteractionAbort.hpp>
23 #include <com/sun/star/task/XInteractionApprove.hpp>
24 #include <com/sun/star/task/XInteractionDisapprove.hpp>
25 #include <com/sun/star/task/XInteractionRetry.hpp>
27 #include <sal/log.hxx>
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::task
;
35 using namespace ::com::sun::star::ucb
;
37 OFilePickerInteractionHandler::OFilePickerInteractionHandler( const css::uno::Reference
< css::task::XInteractionHandler
>& _rxMaster
)
38 :m_xMaster( _rxMaster
)
40 ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION
)
42 SAL_WARN_IF( !m_xMaster
.is(), "fpicker.office", "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
46 OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
51 void SAL_CALL
OFilePickerInteractionHandler::handle( const Reference
< XInteractionRequest
>& _rxRequest
)
58 // extract some generic continuations ... might we need it later
59 // if something goes wrong.
60 Reference
< XInteractionAbort
> xAbort
;
61 Reference
< XInteractionApprove
> xApprove
;
62 Reference
< XInteractionDisapprove
> xDisapprove
;
63 Reference
< XInteractionRetry
> xRetry
;
65 const Sequence
< Reference
< XInteractionContinuation
> > lConts
= _rxRequest
->getContinuations();
66 const Reference
< XInteractionContinuation
>* pConts
= lConts
.getConstArray();
67 for (sal_Int32 i
=0; i
<lConts
.getLength(); ++i
)
70 xAbort
.set(pConts
[i
], UNO_QUERY
);
72 xApprove
.set(pConts
[i
], UNO_QUERY
);
73 if (!xDisapprove
.is())
74 xDisapprove
.set(pConts
[i
], UNO_QUERY
);
76 xRetry
.set(pConts
[i
], UNO_QUERY
);
79 // safe the original request for later analyzing!
80 m_aException
= _rxRequest
->getRequest();
82 // intercept some interesting interactions
84 // The "does not exist" interaction will be suppressed here completely.
85 if (m_eInterceptions
& OFilePickerInteractionHandler::E_DOESNOTEXIST
)
87 InteractiveIOException aIoException
;
89 (m_aException
>>= aIoException
) &&
90 (IOErrorCode_NOT_EXISTING
== aIoException
.Code
)
99 // no master => abort this operation ...
107 // forward it to our master - so he can handle all
108 // not interesting interactions :-)
109 m_xMaster
->handle(_rxRequest
);
113 void OFilePickerInteractionHandler::enableInterceptions( EInterceptedInteractions eInterceptions
)
115 m_eInterceptions
= eInterceptions
;
119 void OFilePickerInteractionHandler::resetUseState()
125 void OFilePickerInteractionHandler::forgetRequest()
127 m_aException
= Any();
131 bool OFilePickerInteractionHandler::wasAccessDenied() const
133 InteractiveIOException aIoException
;
134 return (m_aException
>>= aIoException
) &&
135 (IOErrorCode_ACCESS_DENIED
== aIoException
.Code
);
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */