Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / ole / olehelper.cxx
blob05b787d9f85a2566ed0aa1e5150e16beedef88b5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <oox/ole/olehelper.hxx>
22 #include <rtl/ustrbuf.hxx>
23 #include <sot/storage.hxx>
24 #include <osl/diagnose.h>
25 #include <oox/helper/binaryinputstream.hxx>
26 #include <oox/helper/binaryoutputstream.hxx>
27 #include <oox/helper/graphichelper.hxx>
28 #include <oox/token/properties.hxx>
29 #include <oox/token/tokens.hxx>
30 #include <oox/ole/axcontrol.hxx>
31 #include <oox/helper/propertymap.hxx>
32 #include <oox/helper/propertyset.hxx>
33 #include <oox/ole/olestorage.hxx>
35 #include <com/sun/star/awt/XControlModel.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/form/FormComponentType.hpp>
38 #include <com/sun/star/form/XFormComponent.hpp>
39 #include <com/sun/star/frame/XFrame.hpp>
40 #include <com/sun/star/frame/XModel.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/awt/Size.hpp>
43 #include <com/sun/star/uno/XComponentContext.hpp>
45 #include <tools/globname.hxx>
46 #include <unotools/streamwrap.hxx>
47 #include <comphelper/processfactory.hxx>
49 namespace oox {
50 namespace ole {
52 using ::com::sun::star::form::XFormComponent;
53 using ::com::sun::star::awt::XControlModel;
54 using ::com::sun::star::awt::Size;
55 using ::com::sun::star::frame::XModel;
56 using ::com::sun::star::io::XOutputStream;
57 using ::com::sun::star::io::XInputStream;
58 using ::com::sun::star::beans::XPropertySet;
59 using ::com::sun::star::uno::Reference;
60 using ::com::sun::star::uno::UNO_QUERY;
61 using ::com::sun::star::uno::XComponentContext;
62 using ::com::sun::star::lang::XServiceInfo;
64 using namespace ::com::sun::star::form;
66 namespace {
68 const sal_uInt32 OLE_COLORTYPE_MASK = 0xFF000000;
69 const sal_uInt32 OLE_COLORTYPE_CLIENT = 0x00000000;
70 const sal_uInt32 OLE_COLORTYPE_PALETTE = 0x01000000;
71 const sal_uInt32 OLE_COLORTYPE_BGR = 0x02000000;
72 const sal_uInt32 OLE_COLORTYPE_SYSCOLOR = 0x80000000;
74 const sal_uInt32 OLE_PALETTECOLOR_MASK = 0x0000FFFF;
75 const sal_uInt32 OLE_SYSTEMCOLOR_MASK = 0x0000FFFF;
77 /** Swaps the red and blue component of the passed color. */
78 sal_uInt32 lclSwapRedBlue( sal_uInt32 nColor )
80 return static_cast< sal_uInt32 >( (nColor & 0xFF00FF00) | ((nColor & 0x0000FF) << 16) | ((nColor & 0xFF0000) >> 16) );
83 /** Returns the UNO RGB color from the passed encoded OLE BGR color. */
84 ::Color lclDecodeBgrColor( sal_uInt32 nOleColor )
86 return ::Color( lclSwapRedBlue( nOleColor ) & 0xFFFFFF );
89 const sal_uInt32 OLE_STDPIC_ID = 0x0000746C;
91 struct GUIDCNamePair
93 const char* sGUID;
94 const char* sName;
97 struct IdCntrlData
99 sal_Int16 nId;
100 GUIDCNamePair const aData;
103 const sal_Int16 TOGGLEBUTTON = -1;
104 const sal_Int16 FORMULAFIELD = -2;
106 typedef std::map< sal_Int16, GUIDCNamePair > GUIDCNamePairMap;
107 class classIdToGUIDCNamePairMap
109 GUIDCNamePairMap mnIdToGUIDCNamePairMap;
110 classIdToGUIDCNamePairMap();
111 public:
112 static GUIDCNamePairMap& get();
115 classIdToGUIDCNamePairMap::classIdToGUIDCNamePairMap()
117 static IdCntrlData const initialCntrlData[] =
119 // Command button MUST be at index 0
120 { FormComponentType::COMMANDBUTTON,
121 { AX_GUID_COMMANDBUTTON, "CommandButton"} ,
123 // Toggle button MUST be at index 1
124 { TOGGLEBUTTON,
125 { AX_GUID_TOGGLEBUTTON, "ToggleButton"},
127 { FormComponentType::FIXEDTEXT,
128 { AX_GUID_LABEL, "Label"},
130 { FormComponentType::TEXTFIELD,
131 { AX_GUID_TEXTBOX, "TextBox"},
133 { FormComponentType::LISTBOX,
134 { AX_GUID_LISTBOX, "ListBox"},
136 { FormComponentType::COMBOBOX,
137 { AX_GUID_COMBOBOX, "ComboBox"},
139 { FormComponentType::CHECKBOX,
140 { AX_GUID_CHECKBOX, "CheckBox"},
142 { FormComponentType::RADIOBUTTON,
143 { AX_GUID_OPTIONBUTTON, "OptionButton"},
145 { FormComponentType::IMAGECONTROL,
146 { AX_GUID_IMAGE, "Image"},
148 { FormComponentType::DATEFIELD,
149 { AX_GUID_TEXTBOX, "TextBox"},
151 { FormComponentType::TIMEFIELD,
152 { AX_GUID_TEXTBOX, "TextBox"},
154 { FormComponentType::NUMERICFIELD,
155 { AX_GUID_TEXTBOX, "TextBox"},
157 { FormComponentType::CURRENCYFIELD,
158 { AX_GUID_TEXTBOX, "TextBox"},
160 { FormComponentType::PATTERNFIELD,
161 { AX_GUID_TEXTBOX, "TextBox"},
163 { FORMULAFIELD,
164 { AX_GUID_TEXTBOX, "TextBox"},
166 { FormComponentType::IMAGEBUTTON,
167 { AX_GUID_COMMANDBUTTON, "CommandButton"},
169 { FormComponentType::SPINBUTTON,
170 { AX_GUID_SPINBUTTON, "SpinButton"},
172 { FormComponentType::SCROLLBAR,
173 { AX_GUID_SCROLLBAR, "ScrollBar"},
176 int const length = SAL_N_ELEMENTS( initialCntrlData );
177 IdCntrlData const * pData = initialCntrlData;
178 for ( int index = 0; index < length; ++index, ++pData )
179 mnIdToGUIDCNamePairMap[ pData->nId ] = pData->aData;
182 GUIDCNamePairMap& classIdToGUIDCNamePairMap::get()
184 static classIdToGUIDCNamePairMap theInst;
185 return theInst.mnIdToGUIDCNamePairMap;
188 template< typename Type >
189 void lclAppendHex( OUStringBuffer& orBuffer, Type nValue )
191 const sal_Int32 nWidth = 2 * sizeof( Type );
192 static const sal_Unicode spcHexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
193 orBuffer.setLength( orBuffer.getLength() + nWidth );
194 for( sal_Int32 nCharIdx = orBuffer.getLength() - 1, nCharEnd = nCharIdx - nWidth; nCharIdx > nCharEnd; --nCharIdx, nValue >>= 4 )
195 orBuffer[nCharIdx] = spcHexChars[ nValue & 0xF ];
198 } // namespace
200 StdFontInfo::StdFontInfo() :
201 mnHeight( 0 ),
202 mnWeight( OLE_STDFONT_NORMAL ),
203 mnCharSet( WINDOWS_CHARSET_ANSI ),
204 mnFlags( 0 )
208 StdFontInfo::StdFontInfo( const OUString& rName, sal_uInt32 nHeight ) :
209 maName( rName ),
210 mnHeight( nHeight ),
211 mnWeight( OLE_STDFONT_NORMAL ),
212 mnCharSet( WINDOWS_CHARSET_ANSI ),
213 mnFlags( 0 )
217 ::Color OleHelper::decodeOleColor(
218 const GraphicHelper& rGraphicHelper, sal_uInt32 nOleColor, bool bDefaultColorBgr )
220 static const sal_Int32 spnSystemColors[] =
222 XML_scrollBar, XML_background, XML_activeCaption, XML_inactiveCaption,
223 XML_menu, XML_window, XML_windowFrame, XML_menuText,
224 XML_windowText, XML_captionText, XML_activeBorder, XML_inactiveBorder,
225 XML_appWorkspace, XML_highlight, XML_highlightText, XML_btnFace,
226 XML_btnShadow, XML_grayText, XML_btnText, XML_inactiveCaptionText,
227 XML_btnHighlight, XML_3dDkShadow, XML_3dLight, XML_infoText,
228 XML_infoBk
231 switch( nOleColor & OLE_COLORTYPE_MASK )
233 case OLE_COLORTYPE_CLIENT:
234 return bDefaultColorBgr ? lclDecodeBgrColor( nOleColor ) : rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK );
236 case OLE_COLORTYPE_PALETTE:
237 return rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK );
239 case OLE_COLORTYPE_BGR:
240 return lclDecodeBgrColor( nOleColor );
242 case OLE_COLORTYPE_SYSCOLOR:
243 return rGraphicHelper.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nOleColor & OLE_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE );
245 OSL_FAIL( "OleHelper::decodeOleColor - unknown color type" );
246 return API_RGB_BLACK;
249 sal_uInt32 OleHelper::encodeOleColor( sal_Int32 nRgbColor )
251 return OLE_COLORTYPE_BGR | lclSwapRedBlue( static_cast< sal_uInt32 >( nRgbColor & 0xFFFFFF ) );
254 void OleHelper::exportGuid( BinaryOutputStream& rOStr, const SvGlobalName& rId )
256 rOStr.WriteUInt32( rId.GetCLSID().Data1 );
257 rOStr.WriteUInt16( rId.GetCLSID().Data2 );
258 rOStr.WriteUInt16( rId.GetCLSID().Data3 );
259 rOStr.writeArray( rId.GetCLSID().Data4, 8 );
262 OUString OleHelper::importGuid( BinaryInputStream& rInStrm )
264 OUStringBuffer aBuffer(40);
265 aBuffer.append( '{' );
266 lclAppendHex( aBuffer, rInStrm.readuInt32() );
267 aBuffer.append( '-' );
268 lclAppendHex( aBuffer, rInStrm.readuInt16() );
269 aBuffer.append( '-' );
270 lclAppendHex( aBuffer, rInStrm.readuInt16() );
271 aBuffer.append( '-' );
272 lclAppendHex( aBuffer, rInStrm.readuInt8() );
273 lclAppendHex( aBuffer, rInStrm.readuInt8() );
274 aBuffer.append( '-' );
275 for( int nIndex = 0; nIndex < 6; ++nIndex )
276 lclAppendHex( aBuffer, rInStrm.readuInt8() );
277 aBuffer.append( '}' );
278 return aBuffer.makeStringAndClear();
281 bool OleHelper::importStdFont( StdFontInfo& orFontInfo, BinaryInputStream& rInStrm, bool bWithGuid )
283 if( bWithGuid )
285 bool bIsStdFont = importGuid( rInStrm ) == OLE_GUID_STDFONT;
286 OSL_ENSURE( bIsStdFont, "OleHelper::importStdFont - unexpected header GUID, expected StdFont" );
287 if( !bIsStdFont )
288 return false;
291 sal_uInt8 nVersion, nNameLen;
292 nVersion = rInStrm.readuChar();
293 orFontInfo.mnCharSet = rInStrm.readuInt16();
294 orFontInfo.mnFlags = rInStrm.readuChar();
295 orFontInfo.mnWeight = rInStrm.readuInt16();
296 orFontInfo.mnHeight = rInStrm.readuInt32();
297 nNameLen = rInStrm.readuChar();
298 // according to spec the name is ASCII
299 orFontInfo.maName = rInStrm.readCharArrayUC( nNameLen, RTL_TEXTENCODING_ASCII_US );
300 OSL_ENSURE( nVersion <= 1, "OleHelper::importStdFont - wrong version" );
301 return !rInStrm.isEof() && (nVersion <= 1);
304 bool OleHelper::importStdPic( StreamDataSequence& orGraphicData, BinaryInputStream& rInStrm )
306 bool bIsStdPic = importGuid( rInStrm ) == OLE_GUID_STDPIC;
307 OSL_ENSURE( bIsStdPic, "OleHelper::importStdPic - unexpected header GUID, expected StdPic" );
308 if( !bIsStdPic )
309 return false;
311 sal_uInt32 nStdPicId;
312 sal_Int32 nBytes;
313 nStdPicId = rInStrm.readuInt32();
314 nBytes = rInStrm.readInt32();
315 OSL_ENSURE( nStdPicId == OLE_STDPIC_ID, "OleHelper::importStdPic - unexpected header version" );
316 return !rInStrm.isEof() && (nStdPicId == OLE_STDPIC_ID) && (nBytes > 0) && (rInStrm.readData( orGraphicData, nBytes ) == nBytes);
319 static Reference< css::frame::XFrame > lcl_getFrame( const Reference< css::frame::XModel >& rxModel )
321 Reference< css::frame::XFrame > xFrame;
322 if ( rxModel.is() )
324 Reference< css::frame::XController > xController = rxModel->getCurrentController();
325 xFrame = xController.is() ? xController->getFrame() : nullptr;
327 return xFrame;
330 OleFormCtrlExportHelper::OleFormCtrlExportHelper( const Reference< XComponentContext >& rxCtx, const Reference< XModel >& rxDocModel, const Reference< XControlModel >& xCntrlModel ) : mpModel( nullptr ), maGrfHelper( rxCtx, lcl_getFrame( rxDocModel ), StorageRef() ), mxDocModel( rxDocModel ), mxControlModel( xCntrlModel )
332 // try to get the guid
333 Reference< css::beans::XPropertySet > xProps( xCntrlModel, UNO_QUERY );
334 if ( xProps.is() )
336 sal_Int16 nClassId = 0;
337 PropertySet aPropSet( mxControlModel );
338 if ( aPropSet.getProperty( nClassId, PROP_ClassId ) )
340 /* pseudo ripped from legacy msocximex:
341 "There is a truly horrible thing with EditControls and FormattedField
342 Controls, they both pretend to have an EDITBOX ClassId for compatibility
343 reasons, at some stage in the future hopefully there will be a proper
344 FormulaField ClassId rather than this piggybacking two controls onto the
345 same ClassId, cmc." - when fixed the fake FORMULAFIELD id entry
346 and definition above can be removed/replaced
348 if ( nClassId == FormComponentType::TEXTFIELD)
350 Reference< XServiceInfo > xInfo( xCntrlModel,
351 UNO_QUERY);
352 if (xInfo->
353 supportsService( "com.sun.star.form.component.FormattedField" ) )
354 nClassId = FORMULAFIELD;
356 else if ( nClassId == FormComponentType::COMMANDBUTTON )
358 bool bToggle = false;
359 if ( aPropSet.getProperty( bToggle, PROP_Toggle ) && bToggle )
360 nClassId = TOGGLEBUTTON;
362 else if ( nClassId == FormComponentType::CONTROL )
364 Reference< XServiceInfo > xInfo( xCntrlModel,
365 UNO_QUERY);
366 if (xInfo->supportsService("com.sun.star.form.component.ImageControl" ) )
367 nClassId = FormComponentType::IMAGECONTROL;
370 GUIDCNamePairMap& cntrlMap = classIdToGUIDCNamePairMap::get();
371 GUIDCNamePairMap::iterator it = cntrlMap.find( nClassId );
372 if ( it != cntrlMap.end() )
374 aPropSet.getProperty(maName, PROP_Name );
375 maTypeName = OUString::createFromAscii( it->second.sName );
376 maFullName = "Microsoft Forms 2.0 " + maTypeName;
377 mpControl.reset(new EmbeddedControl( maName ));
378 maGUID = OUString::createFromAscii( it->second.sGUID );
379 mpModel = mpControl->createModelFromGuid( maGUID );
385 OleFormCtrlExportHelper::~OleFormCtrlExportHelper()
389 void OleFormCtrlExportHelper::exportName( const Reference< XOutputStream >& rxOut )
391 oox::BinaryXOutputStream aOut( rxOut, false );
392 aOut.writeUnicodeArray( maName );
393 aOut.WriteInt32(0);
396 void OleFormCtrlExportHelper::exportCompObj( const Reference< XOutputStream >& rxOut )
398 oox::BinaryXOutputStream aOut( rxOut, false );
399 if ( mpModel )
400 mpModel->exportCompObj( aOut );
403 void OleFormCtrlExportHelper::exportControl( const Reference< XOutputStream >& rxOut, const Size& rSize, bool bAutoClose )
405 oox::BinaryXOutputStream aOut( rxOut, bAutoClose );
406 if ( mpModel )
408 ::oox::ole::ControlConverter aConv( mxDocModel, maGrfHelper );
409 if(mpControl)
410 mpControl->convertFromProperties( mxControlModel, aConv );
411 mpModel->maSize.first = rSize.Width;
412 mpModel->maSize.second = rSize.Height;
413 mpModel->exportBinaryModel( aOut );
417 MSConvertOCXControls::MSConvertOCXControls( const Reference< css::frame::XModel >& rxModel ) : SvxMSConvertOCXControls( rxModel ), mxCtx( comphelper::getProcessComponentContext() ), maGrfHelper( mxCtx, lcl_getFrame( rxModel ), StorageRef() )
421 MSConvertOCXControls::~MSConvertOCXControls()
425 bool
426 MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const OUString& rGuidString )
428 ::oox::ole::EmbeddedControl aControl( "Unknown" );
429 if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString ) )
431 pModel->importBinaryModel( rInStrm );
432 rxFormComp.set( mxCtx->getServiceManager()->createInstanceWithContext( pModel->getServiceName(), mxCtx ), UNO_QUERY );
433 Reference< XControlModel > xCtlModel( rxFormComp, UNO_QUERY );
434 ::oox::ole::ControlConverter aConv( mxModel, maGrfHelper );
435 aControl.convertProperties( xCtlModel, aConv );
437 return rxFormComp.is();
440 bool
441 MSConvertOCXControls::ReadOCXCtlsStream( tools::SvRef<SotStorageStream> const & rSrc1, Reference< XFormComponent > & rxFormComp,
442 sal_Int32 nPos,
443 sal_Int32 nStreamSize)
445 if ( rSrc1.is() )
447 BinaryXInputStream aCtlsStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *rSrc1 ) ), true );
448 aCtlsStrm.seek( nPos );
449 OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( aCtlsStrm );
450 return importControlFromStream( aCtlsStrm, rxFormComp, aStrmClassId, nStreamSize );
452 return false;
455 bool MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const OUString& rStrmClassId,
456 sal_Int32 nStreamSize)
458 if ( !rInStrm.isEof() )
460 // Special processing for those html controls
461 bool bOneOfHtmlControls = false;
462 if ( rStrmClassId.toAsciiUpperCase() == HTML_GUID_SELECT
463 || rStrmClassId.toAsciiUpperCase() == HTML_GUID_TEXTBOX )
464 bOneOfHtmlControls = true;
466 if ( bOneOfHtmlControls )
468 // html controls don't seem have a handy record length following the GUID
469 // in the binary stream.
470 // Given the control stream length create a stream of nStreamSize bytes starting from
471 // nPos ( offset by the guid already read in )
472 if ( !nStreamSize )
473 return false;
474 const int nGuidSize = 0x10;
475 StreamDataSequence aDataSeq;
476 sal_Int32 nBytesToRead = nStreamSize - nGuidSize;
477 while ( nBytesToRead )
478 nBytesToRead -= rInStrm.readData( aDataSeq, nBytesToRead );
479 SequenceInputStream aInSeqStream( aDataSeq );
480 importControlFromStream( aInSeqStream, rxFormComp, rStrmClassId );
482 else
484 importControlFromStream( rInStrm, rxFormComp, rStrmClassId );
487 return rxFormComp.is();
490 bool MSConvertOCXControls::ReadOCXStorage( tools::SvRef<SotStorage> const & xOleStg,
491 Reference< XFormComponent > & rxFormComp )
493 if ( xOleStg.is() )
495 tools::SvRef<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME", StreamMode::READ);
496 BinaryXInputStream aNameStream( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pNameStream ) ), true );
498 tools::SvRef<SotStorageStream> pContents = xOleStg->OpenSotStream("contents", StreamMode::READ);
499 BinaryXInputStream aInStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pContents ) ), true );
501 tools::SvRef<SotStorageStream> pClsStrm = xOleStg->OpenSotStream("\1CompObj", StreamMode::READ);
502 BinaryXInputStream aClsStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper(*pClsStrm ) ), true );
503 aClsStrm.skip(12);
505 OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( aClsStrm );
506 if ( importControlFromStream( aInStrm, rxFormComp, aStrmClassId, aInStrm.size() ) )
508 OUString aName = aNameStream.readNulUnicodeArray();
509 Reference< XControlModel > xCtlModel( rxFormComp, UNO_QUERY );
510 if ( !aName.isEmpty() && xCtlModel.is() )
512 PropertyMap aPropMap;
513 aPropMap.setProperty( PROP_Name, aName );
514 PropertySet aPropSet( xCtlModel );
515 aPropSet.setProperties( aPropMap );
517 return rxFormComp.is();
520 return false;
523 bool MSConvertOCXControls::WriteOCXExcelKludgeStream( const css::uno::Reference< css::frame::XModel >& rxModel, const css::uno::Reference< css::io::XOutputStream >& xOutStrm, const css::uno::Reference< css::awt::XControlModel > &rxControlModel, const css::awt::Size& rSize,OUString &rName )
525 OleFormCtrlExportHelper exportHelper( comphelper::getProcessComponentContext(), rxModel, rxControlModel );
526 if ( !exportHelper.isValid() )
527 return false;
528 rName = exportHelper.getTypeName();
529 SvGlobalName aName;
530 OUString sId = exportHelper.getGUID();
531 aName.MakeId(sId);
532 BinaryXOutputStream aOut( xOutStrm, false );
533 OleHelper::exportGuid( aOut, aName );
534 exportHelper.exportControl( xOutStrm, rSize );
535 return true;
538 bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, tools::SvRef<SotStorage> const &xOleStg,
539 const Reference< XControlModel > &rxControlModel,
540 const css::awt::Size& rSize, OUString &rName)
542 SvGlobalName aName;
544 OleFormCtrlExportHelper exportHelper( comphelper::getProcessComponentContext(), rxModel, rxControlModel );
546 if ( !exportHelper.isValid() )
547 return false;
549 OUString sId = exportHelper.getGUID();
550 aName.MakeId(sId);
552 OUString sFullName = exportHelper.getFullName();
553 rName = exportHelper.getTypeName();
554 xOleStg->SetClass( aName, SotClipboardFormatId::EMBEDDED_OBJ_OLE, sFullName);
556 tools::SvRef<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME");
557 Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pNameStream );
558 exportHelper.exportName( xOut );
561 tools::SvRef<SotStorageStream> pObjStream = xOleStg->OpenSotStream("\1CompObj");
562 Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pObjStream );
563 exportHelper.exportCompObj( xOut );
566 tools::SvRef<SotStorageStream> pContents = xOleStg->OpenSotStream("contents");
567 Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pContents );
568 exportHelper.exportControl( xOut, rSize );
570 return true;
573 } // namespace ole
574 } // namespace oox
576 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */