1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_fpicker.hxx"
30 #include "fpinteraction.hxx"
31 #include <tools/debug.hxx>
32 #include <com/sun/star/ucb/InteractiveIOException.hpp>
33 #include <com/sun/star/task/XInteractionAbort.hpp>
34 #include <com/sun/star/task/XInteractionApprove.hpp>
35 #include <com/sun/star/task/XInteractionDisapprove.hpp>
36 #include <com/sun/star/task/XInteractionRetry.hpp>
38 //........................................................................
41 //........................................................................
42 using namespace ::com::sun::star::uno
;
43 using namespace ::com::sun::star::task
;
44 using namespace ::com::sun::star::ucb
;
46 //====================================================================
47 //= OFilePickerInteractionHandler
48 //====================================================================
49 DBG_NAME( OFilePickerInteractionHandler
)
50 //--------------------------------------------------------------------
51 OFilePickerInteractionHandler::OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionHandler
>& _rxMaster
)
52 :m_xMaster( _rxMaster
)
54 ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION
)
56 DBG_CTOR( OFilePickerInteractionHandler
, NULL
);
57 DBG_ASSERT( m_xMaster
.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
60 //--------------------------------------------------------------------
61 OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
63 DBG_DTOR( OFilePickerInteractionHandler
, NULL
);
66 //--------------------------------------------------------------------
67 void SAL_CALL
OFilePickerInteractionHandler::handle( const Reference
< XInteractionRequest
>& _rxRequest
) throw (RuntimeException
)
74 // extract some generic continuations ... might we need it later
75 // if something goes wrong.
76 Reference
< XInteractionAbort
> xAbort
;
77 Reference
< XInteractionApprove
> xApprove
;
78 Reference
< XInteractionDisapprove
> xDisapprove
;
79 Reference
< XInteractionRetry
> xRetry
;
81 const Sequence
< Reference
< XInteractionContinuation
> > lConts
= _rxRequest
->getContinuations();
82 const Reference
< XInteractionContinuation
>* pConts
= lConts
.getConstArray();
83 for (sal_Int32 i
=0; i
<lConts
.getLength(); ++i
)
86 xAbort
= Reference
< XInteractionAbort
>(pConts
[i
], UNO_QUERY
);
88 xApprove
= Reference
< XInteractionApprove
>(pConts
[i
], UNO_QUERY
);
89 if (!xDisapprove
.is())
90 xDisapprove
= Reference
< XInteractionDisapprove
>(pConts
[i
], UNO_QUERY
);
92 xRetry
= Reference
< XInteractionRetry
>(pConts
[i
], UNO_QUERY
);
95 // safe the original request for later analyzing!
96 m_aException
= _rxRequest
->getRequest();
98 // intercept some interesting interactions
100 // The "does not exist" interaction will be supressed here completly.
101 if (m_eInterceptions
& OFilePickerInteractionHandler::E_DOESNOTEXIST
)
103 InteractiveIOException aIoException
;
105 (m_aException
>>= aIoException
) &&
106 (IOErrorCode_NOT_EXISTING
== aIoException
.Code
)
115 // no master => abort this operation ...
123 // forward it to our master - so he can handle all
124 // not interesting interactions :-)
125 m_xMaster
->handle(_rxRequest
);
128 //--------------------------------------------------------------------
129 void OFilePickerInteractionHandler::enableInterceptions( EInterceptedInteractions eInterceptions
)
131 m_eInterceptions
= eInterceptions
;
134 //--------------------------------------------------------------------
135 sal_Bool
OFilePickerInteractionHandler::wasUsed() const
140 //--------------------------------------------------------------------
141 void OFilePickerInteractionHandler::resetUseState()
146 //--------------------------------------------------------------------
147 void OFilePickerInteractionHandler::forgetRequest()
149 m_aException
= Any();
152 //--------------------------------------------------------------------
153 sal_Bool
OFilePickerInteractionHandler::wasAccessDenied() const
155 InteractiveIOException aIoException
;
157 (m_aException
>>= aIoException
) &&
158 (IOErrorCode_ACCESS_DENIED
== aIoException
.Code
)
166 //........................................................................
168 //........................................................................