LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/doc - ownsubfilterservice.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 49 4.1 %
Date: 2012-12-17 Functions: 1 13 7.7 %
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 <com/sun/star/frame/DoubleInitializationException.hpp>
      21             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      22             : 
      23             : #include <ownsubfilterservice.hxx>
      24             : #include <sfx2/objsh.hxx>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : namespace sfx2 {
      29             : 
      30             : //-------------------------------------------------------------------------
      31           0 : OwnSubFilterService::OwnSubFilterService( const uno::Reference < lang::XMultiServiceFactory >& xFactory )
      32             : : m_xFactory( xFactory )
      33           0 : , m_pObjectShell( NULL )
      34             : {
      35           0 : }
      36             : 
      37             : //-------------------------------------------------------------------------
      38           0 : OwnSubFilterService::~OwnSubFilterService()
      39             : {
      40           0 : }
      41             : 
      42             : //-------------------------------------------------------------------------
      43           0 : uno::Sequence< ::rtl::OUString > SAL_CALL OwnSubFilterService::impl_getStaticSupportedServiceNames()
      44             : {
      45           0 :     uno::Sequence< ::rtl::OUString > aRet(2);
      46           0 :     aRet[0] = ::rtl::OUString("com.sun.star.document.OwnSubFilter");
      47           0 :     aRet[1] = ::rtl::OUString("com.sun.star.comp.document.OwnSubFilter");
      48           0 :     return aRet;
      49             : }
      50             : 
      51             : //-------------------------------------------------------------------------
      52         176 : ::rtl::OUString SAL_CALL OwnSubFilterService::impl_getStaticImplementationName()
      53             : {
      54         176 :     return ::rtl::OUString("com.sun.star.comp.document.OwnSubFilter");
      55             : }
      56             : 
      57             : //-------------------------------------------------------------------------
      58           0 : uno::Reference< uno::XInterface > SAL_CALL OwnSubFilterService::impl_staticCreateSelfInstance(
      59             :             const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
      60             : {
      61           0 :     return uno::Reference< uno::XInterface >( *new OwnSubFilterService( xServiceManager ) );
      62             : }
      63             : 
      64             : //-------------------------------------------------------------------------
      65           0 : uno::Reference< lang::XSingleServiceFactory > SAL_CALL OwnSubFilterService::impl_createFactory(
      66             :             const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
      67             : {
      68             :     return ::cppu::createSingleFactory( xServiceManager,
      69             :                                 OwnSubFilterService::impl_getStaticImplementationName(),
      70             :                                 OwnSubFilterService::impl_staticCreateSelfInstance,
      71           0 :                                 OwnSubFilterService::impl_getStaticSupportedServiceNames() );
      72             : }
      73             : 
      74             : 
      75             : // XFilter
      76             : 
      77             : //-------------------------------------------------------------------------
      78           0 : sal_Bool SAL_CALL OwnSubFilterService::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
      79             :     throw (uno::RuntimeException)
      80             : {
      81           0 :     if ( !m_pObjectShell )
      82           0 :         throw uno::RuntimeException();
      83             : 
      84           0 :     return m_pObjectShell->ImportFromGeneratedStream_Impl( m_xStream, aDescriptor );
      85             : }
      86             : 
      87             : //-------------------------------------------------------------------------
      88           0 : void SAL_CALL OwnSubFilterService::cancel()
      89             :     throw (uno::RuntimeException)
      90             : {
      91             :     // not implemented
      92           0 : }
      93             : 
      94             : 
      95             : // XInitialization
      96             : 
      97             : //-------------------------------------------------------------------------
      98           0 : void SAL_CALL OwnSubFilterService::initialize( const uno::Sequence< uno::Any >& aArguments )
      99             :     throw (uno::Exception, uno::RuntimeException)
     100             : {
     101           0 :     if ( !m_xFactory.is() )
     102           0 :         throw uno::RuntimeException();
     103             : 
     104           0 :     if ( aArguments.getLength() != 2 )
     105           0 :         throw lang::IllegalArgumentException();
     106             : 
     107           0 :     if ( m_pObjectShell )
     108           0 :         throw frame::DoubleInitializationException();
     109             : 
     110           0 :     if ( ( aArguments[1] >>= m_xStream ) && m_xStream.is()
     111           0 :       && ( aArguments[0] >>= m_xModel ) && m_xModel.is() )
     112             :     {
     113           0 :         ::com::sun::star::uno::Reference < ::com::sun::star::lang::XUnoTunnel > xObj( m_xModel, uno::UNO_QUERY_THROW );
     114           0 :         ::com::sun::star::uno::Sequence < sal_Int8 > aSeq( SvGlobalName( SFX_GLOBAL_CLASSID ).GetByteSequence() );
     115           0 :         sal_Int64 nHandle = xObj->getSomething( aSeq );
     116           0 :         if ( nHandle )
     117           0 :             m_pObjectShell = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle ));
     118             :     }
     119             : 
     120           0 :     if ( !m_pObjectShell )
     121           0 :         throw lang::IllegalArgumentException();
     122           0 : }
     123             : 
     124             : 
     125             : // XServiceInfo
     126             : 
     127             : //-------------------------------------------------------------------------
     128           0 : ::rtl::OUString SAL_CALL OwnSubFilterService::getImplementationName()
     129             :     throw ( uno::RuntimeException )
     130             : {
     131           0 :     return impl_getStaticImplementationName();
     132             : }
     133             : 
     134             : //-------------------------------------------------------------------------
     135           0 : sal_Bool SAL_CALL OwnSubFilterService::supportsService( const ::rtl::OUString& ServiceName )
     136             :     throw ( uno::RuntimeException )
     137             : {
     138           0 :     uno::Sequence< ::rtl::OUString > aSeq = impl_getStaticSupportedServiceNames();
     139             : 
     140           0 :     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
     141           0 :         if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
     142           0 :             return sal_True;
     143             : 
     144           0 :     return sal_False;
     145             : }
     146             : 
     147             : //-------------------------------------------------------------------------
     148           0 : uno::Sequence< ::rtl::OUString > SAL_CALL OwnSubFilterService::getSupportedServiceNames()
     149             :     throw ( uno::RuntimeException )
     150             : {
     151           0 :     return impl_getStaticSupportedServiceNames();
     152             : }
     153             : 
     154             : } // namespace sfx2
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10