LCOV - code coverage report
Current view: top level - fpicker/source/office - fpinteraction.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 55 0.0 %
Date: 2014-11-03 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "fpinteraction.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include <com/sun/star/ucb/InteractiveIOException.hpp>
      23             : #include <com/sun/star/task/XInteractionAbort.hpp>
      24             : #include <com/sun/star/task/XInteractionApprove.hpp>
      25             : #include <com/sun/star/task/XInteractionDisapprove.hpp>
      26             : #include <com/sun/star/task/XInteractionRetry.hpp>
      27             : 
      28             : 
      29             : namespace svt
      30             : {
      31             : 
      32             :     using namespace ::com::sun::star::uno;
      33             :     using namespace ::com::sun::star::task;
      34             :     using namespace ::com::sun::star::ucb;
      35             : 
      36           0 :     OFilePickerInteractionHandler::OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxMaster )
      37             :         :m_xMaster( _rxMaster )
      38             :         ,m_bUsed( false )
      39           0 :         ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION )
      40             :     {
      41             :         DBG_ASSERT( m_xMaster.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
      42           0 :     }
      43             : 
      44             : 
      45           0 :     OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
      46             :     {
      47           0 :     }
      48             : 
      49             : 
      50           0 :     void SAL_CALL OFilePickerInteractionHandler::handle( const Reference< XInteractionRequest >& _rxRequest ) throw (RuntimeException, std::exception)
      51             :     {
      52           0 :         if (!_rxRequest.is())
      53           0 :             return;
      54             : 
      55           0 :         m_bUsed = true;
      56             : 
      57             :         // extract some generic continuations ... might we need it later
      58             :         // if something goes wrong.
      59           0 :         Reference< XInteractionAbort >       xAbort;
      60           0 :         Reference< XInteractionApprove >     xApprove;
      61           0 :         Reference< XInteractionDisapprove >  xDisapprove;
      62           0 :         Reference< XInteractionRetry >       xRetry;
      63             : 
      64           0 :         const Sequence< Reference< XInteractionContinuation > > lConts = _rxRequest->getContinuations();
      65           0 :         const Reference< XInteractionContinuation >*            pConts = lConts.getConstArray();
      66           0 :         for (sal_Int32 i=0; i<lConts.getLength(); ++i)
      67             :         {
      68           0 :             if (!xAbort.is())
      69           0 :                 xAbort = Reference< XInteractionAbort >(pConts[i], UNO_QUERY);
      70           0 :             if (!xApprove.is())
      71           0 :                 xApprove = Reference< XInteractionApprove >(pConts[i], UNO_QUERY);
      72           0 :             if (!xDisapprove.is())
      73           0 :                 xDisapprove = Reference< XInteractionDisapprove >(pConts[i], UNO_QUERY);
      74           0 :             if (!xRetry.is())
      75           0 :                 xRetry = Reference< XInteractionRetry >(pConts[i], UNO_QUERY);
      76             :         }
      77             : 
      78             :         // safe the original request for later analyzing!
      79           0 :         m_aException = _rxRequest->getRequest();
      80             : 
      81             :         // intercept some interesting interactions
      82             : 
      83             :         // The "does not exist" interaction will be suppressed here completely.
      84           0 :         if (m_eInterceptions & OFilePickerInteractionHandler::E_DOESNOTEXIST)
      85             :         {
      86           0 :             InteractiveIOException aIoException;
      87           0 :             if (
      88           0 :                 (m_aException             >>= aIoException     ) &&
      89           0 :                 (IOErrorCode_NOT_EXISTING  == aIoException.Code)
      90             :                )
      91             :             {
      92           0 :                 if (xAbort.is())
      93           0 :                     xAbort->select();
      94           0 :                 return;
      95           0 :             }
      96             :         }
      97             : 
      98             :         // no master => abort this operation ...
      99           0 :         if (!m_xMaster.is())
     100             :         {
     101           0 :             if (xAbort.is())
     102           0 :                 xAbort->select();
     103           0 :             return;
     104             :         }
     105             : 
     106             :         // forward it to our master - so he can handle all
     107             :         // not interesting interactions :-)
     108           0 :         m_xMaster->handle(_rxRequest);
     109             :     }
     110             : 
     111             : 
     112           0 :     void OFilePickerInteractionHandler::enableInterceptions( EInterceptedInteractions eInterceptions )
     113             :     {
     114           0 :         m_eInterceptions = eInterceptions;
     115           0 :     }
     116             : 
     117             : 
     118             : 
     119             : 
     120           0 :     void OFilePickerInteractionHandler::resetUseState()
     121             :     {
     122           0 :         m_bUsed = false;
     123           0 :     }
     124             : 
     125             : 
     126           0 :     void OFilePickerInteractionHandler::forgetRequest()
     127             :     {
     128           0 :         m_aException = Any();
     129           0 :     }
     130             : 
     131             : 
     132           0 :     bool OFilePickerInteractionHandler::wasAccessDenied() const
     133             :     {
     134           0 :         InteractiveIOException aIoException;
     135           0 :         if (
     136           0 :             (m_aException              >>= aIoException     ) &&
     137           0 :             (IOErrorCode_ACCESS_DENIED  == aIoException.Code)
     138             :            )
     139             :         {
     140           0 :             return true;
     141             :         }
     142           0 :         return false;
     143             :     }
     144             : 
     145             : 
     146             : }   // namespace svt
     147             : 
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10