LCOV - code coverage report
Current view: top level - libreoffice/fpicker/source/office - fpinteraction.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 52 0.0 %
Date: 2012-12-27 Functions: 0 9 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             :     //====================================================================
      37             :     //= OFilePickerInteractionHandler
      38             :     //====================================================================
      39             :     DBG_NAME( OFilePickerInteractionHandler )
      40             :     //--------------------------------------------------------------------
      41           0 :     OFilePickerInteractionHandler::OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxMaster )
      42             :         :m_xMaster( _rxMaster )
      43             :         ,m_bUsed( sal_False )
      44           0 :         ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION )
      45             :     {
      46             :         DBG_CTOR( OFilePickerInteractionHandler, NULL );
      47             :         DBG_ASSERT( m_xMaster.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
      48           0 :     }
      49             : 
      50             :     //--------------------------------------------------------------------
      51           0 :     OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
      52             :     {
      53             :         DBG_DTOR( OFilePickerInteractionHandler, NULL );
      54           0 :     }
      55             : 
      56             :     //--------------------------------------------------------------------
      57           0 :     void SAL_CALL OFilePickerInteractionHandler::handle( const Reference< XInteractionRequest >& _rxRequest ) throw (RuntimeException)
      58             :     {
      59           0 :         if (!_rxRequest.is())
      60             :             return;
      61             : 
      62           0 :         m_bUsed = sal_True;
      63             : 
      64             :         // extract some generic continuations ... might we need it later
      65             :         // if something goes wrong.
      66           0 :         Reference< XInteractionAbort >       xAbort;
      67           0 :         Reference< XInteractionApprove >     xApprove;
      68           0 :         Reference< XInteractionDisapprove >  xDisapprove;
      69           0 :         Reference< XInteractionRetry >       xRetry;
      70             : 
      71           0 :         const Sequence< Reference< XInteractionContinuation > > lConts = _rxRequest->getContinuations();
      72           0 :         const Reference< XInteractionContinuation >*            pConts = lConts.getConstArray();
      73           0 :         for (sal_Int32 i=0; i<lConts.getLength(); ++i)
      74             :         {
      75           0 :             if (!xAbort.is())
      76           0 :                 xAbort = Reference< XInteractionAbort >(pConts[i], UNO_QUERY);
      77           0 :             if (!xApprove.is())
      78           0 :                 xApprove = Reference< XInteractionApprove >(pConts[i], UNO_QUERY);
      79           0 :             if (!xDisapprove.is())
      80           0 :                 xDisapprove = Reference< XInteractionDisapprove >(pConts[i], UNO_QUERY);
      81           0 :             if (!xRetry.is())
      82           0 :                 xRetry = Reference< XInteractionRetry >(pConts[i], UNO_QUERY);
      83             :         }
      84             : 
      85             :         // safe the original request for later analyzing!
      86           0 :         m_aException = _rxRequest->getRequest();
      87             : 
      88             :         // intercept some interesting interactions
      89             : 
      90             :         // The "does not exist" interaction will be supressed here completly.
      91           0 :         if (m_eInterceptions & OFilePickerInteractionHandler::E_DOESNOTEXIST)
      92             :         {
      93           0 :             InteractiveIOException aIoException;
      94           0 :             if (
      95           0 :                 (m_aException             >>= aIoException     ) &&
      96             :                 (IOErrorCode_NOT_EXISTING  == aIoException.Code)
      97             :                )
      98             :             {
      99           0 :                 if (xAbort.is())
     100           0 :                     xAbort->select();
     101             :                 return;
     102           0 :             }
     103             :         }
     104             : 
     105             :         // no master => abort this operation ...
     106           0 :         if (!m_xMaster.is())
     107             :         {
     108           0 :             if (xAbort.is())
     109           0 :                 xAbort->select();
     110             :             return;
     111             :         }
     112             : 
     113             :         // forward it to our master - so he can handle all
     114             :         // not interesting interactions :-)
     115           0 :         m_xMaster->handle(_rxRequest);
     116             :     }
     117             : 
     118             :     //--------------------------------------------------------------------
     119           0 :     void OFilePickerInteractionHandler::enableInterceptions( EInterceptedInteractions eInterceptions )
     120             :     {
     121           0 :         m_eInterceptions = eInterceptions;
     122           0 :     }
     123             : 
     124             :     //--------------------------------------------------------------------
     125           0 :     sal_Bool OFilePickerInteractionHandler::wasUsed() const
     126             :     {
     127           0 :         return m_bUsed;
     128             :     }
     129             : 
     130             :     //--------------------------------------------------------------------
     131           0 :     void OFilePickerInteractionHandler::resetUseState()
     132             :     {
     133           0 :         m_bUsed = sal_False;
     134           0 :     }
     135             : 
     136             :     //--------------------------------------------------------------------
     137           0 :     void OFilePickerInteractionHandler::forgetRequest()
     138             :     {
     139           0 :         m_aException = Any();
     140           0 :     }
     141             : 
     142             :     //--------------------------------------------------------------------
     143           0 :     sal_Bool OFilePickerInteractionHandler::wasAccessDenied() const
     144             :     {
     145           0 :         InteractiveIOException aIoException;
     146           0 :         if (
     147           0 :             (m_aException              >>= aIoException     ) &&
     148             :             (IOErrorCode_ACCESS_DENIED  == aIoException.Code)
     149             :            )
     150             :         {
     151           0 :             return sal_True;
     152             :         }
     153           0 :         return sal_False;
     154             :     }
     155             : 
     156             : //........................................................................
     157             : }   // namespace svt
     158             : //........................................................................
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10