summaryrefslogtreecommitdiff
path: root/embeddedobj/source/general/xcreator.cxx
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2007-06-26 15:05:07 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2007-06-26 15:05:07 +0000
commitf81fbb96b7580863cb3329e824af606ca5cdd989 (patch)
treed3b89f25fff20c7e74b9dfdd8cee91d2e04dcb9a /embeddedobj/source/general/xcreator.cxx
parenta95d6483a41bafcf1d5692d81a6dcfe90ee5fc46 (diff)
INTEGRATION: CWS mav21 (1.13.28); FILE MERGED
2007/06/12 10:09:01 mav 1.13.28.3: #i75233# the OLE objects have no classID registration, but they are known by mediatype 2007/03/28 13:12:05 mav 1.13.28.2: #i75820# allow to support factory only 2007/03/08 12:39:01 mav 1.13.28.1: #i75233# the implementation for unknown objects
Diffstat (limited to 'embeddedobj/source/general/xcreator.cxx')
-rw-r--r--embeddedobj/source/general/xcreator.cxx41
1 files changed, 24 insertions, 17 deletions
diff --git a/embeddedobj/source/general/xcreator.cxx b/embeddedobj/source/general/xcreator.cxx
index 465fe7ea6ed5..0686f658b1bc 100644
--- a/embeddedobj/source/general/xcreator.cxx
+++ b/embeddedobj/source/general/xcreator.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: xcreator.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: obo $ $Date: 2006-10-12 11:21:30 $
+ * last change: $Author: hr $ $Date: 2007-06-26 16:05:07 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -71,8 +71,9 @@
#include <rtl/logfile.hxx>
-#include "xcreator.hxx"
-#include "convert.hxx"
+#include <xcreator.hxx>
+#include <convert.hxx>
+#include <dummyobject.hxx>
using namespace ::com::sun::star;
@@ -178,6 +179,7 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
throw container::NoSuchElementException();
::rtl::OUString aMediaType;
+ ::rtl::OUString aEmbedFactory;
if ( xStorage->isStorageElement( sEntName ) )
{
// the object must be based on storage
@@ -223,6 +225,8 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
try {
uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) );
aAny >>= aMediaType;
+ if ( aMediaType.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.oleobject" ) ) ) )
+ aEmbedFactory = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) );
}
catch ( uno::Exception& )
{
@@ -239,24 +243,27 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
}
OSL_ENSURE( aMediaType.getLength(), "No media type is specified for the object!" );
- ::rtl::OUString aEmbedFactory;
- if ( aMediaType.getLength() )
+ if ( aMediaType.getLength() && !aEmbedFactory.getLength() )
aEmbedFactory = m_aConfigHelper.GetFactoryNameByMediaType( aMediaType );
- if ( !aEmbedFactory.getLength() )
+ 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< uno::XInterface > xFact = m_xFactory->createInstance( aEmbedFactory );
- uno::Reference< embed::XEmbedObjectCreator > xEmbCreator(
- m_xFactory->createInstance( aEmbedFactory ),
- uno::UNO_QUERY );
- if ( !xEmbCreator.is() )
- throw uno::RuntimeException(); // TODO:
+ uno::Reference< embed::XEmbedObjectCreator > xEmbCreator( xFact, uno::UNO_QUERY );
+ if ( xEmbCreator.is() )
+ return xEmbCreator->createInstanceInitFromEntry( xStorage, sEntName, aMedDescr, lObjArgs );
- return xEmbCreator->createInstanceInitFromEntry( xStorage, sEntName, aMedDescr, lObjArgs );
+ uno::Reference < embed::XEmbedObjectFactory > xEmbFact( xFact, uno::UNO_QUERY );
+ if ( xEmbFact.is() )
+ return xEmbFact->createInstanceUserInit( uno::Sequence< sal_Int8 >(), ::rtl::OUString(), xStorage, sEntName, embed::EntryInitModes::DEFAULT_INIT, aMedDescr, lObjArgs);
+ }
+
+ // the default object should be created, it will allow to store the contents on the next saving
+ uno::Reference< uno::XInterface > xResult( static_cast< cppu::OWeakObject* >( new ODummyEmbeddedObject() ) );
+ uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
+ xPersist->setPersistentEntry( xStorage, sEntName, embed::EntryInitModes::DEFAULT_INIT, aMedDescr, lObjArgs );
+ return xResult;
}
//-------------------------------------------------------------------------