LCOV - code coverage report
Current view: top level - framework/source/fwe/dispatch - interaction.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 54 22.2 %
Date: 2012-08-25 Functions: 6 23 26.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 54 13.0 %

           Branch data     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 <comphelper/interaction.hxx>
      21                 :            : #include <framework/interaction.hxx>
      22                 :            : #include <general.h>
      23                 :            : 
      24                 :            : using namespace ::com::sun::star;
      25                 :            : 
      26                 :            : namespace framework{
      27                 :            : 
      28                 :            : /*-************************************************************************************************************//**
      29                 :            :     @short          declaration of special continuation for filter selection
      30                 :            :     @descr          Sometimes filter detection during loading document failed. Then we need a possibility
      31                 :            :                     to ask user for his decision. These continuation transport selected filter by user to
      32                 :            :                     code user of interaction.
      33                 :            : 
      34                 :            :     @attention      This implementation could be used one times only. We don't support a resetable continuation yet!
      35                 :            :                     Why? Normaly interaction should show a filter selection dialog and ask user for his decision.
      36                 :            :                     He can select any filter - then instances of these class will be called by handler ... or user
      37                 :            :                     close dialog without any selection. Then another continuation should be slected by handler to
      38                 :            :                     abort continuations ... Retrying isn't very usefull here ... I think.
      39                 :            : 
      40                 :            :     @implements     XInteractionFilterSelect
      41                 :            : 
      42                 :            :     @base           ImplInheritanceHelper1
      43                 :            :                     ContinuationBase
      44                 :            : 
      45                 :            :     @devstatus      ready to use
      46                 :            :     @threadsafe     no (used on once position only!)
      47                 :            : *//*-*************************************************************************************************************/
      48         [ #  # ]:          0 : class ContinuationFilterSelect : public comphelper::OInteraction< ::com::sun::star::document::XInteractionFilterSelect >
      49                 :            : {
      50                 :            :     // c++ interface
      51                 :            :     public:
      52                 :            :         ContinuationFilterSelect();
      53                 :            : 
      54                 :            :     // uno interface
      55                 :            :     public:
      56                 :            :         virtual void            SAL_CALL setFilter( const ::rtl::OUString& sFilter ) throw( ::com::sun::star::uno::RuntimeException );
      57                 :            :         virtual ::rtl::OUString SAL_CALL getFilter(                                ) throw( ::com::sun::star::uno::RuntimeException );
      58                 :            : 
      59                 :            :     // member
      60                 :            :     private:
      61                 :            :         ::rtl::OUString m_sFilter;
      62                 :            : 
      63                 :            : };  // class ContinuationFilterSelect
      64                 :            : 
      65                 :            : 
      66                 :            : //---------------------------------------------------------------------------------------------------------
      67                 :            : // initialize continuation with right start values
      68                 :            : //---------------------------------------------------------------------------------------------------------
      69                 :          0 : ContinuationFilterSelect::ContinuationFilterSelect()
      70                 :          0 :     : m_sFilter( ::rtl::OUString() )
      71                 :            : {
      72                 :          0 : }
      73                 :            : 
      74                 :            : //---------------------------------------------------------------------------------------------------------
      75                 :            : // handler should use it after selection to set user specified filter for transport
      76                 :            : //---------------------------------------------------------------------------------------------------------
      77                 :          0 : void SAL_CALL ContinuationFilterSelect::setFilter( const ::rtl::OUString& sFilter ) throw( css::uno::RuntimeException )
      78                 :            : {
      79                 :          0 :     m_sFilter = sFilter;
      80                 :          0 : }
      81                 :            : 
      82                 :            : //---------------------------------------------------------------------------------------------------------
      83                 :            : // read access to transported filter
      84                 :            : //---------------------------------------------------------------------------------------------------------
      85                 :          0 : ::rtl::OUString SAL_CALL ContinuationFilterSelect::getFilter() throw( css::uno::RuntimeException )
      86                 :            : {
      87                 :          0 :     return m_sFilter;
      88                 :            : }
      89                 :            : 
      90 [ #  # ][ #  # ]:          0 : class RequestFilterSelect_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
      91                 :            : {
      92                 :            : public:
      93                 :            :     RequestFilterSelect_Impl( const ::rtl::OUString& sURL );
      94                 :            :     sal_Bool        isAbort  () const;
      95                 :            :     ::rtl::OUString getFilter() const;
      96                 :            : 
      97                 :            : public:
      98                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL getRequest() throw( ::com::sun::star::uno::RuntimeException );
      99                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( ::com::sun::star::uno::RuntimeException );
     100                 :            : 
     101                 :            : private:
     102                 :            :     ::com::sun::star::uno::Any                                                                                                 m_aRequest      ;
     103                 :            :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >    m_lContinuations;
     104                 :            :     comphelper::OInteractionAbort* m_pAbort;
     105                 :            :     ContinuationFilterSelect* m_pFilter;
     106                 :            : };
     107                 :            : 
     108                 :            : //---------------------------------------------------------------------------------------------------------
     109                 :            : // initialize instance with all neccessary informations
     110                 :            : // We use it without any further checks on our member then ...!
     111                 :            : //---------------------------------------------------------------------------------------------------------
     112         [ #  # ]:          0 : RequestFilterSelect_Impl::RequestFilterSelect_Impl( const ::rtl::OUString& sURL )
     113                 :            : {
     114                 :          0 :     ::rtl::OUString temp;
     115                 :          0 :     css::uno::Reference< css::uno::XInterface > temp2;
     116                 :            :     css::document::NoSuchFilterRequest aFilterRequest( temp                             ,
     117                 :            :                                                        temp2                            ,
     118         [ #  # ]:          0 :                                                        sURL                                          );
     119         [ #  # ]:          0 :     m_aRequest <<= aFilterRequest;
     120                 :            : 
     121         [ #  # ]:          0 :     m_pAbort  = new comphelper::OInteractionAbort;
     122         [ #  # ]:          0 :     m_pFilter = new ContinuationFilterSelect;
     123                 :            : 
     124         [ #  # ]:          0 :     m_lContinuations.realloc( 2 );
     125 [ #  # ][ #  # ]:          0 :     m_lContinuations[0] = css::uno::Reference< css::task::XInteractionContinuation >( m_pAbort  );
         [ #  # ][ #  # ]
     126 [ #  # ][ #  # ]:          0 :     m_lContinuations[1] = css::uno::Reference< css::task::XInteractionContinuation >( m_pFilter );
         [ #  # ][ #  # ]
                 [ #  # ]
     127                 :          0 : }
     128                 :            : 
     129                 :            : //---------------------------------------------------------------------------------------------------------
     130                 :            : // return abort state of interaction
     131                 :            : // If it is true, return value of method "getFilter()" will be unspecified then!
     132                 :            : //---------------------------------------------------------------------------------------------------------
     133                 :          0 : sal_Bool RequestFilterSelect_Impl::isAbort() const
     134                 :            : {
     135                 :          0 :     return m_pAbort->wasSelected();
     136                 :            : }
     137                 :            : 
     138                 :            : //---------------------------------------------------------------------------------------------------------
     139                 :            : // return user selected filter
     140                 :            : // Return value valid for non aborted interaction only. Please check "isAbort()" before you call these ony!
     141                 :            : //---------------------------------------------------------------------------------------------------------
     142                 :          0 : ::rtl::OUString RequestFilterSelect_Impl::getFilter() const
     143                 :            : {
     144                 :          0 :     return m_pFilter->getFilter();
     145                 :            : }
     146                 :            : 
     147                 :            : //---------------------------------------------------------------------------------------------------------
     148                 :            : // handler call it to get type of request
     149                 :            : // Is hard coded to "please select filter" here. see ctor for further informations.
     150                 :            : //---------------------------------------------------------------------------------------------------------
     151                 :          0 : css::uno::Any SAL_CALL RequestFilterSelect_Impl::getRequest() throw( css::uno::RuntimeException )
     152                 :            : {
     153                 :          0 :     return m_aRequest;
     154                 :            : }
     155                 :            : 
     156                 :            : //---------------------------------------------------------------------------------------------------------
     157                 :            : // handler call it to get possible continuations
     158                 :            : // We support "abort/select_filter" only here.
     159                 :            : // After interaction we support read access on these continuations on our c++ interface to
     160                 :            : // return user decision.
     161                 :            : //---------------------------------------------------------------------------------------------------------
     162                 :          0 : css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL RequestFilterSelect_Impl::getContinuations() throw( css::uno::RuntimeException )
     163                 :            : {
     164                 :          0 :     return m_lContinuations;
     165                 :            : }
     166                 :            : 
     167                 :            : 
     168                 :          0 : RequestFilterSelect::RequestFilterSelect( const ::rtl::OUString& sURL )
     169                 :            : {
     170         [ #  # ]:          0 :     pImp = new RequestFilterSelect_Impl( sURL );
     171                 :          0 :     pImp->acquire();
     172                 :          0 : }
     173                 :            : 
     174                 :          0 : RequestFilterSelect::~RequestFilterSelect()
     175                 :            : {
     176                 :          0 :     pImp->release();
     177                 :          0 : }
     178                 :            : 
     179                 :            : 
     180                 :            : //---------------------------------------------------------------------------------------------------------
     181                 :            : // return abort state of interaction
     182                 :            : // If it is true, return value of method "getFilter()" will be unspecified then!
     183                 :            : //---------------------------------------------------------------------------------------------------------
     184                 :          0 : sal_Bool RequestFilterSelect::isAbort() const
     185                 :            : {
     186                 :          0 :     return pImp->isAbort();
     187                 :            : }
     188                 :            : 
     189                 :            : //---------------------------------------------------------------------------------------------------------
     190                 :            : // return user selected filter
     191                 :            : // Return value valid for non aborted interaction only. Please check "isAbort()" before you call these ony!
     192                 :            : //---------------------------------------------------------------------------------------------------------
     193                 :          0 : ::rtl::OUString RequestFilterSelect::getFilter() const
     194                 :            : {
     195                 :          0 :     return pImp->getFilter();
     196                 :            : }
     197                 :            : 
     198                 :          0 : uno::Reference < task::XInteractionRequest > RequestFilterSelect::GetRequest()
     199                 :            : {
     200         [ #  # ]:          0 :     return uno::Reference < task::XInteractionRequest > (pImp);
     201                 :            : }
     202                 :            : 
     203 [ +  - ][ -  + ]:         66 : class InteractionRequest_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
     204                 :            : {
     205                 :            :     uno::Any m_aRequest;
     206                 :            :     uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
     207                 :            : 
     208                 :            : public:
     209                 :         33 :     InteractionRequest_Impl( const ::com::sun::star::uno::Any& aRequest,
     210                 :            :         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations )
     211         [ +  - ]:         33 :     {
     212                 :         33 :         m_aRequest = aRequest;
     213         [ +  - ]:         33 :         m_lContinuations = lContinuations;
     214                 :         33 :     }
     215                 :            : 
     216                 :            :     virtual uno::Any SAL_CALL getRequest() throw( uno::RuntimeException );
     217                 :            :     virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations()
     218                 :            :             throw( uno::RuntimeException );
     219                 :            : };
     220                 :            : 
     221                 :         33 : uno::Any SAL_CALL InteractionRequest_Impl::getRequest() throw( uno::RuntimeException )
     222                 :            : {
     223                 :         33 :     return m_aRequest;
     224                 :            : }
     225                 :            : 
     226                 :         33 : uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL InteractionRequest_Impl::getContinuations()
     227                 :            :     throw( uno::RuntimeException )
     228                 :            : {
     229                 :         33 :     return m_lContinuations;
     230                 :            : }
     231                 :            : 
     232                 :         33 : uno::Reference < task::XInteractionRequest > InteractionRequest::CreateRequest(
     233                 :            :     const uno::Any& aRequest, const uno::Sequence< uno::Reference< task::XInteractionContinuation > > lContinuations )
     234                 :            : {
     235 [ +  - ][ +  - ]:         33 :     return new InteractionRequest_Impl( aRequest, lContinuations );
                 [ +  - ]
     236                 :            : }
     237                 :            : 
     238                 :            : }       //  namespace framework
     239                 :            : 
     240                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10