20#include <com/sun/star/embed/EntryInitModes.hpp>
21#include <com/sun/star/beans/PropertyValue.hpp>
22#include <com/sun/star/container/XNameAccess.hpp>
23#include <com/sun/star/embed/Aspects.hpp>
24#include <com/sun/star/io/IOException.hpp>
25#include <com/sun/star/lang/IllegalArgumentException.hpp>
39 const uno::Reference< embed::XStorage >& xStorage,
40 const OUString& sEntName,
41 const uno::Sequence< beans::PropertyValue >& aMedDescr,
42 const uno::Sequence< beans::PropertyValue >& lObjArgs )
45 throw lang::IllegalArgumentException(
"No parent storage is provided!",
49 if ( sEntName.isEmpty() )
50 throw lang::IllegalArgumentException(
"Empty element name is provided!",
54 uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY_THROW );
57 if ( !xNameAccess->hasByName( sEntName ) )
58 throw container::NoSuchElementException();
60 if ( !xStorage->isStreamElement( sEntName ) )
63 throw io::IOException();
66 uno::Reference< uno::XInterface > xResult(
70 uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
71 xPersist->setPersistentEntry( xStorage,
73 embed::EntryInitModes::DEFAULT_INIT,
77 for ( beans::PropertyValue
const & prop : lObjArgs )
79 if ( prop.Name ==
"CloneFrom" )
83 uno::Reference < embed::XEmbeddedObject > xObj;
84 uno::Reference < embed::XEmbeddedObject > xNew( xResult, uno::UNO_QUERY );
87 xNew->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, xObj->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ) );
89 catch (
const uno::Exception& ) {}
99 const uno::Reference< embed::XStorage >& xStorage,
100 const OUString& sEntName,
101 const uno::Sequence< beans::PropertyValue >& aMediaDescr,
102 const uno::Sequence< beans::PropertyValue >& lObjArgs )
104 if ( !xStorage.is() )
105 throw lang::IllegalArgumentException(
"No parent storage is provided!",
109 if ( sEntName.isEmpty() )
110 throw lang::IllegalArgumentException(
"Empty element name is provided!",
114 uno::Reference< uno::XInterface > xResult(
118 uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
119 xPersist->setPersistentEntry( xStorage,
121 embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT,
130 const uno::Sequence< sal_Int8 >& aClassID,
131 const OUString& aClassName,
132 const uno::Reference< embed::XStorage >& xStorage,
133 const OUString& sEntName,
134 const uno::Sequence< beans::PropertyValue >& lObjArgs )
136 if ( !xStorage.is() )
137 throw lang::IllegalArgumentException(
"No parent storage is provided!",
141 if ( sEntName.isEmpty() )
142 throw lang::IllegalArgumentException(
"Empty element name is provided!",
146 uno::Reference< uno::XInterface > xResult(
150 uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
151 xPersist->setPersistentEntry( xStorage,
153 embed::EntryInitModes::TRUNCATE_INIT,
154 uno::Sequence< beans::PropertyValue >(),
162 const uno::Reference< embed::XStorage >& xStorage,
163 const OUString& sEntName,
164 const uno::Sequence< beans::PropertyValue >& aMediaDescr,
165 const uno::Sequence< beans::PropertyValue >& lObjArgs )
167 if ( !xStorage.is() )
168 throw lang::IllegalArgumentException(
"No parent storage is provided!",
172 if ( sEntName.isEmpty() )
173 throw lang::IllegalArgumentException(
"Empty element name is provided!",
177 uno::Reference< uno::XInterface > xResult(
181 uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
182 xPersist->setPersistentEntry( xStorage,
184 embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT,
193 const uno::Sequence< sal_Int8 >& aClassID,
194 const OUString& aClassName,
195 const uno::Reference< embed::XStorage >& xStorage,
196 const OUString& sEntName,
198 const uno::Sequence< beans::PropertyValue >& ,
199 const uno::Sequence< beans::PropertyValue >& lObjArgs )
202 if ( !xStorage.is() )
203 throw lang::IllegalArgumentException(
"No parent storage is provided!",
207 if ( sEntName.isEmpty() )
208 throw lang::IllegalArgumentException(
"Empty element name is provided!",
212 uno::Reference< uno::XInterface > xResult(
216 uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
217 xPersist->setPersistentEntry( xStorage,
219 embed::EntryInitModes::DEFAULT_INIT,
220 uno::Sequence< beans::PropertyValue >(),
229 return "com.sun.star.comp.embed.OLEEmbeddedObjectFactory";
240 return {
"com.sun.star.embed.OLEEmbeddedObjectFactory",
241 "com.sun.star.comp.embed.OLEEmbeddedObjectFactory" };
244extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
246 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceInitNew(const css::uno::Sequence< sal_Int8 > &aClassID, const OUString &aClassName, const css::uno::Reference< css::embed::XStorage > &xStorage, const OUString &sEntName, const css::uno::Sequence< css::beans::PropertyValue > &lObjArgs) override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceUserInit(const css::uno::Sequence< sal_Int8 > &aClassID, const OUString &aClassName, const css::uno::Reference< css::embed::XStorage > &xStorage, const OUString &sEntName, sal_Int32 nEntryConnectionMode, const css::uno::Sequence< css::beans::PropertyValue > &lArguments, const css::uno::Sequence< css::beans::PropertyValue > &lObjArgs) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceInitFromMediaDescriptor(const css::uno::Reference< css::embed::XStorage > &xStorage, const OUString &sEntName, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescr, const css::uno::Sequence< css::beans::PropertyValue > &lObjArgs) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceInitFromEntry(const css::uno::Reference< css::embed::XStorage > &xStorage, const OUString &sEntName, const css::uno::Sequence< css::beans::PropertyValue > &aMedDescr, const css::uno::Sequence< css::beans::PropertyValue > &lObjArgs) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceLink(const css::uno::Reference< css::embed::XStorage > &xStorage, const OUString &sEntName, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescr, const css::uno::Sequence< css::beans::PropertyValue > &lObjArgs) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
Represents an OLE object that has native data and we try to let an external application handle that d...
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
const char *const aClassID
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * embeddedobj_OleEmbeddedObjectFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)