LibreOffice Module oox (master) 1
olehelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <oox/ole/olehelper.hxx>
21
22#include <rtl/ustrbuf.hxx>
23#include <sot/storage.hxx>
24#include <osl/diagnose.h>
28#include <oox/token/properties.hxx>
29#include <oox/token/tokens.hxx>
30#include <oox/ole/axcontrol.hxx>
33
34#include <com/sun/star/awt/XControlModel.hpp>
35#include <com/sun/star/beans/XPropertySet.hpp>
36#include <com/sun/star/form/FormComponentType.hpp>
37#include <com/sun/star/form/XFormComponent.hpp>
38#include <com/sun/star/frame/XFrame.hpp>
39#include <com/sun/star/frame/XModel.hpp>
40#include <com/sun/star/lang/XServiceInfo.hpp>
41#include <com/sun/star/awt/Size.hpp>
42#include <com/sun/star/uno/XComponentContext.hpp>
43
44#include <tools/globname.hxx>
47#include <utility>
48
49namespace oox::ole {
50
51using ::com::sun::star::form::XFormComponent;
52using ::com::sun::star::awt::XControlModel;
53using ::com::sun::star::awt::Size;
54using ::com::sun::star::frame::XModel;
55using ::com::sun::star::io::XOutputStream;
56using ::com::sun::star::io::XInputStream;
57using ::com::sun::star::beans::XPropertySet;
58using ::com::sun::star::uno::Reference;
59using ::com::sun::star::uno::UNO_QUERY;
60using ::com::sun::star::uno::XComponentContext;
61using ::com::sun::star::lang::XServiceInfo;
62
63using namespace ::com::sun::star::form;
64
65namespace {
66
67const sal_uInt32 OLE_COLORTYPE_MASK = 0xFF000000;
68const sal_uInt32 OLE_COLORTYPE_CLIENT = 0x00000000;
69const sal_uInt32 OLE_COLORTYPE_PALETTE = 0x01000000;
70const sal_uInt32 OLE_COLORTYPE_BGR = 0x02000000;
71const sal_uInt32 OLE_COLORTYPE_SYSCOLOR = 0x80000000;
72
73const sal_uInt32 OLE_PALETTECOLOR_MASK = 0x0000FFFF;
74const sal_uInt32 OLE_SYSTEMCOLOR_MASK = 0x0000FFFF;
75
77sal_uInt32 lclSwapRedBlue( sal_uInt32 nColor )
78{
79 return static_cast< sal_uInt32 >( (nColor & 0xFF00FF00) | ((nColor & 0x0000FF) << 16) | ((nColor & 0xFF0000) >> 16) );
80}
81
83::Color lclDecodeBgrColor( sal_uInt32 nOleColor )
84{
85 return ::Color( ColorTransparency, lclSwapRedBlue( nOleColor ) & 0xFFFFFF );
86}
87
88const sal_uInt32 OLE_STDPIC_ID = 0x0000746C;
89
90struct GUIDCNamePair
91{
92 const char* sGUID;
93 const char* sName;
94};
95
96struct IdCntrlData
97{
98 sal_Int16 nId;
99 GUIDCNamePair aData;
100};
101
102const sal_Int16 TOGGLEBUTTON = -1;
103const sal_Int16 FORMULAFIELD = -2;
104
105typedef std::map< sal_Int16, GUIDCNamePair > GUIDCNamePairMap;
106class classIdToGUIDCNamePairMap
107{
108 GUIDCNamePairMap mnIdToGUIDCNamePairMap;
109 classIdToGUIDCNamePairMap();
110public:
111 static GUIDCNamePairMap& get();
112};
113
114classIdToGUIDCNamePairMap::classIdToGUIDCNamePairMap()
115{
116 static IdCntrlData const initialCntrlData[] =
117 {
118 // Command button MUST be at index 0
119 { FormComponentType::COMMANDBUTTON,
120 { AX_GUID_COMMANDBUTTON, "CommandButton"} ,
121 },
122 // Toggle button MUST be at index 1
123 { TOGGLEBUTTON,
124 { AX_GUID_TOGGLEBUTTON, "ToggleButton"},
125 },
126 { FormComponentType::FIXEDTEXT,
127 { AX_GUID_LABEL, "Label"},
128 },
129 { FormComponentType::TEXTFIELD,
130 { AX_GUID_TEXTBOX, "TextBox"},
131 },
132 { FormComponentType::LISTBOX,
133 { AX_GUID_LISTBOX, "ListBox"},
134 },
135 { FormComponentType::COMBOBOX,
136 { AX_GUID_COMBOBOX, "ComboBox"},
137 },
138 { FormComponentType::CHECKBOX,
139 { AX_GUID_CHECKBOX, "CheckBox"},
140 },
141 { FormComponentType::RADIOBUTTON,
142 { AX_GUID_OPTIONBUTTON, "OptionButton"},
143 },
144 { FormComponentType::IMAGECONTROL,
145 { AX_GUID_IMAGE, "Image"},
146 },
147 { FormComponentType::DATEFIELD,
148 { AX_GUID_TEXTBOX, "TextBox"},
149 },
150 { FormComponentType::TIMEFIELD,
151 { AX_GUID_TEXTBOX, "TextBox"},
152 },
153 { FormComponentType::NUMERICFIELD,
154 { AX_GUID_TEXTBOX, "TextBox"},
155 },
156 { FormComponentType::CURRENCYFIELD,
157 { AX_GUID_TEXTBOX, "TextBox"},
158 },
159 { FormComponentType::PATTERNFIELD,
160 { AX_GUID_TEXTBOX, "TextBox"},
161 },
162 { FORMULAFIELD,
163 { AX_GUID_TEXTBOX, "TextBox"},
164 },
165 { FormComponentType::IMAGEBUTTON,
166 { AX_GUID_COMMANDBUTTON, "CommandButton"},
167 },
168 { FormComponentType::SPINBUTTON,
169 { AX_GUID_SPINBUTTON, "SpinButton"},
170 },
171 { FormComponentType::SCROLLBAR,
172 { AX_GUID_SCROLLBAR, "ScrollBar"},
173 }
174 };
175 int const length = std::size( initialCntrlData );
176 IdCntrlData const * pData = initialCntrlData;
177 for ( int index = 0; index < length; ++index, ++pData )
178 mnIdToGUIDCNamePairMap[ pData->nId ] = pData->aData;
179};
180
181GUIDCNamePairMap& classIdToGUIDCNamePairMap::get()
182{
183 static classIdToGUIDCNamePairMap theInst;
184 return theInst.mnIdToGUIDCNamePairMap;
185}
186
187template< typename Type >
188void lclAppendHex( OUStringBuffer& orBuffer, Type nValue )
189{
190 const sal_Int32 nWidth = 2 * sizeof( Type );
191 static const sal_Unicode spcHexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
192 orBuffer.setLength( orBuffer.getLength() + nWidth );
193 for( sal_Int32 nCharIdx = orBuffer.getLength() - 1, nCharEnd = nCharIdx - nWidth; nCharIdx > nCharEnd; --nCharIdx, nValue >>= 4 )
194 orBuffer[nCharIdx] = spcHexChars[ nValue & 0xF ];
195}
196
197} // namespace
198
200 mnHeight( 0 ),
202 mnCharSet( WINDOWS_CHARSET_ANSI ),
203 mnFlags( 0 )
204{
205}
206
207StdFontInfo::StdFontInfo( OUString aName, sal_uInt32 nHeight ) :
208 maName(std::move( aName )),
209 mnHeight( nHeight ),
211 mnCharSet( WINDOWS_CHARSET_ANSI ),
212 mnFlags( 0 )
213{
214}
215
217 const GraphicHelper& rGraphicHelper, sal_uInt32 nOleColor, bool bDefaultColorBgr )
218{
219 static const sal_Int32 spnSystemColors[] =
220 {
221 XML_scrollBar, XML_background, XML_activeCaption, XML_inactiveCaption,
222 XML_menu, XML_window, XML_windowFrame, XML_menuText,
223 XML_windowText, XML_captionText, XML_activeBorder, XML_inactiveBorder,
224 XML_appWorkspace, XML_highlight, XML_highlightText, XML_btnFace,
225 XML_btnShadow, XML_grayText, XML_btnText, XML_inactiveCaptionText,
226 XML_btnHighlight, XML_3dDkShadow, XML_3dLight, XML_infoText,
227 XML_infoBk
228 };
229
230 switch( nOleColor & OLE_COLORTYPE_MASK )
231 {
232 case OLE_COLORTYPE_CLIENT:
233 return bDefaultColorBgr ? lclDecodeBgrColor( nOleColor ) : rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK );
234
235 case OLE_COLORTYPE_PALETTE:
236 return rGraphicHelper.getPaletteColor( nOleColor & OLE_PALETTECOLOR_MASK );
237
238 case OLE_COLORTYPE_BGR:
239 return lclDecodeBgrColor( nOleColor );
240
241 case OLE_COLORTYPE_SYSCOLOR:
242 return rGraphicHelper.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nOleColor & OLE_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE );
243 }
244 OSL_FAIL( "OleHelper::decodeOleColor - unknown color type" );
245 return API_RGB_BLACK;
246}
247
248sal_uInt32 OleHelper::encodeOleColor( sal_Int32 nRgbColor )
249{
250 return OLE_COLORTYPE_BGR | lclSwapRedBlue( static_cast< sal_uInt32 >( nRgbColor & 0xFFFFFF ) );
251}
252
254{
255 rOStr.WriteUInt32( rId.GetCLSID().Data1 );
256 rOStr.WriteUInt16( rId.GetCLSID().Data2 );
257 rOStr.WriteUInt16( rId.GetCLSID().Data3 );
258 rOStr.writeArray( rId.GetCLSID().Data4, 8 );
259}
260
262{
263 OUStringBuffer aBuffer(40);
264 aBuffer.append( '{' );
265 lclAppendHex( aBuffer, rInStrm.readuInt32() );
266 aBuffer.append( '-' );
267 lclAppendHex( aBuffer, rInStrm.readuInt16() );
268 aBuffer.append( '-' );
269 lclAppendHex( aBuffer, rInStrm.readuInt16() );
270 aBuffer.append( '-' );
271 lclAppendHex( aBuffer, rInStrm.readuInt8() );
272 lclAppendHex( aBuffer, rInStrm.readuInt8() );
273 aBuffer.append( '-' );
274 for( int nIndex = 0; nIndex < 6; ++nIndex )
275 lclAppendHex( aBuffer, rInStrm.readuInt8() );
276 aBuffer.append( '}' );
277 return aBuffer.makeStringAndClear();
278}
279
280bool OleHelper::importStdFont( StdFontInfo& orFontInfo, BinaryInputStream& rInStrm, bool bWithGuid )
281{
282 if( bWithGuid )
283 {
284 bool bIsStdFont = importGuid( rInStrm ) == OLE_GUID_STDFONT;
285 OSL_ENSURE( bIsStdFont, "OleHelper::importStdFont - unexpected header GUID, expected StdFont" );
286 if( !bIsStdFont )
287 return false;
288 }
289
290 sal_uInt8 nVersion, nNameLen;
291 nVersion = rInStrm.readuChar();
292 orFontInfo.mnCharSet = rInStrm.readuInt16();
293 orFontInfo.mnFlags = rInStrm.readuChar();
294 orFontInfo.mnWeight = rInStrm.readuInt16();
295 orFontInfo.mnHeight = rInStrm.readuInt32();
296 nNameLen = rInStrm.readuChar();
297 // according to spec the name is ASCII
298 orFontInfo.maName = rInStrm.readCharArrayUC( nNameLen, RTL_TEXTENCODING_ASCII_US );
299 OSL_ENSURE( nVersion <= 1, "OleHelper::importStdFont - wrong version" );
300 return !rInStrm.isEof() && (nVersion <= 1);
301}
302
304{
305 bool bIsStdPic = importGuid( rInStrm ) == OLE_GUID_STDPIC;
306 OSL_ENSURE( bIsStdPic, "OleHelper::importStdPic - unexpected header GUID, expected StdPic" );
307 if( !bIsStdPic )
308 return false;
309
310 sal_uInt32 nStdPicId;
311 sal_Int32 nBytes;
312 nStdPicId = rInStrm.readuInt32();
313 nBytes = rInStrm.readInt32();
314 OSL_ENSURE( nStdPicId == OLE_STDPIC_ID, "OleHelper::importStdPic - unexpected header version" );
315 return !rInStrm.isEof() && (nStdPicId == OLE_STDPIC_ID) && (nBytes > 0) && (rInStrm.readData( orGraphicData, nBytes ) == nBytes);
316}
317
318static Reference< css::frame::XFrame > lcl_getFrame( const Reference< css::frame::XModel >& rxModel )
319{
320 Reference< css::frame::XFrame > xFrame;
321 if ( rxModel.is() )
322 {
323 Reference< css::frame::XController > xController = rxModel->getCurrentController();
324 xFrame = xController.is() ? xController->getFrame() : nullptr;
325 }
326 return xFrame;
327}
328
329OleFormCtrlExportHelper::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 )
330{
331 // try to get the guid
332 Reference< css::beans::XPropertySet > xProps( xCntrlModel, UNO_QUERY );
333 if ( !xProps.is() )
334 return;
335
336 sal_Int16 nClassId = 0;
337 PropertySet aPropSet( mxControlModel );
338 if ( !aPropSet.getProperty( nClassId, PROP_ClassId ) )
339 return;
340
341 /* pseudo ripped from legacy msocximex:
342 "There is a truly horrible thing with EditControls and FormattedField
343 Controls, they both pretend to have an EDITBOX ClassId for compatibility
344 reasons, at some stage in the future hopefully there will be a proper
345 FormulaField ClassId rather than this piggybacking two controls onto the
346 same ClassId, cmc." - when fixed the fake FORMULAFIELD id entry
347 and definition above can be removed/replaced
348 */
349 if ( nClassId == FormComponentType::TEXTFIELD)
350 {
351 Reference< XServiceInfo > xInfo( xCntrlModel,
352 UNO_QUERY);
353 if (xInfo->
354 supportsService( "com.sun.star.form.component.FormattedField" ) )
355 nClassId = FORMULAFIELD;
356 }
357 else if ( nClassId == FormComponentType::COMMANDBUTTON )
358 {
359 bool bToggle = false;
360 if ( aPropSet.getProperty( bToggle, PROP_Toggle ) && bToggle )
361 nClassId = TOGGLEBUTTON;
362 }
363 else if ( nClassId == FormComponentType::CONTROL )
364 {
365 Reference< XServiceInfo > xInfo( xCntrlModel,
366 UNO_QUERY);
367 if (xInfo->supportsService("com.sun.star.form.component.ImageControl" ) )
368 nClassId = FormComponentType::IMAGECONTROL;
369 }
370
371 GUIDCNamePairMap& cntrlMap = classIdToGUIDCNamePairMap::get();
372 GUIDCNamePairMap::iterator it = cntrlMap.find( nClassId );
373 if ( it != cntrlMap.end() )
374 {
375 aPropSet.getProperty(maName, PROP_Name );
376 maTypeName = OUString::createFromAscii( it->second.sName );
377 maFullName = "Microsoft Forms 2.0 " + maTypeName;
378 mpControl.reset(new EmbeddedControl( maName ));
379 maGUID = OUString::createFromAscii( it->second.sGUID );
380 mpModel = mpControl->createModelFromGuid( maGUID );
381 }
382}
383
385{
386}
387
388void OleFormCtrlExportHelper::exportName( const Reference< XOutputStream >& rxOut )
389{
390 oox::BinaryXOutputStream aOut( rxOut, false );
392 aOut.WriteInt32(0);
393}
394
395void OleFormCtrlExportHelper::exportCompObj( const Reference< XOutputStream >& rxOut )
396{
397 oox::BinaryXOutputStream aOut( rxOut, false );
398 if ( mpModel )
399 mpModel->exportCompObj( aOut );
400}
401
402void OleFormCtrlExportHelper::exportControl( const Reference< XOutputStream >& rxOut, const Size& rSize, bool bAutoClose )
403{
404 oox::BinaryXOutputStream aOut( rxOut, bAutoClose );
405 if ( mpModel )
406 {
408 if(mpControl)
409 mpControl->convertFromProperties( mxControlModel, aConv );
410 mpModel->maSize.first = rSize.Width;
411 mpModel->maSize.second = rSize.Height;
412 mpModel->exportBinaryModel( aOut );
413 }
414}
415
416MSConvertOCXControls::MSConvertOCXControls( const Reference< css::frame::XModel >& rxModel ) : SvxMSConvertOCXControls( rxModel ), mxCtx( comphelper::getProcessComponentContext() ), maGrfHelper( mxCtx, lcl_getFrame( rxModel ), StorageRef() )
417{
418}
419
421{
422}
423
424bool
425MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, std::u16string_view rGuidString )
426{
427 ::oox::ole::EmbeddedControl aControl( "Unknown" );
428 if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString ) )
429 {
430 pModel->importBinaryModel( rInStrm );
431 rxFormComp.set( mxCtx->getServiceManager()->createInstanceWithContext( pModel->getServiceName(), mxCtx ), UNO_QUERY );
432 Reference< XControlModel > xCtlModel( rxFormComp, UNO_QUERY );
434 aControl.convertProperties( xCtlModel, aConv );
435 }
436 return rxFormComp.is();
437}
438
439bool
440MSConvertOCXControls::ReadOCXCtlsStream( tools::SvRef<SotStorageStream> const & rSrc1, Reference< XFormComponent > & rxFormComp,
441 sal_Int32 nPos,
442 sal_Int32 nStreamSize)
443{
444 if ( rSrc1.is() )
445 {
446 BinaryXInputStream aCtlsStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *rSrc1 ) ), true );
447 aCtlsStrm.seek( nPos );
448 OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( aCtlsStrm );
449 return importControlFromStream( aCtlsStrm, rxFormComp, aStrmClassId, nStreamSize );
450 }
451 return false;
452}
453
454bool MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const OUString& rStrmClassId,
455 sal_Int32 nStreamSize)
456{
457 if ( !rInStrm.isEof() )
458 {
459 // Special processing for those html controls
460 bool bOneOfHtmlControls = false;
461 if ( rStrmClassId.toAsciiUpperCase() == HTML_GUID_SELECT
462 || rStrmClassId.toAsciiUpperCase() == HTML_GUID_TEXTBOX )
463 bOneOfHtmlControls = true;
464
465 if ( bOneOfHtmlControls )
466 {
467 // html controls don't seem have a handy record length following the GUID
468 // in the binary stream.
469 // Given the control stream length create a stream of nStreamSize bytes starting from
470 // nPos ( offset by the guid already read in )
471 if ( !nStreamSize )
472 return false;
473 const int nGuidSize = 0x10;
474 StreamDataSequence aDataSeq;
475 sal_Int32 nBytesToRead = nStreamSize - nGuidSize;
476 while ( nBytesToRead )
477 nBytesToRead -= rInStrm.readData( aDataSeq, nBytesToRead );
478 SequenceInputStream aInSeqStream( aDataSeq );
479 importControlFromStream( aInSeqStream, rxFormComp, rStrmClassId );
480 }
481 else
482 {
483 importControlFromStream( rInStrm, rxFormComp, rStrmClassId );
484 }
485 }
486 return rxFormComp.is();
487}
488
490 Reference< XFormComponent > & rxFormComp )
491{
492 if ( xOleStg.is() )
493 {
494 tools::SvRef<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME", StreamMode::READ);
495 BinaryXInputStream aNameStream( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pNameStream ) ), true );
496
497 tools::SvRef<SotStorageStream> pContents = xOleStg->OpenSotStream("contents", StreamMode::READ);
498 BinaryXInputStream aInStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper( *pContents ) ), true );
499
500 tools::SvRef<SotStorageStream> pClsStrm = xOleStg->OpenSotStream("\1CompObj", StreamMode::READ);
501 BinaryXInputStream aClsStrm( Reference< XInputStream >( new utl::OSeekableInputStreamWrapper(*pClsStrm ) ), true );
502 aClsStrm.skip(12);
503
504 OUString aStrmClassId = ::oox::ole::OleHelper::importGuid( aClsStrm );
505 if ( importControlFromStream( aInStrm, rxFormComp, aStrmClassId, aInStrm.size() ) )
506 {
507 OUString aName = aNameStream.readNulUnicodeArray();
508 Reference< XControlModel > xCtlModel( rxFormComp, UNO_QUERY );
509 if ( !aName.isEmpty() && xCtlModel.is() )
510 {
511 PropertyMap aPropMap;
512 aPropMap.setProperty( PROP_Name, aName );
513 PropertySet aPropSet( xCtlModel );
514 aPropSet.setProperties( aPropMap );
515 }
516 return rxFormComp.is();
517 }
518 }
519 return false;
520}
521
522bool 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 )
523{
524 OleFormCtrlExportHelper exportHelper( comphelper::getProcessComponentContext(), rxModel, rxControlModel );
525 if ( !exportHelper.isValid() )
526 return false;
527 rName = exportHelper.getTypeName();
529 aName.MakeId(exportHelper.getGUID());
530 BinaryXOutputStream aOut( xOutStrm, false );
532 exportHelper.exportControl( xOutStrm, rSize );
533 return true;
534}
535
536bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, tools::SvRef<SotStorage> const &xOleStg,
537 const Reference< XControlModel > &rxControlModel,
538 const css::awt::Size& rSize, OUString &rName)
539{
541
542 OleFormCtrlExportHelper exportHelper( comphelper::getProcessComponentContext(), rxModel, rxControlModel );
543
544 if ( !exportHelper.isValid() )
545 return false;
546
547 aName.MakeId(exportHelper.getGUID());
548
549 OUString sFullName = exportHelper.getFullName();
550 rName = exportHelper.getTypeName();
551 xOleStg->SetClass( aName, SotClipboardFormatId::EMBEDDED_OBJ_OLE, sFullName);
552 {
553 tools::SvRef<SotStorageStream> pNameStream = xOleStg->OpenSotStream("\3OCXNAME");
554 Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pNameStream );
555 exportHelper.exportName( xOut );
556 }
557 {
558 tools::SvRef<SotStorageStream> pObjStream = xOleStg->OpenSotStream("\1CompObj");
559 Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pObjStream );
560 exportHelper.exportCompObj( xOut );
561 }
562 {
563 tools::SvRef<SotStorageStream> pContents = xOleStg->OpenSotStream("contents");
564 Reference< XOutputStream > xOut = new utl::OSeekableOutputStreamWrapper( *pContents );
565 exportHelper.exportControl( xOut, rSize );
566 }
567 return true;
568}
569
570} // namespace oox
571
572/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 mnWeight
#define AX_GUID_IMAGE
Definition: axcontrol.hxx:66
#define AX_GUID_COMBOBOX
Definition: axcontrol.hxx:72
#define AX_GUID_SPINBUTTON
Definition: axcontrol.hxx:73
#define AX_GUID_CHECKBOX
Definition: axcontrol.hxx:68
#define HTML_GUID_SELECT
Definition: axcontrol.hxx:79
#define AX_GUID_LABEL
Definition: axcontrol.hxx:65
#define AX_GUID_TEXTBOX
Definition: axcontrol.hxx:70
#define AX_GUID_SCROLLBAR
Definition: axcontrol.hxx:74
#define HTML_GUID_TEXTBOX
Definition: axcontrol.hxx:80
#define AX_GUID_COMMANDBUTTON
Definition: axcontrol.hxx:64
#define AX_GUID_LISTBOX
Definition: axcontrol.hxx:71
#define AX_GUID_TOGGLEBUTTON
Definition: axcontrol.hxx:67
#define AX_GUID_OPTIONBUTTON
Definition: axcontrol.hxx:69
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const SvGUID & GetCLSID() const
css::uno::Reference< css::frame::XModel > mxModel
Interface for binary input stream classes.
OUString readCharArrayUC(sal_Int32 nChars, rtl_TextEncoding eTextEnc)
Reads a byte character array and returns a Unicode string.
OUString readNulUnicodeArray()
Reads a NUL-terminated Unicode character array and returns the string.
virtual sal_Int32 readData(StreamDataSequence &orData, sal_Int32 nBytes, size_t nAtomSize=1)=0
Derived classes implement reading nBytes bytes to the passed sequence.
Interface for binary output stream classes.
BinaryOutputStream & WriteUInt32(sal_uInt32 x)
BinaryOutputStream & WriteInt32(sal_Int32 x)
BinaryOutputStream & WriteUInt16(sal_uInt16 x)
void writeArray(Type *opnArray, sal_Int32 nElemCount)
void writeUnicodeArray(const OUString &rString)
bool isEof() const
Returns true, if the stream position is invalid (EOF).
Wraps a UNO input stream and provides convenient access functions.
virtual void skip(sal_Int32 nBytes, size_t nAtomSize=1) override
Seeks the stream forward by the passed number of bytes.
Wraps a UNO output stream and provides convenient access functions.
virtual sal_Int64 size() const override
Returns the size of the stream, if wrapped stream is seekable, otherwise -1.
virtual void seek(sal_Int64 nPos) override
Seeks the stream to the passed position, if wrapped stream is seekable.
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
virtual ::Color getPaletteColor(sal_Int32 nPaletteIdx) const
Derived classes may implement to resolve a palette index to an RGB color.
::Color getSystemColor(sal_Int32 nToken, ::Color nDefaultRgb=API_RGB_TRANSPARENT) const
Returns a system color specified by the passed XML token identifier.
A helper that maps property identifiers to property values.
Definition: propertymap.hxx:52
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
Definition: propertymap.hxx:72
A wrapper for a UNO property set.
Definition: propertyset.hxx:58
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
bool getProperty(Type &orValue, sal_Int32 nPropId) const
Gets the specified property from the property set.
Definition: propertyset.hxx:94
Wraps a StreamDataSequence and provides convenient access functions.
A base class with useful helper functions for something that is able to convert ActiveX and ComCtl fo...
Definition: axcontrol.hxx:194
Base class for all models of form controls.
Definition: axcontrol.hxx:347
virtual void exportCompObj(BinaryOutputStream &)
Derived classes export CompObjStream contents.
Definition: axcontrol.hxx:370
AxPairData maSize
Size of the control in 1/100 mm.
Definition: axcontrol.hxx:382
virtual void exportBinaryModel(BinaryOutputStream &)
Derived classes export a form control model to the passed output stream.
Definition: axcontrol.hxx:368
A form control embedded in a document draw page.
Definition: axcontrol.hxx:898
static bool WriteOCXStream(const css::uno::Reference< css::frame::XModel > &rxModel, tools::SvRef< SotStorage > const &rSrc1, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size &rSize, OUString &rName)
Definition: olehelper.cxx:536
bool ReadOCXStorage(tools::SvRef< SotStorage > const &rSrc1, css::uno::Reference< css::form::XFormComponent > &rxFormComp)
Definition: olehelper.cxx:489
css::uno::Reference< css::uno::XComponentContext > mxCtx
Definition: olehelper.hxx:172
bool importControlFromStream(::oox::BinaryInputStream &rInStrm, css::uno::Reference< css::form::XFormComponent > &rxFormComp, std::u16string_view rGuidString)
MSConvertOCXControls(const css::uno::Reference< css::frame::XModel > &rxModel)
Definition: olehelper.cxx:416
bool ReadOCXCtlsStream(tools::SvRef< SotStorageStream > const &rSrc1, css::uno::Reference< css::form::XFormComponent > &rxFormComp, sal_Int32 nPos, sal_Int32 nSize)
Definition: olehelper.cxx:440
::oox::GraphicHelper maGrfHelper
Definition: olehelper.hxx:173
static bool WriteOCXExcelKludgeStream(const css::uno::Reference< css::frame::XModel > &rxModel, const css::uno::Reference< css::io::XOutputStream > &xOutStrm, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size &rSize, OUString &rName)
Definition: olehelper.cxx:522
virtual ~MSConvertOCXControls() override
Definition: olehelper.cxx:420
::oox::ole::ControlModelBase * mpModel
Definition: olehelper.hxx:136
std::unique_ptr<::oox::ole::EmbeddedControl > mpControl
Definition: olehelper.hxx:135
void exportCompObj(const css::uno::Reference< css::io::XOutputStream > &rxOut)
Definition: olehelper.cxx:395
std::u16string_view getGUID() const
Definition: olehelper.hxx:149
const OUString & getFullName() const
Definition: olehelper.hxx:156
css::uno::Reference< css::awt::XControlModel > mxControlModel
Definition: olehelper.hxx:139
::oox::GraphicHelper maGrfHelper
Definition: olehelper.hxx:137
OleFormCtrlExportHelper(const css::uno::Reference< css::uno::XComponentContext > &rxCtx, const css::uno::Reference< css::frame::XModel > &xDocModel, const css::uno::Reference< css::awt::XControlModel > &xModel)
Definition: olehelper.cxx:329
const OUString & getTypeName() const
Definition: olehelper.hxx:157
void exportName(const css::uno::Reference< css::io::XOutputStream > &rxOut)
Definition: olehelper.cxx:388
css::uno::Reference< css::frame::XModel > mxDocModel
Definition: olehelper.hxx:138
void exportControl(const css::uno::Reference< css::io::XOutputStream > &rxOut, const css::awt::Size &rSize, bool bAutoClose=false)
Definition: olehelper.cxx:402
bool is() const
OUString maName
Definition: dffdumper.cxx:161
sal_Int16 nVersion
sal_Int16 nValue
FuncFlags mnFlags
#define STATIC_ARRAY_SELECT(array, index, def)
Expands to the 'index'-th element of a STATIC data array, or to 'def', if 'index' is out of the array...
Definition: helper.hxx:57
sal_Int32 nIndex
OUString aName
Reference< XComponentContext > mxCtx
sal_uInt16 nPos
std::unique_ptr< sal_Int32[]> pData
Reference< XComponentContext > getProcessComponentContext()
Type
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
index
OOX_DLLPUBLIC OUString importGuid(BinaryInputStream &rInStrm)
Imports a GUID from the passed binary stream and returns its string representation (in uppercase char...
Definition: olehelper.cxx:261
OOX_DLLPUBLIC::Color decodeOleColor(const GraphicHelper &rGraphicHelper, sal_uInt32 nOleColor, bool bDefaultColorBgr)
Returns the UNO RGB color from the passed encoded OLE color.
Definition: olehelper.cxx:216
OOX_DLLPUBLIC void exportGuid(BinaryOutputStream &rOutStrm, const SvGlobalName &rId)
Definition: olehelper.cxx:253
OOX_DLLPUBLIC bool importStdPic(StreamDataSequence &orGraphicData, BinaryInputStream &rInStrm)
Imports an OLE StdPic picture from the current position of the passed binary stream.
Definition: olehelper.cxx:303
OOX_DLLPUBLIC bool importStdFont(StdFontInfo &orFontInfo, BinaryInputStream &rInStrm, bool bWithGuid)
Imports an OLE StdFont font structure from the current position of the passed binary stream.
Definition: olehelper.cxx:280
OOX_DLLPUBLIC sal_uInt32 encodeOleColor(sal_Int32 nRgbColor)
Returns the OLE color from the passed UNO RGB color.
Definition: olehelper.cxx:248
static Reference< css::frame::XFrame > lcl_getFrame(const Reference< css::frame::XModel > &rxModel)
Definition: olehelper.cxx:318
const sal_uInt16 OLE_STDFONT_NORMAL
Definition: olehelper.hxx:60
const sal_uInt8 WINDOWS_CHARSET_ANSI
Definition: helper.hxx:62
const ::Color API_RGB_WHITE(0xFFFFFF)
White color for API calls.
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
css::uno::Sequence< sal_Int8 > StreamDataSequence
const ::Color API_RGB_BLACK(0x000000)
Black color for API calls.
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
XML_TOKEN_INVALID
sal_Int16 nId
Definition: olehelper.cxx:98
const char * sName
Definition: olehelper.cxx:93
const char * sGUID
Definition: olehelper.cxx:92
GUIDCNamePairMap mnIdToGUIDCNamePairMap
Definition: olehelper.cxx:108
GUIDCNamePair aData
Definition: olehelper.cxx:99
#define OLE_GUID_STDPIC
Definition: olehelper.hxx:57
#define OLE_GUID_STDFONT
Definition: olehelper.hxx:56
double mnHeight
sal_uInt8 Data4[8]
sal_uInt16 Data3
sal_uInt16 Data2
sal_uInt32 Data1
Stores data about a StdFont font structure.
Definition: olehelper.hxx:69
sal_uInt8 mnFlags
Font flags.
Definition: olehelper.hxx:74
sal_uInt32 mnHeight
Font height (1/10,000 points).
Definition: olehelper.hxx:71
sal_uInt16 mnCharSet
Font charset.
Definition: olehelper.hxx:73
sal_uInt16 mnWeight
Font weight (normal/bold).
Definition: olehelper.hxx:72
OUString maName
Font name.
Definition: olehelper.hxx:70
Reference< XController > xController
Reference< XFrame > xFrame
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
std::unique_ptr< char[]> aBuffer