LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_documentcontentfactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 36 66.7 %
Date: 2012-08-25 Functions: 8 11 72.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 15 48 31.2 %

           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                 :            : 
      21                 :            : /**************************************************************************
      22                 :            :                                 TODO
      23                 :            :  **************************************************************************
      24                 :            : 
      25                 :            :  *************************************************************************/
      26                 :            : 
      27                 :            : #include "cppuhelper/factory.hxx"
      28                 :            : 
      29                 :            : #include "tdoc_documentcontentfactory.hxx"
      30                 :            : 
      31                 :            : using namespace com::sun::star;
      32                 :            : using namespace tdoc_ucp;
      33                 :            : 
      34                 :            : //=========================================================================
      35                 :            : //=========================================================================
      36                 :            : //
      37                 :            : // DocumentContentFactory Implementation.
      38                 :            : //
      39                 :            : //=========================================================================
      40                 :            : //=========================================================================
      41                 :            : 
      42                 :         17 : DocumentContentFactory::DocumentContentFactory(
      43                 :            :             const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
      44                 :         17 : : m_xSMgr( xSMgr )
      45                 :            : {
      46                 :         17 : }
      47                 :            : 
      48                 :            : //=========================================================================
      49                 :            : // virtual
      50                 :         17 : DocumentContentFactory::~DocumentContentFactory()
      51                 :            : {
      52         [ -  + ]:         34 : }
      53                 :            : 
      54                 :            : //=========================================================================
      55                 :            : //
      56                 :            : // XServiceInfo methods.
      57                 :            : //
      58                 :            : //=========================================================================
      59                 :            : 
      60                 :            : // virtual
      61                 :          0 : ::rtl::OUString SAL_CALL DocumentContentFactory::getImplementationName()
      62                 :            :     throw ( uno::RuntimeException )
      63                 :            : {
      64                 :          0 :     return getImplementationName_Static();
      65                 :            : }
      66                 :            : 
      67                 :            : //=========================================================================
      68                 :            : // virtual
      69                 :            : sal_Bool SAL_CALL
      70                 :          0 : DocumentContentFactory::supportsService( const ::rtl::OUString& ServiceName )
      71                 :            :     throw ( uno::RuntimeException )
      72                 :            : {
      73         [ #  # ]:          0 :     uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
      74                 :          0 :     const rtl::OUString * pArray = aSNL.getConstArray();
      75         [ #  # ]:          0 :     for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
      76                 :            :     {
      77         [ #  # ]:          0 :         if ( pArray[ i ] == ServiceName )
      78                 :          0 :             return sal_True;
      79                 :            :     }
      80         [ #  # ]:          0 :     return sal_False;
      81                 :            : }
      82                 :            : 
      83                 :            : //=========================================================================
      84                 :            : // virtual
      85                 :            : uno::Sequence< ::rtl::OUString > SAL_CALL
      86                 :          0 : DocumentContentFactory::getSupportedServiceNames()
      87                 :            :     throw ( uno::RuntimeException )
      88                 :            : {
      89                 :          0 :     return getSupportedServiceNames_Static();
      90                 :            : }
      91                 :            : 
      92                 :            : //=========================================================================
      93                 :            : // static
      94                 :         34 : rtl::OUString DocumentContentFactory::getImplementationName_Static()
      95                 :            : {
      96                 :            :     return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
      97                 :         34 :         "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory" ) );
      98                 :            : }
      99                 :            : 
     100                 :            : //=========================================================================
     101                 :            : // static
     102                 :            : uno::Sequence< rtl::OUString >
     103                 :         17 : DocumentContentFactory::getSupportedServiceNames_Static()
     104                 :            : {
     105                 :         17 :     uno::Sequence< rtl::OUString > aSNS( 1 );
     106                 :            :     aSNS.getArray()[ 0 ]
     107                 :            :         = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     108 [ +  - ][ +  - ]:         17 :             "com.sun.star.frame.TransientDocumentsDocumentContentFactory" ) );
     109                 :         17 :     return aSNS;
     110                 :            : }
     111                 :            : 
     112                 :            : //=========================================================================
     113                 :            : //
     114                 :            : // XTransientDocumentsDocumentContentFactory methods.
     115                 :            : //
     116                 :            : //=========================================================================
     117                 :            : 
     118                 :            : // virtual
     119                 :            : uno::Reference< ucb::XContent > SAL_CALL
     120                 :         50 : DocumentContentFactory::createDocumentContent(
     121                 :            :         const uno::Reference< frame::XModel >& Model )
     122                 :            :     throw ( lang::IllegalArgumentException, uno::RuntimeException )
     123                 :            : {
     124                 :         50 :     uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
     125                 :            :     try
     126                 :            :     {
     127                 :            :         xDocFac
     128                 :            :             = uno::Reference< frame::XTransientDocumentsDocumentContentFactory >(
     129         [ +  - ]:         50 :                 m_xSMgr->createInstance(
     130                 :            :                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     131                 :            :                         "com.sun.star.ucb.TransientDocumentsContentProvider" ) )
     132                 :         50 :                     ),
     133 [ +  - ][ +  - ]:         50 :                 uno::UNO_QUERY );
         [ +  - ][ +  - ]
                 [ #  # ]
     134                 :            :     }
     135         [ #  # ]:          0 :     catch ( uno::Exception const & )
     136                 :            :     {
     137                 :            :         // handled below.
     138                 :            :     }
     139                 :            : 
     140         [ +  - ]:         50 :     if ( xDocFac.is() )
     141 [ +  - ][ +  - ]:        100 :         return xDocFac->createDocumentContent( Model );
     142                 :            : 
     143                 :            :     throw uno::RuntimeException(
     144                 :            :         rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     145                 :            :             "Unable to obtain document content factory!" ) ),
     146 [ #  # ][ #  # ]:         50 :         static_cast< cppu::OWeakObject * >( this ) );
                 [ #  # ]
     147                 :            : }
     148                 :            : 
     149                 :            : //=========================================================================
     150                 :            : //
     151                 :            : // Service factory implementation.
     152                 :            : //
     153                 :            : //=========================================================================
     154                 :            : 
     155                 :            : static uno::Reference< uno::XInterface > SAL_CALL
     156                 :         17 : DocumentContentFactory_CreateInstance(
     157                 :            :     const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
     158                 :            :     throw( uno::Exception )
     159                 :            : {
     160                 :            :     lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
     161 [ +  - ][ +  - ]:         17 :         new DocumentContentFactory( rSMgr ) );
     162                 :         17 :     return uno::Reference< uno::XInterface >::query( pX );
     163                 :            : }
     164                 :            : 
     165                 :            : //=========================================================================
     166                 :            : // static
     167                 :            : uno::Reference< lang::XSingleServiceFactory >
     168                 :         17 : DocumentContentFactory::createServiceFactory(
     169                 :            :     const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
     170                 :            : {
     171                 :            :     return uno::Reference< lang::XSingleServiceFactory >(
     172                 :            :             cppu::createOneInstanceFactory(
     173                 :            :                 rxServiceMgr,
     174                 :            :                 DocumentContentFactory::getImplementationName_Static(),
     175                 :            :                 DocumentContentFactory_CreateInstance,
     176 [ +  - ][ +  - ]:         17 :                 DocumentContentFactory::getSupportedServiceNames_Static() ) );
     177                 :            : }
     178                 :            : 
     179                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10