1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/graphichelper.hxx"
27 #include "oox/token/tokens.hxx"
28 #include "oox/ole/axcontrol.hxx"
29 #include "oox/helper/propertymap.hxx"
30 #include "oox/helper/propertyset.hxx"
31 #include "oox/ole/olestorage.hxx"
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/form/FormComponentType.hpp>
35 #include <com/sun/star/form/XFormsSupplier.hpp>
36 #include <com/sun/star/form/XForm.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
39 #include <com/sun/star/container/XNameContainer.hpp>
40 #include <com/sun/star/awt/Size.hpp>
42 #include <tools/globname.hxx>
43 #include <unotools/streamwrap.hxx>
44 #include <comphelper/processfactory.hxx>
49 using ::com::sun::star::form::XFormComponent
;
50 using ::com::sun::star::form::XForm
;
51 using ::com::sun::star::awt::XControlModel
;
52 using ::com::sun::star::awt::Size
;
53 using ::com::sun::star::frame::XModel
;
54 using ::com::sun::star::form::XFormsSupplier
;
55 using ::com::sun::star::drawing::XDrawPage
;
56 using ::com::sun::star::drawing::XDrawPageSupplier
;
57 using ::com::sun::star::drawing::XShapes
;
58 using ::com::sun::star::io::XOutputStream
;
59 using ::com::sun::star::io::XInputStream
;
60 using ::com::sun::star::beans::XPropertySet
;
61 using ::com::sun::star::uno::Reference
;
62 using ::com::sun::star::uno::XInterface
;
63 using ::com::sun::star::uno::UNO_QUERY
;
64 using ::com::sun::star::uno::Any
;
65 using ::com::sun::star::uno::XComponentContext
;
66 using ::com::sun::star::container::XIndexContainer
;
67 using ::com::sun::star::container::XNameContainer
;
68 using ::com::sun::star::lang::XMultiServiceFactory
;
69 using ::com::sun::star::lang::XServiceInfo
;
71 using namespace ::com::sun::star::form
;
75 const sal_uInt32 OLE_COLORTYPE_MASK
= 0xFF000000;
76 const sal_uInt32 OLE_COLORTYPE_CLIENT
= 0x00000000;
77 const sal_uInt32 OLE_COLORTYPE_PALETTE
= 0x01000000;
78 const sal_uInt32 OLE_COLORTYPE_BGR
= 0x02000000;
79 const sal_uInt32 OLE_COLORTYPE_SYSCOLOR
= 0x80000000;
81 const sal_uInt32 OLE_PALETTECOLOR_MASK
= 0x0000FFFF;
82 const sal_uInt32 OLE_SYSTEMCOLOR_MASK
= 0x0000FFFF;
84 /** Swaps the red and blue component of the passed color. */
85 inline sal_uInt32
lclSwapRedBlue( sal_uInt32 nColor
)
87 return static_cast< sal_uInt32
>( (nColor
& 0xFF00FF00) | ((nColor
& 0x0000FF) << 16) | ((nColor
& 0xFF0000) >> 16) );
90 /** Returns the UNO RGB color from the passed encoded OLE BGR color. */
91 inline sal_Int32
lclDecodeBgrColor( sal_uInt32 nOleColor
)
93 return static_cast< sal_Int32
>( lclSwapRedBlue( nOleColor
) & 0xFFFFFF );
96 const sal_uInt32 OLE_STDPIC_ID
= 0x0000746C;
110 const sal_Int16 TOGGLEBUTTON
= -1;
111 const sal_Int16 FORMULAFIELD
= -2;
113 typedef std::map
< sal_Int16
, GUIDCNamePair
> GUIDCNamePairMap
;
114 class classIdToGUIDCNamePairMap
116 GUIDCNamePairMap mnIdToGUIDCNamePairMap
;
117 classIdToGUIDCNamePairMap();
119 static GUIDCNamePairMap
& get();
122 classIdToGUIDCNamePairMap::classIdToGUIDCNamePairMap()
124 IdCntrlData initialCntrlData
[] =
126 // Command button MUST be at index 0
127 { FormComponentType::COMMANDBUTTON
,
128 { AX_GUID_COMMANDBUTTON
, "CommandButton"} ,
130 // Toggle button MUST be at index 1
132 { AX_GUID_TOGGLEBUTTON
, "ToggleButton"},
134 { FormComponentType::FIXEDTEXT
,
135 { AX_GUID_LABEL
, "Label"},
137 { FormComponentType::TEXTFIELD
,
138 { AX_GUID_TEXTBOX
, "TextBox"},
140 { FormComponentType::LISTBOX
,
141 { AX_GUID_LISTBOX
, "ListBox"},
143 { FormComponentType::COMBOBOX
,
144 { AX_GUID_COMBOBOX
, "ComboBox"},
146 { FormComponentType::CHECKBOX
,
147 { AX_GUID_CHECKBOX
, "CheckBox"},
149 { FormComponentType::RADIOBUTTON
,
150 { AX_GUID_OPTIONBUTTON
, "OptionButton"},
152 { FormComponentType::IMAGECONTROL
,
153 { AX_GUID_IMAGE
, "Image"},
155 { FormComponentType::DATEFIELD
,
156 { AX_GUID_TEXTBOX
, "TextBox"},
158 { FormComponentType::TIMEFIELD
,
159 { AX_GUID_TEXTBOX
, "TextBox"},
161 { FormComponentType::NUMERICFIELD
,
162 { AX_GUID_TEXTBOX
, "TextBox"},
164 { FormComponentType::CURRENCYFIELD
,
165 { AX_GUID_TEXTBOX
, "TextBox"},
167 { FormComponentType::PATTERNFIELD
,
168 { AX_GUID_TEXTBOX
, "TextBox"},
171 { AX_GUID_TEXTBOX
, "TextBox"},
173 { FormComponentType::IMAGEBUTTON
,
174 { AX_GUID_COMMANDBUTTON
, "CommandButton"},
176 { FormComponentType::SPINBUTTON
,
177 { AX_GUID_SPINBUTTON
, "SpinButton"},
179 { FormComponentType::SCROLLBAR
,
180 { AX_GUID_SCROLLBAR
, "ScrollBar"},
183 int length
= SAL_N_ELEMENTS( initialCntrlData
);
184 IdCntrlData
* pData
= initialCntrlData
;
185 for ( int index
= 0; index
< length
; ++index
, ++pData
)
186 mnIdToGUIDCNamePairMap
[ pData
->nId
] = pData
->aData
;
189 GUIDCNamePairMap
& classIdToGUIDCNamePairMap::get()
191 static classIdToGUIDCNamePairMap theInst
;
192 return theInst
.mnIdToGUIDCNamePairMap
;
195 template< typename Type
>
196 void lclAppendHex( OUStringBuffer
& orBuffer
, Type nValue
)
198 const sal_Int32 nWidth
= 2 * sizeof( Type
);
199 static const sal_Unicode spcHexChars
[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
200 orBuffer
.setLength( orBuffer
.getLength() + nWidth
);
201 for( sal_Int32 nCharIdx
= orBuffer
.getLength() - 1, nCharEnd
= nCharIdx
- nWidth
; nCharIdx
> nCharEnd
; --nCharIdx
, nValue
>>= 4 )
202 orBuffer
[nCharIdx
] = spcHexChars
[ nValue
& 0xF ];
207 StdFontInfo::StdFontInfo() :
209 mnWeight( OLE_STDFONT_NORMAL
),
210 mnCharSet( WINDOWS_CHARSET_ANSI
),
215 StdFontInfo::StdFontInfo( const OUString
& rName
, sal_uInt32 nHeight
,
216 sal_uInt16 nWeight
, sal_uInt16 nCharSet
, sal_uInt8 nFlags
) :
220 mnCharSet( nCharSet
),
225 sal_Int32
OleHelper::decodeOleColor(
226 const GraphicHelper
& rGraphicHelper
, sal_uInt32 nOleColor
, bool bDefaultColorBgr
)
228 static const sal_Int32 spnSystemColors
[] =
230 XML_scrollBar
, XML_background
, XML_activeCaption
, XML_inactiveCaption
,
231 XML_menu
, XML_window
, XML_windowFrame
, XML_menuText
,
232 XML_windowText
, XML_captionText
, XML_activeBorder
, XML_inactiveBorder
,
233 XML_appWorkspace
, XML_highlight
, XML_highlightText
, XML_btnFace
,
234 XML_btnShadow
, XML_grayText
, XML_btnText
, XML_inactiveCaptionText
,
235 XML_btnHighlight
, XML_3dDkShadow
, XML_3dLight
, XML_infoText
,
239 switch( nOleColor
& OLE_COLORTYPE_MASK
)
241 case OLE_COLORTYPE_CLIENT
:
242 return bDefaultColorBgr
? lclDecodeBgrColor( nOleColor
) : rGraphicHelper
.getPaletteColor( nOleColor
& OLE_PALETTECOLOR_MASK
);
244 case OLE_COLORTYPE_PALETTE
:
245 return rGraphicHelper
.getPaletteColor( nOleColor
& OLE_PALETTECOLOR_MASK
);
247 case OLE_COLORTYPE_BGR
:
248 return lclDecodeBgrColor( nOleColor
);
250 case OLE_COLORTYPE_SYSCOLOR
:
251 return rGraphicHelper
.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors
, nOleColor
& OLE_SYSTEMCOLOR_MASK
, XML_TOKEN_INVALID
), API_RGB_WHITE
);
253 OSL_FAIL( "OleHelper::decodeOleColor - unknown color type" );
254 return API_RGB_BLACK
;
257 sal_uInt32
OleHelper::encodeOleColor( sal_Int32 nRgbColor
)
259 return OLE_COLORTYPE_BGR
| lclSwapRedBlue( static_cast< sal_uInt32
>( nRgbColor
& 0xFFFFFF ) );
262 void OleHelper::exportGuid( BinaryOutputStream
& rOStr
, const SvGlobalName
& rId
)
264 rOStr
.WriteUInt32( rId
.GetCLSID().Data1
);
265 rOStr
.WriteUInt16( rId
.GetCLSID().Data2
);
266 rOStr
.WriteUInt16( rId
.GetCLSID().Data3
);
267 rOStr
.writeArray( rId
.GetCLSID().Data4
, 8 );
270 OUString
OleHelper::importGuid( BinaryInputStream
& rInStrm
)
272 OUStringBuffer aBuffer
;
273 aBuffer
.append( '{' );
274 lclAppendHex( aBuffer
, rInStrm
.readuInt32() );
275 aBuffer
.append( '-' );
276 lclAppendHex( aBuffer
, rInStrm
.readuInt16() );
277 aBuffer
.append( '-' );
278 lclAppendHex( aBuffer
, rInStrm
.readuInt16() );
279 aBuffer
.append( '-' );
280 lclAppendHex( aBuffer
, rInStrm
.readuInt8() );
281 lclAppendHex( aBuffer
, rInStrm
.readuInt8() );
282 aBuffer
.append( '-' );
283 for( int nIndex
= 0; nIndex
< 6; ++nIndex
)
284 lclAppendHex( aBuffer
, rInStrm
.readuInt8() );
285 aBuffer
.append( '}' );
286 return aBuffer
.makeStringAndClear();
289 bool OleHelper::importStdFont( StdFontInfo
& orFontInfo
, BinaryInputStream
& rInStrm
, bool bWithGuid
)
293 bool bIsStdFont
= importGuid( rInStrm
) == OLE_GUID_STDFONT
;
294 OSL_ENSURE( bIsStdFont
, "OleHelper::importStdFont - unexpected header GUID, expected StdFont" );
299 sal_uInt8 nVersion
, nNameLen
;
300 nVersion
= rInStrm
.readuChar();
301 orFontInfo
.mnCharSet
= rInStrm
.readuInt16();
302 orFontInfo
.mnFlags
= rInStrm
.readuChar();
303 orFontInfo
.mnWeight
= rInStrm
.readuInt16();
304 orFontInfo
.mnHeight
= rInStrm
.readuInt32();
305 nNameLen
= rInStrm
.readuChar();
306 // according to spec the name is ASCII
307 orFontInfo
.maName
= rInStrm
.readCharArrayUC( nNameLen
, RTL_TEXTENCODING_ASCII_US
);
308 OSL_ENSURE( nVersion
<= 1, "OleHelper::importStdFont - wrong version" );
309 return !rInStrm
.isEof() && (nVersion
<= 1);
312 bool OleHelper::importStdPic( StreamDataSequence
& orGraphicData
, BinaryInputStream
& rInStrm
, bool bWithGuid
)
316 bool bIsStdPic
= importGuid( rInStrm
) == OLE_GUID_STDPIC
;
317 OSL_ENSURE( bIsStdPic
, "OleHelper::importStdPic - unexpected header GUID, expected StdPic" );
322 sal_uInt32 nStdPicId
;
324 nStdPicId
= rInStrm
.readuInt32();
325 nBytes
= rInStrm
.readInt32();
326 OSL_ENSURE( nStdPicId
== OLE_STDPIC_ID
, "OleHelper::importStdPic - unexpected header version" );
327 return !rInStrm
.isEof() && (nStdPicId
== OLE_STDPIC_ID
) && (nBytes
> 0) && (rInStrm
.readData( orGraphicData
, nBytes
) == nBytes
);
330 Reference
< ::com::sun::star::frame::XFrame
>
331 lcl_getFrame( const Reference
< ::com::sun::star::frame::XModel
>& rxModel
)
333 Reference
< ::com::sun::star::frame::XFrame
> xFrame
;
336 Reference
< ::com::sun::star::frame::XController
> xController
= rxModel
->getCurrentController();
337 xFrame
= xController
.is() ? xController
->getFrame() : NULL
;
342 class OleFormCtrlExportHelper
344 ::oox::ole::EmbeddedControl maControl
;
345 ::oox::ole::ControlModelBase
* mpModel
;
346 ::oox::GraphicHelper maGrfHelper
;
347 Reference
< XModel
> mxDocModel
;
348 Reference
< XControlModel
> mxControlModel
;
355 OleFormCtrlExportHelper( const Reference
< XComponentContext
>& rxCtx
, const Reference
< XModel
>& xDocModel
, const Reference
< XControlModel
>& xModel
);
356 virtual ~OleFormCtrlExportHelper() { }
360 if ( maGUID
.getLength() > 2 )
361 sResult
= maGUID
.copy(1, maGUID
.getLength() - 2 );
364 OUString
getFullName() { return maFullName
; }
365 OUString
getTypeName() { return maTypeName
; }
366 bool isValid() { return mpModel
!= NULL
; }
367 void exportName( const Reference
< XOutputStream
>& rxOut
);
368 void exportCompObj( const Reference
< XOutputStream
>& rxOut
);
369 void exportControl( const Reference
< XOutputStream
>& rxOut
, const ::com::sun::star::awt::Size
& rSize
);
371 OleFormCtrlExportHelper::OleFormCtrlExportHelper( const Reference
< XComponentContext
>& rxCtx
, const Reference
< XModel
>& rxDocModel
, const Reference
< XControlModel
>& xCntrlModel
) : maControl( "Unknown" ), mpModel( NULL
), maGrfHelper( rxCtx
, lcl_getFrame( rxDocModel
), StorageRef() ), mxDocModel( rxDocModel
), mxControlModel( xCntrlModel
)
373 // try to get the guid
374 Reference
< com::sun::star::beans::XPropertySet
> xProps( xCntrlModel
, UNO_QUERY
);
377 sal_Int16 nClassId
= 0;
378 PropertySet
aPropSet( mxControlModel
);
379 if ( aPropSet
.getProperty( nClassId
, PROP_ClassId
) )
381 /* pseudo ripped from legacy msocximex:
382 "There is a truly horrible thing with EditControls and FormattedField
383 Controls, they both pretend to have an EDITBOX ClassId for compatibility
384 reasons, at some stage in the future hopefully there will be a proper
385 FormulaField ClassId rather than this piggybacking two controls onto the
386 same ClassId, cmc." - when fixed the fake FORMULAFIELD id entry
387 and definition above can be removed/replaced
389 if ( nClassId
== FormComponentType::TEXTFIELD
)
391 Reference
< XServiceInfo
> xInfo( xCntrlModel
,
394 supportsService( "com.sun.star.form.component.FormattedField" ) )
395 nClassId
= FORMULAFIELD
;
397 else if ( nClassId
== FormComponentType::COMMANDBUTTON
)
399 bool bToggle
= false;
400 if ( aPropSet
.getProperty( bToggle
, PROP_Toggle
) && bToggle
)
401 nClassId
= TOGGLEBUTTON
;
403 else if ( nClassId
== FormComponentType::CONTROL
)
405 Reference
< XServiceInfo
> xInfo( xCntrlModel
,
407 if (xInfo
->supportsService("com.sun.star.form.component.ImageControl" ) )
408 nClassId
= FormComponentType::IMAGECONTROL
;
411 GUIDCNamePairMap
& cntrlMap
= classIdToGUIDCNamePairMap::get();
412 GUIDCNamePairMap::iterator it
= cntrlMap
.find( nClassId
);
413 if ( it
!= cntrlMap
.end() )
415 aPropSet
.getProperty(maName
, PROP_Name
);
416 maTypeName
= OUString::createFromAscii( it
->second
.sName
);
417 maFullName
= "Microsoft Forms 2.0 " + maTypeName
;
418 maControl
= EmbeddedControl( maName
);
419 maGUID
= OUString::createFromAscii( it
->second
.sGUID
);
420 mpModel
= maControl
.createModelFromGuid( maGUID
);
426 void OleFormCtrlExportHelper::exportName( const Reference
< XOutputStream
>& rxOut
)
428 oox::BinaryXOutputStream
aOut( rxOut
, false );
429 aOut
.writeUnicodeArray( maName
);
433 void OleFormCtrlExportHelper::exportCompObj( const Reference
< XOutputStream
>& rxOut
)
435 oox::BinaryXOutputStream
aOut( rxOut
, false );
437 mpModel
->exportCompObj( aOut
);
440 void OleFormCtrlExportHelper::exportControl( const Reference
< XOutputStream
>& rxOut
, const Size
& rSize
)
442 oox::BinaryXOutputStream
aOut( rxOut
, false );
445 ::oox::ole::ControlConverter
aConv( mxDocModel
, maGrfHelper
);
446 maControl
.convertFromProperties( mxControlModel
, aConv
);
447 mpModel
->maSize
.first
= rSize
.Width
;
448 mpModel
->maSize
.second
= rSize
.Height
;
449 mpModel
->exportBinaryModel( aOut
);
453 MSConvertOCXControls::MSConvertOCXControls( const Reference
< ::com::sun::star::frame::XModel
>& rxModel
) : SvxMSConvertOCXControls( rxModel
), mxCtx( comphelper::getProcessComponentContext() ), maGrfHelper( mxCtx
, lcl_getFrame( rxModel
), StorageRef() )
457 MSConvertOCXControls::~MSConvertOCXControls()
462 MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream
& rInStrm
, Reference
< XFormComponent
>& rxFormComp
, const OUString
& rGuidString
)
464 ::oox::ole::EmbeddedControl
aControl( "Unknown" );
465 if( ::oox::ole::ControlModelBase
* pModel
= aControl
.createModelFromGuid( rGuidString
) )
467 pModel
->importBinaryModel( rInStrm
);
468 rxFormComp
.set( mxCtx
->getServiceManager()->createInstanceWithContext( pModel
->getServiceName(), mxCtx
), UNO_QUERY
);
469 Reference
< XControlModel
> xCtlModel( rxFormComp
, UNO_QUERY
);
470 ::oox::ole::ControlConverter
aConv( mxModel
, maGrfHelper
);
471 aControl
.convertProperties( xCtlModel
, aConv
);
473 return rxFormComp
.is();
477 MSConvertOCXControls::ReadOCXCtlsStream( tools::SvRef
<SotStorageStream
>& rSrc1
, Reference
< XFormComponent
> & rxFormComp
,
479 sal_Int32 nStreamSize
)
483 BinaryXInputStream
aCtlsStrm( Reference
< XInputStream
>( new utl::OSeekableInputStreamWrapper( *rSrc1
) ), true );
484 aCtlsStrm
.seek( nPos
);
485 OUString aStrmClassId
= ::oox::ole::OleHelper::importGuid( aCtlsStrm
);
486 return importControlFromStream( aCtlsStrm
, rxFormComp
, aStrmClassId
, nStreamSize
);
491 bool MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream
& rInStrm
, Reference
< XFormComponent
>& rxFormComp
, const OUString
& rStrmClassId
,
492 sal_Int32 nStreamSize
)
494 if ( !rInStrm
.isEof() )
496 // Special processing for those html controls
497 bool bOneOfHtmlControls
= false;
498 if ( rStrmClassId
.toAsciiUpperCase() == HTML_GUID_SELECT
499 || rStrmClassId
.toAsciiUpperCase() == HTML_GUID_TEXTBOX
)
500 bOneOfHtmlControls
= true;
502 if ( bOneOfHtmlControls
)
504 // html controls don't seem have a handy record length following the GUID
505 // in the binary stream.
506 // Given the control stream length create a stream of nStreamSize bytes starting from
507 // nPos ( offset by the guid already read in )
510 const int nGuidSize
= 0x10;
511 StreamDataSequence aDataSeq
;
512 sal_Int32 nBytesToRead
= nStreamSize
- nGuidSize
;
513 while ( nBytesToRead
)
514 nBytesToRead
-= rInStrm
.readData( aDataSeq
, nBytesToRead
);
515 SequenceInputStream
aInSeqStream( aDataSeq
);
516 importControlFromStream( aInSeqStream
, rxFormComp
, rStrmClassId
);
520 importControlFromStream( rInStrm
, rxFormComp
, rStrmClassId
);
523 return rxFormComp
.is();
526 bool MSConvertOCXControls::ReadOCXStorage( tools::SvRef
<SotStorage
>& xOleStg
,
527 Reference
< XFormComponent
> & rxFormComp
)
531 tools::SvRef
<SotStorageStream
> pNameStream
= xOleStg
->OpenSotStream( OUString("\3OCXNAME"));
532 BinaryXInputStream
aNameStream( Reference
< XInputStream
>( new utl::OSeekableInputStreamWrapper( *pNameStream
) ), true );
534 tools::SvRef
<SotStorageStream
> pContents
= xOleStg
->OpenSotStream( OUString("contents"));
535 BinaryXInputStream
aInStrm( Reference
< XInputStream
>( new utl::OSeekableInputStreamWrapper( *pContents
) ), true );
537 tools::SvRef
<SotStorageStream
> pClsStrm
= xOleStg
->OpenSotStream(OUString("\1CompObj"));
538 BinaryXInputStream
aClsStrm( Reference
< XInputStream
>( new utl::OSeekableInputStreamWrapper(*pClsStrm
) ), true );
541 OUString aStrmClassId
= ::oox::ole::OleHelper::importGuid( aClsStrm
);
542 if ( importControlFromStream( aInStrm
, rxFormComp
, aStrmClassId
, aInStrm
.size() ) )
544 OUString aName
= aNameStream
.readNulUnicodeArray();
545 Reference
< XControlModel
> xCtlModel( rxFormComp
, UNO_QUERY
);
546 if ( !aName
.isEmpty() && xCtlModel
.is() )
548 PropertyMap aPropMap
;
549 aPropMap
.setProperty( PROP_Name
, aName
);
550 PropertySet
aPropSet( xCtlModel
);
551 aPropSet
.setProperties( aPropMap
);
553 return rxFormComp
.is();
559 bool MSConvertOCXControls::WriteOCXExcelKludgeStream( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& rxModel
, const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
>& xOutStrm
, const com::sun::star::uno::Reference
< com::sun::star::awt::XControlModel
> &rxControlModel
, const com::sun::star::awt::Size
& rSize
,OUString
&rName
)
561 OleFormCtrlExportHelper
exportHelper( comphelper::getProcessComponentContext(), rxModel
, rxControlModel
);
562 if ( !exportHelper
.isValid() )
564 rName
= exportHelper
.getTypeName();
566 OUString sId
= exportHelper
.getGUID();
568 BinaryXOutputStream
xOut( xOutStrm
, false );
569 OleHelper::exportGuid( xOut
, aName
);
570 exportHelper
.exportControl( xOutStrm
, rSize
);
574 bool MSConvertOCXControls::WriteOCXStream( const Reference
< XModel
>& rxModel
, tools::SvRef
<SotStorage
> &xOleStg
,
575 const Reference
< XControlModel
> &rxControlModel
,
576 const com::sun::star::awt::Size
& rSize
, OUString
&rName
)
580 OleFormCtrlExportHelper
exportHelper( comphelper::getProcessComponentContext(), rxModel
, rxControlModel
);
582 if ( !exportHelper
.isValid() )
585 OUString sId
= exportHelper
.getGUID();
588 OUString sFullName
= exportHelper
.getFullName();
589 rName
= exportHelper
.getTypeName();
590 xOleStg
->SetClass( aName
, SotClipboardFormatId::EMBEDDED_OBJ_OLE
, sFullName
);
592 tools::SvRef
<SotStorageStream
> pNameStream
= xOleStg
->OpenSotStream(OUString("\3OCXNAME"));
593 Reference
< XOutputStream
> xOut
= new utl::OSeekableOutputStreamWrapper( *pNameStream
);
594 exportHelper
.exportName( xOut
);
597 tools::SvRef
<SotStorageStream
> pObjStream
= xOleStg
->OpenSotStream(OUString("\1CompObj"));
598 Reference
< XOutputStream
> xOut
= new utl::OSeekableOutputStreamWrapper( *pObjStream
);
599 exportHelper
.exportCompObj( xOut
);
602 tools::SvRef
<SotStorageStream
> pContents
= xOleStg
->OpenSotStream(OUString("contents"));
603 Reference
< XOutputStream
> xOut
= new utl::OSeekableOutputStreamWrapper( *pContents
);
604 exportHelper
.exportControl( xOut
, rSize
);
612 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */