LCOV - code coverage report
Current view: top level - framework/source/interaction - quietinteraction.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 53 0.0 %
Date: 2014-04-14 Functions: 0 4 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 "interaction/quietinteraction.hxx"
      21             : 
      22             : #include <macros/generic.hxx>
      23             : 
      24             : #include <com/sun/star/task/XInteractionAbort.hpp>
      25             : #include <com/sun/star/task/XInteractionApprove.hpp>
      26             : #include <com/sun/star/document/XInteractionFilterSelect.hpp>
      27             : #include <com/sun/star/document/XInteractionFilterOptions.hpp>
      28             : #include <com/sun/star/document/AmbigousFilterRequest.hpp>
      29             : #include <com/sun/star/document/FilterOptionsRequest.hpp>
      30             : #include <com/sun/star/task/ErrorCodeRequest.hpp>
      31             : 
      32             : #include <com/sun/star/document/LockedDocumentRequest.hpp>
      33             : 
      34             : #include <vcl/svapp.hxx>
      35             : 
      36             : #ifndef __RSC
      37             : #include <tools/errinf.hxx>
      38             : #endif
      39             : 
      40             : namespace framework{
      41             : 
      42           0 : QuietInteraction::QuietInteraction()
      43           0 :     : m_aRequest         (                               )
      44             : {
      45           0 : }
      46             : 
      47           0 : void SAL_CALL QuietInteraction::handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException, std::exception )
      48             : {
      49             :     // safe the request for outside analyzing everytime!
      50           0 :     css::uno::Any aRequest = xRequest->getRequest();
      51             :     {
      52           0 :         SolarMutexGuard g;
      53           0 :         m_aRequest = aRequest;
      54             :     }
      55             : 
      56             :     // analyze the request
      57             :     // We need XAbort as possible continuation as minimum!
      58             :     // An optional filter selection we can handle too.
      59           0 :     css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
      60           0 :     css::uno::Reference< css::task::XInteractionAbort >                              xAbort;
      61           0 :     css::uno::Reference< css::task::XInteractionApprove >                            xApprove;
      62           0 :     css::uno::Reference< css::document::XInteractionFilterSelect >                   xFilter;
      63           0 :     css::uno::Reference< css::document::XInteractionFilterOptions >                  xFOptions;
      64             : 
      65           0 :     sal_Int32 nCount=lContinuations.getLength();
      66           0 :     for (sal_Int32 i=0; i<nCount; ++i)
      67             :     {
      68           0 :         if ( ! xAbort.is() )
      69           0 :             xAbort = css::uno::Reference< css::task::XInteractionAbort >( lContinuations[i], css::uno::UNO_QUERY );
      70             : 
      71           0 :         if( ! xApprove.is() )
      72           0 :             xApprove  = css::uno::Reference< css::task::XInteractionApprove >( lContinuations[i], css::uno::UNO_QUERY );
      73             : 
      74           0 :         if ( ! xFilter.is() )
      75           0 :             xFilter = css::uno::Reference< css::document::XInteractionFilterSelect >( lContinuations[i], css::uno::UNO_QUERY );
      76             : 
      77           0 :         if ( ! xFOptions.is() )
      78           0 :             xFOptions = css::uno::Reference< css::document::XInteractionFilterOptions >( lContinuations[i], css::uno::UNO_QUERY );
      79             :     }
      80             : 
      81             :     // differ between abortable interactions (error, unknown filter ...)
      82             :     // and other ones (ambigous but not unknown filter ...)
      83           0 :     css::task::ErrorCodeRequest          aErrorCodeRequest;
      84           0 :     css::document::AmbigousFilterRequest aAmbigousFilterRequest;
      85           0 :     css::document::LockedDocumentRequest aLockedDocumentRequest;
      86           0 :     css::document::FilterOptionsRequest  aFilterOptionsRequest;
      87             : 
      88           0 :     if (aRequest>>=aAmbigousFilterRequest)
      89             :     {
      90           0 :         if (xFilter.is())
      91             :         {
      92             :             // user selected filter wins everytime!
      93           0 :             xFilter->setFilter( aAmbigousFilterRequest.SelectedFilter );
      94           0 :             xFilter->select();
      95             :         }
      96             :     }
      97             :     else
      98           0 :     if( aRequest >>= aErrorCodeRequest )
      99             :     {
     100             :         // warnings can be ignored   => approve
     101             :         // errors must break loading => abort
     102           0 :         bool bWarning = (aErrorCodeRequest.ErrCode & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK;
     103           0 :         if (xApprove.is() && bWarning)
     104           0 :             xApprove->select();
     105             :         else
     106           0 :         if (xAbort.is())
     107           0 :             xAbort->select();
     108             :     }
     109             :     else
     110           0 :     if( aRequest >>= aLockedDocumentRequest )
     111             :     {
     112             :         // the locked document should be opened readonly by default
     113           0 :         if (xApprove.is())
     114           0 :             xApprove->select();
     115             :         else
     116           0 :         if (xAbort.is())
     117           0 :             xAbort->select();
     118             :     }
     119             :     else
     120           0 :     if (aRequest>>=aFilterOptionsRequest)
     121             :     {
     122           0 :         if (xFOptions.is())
     123             :         {
     124             :             // let the default filter options be used
     125           0 :             xFOptions->select();
     126             :         }
     127             :     }
     128             :     else
     129           0 :     if (xAbort.is())
     130           0 :         xAbort->select();
     131           0 : }
     132             : 
     133           0 : css::uno::Any QuietInteraction::getRequest() const
     134             : {
     135           0 :     SolarMutexGuard g;
     136           0 :     return m_aRequest;
     137             : }
     138             : 
     139           0 : bool QuietInteraction::wasUsed() const
     140             : {
     141           0 :     SolarMutexGuard g;
     142           0 :     return m_aRequest.hasValue();
     143             : }
     144             : 
     145             : } // namespace framework
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10