Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / fpicker / source / office / fpinteraction.cxx
blob9d3591d7586b8fe7c45f1956b1a2d9bc5cbc3739
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include <utility>
31 namespace svt
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::task;
36 using namespace ::com::sun::star::ucb;
38 OFilePickerInteractionHandler::OFilePickerInteractionHandler( css::uno::Reference< css::task::XInteractionHandler > _xMaster )
39 :m_xMaster(std::move( _xMaster ))
40 ,m_bUsed( false )
41 ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION )
43 SAL_WARN_IF( !m_xMaster.is(), "fpicker.office", "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
47 OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
52 void SAL_CALL OFilePickerInteractionHandler::handle( const Reference< XInteractionRequest >& _rxRequest )
54 if (!_rxRequest.is())
55 return;
57 m_bUsed = true;
59 // extract some generic continuations ... might we need it later
60 // if something goes wrong.
61 Reference< XInteractionAbort > xAbort;
62 Reference< XInteractionApprove > xApprove;
63 Reference< XInteractionDisapprove > xDisapprove;
64 Reference< XInteractionRetry > xRetry;
66 const Sequence< Reference< XInteractionContinuation > > lConts = _rxRequest->getContinuations();
67 for (const Reference< XInteractionContinuation >& rCont : lConts)
69 if (!xAbort.is())
70 xAbort.set(rCont, UNO_QUERY);
71 if (!xApprove.is())
72 xApprove.set(rCont, UNO_QUERY);
73 if (!xDisapprove.is())
74 xDisapprove.set(rCont, UNO_QUERY);
75 if (!xRetry.is())
76 xRetry.set(rCont, 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;
88 if (
89 (m_aException >>= aIoException ) &&
90 (IOErrorCode_NOT_EXISTING == aIoException.Code)
93 if (xAbort.is())
94 xAbort->select();
95 return;
99 // no master => abort this operation ...
100 if (!m_xMaster.is())
102 if (xAbort.is())
103 xAbort->select();
104 return;
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()
121 m_bUsed = false;
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);
139 } // namespace svt
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */