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: fpinteraction.cxx,v $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_fpicker.hxx"
33 #include "fpinteraction.hxx"
34 #include <tools/debug.hxx>
35 #include <com/sun/star/ucb/InteractiveIOException.hpp>
36 #include <com/sun/star/task/XInteractionAbort.hpp>
37 #include <com/sun/star/task/XInteractionApprove.hpp>
38 #include <com/sun/star/task/XInteractionDisapprove.hpp>
39 #include <com/sun/star/task/XInteractionRetry.hpp>
41 //........................................................................
44 //........................................................................
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::task
;
47 using namespace ::com::sun::star::ucb
;
49 //====================================================================
50 //= OFilePickerInteractionHandler
51 //====================================================================
52 DBG_NAME( OFilePickerInteractionHandler
)
53 //--------------------------------------------------------------------
54 OFilePickerInteractionHandler::OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference
< ::com::sun::star::task::XInteractionHandler
>& _rxMaster
)
55 :m_xMaster( _rxMaster
)
57 ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION
)
59 DBG_CTOR( OFilePickerInteractionHandler
, NULL
);
60 DBG_ASSERT( m_xMaster
.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
63 //--------------------------------------------------------------------
64 OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
66 DBG_DTOR( OFilePickerInteractionHandler
, NULL
);
69 //--------------------------------------------------------------------
70 void SAL_CALL
OFilePickerInteractionHandler::handle( const Reference
< XInteractionRequest
>& _rxRequest
) throw (RuntimeException
)
77 // extract some generic continuations ... might we need it later
78 // if something goes wrong.
79 Reference
< XInteractionAbort
> xAbort
;
80 Reference
< XInteractionApprove
> xApprove
;
81 Reference
< XInteractionDisapprove
> xDisapprove
;
82 Reference
< XInteractionRetry
> xRetry
;
84 const Sequence
< Reference
< XInteractionContinuation
> > lConts
= _rxRequest
->getContinuations();
85 const Reference
< XInteractionContinuation
>* pConts
= lConts
.getConstArray();
86 for (sal_Int32 i
=0; i
<lConts
.getLength(); ++i
)
89 xAbort
= Reference
< XInteractionAbort
>(pConts
[i
], UNO_QUERY
);
91 xApprove
= Reference
< XInteractionApprove
>(pConts
[i
], UNO_QUERY
);
92 if (!xDisapprove
.is())
93 xDisapprove
= Reference
< XInteractionDisapprove
>(pConts
[i
], UNO_QUERY
);
95 xRetry
= Reference
< XInteractionRetry
>(pConts
[i
], UNO_QUERY
);
98 // safe the original request for later analyzing!
99 m_aException
= _rxRequest
->getRequest();
101 // intercept some interesting interactions
103 // The "does not exist" interaction will be supressed here completly.
104 if (m_eInterceptions
& OFilePickerInteractionHandler::E_DOESNOTEXIST
)
106 InteractiveIOException aIoException
;
108 (m_aException
>>= aIoException
) &&
109 (IOErrorCode_NOT_EXISTING
== aIoException
.Code
)
118 // no master => abort this operation ...
126 // forward it to our master - so he can handle all
127 // not interesting interactions :-)
128 m_xMaster
->handle(_rxRequest
);
131 //--------------------------------------------------------------------
132 void OFilePickerInteractionHandler::enableInterceptions( EInterceptedInteractions eInterceptions
)
134 m_eInterceptions
= eInterceptions
;
137 //--------------------------------------------------------------------
138 sal_Bool
OFilePickerInteractionHandler::wasUsed() const
143 //--------------------------------------------------------------------
144 void OFilePickerInteractionHandler::resetUseState()
149 //--------------------------------------------------------------------
150 void OFilePickerInteractionHandler::forgetRequest()
152 m_aException
= Any();
155 //--------------------------------------------------------------------
156 sal_Bool
OFilePickerInteractionHandler::wasAccessDenied() const
158 InteractiveIOException aIoException
;
160 (m_aException
>>= aIoException
) &&
161 (IOErrorCode_ACCESS_DENIED
== aIoException
.Code
)
169 //........................................................................
171 //........................................................................