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