22#include <com/sun/star/awt/Rectangle.hpp>
23#include <com/sun/star/awt/Size.hpp>
24#include <com/sun/star/beans/PropertyValue.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/container/XNameAccess.hpp>
27#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
28#include <com/sun/star/embed/Aspects.hpp>
29#include <com/sun/star/frame/XModel.hpp>
30#include <com/sun/star/io/XOutputStream.hpp>
31#include <com/sun/star/lang/XComponent.hpp>
32#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33#include <osl/diagnose.h>
37#include <oox/token/properties.hxx>
51 mbShowAsIcon( false ),
52 mbAutoUpdate( false ),
60 const Reference< XMultiServiceFactory >& rxModelFactory,
61 uno::Reference<frame::XModel> xModel)
66 if( rxModelFactory.is() )
try
68 mxResolver.set( rxModelFactory->createInstance(
"com.sun.star.document.ImportEmbeddedObjectResolver" ), UNO_QUERY );
79 Reference< XComponent > xResolverComp(
mxResolver, UNO_QUERY_THROW );
80 xResolverComp->dispose();
92 OUString
const& rObjectName, OUString
const*
const pOldObjectName,
93 OUString
const& rProgId)
95 static constexpr OUStringLiteral sEmbeddingsPropName =
u"EmbeddedObjects";
98 uno::Reference<beans::XPropertySet>
const xDocProps(
xModel, uno::UNO_QUERY);
103 if (aGrabBag.
find(sEmbeddingsPropName) != aGrabBag.
end())
104 objectsList << aGrabBag[sEmbeddingsPropName];
113 if (it != objectsList.
end())
114 objectsList.
erase(it);
117 objectsList[rObjectName] <<= aGrabBagAttribute;
144 OUString aObjectId =
"Obj" + OUString::number(
mnObjectId++ );
146 Reference< XNameAccess > xResolverNA(
mxResolver, UNO_QUERY_THROW );
147 Reference< XOutputStream > xOutStrm( xResolverNA->getByName( aObjectId ), UNO_QUERY_THROW );
149 xOutStrm->closeOutput();
153 OUString aUrl =
mxResolver->resolveEmbeddedObjectURL( aObjectId );
154 OSL_ENSURE( aUrl.match(
g_aEmbeddedObjScheme ),
"OleObjectHelper::importOleObject - unexpected URL scheme" );
156 if( !aPersistName.isEmpty() )
158 rPropMap.
setProperty( PROP_PersistName, aPersistName);
170 rPropMap.
setProperty( PROP_VisualArea, awt::Rectangle( 0, 0, rObjSize.Width, rObjSize.Height ));
iterator erase(iterator it)
iterator find(const OUString &rKey)
SequenceAsHashMapBase::iterator iterator
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
A helper that maps property identifiers to property values.
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
css::uno::Reference< css::frame::XModel > m_xModel
bool importOleObject(PropertyMap &rPropMap, const OleObjectInfo &rOleObject, const css::awt::Size &rObjSize)
OleObjectHelper(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxModelFactory, css::uno::Reference< css::frame::XModel > xModel)
css::uno::Reference< css::document::XEmbeddedObjectResolver > mxResolver
Reference< frame::XModel > m_xModel
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
void SaveInteropProperties(uno::Reference< frame::XModel > const &xModel, OUString const &rObjectName, OUString const *const pOldObjectName, OUString const &rProgId)
const char g_aEmbeddedObjScheme[]
Contains generic information about an OLE object.
StreamDataSequence maEmbeddedData
Data of an embedded OLE object.
OUString maTargetLink
Path to external data for linked OLE object.
bool mbShowAsIcon
True = show as icon, false = show contents.
bool mbLinked
True = linked OLE object, false = embedded OLE object.
Reference< XModel > xModel
constexpr OUStringLiteral PROP_Aspect