LCOV - code coverage report
Current view: top level - libreoffice/embeddedobj/source/commonembedding - xfactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 67 181 37.0 %
Date: 2012-12-17 Functions: 7 19 36.8 %
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/embed/ElementModes.hpp>
      21             : #include <com/sun/star/embed/EntryInitModes.hpp>
      22             : #include <com/sun/star/document/XTypeDetection.hpp>
      23             : #include <com/sun/star/beans/PropertyValue.hpp>
      24             : #include <com/sun/star/beans/XPropertySet.hpp>
      25             : #include <com/sun/star/container/XNameAccess.hpp>
      26             : 
      27             : #include <rtl/logfile.hxx>
      28             : 
      29             : 
      30             : #include "xfactory.hxx"
      31             : #include "commonembobj.hxx"
      32             : #include "specialobject.hxx"
      33             : #include "oleembobj.hxx"
      34             : 
      35             : 
      36             : using namespace ::com::sun::star;
      37             : 
      38             : //-------------------------------------------------------------------------
      39           8 : uno::Sequence< ::rtl::OUString > SAL_CALL OOoEmbeddedObjectFactory::impl_staticGetSupportedServiceNames()
      40             : {
      41           8 :     uno::Sequence< ::rtl::OUString > aRet(2);
      42           8 :     aRet[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.OOoEmbeddedObjectFactory"));
      43           8 :     aRet[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.embed.OOoEmbeddedObjectFactory"));
      44           8 :     return aRet;
      45             : }
      46             : 
      47             : //-------------------------------------------------------------------------
      48          26 : ::rtl::OUString SAL_CALL OOoEmbeddedObjectFactory::impl_staticGetImplementationName()
      49             : {
      50          26 :     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.embed.OOoEmbeddedObjectFactory"));
      51             : }
      52             : 
      53             : //-------------------------------------------------------------------------
      54           8 : uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::impl_staticCreateSelfInstance(
      55             :             const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
      56             : {
      57           8 :     return uno::Reference< uno::XInterface >( *new OOoEmbeddedObjectFactory( xServiceManager ) );
      58             : }
      59             : 
      60             : //-------------------------------------------------------------------------
      61           8 : uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceInitFromEntry(
      62             :                                                                     const uno::Reference< embed::XStorage >& xStorage,
      63             :                                                                     const ::rtl::OUString& sEntName,
      64             :                                                                     const uno::Sequence< beans::PropertyValue >& aMediaDescr,
      65             :                                                                     const uno::Sequence< beans::PropertyValue >& lObjArgs )
      66             :     throw ( lang::IllegalArgumentException,
      67             :             container::NoSuchElementException,
      68             :             io::IOException,
      69             :             uno::Exception,
      70             :             uno::RuntimeException)
      71             : {
      72             :     RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceInitFromEntry" );
      73             : 
      74           8 :     if ( !xStorage.is() )
      75             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
      76             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
      77           0 :                                             1 );
      78             : 
      79           8 :     if ( sEntName.isEmpty() )
      80             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
      81             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
      82           0 :                                             2 );
      83             : 
      84           8 :     uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY );
      85           8 :     if ( !xNameAccess.is() )
      86           0 :         throw uno::RuntimeException(); //TODO
      87             : 
      88             :     // detect entry existence
      89           8 :     if ( !xNameAccess->hasByName( sEntName ) )
      90           0 :         throw container::NoSuchElementException();
      91             : 
      92           8 :     uno::Reference< uno::XInterface > xResult;
      93           8 :     if ( xStorage->isStorageElement( sEntName ) )
      94             :     {
      95             :         // the object must be based on storage
      96             :         uno::Reference< embed::XStorage > xSubStorage =
      97           8 :                 xStorage->openStorageElement( sEntName, embed::ElementModes::READ );
      98             : 
      99           8 :         uno::Reference< beans::XPropertySet > xPropSet( xSubStorage, uno::UNO_QUERY );
     100           8 :         if ( !xPropSet.is() )
     101           0 :             throw uno::RuntimeException();
     102             : 
     103           8 :         ::rtl::OUString aMediaType;
     104             :         try {
     105           8 :             uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MediaType" )) );
     106           8 :             aAny >>= aMediaType;
     107             :         }
     108           0 :         catch ( const uno::Exception& )
     109             :         {
     110             :         }
     111             : 
     112             :         try {
     113           8 :             uno::Reference< lang::XComponent > xComp( xSubStorage, uno::UNO_QUERY );
     114           8 :             if ( xComp.is() )
     115           8 :                 xComp->dispose();
     116             :         }
     117           0 :         catch ( const uno::Exception& )
     118             :         {
     119             :         }
     120           8 :         xSubStorage = uno::Reference< embed::XStorage >();
     121             : 
     122           8 :         uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByMediaType( aMediaType );
     123           8 :         if ( !aObject.getLength() )
     124           0 :             throw io::IOException(); // unexpected mimetype of the storage
     125             : 
     126             :         xResult = uno::Reference< uno::XInterface >(
     127             :                     static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
     128             :                                                 m_xFactory,
     129           8 :                                                 aObject ) ),
     130           8 :                     uno::UNO_QUERY );
     131             :     }
     132             :     else
     133             :     {
     134             :         // the object must be OOo embedded object, if it is not an exception must be thrown
     135           0 :         throw io::IOException(); // TODO:
     136             :     }
     137             : 
     138           8 :     uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
     139             : 
     140           8 :     if ( !xPersist.is() )
     141           0 :         throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects
     142             : 
     143           8 :     xPersist->setPersistentEntry( xStorage,
     144             :                                     sEntName,
     145             :                                     embed::EntryInitModes::DEFAULT_INIT,
     146             :                                     aMediaDescr,
     147           8 :                                     lObjArgs );
     148             : 
     149           8 :     return xResult;
     150             : }
     151             : 
     152             : //-------------------------------------------------------------------------
     153           6 : uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceInitFromMediaDescriptor(
     154             :         const uno::Reference< embed::XStorage >& xStorage,
     155             :         const ::rtl::OUString& sEntName,
     156             :         const uno::Sequence< beans::PropertyValue >& aMediaDescr,
     157             :         const uno::Sequence< beans::PropertyValue >& lObjArgs )
     158             :     throw ( lang::IllegalArgumentException,
     159             :             io::IOException,
     160             :             uno::Exception,
     161             :             uno::RuntimeException)
     162             : {
     163             :     RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceInitFromMediaDescriptor" );
     164             : 
     165           6 :     if ( !xStorage.is() )
     166             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
     167             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     168           0 :                                             1 );
     169             : 
     170           6 :     if ( sEntName.isEmpty() )
     171             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
     172             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     173           0 :                                             2 );
     174             : 
     175           6 :     uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
     176             : 
     177             :     // check if there is FilterName
     178           6 :     ::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
     179             : 
     180           6 :     uno::Reference< uno::XInterface > xResult;
     181             : 
     182             :     // find document service name
     183           6 :     if ( !aFilterName.isEmpty() )
     184             :     {
     185           6 :         uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
     186           6 :         if ( !aObject.getLength() )
     187           0 :             throw io::IOException(); // unexpected mimetype of the storage
     188             : 
     189             : 
     190             :         xResult = uno::Reference< uno::XInterface >(
     191             :                     static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
     192             :                                             m_xFactory,
     193           6 :                                             aObject ) ),
     194           6 :                     uno::UNO_QUERY );
     195             :     }
     196             :     else
     197             :     {
     198             :         // the object must be OOo embedded object, if it is not an exception must be thrown
     199           0 :         throw io::IOException(); // TODO:
     200             :     }
     201             : 
     202           6 :     uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
     203             : 
     204           6 :     if ( !xPersist.is() )
     205           0 :         throw uno::RuntimeException(); // TODO: the interface must be supported ( what about applets? )
     206             : 
     207           6 :     xPersist->setPersistentEntry( xStorage,
     208             :                                     sEntName,
     209             :                                     embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT,
     210             :                                     aTempMedDescr,
     211           6 :                                     lObjArgs );
     212             : 
     213           6 :     return xResult;
     214             : }
     215             : 
     216             : //-------------------------------------------------------------------------
     217         366 : uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceInitNew(
     218             :                                             const uno::Sequence< sal_Int8 >& aClassID,
     219             :                                             const ::rtl::OUString& /*aClassName*/,
     220             :                                             const uno::Reference< embed::XStorage >& xStorage,
     221             :                                             const ::rtl::OUString& sEntName,
     222             :                                             const uno::Sequence< beans::PropertyValue >& lObjArgs )
     223             :     throw ( lang::IllegalArgumentException,
     224             :             io::IOException,
     225             :             uno::Exception,
     226             :             uno::RuntimeException)
     227             : {
     228             :     RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceInitNew" );
     229             : 
     230         366 :     uno::Reference< uno::XInterface > xResult;
     231             : 
     232         366 :     if ( !xStorage.is() )
     233             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
     234             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     235           0 :                                             3 );
     236             : 
     237         366 :     if ( sEntName.isEmpty() )
     238             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
     239             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     240           0 :                                             4 );
     241             : 
     242         366 :     uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
     243         366 :     if ( !aObject.getLength() )
     244           0 :         throw io::IOException(); // unexpected mimetype of the storage
     245             : 
     246             :     xResult = uno::Reference< uno::XInterface >(
     247             :                     static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
     248             :                                                 m_xFactory,
     249         366 :                                                 aObject ) ),
     250         366 :                     uno::UNO_QUERY );
     251             : 
     252             : 
     253         366 :     uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
     254             : 
     255         366 :     if ( !xPersist.is() )
     256           0 :         throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects
     257             : 
     258         366 :     xPersist->setPersistentEntry( xStorage,
     259             :                                     sEntName,
     260             :                                     embed::EntryInitModes::TRUNCATE_INIT,
     261             :                                     uno::Sequence< beans::PropertyValue >(),
     262         366 :                                     lObjArgs );
     263             : 
     264         366 :     return xResult;
     265             : }
     266             : 
     267             : //-------------------------------------------------------------------------
     268           0 : uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceUserInit(
     269             :             const uno::Sequence< sal_Int8 >& aClassID,
     270             :             const ::rtl::OUString& /*aClassName*/,
     271             :             const uno::Reference< embed::XStorage >& xStorage,
     272             :             const ::rtl::OUString& sEntName,
     273             :             sal_Int32 nEntryConnectionMode,
     274             :             const uno::Sequence< beans::PropertyValue >& lArguments,
     275             :             const uno::Sequence< beans::PropertyValue >& lObjArgs )
     276             :     throw ( lang::IllegalArgumentException,
     277             :             io::IOException,
     278             :             uno::Exception,
     279             :             uno::RuntimeException )
     280             : {
     281             :     RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceUserInit" );
     282             : 
     283             :     // the initialization is completelly controlled by user
     284           0 :     if ( !xStorage.is() )
     285             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
     286             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     287           0 :                                             1 );
     288             : 
     289           0 :     if ( sEntName.isEmpty() )
     290             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
     291             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     292           0 :                                             2 );
     293             : 
     294           0 :     uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
     295           0 :     if ( !aObject.getLength() )
     296           0 :         throw io::IOException(); // unexpected mimetype of the storage
     297             : 
     298           0 :     uno::Sequence< beans::PropertyValue > aTempMedDescr( lArguments );
     299           0 :     if ( nEntryConnectionMode == embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT )
     300             :     {
     301           0 :         ::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, aObject );
     302           0 :         if ( aFilterName.isEmpty() )
     303             :         // the object must be OOo embedded object, if it is not an exception must be thrown
     304           0 :             throw io::IOException(); // TODO:
     305             :     }
     306             : 
     307             :     uno::Reference< uno::XInterface > xResult = uno::Reference< uno::XInterface > (
     308             :                     static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
     309             :                                                 m_xFactory,
     310           0 :                                                 aObject ) ),
     311           0 :                     uno::UNO_QUERY );
     312             : 
     313           0 :     uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
     314           0 :     if ( xPersist.is() )
     315             :     {
     316           0 :         xPersist->setPersistentEntry( xStorage,
     317             :                                     sEntName,
     318             :                                     nEntryConnectionMode,
     319             :                                     aTempMedDescr,
     320           0 :                                     lObjArgs );
     321             : 
     322             :     }
     323             :     else
     324           0 :         throw uno::RuntimeException(); // TODO:
     325             : 
     326           0 :     return xResult;
     327             : }
     328             : 
     329             : 
     330             : //-------------------------------------------------------------------------
     331           0 : uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceLink(
     332             :                                             const uno::Reference< embed::XStorage >& /*xStorage*/,
     333             :                                             const ::rtl::OUString& /*sEntName*/,
     334             :                                             const uno::Sequence< beans::PropertyValue >& aMediaDescr,
     335             :                                             const uno::Sequence< beans::PropertyValue >& lObjArgs )
     336             :         throw ( lang::IllegalArgumentException,
     337             :                 io::IOException,
     338             :                 uno::Exception,
     339             :                 uno::RuntimeException )
     340             : {
     341             :     RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceLink" );
     342             : 
     343           0 :     uno::Reference< uno::XInterface > xResult;
     344             : 
     345           0 :     uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
     346             : 
     347             :     // check if there is URL, URL must exist
     348           0 :     ::rtl::OUString aURL;
     349           0 :     for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
     350           0 :         if ( aTempMedDescr[nInd].Name == "URL" )
     351           0 :             aTempMedDescr[nInd].Value >>= aURL;
     352             : 
     353           0 :     if ( aURL.isEmpty() )
     354             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No URL for the link is provided!\n" )),
     355             :                                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     356           0 :                                         3 );
     357             : 
     358           0 :     ::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
     359             : 
     360           0 :     if ( !aFilterName.isEmpty() )
     361             :     {
     362           0 :         uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
     363           0 :         if ( !aObject.getLength() )
     364           0 :             throw io::IOException(); // unexpected mimetype of the storage
     365             : 
     366             : 
     367             :         xResult = uno::Reference< uno::XInterface >(
     368             :                     static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
     369             :                                             m_xFactory,
     370             :                                             aObject,
     371             :                                             aTempMedDescr,
     372           0 :                                             lObjArgs ) ),
     373           0 :                     uno::UNO_QUERY );
     374             :     }
     375             :     else
     376             :     {
     377             :         // the object must be OOo embedded object, if it is not an exception must be thrown
     378           0 :         throw io::IOException(); // TODO:
     379             :     }
     380             : 
     381           0 :     return xResult;
     382             : }
     383             : 
     384             : //-------------------------------------------------------------------------
     385           0 : uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceLinkUserInit(
     386             :                                                 const uno::Sequence< sal_Int8 >& aClassID,
     387             :                                                 const ::rtl::OUString& /*aClassName*/,
     388             :                                                 const uno::Reference< embed::XStorage >& xStorage,
     389             :                                                 const ::rtl::OUString& sEntName,
     390             :                                                 const uno::Sequence< beans::PropertyValue >& lArguments,
     391             :                                                 const uno::Sequence< beans::PropertyValue >& lObjArgs )
     392             :         throw ( lang::IllegalArgumentException,
     393             :                 io::IOException,
     394             :                 uno::Exception,
     395             :                 uno::RuntimeException )
     396             : {
     397             :     RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceLinkUserInit" );
     398             : 
     399           0 :     uno::Reference< uno::XInterface > xResult;
     400             : 
     401             :     // the initialization is completelly controlled by user
     402           0 :     if ( !xStorage.is() )
     403             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
     404             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     405           0 :                                             1 );
     406             : 
     407           0 :     if ( sEntName.isEmpty() )
     408             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
     409             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     410           0 :                                             2 );
     411             : 
     412           0 :     uno::Sequence< beans::PropertyValue > aTempMedDescr( lArguments );
     413             : 
     414           0 :     ::rtl::OUString aURL;
     415           0 :     for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
     416           0 :         if ( aTempMedDescr[nInd].Name == "URL" )
     417           0 :             aTempMedDescr[nInd].Value >>= aURL;
     418             : 
     419           0 :     if ( aURL.isEmpty() )
     420             :         throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No URL for the link is provided!\n" )),
     421             :                                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     422           0 :                                         3 );
     423             : 
     424           0 :     uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
     425           0 :     if ( !aObject.getLength() )
     426           0 :         throw io::IOException(); // unexpected mimetype of the storage
     427             : 
     428           0 :     ::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, aObject );
     429             : 
     430           0 :     if ( !aFilterName.isEmpty() )
     431             :     {
     432             : 
     433             :         xResult = uno::Reference< uno::XInterface >(
     434             :                     static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
     435             :                                             m_xFactory,
     436             :                                             aObject,
     437             :                                             aTempMedDescr,
     438           0 :                                             lObjArgs ) ),
     439           0 :                     uno::UNO_QUERY );
     440             :     }
     441             :     else
     442             :     {
     443             :         // the object must be OOo embedded object, if it is not an exception must be thrown
     444           0 :         throw io::IOException(); // TODO:
     445             :     }
     446             : 
     447           0 :     return xResult;
     448             : }
     449             : 
     450             : //-------------------------------------------------------------------------
     451           0 : ::rtl::OUString SAL_CALL OOoEmbeddedObjectFactory::getImplementationName()
     452             :     throw ( uno::RuntimeException )
     453             : {
     454           0 :     return impl_staticGetImplementationName();
     455             : }
     456             : 
     457             : //-------------------------------------------------------------------------
     458           0 : sal_Bool SAL_CALL OOoEmbeddedObjectFactory::supportsService( const ::rtl::OUString& ServiceName )
     459             :     throw ( uno::RuntimeException )
     460             : {
     461           0 :     uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
     462             : 
     463           0 :     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
     464           0 :         if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
     465           0 :             return sal_True;
     466             : 
     467           0 :     return sal_False;
     468             : }
     469             : 
     470             : //-------------------------------------------------------------------------
     471           0 : uno::Sequence< ::rtl::OUString > SAL_CALL OOoEmbeddedObjectFactory::getSupportedServiceNames()
     472             :     throw ( uno::RuntimeException )
     473             : {
     474           0 :     return impl_staticGetSupportedServiceNames();
     475             : }
     476             : 
     477             : //-------------------------------------------------------------------------
     478           0 : uno::Sequence< ::rtl::OUString > SAL_CALL OOoSpecialEmbeddedObjectFactory::impl_staticGetSupportedServiceNames()
     479             : {
     480           0 :     uno::Sequence< ::rtl::OUString > aRet(2);
     481           0 :     aRet[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.OOoSpecialEmbeddedObjectFactory"));
     482           0 :     aRet[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory"));
     483           0 :     return aRet;
     484             : }
     485             : 
     486             : //-------------------------------------------------------------------------
     487          10 : ::rtl::OUString SAL_CALL OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName()
     488             : {
     489          10 :     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory"));
     490             : }
     491             : 
     492             : //-------------------------------------------------------------------------
     493           0 : uno::Reference< uno::XInterface > SAL_CALL OOoSpecialEmbeddedObjectFactory::impl_staticCreateSelfInstance(
     494             :             const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
     495             : {
     496           0 :     return uno::Reference< uno::XInterface >( *new OOoSpecialEmbeddedObjectFactory( xServiceManager ) );
     497             : }
     498             : 
     499             : //-------------------------------------------------------------------------
     500           0 : uno::Reference< uno::XInterface > SAL_CALL OOoSpecialEmbeddedObjectFactory::createInstanceUserInit(
     501             :             const uno::Sequence< sal_Int8 >& aClassID,
     502             :             const ::rtl::OUString& /*aClassName*/,
     503             :             const uno::Reference< embed::XStorage >& /*xStorage*/,
     504             :             const ::rtl::OUString& /*sEntName*/,
     505             :             sal_Int32 /*nEntryConnectionMode*/,
     506             :             const uno::Sequence< beans::PropertyValue >& /*lArguments*/,
     507             :             const uno::Sequence< beans::PropertyValue >& /*lObjArgs*/ )
     508             :     throw ( lang::IllegalArgumentException,
     509             :             io::IOException,
     510             :             uno::Exception,
     511             :             uno::RuntimeException )
     512             : {
     513           0 :     uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
     514           0 :     if ( !aObject.getLength() )
     515           0 :         throw io::IOException(); // unexpected mimetype of the storage
     516             : 
     517             :     uno::Reference< uno::XInterface > xResult(
     518             :                     static_cast< ::cppu::OWeakObject* > ( new OSpecialEmbeddedObject(
     519             :                                                 m_xFactory,
     520           0 :                                                 aObject ) ),
     521           0 :                     uno::UNO_QUERY );
     522           0 :     return xResult;
     523             : }
     524             : 
     525             : //-------------------------------------------------------------------------
     526           0 : ::rtl::OUString SAL_CALL OOoSpecialEmbeddedObjectFactory::getImplementationName()
     527             :     throw ( uno::RuntimeException )
     528             : {
     529           0 :     return impl_staticGetImplementationName();
     530             : }
     531             : 
     532             : //-------------------------------------------------------------------------
     533           0 : sal_Bool SAL_CALL OOoSpecialEmbeddedObjectFactory::supportsService( const ::rtl::OUString& ServiceName )
     534             :     throw ( uno::RuntimeException )
     535             : {
     536           0 :     uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
     537             : 
     538           0 :     for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
     539           0 :         if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
     540           0 :             return sal_True;
     541             : 
     542           0 :     return sal_False;
     543             : }
     544             : 
     545             : //-------------------------------------------------------------------------
     546           0 : uno::Sequence< ::rtl::OUString > SAL_CALL OOoSpecialEmbeddedObjectFactory::getSupportedServiceNames()
     547             :     throw ( uno::RuntimeException )
     548             : {
     549           0 :     return impl_staticGetSupportedServiceNames();
     550             : }
     551             : 
     552             : 
     553             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10