INTEGRATION: CWS mav09 (1.6.2); FILE MERGED
2004/08/18 12:24:34 mav 1.6.2.4: #i27773# use system fallback 2004/06/24 17:13:42 mav 1.6.2.3: #i27773# reactivate linking support for OOo documents 2004/06/18 14:17:55 mba 1.6.2.2: #i27773#: special objects don't have a hatchwindow 2004/06/10 16:19:50 mav 1.6.2.1: #i27773# use configuration for conversion purposes
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
*
|
*
|
||||||
* $RCSfile: xcreator.cxx,v $
|
* $RCSfile: xcreator.cxx,v $
|
||||||
*
|
*
|
||||||
* $Revision: 1.7 $
|
* $Revision: 1.8 $
|
||||||
*
|
*
|
||||||
* last change: $Author: hr $ $Date: 2004-08-02 17:44:57 $
|
* last change: $Author: kz $ $Date: 2004-10-04 19:53:05 $
|
||||||
*
|
*
|
||||||
* The Contents of this file are made available subject to the terms of
|
* The Contents of this file are made available subject to the terms of
|
||||||
* either of the following licenses
|
* either of the following licenses
|
||||||
@@ -99,10 +99,6 @@
|
|||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
|
|
||||||
|
|
||||||
::rtl::OUString GetDocServiceNameFromFilter( const ::rtl::OUString& aFilterName,
|
|
||||||
const uno::Reference< lang::XMultiServiceFactory >& xFactory );
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
uno::Sequence< ::rtl::OUString > SAL_CALL UNOEmbeddedObjectCreator::impl_staticGetSupportedServiceNames()
|
uno::Sequence< ::rtl::OUString > SAL_CALL UNOEmbeddedObjectCreator::impl_staticGetSupportedServiceNames()
|
||||||
{
|
{
|
||||||
@@ -149,43 +145,23 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
||||||
4 );
|
4 );
|
||||||
|
|
||||||
::rtl::OUString aDocServiceName = GetDocumentServiceNameFromClassID( aClassID );
|
::rtl::OUString aEmbedFactory = m_aConfigHelper.GetFactoryNameByClassID( aClassID );
|
||||||
|
if ( !aEmbedFactory.getLength() )
|
||||||
if ( aDocServiceName.getLength() )
|
|
||||||
{
|
{
|
||||||
uno::Reference< embed::XEmbedObjectFactory > xOOoEmbFact(
|
// use system fallback
|
||||||
m_xFactory->createInstance(
|
// TODO: in future users factories can be tested
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) ),
|
aEmbedFactory = ::rtl::OUString::createFromAscii( "com.sun.star.embed.OLEEmbeddedObjectFactory" );
|
||||||
uno::UNO_QUERY );
|
|
||||||
if ( !xOOoEmbFact.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
|
||||||
|
|
||||||
xResult = xOOoEmbFact->createInstanceUserInit( GetClassIDFromServName( aDocServiceName ),
|
|
||||||
GetClassNameFromServName( aDocServiceName ),
|
|
||||||
xStorage,
|
|
||||||
sEntName,
|
|
||||||
embed::EntryInitModes::TRUNCATE_INIT,
|
|
||||||
uno::Sequence< beans::PropertyValue >(),
|
|
||||||
lObjArgs );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// can be an OLE object
|
|
||||||
// TODO: but in future it can be a different type of an object
|
|
||||||
// the information about implementation and factory to create it
|
|
||||||
// will be retrieved from configuration
|
|
||||||
|
|
||||||
uno::Reference< embed::XEmbedObjectCreator > xOleEmbCreator(
|
|
||||||
m_xFactory->createInstance(
|
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
if ( !xOleEmbCreator.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
|
||||||
|
|
||||||
xResult = xOleEmbCreator->createInstanceInitNew( aClassID, aClassName, xStorage, sEntName, lObjArgs );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return xResult;
|
uno::Reference < uno::XInterface > xFact( m_xFactory->createInstance( aEmbedFactory ) );
|
||||||
|
uno::Reference< embed::XEmbedObjectCreator > xEmbCreator( xFact, uno::UNO_QUERY );
|
||||||
|
if ( xEmbCreator.is() )
|
||||||
|
return xEmbCreator->createInstanceInitNew( aClassID, aClassName, xStorage, sEntName, lObjArgs );
|
||||||
|
|
||||||
|
uno::Reference < embed::XEmbedObjectFactory > xEmbFact( xFact, uno::UNO_QUERY );
|
||||||
|
if ( !xEmbFact.is() )
|
||||||
|
throw uno::RuntimeException();
|
||||||
|
return xEmbFact->createInstanceUserInit( aClassID, aClassName, xStorage, sEntName, embed::EntryInitModes::TRUNCATE_INIT, uno::Sequence < beans::PropertyValue >(), lObjArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -218,7 +194,7 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
if ( !xNameAccess->hasByName( sEntName ) )
|
if ( !xNameAccess->hasByName( sEntName ) )
|
||||||
throw container::NoSuchElementException();
|
throw container::NoSuchElementException();
|
||||||
|
|
||||||
uno::Reference< uno::XInterface > xResult;
|
::rtl::OUString aMediaType;
|
||||||
if ( xStorage->isStorageElement( sEntName ) )
|
if ( xStorage->isStorageElement( sEntName ) )
|
||||||
{
|
{
|
||||||
// the object must be based on storage
|
// the object must be based on storage
|
||||||
@@ -229,7 +205,6 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
if ( !xPropSet.is() )
|
if ( !xPropSet.is() )
|
||||||
throw uno::RuntimeException();
|
throw uno::RuntimeException();
|
||||||
|
|
||||||
::rtl::OUString aMediaType;
|
|
||||||
try {
|
try {
|
||||||
uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) );
|
uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) );
|
||||||
aAny >>= aMediaType;
|
aAny >>= aMediaType;
|
||||||
@@ -246,35 +221,6 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
catch ( uno::Exception& )
|
catch ( uno::Exception& )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: in future it is possible to have another objects based on storages
|
|
||||||
// in this case first a factory service name will be detected from the configuration
|
|
||||||
// and then it will be used with ClassID from the same entry
|
|
||||||
|
|
||||||
::rtl::OUString aDocServiceName = GetDocumentServiceFromMediaType( aMediaType );
|
|
||||||
if ( !aDocServiceName.getLength() )
|
|
||||||
{
|
|
||||||
// only own document can be based on storage for now
|
|
||||||
// in case it is not possible to find related
|
|
||||||
// document service name the storage entry is invalid
|
|
||||||
|
|
||||||
throw io::IOException(); // unexpected mimetype of the storage
|
|
||||||
}
|
|
||||||
|
|
||||||
uno::Reference< embed::XEmbedObjectFactory > xOOoEmbFact(
|
|
||||||
m_xFactory->createInstance(
|
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
if ( !xOOoEmbFact.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
|
||||||
|
|
||||||
xResult = xOOoEmbFact->createInstanceUserInit( GetClassIDFromServName( aDocServiceName ),
|
|
||||||
GetClassNameFromServName( aDocServiceName ),
|
|
||||||
xStorage,
|
|
||||||
sEntName,
|
|
||||||
embed::EntryInitModes::DEFAULT_INIT,
|
|
||||||
aMedDescr,
|
|
||||||
lObjArgs );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -291,7 +237,6 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
if ( !xPropSet.is() )
|
if ( !xPropSet.is() )
|
||||||
throw uno::RuntimeException();
|
throw uno::RuntimeException();
|
||||||
|
|
||||||
::rtl::OUString aMediaType;
|
|
||||||
try {
|
try {
|
||||||
uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) );
|
uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) );
|
||||||
aAny >>= aMediaType;
|
aAny >>= aMediaType;
|
||||||
@@ -308,30 +253,23 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
catch ( uno::Exception& )
|
catch ( uno::Exception& )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aMediaType.equalsAscii( "application/vnd.sun.star.oleobject" ) )
|
|
||||||
{
|
|
||||||
uno::Reference< embed::XEmbedObjectCreator > xOleEmbCreator(
|
|
||||||
m_xFactory->createInstance(
|
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
if ( !xOleEmbCreator.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
|
||||||
|
|
||||||
xResult = xOleEmbCreator->createInstanceInitFromEntry( xStorage, sEntName, aMedDescr, lObjArgs );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: in future it is possible to have different object implementations based on stream
|
|
||||||
// in this case the media-type of the stream will be used to detect factory and may be ClassID
|
|
||||||
// for OLE objects ClassID will be detected during object loading.
|
|
||||||
// if ClassID can not be detected the *Creator interface must be used, otherwise *Factory can be used.
|
|
||||||
|
|
||||||
throw io::IOException(); // unexpected mimetype of the stream
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return xResult;
|
::rtl::OUString aEmbedFactory = m_aConfigHelper.GetFactoryNameByMediaType( aMediaType );
|
||||||
|
if ( !aEmbedFactory.getLength() )
|
||||||
|
{
|
||||||
|
// use system fallback
|
||||||
|
// TODO: in future users factories can be tested
|
||||||
|
aEmbedFactory = ::rtl::OUString::createFromAscii( "com.sun.star.embed.OLEEmbeddedObjectFactory" );
|
||||||
|
}
|
||||||
|
|
||||||
|
uno::Reference< embed::XEmbedObjectCreator > xEmbCreator(
|
||||||
|
m_xFactory->createInstance( aEmbedFactory ),
|
||||||
|
uno::UNO_QUERY );
|
||||||
|
if ( !xEmbCreator.is() )
|
||||||
|
throw uno::RuntimeException(); // TODO:
|
||||||
|
|
||||||
|
return xEmbCreator->createInstanceInitFromEntry( xStorage, sEntName, aMedDescr, lObjArgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -357,77 +295,26 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
||||||
2 );
|
2 );
|
||||||
|
|
||||||
|
uno::Reference< uno::XInterface > xResult;
|
||||||
uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
|
uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
|
||||||
|
|
||||||
// check if there is FilterName
|
// check if there is FilterName
|
||||||
::rtl::OUString aFilterName;
|
::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
|
||||||
for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
|
|
||||||
if ( aTempMedDescr[nInd].Name.equalsAscii( "FilterName" ) )
|
|
||||||
aTempMedDescr[nInd].Value >>= aFilterName;
|
|
||||||
|
|
||||||
if ( !aFilterName.getLength() )
|
|
||||||
{
|
|
||||||
// filter name is not specified, so type detection should be done
|
|
||||||
|
|
||||||
uno::Reference< document::XTypeDetection > xTypeDetection(
|
|
||||||
m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.TypeDetection" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
|
|
||||||
if ( !xTypeDetection.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO
|
|
||||||
|
|
||||||
// get TypeName
|
|
||||||
::rtl::OUString aTypeName = xTypeDetection->queryTypeByDescriptor( aTempMedDescr, sal_True );
|
|
||||||
|
|
||||||
// get FilterName
|
|
||||||
for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
|
|
||||||
if ( aTempMedDescr[nInd].Name.equalsAscii( "FilterName" ) )
|
|
||||||
aTempMedDescr[nInd].Value >>= aFilterName;
|
|
||||||
|
|
||||||
if ( !aFilterName.getLength() && aTypeName.getLength() )
|
|
||||||
{
|
|
||||||
uno::Reference<container::XNameAccess> xNameAccess( xTypeDetection, uno::UNO_QUERY );
|
|
||||||
if ( xNameAccess.is() && xNameAccess->hasByName( aTypeName ) )
|
|
||||||
{
|
|
||||||
uno::Sequence<beans::PropertyValue> aTypes;
|
|
||||||
xNameAccess->getByName(aTypeName) >>= aTypes;
|
|
||||||
for( sal_Int32 nInd = 0; nInd < aTypes.getLength(); nInd++ )
|
|
||||||
if ( aTypes[nInd].Name.equalsAscii( "PreferredFilter" ) )
|
|
||||||
{
|
|
||||||
aTypes[nInd].Value >>= aFilterName;
|
|
||||||
sal_Int32 nLen = aTempMedDescr.getLength();
|
|
||||||
aTempMedDescr.realloc(nLen+1);
|
|
||||||
aTempMedDescr[nLen].Value = aTypes[nInd].Value;
|
|
||||||
aTempMedDescr[nLen].Name = ::rtl::OUString::createFromAscii( "FilterName" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uno::Reference< uno::XInterface > xResult;
|
|
||||||
|
|
||||||
if ( aFilterName.getLength() )
|
if ( aFilterName.getLength() )
|
||||||
{
|
{
|
||||||
// the object can be loaded by one of the office application
|
// the object can be loaded by one of the office application
|
||||||
::rtl::OUString aDocServiceName = GetDocServiceNameFromFilter( aFilterName, m_xFactory );
|
uno::Reference< embed::XEmbedObjectCreator > xOOoEmbCreator(
|
||||||
if ( !aDocServiceName.getLength() )
|
|
||||||
throw io::IOException(); // TODO: filter detection failed
|
|
||||||
|
|
||||||
uno::Reference< embed::XEmbedObjectFactory > xOOoEmbFact(
|
|
||||||
m_xFactory->createInstance(
|
m_xFactory->createInstance(
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) ),
|
::rtl::OUString::createFromAscii( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) ),
|
||||||
uno::UNO_QUERY );
|
uno::UNO_QUERY );
|
||||||
if ( !xOOoEmbFact.is() )
|
if ( !xOOoEmbCreator.is() )
|
||||||
throw uno::RuntimeException(); // TODO:
|
throw uno::RuntimeException(); // TODO:
|
||||||
|
|
||||||
xResult = xOOoEmbFact->createInstanceUserInit( GetClassIDFromServName( aDocServiceName ),
|
xResult = xOOoEmbCreator->createInstanceInitFromMediaDescriptor( xStorage,
|
||||||
GetClassNameFromServName( aDocServiceName ),
|
sEntName,
|
||||||
xStorage,
|
aTempMedDescr,
|
||||||
sEntName,
|
lObjArgs );
|
||||||
embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT,
|
|
||||||
aTempMedDescr,
|
|
||||||
lObjArgs );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -479,50 +366,20 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
||||||
4 );
|
4 );
|
||||||
|
|
||||||
::rtl::OUString aDocServiceName = GetDocumentServiceNameFromClassID( aClassID );
|
::rtl::OUString aEmbedFactory = m_aConfigHelper.GetFactoryNameByClassID( aClassID );
|
||||||
|
uno::Reference< embed::XEmbedObjectFactory > xEmbFactory(
|
||||||
if ( aDocServiceName.getLength() )
|
m_xFactory->createInstance( aEmbedFactory ),
|
||||||
{
|
uno::UNO_QUERY );
|
||||||
uno::Reference< embed::XEmbedObjectFactory > xOOoEmbFact(
|
if ( !xEmbFactory.is() )
|
||||||
m_xFactory->createInstance(
|
throw uno::RuntimeException(); // TODO:
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
if ( !xOOoEmbFact.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
|
||||||
|
|
||||||
xResult = xOOoEmbFact->createInstanceUserInit( aClassID,
|
|
||||||
sClassName,
|
|
||||||
xStorage,
|
|
||||||
sEntName,
|
|
||||||
nEntryConnectionMode,
|
|
||||||
aArgs,
|
|
||||||
aObjectArgs );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// can be an OLE object
|
|
||||||
// TODO: but in future it can be a different type of an object
|
|
||||||
// the information about implementation and factory to create it
|
|
||||||
// will be retrieved from configuration
|
|
||||||
|
|
||||||
uno::Reference< embed::XEmbedObjectFactory > xOleEmbFactory(
|
|
||||||
m_xFactory->createInstance(
|
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
if ( !xOleEmbFactory.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
|
||||||
|
|
||||||
xResult = xOleEmbFactory->createInstanceUserInit( aClassID,
|
|
||||||
sClassName,
|
|
||||||
xStorage,
|
|
||||||
sEntName,
|
|
||||||
nEntryConnectionMode,
|
|
||||||
aArgs,
|
|
||||||
aObjectArgs );
|
|
||||||
}
|
|
||||||
|
|
||||||
return xResult;
|
|
||||||
|
|
||||||
|
return xEmbFactory->createInstanceUserInit( aClassID,
|
||||||
|
sClassName,
|
||||||
|
xStorage,
|
||||||
|
sEntName,
|
||||||
|
nEntryConnectionMode,
|
||||||
|
aArgs,
|
||||||
|
aObjectArgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -536,15 +393,14 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
uno::Exception,
|
uno::Exception,
|
||||||
uno::RuntimeException )
|
uno::RuntimeException )
|
||||||
{
|
{
|
||||||
|
uno::Reference< uno::XInterface > xResult;
|
||||||
|
|
||||||
uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
|
uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
|
||||||
|
|
||||||
// check if there is FilterName and URL, URL must exist
|
// check if there is URL, URL must exist
|
||||||
::rtl::OUString aFilterName;
|
|
||||||
::rtl::OUString aURL;
|
::rtl::OUString aURL;
|
||||||
for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
|
for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
|
||||||
if ( aTempMedDescr[nInd].Name.equalsAscii( "FilterName" ) )
|
if ( aTempMedDescr[nInd].Name.equalsAscii( "URL" ) )
|
||||||
aTempMedDescr[nInd].Value >>= aFilterName;
|
|
||||||
else if ( aTempMedDescr[nInd].Name.equalsAscii( "URL" ) )
|
|
||||||
aTempMedDescr[nInd].Value >>= aURL;
|
aTempMedDescr[nInd].Value >>= aURL;
|
||||||
|
|
||||||
if ( !aURL.getLength() )
|
if ( !aURL.getLength() )
|
||||||
@@ -552,52 +408,22 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
|
||||||
3 );
|
3 );
|
||||||
|
|
||||||
if ( !aFilterName.getLength() )
|
::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
|
||||||
{
|
|
||||||
uno::Reference< document::XTypeDetection > xTypeDetection(
|
|
||||||
m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.TypeDetection" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
|
|
||||||
if ( !xTypeDetection.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO
|
|
||||||
|
|
||||||
::rtl::OUString aTypeName = xTypeDetection->queryTypeByDescriptor( aTempMedDescr, sal_True );
|
|
||||||
|
|
||||||
// TODO: in case of unexpected format we can try to create an OLE link;
|
|
||||||
// when we have different objects for unknown non-OLE formats
|
|
||||||
// we will need kind of typedetection to detect which type of the link we need;
|
|
||||||
// another way could be to provide ClassID to the call, but how
|
|
||||||
// can caller detect object type if factory can not?
|
|
||||||
|
|
||||||
for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
|
|
||||||
if ( aTempMedDescr[nInd].Name.equalsAscii( "FilterName" ) )
|
|
||||||
aTempMedDescr[nInd].Value >>= aFilterName;
|
|
||||||
}
|
|
||||||
|
|
||||||
uno::Reference< uno::XInterface > xResult;
|
|
||||||
|
|
||||||
if ( aFilterName.getLength() )
|
if ( aFilterName.getLength() )
|
||||||
{
|
{
|
||||||
// find document service name
|
// the object can be loaded by one of the office application
|
||||||
//TODO: will use storages in future
|
uno::Reference< embed::XLinkCreator > xOOoLinkCreator(
|
||||||
|
m_xFactory->createInstance(
|
||||||
::rtl::OUString aDocServiceName = GetDocServiceNameFromFilter( aFilterName, m_xFactory );
|
::rtl::OUString::createFromAscii( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) ),
|
||||||
if ( !aDocServiceName.getLength() )
|
uno::UNO_QUERY );
|
||||||
throw io::IOException(); // TODO: unexpected format
|
if ( !xOOoLinkCreator.is() )
|
||||||
|
|
||||||
uno::Reference< embed::XLinkFactory > xOOoLinkFact(
|
|
||||||
m_xFactory->createInstance(
|
|
||||||
::rtl::OUString::createFromAscii( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) ),
|
|
||||||
uno::UNO_QUERY );
|
|
||||||
if ( !xOOoLinkFact.is() )
|
|
||||||
throw uno::RuntimeException(); // TODO:
|
throw uno::RuntimeException(); // TODO:
|
||||||
|
|
||||||
xResult = xOOoLinkFact->createInstanceLinkUserInit( GetClassIDFromServName( aDocServiceName ),
|
xResult = xOOoLinkCreator->createInstanceLink( xStorage,
|
||||||
GetClassNameFromServName( aDocServiceName ),
|
sEntName,
|
||||||
xStorage,
|
aTempMedDescr,
|
||||||
sEntName,
|
lObjArgs );
|
||||||
aTempMedDescr,
|
|
||||||
lObjArgs );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -635,6 +461,37 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
|
|||||||
return xResult;
|
return xResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceLinkUserInit(
|
||||||
|
const uno::Sequence< sal_Int8 >& aClassID,
|
||||||
|
const ::rtl::OUString& aClassName,
|
||||||
|
const uno::Reference< embed::XStorage >& xStorage,
|
||||||
|
const ::rtl::OUString& sEntName,
|
||||||
|
const uno::Sequence< beans::PropertyValue >& lArguments,
|
||||||
|
const uno::Sequence< beans::PropertyValue >& lObjArgs )
|
||||||
|
throw ( lang::IllegalArgumentException,
|
||||||
|
io::IOException,
|
||||||
|
uno::Exception,
|
||||||
|
uno::RuntimeException )
|
||||||
|
{
|
||||||
|
uno::Reference< uno::XInterface > xResult;
|
||||||
|
|
||||||
|
::rtl::OUString aEmbedFactory = m_aConfigHelper.GetFactoryNameByClassID( aClassID );
|
||||||
|
uno::Reference< embed::XLinkFactory > xLinkFactory(
|
||||||
|
m_xFactory->createInstance( aEmbedFactory ),
|
||||||
|
uno::UNO_QUERY );
|
||||||
|
if ( !xLinkFactory.is() )
|
||||||
|
throw uno::RuntimeException(); // TODO:
|
||||||
|
|
||||||
|
return xLinkFactory->createInstanceLinkUserInit( aClassID,
|
||||||
|
aClassName,
|
||||||
|
xStorage,
|
||||||
|
sEntName,
|
||||||
|
lArguments,
|
||||||
|
lObjArgs );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
::rtl::OUString SAL_CALL UNOEmbeddedObjectCreator::getImplementationName()
|
::rtl::OUString SAL_CALL UNOEmbeddedObjectCreator::getImplementationName()
|
||||||
throw ( uno::RuntimeException )
|
throw ( uno::RuntimeException )
|
||||||
|
Reference in New Issue
Block a user