24#include <ooxml/resourceids.hxx>
25#include <rtl/ustring.hxx>
27#include <osl/diagnose.h>
30#include <officecfg/Office/Common.hxx>
31#include <com/sun/star/container/XNameAccess.hpp>
32#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
33#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
34#include <com/sun/star/document/XFilter.hpp>
35#include <com/sun/star/document/XImporter.hpp>
36#include <com/sun/star/drawing/XShape.hpp>
37#include <com/sun/star/graphic/XGraphic.hpp>
38#include <com/sun/star/io/XOutputStream.hpp>
39#include <com/sun/star/lang/XComponent.hpp>
40#include <com/sun/star/lang/XMultiServiceFactory.hpp>
41#include <com/sun/star/lang/XServiceInfo.hpp>
42#include <com/sun/star/text/XTextDocument.hpp>
43#include <com/sun/star/text/WrapTextMode.hpp>
44#include <com/sun/star/uno/XComponentContext.hpp>
53 m_nWrapMode(
text::WrapTextMode_THROUGHT),
54 m_rDomainMapper(rDomainMapper)
69 case NS_ooxml::LN_CT_OLEObject_Type:
71 case NS_ooxml::LN_CT_OLEObject_ProgID:
74 case NS_ooxml::LN_CT_OLEObject_ShapeID:
76 case NS_ooxml::LN_CT_OLEObject_DrawAspect:
79 case NS_ooxml::LN_CT_OLEObject_ObjectID:
81 case NS_ooxml::LN_CT_OLEObject_r_id:
83 case NS_ooxml::LN_inputstream:
86 case NS_ooxml::LN_CT_Object_dxaOrig:
89 case NS_ooxml::LN_CT_Object_dyaOrig:
92 case NS_ooxml::LN_shape:
95 rVal.
getAny() >>= xTempShape;
99 if(xSInfo->supportsService(
"com.sun.star.drawing.ControlShape"))
105 if( xTempShape.is() )
117 xShapeProps->setPropertyValue(
"Opaque",
uno::Any(
false));
119 catch(
const uno::Exception& )
128 OSL_FAIL(
"unknown attribute");
135 return css::awt::Size();
144 css::uno::Reference<css::graphic::XGraphic> xReplacement;
151 sal_uInt32 nSprmId = rSprm.
getId();
154 case NS_ooxml::LN_OLEObject_OLEObject:
159 pProperties->resolve(*
this);
163 case NS_ooxml::LN_wrap_wrap:
169 pProperties->resolve( *pHandler );
177 xShapeProps->setPropertyValue(
184 xShapeProps->setPropertyValue(
"Opaque",
uno::Any(
m_nWrapMode != text::WrapTextMode_THROUGH));
186 catch(
const uno::Exception& )
195 OSL_FAIL(
"unknown attribute");
202 OUString aFilterService;
204 aFilterService =
"com.sun.star.comp.Writer.WriterFilter";
206 aFilterService =
"com.sun.star.comp.oox.xls.ExcelFilter";
208 aFilterService =
"com.sun.star.comp.Math.MathTypeFilter";
210 SAL_WARN(
"writerfilter",
"OLEHandler::importStream: unhandled m_sProgId: " <<
m_sProgId);
222 if (!xEmbeddedObject.is())
224 xImporter->setTargetDocument( xEmbeddedObject );
230 xFilter->filter(aMediaDescriptor.getAsConstPropertyValueList());
234 ::oox::ole::SaveInteropProperties(xTextDocument,
235 xPropertySet->getPropertyValue(
"StreamName").get<OUString>(), &
m_aURL,
246 if (officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get())
247 aRet =
"8BC6B165-B1B2-4EDD-aa47-dae2ee689dd6";
251 if (officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc::get())
252 aRet =
"47BBB4CB-CE4C-4E80-A591-42D9AE74950F";
256 if (officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::get())
257 aRet =
"078B7ABA-54FC-457F-8551-6147E776A997";
260 SAL_WARN(
"writerfilter",
"OLEHandler::getCLSID: unhandled m_sProgId: " <<
m_sProgId);
290 xFactory->createInstance(
"com.sun.star.document.ImportEmbeddedObjectResolver"), uno::UNO_QUERY_THROW );
292 static sal_Int32 nObjectCount = 100;
294 OUString
aURL =
"Obj" + OUString::number( nObjectCount++ );
296 if( (xNA->getByName(
aURL ) >>= xOLEStream) && xOLEStream.is() )
298 const sal_Int32 nReadRequest = 0x1000;
304 xOLEStream->writeBytes(
aData );
305 if( nRead < nReadRequest )
307 xOLEStream->closeOutput();
312 ::oox::ole::SaveInteropProperties(xTextDocument,
aURL,
nullptr,
m_sProgId);
314 OUString aPersistName( xEmbeddedResolver->resolveEmbeddedObjectURL(
aURL ) );
315 sRet = aPersistName.copy( strlen(
"vnd.sun.star.EmbeddedObject:") );
322 catch(
const uno::Exception& )
An SPRM: Section, Paragraph and Run Modifier.
virtual sal_uInt32 getId() const =0
Returns id of the SPRM.
virtual writerfilter::Reference< Properties >::Pointer_t getProps()=0
Returns reference to properties contained in the SPRM.
virtual OUString getString() const =0
Returns string representation of the value.
virtual css::uno::Any getAny() const =0
Returns representation of the value as uno::Any.
void hasControls(const bool bSet)
bool IsInHeaderFooter() const
OUString m_sVisAreaHeight
virtual ~OLEHandler() override
OUString const & GetDrawAspect() const
virtual void lcl_sprm(Sprm &sprm) override
virtual void lcl_attribute(Id Name, Value &val) override
css::uno::Reference< css::io::XInputStream > m_xInputStream
OUString getCLSID() const
Get the CLSID of the OLE object, in case we can find one based on m_sProgId.
OUString m_aURL
The stream URL right after the import of the raw data.
OLEHandler(DomainMapper &rDomainMapper)
void importStream(const css::uno::Reference< css::uno::XComponentContext > &xComponentContext, const css::uno::Reference< css::text::XTextDocument > &xTextDocument, const css::uno::Reference< css::text::XTextContent > &xOLE)
In case of a valid CLSID, import the native data to the previously created empty OLE object.
css::text::WrapTextMode m_nWrapMode
css::uno::Reference< css::graphic::XGraphic > getReplacement() const
OUString const & GetVisAreaWidth() const
DomainMapper & m_rDomainMapper
css::uno::Reference< css::drawing::XShape > m_xShape
css::awt::Size getSize() const
OUString const & GetVisAreaHeight() const
OUString copyOLEOStream(css::uno::Reference< css::text::XTextDocument > const &xTextDocument)
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN(area, stream)
constexpr OUStringLiteral aData
OUString getPropertyName(PropertyIds eId)