LibreOffice Module sc (master)  1
xiescher.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 <xiescher.hxx>
21 
22 #include <com/sun/star/beans/NamedValue.hpp>
23 #include <com/sun/star/container/XIndexContainer.hpp>
24 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <com/sun/star/embed/Aspects.hpp>
26 #include <com/sun/star/embed/XEmbeddedObject.hpp>
27 #include <com/sun/star/embed/XEmbedPersist.hpp>
28 #include <com/sun/star/awt/PushButtonType.hpp>
29 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
30 #include <com/sun/star/awt/VisualEffect.hpp>
31 #include <com/sun/star/style/VerticalAlignment.hpp>
32 #include <com/sun/star/drawing/XControlShape.hpp>
33 #include <com/sun/star/form/XForm.hpp>
34 #include <com/sun/star/form/XFormsSupplier.hpp>
35 #include <com/sun/star/form/binding/XBindableValue.hpp>
36 #include <com/sun/star/form/binding/XValueBinding.hpp>
37 #include <com/sun/star/form/binding/XListEntrySink.hpp>
38 #include <com/sun/star/form/binding/XListEntrySource.hpp>
39 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
40 #include <com/sun/star/script/XEventAttacherManager.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/frame/XModel.hpp>
43 
44 #include <sfx2/objsh.hxx>
46 #include <unotools/configmgr.hxx>
47 #include <unotools/fltrcfg.hxx>
48 #include <vcl/dibtools.hxx>
49 #include <vcl/gdimtf.hxx>
50 #include <vcl/outdev.hxx>
51 #include <vcl/wmf.hxx>
52 #include <comphelper/classids.hxx>
57 #include <sal/log.hxx>
58 
59 #include <svx/svdopath.hxx>
60 #include <svx/svdocirc.hxx>
61 #include <svx/svdoedge.hxx>
62 #include <svx/svdogrp.hxx>
63 #include <svx/svdoashp.hxx>
64 #include <svx/svdograf.hxx>
65 #include <svx/svdoole2.hxx>
66 #include <svx/svdouno.hxx>
67 #include <svx/svdpage.hxx>
68 #include <editeng/editobj.hxx>
69 #include <editeng/outliner.hxx>
70 #include <editeng/outlobj.hxx>
71 #include <svx/svditer.hxx>
73 #include <svx/xlnclit.hxx>
74 #include <svx/xlndsit.hxx>
75 #include <svx/xlnedcit.hxx>
76 #include <svx/xlnedit.hxx>
77 #include <svx/xlnedwit.hxx>
78 #include <svx/xlnstcit.hxx>
79 #include <svx/xlnstit.hxx>
80 #include <svx/xlnstwit.hxx>
81 #include <svx/xlnwtit.hxx>
82 #include <svx/sdasitm.hxx>
83 #include <svx/sdshcitm.hxx>
84 #include <svx/sdshitm.hxx>
85 #include <svx/sdsxyitm.hxx>
86 #include <svx/sdtagitm.hxx>
87 #include <svx/sdtditm.hxx>
88 
89 #include <editeng/eeitem.hxx>
90 #include <svx/xflclit.hxx>
91 #include <sal/macros.h>
92 #include <editeng/adjustitem.hxx>
93 #include <svx/xfillit0.hxx>
94 #include <svx/xlineit0.hxx>
95 #include <svx/xlinjoit.hxx>
96 #include <svx/xlntrit.hxx>
97 #include <svx/xbtmpit.hxx>
98 #include <svx/xbitmap.hxx>
99 #include <svtools/embedhlp.hxx>
100 #include <sot/storage.hxx>
101 
102 #include <document.hxx>
103 #include <drwlayer.hxx>
104 #include <userdat.hxx>
105 #include <unonames.hxx>
106 #include <convuno.hxx>
107 #include <postit.hxx>
108 #include <globstr.hrc>
109 #include <scresid.hxx>
110 
111 #include <fprogressbar.hxx>
112 #include <xltracer.hxx>
113 #include <xistream.hxx>
114 #include <xihelper.hxx>
115 #include <xiformula.hxx>
116 #include <xilink.hxx>
117 #include <xistyle.hxx>
118 #include <xipage.hxx>
119 #include <xichart.hxx>
120 #include <xicontent.hxx>
121 #include <scextopt.hxx>
122 
123 #include <namebuff.hxx>
124 #include <sfx2/docfile.hxx>
125 #include <memory>
126 #include <numeric>
127 #include <utility>
128 
129 using namespace com::sun::star;
130 using ::com::sun::star::uno::makeAny;
131 using ::com::sun::star::uno::Any;
132 using ::com::sun::star::beans::XPropertySet;
133 using ::com::sun::star::uno::makeAny;
134 using ::com::sun::star::uno::Exception;
135 using ::com::sun::star::uno::Reference;
136 using ::com::sun::star::uno::Sequence;
137 using ::com::sun::star::uno::UNO_QUERY;
138 using ::com::sun::star::uno::UNO_QUERY_THROW;
139 using ::com::sun::star::uno::UNO_SET_THROW;
140 using ::com::sun::star::beans::NamedValue;
141 using ::com::sun::star::lang::XMultiServiceFactory;
142 using ::com::sun::star::container::XIndexContainer;
143 using ::com::sun::star::container::XNameContainer;
144 using ::com::sun::star::frame::XModel;
145 using ::com::sun::star::awt::XControlModel;
146 using ::com::sun::star::embed::XEmbeddedObject;
147 using ::com::sun::star::embed::XEmbedPersist;
148 using ::com::sun::star::drawing::XControlShape;
149 using ::com::sun::star::drawing::XShape;
150 using ::com::sun::star::form::XFormComponent;
151 using ::com::sun::star::form::XFormsSupplier;
152 using ::com::sun::star::form::binding::XBindableValue;
153 using ::com::sun::star::form::binding::XValueBinding;
154 using ::com::sun::star::form::binding::XListEntrySink;
155 using ::com::sun::star::form::binding::XListEntrySource;
156 using ::com::sun::star::script::ScriptEventDescriptor;
157 using ::com::sun::star::script::XEventAttacherManager;
158 using ::com::sun::star::table::CellAddress;
159 using ::com::sun::star::table::CellRangeAddress;
160 
161 // Drawing objects ============================================================
162 
164  XclImpRoot( rRoot ),
165  mnObjId( EXC_OBJ_INVALID_ID ),
166  mnTab( 0 ),
167  mnObjType( EXC_OBJTYPE_UNKNOWN ),
168  mnDffShapeId( 0 ),
169  mnDffFlags( ShapeFlag::NONE ),
170  mbHasAnchor( false ),
171  mbHidden( false ),
172  mbVisible( true ),
173  mbPrintable( true ),
174  mbAreaObj( false ),
175  mbAutoMargin( true ),
176  mbSimpleMacro( true ),
177  mbProcessSdr( true ),
178  mbInsertSdr( true ),
179  mbCustomDff( false ),
180  mbNotifyMacroEventRead( false )
181 {
182 }
183 
185 {
186 }
187 
189 {
190  XclImpDrawObjRef xDrawObj;
191 
192  if( rStrm.GetRecLeft() >= 30 )
193  {
194  sal_uInt16 nObjType;
195  rStrm.Ignore( 4 );
196  nObjType = rStrm.ReaduInt16();
197  switch( nObjType )
198  {
199  case EXC_OBJTYPE_GROUP: xDrawObj= std::make_shared<XclImpGroupObj>( rRoot ); break;
200  case EXC_OBJTYPE_LINE: xDrawObj= std::make_shared<XclImpLineObj>( rRoot ); break;
201  case EXC_OBJTYPE_RECTANGLE: xDrawObj= std::make_shared<XclImpRectObj>( rRoot ); break;
202  case EXC_OBJTYPE_OVAL: xDrawObj= std::make_shared<XclImpOvalObj>( rRoot ); break;
203  case EXC_OBJTYPE_ARC: xDrawObj= std::make_shared<XclImpArcObj>( rRoot ); break;
204  case EXC_OBJTYPE_CHART: xDrawObj= std::make_shared<XclImpChartObj>( rRoot ); break;
205  case EXC_OBJTYPE_TEXT: xDrawObj= std::make_shared<XclImpTextObj>( rRoot ); break;
206  case EXC_OBJTYPE_BUTTON: xDrawObj= std::make_shared<XclImpButtonObj>( rRoot ); break;
207  case EXC_OBJTYPE_PICTURE: xDrawObj= std::make_shared<XclImpPictureObj>( rRoot ); break;
208  default:
209  SAL_WARN("sc.filter", "XclImpDrawObjBase::ReadObj3 - unknown object type 0x" << std::hex << nObjType );
211  }
212  }
213 
214  if (!xDrawObj)
215  {
216  xDrawObj = std::make_shared<XclImpPhObj>(rRoot);
217  }
218 
219  xDrawObj->mnTab = rRoot.GetCurrScTab();
220  xDrawObj->ImplReadObj3( rStrm );
221  return xDrawObj;
222 }
223 
225 {
226  XclImpDrawObjRef xDrawObj;
227 
228  if( rStrm.GetRecLeft() >= 30 )
229  {
230  sal_uInt16 nObjType;
231  rStrm.Ignore( 4 );
232  nObjType = rStrm.ReaduInt16();
233  switch( nObjType )
234  {
235  case EXC_OBJTYPE_GROUP: xDrawObj = std::make_shared<XclImpGroupObj>( rRoot ); break;
236  case EXC_OBJTYPE_LINE: xDrawObj = std::make_shared<XclImpLineObj>( rRoot ); break;
237  case EXC_OBJTYPE_RECTANGLE: xDrawObj = std::make_shared<XclImpRectObj>( rRoot ); break;
238  case EXC_OBJTYPE_OVAL: xDrawObj = std::make_shared<XclImpOvalObj>( rRoot ); break;
239  case EXC_OBJTYPE_ARC: xDrawObj = std::make_shared<XclImpArcObj>( rRoot ); break;
240  case EXC_OBJTYPE_CHART: xDrawObj = std::make_shared<XclImpChartObj>( rRoot ); break;
241  case EXC_OBJTYPE_TEXT: xDrawObj = std::make_shared<XclImpTextObj>( rRoot ); break;
242  case EXC_OBJTYPE_BUTTON: xDrawObj = std::make_shared<XclImpButtonObj>( rRoot ); break;
243  case EXC_OBJTYPE_PICTURE: xDrawObj = std::make_shared<XclImpPictureObj>( rRoot ); break;
244  case EXC_OBJTYPE_POLYGON: xDrawObj = std::make_shared<XclImpPolygonObj>( rRoot ); break;
245  default:
246  SAL_WARN("sc.filter", "XclImpDrawObjBase::ReadObj4 - unknown object type 0x" << std::hex << nObjType );
248  }
249  }
250 
251  if (!xDrawObj)
252  {
253  xDrawObj = std::make_shared<XclImpPhObj>(rRoot);
254  }
255 
256  xDrawObj->mnTab = rRoot.GetCurrScTab();
257  xDrawObj->ImplReadObj4( rStrm );
258  return xDrawObj;
259 }
260 
262 {
263  XclImpDrawObjRef xDrawObj;
264 
265  if( rStrm.GetRecLeft() >= 34 )
266  {
267  sal_uInt16 nObjType(EXC_OBJTYPE_UNKNOWN);
268  rStrm.Ignore( 4 );
269  nObjType = rStrm.ReaduInt16();
270  switch( nObjType )
271  {
272  case EXC_OBJTYPE_GROUP: xDrawObj = std::make_shared<XclImpGroupObj>( rRoot ); break;
273  case EXC_OBJTYPE_LINE: xDrawObj = std::make_shared<XclImpLineObj>( rRoot ); break;
274  case EXC_OBJTYPE_RECTANGLE: xDrawObj = std::make_shared<XclImpRectObj>( rRoot ); break;
275  case EXC_OBJTYPE_OVAL: xDrawObj = std::make_shared<XclImpOvalObj>( rRoot ); break;
276  case EXC_OBJTYPE_ARC: xDrawObj = std::make_shared<XclImpArcObj>( rRoot ); break;
277  case EXC_OBJTYPE_CHART: xDrawObj = std::make_shared<XclImpChartObj>( rRoot ); break;
278  case EXC_OBJTYPE_TEXT: xDrawObj = std::make_shared<XclImpTextObj>( rRoot ); break;
279  case EXC_OBJTYPE_BUTTON: xDrawObj = std::make_shared<XclImpButtonObj>( rRoot ); break;
280  case EXC_OBJTYPE_PICTURE: xDrawObj = std::make_shared<XclImpPictureObj>( rRoot ); break;
281  case EXC_OBJTYPE_POLYGON: xDrawObj = std::make_shared<XclImpPolygonObj>( rRoot ); break;
282  case EXC_OBJTYPE_CHECKBOX: xDrawObj = std::make_shared<XclImpCheckBoxObj>( rRoot ); break;
283  case EXC_OBJTYPE_OPTIONBUTTON: xDrawObj = std::make_shared<XclImpOptionButtonObj>( rRoot ); break;
284  case EXC_OBJTYPE_EDIT: xDrawObj = std::make_shared<XclImpEditObj>( rRoot ); break;
285  case EXC_OBJTYPE_LABEL: xDrawObj = std::make_shared<XclImpLabelObj>( rRoot ); break;
286  case EXC_OBJTYPE_DIALOG: xDrawObj = std::make_shared<XclImpDialogObj>( rRoot ); break;
287  case EXC_OBJTYPE_SPIN: xDrawObj = std::make_shared<XclImpSpinButtonObj>( rRoot ); break;
288  case EXC_OBJTYPE_SCROLLBAR: xDrawObj = std::make_shared<XclImpScrollBarObj>( rRoot ); break;
289  case EXC_OBJTYPE_LISTBOX: xDrawObj = std::make_shared<XclImpListBoxObj>( rRoot ); break;
290  case EXC_OBJTYPE_GROUPBOX: xDrawObj = std::make_shared<XclImpGroupBoxObj>( rRoot ); break;
291  case EXC_OBJTYPE_DROPDOWN: xDrawObj = std::make_shared<XclImpDropDownObj>( rRoot ); break;
292  default:
293  SAL_WARN("sc.filter", "XclImpDrawObjBase::ReadObj5 - unknown object type 0x" << std::hex << nObjType );
295  xDrawObj = std::make_shared<XclImpPhObj>( rRoot );
296  }
297  }
298 
299  OSL_ENSURE(xDrawObj, "object import failed");
300 
301  if (xDrawObj)
302  {
303  xDrawObj->mnTab = rRoot.GetCurrScTab();
304  xDrawObj->ImplReadObj5( rStrm );
305  }
306  return xDrawObj;
307 }
308 
310 {
311  XclImpDrawObjRef xDrawObj;
312 
313  if( rStrm.GetRecLeft() >= 10 )
314  {
315  sal_uInt16 nSubRecId(0), nSubRecSize(0), nObjType(0);
316  nSubRecId = rStrm.ReaduInt16();
317  nSubRecSize = rStrm.ReaduInt16();
318  nObjType = rStrm.ReaduInt16();
319  OSL_ENSURE( nSubRecId == EXC_ID_OBJCMO, "XclImpDrawObjBase::ReadObj8 - OBJCMO subrecord expected" );
320  if( (nSubRecId == EXC_ID_OBJCMO) && (nSubRecSize >= 6) )
321  {
322  switch( nObjType )
323  {
324  // in BIFF8, all simple objects support text
325  case EXC_OBJTYPE_LINE:
326  case EXC_OBJTYPE_ARC:
327  xDrawObj = std::make_shared<XclImpTextObj>( rRoot );
328  // lines and arcs may be 2-dimensional
329  xDrawObj->SetAreaObj( false );
330  break;
331 
332  // in BIFF8, all simple objects support text
334  case EXC_OBJTYPE_OVAL:
335  case EXC_OBJTYPE_POLYGON:
336  case EXC_OBJTYPE_DRAWING:
337  case EXC_OBJTYPE_TEXT:
338  xDrawObj = std::make_shared<XclImpTextObj>( rRoot );
339  break;
340 
341  case EXC_OBJTYPE_GROUP: xDrawObj = std::make_shared<XclImpGroupObj>( rRoot ); break;
342  case EXC_OBJTYPE_CHART: xDrawObj = std::make_shared<XclImpChartObj>( rRoot ); break;
343  case EXC_OBJTYPE_BUTTON: xDrawObj = std::make_shared<XclImpButtonObj>( rRoot ); break;
344  case EXC_OBJTYPE_PICTURE: xDrawObj = std::make_shared<XclImpPictureObj>( rRoot ); break;
345  case EXC_OBJTYPE_CHECKBOX: xDrawObj = std::make_shared<XclImpCheckBoxObj>( rRoot ); break;
346  case EXC_OBJTYPE_OPTIONBUTTON: xDrawObj = std::make_shared<XclImpOptionButtonObj>( rRoot ); break;
347  case EXC_OBJTYPE_EDIT: xDrawObj = std::make_shared<XclImpEditObj>( rRoot ); break;
348  case EXC_OBJTYPE_LABEL: xDrawObj = std::make_shared<XclImpLabelObj>( rRoot ); break;
349  case EXC_OBJTYPE_DIALOG: xDrawObj = std::make_shared<XclImpDialogObj>( rRoot ); break;
350  case EXC_OBJTYPE_SPIN: xDrawObj = std::make_shared<XclImpSpinButtonObj>( rRoot ); break;
351  case EXC_OBJTYPE_SCROLLBAR: xDrawObj = std::make_shared<XclImpScrollBarObj>( rRoot ); break;
352  case EXC_OBJTYPE_LISTBOX: xDrawObj = std::make_shared<XclImpListBoxObj>( rRoot ); break;
353  case EXC_OBJTYPE_GROUPBOX: xDrawObj = std::make_shared<XclImpGroupBoxObj>( rRoot ); break;
354  case EXC_OBJTYPE_DROPDOWN: xDrawObj = std::make_shared<XclImpDropDownObj>( rRoot ); break;
355  case EXC_OBJTYPE_NOTE: xDrawObj = std::make_shared<XclImpNoteObj>( rRoot ); break;
356 
357  default:
358  SAL_WARN("sc.filter", "XclImpDrawObjBase::ReadObj8 - unknown object type 0x" << std::hex << nObjType );
360  }
361  }
362  }
363 
364  if (!xDrawObj) //ensure placeholder for unknown or broken records
365  {
366  SAL_WARN( "sc.filter", "XclImpDrawObjBase::ReadObj8 import failed, substituting placeholder");
367  xDrawObj = std::make_shared<XclImpPhObj>( rRoot );
368  }
369 
370  xDrawObj->mnTab = rRoot.GetCurrScTab();
371  xDrawObj->ImplReadObj8( rStrm );
372  return xDrawObj;
373 }
374 
376 {
377  maAnchor = rAnchor;
378  mbHasAnchor = true;
379 }
380 
382  const DffObjData& rDffObjData, const OUString& rObjName, const OUString& rHyperlink,
383  bool bVisible, bool bAutoMargin )
384 {
385  mnDffShapeId = rDffObjData.nShapeId;
386  mnDffFlags = rDffObjData.nSpFlags;
387  maObjName = rObjName;
388  maHyperlink = rHyperlink;
389  mbVisible = bVisible;
390  mbAutoMargin = bAutoMargin;
391 }
392 
394 {
395  /* #i51348# Always return a non-empty name. Create English
396  default names depending on the object type. This is not implemented as
397  virtual functions in derived classes, as class type and object type may
398  not match. */
399  return maObjName.isEmpty() ? GetObjectManager().GetDefaultObjName(*this) : maObjName;
400 }
401 
403 {
404  return mbHasAnchor ? &maAnchor : nullptr;
405 }
406 
407 bool XclImpDrawObjBase::IsValidSize( const tools::Rectangle& rAnchorRect ) const
408 {
409  // XclObjAnchor rounds up the width, width of 3 is the result of an Excel width of 0
410  return mbAreaObj ?
411  ((rAnchorRect.GetWidth() > 3) && (rAnchorRect.GetHeight() > 1)) :
412  ((rAnchorRect.GetWidth() > 3) || (rAnchorRect.GetHeight() > 1));
413 }
414 
416 {
417  ScRange aScUsedArea( ScAddress::INITIALIZE_INVALID );
418  // #i44077# object inserted -> update used area for OLE object import
419  if( mbHasAnchor && GetAddressConverter().ConvertRange( aScUsedArea, maAnchor, nScTab, nScTab, false ) )
420  {
421  // reduce range, if object ends directly on borders between two columns or rows
422  if( (maAnchor.mnRX == 0) && (aScUsedArea.aStart.Col() < aScUsedArea.aEnd.Col()) )
423  aScUsedArea.aEnd.IncCol( -1 );
424  if( (maAnchor.mnBY == 0) && (aScUsedArea.aStart.Row() < aScUsedArea.aEnd.Row()) )
425  aScUsedArea.aEnd.IncRow( -1 );
426  }
427  return aScUsedArea;
428 }
429 
431 {
432  return DoGetProgressSize();
433 }
434 
436 {
437  SdrObjectUniquePtr xSdrObj;
438  if( bIsDff && !mbCustomDff )
439  {
440  rDffConv.Progress( GetProgressSize() );
441  }
442  else
443  {
444  xSdrObj = DoCreateSdrObj( rDffConv, rAnchorRect );
445 
446  //added for exporting OCX control
447  /* mnObjType value set should be as below table:
448  0x0000 Group 0x0001 Line
449  0x0002 Rectangle 0x0003 Oval
450  0x0004 Arc 0x0005 Chart
451  0x0006 Text 0x0009 Polygon
452  +-----------------------------------------------------+
453  OCX ==>| 0x0008 Picture |
454  +-----------------------------------------------------+
455  | 0x0007 Button |
456  | 0x000B Checkbox 0x000C Radio button |
457  | 0x000D Edit box 0x000E Label |
458  TBX ==> | 0x000F Dialog box 0x0010 Spin control |
459  | 0x0011 Scrollbar 0x0012 List |
460  | 0x0013 Group box 0x0014 Dropdown list |
461  +-----------------------------------------------------+
462  0x0019 Note 0x001E OfficeArt object
463  */
464  if( xSdrObj && xSdrObj->IsUnoObj() &&
465  ( (mnObjType < 25 && mnObjType > 10) || mnObjType == 7 || mnObjType == 8 ) )
466  {
467  SdrUnoObj* pSdrUnoObj = dynamic_cast< SdrUnoObj* >( xSdrObj.get() );
468  if( pSdrUnoObj != nullptr )
469  {
470  const Reference< XControlModel >& xCtrlModel = pSdrUnoObj->GetUnoControlModel();
471  Reference< XPropertySet > xPropSet(xCtrlModel,UNO_QUERY);
472  static constexpr OUStringLiteral sPropertyName(u"ControlTypeinMSO");
473 
474  enum { eCreateFromOffice = 0, eCreateFromMSTBXControl, eCreateFromMSOCXControl };
475 
476  if( mnObjType == 7 || (mnObjType < 25 && mnObjType > 10) )//TBX
477  {
478  try
479  {
480  //Need summary type for export. Detail type(checkbox, button ...) has been contained by mnObjType
481  const sal_Int16 nTBXControlType = eCreateFromMSTBXControl ;
482  xPropSet->setPropertyValue(sPropertyName, Any(nTBXControlType));
483  }
484  catch(const Exception&)
485  {
486  SAL_WARN("sc.filter", "XclImpDrawObjBase::CreateSdrObject, this control can't be set the property ControlTypeinMSO!");
487  }
488  }
489  if( mnObjType == 8 )//OCX
490  {
491  //Need summary type for export
492  static constexpr OUStringLiteral sObjIdPropertyName(u"ObjIDinMSO");
493  const XclImpPictureObj* const pObj = dynamic_cast< const XclImpPictureObj* const >(this);
494  if( pObj != nullptr && pObj->IsOcxControl() )
495  {
496  try
497  {
498  const sal_Int16 nOCXControlType = eCreateFromMSOCXControl;
499  xPropSet->setPropertyValue(sPropertyName, Any(nOCXControlType));
500  //Detail type(checkbox, button ...)
501  xPropSet->setPropertyValue(sObjIdPropertyName, makeAny<sal_uInt16>(mnObjId));
502  }
503  catch(const Exception&)
504  {
505  SAL_WARN("sc.filter", "XclImpDrawObjBase::CreateSdrObject, this control can't be set the property ObjIDinMSO!");
506  }
507  }
508  }
509 
510  }
511  }
512  }
513  return xSdrObj;
514 }
515 
517 {
519  return;
520  SfxObjectShell* pDocShell = GetDocShell();
521  if (!pDocShell)
522  return;
524  mbNotifyMacroEventRead = true;
525 }
526 
528 {
529  // default: front layer, derived classes may have to set other layer in DoPreProcessSdrObj()
530  rSdrObj.NbcSetLayer( SC_LAYER_FRONT );
531 
532  // set object name (GetObjName() will always return a non-empty name)
533  rSdrObj.SetName( GetObjName() );
534 
535  // #i39167# full width for all objects regardless of horizontal alignment
537 
538  // automatic text margin
539  if( mbAutoMargin )
540  {
541  sal_Int32 nMargin = rDffConv.GetDefaultTextMargin();
542  rSdrObj.SetMergedItem( makeSdrTextLeftDistItem( nMargin ) );
543  rSdrObj.SetMergedItem( makeSdrTextRightDistItem( nMargin ) );
544  rSdrObj.SetMergedItem( makeSdrTextUpperDistItem( nMargin ) );
545  rSdrObj.SetMergedItem( makeSdrTextLowerDistItem( nMargin ) );
546  }
547 
548  // macro and hyperlink
549  // removed oracle/sun check for mbSimpleMacro ( no idea what its for )
550  if (!maMacroName.isEmpty())
551  {
552  if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, true ) )
553  {
554  OUString sMacro = XclTools::GetSbMacroUrl(maMacroName, GetDocShell());
555  if (!sMacro.isEmpty())
557  pInfo->SetMacro(sMacro);
558  }
559  }
560  if (!maHyperlink.isEmpty())
561  rSdrObj.setHyperlink(maHyperlink);
562 
563  // call virtual function for object type specific processing
564  DoPreProcessSdrObj( rDffConv, rSdrObj );
565 }
566 
568 {
569  // call virtual function for object type specific processing
570  DoPostProcessSdrObj( rDffConv, rSdrObj );
571 }
572 
573 // protected ------------------------------------------------------------------
574 
575 void XclImpDrawObjBase::ReadName5( XclImpStream& rStrm, sal_uInt16 nNameLen )
576 {
577  maObjName.clear();
578  if( nNameLen > 0 )
579  {
580  // name length field is repeated before the name
581  maObjName = rStrm.ReadByteString( false );
582  // skip padding byte for word boundaries
583  if( rStrm.GetRecPos() & 1 ) rStrm.Ignore( 1 );
584  }
585 }
586 
587 void XclImpDrawObjBase::ReadMacro3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
588 {
589  maMacroName.clear();
590  rStrm.Ignore( nMacroSize );
591  // skip padding byte for word boundaries, not contained in nMacroSize
592  if( rStrm.GetRecPos() & 1 ) rStrm.Ignore( 1 );
593 }
594 
595 void XclImpDrawObjBase::ReadMacro4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
596 {
597  maMacroName.clear();
598  rStrm.Ignore( nMacroSize );
599 }
600 
601 void XclImpDrawObjBase::ReadMacro5( XclImpStream& rStrm, sal_uInt16 nMacroSize )
602 {
603  maMacroName.clear();
604  rStrm.Ignore( nMacroSize );
605 }
606 
608 {
609  maMacroName.clear();
610  if( rStrm.GetRecLeft() <= 6 )
611  return;
612 
613  // macro is stored in a tNameXR token containing a link to a defined name
614  sal_uInt16 nFmlaSize;
615  nFmlaSize = rStrm.ReaduInt16();
616  rStrm.Ignore( 4 );
617  OSL_ENSURE( nFmlaSize == 7, "XclImpDrawObjBase::ReadMacro - unexpected formula size" );
618  if( nFmlaSize == 7 )
619  {
620  sal_uInt8 nTokenId;
621  sal_uInt16 nExtSheet, nExtName;
622  nTokenId = rStrm.ReaduInt8();
623  nExtSheet = rStrm.ReaduInt16();
624  nExtName = rStrm.ReaduInt16();
626  "XclImpDrawObjBase::ReadMacro - tNameXR token expected" );
628  maMacroName = GetLinkManager().GetMacroName( nExtSheet, nExtName );
629  }
630 }
631 
632 void XclImpDrawObjBase::ConvertLineStyle( SdrObject& rSdrObj, const XclObjLineData& rLineData ) const
633 {
634  if( rLineData.IsAuto() )
635  {
636  XclObjLineData aAutoData;
637  aAutoData.mnAuto = 0;
638  ConvertLineStyle( rSdrObj, aAutoData );
639  }
640  else
641  {
642  tools::Long nLineWidth = 35 * ::std::min( rLineData.mnWidth, EXC_OBJ_LINE_THICK );
643  rSdrObj.SetMergedItem( XLineWidthItem( nLineWidth ) );
644  rSdrObj.SetMergedItem( XLineColorItem( EMPTY_OUSTRING, GetPalette().GetColor( rLineData.mnColorIdx ) ) );
645  rSdrObj.SetMergedItem( XLineJointItem( css::drawing::LineJoint_MITER ) );
646 
647  sal_uLong nDotLen = ::std::max< sal_uLong >( 70 * rLineData.mnWidth, 35 );
648  sal_uLong nDashLen = 3 * nDotLen;
649  sal_uLong nDist = 2 * nDotLen;
650 
651  switch( rLineData.mnStyle )
652  {
653  default:
654  case EXC_OBJ_LINE_SOLID:
655  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID ) );
656  break;
657  case EXC_OBJ_LINE_DASH:
658  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH ) );
659  rSdrObj.SetMergedItem( XLineDashItem( EMPTY_OUSTRING, XDash( css::drawing::DashStyle_RECT, 0, nDotLen, 1, nDashLen, nDist ) ) );
660  break;
661  case EXC_OBJ_LINE_DOT:
662  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH ) );
663  rSdrObj.SetMergedItem( XLineDashItem( EMPTY_OUSTRING, XDash( css::drawing::DashStyle_RECT, 1, nDotLen, 0, nDashLen, nDist ) ) );
664  break;
666  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH ) );
667  rSdrObj.SetMergedItem( XLineDashItem( EMPTY_OUSTRING, XDash( css::drawing::DashStyle_RECT, 1, nDotLen, 1, nDashLen, nDist ) ) );
668  break;
670  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH ) );
671  rSdrObj.SetMergedItem( XLineDashItem( EMPTY_OUSTRING, XDash( css::drawing::DashStyle_RECT, 2, nDotLen, 1, nDashLen, nDist ) ) );
672  break;
674  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID ) );
675  rSdrObj.SetMergedItem( XLineTransparenceItem( 50 ) );
676  break;
678  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID ) );
679  rSdrObj.SetMergedItem( XLineTransparenceItem( 25 ) );
680  break;
682  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID ) );
683  rSdrObj.SetMergedItem( XLineTransparenceItem( 75 ) );
684  break;
685  case EXC_OBJ_LINE_NONE:
686  rSdrObj.SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
687  break;
688  }
689  }
690 }
691 
692 void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillData& rFillData ) const
693 {
694  if( rFillData.IsAuto() )
695  {
696  XclObjFillData aAutoData;
697  aAutoData.mnAuto = 0;
698  ConvertFillStyle( rSdrObj, aAutoData );
699  }
700  else if( rFillData.mnPattern == EXC_PATT_NONE )
701  {
702  rSdrObj.SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
703  }
704  else
705  {
706  Color aPattColor = GetPalette().GetColor( rFillData.mnPattColorIdx );
707  Color aBackColor = GetPalette().GetColor( rFillData.mnBackColorIdx );
708  if( (rFillData.mnPattern == EXC_PATT_SOLID) || (aPattColor == aBackColor) )
709  {
710  rSdrObj.SetMergedItem( XFillStyleItem( drawing::FillStyle_SOLID ) );
711  rSdrObj.SetMergedItem( XFillColorItem( EMPTY_OUSTRING, aPattColor ) );
712  }
713  else
714  {
715  static const sal_uInt8 sppnPatterns[][ 8 ] =
716  {
717  { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 },
718  { 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD },
719  { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 },
720  { 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 },
721  { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC },
722  { 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, 0xCC, 0x99 },
723  { 0xCC, 0x66, 0x33, 0x99, 0xCC, 0x66, 0x33, 0x99 },
724  { 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33 },
725  { 0xCC, 0xFF, 0x33, 0xFF, 0xCC, 0xFF, 0x33, 0xFF },
726  { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00 },
727  { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 },
728  { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 },
729  { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 },
730  { 0xFF, 0x11, 0x11, 0x11, 0xFF, 0x11, 0x11, 0x11 },
731  { 0xAA, 0x44, 0xAA, 0x11, 0xAA, 0x44, 0xAA, 0x11 },
732  { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },
733  { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 }
734  };
735  const sal_uInt8* const pnPattern = sppnPatterns[std::min<size_t>(rFillData.mnPattern - 2, SAL_N_ELEMENTS(sppnPatterns) - 1)];
736  // create 2-colored 8x8 DIB
737  SvMemoryStream aMemStrm;
738  aMemStrm.WriteUInt32( 12 ).WriteInt16( 8 ).WriteInt16( 8 ).WriteUInt16( 1 ).WriteUInt16( 1 );
739  aMemStrm.WriteUChar( 0xFF ).WriteUChar( 0xFF ).WriteUChar( 0xFF );
740  aMemStrm.WriteUChar( 0x00 ).WriteUChar( 0x00 ).WriteUChar( 0x00 );
741  for( size_t nIdx = 0; nIdx < 8; ++nIdx )
742  aMemStrm.WriteUInt32( pnPattern[ nIdx ] ); // 32-bit little-endian
743  aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
744  Bitmap aBitmap;
745  (void)ReadDIB(aBitmap, aMemStrm, false);
746 
747  XOBitmap aXOBitmap(( BitmapEx(aBitmap) ));
748  aXOBitmap.Bitmap2Array();
749  if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
750  ::std::swap( aPattColor, aBackColor );
751  aXOBitmap.SetPixelColor( aPattColor );
752  aXOBitmap.SetBackgroundColor( aBackColor );
753  aXOBitmap.Array2Bitmap();
754  aBitmap = aXOBitmap.GetBitmap().GetBitmap();
755 
756  rSdrObj.SetMergedItem(XFillStyleItem(drawing::FillStyle_BITMAP));
758  }
759  }
760 }
761 
762 void XclImpDrawObjBase::ConvertFrameStyle( SdrObject& rSdrObj, sal_uInt16 nFrameFlags ) const
763 {
764  if( ::get_flag( nFrameFlags, EXC_OBJ_FRAME_SHADOW ) )
765  {
766  rSdrObj.SetMergedItem( makeSdrShadowItem( true ) );
767  rSdrObj.SetMergedItem( makeSdrShadowXDistItem( 35 ) );
768  rSdrObj.SetMergedItem( makeSdrShadowYDistItem( 35 ) );
770  }
771 }
772 
774 {
775  Color aColor( COL_TRANSPARENT );
776  if( rLineData.IsAuto() )
777  {
778  XclObjLineData aAutoData;
779  aAutoData.mnAuto = 0;
780  aColor = GetSolidLineColor( aAutoData );
781  }
782  else if( rLineData.mnStyle != EXC_OBJ_LINE_NONE )
783  {
784  aColor = GetPalette().GetColor( rLineData.mnColorIdx );
785  }
786  return aColor;
787 }
788 
790 {
791  Color aColor( COL_TRANSPARENT );
792  if( rFillData.IsAuto() )
793  {
794  XclObjFillData aAutoData;
795  aAutoData.mnAuto = 0;
796  aColor = GetSolidFillColor( aAutoData );
797  }
798  else if( rFillData.mnPattern != EXC_PATT_NONE )
799  {
800  Color aPattColor = GetPalette().GetColor( rFillData.mnPattColorIdx );
801  Color aBackColor = GetPalette().GetColor( rFillData.mnBackColorIdx );
802  aColor = XclTools::GetPatternColor( aPattColor, aBackColor, rFillData.mnPattern );
803  }
804  return aColor;
805 }
806 
808 {
809 }
810 
812 {
813 }
814 
815 void XclImpDrawObjBase::DoReadObj5( XclImpStream&, sal_uInt16, sal_uInt16 )
816 {
817 }
818 
819 void XclImpDrawObjBase::DoReadObj8SubRec( XclImpStream&, sal_uInt16, sal_uInt16 )
820 {
821 }
822 
824 {
825  return 1;
826 }
827 
829 {
830  rDffConv.Progress( GetProgressSize() );
831  return nullptr;
832 }
833 
835 {
836  // trace if object is not printable
837  if( !IsPrintable() )
839 }
840 
842 {
843 }
844 
846 {
847  // back to offset 4 (ignore object count field)
848  rStrm.Seek( 4 );
849 
850  sal_uInt16 nObjFlags, nMacroSize;
851  mnObjType = rStrm.ReaduInt16();
852  mnObjId = rStrm.ReaduInt16();
853  nObjFlags = rStrm.ReaduInt16();
854  rStrm >> maAnchor;
855  nMacroSize = rStrm.ReaduInt16();
856  rStrm.Ignore( 2 );
857 
858  mbHasAnchor = true;
859  mbHidden = ::get_flag( nObjFlags, EXC_OBJ_HIDDEN );
860  mbVisible = ::get_flag( nObjFlags, EXC_OBJ_VISIBLE );
861  DoReadObj3( rStrm, nMacroSize );
862 }
863 
865 {
866  // back to offset 4 (ignore object count field)
867  rStrm.Seek( 4 );
868 
869  sal_uInt16 nObjFlags, nMacroSize;
870  mnObjType = rStrm.ReaduInt16();
871  mnObjId = rStrm.ReaduInt16();
872  nObjFlags = rStrm.ReaduInt16();
873  rStrm >> maAnchor;
874  nMacroSize = rStrm.ReaduInt16();
875  rStrm.Ignore( 2 );
876 
877  mbHasAnchor = true;
878  mbHidden = ::get_flag( nObjFlags, EXC_OBJ_HIDDEN );
879  mbVisible = ::get_flag( nObjFlags, EXC_OBJ_VISIBLE );
880  mbPrintable = ::get_flag( nObjFlags, EXC_OBJ_PRINTABLE );
881  DoReadObj4( rStrm, nMacroSize );
882 }
883 
885 {
886  // back to offset 4 (ignore object count field)
887  rStrm.Seek( 4 );
888 
889  sal_uInt16 nObjFlags, nMacroSize, nNameLen;
890  mnObjType = rStrm.ReaduInt16();
891  mnObjId = rStrm.ReaduInt16();
892  nObjFlags = rStrm.ReaduInt16();
893  rStrm >> maAnchor;
894  nMacroSize = rStrm.ReaduInt16();
895  rStrm.Ignore( 2 );
896  nNameLen = rStrm.ReaduInt16();
897  rStrm.Ignore( 2 );
898 
899  mbHasAnchor = true;
900  mbHidden = ::get_flag( nObjFlags, EXC_OBJ_HIDDEN );
901  mbVisible = ::get_flag( nObjFlags, EXC_OBJ_VISIBLE );
902  mbPrintable = ::get_flag( nObjFlags, EXC_OBJ_PRINTABLE );
903  DoReadObj5( rStrm, nNameLen, nMacroSize );
904 }
905 
907 {
908  // back to beginning
909  rStrm.Seek( EXC_REC_SEEK_TO_BEGIN );
910 
911  bool bLoop = true;
912  while (bLoop)
913  {
914  if (rStrm.GetRecLeft() < 4)
915  break;
916 
917  sal_uInt16 nSubRecId = rStrm.ReaduInt16();
918  sal_uInt16 nSubRecSize = rStrm.ReaduInt16();
919  rStrm.PushPosition();
920  // sometimes the last subrecord has an invalid length (OBJLBSDATA) -> min()
921  nSubRecSize = static_cast< sal_uInt16 >( ::std::min< std::size_t >( nSubRecSize, rStrm.GetRecLeft() ) );
922 
923  switch( nSubRecId )
924  {
925  case EXC_ID_OBJCMO:
926  OSL_ENSURE( rStrm.GetRecPos() == 4, "XclImpDrawObjBase::ImplReadObj8 - unexpected OBJCMO subrecord" );
927  if( (rStrm.GetRecPos() == 4) && (nSubRecSize >= 6) )
928  {
929  sal_uInt16 nObjFlags;
930  mnObjType = rStrm.ReaduInt16();
931  mnObjId = rStrm.ReaduInt16( );
932  nObjFlags = rStrm.ReaduInt16( );
934  }
935  break;
936  case EXC_ID_OBJMACRO:
937  ReadMacro8( rStrm );
938  break;
939  case EXC_ID_OBJEND:
940  bLoop = false;
941  break;
942  default:
943  DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
944  }
945 
946  rStrm.PopPosition();
947  rStrm.Ignore( nSubRecSize );
948  }
949 
950  /* Call DoReadObj8SubRec() with EXC_ID_OBJEND for further stream
951  processing (e.g. charts), even if the OBJEND subrecord is missing. */
952  DoReadObj8SubRec( rStrm, EXC_ID_OBJEND, 0 );
953 
954  /* Pictures that Excel reads from BIFF5 and writes to BIFF8 still have the
955  IMGDATA record following the OBJ record (but they use the image data
956  stored in DFF). The IMGDATA record may be continued by several CONTINUE
957  records. But the last CONTINUE record may be in fact an MSODRAWING
958  record that contains the DFF data of the next drawing object! So we
959  have to skip just enough CONTINUE records to look at the next
960  MSODRAWING/CONTINUE record. */
961  if( !((rStrm.GetNextRecId() == EXC_ID3_IMGDATA) && rStrm.StartNextRecord()) )
962  return;
963 
964  rStrm.Ignore( 4 );
965  sal_uInt32 nDataSize = rStrm.ReaduInt32();
966  nDataSize -= rStrm.GetRecLeft();
967  // skip following CONTINUE records until IMGDATA ends
968  while (true)
969  {
970  if (!nDataSize)
971  break;
972  if (rStrm.GetNextRecId() != EXC_ID_CONT)
973  break;
974  if (!rStrm.StartNextRecord())
975  break;
976  OSL_ENSURE( nDataSize >= rStrm.GetRecLeft(), "XclImpDrawObjBase::ImplReadObj8 - CONTINUE too long" );
977  nDataSize -= ::std::min< sal_uInt32 >( rStrm.GetRecLeft(), nDataSize );
978  }
979  OSL_ENSURE( nDataSize == 0, "XclImpDrawObjBase::ImplReadObj8 - missing CONTINUE records" );
980  // next record may be MSODRAWING or CONTINUE or anything else
981 }
982 
984 {
985  if( !mObjs.empty() )
986  if( XclImpGroupObj* pGroupObj = dynamic_cast< XclImpGroupObj* >( mObjs.back().get() ) )
987  if( pGroupObj->TryInsert( xDrawObj ) )
988  return;
989  mObjs.push_back( xDrawObj );
990 }
991 
993 {
994  return std::accumulate(mObjs.begin(), mObjs.end(), std::size_t(0),
995  [](const std::size_t& rSum, const XclImpDrawObjRef& rxObj) { return rSum + rxObj->GetProgressSize(); });
996 }
997 
999  XclImpDrawObjBase( rRoot )
1000 {
1001  SetProcessSdrObj( false );
1002 }
1003 
1005  XclImpDrawObjBase( rRoot ),
1006  mnFirstUngrouped( 0 )
1007 {
1008 }
1009 
1011 {
1012  if( xDrawObj->GetObjId() == mnFirstUngrouped )
1013  return false;
1014  // insert into own list or into nested group
1015  maChildren.InsertGrouped( xDrawObj );
1016  return true;
1017 }
1018 
1019 void XclImpGroupObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1020 {
1021  rStrm.Ignore( 4 );
1022  mnFirstUngrouped = rStrm.ReaduInt16();
1023  rStrm.Ignore( 16 );
1024  ReadMacro3( rStrm, nMacroSize );
1025 }
1026 
1027 void XclImpGroupObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1028 {
1029  rStrm.Ignore( 4 );
1030  mnFirstUngrouped = rStrm.ReaduInt16();
1031  rStrm.Ignore( 16 );
1032  ReadMacro4( rStrm, nMacroSize );
1033 }
1034 
1035 void XclImpGroupObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
1036 {
1037  rStrm.Ignore( 4 );
1038  mnFirstUngrouped = rStrm.ReaduInt16();
1039  rStrm.Ignore( 16 );
1040  ReadName5( rStrm, nNameLen );
1041  ReadMacro5( rStrm, nMacroSize );
1042 }
1043 
1045 {
1047 }
1048 
1050 {
1051  std::unique_ptr<SdrObjGroup, SdrObjectFreeOp> xSdrObj(
1052  new SdrObjGroup(
1053  *GetDoc().GetDrawLayer()));
1054  // child objects in BIFF2-BIFF5 have absolute size, not needed to pass own anchor rectangle
1055  SdrObjList& rObjList = *xSdrObj->GetSubList(); // SdrObjGroup always returns existing sublist
1056  for( const auto& rxChild : maChildren )
1057  rDffConv.ProcessObject( rObjList, *rxChild );
1058  rDffConv.Progress();
1059  return xSdrObj;
1060 }
1061 
1063  XclImpDrawObjBase( rRoot ),
1064  mnArrows( 0 ),
1065  mnStartPoint( EXC_OBJ_LINE_TL )
1066 {
1067  SetAreaObj( false );
1068 }
1069 
1070 void XclImpLineObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1071 {
1072  rStrm >> maLineData;
1073  mnArrows = rStrm.ReaduInt16();
1074  mnStartPoint = rStrm.ReaduInt8();
1075  rStrm.Ignore( 1 );
1076  ReadMacro3( rStrm, nMacroSize );
1077 }
1078 
1079 void XclImpLineObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1080 {
1081  rStrm >> maLineData;
1082  mnArrows = rStrm.ReaduInt16();
1083  mnStartPoint = rStrm.ReaduInt8();
1084  rStrm.Ignore( 1 );
1085  ReadMacro4( rStrm, nMacroSize );
1086 }
1087 
1088 void XclImpLineObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
1089 {
1090  rStrm >> maLineData;
1091  mnArrows = rStrm.ReaduInt16();
1092  mnStartPoint = rStrm.ReaduInt8();
1093  rStrm.Ignore( 1 );
1094  ReadName5( rStrm, nNameLen );
1095  ReadMacro5( rStrm, nMacroSize );
1096 }
1097 
1099 {
1100  ::basegfx::B2DPolygon aB2DPolygon;
1101  switch( mnStartPoint )
1102  {
1103  default:
1104  case EXC_OBJ_LINE_TL:
1105  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Left(), rAnchorRect.Top() ) );
1106  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Right(), rAnchorRect.Bottom() ) );
1107  break;
1108  case EXC_OBJ_LINE_TR:
1109  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Right(), rAnchorRect.Top() ) );
1110  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Left(), rAnchorRect.Bottom() ) );
1111  break;
1112  case EXC_OBJ_LINE_BR:
1113  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Right(), rAnchorRect.Bottom() ) );
1114  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Left(), rAnchorRect.Top() ) );
1115  break;
1116  case EXC_OBJ_LINE_BL:
1117  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Left(), rAnchorRect.Bottom() ) );
1118  aB2DPolygon.append( ::basegfx::B2DPoint( rAnchorRect.Right(), rAnchorRect.Top() ) );
1119  break;
1120  }
1121  SdrObjectUniquePtr xSdrObj(
1122  new SdrPathObj(
1123  *GetDoc().GetDrawLayer(),
1124  OBJ_LINE,
1125  ::basegfx::B2DPolyPolygon(aB2DPolygon)));
1126  ConvertLineStyle( *xSdrObj, maLineData );
1127 
1128  // line ends
1129  sal_uInt8 nArrowType = ::extract_value< sal_uInt8 >( mnArrows, 0, 4 );
1130  bool bLineStart = false;
1131  bool bLineEnd = false;
1132  bool bFilled = false;
1133  switch( nArrowType )
1134  {
1135  case EXC_OBJ_ARROW_OPEN: bLineStart = false; bLineEnd = true; bFilled = false; break;
1136  case EXC_OBJ_ARROW_OPENBOTH: bLineStart = true; bLineEnd = true; bFilled = false; break;
1137  case EXC_OBJ_ARROW_FILLED: bLineStart = false; bLineEnd = true; bFilled = true; break;
1138  case EXC_OBJ_ARROW_FILLEDBOTH: bLineStart = true; bLineEnd = true; bFilled = true; break;
1139  }
1140  if( bLineStart || bLineEnd )
1141  {
1142  sal_uInt8 nArrowWidth = ::extract_value< sal_uInt8 >( mnArrows, 4, 4 );
1143  double fArrowWidth = 3.0;
1144  switch( nArrowWidth )
1145  {
1146  case EXC_OBJ_ARROW_NARROW: fArrowWidth = 2.0; break;
1147  case EXC_OBJ_ARROW_MEDIUM: fArrowWidth = 3.0; break;
1148  case EXC_OBJ_ARROW_WIDE: fArrowWidth = 5.0; break;
1149  }
1150 
1151  sal_uInt8 nArrowLength = ::extract_value< sal_uInt8 >( mnArrows, 8, 4 );
1152  double fArrowLength = 3.0;
1153  switch( nArrowLength )
1154  {
1155  case EXC_OBJ_ARROW_NARROW: fArrowLength = 2.5; break;
1156  case EXC_OBJ_ARROW_MEDIUM: fArrowLength = 3.5; break;
1157  case EXC_OBJ_ARROW_WIDE: fArrowLength = 6.0; break;
1158  }
1159 
1160  ::basegfx::B2DPolygon aArrowPoly;
1161 #define EXC_ARROW_POINT( x, y ) ::basegfx::B2DPoint( fArrowWidth * (x), fArrowLength * (y) )
1162  if( bFilled )
1163  {
1164  aArrowPoly.append( EXC_ARROW_POINT( 0, 100 ) );
1165  aArrowPoly.append( EXC_ARROW_POINT( 50, 0 ) );
1166  aArrowPoly.append( EXC_ARROW_POINT( 100, 100 ) );
1167  }
1168  else
1169  {
1171  aArrowPoly.append( EXC_ARROW_POINT( 50, 0 ) );
1172  aArrowPoly.append( EXC_ARROW_POINT( 100, 100 - 3 * nLineWidth ) );
1173  aArrowPoly.append( EXC_ARROW_POINT( 100 - 5 * nLineWidth, 100 ) );
1174  aArrowPoly.append( EXC_ARROW_POINT( 50, 12 * nLineWidth ) );
1175  aArrowPoly.append( EXC_ARROW_POINT( 5 * nLineWidth, 100 ) );
1176  aArrowPoly.append( EXC_ARROW_POINT( 0, 100 - 3 * nLineWidth ) );
1177  }
1178 #undef EXC_ARROW_POINT
1179 
1180  ::basegfx::B2DPolyPolygon aArrowPolyPoly( aArrowPoly );
1181  tools::Long nWidth = static_cast< tools::Long >( 125 * fArrowWidth );
1182  if( bLineStart )
1183  {
1184  xSdrObj->SetMergedItem( XLineStartItem( EMPTY_OUSTRING, aArrowPolyPoly ) );
1185  xSdrObj->SetMergedItem( XLineStartWidthItem( nWidth ) );
1186  xSdrObj->SetMergedItem( XLineStartCenterItem( false ) );
1187  }
1188  if( bLineEnd )
1189  {
1190  xSdrObj->SetMergedItem( XLineEndItem( EMPTY_OUSTRING, aArrowPolyPoly ) );
1191  xSdrObj->SetMergedItem( XLineEndWidthItem( nWidth ) );
1192  xSdrObj->SetMergedItem( XLineEndCenterItem( false ) );
1193  }
1194  }
1195  rDffConv.Progress();
1196  return xSdrObj;
1197 }
1198 
1200  XclImpDrawObjBase( rRoot ),
1201  mnFrameFlags( 0 )
1202 {
1203  SetAreaObj( true );
1204 }
1205 
1207 {
1208  rStrm >> maFillData >> maLineData;
1209  mnFrameFlags = rStrm.ReaduInt16();
1210 }
1211 
1213 {
1214  ConvertLineStyle( rSdrObj, maLineData );
1215  ConvertFillStyle( rSdrObj, maFillData );
1216  ConvertFrameStyle( rSdrObj, mnFrameFlags );
1217 }
1218 
1219 void XclImpRectObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1220 {
1221  ReadFrameData( rStrm );
1222  ReadMacro3( rStrm, nMacroSize );
1223 }
1224 
1225 void XclImpRectObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1226 {
1227  ReadFrameData( rStrm );
1228  ReadMacro4( rStrm, nMacroSize );
1229 }
1230 
1231 void XclImpRectObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
1232 {
1233  ReadFrameData( rStrm );
1234  ReadName5( rStrm, nNameLen );
1235  ReadMacro5( rStrm, nMacroSize );
1236 }
1237 
1239 {
1240  SdrObjectUniquePtr xSdrObj(
1241  new SdrRectObj(
1242  *GetDoc().GetDrawLayer(),
1243  rAnchorRect));
1244  ConvertRectStyle( *xSdrObj );
1245  rDffConv.Progress();
1246  return xSdrObj;
1247 }
1248 
1250  XclImpRectObj( rRoot )
1251 {
1252 }
1253 
1255 {
1256  SdrObjectUniquePtr xSdrObj(
1257  new SdrCircObj(
1258  *GetDoc().GetDrawLayer(),
1259  SdrCircKind::Full,
1260  rAnchorRect));
1261  ConvertRectStyle( *xSdrObj );
1262  rDffConv.Progress();
1263  return xSdrObj;
1264 }
1265 
1267  XclImpDrawObjBase( rRoot ),
1268  mnQuadrant( EXC_OBJ_ARC_TR )
1269 {
1270  SetAreaObj( false ); // arc may be 2-dimensional
1271 }
1272 
1273 void XclImpArcObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1274 {
1275  rStrm >> maFillData >> maLineData;
1276  mnQuadrant = rStrm.ReaduInt8();
1277  rStrm.Ignore( 1 );
1278  ReadMacro3( rStrm, nMacroSize );
1279 }
1280 
1281 void XclImpArcObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1282 {
1283  rStrm >> maFillData >> maLineData;
1284  mnQuadrant = rStrm.ReaduInt8();
1285  rStrm.Ignore( 1 );
1286  ReadMacro4( rStrm, nMacroSize );
1287 }
1288 
1289 void XclImpArcObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
1290 {
1291  rStrm >> maFillData >> maLineData;
1292  mnQuadrant = rStrm.ReaduInt8();
1293  rStrm.Ignore( 1 );
1294  ReadName5( rStrm, nNameLen );
1295  ReadMacro5( rStrm, nMacroSize );
1296 }
1297 
1299 {
1300  tools::Rectangle aNewRect = rAnchorRect;
1301  Degree100 nStartAngle;
1302  Degree100 nEndAngle;
1303  switch( mnQuadrant )
1304  {
1305  default:
1306  case EXC_OBJ_ARC_TR:
1307  nStartAngle = 0_deg100;
1308  nEndAngle = 9000_deg100;
1309  aNewRect.AdjustLeft( -(rAnchorRect.GetWidth()) );
1310  aNewRect.AdjustBottom(rAnchorRect.GetHeight() );
1311  break;
1312  case EXC_OBJ_ARC_TL:
1313  nStartAngle = 9000_deg100;
1314  nEndAngle = 18000_deg100;
1315  aNewRect.AdjustRight(rAnchorRect.GetWidth() );
1316  aNewRect.AdjustBottom(rAnchorRect.GetHeight() );
1317  break;
1318  case EXC_OBJ_ARC_BL:
1319  nStartAngle = 18000_deg100;
1320  nEndAngle = 27000_deg100;
1321  aNewRect.AdjustRight(rAnchorRect.GetWidth() );
1322  aNewRect.AdjustTop( -(rAnchorRect.GetHeight()) );
1323  break;
1324  case EXC_OBJ_ARC_BR:
1325  nStartAngle = 27000_deg100;
1326  nEndAngle = 0_deg100;
1327  aNewRect.AdjustLeft( -(rAnchorRect.GetWidth()) );
1328  aNewRect.AdjustTop( -(rAnchorRect.GetHeight()) );
1329  break;
1330  }
1331  SdrCircKind eObjKind = maFillData.IsFilled() ? SdrCircKind::Section : SdrCircKind::Arc;
1332  SdrObjectUniquePtr xSdrObj(
1333  new SdrCircObj(
1334  *GetDoc().GetDrawLayer(),
1335  eObjKind,
1336  aNewRect,
1337  nStartAngle,
1338  nEndAngle));
1339  ConvertFillStyle( *xSdrObj, maFillData );
1340  ConvertLineStyle( *xSdrObj, maLineData );
1341  rDffConv.Progress();
1342  return xSdrObj;
1343 }
1344 
1346  XclImpRectObj( rRoot ),
1347  mnPolyFlags( 0 ),
1348  mnPointCount( 0 )
1349 {
1350  SetAreaObj( false ); // polygon may be 2-dimensional
1351 }
1352 
1354 {
1355  if( (rStrm.GetNextRecId() == EXC_ID_COORDLIST) && rStrm.StartNextRecord() )
1356  {
1357  OSL_ENSURE( rStrm.GetRecLeft() / 4 == mnPointCount, "XclImpPolygonObj::ReadCoordList - wrong polygon point count" );
1358  while (true)
1359  {
1360  if (rStrm.GetRecLeft() < 4)
1361  break;
1362  sal_uInt16 nX = rStrm.ReaduInt16();
1363  sal_uInt16 nY = rStrm.ReaduInt16();
1364  maCoords.emplace_back( nX, nY );
1365  }
1366  }
1367 }
1368 
1369 void XclImpPolygonObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1370 {
1371  ReadFrameData( rStrm );
1372  mnPolyFlags = rStrm.ReaduInt16();
1373  rStrm.Ignore( 10 );
1374  mnPointCount = rStrm.ReaduInt16();
1375  rStrm.Ignore( 8 );
1376  ReadMacro4( rStrm, nMacroSize );
1377  ReadCoordList( rStrm );
1378 }
1379 
1380 void XclImpPolygonObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
1381 {
1382  ReadFrameData( rStrm );
1383  mnPolyFlags = rStrm.ReaduInt16();
1384  rStrm.Ignore( 10 );
1385  mnPointCount = rStrm.ReaduInt16();
1386  rStrm.Ignore( 8 );
1387  ReadName5( rStrm, nNameLen );
1388  ReadMacro5( rStrm, nMacroSize );
1389  ReadCoordList( rStrm );
1390 }
1391 
1392 namespace {
1393 
1394 ::basegfx::B2DPoint lclGetPolyPoint( const tools::Rectangle& rAnchorRect, const Point& rPoint )
1395 {
1396  return ::basegfx::B2DPoint(
1397  rAnchorRect.Left() + static_cast< sal_Int32 >( ::std::min< double >( rPoint.X(), 16384.0 ) / 16384.0 * rAnchorRect.GetWidth() + 0.5 ),
1398  rAnchorRect.Top() + static_cast< sal_Int32 >( ::std::min< double >( rPoint.Y(), 16384.0 ) / 16384.0 * rAnchorRect.GetHeight() + 0.5 ) );
1399 }
1400 
1401 } // namespace
1402 
1404 {
1405  SdrObjectUniquePtr xSdrObj;
1406  if( maCoords.size() >= 2 )
1407  {
1408  // create the polygon
1409  ::basegfx::B2DPolygon aB2DPolygon;
1410  for( const auto& rCoord : maCoords )
1411  aB2DPolygon.append( lclGetPolyPoint( rAnchorRect, rCoord ) );
1412  // close polygon if specified
1413  if( ::get_flag( mnPolyFlags, EXC_OBJ_POLY_CLOSED ) && (maCoords.front() != maCoords.back()) )
1414  aB2DPolygon.append( lclGetPolyPoint( rAnchorRect, maCoords.front() ) );
1415  // create the SdrObject
1417  xSdrObj.reset(
1418  new SdrPathObj(
1419  *GetDoc().GetDrawLayer(),
1420  eObjKind,
1421  ::basegfx::B2DPolyPolygon(aB2DPolygon)));
1422  ConvertRectStyle( *xSdrObj );
1423  }
1424  rDffConv.Progress();
1425  return xSdrObj;
1426 }
1427 
1429 {
1430  mxString.reset();
1431  if( maData.mnTextLen > 0 )
1432  {
1433  mxString = std::make_shared<XclImpString>( rStrm.ReadRawByteString( maData.mnTextLen ) );
1434  // skip padding byte for word boundaries
1435  if( rStrm.GetRecPos() & 1 ) rStrm.Ignore( 1 );
1436  }
1437 }
1438 
1440 {
1441  if( mxString )
1442  mxString->ReadObjFormats( rStrm, maData.mnFormatSize );
1443  else
1444  rStrm.Ignore( maData.mnFormatSize );
1445 }
1446 
1448  XclImpRectObj( rRoot )
1449 {
1450 }
1451 
1452 void XclImpTextObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1453 {
1454  ReadFrameData( rStrm );
1455  maTextData.maData.ReadObj3( rStrm );
1456  ReadMacro3( rStrm, nMacroSize );
1457  maTextData.ReadByteString( rStrm );
1458  maTextData.ReadFormats( rStrm );
1459 }
1460 
1461 void XclImpTextObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1462 {
1463  ReadFrameData( rStrm );
1464  maTextData.maData.ReadObj3( rStrm );
1465  ReadMacro4( rStrm, nMacroSize );
1466  maTextData.ReadByteString( rStrm );
1467  maTextData.ReadFormats( rStrm );
1468 }
1469 
1470 void XclImpTextObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
1471 {
1472  ReadFrameData( rStrm );
1473  maTextData.maData.ReadObj5( rStrm );
1474  ReadName5( rStrm, nNameLen );
1475  ReadMacro5( rStrm, nMacroSize );
1476  maTextData.ReadByteString( rStrm );
1477  rStrm.Ignore( maTextData.maData.mnLinkSize ); // ignore text link formula
1478  maTextData.ReadFormats( rStrm );
1479 }
1480 
1482 {
1483  std::unique_ptr<SdrObjCustomShape, SdrObjectFreeOp> xSdrObj(
1484  new SdrObjCustomShape(
1485  *GetDoc().GetDrawLayer()));
1486  xSdrObj->NbcSetSnapRect( rAnchorRect );
1487  OUString aRectType = "rectangle";
1488  xSdrObj->MergeDefaultAttributes( &aRectType );
1489  ConvertRectStyle( *xSdrObj );
1491  xSdrObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoSize ) );
1492  xSdrObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoSize ) );
1493  xSdrObj->SetMergedItem( makeSdrTextWordWrapItem( true ) );
1494  rDffConv.Progress();
1495  return xSdrObj;
1496 }
1497 
1499 {
1500  // set text data
1501  if( SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( &rSdrObj ) )
1502  {
1503  if( maTextData.mxString )
1504  {
1505  if( maTextData.mxString->IsRich() )
1506  {
1507  if (maTextData.mxString->GetText().getLength() > 1024 && utl::ConfigManager::IsFuzzing())
1508  {
1509  SAL_WARN("sc.filter", "truncating slow long rich text for fuzzing performance");
1510  maTextData.mxString->SetText(maTextData.mxString->GetText().copy(0, 1024));
1511  }
1512 
1513  // rich text
1514  std::unique_ptr< EditTextObject > xEditObj(
1516  OutlinerParaObject aOutlineObj(std::move(xEditObj));
1517  aOutlineObj.SetOutlinerMode( OutlinerMode::TextObject );
1518  pTextObj->NbcSetOutlinerParaObject( std::move(aOutlineObj) );
1519  }
1520  else
1521  {
1522  // plain text
1523  pTextObj->NbcSetText( maTextData.mxString->GetText() );
1524  }
1525 
1526  /* #i96858# Do not apply any formatting if there is no text.
1527  SdrObjCustomShape::SetVerticalWriting (initiated from
1528  SetMergedItem) calls SdrTextObj::ForceOutlinerParaObject which
1529  ensures that we can erroneously write a ClientTextbox record
1530  (with no content) while exporting to XLS, which can cause a
1531  corrupted exported document. */
1532 
1533  SvxAdjust eHorAlign = SvxAdjust::Left;
1535 
1536  // orientation (this is only a fake, drawing does not support real text orientation)
1537  namespace csst = ::com::sun::star::text;
1538  csst::WritingMode eWriteMode = csst::WritingMode_LR_TB;
1539  switch( maTextData.maData.mnOrient )
1540  {
1541  default:
1542  case EXC_OBJ_ORIENT_NONE:
1543  {
1544  eWriteMode = csst::WritingMode_LR_TB;
1545  switch( maTextData.maData.GetHorAlign() )
1546  {
1547  case EXC_OBJ_HOR_LEFT: eHorAlign = SvxAdjust::Left; break;
1548  case EXC_OBJ_HOR_CENTER: eHorAlign = SvxAdjust::Center; break;
1549  case EXC_OBJ_HOR_RIGHT: eHorAlign = SvxAdjust::Right; break;
1550  case EXC_OBJ_HOR_JUSTIFY: eHorAlign = SvxAdjust::Block; break;
1551  }
1552  switch( maTextData.maData.GetVerAlign() )
1553  {
1554  case EXC_OBJ_VER_TOP: eVerAlign = SDRTEXTVERTADJUST_TOP; break;
1555  case EXC_OBJ_VER_CENTER: eVerAlign = SDRTEXTVERTADJUST_CENTER; break;
1556  case EXC_OBJ_VER_BOTTOM: eVerAlign = SDRTEXTVERTADJUST_BOTTOM; break;
1557  case EXC_OBJ_VER_JUSTIFY: eVerAlign = SDRTEXTVERTADJUST_BLOCK; break;
1558  }
1559  }
1560  break;
1561 
1562  case EXC_OBJ_ORIENT_90CCW:
1563  {
1564  if( SdrObjCustomShape* pObjCustomShape = dynamic_cast< SdrObjCustomShape* >( &rSdrObj ) )
1565  {
1566  css::beans::PropertyValue aTextRotateAngle;
1567  aTextRotateAngle.Name = "TextRotateAngle";
1568  aTextRotateAngle.Value <<= 180.0;
1569  SdrCustomShapeGeometryItem aGeometryItem(pObjCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
1570  aGeometryItem.SetPropertyValue( aTextRotateAngle );
1571  pObjCustomShape->SetMergedItem( aGeometryItem );
1572  }
1573  eWriteMode = csst::WritingMode_TB_RL;
1574  switch( maTextData.maData.GetHorAlign() )
1575  {
1576  case EXC_OBJ_HOR_LEFT: eVerAlign = SDRTEXTVERTADJUST_TOP; break;
1577  case EXC_OBJ_HOR_CENTER: eVerAlign = SDRTEXTVERTADJUST_CENTER; break;
1578  case EXC_OBJ_HOR_RIGHT: eVerAlign = SDRTEXTVERTADJUST_BOTTOM; break;
1579  case EXC_OBJ_HOR_JUSTIFY: eVerAlign = SDRTEXTVERTADJUST_BLOCK; break;
1580  }
1581  MSO_Anchor eTextAnchor = static_cast<MSO_Anchor>(rDffConv.GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop ));
1582  switch( eTextAnchor )
1583  {
1584  case mso_anchorTopCentered :
1587  {
1588  eHorAlign = SvxAdjust::Center;
1589  }
1590  break;
1591 
1592  default:
1593  {
1594  switch( maTextData.maData.GetVerAlign() )
1595  {
1596  case EXC_OBJ_VER_TOP: eHorAlign = SvxAdjust::Right; break;
1597  case EXC_OBJ_VER_CENTER: eHorAlign = SvxAdjust::Center; break;
1598  case EXC_OBJ_VER_BOTTOM: eHorAlign = SvxAdjust::Left; break;
1599  case EXC_OBJ_VER_JUSTIFY: eHorAlign = SvxAdjust::Block; break;
1600  }
1601  }
1602  }
1603  }
1604  break;
1605 
1607  {
1608  // sj: STACKED is not supported, maybe it can be optimized here a bit
1609  [[fallthrough]];
1610  }
1611  case EXC_OBJ_ORIENT_90CW:
1612  {
1613  eWriteMode = csst::WritingMode_TB_RL;
1614  switch( maTextData.maData.GetHorAlign() )
1615  {
1616  case EXC_OBJ_HOR_LEFT: eVerAlign = SDRTEXTVERTADJUST_BOTTOM; break;
1617  case EXC_OBJ_HOR_CENTER: eVerAlign = SDRTEXTVERTADJUST_CENTER; break;
1618  case EXC_OBJ_HOR_RIGHT: eVerAlign = SDRTEXTVERTADJUST_TOP; break;
1619  case EXC_OBJ_HOR_JUSTIFY: eVerAlign = SDRTEXTVERTADJUST_BLOCK; break;
1620  }
1621  MSO_Anchor eTextAnchor = static_cast<MSO_Anchor>(rDffConv.GetPropertyValue( DFF_Prop_anchorText, mso_anchorTop ));
1622  switch ( eTextAnchor )
1623  {
1624  case mso_anchorTopCentered :
1627  {
1628  eHorAlign = SvxAdjust::Center;
1629  }
1630  break;
1631 
1632  default:
1633  {
1634  switch( maTextData.maData.GetVerAlign() )
1635  {
1636  case EXC_OBJ_VER_TOP: eHorAlign = SvxAdjust::Left; break;
1637  case EXC_OBJ_VER_CENTER: eHorAlign = SvxAdjust::Center; break;
1638  case EXC_OBJ_VER_BOTTOM: eHorAlign = SvxAdjust::Right; break;
1639  case EXC_OBJ_VER_JUSTIFY: eHorAlign = SvxAdjust::Block; break;
1640  }
1641  }
1642  }
1643  }
1644  break;
1645  }
1646  rSdrObj.SetMergedItem( SvxAdjustItem( eHorAlign, EE_PARA_JUST ) );
1647  rSdrObj.SetMergedItem( SdrTextVertAdjustItem( eVerAlign ) );
1648  rSdrObj.SetMergedItem( SvxWritingModeItem( eWriteMode, SDRATTR_TEXTDIRECTION ) );
1649  }
1650  }
1651  // base class processing
1652  XclImpRectObj::DoPreProcessSdrObj( rDffConv, rSdrObj );
1653 }
1654 
1655 XclImpChartObj::XclImpChartObj( const XclImpRoot& rRoot, bool bOwnTab ) :
1656  XclImpRectObj( rRoot ),
1657  mbOwnTab( bOwnTab )
1658 {
1659  SetSimpleMacro( false );
1660  SetCustomDffObj( true );
1661 }
1662 
1664 {
1665  /* If chart is read from a chartsheet (mbOwnTab == true), the BOF record
1666  has already been read. If chart is embedded as object, the next record
1667  has to be the BOF record. */
1668  if( mbOwnTab )
1669  {
1670  /* #i109800# The input stream may point somewhere inside the chart
1671  substream and not exactly to the leading BOF record. To read this
1672  record correctly in the following, the stream has to rewind it, so
1673  that the next call to StartNextRecord() will find it correctly. */
1674  if( rStrm.GetRecId() != EXC_ID5_BOF )
1675  rStrm.RewindRecord();
1676  }
1677  else
1678  {
1679  if( (rStrm.GetNextRecId() == EXC_ID5_BOF) && rStrm.StartNextRecord() )
1680  {
1681  sal_uInt16 nBofType;
1682  rStrm.Seek( 2 );
1683  nBofType = rStrm.ReaduInt16();
1684  SAL_WARN_IF( nBofType != EXC_BOF_CHART, "sc.filter", "XclImpChartObj::ReadChartSubStream - no chart BOF record" );
1685  }
1686  else
1687  {
1688  SAL_INFO("sc.filter", "XclImpChartObj::ReadChartSubStream - missing chart substream");
1689  return;
1690  }
1691  }
1692 
1693  // read chart, even if BOF record contains wrong substream identifier
1694  mxChart = std::make_shared<XclImpChart>( GetRoot(), mbOwnTab );
1695  mxChart->ReadChartSubStream( rStrm );
1696  if( mbOwnTab )
1697  FinalizeTabChart();
1698 }
1699 
1700 void XclImpChartObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1701 {
1702  // read OBJ record and the following chart substream
1703  ReadFrameData( rStrm );
1704  rStrm.Ignore( 18 );
1705  ReadMacro3( rStrm, nMacroSize );
1706  // set frame format from OBJ record, it is used if chart itself is transparent
1707  if( mxChart )
1708  mxChart->UpdateObjFrame( maLineData, maFillData );
1709 }
1710 
1711 void XclImpChartObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
1712 {
1713  // read OBJ record and the following chart substream
1714  ReadFrameData( rStrm );
1715  rStrm.Ignore( 18 );
1716  ReadMacro4( rStrm, nMacroSize );
1717  // set frame format from OBJ record, it is used if chart itself is transparent
1718  if( mxChart )
1719  mxChart->UpdateObjFrame( maLineData, maFillData );
1720 }
1721 
1722 void XclImpChartObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
1723 {
1724  // read OBJ record and the following chart substream
1725  ReadFrameData( rStrm );
1726  rStrm.Ignore( 18 );
1727  ReadName5( rStrm, nNameLen );
1728  ReadMacro5( rStrm, nMacroSize );
1729  ReadChartSubStream( rStrm );
1730  // set frame format from OBJ record, it is used if chart itself is transparent
1731  if( mxChart )
1732  mxChart->UpdateObjFrame( maLineData, maFillData );
1733 }
1734 
1735 void XclImpChartObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 /*nSubRecSize*/ )
1736 {
1737  // read the following chart substream
1738  if( nSubRecId == EXC_ID_OBJEND )
1739  {
1740  // enable CONTINUE handling for the entire chart substream
1741  rStrm.ResetRecord( true );
1742  ReadChartSubStream( rStrm );
1743  /* disable CONTINUE handling again to be able to read
1744  following CONTINUE records as MSODRAWING records. */
1745  rStrm.ResetRecord( false );
1746  }
1747 }
1748 
1750 {
1751  return mxChart ? mxChart->GetProgressSize() : 1;
1752 }
1753 
1755 {
1756  SdrObjectUniquePtr xSdrObj;
1757  SfxObjectShell* pDocShell = GetDocShell();
1758  if( rDffConv.SupportsOleObjects() && SvtModuleOptions().IsChart() && pDocShell && mxChart && !mxChart->IsPivotChart() )
1759  {
1760  // create embedded chart object
1761  OUString aEmbObjName;
1762  OUString sBaseURL(GetRoot().GetMedium().GetBaseURL());
1763  Reference< XEmbeddedObject > xEmbObj = pDocShell->GetEmbeddedObjectContainer().
1764  CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aEmbObjName, &sBaseURL );
1765 
1766  /* Set the size to the embedded object, this prevents that font sizes
1767  of text objects are changed in the chart when the object is
1768  inserted into the draw page. */
1769  sal_Int64 nAspect = css::embed::Aspects::MSOLE_CONTENT;
1770  MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xEmbObj->getMapUnit( nAspect ) );
1771  Size aSize( OutputDevice::LogicToLogic( rAnchorRect.GetSize(), MapMode( MapUnit::Map100thMM ), MapMode( aUnit ) ) );
1772  css::awt::Size aAwtSize( aSize.Width(), aSize.Height() );
1773  xEmbObj->setVisualAreaSize( nAspect, aAwtSize );
1774 
1775  // #i121334# This call will change the chart's default background fill from white to transparent.
1776  // Add here again if this is wanted (see task description for details)
1777  // ChartHelper::AdaptDefaultsForChart( xEmbObj );
1778 
1779  // create the container OLE object
1780  xSdrObj.reset(
1781  new SdrOle2Obj(
1782  *GetDoc().GetDrawLayer(),
1783  svt::EmbeddedObjectRef(xEmbObj, nAspect),
1784  aEmbObjName,
1785  rAnchorRect));
1786  }
1787 
1788  return xSdrObj;
1789 }
1790 
1792 {
1793  const SdrOle2Obj* pSdrOleObj = dynamic_cast< const SdrOle2Obj* >( &rSdrObj );
1794  if( !(mxChart && pSdrOleObj) )
1795  return;
1796 
1797  const Reference< XEmbeddedObject >& xEmbObj = pSdrOleObj->GetObjRef();
1798  if( xEmbObj.is() && ::svt::EmbeddedObjectRef::TryRunningState( xEmbObj ) ) try
1799  {
1800  Reference< XEmbedPersist > xPersist( xEmbObj, UNO_QUERY_THROW );
1801  Reference< XModel > xModel( xEmbObj->getComponent(), UNO_QUERY_THROW );
1802  mxChart->Convert( xModel, rDffConv, xPersist->getEntryName(), rSdrObj.GetLogicRect() );
1803  }
1804  catch( const Exception& )
1805  {
1806  }
1807 }
1808 
1810 {
1811  /* #i44077# Calculate and store DFF anchor for sheet charts.
1812  Needed to get used area if this chart is inserted as OLE object. */
1813  OSL_ENSURE( mbOwnTab, "XclImpChartObj::FinalizeTabChart - not allowed for embedded chart objects" );
1814 
1815  // set uninitialized page to landscape
1816  if( !GetPageSettings().GetPageData().mbValid )
1818 
1819  // calculate size of the chart object
1820  const XclPageData& rPageData = GetPageSettings().GetPageData();
1821  Size aPaperSize = rPageData.GetScPaperSize();
1822 
1823  tools::Long nWidth = XclTools::GetHmmFromTwips( aPaperSize.Width() );
1824  tools::Long nHeight = XclTools::GetHmmFromTwips( aPaperSize.Height() );
1825 
1826  // subtract page margins, give some more extra space
1827  nWidth -= o3tl::saturating_add(XclTools::GetHmmFromInch(rPageData.mfLeftMargin + rPageData.mfRightMargin), static_cast<sal_Int32>(2000));
1828  nHeight -= o3tl::saturating_add(XclTools::GetHmmFromInch(rPageData.mfTopMargin + rPageData.mfBottomMargin), static_cast<sal_Int32>(1000));
1829 
1830  // print column/row headers?
1831  if( rPageData.mbPrintHeadings )
1832  {
1833  nWidth -= 2000;
1834  nHeight -= 1000;
1835  }
1836 
1837  // create the object anchor
1838  XclObjAnchor aAnchor;
1839  aAnchor.SetRect( GetRoot(), GetCurrScTab(), tools::Rectangle( 1000, 500, nWidth, nHeight ), MapUnit::Map100thMM );
1840  SetAnchor( aAnchor );
1841 }
1842 
1844  XclImpTextObj( rRoot ),
1845  maScPos( ScAddress::INITIALIZE_INVALID ),
1846  mnNoteFlags( 0 )
1847 {
1848  SetSimpleMacro( false );
1849  // caption object will be created manually
1850  SetInsertSdrObj( false );
1851 }
1852 
1853 void XclImpNoteObj::SetNoteData( const ScAddress& rScPos, sal_uInt16 nNoteFlags )
1854 {
1855  maScPos = rScPos;
1856  mnNoteFlags = nNoteFlags;
1857 }
1858 
1860 {
1861  // create formatted text
1862  XclImpTextObj::DoPreProcessSdrObj( rDffConv, rSdrObj );
1863  OutlinerParaObject* pOutlinerObj = rSdrObj.GetOutlinerParaObject();
1864  if( maScPos.IsValid() && pOutlinerObj )
1865  {
1866  // create cell note with all data from drawing object
1868  GetDoc(), maScPos,
1869  rSdrObj.GetMergedItemSet().CloneAsValue(), // new object on heap expected
1870  *pOutlinerObj,
1871  rSdrObj.GetLogicRect(),
1873  }
1874 }
1875 
1877  mrRoot( rRoot ),
1878  meBindMode( eBindMode )
1879 {
1880 }
1881 
1883 {
1884 }
1885 
1887  const Reference< XShape >& rxShape, const tools::Rectangle& rAnchorRect ) const
1888 {
1889  mxShape = rxShape;
1891  if( xSdrObj )
1892  {
1893  xSdrObj->NbcSetSnapRect( rAnchorRect );
1894  // #i30543# insert into control layer
1895  xSdrObj->NbcSetLayer( SC_LAYER_CONTROLS );
1896  }
1897  return xSdrObj;
1898 }
1899 
1901 {
1902 
1903  Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape );
1904  if( !xCtrlModel.is() )
1905  return;
1906 
1907  // sheet links
1908  SfxObjectShell* pDocShell = mrRoot.GetDocShell();
1909  if(!pDocShell)
1910  return;
1911 
1912  Reference< XMultiServiceFactory > xFactory( pDocShell->GetModel(), UNO_QUERY );
1913  if( !xFactory.is() )
1914  return;
1915 
1916  // cell link
1917  if( mxCellLink ) try
1918  {
1919  Reference< XBindableValue > xBindable( xCtrlModel, UNO_QUERY_THROW );
1920 
1921  // create argument sequence for createInstanceWithArguments()
1922  CellAddress aApiAddress;
1924 
1925  NamedValue aValue;
1926  aValue.Name = SC_UNONAME_BOUNDCELL;
1927  aValue.Value <<= aApiAddress;
1928 
1929  Sequence< Any > aArgs( 1 );
1930  aArgs[ 0 ] <<= aValue;
1931 
1932  // create the CellValueBinding instance and set at the control model
1933  OUString aServiceName;
1934  switch( meBindMode )
1935  {
1936  case EXC_CTRL_BINDCONTENT: aServiceName = SC_SERVICENAME_VALBIND; break;
1937  case EXC_CTRL_BINDPOSITION: aServiceName = SC_SERVICENAME_LISTCELLBIND; break;
1938  }
1939  Reference< XValueBinding > xBinding(
1940  xFactory->createInstanceWithArguments( aServiceName, aArgs ), UNO_QUERY_THROW );
1941  xBindable->setValueBinding( xBinding );
1942  }
1943  catch( const Exception& )
1944  {
1945  }
1946 
1947  // source range
1948  if( !mxSrcRange )
1949  return;
1950 
1951  try
1952  {
1953  Reference< XListEntrySink > xEntrySink( xCtrlModel, UNO_QUERY_THROW );
1954 
1955  // create argument sequence for createInstanceWithArguments()
1956  CellRangeAddress aApiRange;
1958 
1959  NamedValue aValue;
1960  aValue.Name = SC_UNONAME_CELLRANGE;
1961  aValue.Value <<= aApiRange;
1962 
1963  Sequence< Any > aArgs( 1 );
1964  aArgs[ 0 ] <<= aValue;
1965 
1966  // create the EntrySource instance and set at the control model
1967  Reference< XListEntrySource > xEntrySource( xFactory->createInstanceWithArguments(
1968  SC_SERVICENAME_LISTSOURCE, aArgs ), UNO_QUERY_THROW );
1969  xEntrySink->setListEntrySource( xEntrySource );
1970  }
1971  catch( const Exception& )
1972  {
1973  }
1974 }
1975 
1977 {
1978  Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape );
1979  if( !xCtrlModel.is() )
1980  return;
1981 
1983 
1984  ScfPropertySet aPropSet( xCtrlModel );
1985 
1986  // #i51348# set object name at control model
1987  aPropSet.SetStringProperty( "Name", rDrawObj.GetObjName() );
1988 
1989  // control visible and printable?
1990  aPropSet.SetBoolProperty( "EnableVisible", rDrawObj.IsVisible() );
1991  aPropSet.SetBoolProperty( "Printable", rDrawObj.IsPrintable() );
1992 
1993  // virtual call for type specific processing
1994  DoProcessControl( aPropSet );
1995 }
1996 
1997 void XclImpControlHelper::ReadCellLinkFormula( XclImpStream& rStrm, bool bWithBoundSize )
1998 {
1999  ScRangeList aScRanges;
2000  ReadRangeList( aScRanges, rStrm, bWithBoundSize );
2001  // Use first cell of first range
2002  if ( !aScRanges.empty() )
2003  {
2004  const ScRange & rScRange = aScRanges.front();
2005  mxCellLink = std::make_shared<ScAddress>( rScRange.aStart );
2006  }
2007 }
2008 
2010 {
2011  ScRangeList aScRanges;
2012  ReadRangeList( aScRanges, rStrm, bWithBoundSize );
2013  // Use first range
2014  if ( !aScRanges.empty() )
2015  {
2016  const ScRange & rScRange = aScRanges.front();
2017  mxSrcRange = std::make_shared<ScRange>( rScRange );
2018  }
2019 }
2020 
2022 {
2023 }
2024 
2026 {
2027  XclTokenArray aXclTokArr;
2028  sal_uInt16 nSize = XclTokenArray::ReadSize(rStrm);
2029  rStrm.Ignore( 4 );
2030  aXclTokArr.ReadArray(nSize, rStrm);
2031  mrRoot.GetFormulaCompiler().CreateRangeList( rScRanges, EXC_FMLATYPE_CONTROL, aXclTokArr, rStrm );
2032 }
2033 
2034 void XclImpControlHelper::ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm, bool bWithBoundSize )
2035 {
2036  if( bWithBoundSize )
2037  {
2038  sal_uInt16 nSize;
2039  nSize = rStrm.ReaduInt16();
2040  if( nSize > 0 )
2041  {
2042  rStrm.PushPosition();
2043  ReadRangeList( rScRanges, rStrm );
2044  rStrm.PopPosition();
2045  rStrm.Ignore( nSize );
2046  }
2047  }
2048  else
2049  {
2050  ReadRangeList( rScRanges, rStrm );
2051  }
2052 }
2053 
2055  XclImpTextObj( rRoot ),
2057 {
2058  SetSimpleMacro( false );
2059  SetCustomDffObj( true );
2060 }
2061 
2062 namespace {
2063 
2064 void lclExtractColor( sal_uInt8& rnColorIdx, const DffPropSet& rDffPropSet, sal_uInt32 nPropId )
2065 {
2066  if( rDffPropSet.IsProperty( nPropId ) )
2067  {
2068  sal_uInt32 nColor = rDffPropSet.GetPropertyValue( nPropId, 0 );
2069  if( (nColor & 0xFF000000) == 0x08000000 )
2070  rnColorIdx = ::extract_value< sal_uInt8 >( nColor, 0, 8 );
2071  }
2072 }
2073 
2074 } // namespace
2075 
2077 {
2079  lclExtractColor( maFillData.mnBackColorIdx, rDffPropSet, DFF_Prop_fillBackColor );
2080  lclExtractColor( maFillData.mnPattColorIdx, rDffPropSet, DFF_Prop_fillColor );
2082 
2084  lclExtractColor( maLineData.mnColorIdx, rDffPropSet, DFF_Prop_lineColor );
2086 }
2087 
2088 bool XclImpTbxObjBase::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor ) const
2089 {
2091 }
2092 
2094 {
2095  if( maTextData.mxString )
2096  {
2097  const XclFormatRunVec& rFormatRuns = maTextData.mxString->GetFormats();
2098  if( rFormatRuns.empty() )
2100  else
2101  GetFontBuffer().WriteFontProperties( rPropSet, EXC_FONTPROPSET_CONTROL, rFormatRuns.front().mnFontIdx );
2102  }
2103 }
2104 
2106 {
2107  if( maTextData.mxString )
2108  {
2109  OUString aLabel = maTextData.mxString->GetText();
2110  if( maTextData.maData.mnShortcut > 0 )
2111  {
2112  sal_Int32 nPos = aLabel.indexOf( static_cast< sal_Unicode >( maTextData.maData.mnShortcut ) );
2113  if( nPos != -1 )
2114  aLabel = aLabel.replaceAt( nPos, 0, "~" );
2115  }
2116  rPropSet.SetStringProperty( "Label", aLabel );
2117 
2118  //Excel Alt text <==> Aoo description
2119  //For TBX control, if user does not operate alt text, alt text will be set label text as default value in Excel.
2120  //In this case, DFF_Prop_wzDescription will not be set in excel file.
2121  //So In the end of SvxMSDffManager::ImportShape, description will not be set. But actually in excel,
2122  //the alt text is the label value. So here set description as label text first which is called before ImportShape.
2123  Reference< css::beans::XPropertySet > xPropset( mxShape, UNO_QUERY );
2124  try{
2125  if(xPropset.is())
2126  xPropset->setPropertyValue( "Description", makeAny(aLabel) );
2127  }catch( ... )
2128  {
2129  SAL_WARN("sc.filter", "Can't set a default text for TBX Control ");
2130  }
2131  }
2132  ConvertFont( rPropSet );
2133 }
2134 
2136 {
2137  SdrObjectUniquePtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
2138  rDffConv.Progress();
2139  return xSdrObj;
2140 }
2141 
2142 void XclImpTbxObjBase::DoPreProcessSdrObj( XclImpDffConverter& /*rDffConv*/, SdrObject& /*rSdrObj*/ ) const
2143 {
2144  // do not call DoPreProcessSdrObj() from base class (to skip text processing)
2145  ProcessControl( *this );
2146 }
2147 
2149  XclImpTbxObjBase( rRoot )
2150 {
2151 }
2152 
2154 {
2155  // label and text formatting
2156  ConvertLabel( rPropSet );
2157 
2158  /* Horizontal text alignment. For unknown reason, the property type is a
2159  simple sal_Int16 and not a com.sun.star.style.HorizontalAlignment. */
2160  sal_Int16 nHorAlign = 1;
2161  switch( maTextData.maData.GetHorAlign() )
2162  {
2163  case EXC_OBJ_HOR_LEFT: nHorAlign = 0; break;
2164  case EXC_OBJ_HOR_CENTER: nHorAlign = 1; break;
2165  case EXC_OBJ_HOR_RIGHT: nHorAlign = 2; break;
2166  }
2167  rPropSet.SetProperty( "Align", nHorAlign );
2168 
2169  // vertical text alignment
2170  namespace csss = ::com::sun::star::style;
2171  csss::VerticalAlignment eVerAlign = csss::VerticalAlignment_MIDDLE;
2172  switch( maTextData.maData.GetVerAlign() )
2173  {
2174  case EXC_OBJ_VER_TOP: eVerAlign = csss::VerticalAlignment_TOP; break;
2175  case EXC_OBJ_VER_CENTER: eVerAlign = csss::VerticalAlignment_MIDDLE; break;
2176  case EXC_OBJ_VER_BOTTOM: eVerAlign = csss::VerticalAlignment_BOTTOM; break;
2177  }
2178  rPropSet.SetProperty( "VerticalAlign", eVerAlign );
2179 
2180  // always wrap text automatically
2181  rPropSet.SetBoolProperty( "MultiLine", true );
2182 
2183  // default button
2185  rPropSet.SetBoolProperty( "DefaultButton", bDefButton );
2186 
2187  // button type (flags cannot be combined in OOo)
2188  namespace cssa = ::com::sun::star::awt;
2189  cssa::PushButtonType eButtonType = cssa::PushButtonType_STANDARD;
2191  eButtonType = cssa::PushButtonType_OK;
2193  eButtonType = cssa::PushButtonType_CANCEL;
2195  eButtonType = cssa::PushButtonType_HELP;
2196  // property type is short, not enum
2197  rPropSet.SetProperty( "PushButtonType", sal_Int16( eButtonType ) );
2198 }
2199 
2201 {
2202  return "com.sun.star.form.component.CommandButton";
2203 }
2204 
2206 {
2207  return EXC_TBX_EVENT_ACTION;
2208 }
2209 
2211  XclImpTbxObjBase( rRoot ),
2212  mnState( EXC_OBJ_CHECKBOX_UNCHECKED ),
2213  mnCheckBoxFlags( 0 )
2214 {
2215 }
2216 
2217 void XclImpCheckBoxObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2218 {
2219  ReadFrameData( rStrm );
2220  rStrm.Ignore( 10 );
2221  maTextData.maData.mnFlags = rStrm.ReaduInt16();
2222  rStrm.Ignore( 20 );
2223  ReadName5( rStrm, nNameLen );
2224  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2225  ReadCellLinkFormula( rStrm, true );
2227  maTextData.ReadByteString( rStrm );
2228  mnState = rStrm.ReaduInt16();
2231  mnCheckBoxFlags = rStrm.ReaduInt16();
2232 }
2233 
2234 void XclImpCheckBoxObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
2235 {
2236  switch( nSubRecId )
2237  {
2238  case EXC_ID_OBJCBLS:
2239  // do not read EXC_ID_OBJCBLSDATA, not written by OOo Excel export
2240  mnState = rStrm.ReaduInt16();
2241  rStrm.Ignore( 4 );
2244  mnCheckBoxFlags = rStrm.ReaduInt16();
2245  break;
2246  case EXC_ID_OBJCBLSFMLA:
2247  ReadCellLinkFormula( rStrm, false );
2248  break;
2249  default:
2250  XclImpTbxObjBase::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
2251  }
2252 }
2253 
2255 {
2256  // label and text formatting
2257  ConvertLabel( rPropSet );
2258 
2259  // state
2260  bool bSupportsTristate = GetObjType() == EXC_OBJTYPE_CHECKBOX;
2261  sal_Int16 nApiState = 0;
2262  switch( mnState )
2263  {
2264  case EXC_OBJ_CHECKBOX_UNCHECKED: nApiState = 0; break;
2265  case EXC_OBJ_CHECKBOX_CHECKED: nApiState = 1; break;
2266  case EXC_OBJ_CHECKBOX_TRISTATE: nApiState = bSupportsTristate ? 2 : 1; break;
2267  }
2268  if( bSupportsTristate )
2269  rPropSet.SetBoolProperty( "TriState", nApiState == 2 );
2270  rPropSet.SetProperty( "DefaultState", nApiState );
2271 
2272  // box style
2273  namespace AwtVisualEffect = ::com::sun::star::awt::VisualEffect;
2274  sal_Int16 nEffect = ::get_flagvalue( mnCheckBoxFlags, EXC_OBJ_CHECKBOX_FLAT, AwtVisualEffect::FLAT, AwtVisualEffect::LOOK3D );
2275  rPropSet.SetProperty( "VisualEffect", nEffect );
2276 
2277  // do not wrap text automatically
2278  rPropSet.SetBoolProperty( "MultiLine", false );
2279 
2280  // #i40279# always centered vertically
2281  namespace csss = ::com::sun::star::style;
2282  rPropSet.SetProperty( "VerticalAlign", csss::VerticalAlignment_MIDDLE );
2283 
2284  // background color
2285  if( maFillData.IsFilled() )
2286  {
2287  sal_Int32 nColor = static_cast< sal_Int32 >( GetSolidFillColor( maFillData ) );
2288  rPropSet.SetProperty( "BackgroundColor", nColor );
2289  }
2290 }
2291 
2293 {
2294  return "com.sun.star.form.component.CheckBox";
2295 }
2296 
2298 {
2299  return EXC_TBX_EVENT_ACTION;
2300 }
2301 
2303  XclImpCheckBoxObj( rRoot ),
2304  mnNextInGroup( 0 ),
2305  mnFirstInGroup( 1 )
2306 {
2307 }
2308 
2309 void XclImpOptionButtonObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2310 {
2311  ReadFrameData( rStrm );
2312  rStrm.Ignore( 10 );
2313  maTextData.maData.mnFlags = rStrm.ReaduInt16();
2314  rStrm.Ignore( 32 );
2315  ReadName5( rStrm, nNameLen );
2316  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2317  ReadCellLinkFormula( rStrm, true );
2319  maTextData.ReadByteString( rStrm );
2320  mnState = rStrm.ReaduInt16();
2323  mnCheckBoxFlags = rStrm.ReaduInt16();
2324  mnNextInGroup = rStrm.ReaduInt16();
2325  mnFirstInGroup = rStrm.ReaduInt16();
2326 }
2327 
2328 void XclImpOptionButtonObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
2329 {
2330  switch( nSubRecId )
2331  {
2332  case EXC_ID_OBJRBODATA:
2333  mnNextInGroup = rStrm.ReaduInt16();
2334  mnFirstInGroup = rStrm.ReaduInt16();
2335  break;
2336  default:
2337  XclImpCheckBoxObj::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
2338  }
2339 }
2340 
2342 {
2344  // TODO: grouping
2346  if ( pTbxObj && pTbxObj->mnFirstInGroup )
2347  {
2348  // Group has terminated
2349  // traverse each RadioButton in group and
2350  // a) apply the groupname
2351  // b) propagate the linked cell from the lead radiobutton
2352  // c) apply the correct Ref value
2353  XclImpOptionButtonObj* pLeader = pTbxObj;
2354 
2355  sal_Int32 nRefVal = 1;
2356  do
2357  {
2358 
2359  Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( pTbxObj->mxShape );
2360  if ( xCtrlModel.is() )
2361  {
2362  ScfPropertySet aProps( xCtrlModel );
2363  OUString sGroupName = OUString::number( pLeader->GetDffShapeId() );
2364 
2365  aProps.SetStringProperty( "GroupName", sGroupName );
2366  aProps.SetStringProperty( "RefValue", OUString::number( nRefVal++ ) );
2367  if ( pLeader->HasCellLink() && !pTbxObj->HasCellLink() )
2368  {
2369  // propagate cell link info
2370  pTbxObj->mxCellLink = std::make_shared<ScAddress>( *pLeader->mxCellLink );
2371  pTbxObj->ApplySheetLinkProps();
2372  }
2373  pTbxObj = dynamic_cast< XclImpOptionButtonObj* >( GetObjectManager().GetSheetDrawing( GetTab() ).FindDrawObj( pTbxObj->mnNextInGroup ).get() );
2374  }
2375  else
2376  pTbxObj = nullptr;
2377  } while ( pTbxObj && ( pTbxObj->mnFirstInGroup != 1 ) );
2378  }
2379  else
2380  {
2381  // not the leader? try and find it
2382  }
2383 }
2384 
2386 {
2387  return "com.sun.star.form.component.RadioButton";
2388 }
2389 
2391 {
2392  return EXC_TBX_EVENT_ACTION;
2393 }
2394 
2396  XclImpTbxObjBase( rRoot )
2397 {
2398 }
2399 
2401 {
2402  // label and text formatting
2403  ConvertLabel( rPropSet );
2404 
2405  // text alignment (always top/left aligned)
2406  rPropSet.SetProperty( "Align", sal_Int16( 0 ) );
2407  namespace csss = ::com::sun::star::style;
2408  rPropSet.SetProperty( "VerticalAlign", csss::VerticalAlignment_TOP );
2409 
2410  // always wrap text automatically
2411  rPropSet.SetBoolProperty( "MultiLine", true );
2412 }
2413 
2415 {
2416  return "com.sun.star.form.component.FixedText";
2417 }
2418 
2420 {
2421  return EXC_TBX_EVENT_MOUSE;
2422 }
2423 
2425  XclImpTbxObjBase( rRoot ),
2426  mnGroupBoxFlags( 0 )
2427 {
2428 }
2429 
2430 void XclImpGroupBoxObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2431 {
2432  ReadFrameData( rStrm );
2433  rStrm.Ignore( 10 );
2434  maTextData.maData.mnFlags = rStrm.ReaduInt16();
2435  rStrm.Ignore( 26 );
2436  ReadName5( rStrm, nNameLen );
2437  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2439  maTextData.ReadByteString( rStrm );
2442  mnGroupBoxFlags = rStrm.ReaduInt16();
2443 }
2444 
2445 void XclImpGroupBoxObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
2446 {
2447  switch( nSubRecId )
2448  {
2449  case EXC_ID_OBJGBODATA:
2452  mnGroupBoxFlags = rStrm.ReaduInt16();
2453  break;
2454  default:
2455  XclImpTbxObjBase::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
2456  }
2457 }
2458 
2460 {
2461  // label and text formatting
2462  ConvertLabel( rPropSet );
2463 }
2464 
2466 {
2467  return "com.sun.star.form.component.GroupBox";
2468 }
2469 
2471 {
2472  return EXC_TBX_EVENT_MOUSE;
2473 }
2474 
2476  XclImpTbxObjBase( rRoot )
2477 {
2478 }
2479 
2481 {
2482  // label and text formatting
2483  ConvertLabel( rPropSet );
2484 }
2485 
2487 {
2488  // dialog frame faked by a groupbox
2489  return "com.sun.star.form.component.GroupBox";
2490 }
2491 
2493 {
2494  return EXC_TBX_EVENT_MOUSE;
2495 }
2496 
2498  XclImpTbxObjBase( rRoot ),
2499  mnContentType( EXC_OBJ_EDIT_TEXT ),
2500  mnMultiLine( 0 ),
2501  mnScrollBar( 0 ),
2502  mnListBoxObjId( 0 )
2503 {
2504 }
2505 
2507 {
2509 }
2510 
2511 void XclImpEditObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2512 {
2513  ReadFrameData( rStrm );
2514  rStrm.Ignore( 10 );
2515  maTextData.maData.mnFlags = rStrm.ReaduInt16();
2516  rStrm.Ignore( 14 );
2517  ReadName5( rStrm, nNameLen );
2518  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2520  maTextData.ReadByteString( rStrm );
2521  mnContentType = rStrm.ReaduInt16();
2522  mnMultiLine = rStrm.ReaduInt16();
2523  mnScrollBar = rStrm.ReaduInt16();
2524  mnListBoxObjId = rStrm.ReaduInt16();
2525 }
2526 
2527 void XclImpEditObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
2528 {
2529  switch( nSubRecId )
2530  {
2531  case EXC_ID_OBJEDODATA:
2532  mnContentType = rStrm.ReaduInt16();
2533  mnMultiLine = rStrm.ReaduInt16();
2534  mnScrollBar = rStrm.ReaduInt16();
2535  mnListBoxObjId = rStrm.ReaduInt16();
2536  break;
2537  default:
2538  XclImpTbxObjBase::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
2539  }
2540 }
2541 
2543 {
2544  if( maTextData.mxString )
2545  {
2546  OUString aText = maTextData.mxString->GetText();
2547  if( IsNumeric() )
2548  {
2549  // TODO: OUString::toDouble() does not handle local decimal separator
2550  rPropSet.SetProperty( "DefaultValue", aText.toDouble() );
2551  rPropSet.SetBoolProperty( "Spin", mnScrollBar != 0 );
2552  }
2553  else
2554  {
2555  rPropSet.SetProperty( "DefaultText", aText );
2556  rPropSet.SetBoolProperty( "MultiLine", mnMultiLine != 0 );
2557  rPropSet.SetBoolProperty( "VScroll", mnScrollBar != 0 );
2558  }
2559  }
2560  ConvertFont( rPropSet );
2561 }
2562 
2564 {
2565  return IsNumeric() ?
2566  OUString( "com.sun.star.form.component.NumericField" ) :
2567  OUString( "com.sun.star.form.component.TextField" );
2568 }
2569 
2571 {
2572  return EXC_TBX_EVENT_TEXT;
2573 }
2574 
2576  XclImpTbxObjBase( rRoot ),
2577  mnValue( 0 ),
2578  mnMin( 0 ),
2579  mnMax( 100 ),
2580  mnStep( 1 ),
2581  mnPageStep( 10 ),
2582  mnOrient( 0 ),
2583  mnThumbWidth( 1 ),
2584  mnScrollFlags( 0 )
2585 {
2586 }
2587 
2589 {
2590  rStrm.Ignore( 4 );
2591  mnValue = rStrm.ReaduInt16();
2592  mnMin = rStrm.ReaduInt16();
2593  mnMax = rStrm.ReaduInt16();
2594  mnStep = rStrm.ReaduInt16();
2595  mnPageStep = rStrm.ReaduInt16();
2596  mnOrient = rStrm.ReaduInt16();
2597  mnThumbWidth = rStrm.ReaduInt16();
2598  mnScrollFlags = rStrm.ReaduInt16();
2599 }
2600 
2601 void XclImpTbxObjScrollableBase::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
2602 {
2603  switch( nSubRecId )
2604  {
2605  case EXC_ID_OBJSBS:
2606  ReadSbs( rStrm );
2607  break;
2608  case EXC_ID_OBJSBSFMLA:
2609  ReadCellLinkFormula( rStrm, false );
2610  break;
2611  default:
2612  XclImpTbxObjBase::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
2613  }
2614 }
2615 
2618 {
2619 }
2620 
2621 void XclImpSpinButtonObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2622 {
2623  ReadFrameData( rStrm );
2624  ReadSbs( rStrm );
2625  ReadName5( rStrm, nNameLen );
2626  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2627  ReadCellLinkFormula( rStrm, true );
2628 }
2629 
2631 {
2632  // Calc's "Border" property is not the 3D/flat style effect in Excel (#i34712#)
2633  rPropSet.SetProperty( "Border", css::awt::VisualEffect::NONE );
2634  rPropSet.SetProperty< sal_Int32 >( "DefaultSpinValue", mnValue );
2635  rPropSet.SetProperty< sal_Int32 >( "SpinValueMin", mnMin );
2636  rPropSet.SetProperty< sal_Int32 >( "SpinValueMax", mnMax );
2637  rPropSet.SetProperty< sal_Int32 >( "SpinIncrement", mnStep );
2638 
2639  // Excel spin buttons always vertical
2640  rPropSet.SetProperty( "Orientation", css::awt::ScrollBarOrientation::VERTICAL );
2641 }
2642 
2644 {
2645  return "com.sun.star.form.component.SpinButton";
2646 }
2647 
2649 {
2650  return EXC_TBX_EVENT_VALUE;
2651 }
2652 
2655 {
2656 }
2657 
2658 void XclImpScrollBarObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2659 {
2660  ReadFrameData( rStrm );
2661  ReadSbs( rStrm );
2662  ReadName5( rStrm, nNameLen );
2663  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2664  ReadCellLinkFormula( rStrm, true );
2665 }
2666 
2668 {
2669  // Calc's "Border" property is not the 3D/flat style effect in Excel (#i34712#)
2670  rPropSet.SetProperty( "Border", css::awt::VisualEffect::NONE );
2671  rPropSet.SetProperty< sal_Int32 >( "DefaultScrollValue", mnValue );
2672  rPropSet.SetProperty< sal_Int32 >( "ScrollValueMin", mnMin );
2673  rPropSet.SetProperty< sal_Int32 >( "ScrollValueMax", mnMax );
2674  rPropSet.SetProperty< sal_Int32 >( "LineIncrement", mnStep );
2675  rPropSet.SetProperty< sal_Int32 >( "BlockIncrement", mnPageStep );
2676  rPropSet.SetProperty( "VisibleSize", ::std::min< sal_Int32 >( mnPageStep, 1 ) );
2677 
2678  namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
2679  sal_Int32 nApiOrient = ::get_flagvalue( mnOrient, EXC_OBJ_SCROLLBAR_HOR, AwtScrollOrient::HORIZONTAL, AwtScrollOrient::VERTICAL );
2680  rPropSet.SetProperty( "Orientation", nApiOrient );
2681 }
2682 
2684 {
2685  return "com.sun.star.form.component.ScrollBar";
2686 }
2687 
2689 {
2690  return EXC_TBX_EVENT_VALUE;
2691 }
2692 
2694  XclImpTbxObjScrollableBase( rRoot ),
2695  mnEntryCount( 0 ),
2696  mnSelEntry( 0 ),
2697  mnListFlags( 0 ),
2698  mnEditObjId( 0 ),
2699  mbHasDefFontIdx( false )
2700 {
2701 }
2702 
2704 {
2705  ReadSourceRangeFormula( rStrm, true );
2706  mnEntryCount = rStrm.ReaduInt16();
2707  mnSelEntry = rStrm.ReaduInt16();
2708  mnListFlags = rStrm.ReaduInt16();
2709  mnEditObjId = rStrm.ReaduInt16();
2710 }
2711 
2713 {
2714  // border style
2715  namespace AwtVisualEffect = ::com::sun::star::awt::VisualEffect;
2716  sal_Int16 nApiBorder = ::get_flagvalue( mnListFlags, EXC_OBJ_LISTBOX_FLAT, AwtVisualEffect::FLAT, AwtVisualEffect::LOOK3D );
2717  rPropSet.SetProperty( "Border", nApiBorder );
2718 
2719  // font formatting
2720  if( mbHasDefFontIdx )
2722  else
2724 }
2725 
2727  XclImpTbxObjListBase( rRoot )
2728 {
2729 }
2730 
2731 void XclImpListBoxObj::ReadFullLbsData( XclImpStream& rStrm, std::size_t nRecLeft )
2732 {
2733  std::size_t nRecEnd = rStrm.GetRecPos() + nRecLeft;
2734  ReadLbsData( rStrm );
2735  OSL_ENSURE( (rStrm.GetRecPos() == nRecEnd) || (rStrm.GetRecPos() + mnEntryCount == nRecEnd),
2736  "XclImpListBoxObj::ReadFullLbsData - invalid size of OBJLBSDATA record" );
2737  while (rStrm.IsValid())
2738  {
2739  if (rStrm.GetRecPos() >= nRecEnd)
2740  break;
2741  maSelection.push_back( rStrm.ReaduInt8() );
2742  }
2743 }
2744 
2745 void XclImpListBoxObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2746 {
2747  ReadFrameData( rStrm );
2748  ReadSbs( rStrm );
2749  rStrm.Ignore( 18 );
2751  rStrm.Ignore( 4 );
2752  ReadName5( rStrm, nNameLen );
2753  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2754  ReadCellLinkFormula( rStrm, true );
2755  ReadFullLbsData( rStrm, rStrm.GetRecLeft() );
2756  mbHasDefFontIdx = true;
2757 }
2758 
2759 void XclImpListBoxObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
2760 {
2761  switch( nSubRecId )
2762  {
2763  case EXC_ID_OBJLBSDATA:
2764  ReadFullLbsData( rStrm, nSubRecSize );
2765  break;
2766  default:
2767  XclImpTbxObjListBase::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
2768  }
2769 }
2770 
2772 {
2773  // listbox formatting
2774  SetBoxFormatting( rPropSet );
2775 
2776  // selection type
2777  sal_uInt8 nSelType = ::extract_value< sal_uInt8 >( mnListFlags, 4, 2 );
2778  bool bMultiSel = nSelType != EXC_OBJ_LISTBOX_SINGLE;
2779  rPropSet.SetBoolProperty( "MultiSelection", bMultiSel );
2780 
2781  // selection (do not set, if listbox is linked to a cell)
2782  if( HasCellLink() )
2783  return;
2784 
2785  ScfInt16Vec aSelVec;
2786 
2787  // multi selection: API expects sequence of list entry indexes
2788  if( bMultiSel )
2789  {
2790  sal_Int16 nIndex = 0;
2791  for( const auto& rItem : maSelection )
2792  {
2793  if( rItem != 0 )
2794  aSelVec.push_back( nIndex );
2795  ++nIndex;
2796  }
2797  }
2798  // single selection: mnSelEntry is one-based, API expects zero-based
2799  else if( mnSelEntry > 0 )
2800  aSelVec.push_back( static_cast< sal_Int16 >( mnSelEntry - 1 ) );
2801 
2802  if( !aSelVec.empty() )
2803  {
2804  Sequence<sal_Int16> aSelSeq(aSelVec.data(), static_cast<sal_Int32>(aSelVec.size()));
2805  rPropSet.SetProperty( "DefaultSelection", aSelSeq );
2806  }
2807 }
2808 
2810 {
2811  return "com.sun.star.form.component.ListBox";
2812 }
2813 
2815 {
2816  return EXC_TBX_EVENT_CHANGE;
2817 }
2818 
2820  XclImpTbxObjListBase( rRoot ),
2821  mnLeft( 0 ),
2822  mnTop( 0 ),
2823  mnRight( 0 ),
2824  mnBottom( 0 ),
2825  mnDropDownFlags( 0 ),
2826  mnLineCount( 0 ),
2827  mnMinWidth( 0 )
2828 {
2829 }
2830 
2832 {
2833  return ::extract_value< sal_uInt8 >( mnDropDownFlags, 0, 2 );
2834 }
2835 
2837 {
2838  ReadLbsData( rStrm );
2839  mnDropDownFlags = rStrm.ReaduInt16();
2840  mnLineCount = rStrm.ReaduInt16();
2841  mnMinWidth = rStrm.ReaduInt16();
2843  maTextData.ReadByteString( rStrm );
2844  // dropdowns of auto-filters have 'simple' style, they don't have a text area
2846  SetProcessSdrObj( false );
2847 }
2848 
2849 void XclImpDropDownObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 /*nMacroSize*/ )
2850 {
2851  ReadFrameData( rStrm );
2852  ReadSbs( rStrm );
2853  rStrm.Ignore( 18 );
2855  rStrm.Ignore( 14 );
2856  mnLeft = rStrm.ReaduInt16();
2857  mnTop = rStrm.ReaduInt16();
2858  mnRight = rStrm.ReaduInt16();
2859  mnBottom = rStrm.ReaduInt16();
2860  rStrm.Ignore( 4 );
2861  ReadName5( rStrm, nNameLen );
2862  ReadMacro5( rStrm, rStrm.ReaduInt16() ); // first macro size invalid and unused
2863  ReadCellLinkFormula( rStrm, true );
2864  ReadFullLbsData( rStrm );
2865  mbHasDefFontIdx = true;
2866 }
2867 
2868 void XclImpDropDownObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
2869 {
2870  switch( nSubRecId )
2871  {
2872  case EXC_ID_OBJLBSDATA:
2873  ReadFullLbsData( rStrm );
2874  break;
2875  default:
2876  XclImpTbxObjListBase::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
2877  }
2878 }
2879 
2881 {
2882  // dropdown listbox formatting
2883  SetBoxFormatting( rPropSet );
2884  // enable dropdown button
2885  rPropSet.SetBoolProperty( "Dropdown", true );
2886  // dropdown line count
2887  rPropSet.SetProperty( "LineCount", mnLineCount );
2888 
2890  {
2891  // text of editable combobox
2892  if( maTextData.mxString )
2893  rPropSet.SetStringProperty( "DefaultText", maTextData.mxString->GetText() );
2894  }
2895  else
2896  {
2897  // selection (do not set, if dropdown is linked to a cell)
2898  if( !HasCellLink() && (mnSelEntry > 0) )
2899  {
2900  Sequence< sal_Int16 > aSelSeq( 1 );
2901  aSelSeq[ 0 ] = mnSelEntry - 1;
2902  rPropSet.SetProperty( "DefaultSelection", aSelSeq );
2903  }
2904  }
2905 }
2906 
2908 {
2910  OUString( "com.sun.star.form.component.ComboBox" ) :
2911  OUString( "com.sun.star.form.component.ListBox" );
2912 }
2913 
2915 {
2917 }
2918 
2920  XclImpRectObj( rRoot ),
2922  mnStorageId( 0 ),
2923  mnCtlsStrmPos( 0 ),
2924  mnCtlsStrmSize( 0 ),
2925  mbEmbedded( false ),
2926  mbLinked( false ),
2927  mbSymbol( false ),
2928  mbControl( false ),
2929  mbUseCtlsStrm( false )
2930 {
2931  SetAreaObj( true );
2932  SetSimpleMacro( true );
2933  SetCustomDffObj( true );
2934 }
2935 
2937 {
2938  OUStringBuffer aStrgName;
2939  if( (mbEmbedded || mbLinked) && !mbControl && (mnStorageId > 0) )
2940  {
2941  aStrgName = mbEmbedded ? OUStringLiteral(u"" EXC_STORAGE_OLE_EMBEDDED) : OUStringLiteral(u"" EXC_STORAGE_OLE_LINKED);
2942  static const char spcHexChars[] = "0123456789ABCDEF";
2943  for( sal_uInt8 nIndex = 32; nIndex > 0; nIndex -= 4 )
2944  aStrgName.append(OUStringChar( spcHexChars[ ::extract_value< sal_uInt8 >( mnStorageId, nIndex - 4, 4 ) ] ));
2945  }
2946  return aStrgName.makeStringAndClear();
2947 }
2948 
2949 void XclImpPictureObj::DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize )
2950 {
2951  sal_uInt16 nLinkSize;
2952  ReadFrameData( rStrm );
2953  rStrm.Ignore( 6 );
2954  nLinkSize = rStrm.ReaduInt16();
2955  rStrm.Ignore( 2 );
2956  ReadFlags3( rStrm );
2957  ReadMacro3( rStrm, nMacroSize );
2958  ReadPictFmla( rStrm, nLinkSize );
2959 
2960  if( (rStrm.GetNextRecId() == EXC_ID3_IMGDATA) && rStrm.StartNextRecord() )
2962 }
2963 
2964 void XclImpPictureObj::DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize )
2965 {
2966  sal_uInt16 nLinkSize;
2967  ReadFrameData( rStrm );
2968  rStrm.Ignore( 6 );
2969  nLinkSize = rStrm.ReaduInt16();
2970  rStrm.Ignore( 2 );
2971  ReadFlags3( rStrm );
2972  ReadMacro4( rStrm, nMacroSize );
2973  ReadPictFmla( rStrm, nLinkSize );
2974 
2975  if( (rStrm.GetNextRecId() == EXC_ID3_IMGDATA) && rStrm.StartNextRecord() )
2977 }
2978 
2979 void XclImpPictureObj::DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize )
2980 {
2981  sal_uInt16 nLinkSize;
2982  ReadFrameData( rStrm );
2983  rStrm.Ignore( 6 );
2984  nLinkSize = rStrm.ReaduInt16();
2985  rStrm.Ignore( 2 );
2986  ReadFlags3( rStrm );
2987  rStrm.Ignore( 4 );
2988  ReadName5( rStrm, nNameLen );
2989  ReadMacro5( rStrm, nMacroSize );
2990  ReadPictFmla( rStrm, nLinkSize );
2991 
2992  if( (rStrm.GetNextRecId() == EXC_ID3_IMGDATA) && rStrm.StartNextRecord() )
2993  {
2994  // page background is stored as hidden picture with name "__BkgndObj"
2995  if ( IsHidden() && (GetObjName() == "__BkgndObj") )
2996  GetPageSettings().ReadImgData( rStrm );
2997  else
2999  }
3000 }
3001 
3002 void XclImpPictureObj::DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize )
3003 {
3004  switch( nSubRecId )
3005  {
3006  case EXC_ID_OBJFLAGS:
3007  ReadFlags8( rStrm );
3008  break;
3009  case EXC_ID_OBJPICTFMLA:
3010  ReadPictFmla( rStrm, rStrm.ReaduInt16() );
3011  break;
3012  default:
3013  XclImpDrawObjBase::DoReadObj8SubRec( rStrm, nSubRecId, nSubRecSize );
3014  }
3015 }
3016 
3018 {
3019  // try to create an OLE object or form control
3020  SdrObjectUniquePtr xSdrObj( rDffConv.CreateSdrObject( *this, rAnchorRect ) );
3021 
3022  // insert a graphic replacement for unsupported ole object ( if none already
3023  // exists ) Hmm ok, it's possibly that there has been some imported
3024  // graphic at a base level but unlikely, normally controls have a valid
3025  // preview in the IMGDATA record ( see below )
3026  // It might be possible to push such an imported graphic up to this
3027  // XclImpPictureObj instance but there are so many layers of indirection I
3028  // don't see an easy way. This way at least ensures that we can
3029  // avoid a 'blank' shape that can result from a failed control import
3030  if ( !xSdrObj && IsOcxControl() && maGraphic.GetType() == GraphicType::NONE )
3031  {
3032  const_cast< XclImpPictureObj* >( this )->maGraphic =
3034  }
3035  // no OLE - create a plain picture from IMGDATA record data
3036  if( !xSdrObj && (maGraphic.GetType() != GraphicType::NONE) )
3037  {
3038  xSdrObj.reset(
3039  new SdrGrafObj(
3040  *GetDoc().GetDrawLayer(),
3041  maGraphic,
3042  rAnchorRect));
3043  ConvertRectStyle( *xSdrObj );
3044  }
3045 
3046  rDffConv.Progress();
3047  return xSdrObj;
3048 }
3049 
3051 {
3052  if( IsOcxControl() )
3053  {
3054  OUString sName( GetObjectManager().GetOleNameOverride( GetTab(), GetObjId() ) );
3055  if (!sName.isEmpty())
3056  return sName;
3057  }
3059 }
3060 
3062 {
3063  if( IsOcxControl() )
3064  {
3065  // do not call XclImpRectObj::DoPreProcessSdrObj(), it would trace missing "printable" feature
3066  ProcessControl( *this );
3067  }
3068  else if( mbEmbedded || mbLinked )
3069  {
3070  // trace missing "printable" feature
3071  XclImpRectObj::DoPreProcessSdrObj( rDffConv, rSdrObj );
3072 
3073  SfxObjectShell* pDocShell = GetDocShell();
3074  SdrOle2Obj* pOleSdrObj = dynamic_cast< SdrOle2Obj* >( &rSdrObj );
3075  if( pOleSdrObj && pDocShell )
3076  {
3078  Reference< XEmbeddedObject > xEmbObj = pOleSdrObj->GetObjRef();
3079  OUString aOldName( pOleSdrObj->GetPersistName() );
3080 
3081  /* The object persistence should be already in the storage, but
3082  the object still might not be inserted into the container. */
3083  if( rEmbObjCont.HasEmbeddedObject( aOldName ) )
3084  {
3085  if( !rEmbObjCont.HasEmbeddedObject( xEmbObj ) )
3086  // filter code is allowed to call the following method
3087  rEmbObjCont.AddEmbeddedObject( xEmbObj, aOldName );
3088  }
3089  else
3090  {
3091  /* If the object is still not in container it must be inserted
3092  there, the name must be generated in this case. */
3093  OUString aNewName;
3094  rEmbObjCont.InsertEmbeddedObject( xEmbObj, aNewName );
3095  if( aOldName != aNewName )
3096  // SetPersistName, not SetName
3097  pOleSdrObj->SetPersistName( aNewName );
3098  }
3099  }
3100  }
3101 }
3102 
3104 {
3105  sal_uInt16 nFlags;
3106  nFlags = rStrm.ReaduInt16();
3107  mbSymbol = ::get_flag( nFlags, EXC_OBJ_PIC_SYMBOL );
3108 }
3109 
3111 {
3112  sal_uInt16 nFlags;
3113  nFlags = rStrm.ReaduInt16();
3114  mbSymbol = ::get_flag( nFlags, EXC_OBJ_PIC_SYMBOL );
3117  OSL_ENSURE( mbControl || !mbUseCtlsStrm, "XclImpPictureObj::ReadFlags8 - CTLS stream for controls only" );
3119 }
3120 
3121 void XclImpPictureObj::ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nLinkSize )
3122 {
3123  std::size_t nLinkEnd = rStrm.GetRecPos() + nLinkSize;
3124  if( nLinkSize >= 6 )
3125  {
3126  sal_uInt16 nFmlaSize;
3127  nFmlaSize = rStrm.ReaduInt16();
3128  OSL_ENSURE( nFmlaSize > 0, "XclImpPictureObj::ReadPictFmla - missing link formula" );
3129  // BIFF3/BIFF4 do not support storages, nothing to do here
3130  if( (nFmlaSize > 0) && (GetBiff() >= EXC_BIFF5) )
3131  {
3132  rStrm.Ignore( 4 );
3133  sal_uInt8 nToken;
3134  nToken = rStrm.ReaduInt8();
3135 
3136  // different processing for linked vs. embedded OLE objects
3138  {
3139  mbLinked = true;
3140  switch( GetBiff() )
3141  {
3142  case EXC_BIFF5:
3143  {
3144  sal_Int16 nRefIdx;
3145  sal_uInt16 nNameIdx;
3146  nRefIdx = rStrm.ReadInt16();
3147  rStrm.Ignore( 8 );
3148  nNameIdx = rStrm.ReaduInt16();
3149  rStrm.Ignore( 12 );
3150  const ExtName* pExtName = GetOldRoot().pExtNameBuff->GetNameByIndex( nRefIdx, nNameIdx );
3151  if( pExtName && pExtName->IsOLE() )
3152  mnStorageId = pExtName->nStorageId;
3153  }
3154  break;
3155  case EXC_BIFF8:
3156  {
3157  sal_uInt16 nXti, nExtName;
3158  nXti = rStrm.ReaduInt16();
3159  nExtName = rStrm.ReaduInt16();
3160  const XclImpExtName* pExtName = GetLinkManager().GetExternName( nXti, nExtName );
3161  if( pExtName && (pExtName->GetType() == xlExtOLE) )
3162  mnStorageId = pExtName->GetStorageId();
3163  }
3164  break;
3165  default:
3166  DBG_ERROR_BIFF();
3167  }
3168  }
3170  {
3171  mbEmbedded = true;
3172  OSL_ENSURE( nFmlaSize == 5, "XclImpPictureObj::ReadPictFmla - unexpected formula size" );
3173  rStrm.Ignore( nFmlaSize - 1 ); // token ID already read
3174  if( nFmlaSize & 1 )
3175  rStrm.Ignore( 1 ); // padding byte
3176 
3177  // a class name may follow inside the picture link
3178  if( rStrm.GetRecPos() + 2 <= nLinkEnd )
3179  {
3180  sal_uInt16 nLen = rStrm.ReaduInt16();
3181  if( nLen > 0 )
3182  maClassName = (GetBiff() == EXC_BIFF8) ? rStrm.ReadUniString( nLen ) : rStrm.ReadRawByteString( nLen );
3183  }
3184  }
3185  // else: ignore other formulas, e.g. pictures linked to cell ranges
3186  }
3187  }
3188 
3189  // seek behind picture link data
3190  rStrm.Seek( nLinkEnd );
3191 
3192  // read additional data for embedded OLE objects following the picture link
3193  if( IsOcxControl() )
3194  {
3195  // #i26521# form controls to be ignored
3196  if( maClassName == "Forms.HTML:Hidden.1" )
3197  {
3198  SetProcessSdrObj( false );
3199  return;
3200  }
3201 
3202  if( rStrm.GetRecLeft() <= 8 ) return;
3203 
3204  // position and size of control data in 'Ctls' stream
3205  mnCtlsStrmPos = static_cast< std::size_t >( rStrm.ReaduInt32() );
3206  mnCtlsStrmSize = static_cast< std::size_t >( rStrm.ReaduInt32() );
3207 
3208  if( rStrm.GetRecLeft() <= 8 ) return;
3209 
3210  // additional string (16-bit characters), e.g. for progress bar control
3211  sal_uInt32 nAddStrSize;
3212  nAddStrSize = rStrm.ReaduInt32();
3213  OSL_ENSURE( rStrm.GetRecLeft() >= nAddStrSize + 4, "XclImpPictureObj::ReadPictFmla - missing data" );
3214  if( rStrm.GetRecLeft() >= nAddStrSize + 4 )
3215  {
3216  rStrm.Ignore( nAddStrSize );
3217  // cell link and source range
3218  ReadCellLinkFormula( rStrm, true );
3219  ReadSourceRangeFormula( rStrm, true );
3220  }
3221  }
3222  else if( mbEmbedded && (rStrm.GetRecLeft() >= 4) )
3223  {
3224  mnStorageId = rStrm.ReaduInt32();
3225  }
3226 }
3227 
3228 // DFF stream conversion ======================================================
3229 
3230 void XclImpSolverContainer::InsertSdrObjectInfo( SdrObject& rSdrObj, sal_uInt32 nDffShapeId, ShapeFlag nDffFlags )
3231 {
3232  if( nDffShapeId > 0 )
3233  {
3234  maSdrInfoMap[ nDffShapeId ].Set( &rSdrObj, nDffFlags );
3235  maSdrObjMap[ &rSdrObj ] = nDffShapeId;
3236  }
3237 }
3238 
3240 {
3241  // remove info of passed object from the maps
3242  XclImpSdrObjMap::iterator aIt = maSdrObjMap.find( &rSdrObj );
3243  if( aIt != maSdrObjMap.end() )
3244  {
3245  maSdrInfoMap.erase( aIt->second );
3246  maSdrObjMap.erase( aIt );
3247  }
3248 
3249  // remove info of all child objects of a group object
3250  if( SdrObjGroup* pGroupObj = dynamic_cast< SdrObjGroup* >( &rSdrObj ) )
3251  {
3252  if( SdrObjList* pSubList = pGroupObj->GetSubList() )
3253  {
3254  // iterate flat over the list because this function already works recursively
3255  SdrObjListIter aObjIt( pSubList, SdrIterMode::Flat );
3256  for( SdrObject* pChildObj = aObjIt.Next(); pChildObj; pChildObj = aObjIt.Next() )
3257  RemoveSdrObjectInfo( *pChildObj );
3258  }
3259  }
3260 }
3261 
3263 {
3264  for (auto const & pRule : aCList)
3265  {
3266  UpdateConnection( pRule->nShapeA, pRule->pAObj, &pRule->nSpFlagsA );
3267  UpdateConnection( pRule->nShapeB, pRule->pBObj, &pRule->nSpFlagsB );
3268  UpdateConnection( pRule->nShapeC, pRule->pCObj );
3269  }
3270 }
3271 
3273 {
3274  aCList.clear();
3275  maSdrInfoMap.clear();
3276  maSdrObjMap.clear();
3277 }
3278 
3279 void XclImpSolverContainer::UpdateConnection( sal_uInt32 nDffShapeId, SdrObject*& rpSdrObj, ShapeFlag* pnDffFlags )
3280 {
3281  XclImpSdrInfoMap::const_iterator aIt = maSdrInfoMap.find( nDffShapeId );
3282  if( aIt != maSdrInfoMap.end() )
3283  {
3284  rpSdrObj = aIt->second.mpSdrObj;
3285  if( pnDffFlags )
3286  *pnDffFlags = aIt->second.mnDffFlags;
3287  }
3288 }
3289 
3291  SvxMSDffManager( rDffStrm, rRoot.GetBasePath(), 0, nullptr, rRoot.GetDoc().GetDrawLayer(), 1440, COL_DEFAULT, nullptr ),
3292  XclImpRoot( rRoot )
3293 {
3295 }
3296 
3298 {
3299 }
3300 
3301 bool XclImpSimpleDffConverter::GetColorFromPalette( sal_uInt16 nIndex, Color& rColor ) const
3302 {
3303  Color nColor = GetPalette().GetColor( nIndex );
3304 
3305  if( nColor == COL_AUTO )
3306  return false;
3307 
3308  rColor = nColor;
3309  return true;
3310 }
3311 
3313  XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage ) :
3314  mrDrawing( rDrawing ),
3315  mrSdrModel( rSdrModel ),
3316  mrSdrPage( rSdrPage ),
3317  mnLastCtrlIndex( -1 ),
3318  mbHasCtrlForm( false )
3319 {
3320 }
3321 
3322 constexpr OUStringLiteral gaStdFormName( u"Standard" );
3323 
3325  XclImpSimpleDffConverter( rRoot, rDffStrm ),
3326  oox::ole::MSConvertOCXControls( rRoot.GetDocShell()->GetModel() ),
3327  mnOleImpFlags( 0 ),
3328  mbNotifyMacroEventRead(false)
3329 {
3330  const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
3331  if( rFilterOpt.IsMathType2Math() )
3333  if( rFilterOpt.IsWinWord2Writer() )
3335  if( rFilterOpt.IsPowerPoint2Impress() )
3337 
3338  // try to open the 'Ctls' storage stream containing OCX control properties
3340 
3341  // default text margin (convert EMU to drawing layer units)
3344 }
3345 
3347 {
3348 }
3349 
3350 OUString XclImpObjectManager::GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId )
3351 {
3352  OUString sOleName;
3353  OUString sCodeName = GetExtDocOptions().GetCodeName( nTab );
3354 
3355  if (mxOleCtrlNameOverride.is() && mxOleCtrlNameOverride->hasByName(sCodeName))
3356  {
3357  Reference< XIndexContainer > xIdToOleName;
3358  mxOleCtrlNameOverride->getByName( sCodeName ) >>= xIdToOleName;
3359  xIdToOleName->getByIndex( nObjId ) >>= sOleName;
3360  }
3361 
3362  return sOleName;
3363 }
3364 
3365 void XclImpDffConverter::StartProgressBar( std::size_t nProgressSize )
3366 {
3367  mxProgress = std::make_shared<ScfProgressBar>( GetDocShell(), STR_PROGRESS_CALCULATING );
3368  mxProgress->AddSegment( nProgressSize );
3369  mxProgress->Activate();
3370 }
3371 
3372 void XclImpDffConverter::Progress( std::size_t nDelta )
3373 {
3374  OSL_ENSURE( mxProgress, "XclImpDffConverter::Progress - invalid call, no progress bar" );
3375  mxProgress->Progress( nDelta );
3376 }
3377 
3379 {
3380  XclImpDffConvDataRef xConvData = std::make_shared<XclImpDffConvData>( rDrawing, rSdrModel, rSdrPage );
3381  maDataStack.push_back( xConvData );
3382  SetModel( &xConvData->mrSdrModel, 1440 );
3383 }
3384 
3386 {
3387  if( !rDrawObj.IsProcessSdrObj() )
3388  return;
3389 
3390  const XclObjAnchor* pAnchor = rDrawObj.GetAnchor();
3391  if(!pAnchor)
3392  return;
3393 
3394  tools::Rectangle aAnchorRect = GetConvData().mrDrawing.CalcAnchorRect( *pAnchor, false );
3395  if( rDrawObj.IsValidSize( aAnchorRect ) )
3396  {
3397  // CreateSdrObject() recursively creates embedded child objects
3398  SdrObjectUniquePtr xSdrObj( rDrawObj.CreateSdrObject( *this, aAnchorRect, false ) );
3399  if( xSdrObj )
3400  rDrawObj.PreProcessSdrObject( *this, *xSdrObj );
3401  // call InsertSdrObject() also, if SdrObject is missing
3402  InsertSdrObject( rObjList, rDrawObj, xSdrObj.release() );
3403  }
3404 }
3405 
3407 {
3408  SdrPage& rSdrPage = GetConvData().mrSdrPage;
3409  for( const auto& rxDrawObj : rDrawObjs )
3410  ProcessObject( rSdrPage, *rxDrawObj );
3411 }
3412 
3414 {
3415  if( rDffStrm.TellEnd() > 0 )
3416  {
3417  rDffStrm.Seek( STREAM_SEEK_TO_BEGIN );
3418  DffRecordHeader aHeader;
3419  ReadDffRecordHeader( rDffStrm, aHeader );
3420  OSL_ENSURE( aHeader.nRecType == DFF_msofbtDgContainer, "XclImpDffConverter::ProcessDrawing - unexpected record" );
3421  if( aHeader.nRecType == DFF_msofbtDgContainer )
3422  ProcessDgContainer( rDffStrm, aHeader );
3423  }
3424 }
3425 
3427 {
3428  OSL_ENSURE( !maDataStack.empty(), "XclImpDffConverter::FinalizeDrawing - no drawing manager on stack" );
3429  maDataStack.pop_back();
3430  // restore previous model at core DFF converter
3431  if( !maDataStack.empty() )
3432  SetModel( &maDataStack.back()->mrSdrModel, 1440 );
3433 }
3434 
3436 {
3438  return;
3440  mbNotifyMacroEventRead = true;
3441 }
3442 
3444 {
3445  SdrObjectUniquePtr xSdrObj;
3446 
3447  OUString aServiceName = rTbxObj.GetServiceName();
3448  if( SupportsOleObjects() && !aServiceName.isEmpty() ) try
3449  {
3450  // create the form control from scratch
3451  Reference< XFormComponent > xFormComp( ScfApiHelper::CreateInstance( GetDocShell(), aServiceName ), UNO_QUERY_THROW );
3452  // set controls form, needed in virtual function InsertControl()
3453  InitControlForm();
3454  // try to insert the control into the form
3455  css::awt::Size aDummySize;
3456  Reference< XShape > xShape;
3457  XclImpDffConvData& rConvData = GetConvData();
3458  if( rConvData.mxCtrlForm.is() && InsertControl( xFormComp, aDummySize, &xShape, true ) )
3459  {
3460  xSdrObj = rTbxObj.CreateSdrObjectFromShape( xShape, rAnchorRect );
3461  // try to attach a macro to the control
3462  ScriptEventDescriptor aDescriptor;
3463  if( (rConvData.mnLastCtrlIndex >= 0) && rTbxObj.FillMacroDescriptor( aDescriptor ) )
3464  {
3466  Reference< XEventAttacherManager > xEventMgr( rConvData.mxCtrlForm, UNO_QUERY_THROW );
3467  xEventMgr->registerScriptEvent( rConvData.mnLastCtrlIndex, aDescriptor );
3468  }
3469  }
3470  }
3471  catch( const Exception& )
3472  {
3473  }
3474 
3475  return xSdrObj;
3476 }
3477 
3479 {
3480  SdrObjectUniquePtr xSdrObj;
3481 
3482  if( SupportsOleObjects() )
3483  {
3484  if( rPicObj.IsOcxControl() )
3485  {
3486  if( mxCtlsStrm.is() ) try
3487  {
3488  /* set controls form, needed in virtual function InsertControl()
3489  called from ReadOCXExcelKludgeStream() */
3490  InitControlForm();
3491 
3492  // read from mxCtlsStrm into xShape, insert the control model into the form
3493  Reference< XShape > xShape;
3494  if( GetConvData().mxCtrlForm.is() )
3495  {
3496  Reference< XFormComponent > xFComp;
3497  ReadOCXCtlsStream( mxCtlsStrm, xFComp, rPicObj.GetCtlsStreamPos(), rPicObj.GetCtlsStreamSize() );
3498  // recreate the method formerly known as ReadOCXExcelKludgeStream()
3499  if ( xFComp.is() )
3500  {
3501  css::awt::Size aSz; // not used in import
3502  ScfPropertySet aPropSet( xFComp );
3503  aPropSet.SetStringProperty( "Name", rPicObj.GetObjName() );
3504  InsertControl( xFComp, aSz,&xShape,true);
3505  xSdrObj = rPicObj.CreateSdrObjectFromShape( xShape, rAnchorRect );
3506  }
3507  }
3508  }
3509  catch( const Exception& )
3510  {
3511  }
3512  }
3513  else
3514  {
3515  SfxObjectShell* pDocShell = GetDocShell();
3517  OUString aStrgName = rPicObj.GetOleStorageName();
3518  if( pDocShell && xSrcStrg.is() && (!aStrgName.isEmpty()) )
3519  {
3520  // first try to resolve graphic from DFF storage
3521  Graphic aGraphic;
3522  tools::Rectangle aVisArea;
3523  if( !GetBLIP( GetPropertyValue( DFF_Prop_pib, 0 ), aGraphic, &aVisArea ) )
3524  {
3525  // if not found, use graphic from object (imported from IMGDATA record)
3526  aGraphic = rPicObj.GetGraphic();
3527  }
3528  if( aGraphic.GetType() != GraphicType::NONE )
3529  {
3530  ErrCode nError = ERRCODE_NONE;
3531  namespace cssea = ::com::sun::star::embed::Aspects;
3532  sal_Int64 nAspects = rPicObj.IsSymbol() ? cssea::MSOLE_ICON : cssea::MSOLE_CONTENT;
3533  xSdrObj.reset(
3535  GetConvData().mrSdrModel,
3536  aStrgName,
3537  xSrcStrg,
3538  pDocShell->GetStorage(),
3539  aGraphic,
3540  rAnchorRect,
3541  aVisArea,
3542  nullptr,
3543  nError,
3544  mnOleImpFlags,
3545  nAspects,
3546  GetRoot().GetMedium().GetBaseURL()));
3547  }
3548  }
3549  }
3550  }
3551 
3552  return xSdrObj;
3553 }
3554 
3556 {
3558 }
3559 
3560 // virtual functions ----------------------------------------------------------
3561 
3563  DffRecordHeader& rHeader, DffObjData& rObjData )
3564 {
3565  // find the OBJ record data related to the processed shape
3566  XclImpDffConvData& rConvData = GetConvData();
3567  XclImpDrawObjBase* pDrawObj = rConvData.mrDrawing.FindDrawObj( rObjData.rSpHd ).get();
3568  if(!pDrawObj)
3569  return;
3570 
3571  OSL_ENSURE( rHeader.nRecType == DFF_msofbtClientAnchor, "XclImpDffConverter::ProcessClientAnchor2 - no client anchor record" );
3572  XclObjAnchor aAnchor;
3573  rHeader.SeekToContent( rDffStrm );
3574  sal_uInt8 nFlags(0);
3575  rDffStrm.ReadUChar( nFlags );
3576  rDffStrm.SeekRel( 1 ); // flags
3577  rDffStrm >> aAnchor; // anchor format equal to BIFF5 OBJ records
3578 
3579  if (!rDffStrm.good())
3580  {
3581  SAL_WARN("sc.filter", "ProcessClientAnchor2 short read");
3582  return;
3583  }
3584 
3585  pDrawObj->SetAnchor( aAnchor );
3586  rObjData.aChildAnchor = rConvData.mrDrawing.CalcAnchorRect( aAnchor, true );
3587  rObjData.bChildAnchor = true;
3588  // page anchoring is the best approximation we have if mbMove
3589  // is set
3590  rObjData.bPageAnchor = ( nFlags & 0x1 );
3591 }
3592 
3593 namespace {
3594 
3595 struct XclImpDrawObjClientData : public SvxMSDffClientData
3596 {
3597  const XclImpDrawObjBase* m_pTopLevelObj;
3598 
3599  XclImpDrawObjClientData()
3600  : m_pTopLevelObj(nullptr)
3601  {
3602  }
3603  virtual void NotifyFreeObj(SdrObject*) override {}
3604 };
3605 
3606 }
3607 
3609  SvxMSDffClientData& rClientData, tools::Rectangle& /*rTextRect*/, SdrObject* pOldSdrObj )
3610 {
3611  XclImpDffConvData& rConvData = GetConvData();
3612 
3613  /* pOldSdrObj passes a generated SdrObject. This function owns this object
3614  and can modify it. The function has either to return it back to caller
3615  or to delete it by itself. */
3616  SdrObjectUniquePtr xSdrObj( pOldSdrObj );
3617 
3618  // find the OBJ record data related to the processed shape
3619  XclImpDrawObjRef xDrawObj = rConvData.mrDrawing.FindDrawObj( rDffObjData.rSpHd );
3620  const tools::Rectangle& rAnchorRect = rDffObjData.aChildAnchor;
3621 
3622  // Do not process the global page group shape
3623  bool bGlobalPageGroup( rDffObjData.nSpFlags & ShapeFlag::Patriarch );
3624  if( !xDrawObj || !xDrawObj->IsProcessSdrObj() || bGlobalPageGroup )
3625  return nullptr; // simply return, xSdrObj will be destroyed
3626 
3627  /* Pass pointer to top-level object back to caller. If the processed
3628  object is embedded in a group, the pointer is already set to the
3629  top-level parent object. */
3630  XclImpDrawObjClientData& rDrawObjClientData = static_cast<XclImpDrawObjClientData&>(rClientData);
3631  const bool bIsTopLevel = !rDrawObjClientData.m_pTopLevelObj;
3632  if (bIsTopLevel )
3633  rDrawObjClientData.m_pTopLevelObj = xDrawObj.get();
3634 
3635  // connectors don't have to be area objects
3636  if( dynamic_cast< SdrEdgeObj* >( xSdrObj.get() ) )
3637  xDrawObj->SetAreaObj( false );
3638 
3639  /* Check for valid size for all objects. Needed to ignore lots of invisible
3640  phantom objects from deleted rows or columns (for performance reasons).
3641  #i30816# Include objects embedded in groups.
3642  #i58780# Ignore group shapes, size is not initialized. */
3643  bool bEmbeddedGroup = !bIsTopLevel && dynamic_cast< SdrObjGroup* >( xSdrObj.get() );
3644  if( !bEmbeddedGroup && !xDrawObj->IsValidSize( rAnchorRect ) )
3645  return nullptr; // simply return, xSdrObj will be destroyed
3646 
3647  // set shape information from DFF stream
3648  OUString aObjName = GetPropertyString( DFF_Prop_wzName, rDffStrm );
3649  OUString aHyperlink = ReadHlinkProperty( rDffStrm );
3651  bool bAutoMargin = GetPropertyBool( DFF_Prop_AutoTextMargin );
3652  xDrawObj->SetDffData( rDffObjData, aObjName, aHyperlink, bVisible, bAutoMargin );
3653 
3654  /* Connect textbox data (string, alignment, text orientation) to object.
3655  don't ask for a text-ID, DFF export doesn't set one. */
3656  if( XclImpTextObj* pTextObj = dynamic_cast< XclImpTextObj* >( xDrawObj.get() ) )
3657  if( const XclImpObjTextData* pTextData = rConvData.mrDrawing.FindTextData( rDffObjData.rSpHd ) )
3658  pTextObj->SetTextData( *pTextData );
3659 
3660  // copy line and fill formatting of TBX form controls from DFF properties
3661  if( XclImpTbxObjBase* pTbxObj = dynamic_cast< XclImpTbxObjBase* >( xDrawObj.get() ) )
3662  pTbxObj->SetDffProperties( *this );
3663 
3664  // try to create a custom SdrObject that overwrites the passed object
3665  SdrObjectUniquePtr xNewSdrObj( xDrawObj->CreateSdrObject( *this, rAnchorRect, true ) );
3666  if( xNewSdrObj )
3667  xSdrObj = std::move( xNewSdrObj );
3668 
3669  // process the SdrObject
3670  if( xSdrObj )
3671  {
3672  // filled without color -> set system window color
3674  xSdrObj->SetMergedItem( XFillColorItem( EMPTY_OUSTRING, GetPalette().GetColor( EXC_COLOR_WINDOWBACK ) ) );
3675 
3676  // additional processing on the SdrObject
3677  xDrawObj->PreProcessSdrObject( *this, *xSdrObj );
3678 
3679  /* If the SdrObject will not be inserted into the draw page, delete it
3680  here. Happens e.g. for notes: The PreProcessSdrObject() call above
3681  has inserted the note into the document, and the SdrObject is not
3682  needed anymore. */
3683  if( !xDrawObj->IsInsertSdrObj() )
3684  xSdrObj.reset();
3685  }
3686 
3687  if( xSdrObj )
3688  {
3689  /* Store the relation between shape ID and SdrObject for connectors.
3690  Must be done here (and not in InsertSdrObject() function),
3691  otherwise all SdrObjects embedded in groups would be lost. */
3692  rConvData.maSolverCont.InsertSdrObjectInfo( *xSdrObj, xDrawObj->GetDffShapeId(), xDrawObj->GetDffFlags() );
3693 
3694  /* If the drawing object is embedded in a group object, call
3695  PostProcessSdrObject() here. For top-level objects this will be
3696  done automatically in InsertSdrObject() but grouped shapes are
3697  inserted into their groups somewhere in the SvxMSDffManager base
3698  class without chance of notification. Unfortunately, now this is
3699  called before the object is really inserted into its group object,
3700  but that should not have any effect for grouped objects. */
3701  if( !bIsTopLevel )
3702  xDrawObj->PostProcessSdrObject( *this, *xSdrObj );
3703  }
3704 
3705  return xSdrObj.release();
3706 }
3707 
3709 {
3710  XclImpDffConvData& rConvData = GetConvData();
3711 
3712  /* pOldSdrObj passes a generated SdrObject. This function owns this object
3713  and can modify it. The function has either to return it back to caller
3714  or to delete it by itself. */
3715  SdrObjectUniquePtr xSdrObj( pOldSdrObj );
3716 
3717  // find the OBJ record data related to the processed shape
3718  XclImpDrawObjRef xDrawObj = rConvData.mrDrawing.FindDrawObj( rDffObjData.rSpHd );
3719 
3720  if( xSdrObj && xDrawObj )
3721  {
3722  // cell anchoring
3723  if ( !rDffObjData.bPageAnchor )
3724  ScDrawLayer::SetCellAnchoredFromPosition( *xSdrObj, GetDoc(), xDrawObj->GetTab(), false );
3725  }
3726 
3727  return xSdrObj.release();
3728 }
3729 
3730 bool XclImpDffConverter::InsertControl( const Reference< XFormComponent >& rxFormComp,
3731  const css::awt::Size& /*rSize*/, Reference< XShape >* pxShape,
3732  bool /*bFloatingCtrl*/ )
3733 {
3734  if( GetDocShell() ) try
3735  {
3736  XclImpDffConvData& rConvData = GetConvData();
3737  Reference< XIndexContainer > xFormIC( rConvData.mxCtrlForm, UNO_QUERY_THROW );
3738  Reference< XControlModel > xCtrlModel( rxFormComp, UNO_QUERY_THROW );
3739 
3740  // create the control shape
3741  Reference< XShape > xShape( ScfApiHelper::CreateInstance( GetDocShell(), "com.sun.star.drawing.ControlShape" ), UNO_QUERY_THROW );
3742  Reference< XControlShape > xCtrlShape( xShape, UNO_QUERY_THROW );
3743 
3744  // insert the new control into the form
3745  sal_Int32 nNewIndex = xFormIC->getCount();
3746  xFormIC->insertByIndex( nNewIndex, Any( rxFormComp ) );
3747  // on success: store new index of the control for later use (macro events)
3748  rConvData.mnLastCtrlIndex = nNewIndex;
3749 
3750  // set control model at control shape and pass back shape to caller
3751  xCtrlShape->setControl( xCtrlModel );
3752  if( pxShape ) *pxShape = xShape;
3753  return true;
3754  }
3755  catch( const Exception& )
3756  {
3757  OSL_FAIL( "XclImpDffConverter::InsertControl - cannot create form control" );
3758  }
3759 
3760  return false;
3761 }
3762 
3763 // private --------------------------------------------------------------------
3764 
3766 {
3767  OSL_ENSURE( !maDataStack.empty(), "XclImpDffConverter::GetConvData - no drawing manager on stack" );
3768  return *maDataStack.back();
3769 }
3770 
3772 {
3773  OSL_ENSURE( !maDataStack.empty(), "XclImpDffConverter::GetConvData - no drawing manager on stack" );
3774  return *maDataStack.back();
3775 }
3776 
3778 {
3779  /* Reads hyperlink data from a complex DFF property. Contents of this
3780  property are equal to the HLINK record, import of this record is
3781  implemented in class XclImpHyperlink. This function has to create an
3782  instance of the XclImpStream class to be able to reuse the
3783  functionality of XclImpHyperlink. */
3784  OUString aString;
3785  sal_uInt32 nBufferSize = GetPropertyValue( DFF_Prop_pihlShape, 0 );
3786  if( (0 < nBufferSize) && (nBufferSize <= 0xFFFF) && SeekToContent( DFF_Prop_pihlShape, rDffStrm ) )
3787  {
3788  // create a faked BIFF record that can be read by XclImpStream class
3789  SvMemoryStream aMemStream;
3790  aMemStream.WriteUInt16( 0 ).WriteUInt16( nBufferSize );
3791 
3792  // copy from DFF stream to memory stream
3793  ::std::vector< sal_uInt8 > aBuffer( nBufferSize );
3794  sal_uInt8* pnData = aBuffer.data();
3795  if (rDffStrm.ReadBytes(pnData, nBufferSize) == nBufferSize)
3796  {
3797  aMemStream.WriteBytes(pnData, nBufferSize);
3798 
3799  // create BIFF import stream to be able to use XclImpHyperlink class
3800  XclImpStream aXclStrm( aMemStream, GetRoot() );
3801  if( aXclStrm.StartNextRecord() )
3802  aString = XclImpHyperlink::ReadEmbeddedData( aXclStrm );
3803  }
3804  }
3805  return aString;
3806 }
3807 
3809 {
3810  std::size_t nEndPos = rDgHeader.GetRecEndFilePos();
3811  bool isBreak(false);
3812  while (!isBreak && rDffStrm.good() && rDffStrm.Tell() < nEndPos)
3813  {
3814  DffRecordHeader aHeader;
3815  ReadDffRecordHeader( rDffStrm, aHeader );
3816  switch( aHeader.nRecType )
3817  {
3819  isBreak = !ProcessSolverContainer( rDffStrm, aHeader );
3820  break;
3822  isBreak = !ProcessShGrContainer( rDffStrm, aHeader );
3823  break;
3824  default:
3825  isBreak = !aHeader.SeekToEndOfRecord( rDffStrm );
3826  }
3827  }
3828  // seek to end of drawing page container
3829  isBreak = !rDgHeader.SeekToEndOfRecord( rDffStrm );
3830 
3831  // #i12638# #i37900# connector rules
3833  rSolverCont.UpdateConnectorRules();
3834  SolveSolver( rSolverCont );
3835  rSolverCont.RemoveConnectorRules();
3836  return !isBreak;
3837 }
3838 
3840 {
3841  std::size_t nEndPos = rShGrHeader.GetRecEndFilePos();
3842  bool isBreak(false);
3843  while (!isBreak && rDffStrm.good() && rDffStrm.Tell() < nEndPos)
3844  {
3845  DffRecordHeader aHeader;
3846  ReadDffRecordHeader( rDffStrm, aHeader );
3847  switch( aHeader.nRecType )
3848  {
3850  case DFF_msofbtSpContainer:
3851  isBreak = !ProcessShContainer( rDffStrm, aHeader );
3852  break;
3853  default:
3854  isBreak = !aHeader.SeekToEndOfRecord( rDffStrm );
3855  }
3856  }
3857  // seek to end of shape group container
3858  return rShGrHeader.SeekToEndOfRecord( rDffStrm ) && !isBreak;
3859 }
3860 
3862 {
3863  // solver container wants to read the solver container header again
3864  rSolverHeader.SeekToBegOfRecord( rDffStrm );
3865  // read the entire solver container
3866  ReadSvxMSDffSolverContainer( rDffStrm, GetConvData().maSolverCont );
3867  // seek to end of solver container
3868  return rSolverHeader.SeekToEndOfRecord( rDffStrm );
3869 }
3870 
3872 {
3873  rShHeader.SeekToBegOfRecord( rDffStrm );
3874  tools::Rectangle aDummy;
3875  XclImpDrawObjClientData aDrawObjClientData;
3876  /* The call to ImportObj() creates and returns a new SdrObject for the
3877  processed shape. We take ownership of the returned object here. If the
3878  shape is a group object, all embedded objects are created recursively,
3879  and the returned group object contains them all. ImportObj() calls the
3880  virtual functions ProcessClientAnchor2() and ProcessObj() and writes
3881  the pointer to the related draw object data (OBJ record) into aDrawObjClientData. */
3882  SdrObjectUniquePtr xSdrObj( ImportObj( rDffStrm, aDrawObjClientData, aDummy, aDummy, /*nCalledByGroup*/0, /*pShapeId*/nullptr ) );
3883  if (aDrawObjClientData.m_pTopLevelObj && xSdrObj )
3884  InsertSdrObject( GetConvData().mrSdrPage, *aDrawObjClientData.m_pTopLevelObj, xSdrObj.release() );
3885  return rShHeader.SeekToEndOfRecord( rDffStrm );
3886 }
3887 
3889 {
3890  XclImpDffConvData& rConvData = GetConvData();
3891  /* Take ownership of the passed object. If insertion fails (e.g. rDrawObj
3892  states to skip insertion), the object is automatically deleted. */
3893  SdrObjectUniquePtr xSdrObj( pSdrObj );
3894  if( xSdrObj && rDrawObj.IsInsertSdrObj() )
3895  {
3896  rObjList.NbcInsertObject( xSdrObj.release() );
3897  // callback to drawing manager for e.g. tracking of used sheet area
3898  rConvData.mrDrawing.OnObjectInserted( rDrawObj );
3899  // callback to drawing object for post processing (use pSdrObj, xSdrObj already released)
3900  rDrawObj.PostProcessSdrObject( *this, *pSdrObj );
3901  }
3902  /* SdrObject still here? Insertion failed, remove data from shape ID map.
3903  The SdrObject will be destructed then. */
3904  if( xSdrObj )
3905  rConvData.maSolverCont.RemoveSdrObjectInfo( *xSdrObj );
3906 }
3907 
3909 {
3910  XclImpDffConvData& rConvData = GetConvData();
3911  if( rConvData.mbHasCtrlForm )
3912  return;
3913 
3914  rConvData.mbHasCtrlForm = true;
3915  if( !SupportsOleObjects() )
3916  return;
3917 
3918  try
3919  {
3920  Reference< XFormsSupplier > xFormsSupplier( rConvData.mrSdrPage.getUnoPage(), UNO_QUERY_THROW );
3921  Reference< XNameContainer > xFormsNC( xFormsSupplier->getForms(), UNO_SET_THROW );
3922  // find or create the Standard form used to insert the imported controls
3923  if( xFormsNC->hasByName( gaStdFormName ) )
3924  {
3925  xFormsNC->getByName( gaStdFormName ) >>= rConvData.mxCtrlForm;
3926  }
3927  else if( SfxObjectShell* pDocShell = GetDocShell() )
3928  {
3929  rConvData.mxCtrlForm.set( ScfApiHelper::CreateInstance( pDocShell, "com.sun.star.form.component.Form" ), UNO_QUERY_THROW );
3930  xFormsNC->insertByName( gaStdFormName, Any( rConvData.mxCtrlForm ) );
3931  }
3932  }
3933  catch( const Exception& )
3934  {
3935  }
3936 }
3937 
3938 // Drawing manager ============================================================
3939 
3940 XclImpDrawing::XclImpDrawing( const XclImpRoot& rRoot, bool bOleObjects ) :
3941  XclImpRoot( rRoot ),
3942  mbOleObjs( bOleObjects )
3943 {
3944 }
3945 
3947 {
3948 }
3949 
3951 {
3952  Graphic aGraphic;
3953  sal_uInt16 nFormat = rStrm.ReaduInt16();
3954  rStrm.Ignore( 2 );//nEnv
3955  sal_uInt32 nDataSize = rStrm.ReaduInt32();
3956  if( nDataSize <= rStrm.GetRecLeft() )
3957  {
3958  switch( nFormat )
3959  {
3960  case EXC_IMGDATA_WMF: ReadWmf( aGraphic, rStrm ); break;
3961  case EXC_IMGDATA_BMP: ReadBmp( aGraphic, rRoot, rStrm ); break;
3962  default: OSL_FAIL( "XclImpDrawing::ReadImgData - unknown image format" );
3963  }
3964  }
3965  return aGraphic;
3966 }
3967 
3969 {
3970  XclImpDrawObjRef xDrawObj;
3971 
3972  /* #i61786# In BIFF8 streams, OBJ records may occur without MSODRAWING
3973  records. In this case, the OBJ records are in BIFF5 format. Do a sanity
3974  check here that there is no DFF data loaded before. */
3975  OSL_ENSURE( maDffStrm.Tell() == 0, "XclImpDrawing::ReadObj - unexpected DFF stream data, OBJ will be ignored" );
3976  if( maDffStrm.Tell() == 0 ) switch( GetBiff() )
3977  {
3978  case EXC_BIFF3:
3979  xDrawObj = XclImpDrawObjBase::ReadObj3( GetRoot(), rStrm );
3980  break;
3981  case EXC_BIFF4:
3982  xDrawObj = XclImpDrawObjBase::ReadObj4( GetRoot(), rStrm );
3983  break;
3984  case EXC_BIFF5:
3985  case EXC_BIFF8:
3986  xDrawObj = XclImpDrawObjBase::ReadObj5( GetRoot(), rStrm );
3987  break;
3988  default:
3989  DBG_ERROR_BIFF();
3990  }
3991 
3992  if( xDrawObj )
3993  {
3994  // insert into maRawObjs or into the last open group object
3995  maRawObjs.InsertGrouped( xDrawObj );
3996  // to be able to find objects by ID
3997  maObjMapId[ xDrawObj->GetObjId() ] = xDrawObj;
3998  }
3999 }
4000 
4002 {
4004  // disable internal CONTINUE handling
4005  rStrm.ResetRecord( false );
4006  // read leading MSODRAWING record
4007  ReadDffRecord( rStrm );
4008 
4009  // read following drawing records, but do not start following unrelated record
4010  bool bLoop = true;
4011  while( bLoop ) switch( rStrm.GetNextRecId() )
4012  {
4013  case EXC_ID_MSODRAWING:
4014  case EXC_ID_MSODRAWINGSEL:
4015  case EXC_ID_CONT:
4016  rStrm.StartNextRecord();
4017  ReadDffRecord( rStrm );
4018  break;
4019  case EXC_ID_OBJ:
4020  rStrm.StartNextRecord();
4021  ReadObj8( rStrm );
4022  break;
4023  case EXC_ID_TXO:
4024  rStrm.StartNextRecord();
4025  ReadTxo( rStrm );
4026  break;
4027  default:
4028  bLoop = false;
4029  }
4030 
4031  // re-enable internal CONTINUE handling
4032  rStrm.ResetRecord( true );
4033 }
4034 
4036 {
4037  /* maObjMap stores objects by position of the client data (OBJ record) in
4038  the DFF stream, which is always behind shape start position of the
4039  passed header. The function upper_bound() finds the first element in
4040  the map whose key is greater than the start position of the header. Its
4041  end position is used to test whether the found object is really related
4042  to the shape. */
4043  XclImpDrawObjRef xDrawObj;
4044  XclImpObjMap::const_iterator aIt = maObjMap.upper_bound( rHeader.GetRecBegFilePos() );
4045  if( (aIt != maObjMap.end()) && (aIt->first <= rHeader.GetRecEndFilePos()) )
4046  xDrawObj = aIt->second;
4047  return xDrawObj;
4048 }
4049 
4051 {
4052  XclImpDrawObjRef xDrawObj;
4053  XclImpObjMapById::const_iterator aIt = maObjMapId.find( nObjId );
4054  if( aIt != maObjMapId.end() )
4055  xDrawObj = aIt->second;
4056  return xDrawObj;
4057 }
4058 
4060 {
4061  /* maTextMap stores textbox data by position of the client data (TXO
4062  record) in the DFF stream, which is always behind shape start position
4063  of the passed header. The function upper_bound() finds the first
4064  element in the map whose key is greater than the start position of the
4065  header. Its end position is used to test whether the found object is
4066  really related to the shape. */
4067  XclImpObjTextMap::const_iterator aIt = maTextMap.upper_bound( rHeader.GetRecBegFilePos() );
4068  if( (aIt != maTextMap.end()) && (aIt->first <= rHeader.GetRecEndFilePos()) )
4069  return aIt->second.get();
4070  return nullptr;
4071 }
4072 
4073 void XclImpDrawing::SetSkipObj( sal_uInt16 nObjId )
4074 {
4075  maSkipObjs.push_back( nObjId );
4076 }
4077 
4079 {
4080  return std::accumulate(maObjMap.begin(), maObjMap.end(), maRawObjs.GetProgressSize(),
4081  [](const std::size_t& rSum, const XclImpObjMap::value_type& rEntry) { return rSum + rEntry.second->GetProgressSize(); });
4082 }
4083 
4085 {
4086  //rhbz#636521, disable undo during conversion. faster, smaller and stops
4087  //temp objects being inserted into the undo list
4088  bool bOrigUndoStatus = rSdrModel.IsUndoEnabled();
4089  rSdrModel.EnableUndo(false);
4090  // register this drawing manager at the passed (global) DFF manager
4091  rDffConv.InitializeDrawing( *this, rSdrModel, rSdrPage );
4092  // process list of objects to be skipped
4093  for( const auto& rSkipObj : maSkipObjs )
4094  if( XclImpDrawObjBase* pDrawObj = FindDrawObj( rSkipObj ).get() )
4095  pDrawObj->SetProcessSdrObj( false );
4096  // process drawing objects without DFF data
4097  rDffConv.ProcessDrawing( maRawObjs );
4098  // process all objects in the DFF stream
4099  rDffConv.ProcessDrawing( maDffStrm );
4100  // unregister this drawing manager at the passed (global) DFF manager
4101  rDffConv.FinalizeDrawing();
4102  rSdrModel.EnableUndo(bOrigUndoStatus);
4103 }
4104 
4105 // protected ------------------------------------------------------------------
4106 
4108 {
4109  OSL_ENSURE( rxDrawObj, "XclImpDrawing::AppendRawObject - unexpected empty reference" );
4110  maRawObjs.push_back( rxDrawObj );
4111 }
4112 
4113 // private --------------------------------------------------------------------
4114 
4115 void XclImpDrawing::ReadWmf( Graphic& rGraphic, XclImpStream& rStrm ) // static helper
4116 {
4117  // extract graphic data from IMGDATA and following CONTINUE records
4118  rStrm.Ignore( 8 );
4119  SvMemoryStream aMemStrm;
4120  rStrm.CopyToStream( aMemStrm, rStrm.GetRecLeft() );
4121  aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
4122  // import the graphic from memory stream
4123  GDIMetaFile aGDIMetaFile;
4124  if( ::ReadWindowMetafile( aMemStrm, aGDIMetaFile ) )
4125  rGraphic = aGDIMetaFile;
4126 }
4127 
4128 void XclImpDrawing::ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm ) // static helper
4129 {
4130  // extract graphic data from IMGDATA and following CONTINUE records
4131  SvMemoryStream aMemStrm;
4132 
4133  /* Excel 3 and 4 seem to write broken BMP data. Usually they write a
4134  DIBCOREHEADER (12 bytes) containing width, height, planes = 1, and
4135  pixel depth = 32 bit. After that, 3 unused bytes are added before the
4136  actual pixel data. This does even confuse Excel 5 and later, which
4137  cannot read the image data correctly. */
4138  if( rRoot.GetBiff() <= EXC_BIFF4 )
4139  {
4140  rStrm.PushPosition();
4141  sal_uInt32 nHdrSize;
4142  sal_uInt16 nWidth, nHeight, nPlanes, nDepth;
4143  nHdrSize = rStrm.ReaduInt32();
4144  nWidth = rStrm.ReaduInt16();
4145  nHeight = rStrm.ReaduInt16();
4146  nPlanes = rStrm.ReaduInt16();
4147  nDepth = rStrm.ReaduInt16();
4148  if( (nHdrSize == 12) && (nPlanes == 1) && (nDepth == 32) )
4149  {
4150  rStrm.Ignore( 3 );
4151  aMemStrm.SetEndian( SvStreamEndian::LITTLE );
4152  aMemStrm.WriteUInt32( nHdrSize ).WriteUInt16( nWidth ).WriteUInt16( nHeight ).WriteUInt16( nPlanes ).WriteUInt16( nDepth );
4153  rStrm.CopyToStream( aMemStrm, rStrm.GetRecLeft() );
4154  }
4155  rStrm.PopPosition();
4156  }
4157 
4158  // no special handling above -> just copy the remaining record data
4159  if( aMemStrm.Tell() == 0 )
4160  rStrm.CopyToStream( aMemStrm, rStrm.GetRecLeft() );
4161 
4162  // import the graphic from memory stream
4163  aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
4164  Bitmap aBitmap;
4165  if( ReadDIB(aBitmap, aMemStrm, false) ) // read DIB without file header
4166  rGraphic = BitmapEx(aBitmap);
4167 }
4168 
4170 {
4172  rStrm.CopyRecordToStream( maDffStrm );
4173 }
4174 
4176 {
4177  XclImpDrawObjRef xDrawObj = XclImpDrawObjBase::ReadObj8( GetRoot(), rStrm );
4178  // store the new object in the internal containers
4179  maObjMap[ maDffStrm.Tell() ] = xDrawObj;
4180  maObjMapId[ xDrawObj->GetObjId() ] = xDrawObj;
4181 }
4182 
4184 {
4185  XclImpObjTextRef xTextData = std::make_shared<XclImpObjTextData>();
4186  maTextMap[ maDffStrm.Tell() ] = xTextData;
4187 
4188  // 1) read the TXO record
4189  xTextData->maData.ReadTxo8( rStrm );
4190 
4191  // 2) first CONTINUE with string
4192  xTextData->mxString.reset();
4193  bool bValid = true;
4194  if( xTextData->maData.mnTextLen > 0 )
4195  {
4196  bValid = (rStrm.GetNextRecId() == EXC_ID_CONT) && rStrm.StartNextRecord();
4197  OSL_ENSURE( bValid, "XclImpDrawing::ReadTxo - missing CONTINUE record" );
4198  if( bValid )
4199  xTextData->mxString = std::make_shared<XclImpString>( rStrm.ReadUniString( xTextData->maData.mnTextLen ) );
4200  }
4201 
4202  // 3) second CONTINUE with formatting runs
4203  if( xTextData->maData.mnFormatSize > 0 )
4204  {
4205  bValid = (rStrm.GetNextRecId() == EXC_ID_CONT) && rStrm.StartNextRecord();
4206  OSL_ENSURE( bValid, "XclImpDrawing::ReadTxo - missing CONTINUE record" );
4207  if( bValid )
4208  xTextData->ReadFormats( rStrm );
4209  }
4210 }
4211 
4213  XclImpDrawing( rRoot, true ),
4214  maScUsedArea( ScAddress::INITIALIZE_INVALID )
4215 {
4216  maScUsedArea.aStart.SetTab( nScTab );
4217  maScUsedArea.aEnd.SetTab( nScTab );
4218 }
4219 
4221 {
4222  switch( GetBiff() )
4223  {
4224  case EXC_BIFF2:
4225  case EXC_BIFF3:
4226  case EXC_BIFF4:
4227  case EXC_BIFF5:
4228  ReadNote3( rStrm );
4229  break;
4230  case EXC_BIFF8:
4231  ReadNote8( rStrm );
4232  break;
4233  default:
4234  DBG_ERROR_BIFF();
4235  }
4236 }
4237 
4239 {
4241  auto xChartObj = std::make_shared<XclImpChartObj>( GetRoot(), true );
4242  xChartObj->ReadChartSubStream( rStrm );
4243  // insert the chart as raw object without connected DFF data
4244  AppendRawObject( xChartObj );
4245 }
4246 
4248 {
4249  if( SdrModel* pSdrModel = GetDoc().GetDrawLayer() )
4250  if( SdrPage* pSdrPage = GetSdrPage( maScUsedArea.aStart.Tab() ) )
4251  ImplConvertObjects( rDffConv, *pSdrModel, *pSdrPage );
4252 }
4253 
4254 tools::Rectangle XclImpSheetDrawing::CalcAnchorRect( const XclObjAnchor& rAnchor, bool /*bDffAnchor*/ ) const
4255 {
4256  return rAnchor.GetRect( GetRoot(), maScUsedArea.aStart.Tab(), MapUnit::Map100thMM );
4257 }
4258 
4260 {
4261  ScRange aScObjArea = rDrawObj.GetUsedArea( maScUsedArea.aStart.Tab() );
4262  if( aScObjArea.IsValid() )
4263  maScUsedArea.ExtendTo( aScObjArea );
4264 }
4265 
4266 // private --------------------------------------------------------------------
4267 
4269 {
4270  XclAddress aXclPos;
4271  rStrm >> aXclPos;
4272  sal_uInt16 nTotalLen = rStrm.ReaduInt16();
4273 
4274  ScAddress aScNotePos( ScAddress::UNINITIALIZED );
4275  if( !GetAddressConverter().ConvertAddress( aScNotePos, aXclPos, maScUsedArea.aStart.Tab(), true ) )
4276  return;
4277 
4278  sal_uInt16 nPartLen = ::std::min( nTotalLen, static_cast< sal_uInt16 >( rStrm.GetRecLeft() ) );
4279  OUStringBuffer aNoteText(rStrm.ReadRawByteString( nPartLen ));
4280  nTotalLen = nTotalLen - nPartLen;
4281  while (true)
4282  {
4283  if (!nTotalLen)
4284  break;
4285  if (rStrm.GetNextRecId() != EXC_ID_NOTE)
4286  break;
4287  if (!rStrm.StartNextRecord())
4288  break;
4289  rStrm >> aXclPos;
4290  nPartLen = rStrm.ReaduInt16();
4291  OSL_ENSURE( aXclPos.mnRow == 0xFFFF, "XclImpObjectManager::ReadNote3 - missing continuation NOTE record" );
4292  if( aXclPos.mnRow == 0xFFFF )
4293  {
4294  OSL_ENSURE( nPartLen <= nTotalLen, "XclImpObjectManager::ReadNote3 - string too long" );
4295  aNoteText.append(rStrm.ReadRawByteString( nPartLen ));
4296  nTotalLen = nTotalLen - ::std::min( nTotalLen, nPartLen );
4297  }
4298  else
4299  {
4300  // seems to be a new note, record already started -> load the note
4301  rStrm.Seek( EXC_REC_SEEK_TO_BEGIN );
4302  ReadNote( rStrm );
4303  nTotalLen = 0;
4304  }
4305  }
4306  ScNoteUtil::CreateNoteFromString( GetDoc(), aScNotePos, aNoteText.makeStringAndClear(), false, false );
4307 }
4308 
4310 {
4311  XclAddress aXclPos;
4312  sal_uInt16 nFlags, nObjId;
4313  rStrm >> aXclPos;
4314  nFlags = rStrm.ReaduInt16();
4315  nObjId = rStrm.ReaduInt16();
4316 
4317  ScAddress aScNotePos( ScAddress::UNINITIALIZED );
4318  if( GetAddressConverter().ConvertAddress( aScNotePos, aXclPos, maScUsedArea.aStart.Tab(), true ) )
4319  if( nObjId != EXC_OBJ_INVALID_ID )
4320  if( XclImpNoteObj* pNoteObj = dynamic_cast< XclImpNoteObj* >( FindDrawObj( nObjId ).get() ) )
4321  pNoteObj->SetNoteData( aScNotePos, nFlags );
4322 }
4323 
4324 // The object manager =========================================================
4325 
4327  XclImpRoot( rRoot )
4328 {
4329  maDefObjNames[ EXC_OBJTYPE_GROUP ] = "Group";
4330  maDefObjNames[ EXC_OBJTYPE_LINE ] = ScResId( STR_SHAPE_LINE );
4331  maDefObjNames[ EXC_OBJTYPE_RECTANGLE ] = ScResId( STR_SHAPE_RECTANGLE );
4332  maDefObjNames[ EXC_OBJTYPE_OVAL ] = ScResId( STR_SHAPE_OVAL );
4333  maDefObjNames[ EXC_OBJTYPE_ARC ] = "Arc";
4334  maDefObjNames[ EXC_OBJTYPE_CHART ] = "Chart";
4335  maDefObjNames[ EXC_OBJTYPE_TEXT ] = "Text";
4336  maDefObjNames[ EXC_OBJTYPE_BUTTON ] = ScResId( STR_FORM_BUTTON );
4337  maDefObjNames[ EXC_OBJTYPE_PICTURE ] = "Picture";
4338  maDefObjNames[ EXC_OBJTYPE_POLYGON ] = "Freeform";
4339  maDefObjNames[ EXC_OBJTYPE_CHECKBOX ] = ScResId( STR_FORM_CHECKBOX );
4340  maDefObjNames[ EXC_OBJTYPE_OPTIONBUTTON ] = ScResId( STR_FORM_OPTIONBUTTON );
4341  maDefObjNames[ EXC_OBJTYPE_EDIT ] = "Edit Box";
4342  maDefObjNames[ EXC_OBJTYPE_LABEL ] = ScResId( STR_FORM_LABEL );
4343  maDefObjNames[ EXC_OBJTYPE_DIALOG ] = "Dialog Frame";
4344  maDefObjNames[ EXC_OBJTYPE_SPIN ] = ScResId( STR_FORM_SPINNER );
4345  maDefObjNames[ EXC_OBJTYPE_SCROLLBAR ] = ScResId( STR_FORM_SCROLLBAR );
4346  maDefObjNames[ EXC_OBJTYPE_LISTBOX ] = ScResId( STR_FORM_LISTBOX );
4347  maDefObjNames[ EXC_OBJTYPE_GROUPBOX ] = ScResId( STR_FORM_GROUPBOX );
4348  maDefObjNames[ EXC_OBJTYPE_DROPDOWN ] = ScResId( STR_FORM_DROPDOWN );
4349  maDefObjNames[ EXC_OBJTYPE_NOTE ] = "Comment";
4350  maDefObjNames[ EXC_OBJTYPE_DRAWING ] = ScResId( STR_SHAPE_AUTOSHAPE );
4351 }
4352 
4354 {
4355 }
4356 
4358 {
4360  // Excel continues this record with MSODRAWINGGROUP and CONTINUE records, hmm.
4361  rStrm.ResetRecord( true, EXC_ID_MSODRAWINGGROUP );
4363  rStrm.CopyRecordToStream( maDggStrm );
4364 }
4365 
4367 {
4368  XclImpSheetDrawingRef& rxDrawing = maSheetDrawings[ nScTab ];
4369  if( !rxDrawing )
4370  rxDrawing = std::make_shared<XclImpSheetDrawing>( GetRoot(), nScTab );
4371  return *rxDrawing;
4372 }
4373 
4375 {
4376  // do nothing if the document does not contain a drawing layer
4377  if( !GetDoc().GetDrawLayer() )
4378  return;
4379 
4380  // get total progress bar size for all sheet drawing managers
4381  std::size_t nProgressSize = std::accumulate(maSheetDrawings.begin(), maSheetDrawings.end(), std::size_t(0),
4382  [](const std::size_t& rSum, const XclImpSheetDrawingMap::value_type& rEntry) { return rSum + rEntry.second->GetProgressSize(); });
4383  // nothing to do if progress bar is zero (no objects present)
4384  if( nProgressSize == 0 )
4385  return;
4386 
4387  XclImpDffConverter aDffConv( GetRoot(), maDggStrm );
4388  aDffConv.StartProgressBar( nProgressSize );
4389  for( auto& rEntry : maSheetDrawings )
4390  rEntry.second->ConvertObjects( aDffConv );
4391 
4392  // #i112436# don't call ScChartListenerCollection::SetDirty here,
4393  // instead use InterpretDirtyCells in ScDocument::CalcAfterLoad.
4394 }
4395 
4397 {
4398  OUStringBuffer aDefName;
4399  DefObjNameMap::const_iterator aIt = maDefObjNames.find( rDrawObj.GetObjType() );
4400  if( aIt != maDefObjNames.end() )
4401  aDefName.append(aIt->second);
4402  return aDefName.append(' ').append(static_cast<sal_Int32>(rDrawObj.GetObjId())).makeStringAndClear();
4403 }
4404 
4406 {
4407  XclImpSheetDrawingMap::const_iterator aIt = maSheetDrawings.find( nScTab );
4408  if( aIt != maSheetDrawings.end() )
4409  return aIt->second->GetUsedArea();
4411 }
4412 
4413 // DFF property set helper ====================================================
4414 
4416  XclImpRoot( rRoot ),
4417  maDffConv( rRoot, maDummyStrm )
4418 {
4419 }
4420 
4422 {
4423  sal_uInt32 nPropSetSize;
4424 
4425  rStrm.PushPosition();
4426  rStrm.Ignore( 4 );
4427  nPropSetSize = rStrm.ReaduInt32();
4428  rStrm.PopPosition();
4429 
4430  mxMemStrm.reset( new SvMemoryStream );
4431  rStrm.CopyToStream( *mxMemStrm, 8 + nPropSetSize );
4433  maDffConv.ReadPropSet( *mxMemStrm, nullptr );
4434 }
4435 
4436 sal_uInt32 XclImpDffPropSet::GetPropertyValue( sal_uInt16 nPropId ) const
4437 {
4438  return maDffConv.GetPropertyValue( nPropId, 0 );
4439 }
4440 
4442 {
4443  if( mxMemStrm )
4444  maDffConv.ApplyAttributes( *mxMemStrm, rItemSet );
4445 }
4446 
4448 {
4449  rPropSet.Read( rStrm );
4450  return rStrm;
4451 }
4452 
4453 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void StartProgressBar(std::size_t nProgressSize)
Initializes the internal progress bar with the passed size and starts it.
Definition: xiescher.cxx:3365
OUString ReadRawByteString(sal_uInt16 nChars)
Reads nChar byte characters and returns the string.
Definition: xistream.cxx:949
void ProcessObject(SdrObjList &rObjList, XclImpDrawObjBase &rDrawObj)
Processes BIFF5 drawing objects without DFF data, inserts into the passed object list.
Definition: xiescher.cxx:3385
const DffRecordHeader & rSpHd
SdrCircKind
virtual void DoReadObj5(XclImpStream &rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize) override
Reads the contents of the a BIFF5 OBJ record from the passed stream.
Definition: xiescher.cxx:2849
double mfRightMargin
Left margin in inches.
Definition: xlpage.hxx:119
bool is() const
void ConvertLabel(ScfPropertySet &rPropSet) const
Sets control label and text formatting.
Definition: xiescher.cxx:2105
sal_Int32 mnRight
void ReadFullLbsData(XclImpStream &rStrm)
Reads dropdown box settings.
Definition: xiescher.cxx:2836
std::size_t GetProgressSize() const
Returns the needed size on the progress bar for all contained objects.
Definition: xiescher.cxx:992
virtual SdrObjectUniquePtr DoCreateSdrObj(XclImpDffConverter &rDffConv, const tools::Rectangle &rAnchorRect) const override
Creates and returns a new SdrObject from the contained data.
Definition: xiescher.cxx:1049
SdrMetricItem makeSdrTextUpperDistItem(tools::Long mnHeight)
XclImpObjTextData maTextData
Definition: xiescher.hxx:398
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:33
void SetPixelColor(const Color &rColor)
XclImpDropDownObj(const XclImpRoot &rRoot)
Definition: xiescher.cxx:2819
#define DFF_Prop_fLine
void SetPaperSize(sal_uInt16 nXclPaperSize, bool bPortrait)
Overrides paper size and orientation (used in sheet-charts).
Definition: xipage.cxx:188
virtual ~XclImpSimpleDffConverter() override
Definition: xiescher.cxx:3297
OBJ_PATHPOLY
OUString ReadHlinkProperty(SvStream &rDffStrm) const
Reads contents of a hyperlink property and returns the extracted URL.
Definition: xiescher.cxx:3777
static std::unique_ptr< EditTextObject > CreateTextObject(const XclImpRoot &rRoot, const XclImpString &rString)
Returns a new edit engine text object.
Definition: xihelper.cxx:217
XclImpPhObj(const XclImpRoot &rRoot)
Definition: xiescher.cxx:998
bool SupportsOleObjects() const
Returns true, if the conversion of OLE objects is supported.
Definition: xiescher.cxx:3555
#define DFF_Prop_fFilled
SDRTEXTVERTADJUST_TOP
const sal_uInt16 EXC_ID_OBJSBS
Radio button group data.
Definition: xlescher.hxx:215
sal_uInt16 GetNextRecId()
Returns the record ID of the following record.
Definition: xistream.cxx:587
Helper base class for TBX and OCX form controls to manage spreadsheet links.
Definition: xiescher.hxx:457
SdrMetricItem makeSdrShadowYDistItem(tools::Long nDist)
void Seek(std::size_t nPos)
Seeks absolute in record content to the specified position.
Definition: xistream.cxx:781
sal_Int32 nIndex
Drawing manager of a single sheet.
Definition: xiescher.hxx:1110
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
virtual void DoReadObj8SubRec(XclImpStream &rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize) override
Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream.
Definition: xiescher.cxx:2445
const sal_uInt8 EXC_OBJ_LINE_MEDTRANS
Definition: xlescher.hxx:86
bool IsProcessSdrObj() const
Returns true, if the object is valid and will be processed.
Definition: xiescher.hxx:117
A note object, which is a specialized text box object.
Definition: xiescher.hxx:439
const sal_uInt8 EXC_OBJ_LINE_BL
Definition: xlescher.hxx:111
const sal_uInt16 EXC_ID_OBJEND
Definition: xlescher.hxx:206
XclImpButtonObj(const XclImpRoot &rRoot)
Definition: xiescher.cxx:2148
ScAddress aStart
Definition: address.hxx:499
const sal_uInt16 EXC_OBJ_POLY_CLOSED
Definition: xlescher.hxx:149
void SetDffData(const DffObjData &rDffObjData, const OUString &rObjName, const OUString &rHyperlink, bool bVisible, bool bAutoMargin)
Sets shape data from DFF stream.
Definition: xiescher.cxx:381
const sal_uInt16 EXC_OBJ_ORIENT_90CCW
Stacked top to bottom.
Definition: xlescher.hxx:134
bool bVisible
static sal_uInt16 ReadSize(XclImpStream &rStrm)
Reads the size field of the token array.
Definition: xlformula.cxx:741
virtual XclTbxEventType DoGetEventType() const override
Returns the type of the macro event to be created.
Definition: xiescher.cxx:2470
virtual void DoProcessControl(ScfPropertySet &rPropSet) const override
Sets additional properties for the current form control.
Definition: xiescher.cxx:2880
std::size_t GetProgressSize() const
Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function).
Definition: xiescher.cxx:430
void SetBackgroundColor(const Color &rColor)
sal_Int32 mnLeft
XclImpTbxObjBase(const XclImpRoot &rRoot)
Definition: xiescher.cxx:2054
const OUString & GetMacroName() const
Returns associated macro name, if set, otherwise zero length string.
Definition: xiescher.hxx:95
const OUString & GetMacroName(sal_uInt16 nExtSheet, sal_uInt16 nExtName) const
Returns the specified macro name or an empty string on error.
Definition: xilink.cxx:957
bool ReadDIB(Bitmap &rTarget, SvStream &rIStm, bool bFileHeader, bool bMSOFormat)
OBJ_PATHPLIN
const sal_uInt8 EXC_OBJ_ARROW_NARROW
Definition: xlescher.hxx:104
std::size_t GetRecPos() const
Returns the position inside of the whole record content.
Definition: xistream.cxx:564
sal_uInt16 mnFormatSize
Definition: xlescher.hxx:383
#define EMPTY_OUSTRING
Definition: global.hxx:214
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:89
ReturnType get_flagvalue(Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset)
Returns nSet, if at least one bit of nMask is set in nBitField, otherwise nUnset. ...
Definition: ftools.hxx:80
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
sal_uInt32 nShapeId
bool SeekToContent(sal_uInt32 nRecType, SvStream &rSt) const
virtual SfxItemSet CloneAsValue(bool bItems=true, SfxItemPool *pToPool=nullptr) const
virtual SdrObject * FinalizeObj(DffObjData &rDffObjData, SdrObject *pOldSdrObj) override
Finalize a DFF object, sets anchor after nested objs have been loaded.
Definition: xiescher.cxx:3708
virtual void DoReadObj8SubRec(XclImpStream &rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize) override
Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream.
Definition: xiescher.cxx:2328
SvStream & WriteUInt16(sal_uInt16 nUInt16)
static sal_Int32 GetHmmFromInch(double fInches)
Returns the length in 1/100 mm calculated from a length in inches.
Definition: xltools.cxx:297
bool IsMathType2Math() const
static SdrOle2Obj * CreateSdrOLEFromStorage(SdrModel &rSdrModel, const OUString &rStorageName, tools::SvRef< SotStorage > const &rSrcStorage, const css::uno::Reference< css::embed::XStorage > &xDestStg, const Graphic &rGraf, const tools::Rectangle &rBoundRect, const tools::Rectangle &rVisArea, SvStream *pDataStrrm, ErrCode &rError, sal_uInt32 nConvertFlags, sal_Int64 nAspect, OUString const &rBaseURL)
sal_uInt16 GetRecId() const
Returns the current record ID.
Definition: xistream.hxx:353
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
const sal_uInt16 EXC_OBJTYPE_UNKNOWN
Definition: xlescher.hxx:71
SCROW Row() const
Definition: address.hxx:261
virtual tools::Rectangle CalcAnchorRect(const XclObjAnchor &rAnchor, bool bDffAnchor) const =0
Derived classes calculate the resulting rectangle of the passed anchor.
constexpr OUStringLiteral gaStdFormName(u"Standard")
virtual void DoReadObj5(XclImpStream &rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize) override
Reads the contents of the a BIFF5 OBJ record from the passed stream.
Definition: xiescher.cxx:2309
const XclImpRoot & mrRoot
Definition: xiescher.hxx:494
const std::size_t EXC_REC_SEEK_TO_BEGIN
Definition: xlstream.hxx:26
virtual XclTbxEventType DoGetEventType() const override
Returns the type of the macro event to be created.
Definition: xiescher.cxx:2648
virtual void DoPreProcessSdrObj(XclImpDffConverter &rDffConv, SdrObject &rSdrObj) const override
Inserts the contained text data at the passed object.
Definition: xiescher.cxx:1498
sal_uInt16 mnOrient
Definition: xlescher.hxx:387
const sal_uInt16 EXC_OBJ_PIC_CONTROL
Definition: xlescher.hxx:155
sal_uInt8 mnPattern
Definition: xlescher.hxx:369
virtual void DoProcessControl(ScfPropertySet &rPropSet) const override
Sets additional properties for the current form control.
Definition: xiescher.cxx:2480
const sal_uInt16 EXC_ID_NOTE
Definition: xlescher.hxx:38
void FinalizeTabChart()
Calculates the object anchor of a sheet chart (chart fills one page).
Definition: xiescher.cxx:1809
const sal_uInt16 EXC_OBJ_EDIT_INTEGER
Definition: xlescher.hxx:173
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const sal_uInt16 EXC_OBJ_ORIENT_NONE
Definition: xlescher.hxx:132
sal_uInt16 mnRX
Y offset in top row (1/256 of row height).
Definition: xlescher.hxx:287
void SetName(const OUString &rStr, const bool bSetChanged=true)
virtual std::size_t DoGetProgressSize() const override
Returns a progress bar size that takes all group children into account.
Definition: xiescher.cxx:1044
const Color & GetBackgroundColor() const
std::shared_ptr< ScRange > mxSrcRange
Not derived from XclImpRoot to allow multiple inheritance.
Definition: xiescher.hxx:495
const sal_uInt16 EXC_OBJ_PIC_SYMBOL
Definition: xlescher.hxx:154
const sal_uInt8 EXC_TOKCLASS_REF
00-1F: Base tokens.
Definition: xlformula.hxx:43
bool ReadWindowMetafile(SvStream &rStream, GDIMetaFile &rMTF)
virtual void DoPreProcessSdrObj(XclImpDffConverter &rDffConv, SdrObject &rSdrObj) const override
Inserts the note into the document, sets visibility.
Definition: xiescher.cxx:1859
void SetPersistName(const OUString &rPersistName)
virtual void DoProcessControl(ScfPropertySet &rPropSet) const override
Sets additional properties for the current form control.
Definition: xiescher.cxx:2153
const sal_uInt8 EXC_OBJ_ARC_BL
Definition: xlescher.hxx:145
const sal_uInt16 EXC_ID_TXO
Definition: xlescher.hxx:276
constexpr tools::Long Left() const
const sal_uInt16 EXC_OBJ_INVALID_ID
Definition: xlescher.hxx:46
#define DFF_Prop_AutoTextMargin
void setHyperlink(const OUString &sHyperlink)
MSO_Anchor
XclImpSpinButtonObj(const XclImpRoot &rRoot)
Definition: xiescher.cxx:2616
XclImpLineObj(const XclImpRoot &rRoot)
Definition: xiescher.cxx:1062
sal_Int32 GetDefaultTextMargin() const
Returns the default text margin in drawing layer units.
Definition: xiescher.hxx:950
virtual SdrObject * ProcessObj(SvStream &rDffStrm, DffObjData &rDffObjData, SvxMSDffClientData &rClientData, tools::Rectangle &rTextRect, SdrObject *pOldSdrObj) override
Processes a DFF object, reads properties from DFF stream.
Definition: xiescher.cxx:3608
const sal_uInt16 EXC_ID_OBJPICTFMLA
Option flags.
Definition: xlescher.hxx:212
virtual sal_uInt64 TellEnd()
void NotifyMacroEventRead()
Notify that this document contains a macro event handler.
Definition: xiescher.cxx:3435
sal_uInt16 mnContentType
Definition: xiescher.hxx:663
virtual void DoReadObj8SubRec(XclImpStream &rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize) override
Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream.
Definition: xiescher.cxx:1735
XclImpNoteObj(const XclImpRoot &rRoot)
Definition: xiescher.cxx:1843
void RewindRecord()
Sets stream pointer before current record and invalidates stream.
Definition: xistream.cxx:501
static ScMacroInfo * GetMacroInfo(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2634
XclImpObjMap maObjMap
Copy of the DFF page stream in memory.
Definition: xiescher.hxx:1102
void PostProcessSdrObject(XclImpDffConverter &rDffConv, SdrObject &rSdrObj) const
Additional processing for the passed SdrObject after insertion into the drawing page (calls virtual D...
Definition: xiescher.cxx:567
sal_uIntPtr sal_uLong
long Long
XclImpChartObj(const XclImpRoot &rRoot, bool bOwnTab=false)
Definition: xiescher.cxx:1655
sal_uInt16 mnSelEntry
Definition: xiescher.hxx:741
XclImpTextObj(const XclImpRoot &rRoot)
Definition: xiescher.cxx:1447
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
A group object.
Definition: xiescher.hxx:237
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
virtual void NbcInsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
const sal_uInt16 EXC_ID_MSODRAWINGGROUP
Definition: xlescher.