LibreOffice Module sc (master)  1
xeescher.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 <xeescher.hxx>
21 
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/frame/XModel.hpp>
24 #include <com/sun/star/form/FormComponentType.hpp>
25 #include <com/sun/star/awt/VisualEffect.hpp>
26 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
27 #include <com/sun/star/awt/XControlModel.hpp>
28 #include <com/sun/star/drawing/XShape.hpp>
29 #include <com/sun/star/form/binding/XBindableValue.hpp>
30 #include <com/sun/star/form/binding/XListEntrySink.hpp>
31 #include <com/sun/star/awt/Size.hpp>
32 #include <com/sun/star/chart/XChartDocument.hpp>
33 
34 #include <set>
35 #include <vcl/BitmapReadAccess.hxx>
36 #include <svx/svdoole2.hxx>
37 #include <svx/svdocapt.hxx>
38 #include <editeng/outlobj.hxx>
39 #include <unotools/tempfile.hxx>
41 #include <svtools/embedhlp.hxx>
42 
43 #include <unonames.hxx>
44 #include <convuno.hxx>
45 #include <postit.hxx>
46 
47 #include <fapihelper.hxx>
48 #include <xcl97esc.hxx>
49 #include <xechart.hxx>
50 #include <xeformula.hxx>
51 #include <xehelper.hxx>
52 #include <xelink.hxx>
53 #include <xename.hxx>
54 #include <xestyle.hxx>
55 #include <xllink.hxx>
56 #include <xltools.hxx>
57 #include <userdat.hxx>
58 #include <drwlayer.hxx>
59 #include <svl/itemset.hxx>
60 #include <svx/unoapi.hxx>
61 #include <svx/sdtaitm.hxx>
62 #include <document.hxx>
63 #include <svx/xfillit0.hxx>
64 #include <svx/xflclit.hxx>
65 
66 #include <comphelper/sequence.hxx>
67 #include <oox/token/tokens.hxx>
69 #include <oox/export/drawingml.hxx>
71 #include <oox/export/utils.hxx>
72 #include <oox/token/namespaces.hxx>
73 #include <memory>
74 
75 using namespace com::sun::star;
76 using ::com::sun::star::uno::UNO_QUERY;
77 using ::com::sun::star::uno::Reference;
78 using ::com::sun::star::uno::Sequence;
79 using ::com::sun::star::lang::XServiceInfo;
80 using ::com::sun::star::beans::XPropertySet;
81 using ::com::sun::star::drawing::XShape;
82 using ::com::sun::star::drawing::XShapes;
83 using ::com::sun::star::frame::XModel;
84 using ::com::sun::star::awt::XControlModel;
85 using ::com::sun::star::form::binding::XBindableValue;
86 using ::com::sun::star::form::binding::XListEntrySink;
87 using ::com::sun::star::script::ScriptEventDescriptor;
88 using ::com::sun::star::table::CellAddress;
89 using ::com::sun::star::table::CellRangeAddress;
90 using ::oox::drawingml::DrawingML;
91 using ::oox::drawingml::ChartExport;
92 using namespace oox;
93 
94 namespace
95 {
96 
97 const char *ToHorizAlign( SdrTextHorzAdjust eAdjust )
98 {
99  switch( eAdjust )
100  {
102  return "center";
104  return "right";
106  return "justify";
108  default:
109  return "left";
110  }
111 }
112 
113 const char *ToVertAlign( SdrTextVertAdjust eAdjust )
114 {
115  switch( eAdjust )
116  {
118  return "center";
120  return "bottom";
122  return "justify";
124  default:
125  return "top";
126  }
127 }
128 
129 void lcl_WriteAnchorVertex( sax_fastparser::FSHelperPtr const & rComments, const tools::Rectangle &aRect )
130 {
131  rComments->startElement(FSNS(XML_xdr, XML_col));
132  rComments->writeEscaped( OUString::number( aRect.Left() ) );
133  rComments->endElement( FSNS( XML_xdr, XML_col ) );
134  rComments->startElement(FSNS(XML_xdr, XML_colOff));
135  rComments->writeEscaped( OUString::number( aRect.Top() ) );
136  rComments->endElement( FSNS( XML_xdr, XML_colOff ) );
137  rComments->startElement(FSNS(XML_xdr, XML_row));
138  rComments->writeEscaped( OUString::number( aRect.Right() ) );
139  rComments->endElement( FSNS( XML_xdr, XML_row ) );
140  rComments->startElement(FSNS(XML_xdr, XML_rowOff));
141  rComments->writeEscaped( OUString::number( aRect.Bottom() ) );
142  rComments->endElement( FSNS( XML_xdr, XML_rowOff ) );
143 }
144 
145 tools::Long lcl_hmm2output(tools::Long value, bool bInEMU)
146 {
148 }
149 
150 void lcl_GetFromTo( const XclExpRoot& rRoot, const tools::Rectangle &aRect, sal_Int32 nTab, tools::Rectangle &aFrom, tools::Rectangle &aTo, bool bInEMU = false )
151 {
152  sal_Int32 nCol = 0, nRow = 0;
153  sal_Int32 nColOff = 0, nRowOff= 0;
154 
155  const bool bRTL = rRoot.GetDoc().IsNegativePage( nTab );
156  if (!bRTL)
157  {
158  while(true)
159  {
160  tools::Rectangle r = rRoot.GetDoc().GetMMRect( nCol,nRow,nCol,nRow,nTab );
161  if( r.Left() <= aRect.Left() )
162  {
163  nCol++;
164  nColOff = aRect.Left() - r.Left();
165  }
166  if( r.Top() <= aRect.Top() )
167  {
168  nRow++;
169  nRowOff = aRect.Top() - r.Top();
170  }
171  if( r.Left() > aRect.Left() && r.Top() > aRect.Top() )
172  {
173  aFrom = tools::Rectangle( nCol-1, lcl_hmm2output( nColOff, bInEMU ),
174  nRow-1, lcl_hmm2output( nRowOff, bInEMU ) );
175  break;
176  }
177  }
178  }
179  else
180  {
181  while(true)
182  {
183  tools::Rectangle r = rRoot.GetDoc().GetMMRect( nCol,nRow,nCol,nRow,nTab );
184  if( r.Left() >= aRect.Left() )
185  {
186  nCol++;
187  nColOff = r.Left() - aRect.Left();
188  }
189  if( r.Top() <= aRect.Top() )
190  {
191  nRow++;
192  nRowOff = aRect.Top() - r.Top();
193  }
194  if( r.Left() < aRect.Left() && r.Top() > aRect.Top() )
195  {
196  aFrom = tools::Rectangle( nCol-1, lcl_hmm2output( nColOff, bInEMU ),
197  nRow-1, lcl_hmm2output( nRowOff, bInEMU ) );
198  break;
199  }
200  }
201  }
202  if (!bRTL)
203  {
204  while(true)
205  {
206  tools::Rectangle r = rRoot.GetDoc().GetMMRect( nCol,nRow,nCol,nRow,nTab );
207  if( r.Right() < aRect.Right() )
208  nCol++;
209  if( r.Bottom() < aRect.Bottom() )
210  nRow++;
211  if( r.Right() >= aRect.Right() && r.Bottom() >= aRect.Bottom() )
212  {
213  aTo = tools::Rectangle( nCol, lcl_hmm2output( aRect.Right() - r.Left(), bInEMU ),
214  nRow, lcl_hmm2output( aRect.Bottom() - r.Top(), bInEMU ));
215  break;
216  }
217  }
218  }
219  else
220  {
221  while(true)
222  {
223  tools::Rectangle r = rRoot.GetDoc().GetMMRect( nCol,nRow,nCol,nRow,nTab );
224  if( r.Right() >= aRect.Right() )
225  nCol++;
226  if( r.Bottom() < aRect.Bottom() )
227  nRow++;
228  if( r.Right() < aRect.Right() && r.Bottom() >= aRect.Bottom() )
229  {
230  aTo = tools::Rectangle( nCol, lcl_hmm2output( r.Left() - aRect.Right(), bInEMU ),
231  nRow, lcl_hmm2output( aRect.Bottom() - r.Top(), bInEMU ));
232  break;
233  }
234  }
235  }
236 }
237 
238 } // namespace
239 
240 // Escher client anchor =======================================================
241 
242 XclExpDffAnchorBase::XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags ) :
243  XclExpRoot( rRoot ),
244  mnFlags( nFlags )
245 {
246 }
247 
249 {
250  ImplSetFlags( rSdrObj );
251 }
252 
254 {
255  ImplSetFlags( rSdrObj );
256  ImplCalcAnchorRect( rSdrObj.GetCurrentBoundRect(), MapUnit::Map100thMM );
257 }
258 
260 {
261  rEscherEx.AddAtom( 18, ESCHER_ClientAnchor );
262  rEscherEx.GetStream().WriteUInt16( mnFlags );
263  WriteXclObjAnchor( rEscherEx.GetStream(), maAnchor );
264 }
265 
267 {
268  // the passed rectangle is in twips
269  ImplCalcAnchorRect( rRect, MapUnit::MapTwip );
270  WriteDffData( rEscherEx );
271 }
272 
274 {
275  OSL_FAIL( "XclExpDffAnchorBase::ImplSetFlags - not implemented" );
276 }
277 
279 {
280  OSL_FAIL( "XclExpDffAnchorBase::ImplCalcAnchorRect - not implemented" );
281 }
282 
284  XclExpDffAnchorBase( rRoot ),
285  mnScTab( rRoot.GetCurrScTab() )
286 {
287 }
288 
290 {
291  // set flags for cell/page anchoring
292  if ( ScDrawLayer::GetAnchorType( rSdrObj ) == SCA_CELL )
293  mnFlags = 0;
294  else
296 }
297 
299 {
300  maAnchor.SetRect( GetRoot(), mnScTab, rRect, eMapUnit );
301 }
302 
304  const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY ) :
305  XclExpDffAnchorBase( rRoot ),
306  maPageSize( rPageSize ),
307  mnScaleX( nScaleX ),
308  mnScaleY( nScaleY )
309 {
310 }
311 
313 {
314  // TODO (unsupported feature): fixed size
315 }
316 
318 {
319  maAnchor.SetRect( maPageSize, mnScaleX, mnScaleY, rRect, eMapUnit );
320 }
321 
324 {
325  maAnchor.SetRect( rRoot, rRoot.GetCurrScTab(), rRect, MapUnit::Map100thMM );
326 }
327 
330 {
335 }
336 
337 // MSODRAWING* records ========================================================
338 
339 XclExpMsoDrawingBase::XclExpMsoDrawingBase( XclEscherEx& rEscherEx, sal_uInt16 nRecId ) :
340  XclExpRecord( nRecId ),
341  mrEscherEx( rEscherEx ),
342  mnFragmentKey( rEscherEx.InitNextDffFragment() )
343 {
344 }
345 
347 {
349  "XclExpMsoDrawingBase::WriteBody - DFF stream position mismatch" );
351 }
352 
355 {
356  SvStream& rDffStrm = mrEscherEx.GetStream();
357 
358  // write the DGGCONTAINER with some default settings
360 
361  // TODO: stuff the OPT atom with our own document defaults?
362  static const sal_uInt8 spnDffOpt[] = {
363  0xBF, 0x00, 0x08, 0x00, 0x08, 0x00, 0x81, 0x01,
364  0x09, 0x00, 0x00, 0x08, 0xC0, 0x01, 0x40, 0x00,
365  0x00, 0x08
366  };
367  mrEscherEx.AddAtom( sizeof( spnDffOpt ), ESCHER_OPT, 3, 3 );
368  rDffStrm.WriteBytes(spnDffOpt, sizeof(spnDffOpt));
369 
370  // SPLITMENUCOLORS contains colors in toolbar
371  static const sal_uInt8 spnDffSplitMenuColors[] = {
372  0x0D, 0x00, 0x00, 0x08, 0x0C, 0x00, 0x00, 0x08,
373  0x17, 0x00, 0x00, 0x08, 0xF7, 0x00, 0x00, 0x10
374  };
375  mrEscherEx.AddAtom( sizeof( spnDffSplitMenuColors ), ESCHER_SplitMenuColors, 0, 4 );
376  rDffStrm.WriteBytes(spnDffSplitMenuColors, sizeof(spnDffSplitMenuColors));
377 
378  // close the DGGCONTAINER
381 }
382 
385 {
386 }
387 
388 XclExpImgData::XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId ) :
389  maGraphic( rGraphic ),
390  mnRecId( nRecId )
391 {
392 }
393 
395 {
398  aBmp.Convert( BmpConversion::N24Bit );
399 
400  Bitmap::ScopedReadAccess pAccess(aBmp);
401  if( !pAccess )
402  return;
403 
404  sal_Int32 nWidth = ::std::min< sal_Int32 >( pAccess->Width(), 0xFFFF );
405  sal_Int32 nHeight = ::std::min< sal_Int32 >( pAccess->Height(), 0xFFFF );
406  if( (nWidth <= 0) || (nHeight <= 0) )
407  return;
408 
409  sal_uInt8 nPadding = static_cast< sal_uInt8 >( nWidth & 0x03 );
410  sal_uInt32 nTmpSize = static_cast< sal_uInt32 >( (nWidth * 3 + nPadding) * nHeight + 12 );
411 
412  rStrm.StartRecord( mnRecId, nTmpSize + 4 );
413 
414  rStrm << EXC_IMGDATA_BMP // BMP format
415  << EXC_IMGDATA_WIN // Windows
416  << nTmpSize // size after _this_ field
417  << sal_uInt32( 12 ) // BITMAPCOREHEADER size
418  << static_cast< sal_uInt16 >( nWidth ) // width
419  << static_cast< sal_uInt16 >( nHeight ) // height
420  << sal_uInt16( 1 ) // planes
421  << sal_uInt16( 24 ); // bits per pixel
422 
423  for( sal_Int32 nY = nHeight - 1; nY >= 0; --nY )
424  {
425  Scanline pScanline = pAccess->GetScanline( nY );
426  for( sal_Int32 nX = 0; nX < nWidth; ++nX )
427  {
428  const BitmapColor& rBmpColor = pAccess->GetPixelFromData( pScanline, nX );
429  rStrm << rBmpColor.GetBlue() << rBmpColor.GetGreen() << rBmpColor.GetRed();
430  }
431  rStrm.WriteZeroBytes( nPadding );
432  }
433 
434  rStrm.EndRecord();
435 }
436 
438 {
439  sax_fastparser::FSHelperPtr pWorksheet = rStrm.GetCurrentStream();
440 
441  DrawingML aDML(pWorksheet, &rStrm, drawingml::DOCUMENT_XLSX);
442  OUString rId = aDML.WriteImage( maGraphic );
443  pWorksheet->singleElement(XML_picture, FSNS(XML_r, XML_id), rId);
444 }
445 
447  XclExpRoot( rRoot ),
448  mnEntryCount( 0 )
449 {
450 }
451 
453 {
454 }
455 
456 void XclExpControlHelper::ConvertSheetLinks( Reference< XShape > const & xShape )
457 {
458  mxCellLink.reset();
460  mxSrcRange.reset();
461  mnEntryCount = 0;
462 
463  // get control model
464  Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( xShape );
465  if( !xCtrlModel.is() )
466  return;
467 
468  // *** cell link *** ------------------------------------------------------
469 
470  Reference< XBindableValue > xBindable( xCtrlModel, UNO_QUERY );
471  if( xBindable.is() )
472  {
473  Reference< XServiceInfo > xServInfo( xBindable->getValueBinding(), UNO_QUERY );
474  if( xServInfo.is() && xServInfo->supportsService( SC_SERVICENAME_VALBIND ) )
475  {
476  ScfPropertySet aBindProp( xServInfo );
477  CellAddress aApiAddress;
478  if( aBindProp.GetProperty( aApiAddress, SC_UNONAME_BOUNDCELL ) )
479  {
481  if( GetTabInfo().IsExportTab( mxCellLinkAddress.Tab() ) )
483  }
484  }
485  }
486 
487  // *** source range *** ---------------------------------------------------
488 
489  Reference< XListEntrySink > xEntrySink( xCtrlModel, UNO_QUERY );
490  if( !xEntrySink.is() )
491  return;
492 
493  Reference< XServiceInfo > xServInfo( xEntrySink->getListEntrySource(), UNO_QUERY );
494  if( !(xServInfo.is() && xServInfo->supportsService( SC_SERVICENAME_LISTSOURCE )) )
495  return;
496 
497  ScfPropertySet aSinkProp( xServInfo );
498  CellRangeAddress aApiRange;
499  if( aSinkProp.GetProperty( aApiRange, SC_UNONAME_CELLRANGE ) )
500  {
501  ScRange aSrcRange;
502  ScUnoConversion::FillScRange( aSrcRange, aApiRange );
503  if( (aSrcRange.aStart.Tab() == aSrcRange.aEnd.Tab()) && GetTabInfo().IsExportTab( aSrcRange.aStart.Tab() ) )
505  mnEntryCount = static_cast< sal_uInt16 >( aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1 );
506  }
507 }
508 
510 {
511  sal_uInt16 nFmlaSize = rTokArr.GetSize();
512  rStrm << nFmlaSize << sal_uInt32( 0 );
513  rTokArr.WriteArray( rStrm );
514  if( nFmlaSize & 1 ) // pad to 16-bit
515  rStrm << sal_uInt8( 0 );
516 }
517 
518 void XclExpControlHelper::WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId, const XclTokenArray& rTokArr )
519 {
520  rStrm.StartRecord( nSubRecId, (rTokArr.GetSize() + 5) & ~1 );
521  WriteFormula( rStrm, rTokArr );
522  rStrm.EndRecord();
523 }
524 
525 //delete for exporting OCX
526 //#if EXC_EXP_OCX_CTRL
527 
528 XclExpOcxControlObj::XclExpOcxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > const & xShape,
529  const tools::Rectangle* pChildAnchor, const OUString& rClassName, sal_uInt32 nStrmStart, sal_uInt32 nStrmSize ) :
530  XclObj( rObjMgr, EXC_OBJTYPE_PICTURE, true ),
531  XclExpControlHelper( rObjMgr.GetRoot() ),
532  maClassName( rClassName ),
533  mnStrmStart( nStrmStart ),
534  mnStrmSize( nStrmSize )
535 {
536  ScfPropertySet aCtrlProp( XclControlHelper::GetControlModel( xShape ) );
537 
538  // OBJ record flags
539  SetLocked( true );
540  SetPrintable( aCtrlProp.GetBoolProperty( "Printable" ) );
541  SetAutoFill( false );
542  SetAutoLine( false );
543 
544  // fill DFF property set
547  ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor | ShapeFlag::OLEShape );
548  tools::Rectangle aDummyRect;
550  aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 ); // bool field
551  aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x08000040 );
552  aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080000 ); // bool field
553 
554  // #i51348# name of the control, may overwrite shape name
555  OUString aCtrlName;
556  if( aCtrlProp.GetProperty( aCtrlName, "Name" ) && !aCtrlName.isEmpty() )
557  aPropOpt.AddOpt( ESCHER_Prop_wzName, aCtrlName );
558 
559  // meta file
560  //TODO - needs check
561  Reference< XPropertySet > xShapePS( xShape, UNO_QUERY );
562  if( xShapePS.is() && aPropOpt.CreateGraphicProperties( xShapePS, "MetaFile", false ) )
563  {
564  sal_uInt32 nBlipId;
565  if( aPropOpt.GetOpt( ESCHER_Prop_pib, nBlipId ) )
566  aPropOpt.AddOpt( ESCHER_Prop_pictureId, nBlipId );
567  }
568 
569  // write DFF property set to stream
570  aPropOpt.Commit( mrEscherEx.GetStream() );
571 
572  // anchor
573  ImplWriteAnchor( SdrObject::getSdrObjectFromXShape( xShape ), pChildAnchor );
574 
575  mrEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
576  mrEscherEx.CloseContainer(); // ESCHER_SpContainer
578 
579  // spreadsheet links
580  ConvertSheetLinks( xShape );
581 }
582 
584 {
585  // OBJCF - clipboard format
586  rStrm.StartRecord( EXC_ID_OBJCF, 2 );
587  rStrm << sal_uInt16( 2 );
588  rStrm.EndRecord();
589 
590  // OBJFLAGS
591  rStrm.StartRecord( EXC_ID_OBJFLAGS, 2 );
592  rStrm << sal_uInt16( 0x0031 );
593  rStrm.EndRecord();
594 
595  // OBJPICTFMLA
596  XclExpString aClass( maClassName );
597  sal_uInt16 nClassNameSize = static_cast< sal_uInt16 >( aClass.GetSize() );
598  sal_uInt16 nClassNamePad = nClassNameSize & 1;
599  sal_uInt16 nFirstPartSize = 12 + nClassNameSize + nClassNamePad;
600 
601  const XclTokenArray* pCellLink = GetCellLinkTokArr();
602  sal_uInt16 nCellLinkSize = pCellLink ? ((pCellLink->GetSize() + 7) & 0xFFFE) : 0;
603 
604  const XclTokenArray* pSrcRange = GetSourceRangeTokArr();
605  sal_uInt16 nSrcRangeSize = pSrcRange ? ((pSrcRange->GetSize() + 7) & 0xFFFE) : 0;
606 
607  sal_uInt16 nPictFmlaSize = nFirstPartSize + nCellLinkSize + nSrcRangeSize + 18;
608  rStrm.StartRecord( EXC_ID_OBJPICTFMLA, nPictFmlaSize );
609 
610  rStrm << nFirstPartSize // size of first part
611  << sal_uInt16( 5 ) // formula size
612  << sal_uInt32( 0 ) // unknown ID
613  << sal_uInt8( 0x02 ) << sal_uInt32( 0 ) // tTbl token with unknown ID
614  << sal_uInt8( 3 ) // pad to word
615  << aClass; // "Forms.***.1"
616  rStrm.WriteZeroBytes( nClassNamePad ); // pad to word
617  rStrm << mnStrmStart // start in 'Ctls' stream
618  << mnStrmSize // size in 'Ctls' stream
619  << sal_uInt32( 0 ); // class ID size
620  // cell link
621  rStrm << nCellLinkSize;
622  if( pCellLink )
623  WriteFormula( rStrm, *pCellLink );
624  // list source range
625  rStrm << nSrcRangeSize;
626  if( pSrcRange )
627  WriteFormula( rStrm, *pSrcRange );
628 
629  rStrm.EndRecord();
630 }
631 
632 //#else
633 
634 XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rRoot, Reference< XShape > const & xShape , const tools::Rectangle* pChildAnchor ) :
635  XclObj( rRoot, EXC_OBJTYPE_UNKNOWN, true ),
636  XclMacroHelper( rRoot ),
637  mxShape( xShape ),
638  meEventType( EXC_TBX_EVENT_ACTION ),
639  mnHeight( 0 ),
640  mnState( 0 ),
641  mnLineCount( 0 ),
642  mnSelEntry( 0 ),
643  mnScrollValue( 0 ),
644  mnScrollMin( 0 ),
645  mnScrollMax( 100 ),
646  mnScrollStep( 1 ),
647  mnScrollPage( 10 ),
648  mbFlatButton( false ),
649  mbFlatBorder( false ),
650  mbMultiSel( false ),
651  mbScrollHor( false ),
652  mbPrint( false ),
653  mbVisible( false ),
654  mnShapeId( 0 )
655 {
656  namespace FormCompType = css::form::FormComponentType;
657  namespace AwtVisualEffect = css::awt::VisualEffect;
658  namespace AwtScrollOrient = css::awt::ScrollBarOrientation;
659 
660  ScfPropertySet aCtrlProp( XclControlHelper::GetControlModel( xShape ) );
661  if( !xShape.is() || !aCtrlProp.Is() )
662  return;
663 
664  mnHeight = xShape->getSize().Height;
665  if( mnHeight <= 0 )
666  return;
667 
668  // control type
669  sal_Int16 nClassId = 0;
670  if( aCtrlProp.GetProperty( nClassId, "ClassId" ) )
671  {
672  switch( nClassId )
673  {
674  case FormCompType::COMMANDBUTTON: mnObjType = EXC_OBJTYPE_BUTTON; meEventType = EXC_TBX_EVENT_ACTION; break;
675  case FormCompType::RADIOBUTTON: mnObjType = EXC_OBJTYPE_OPTIONBUTTON; meEventType = EXC_TBX_EVENT_ACTION; break;
676  case FormCompType::CHECKBOX: mnObjType = EXC_OBJTYPE_CHECKBOX; meEventType = EXC_TBX_EVENT_ACTION; break;
677  case FormCompType::LISTBOX: mnObjType = EXC_OBJTYPE_LISTBOX; meEventType = EXC_TBX_EVENT_CHANGE; break;
678  case FormCompType::COMBOBOX: mnObjType = EXC_OBJTYPE_DROPDOWN; meEventType = EXC_TBX_EVENT_CHANGE; break;
679  case FormCompType::GROUPBOX: mnObjType = EXC_OBJTYPE_GROUPBOX; meEventType = EXC_TBX_EVENT_MOUSE; break;
680  case FormCompType::FIXEDTEXT: mnObjType = EXC_OBJTYPE_LABEL; meEventType = EXC_TBX_EVENT_MOUSE; break;
681  case FormCompType::SCROLLBAR: mnObjType = EXC_OBJTYPE_SCROLLBAR; meEventType = EXC_TBX_EVENT_VALUE; break;
682  case FormCompType::SPINBUTTON: mnObjType = EXC_OBJTYPE_SPIN; meEventType = EXC_TBX_EVENT_VALUE; break;
683  }
684  }
686  return;
687 
688  // OBJ record flags
689  SetLocked( true );
690  mbPrint = aCtrlProp.GetBoolProperty( "Printable" );
692  SetAutoFill( false );
693  SetAutoLine( false );
694 
695  // fill DFF property set
697  mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty );
698  EscherPropertyContainer aPropOpt;
699  mbVisible = aCtrlProp.GetBoolProperty( "EnableVisible" );
700  aPropOpt.AddOpt( ESCHER_Prop_fPrint, mbVisible ? 0x00080000 : 0x00080002 ); // visible flag
701 
702  aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x01000100 ); // bool field
703  aPropOpt.AddOpt( ESCHER_Prop_lTxid, 0 ); // Text ID
704  aPropOpt.AddOpt( ESCHER_Prop_WrapText, 0x00000001 );
705  aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x001A0008 ); // bool field
706  aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00100000 ); // bool field
707  aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080000 ); // bool field
708 
709  // #i51348# name of the control, may overwrite shape name
710  if( aCtrlProp.GetProperty( msCtrlName, "Name" ) && !msCtrlName.isEmpty() )
711  aPropOpt.AddOpt( ESCHER_Prop_wzName, msCtrlName );
712 
713  //Export description as alt text
714  if( SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape ) )
715  {
716  OUString aAltTxt;
717  OUString aDescrText = pSdrObj->GetDescription();
718  if(!aDescrText.isEmpty())
719  aAltTxt = aDescrText.copy( 0, std::min<sal_Int32>(MSPROP_DESCRIPTION_MAX_LEN, aDescrText.getLength()) );
720  aPropOpt.AddOpt( ESCHER_Prop_wzDescription, aAltTxt );
721  }
722 
723  // write DFF property set to stream
724  aPropOpt.Commit( mrEscherEx.GetStream() );
725 
726  // anchor
727  ImplWriteAnchor( SdrObject::getSdrObjectFromXShape( xShape ), pChildAnchor );
728 
729  mrEscherEx.AddAtom( 0, ESCHER_ClientData ); // OBJ record
731 
732  // control label
733  if( aCtrlProp.GetProperty( msLabel, "Label" ) )
734  {
735  /* Be sure to construct the MSODRAWING record containing the
736  ClientTextbox atom after the base OBJ's MSODRAWING record data is
737  completed. */
739  mrEscherEx.AddAtom( 0, ESCHER_ClientTextbox ); // TXO record
741 
742  sal_uInt16 nXclFont = EXC_FONT_APP;
743  if( !msLabel.isEmpty() )
744  {
745  XclFontData aFontData;
747  if( (!aFontData.maName.isEmpty() ) && (aFontData.mnHeight > 0) )
748  nXclFont = GetFontBuffer().Insert( aFontData, EXC_COLOR_CTRLTEXT );
749  }
750 
751  pTxo.reset( new XclTxo( msLabel, nXclFont ) );
753  pTxo->SetVerAlign( EXC_OBJ_VER_CENTER );
754  }
755 
756  mrEscherEx.CloseContainer(); // ESCHER_SpContainer
757 
758  // other properties
759  aCtrlProp.GetProperty( mnLineCount, "LineCount" );
760 
761  // border style
762  sal_Int16 nApiButton = AwtVisualEffect::LOOK3D;
763  sal_Int16 nApiBorder = AwtVisualEffect::LOOK3D;
764  switch( nClassId )
765  {
766  case FormCompType::LISTBOX:
767  case FormCompType::COMBOBOX:
768  aCtrlProp.GetProperty( nApiBorder, "Border" );
769  break;
770  case FormCompType::CHECKBOX:
771  case FormCompType::RADIOBUTTON:
772  aCtrlProp.GetProperty( nApiButton, "VisualEffect" );
773  nApiBorder = AwtVisualEffect::NONE;
774  break;
775  // Push button cannot be set to flat in Excel
776  case FormCompType::COMMANDBUTTON:
777  nApiBorder = AwtVisualEffect::LOOK3D;
778  break;
779  // Label does not support a border in Excel
780  case FormCompType::FIXEDTEXT:
781  nApiBorder = AwtVisualEffect::NONE;
782  break;
783  /* Scroll bar and spin button have a "Border" property, but it is
784  really used for a border, and not for own 3D/flat look (#i34712#). */
785  case FormCompType::SCROLLBAR:
786  case FormCompType::SPINBUTTON:
787  nApiButton = AwtVisualEffect::LOOK3D;
788  nApiBorder = AwtVisualEffect::NONE;
789  break;
790  // Group box does not support flat style (#i34712#)
791  case FormCompType::GROUPBOX:
792  nApiBorder = AwtVisualEffect::LOOK3D;
793  break;
794  }
795  mbFlatButton = nApiButton != AwtVisualEffect::LOOK3D;
796  mbFlatBorder = nApiBorder != AwtVisualEffect::LOOK3D;
797 
798  // control state
799  sal_Int16 nApiState = 0;
800  if( aCtrlProp.GetProperty( nApiState, "State" ) )
801  {
802  switch( nApiState )
803  {
804  case 0: mnState = EXC_OBJ_CHECKBOX_UNCHECKED; break;
805  case 1: mnState = EXC_OBJ_CHECKBOX_CHECKED; break;
806  case 2: mnState = EXC_OBJ_CHECKBOX_TRISTATE; break;
807  }
808  }
809 
810  // special control contents
811  switch( nClassId )
812  {
813  case FormCompType::LISTBOX:
814  {
815  mbMultiSel = aCtrlProp.GetBoolProperty( "MultiSelection" );
816  Sequence< sal_Int16 > aSelection;
817  if( aCtrlProp.GetProperty( aSelection, "SelectedItems" ) )
818  {
819  if( aSelection.hasElements() )
820  {
821  mnSelEntry = aSelection[ 0 ] + 1;
823  }
824  }
825 
826  // convert listbox with dropdown button to Excel dropdown
827  if( aCtrlProp.GetBoolProperty( "Dropdown" ) )
829  }
830  break;
831 
832  case FormCompType::COMBOBOX:
833  {
835  OUString aDefText;
836  if( aCtrlProp.GetProperty( aStringList, "StringItemList" ) &&
837  aCtrlProp.GetProperty( aDefText, "Text" ) &&
838  aStringList.hasElements() && !aDefText.isEmpty() )
839  {
840  auto nIndex = comphelper::findValue(aStringList, aDefText);
841  if( nIndex != -1 )
842  mnSelEntry = static_cast< sal_Int16 >( nIndex + 1 ); // 1-based
843  if( mnSelEntry > 0 )
844  maMultiSel.resize( 1, mnSelEntry - 1 );
845  }
846 
847  // convert combobox without dropdown button to Excel listbox
848  if( !aCtrlProp.GetBoolProperty( "Dropdown" ) )
850  }
851  break;
852 
853  case FormCompType::SCROLLBAR:
854  {
855  sal_Int32 nApiValue = 0;
856  if( aCtrlProp.GetProperty( nApiValue, "ScrollValueMin" ) )
857  mnScrollMin = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
858  if( aCtrlProp.GetProperty( nApiValue, "ScrollValueMax" ) )
859  mnScrollMax = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, EXC_OBJ_SCROLLBAR_MAX );
860  if( aCtrlProp.GetProperty( nApiValue, "ScrollValue" ) )
861  mnScrollValue = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, mnScrollMax );
862  if( aCtrlProp.GetProperty( nApiValue, "LineIncrement" ) )
863  mnScrollStep = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
864  if( aCtrlProp.GetProperty( nApiValue, "BlockIncrement" ) )
865  mnScrollPage = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
866  if( aCtrlProp.GetProperty( nApiValue, "Orientation" ) )
867  mbScrollHor = nApiValue == AwtScrollOrient::HORIZONTAL;
868  }
869  break;
870 
871  case FormCompType::SPINBUTTON:
872  {
873  sal_Int32 nApiValue = 0;
874  if( aCtrlProp.GetProperty( nApiValue, "SpinValueMin" ) )
875  mnScrollMin = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
876  if( aCtrlProp.GetProperty( nApiValue, "SpinValueMax" ) )
877  mnScrollMax = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, EXC_OBJ_SCROLLBAR_MAX );
878  if( aCtrlProp.GetProperty( nApiValue, "SpinValue" ) )
879  mnScrollValue = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, mnScrollMax );
880  if( aCtrlProp.GetProperty( nApiValue, "SpinIncrement" ) )
881  mnScrollStep = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
882  if( aCtrlProp.GetProperty( nApiValue, "Orientation" ) )
883  mbScrollHor = nApiValue == AwtScrollOrient::HORIZONTAL;
884  }
885  break;
886  }
887 
888  {
889  Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( xShape );
890  if( xCtrlModel.is() )
891  {
892  Reference< XBindableValue > xBindable( xCtrlModel, UNO_QUERY );
893  if( xBindable.is() )
894  {
895  Reference< XServiceInfo > xServInfo( xBindable->getValueBinding(), UNO_QUERY );
896  if( xServInfo.is() && xServInfo->supportsService( SC_SERVICENAME_VALBIND ) )
897  {
898  ScfPropertySet aBindProp( xServInfo );
899  CellAddress aApiAddress;
900  if( aBindProp.GetProperty( aApiAddress, SC_UNONAME_BOUNDCELL ) )
901  {
903  if( SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape ) )
904  lcl_GetFromTo( rRoot, pSdrObj->GetLogicRect(), mxCellLinkAddress.Tab(), maAreaFrom, maAreaTo, true );
905  }
906  }
907  }
908  }
909  }
910 
911  // spreadsheet links
912  ConvertSheetLinks( xShape );
913 }
914 
915 bool XclExpTbxControlObj::SetMacroLink( const ScriptEventDescriptor& rEvent )
916 {
917  return XclMacroHelper::SetMacroLink( rEvent, meEventType );
918 }
919 
921 {
922  switch( mnObjType )
923  {
924  // *** Push buttons, labels ***
925 
926  case EXC_OBJTYPE_BUTTON:
927  case EXC_OBJTYPE_LABEL:
928  // ftMacro - macro link
929  WriteMacroSubRec( rStrm );
930  break;
931 
932  // *** Check boxes, option buttons ***
933 
936  {
937  // ftCbls - box properties
938  sal_uInt16 nStyle = 0;
940 
941  rStrm.StartRecord( EXC_ID_OBJCBLS, 12 );
942  rStrm << mnState;
943  rStrm.WriteZeroBytes( 8 );
944  rStrm << nStyle;
945  rStrm.EndRecord();
946 
947  // ftMacro - macro link
948  WriteMacroSubRec( rStrm );
949  // ftCblsFmla subrecord - cell link
951 
952  // ftCblsData subrecord - box properties, again
953  rStrm.StartRecord( EXC_ID_OBJCBLS, 8 );
954  rStrm << mnState;
955  rStrm.WriteZeroBytes( 4 );
956  rStrm << nStyle;
957  rStrm.EndRecord();
958  }
959  break;
960 
961  // *** List boxes, combo boxes ***
962 
963  case EXC_OBJTYPE_LISTBOX:
965  {
966  sal_uInt16 nEntryCount = GetSourceEntryCount();
967 
968  // ftSbs subrecord - Scroll bars
969  sal_Int32 nLineHeight = XclTools::GetHmmFromTwips( 200 ); // always 10pt
971  mnLineCount = static_cast< sal_uInt16 >( mnHeight / nLineHeight );
972  mnScrollValue = 0;
973  mnScrollMin = 0;
974  sal_uInt16 nInvisLines = (nEntryCount >= mnLineCount) ? (nEntryCount - mnLineCount) : 0;
975  mnScrollMax = limit_cast< sal_uInt16 >( nInvisLines, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
976  mnScrollStep = 1;
978  mbScrollHor = false;
979  WriteSbs( rStrm );
980 
981  // ftMacro - macro link
982  WriteMacroSubRec( rStrm );
983  // ftSbsFmla subrecord - cell link
985 
986  // ftLbsData - source data range and box properties
987  sal_uInt16 nStyle = 0;
990 
991  rStrm.StartRecord( EXC_ID_OBJLBSDATA, 0 );
992 
993  if( const XclTokenArray* pSrcRange = GetSourceRangeTokArr() )
994  {
995  rStrm << static_cast< sal_uInt16 >( (pSrcRange->GetSize() + 7) & 0xFFFE );
996  WriteFormula( rStrm, *pSrcRange );
997  }
998  else
999  rStrm << sal_uInt16( 0 );
1000 
1001  rStrm << nEntryCount << mnSelEntry << nStyle << sal_uInt16( 0 );
1003  {
1004  if( nEntryCount )
1005  {
1006  ScfUInt8Vec aSelEx( nEntryCount, 0 );
1007  for( const auto& rItem : maMultiSel )
1008  if( rItem < nEntryCount )
1009  aSelEx[ rItem ] = 1;
1010  rStrm.Write( aSelEx.data(), aSelEx.size() );
1011  }
1012  }
1013  else if( mnObjType == EXC_OBJTYPE_DROPDOWN )
1014  {
1015  rStrm << sal_uInt16( 0 ) << mnLineCount << sal_uInt16( 0 ) << sal_uInt16( 0 );
1016  }
1017 
1018  rStrm.EndRecord();
1019  }
1020  break;
1021 
1022  // *** Spin buttons, scrollbars ***
1023 
1024  case EXC_OBJTYPE_SPIN:
1025  case EXC_OBJTYPE_SCROLLBAR:
1026  {
1027  // ftSbs subrecord - scroll bars
1028  WriteSbs( rStrm );
1029  // ftMacro - macro link
1030  WriteMacroSubRec( rStrm );
1031  // ftSbsFmla subrecord - cell link
1033  }
1034  break;
1035 
1036  // *** Group boxes ***
1037 
1038  case EXC_OBJTYPE_GROUPBOX:
1039  {
1040  // ftMacro - macro link
1041  WriteMacroSubRec( rStrm );
1042 
1043  // ftGboData subrecord - group box properties
1044  sal_uInt16 nStyle = 0;
1046 
1047  rStrm.StartRecord( EXC_ID_OBJGBODATA, 6 );
1048  rStrm << sal_uInt32( 0 )
1049  << nStyle;
1050  rStrm.EndRecord();
1051  }
1052  break;
1053  }
1054 }
1055 
1056 void XclExpTbxControlObj::WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId )
1057 {
1058  if( const XclTokenArray* pCellLink = GetCellLinkTokArr() )
1059  WriteFormulaSubRec( rStrm, nSubRecId, *pCellLink );
1060 }
1061 
1063 {
1064  sal_uInt16 nOrient = 0;
1066  sal_uInt16 nStyle = EXC_OBJ_SCROLLBAR_DEFFLAGS;
1068 
1069  rStrm.StartRecord( EXC_ID_OBJSBS, 20 );
1070  rStrm << sal_uInt32( 0 ) // reserved
1071  << mnScrollValue // thumb position
1072  << mnScrollMin // thumb min pos
1073  << mnScrollMax // thumb max pos
1074  << mnScrollStep // line increment
1075  << mnScrollPage // page increment
1076  << nOrient // 0 = vertical, 1 = horizontal
1077  << sal_uInt16( 15 ) // thumb width
1078  << nStyle; // flags/style
1079  rStrm.EndRecord();
1080 }
1081 
1082 void XclExpTbxControlObj::setShapeId(sal_Int32 aShapeId)
1083 {
1084  mnShapeId = aShapeId;
1085 }
1086 
1087 // save into xl\drawings\drawing1.xml
1089 {
1090  sax_fastparser::FSHelperPtr& pDrawing = rStrm.GetCurrentStream();
1091 
1092  pDrawing->startElement(FSNS(XML_mc, XML_AlternateContent),
1093  FSNS(XML_xmlns, XML_mc), rStrm.getNamespaceURL(OOX_NS(mce)));
1094  pDrawing->startElement(FSNS(XML_mc, XML_Choice),
1095  FSNS(XML_xmlns, XML_a14), rStrm.getNamespaceURL(OOX_NS(a14)),
1096  XML_Requires, "a14");
1097 
1098  pDrawing->startElement(FSNS(XML_xdr, XML_twoCellAnchor), XML_editAs, "oneCell");
1099  {
1100  pDrawing->startElement(FSNS(XML_xdr, XML_from));
1101  lcl_WriteAnchorVertex(pDrawing, maAreaFrom);
1102  pDrawing->endElement(FSNS(XML_xdr, XML_from));
1103  pDrawing->startElement(FSNS(XML_xdr, XML_to));
1104  lcl_WriteAnchorVertex(pDrawing, maAreaTo);
1105  pDrawing->endElement(FSNS(XML_xdr, XML_to));
1106 
1107  pDrawing->startElement(FSNS(XML_xdr, XML_sp));
1108  {
1109  // xdr:nvSpPr
1110  pDrawing->startElement(FSNS(XML_xdr, XML_nvSpPr));
1111  {
1112  pDrawing->singleElement(FSNS(XML_xdr, XML_cNvPr),
1113  XML_id, OString::number(mnShapeId).getStr(),
1114  XML_name, msCtrlName, // control name
1115  XML_descr, msLabel, // description as alt text
1116  XML_hidden, mbVisible ? "0" : "1");
1117  pDrawing->singleElement(FSNS(XML_xdr, XML_cNvSpPr));
1118  }
1119  pDrawing->endElement(FSNS(XML_xdr, XML_nvSpPr));
1120 
1121  // xdr:spPr
1122  pDrawing->startElement(FSNS(XML_xdr, XML_spPr));
1123  {
1124  // a:xfrm
1125  pDrawing->startElement(FSNS(XML_a, XML_xfrm));
1126  {
1127  pDrawing->singleElement(FSNS(XML_a, XML_off),
1128  XML_x, "0",
1129  XML_y, "0");
1130  pDrawing->singleElement(FSNS(XML_a, XML_ext),
1131  XML_cx, "0",
1132  XML_cy, "0");
1133  }
1134  pDrawing->endElement(FSNS(XML_a, XML_xfrm));
1135 
1136  // a:prstGeom
1137  pDrawing->startElement(FSNS(XML_a, XML_prstGeom), XML_prst, "rect");
1138  {
1139  pDrawing->singleElement(FSNS(XML_a, XML_avLst));
1140  }
1141  pDrawing->endElement(FSNS(XML_a, XML_prstGeom));
1142  }
1143  pDrawing->endElement(FSNS(XML_xdr, XML_spPr));
1144 
1145  // xdr:txBody
1146  {
1147  pDrawing->startElement(FSNS(XML_xdr, XML_txBody));
1148 
1149 #define DEFLRINS 254
1150 #define DEFTBINS 127
1151  sal_Int32 nLeft, nRight, nTop, nBottom;
1152  nLeft = nRight = DEFLRINS;
1153  nTop = nBottom = DEFTBINS;
1154 
1155  // top inset looks a bit different compared to ppt export
1156  // check if something related doesn't work as expected
1157  Reference< XPropertySet > rXPropSet(mxShape, UNO_QUERY);
1158 
1159  try
1160  {
1161  css::uno::Any mAny;
1162 
1163  mAny = rXPropSet->getPropertyValue("TextLeftDistance");
1164  if (mAny.hasValue())
1165  mAny >>= nLeft;
1166 
1167  mAny = rXPropSet->getPropertyValue("TextRightDistance");
1168  if (mAny.hasValue())
1169  mAny >>= nRight;
1170 
1171  mAny = rXPropSet->getPropertyValue("TextUpperDistance");
1172  if (mAny.hasValue())
1173  mAny >>= nTop;
1174 
1175  mAny = rXPropSet->getPropertyValue("TextLowerDistance");
1176  if (mAny.hasValue())
1177  mAny >>= nBottom;
1178  }
1179  catch (...)
1180  {
1181  }
1182 
1183  // Specifies the inset of the bounding rectangle.
1184  // Insets are used just as internal margins for text boxes within shapes.
1185  // If this attribute is omitted, then a value of 45720 or 0.05 inches is implied.
1186  pDrawing->startElementNS(XML_a, XML_bodyPr,
1187  XML_lIns, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeft)), nLeft != DEFLRINS),
1188  XML_rIns, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nRight)), nRight != DEFLRINS),
1189  XML_tIns, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nTop)), nTop != DEFTBINS),
1190  XML_bIns, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nBottom)), nBottom != DEFTBINS),
1191  XML_anchor, "ctr");
1192 
1193  {
1194  bool bTextAutoGrowHeight = false;
1195 
1196  try
1197  {
1198  css::uno::Any mAny;
1199 
1200  mAny = rXPropSet->getPropertyValue("TextAutoGrowHeight");
1201  if (mAny.hasValue())
1202  mAny >>= bTextAutoGrowHeight;
1203  }
1204  catch (...)
1205  {
1206  }
1207 
1208  pDrawing->singleElementNS(XML_a, (bTextAutoGrowHeight ? XML_spAutoFit : XML_noAutofit));
1209  }
1210 
1211  pDrawing->endElementNS(XML_a, XML_bodyPr);
1212 
1213  {
1214  pDrawing->startElementNS(XML_a, XML_p);
1215  pDrawing->startElementNS(XML_a, XML_r);
1216  pDrawing->startElementNS(XML_a, XML_t);
1217  pDrawing->write(msLabel);
1218  pDrawing->endElementNS(XML_a, XML_t);
1219  pDrawing->endElementNS(XML_a, XML_r);
1220  pDrawing->endElementNS(XML_a, XML_p);
1221  }
1222 
1223  pDrawing->endElement(FSNS(XML_xdr, XML_txBody));
1224  }
1225  }
1226  pDrawing->endElement(FSNS(XML_xdr, XML_sp));
1227  pDrawing->singleElement(FSNS(XML_xdr, XML_clientData));
1228  }
1229  pDrawing->endElement(FSNS(XML_xdr, XML_twoCellAnchor));
1230  pDrawing->endElement( FSNS( XML_mc, XML_Choice ) );
1231  pDrawing->endElement( FSNS( XML_mc, XML_AlternateContent ) );
1232 }
1233 
1234 // output into ctrlProp1.xml
1236 {
1237  OUString sIdFormControlPr;
1238 
1239  switch (mnObjType)
1240  {
1241  case EXC_OBJTYPE_CHECKBOX:
1242  {
1243  const sal_Int32 nDrawing = DrawingML::getNewDrawingUniqueId();
1244  sax_fastparser::FSHelperPtr pFormControl = rStrm.CreateOutputStream(
1245  XclXmlUtils::GetStreamName( "xl/", "ctrlProps/ctrlProps", nDrawing ),
1246  XclXmlUtils::GetStreamName( "../", "ctrlProps/ctrlProps", nDrawing ),
1247  rStrm.GetCurrentStream()->getOutputStream(),
1248  "application/vnd.ms-excel.controlproperties+xml",
1249  oox::getRelationship(Relationship::CTRLPROP),
1250  &sIdFormControlPr );
1251 
1252  rStrm.PushStream( pFormControl );
1253  // checkbox
1254  // <formControlPr
1255  // xmlns="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
1256  // objectType="CheckBox" checked="Checked" lockText="1" noThreeD="1"/>
1257  //
1258  pFormControl->write("<formControlPr xmlns=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" objectType=\"CheckBox\"");
1260  pFormControl->write(" checked=\"Checked\"");
1261 
1262  pFormControl->write(" autoLine=\"false\"");
1263 
1264  if (mbPrint)
1265  pFormControl->write(" print=\"true\"");
1266  else
1267  pFormControl->write(" print=\"false\"");
1268 
1269  if (mxCellLinkAddress.IsValid())
1270  {
1271  OUString aCellLink = mxCellLinkAddress.Format(ScRefFlags::ADDR_ABS,
1272  &GetDoc(),
1274 
1275  // "Sheet1!$C$5"
1276  pFormControl->write(" fmlaLink=\"");
1277  if (aCellLink.indexOf('!') < 0)
1278  {
1279  pFormControl->write(GetTabInfo().GetScTabName(mxCellLinkAddress.Tab()));
1280  pFormControl->write("!");
1281  }
1282  pFormControl->write(aCellLink);
1283  pFormControl->write("\"");
1284  }
1285 
1286  pFormControl->write(" lockText=\"1\" noThreeD=\"1\"/>");
1287  rStrm.PopStream();
1288 
1289  break;
1290  }
1291  }
1292 
1293  return sIdFormControlPr;
1294 }
1295 
1296 // output into sheet1.xml
1297 void XclExpTbxControlObj::SaveSheetXml(XclExpXmlStream& rStrm, const OUString& aIdFormControlPr) const
1298 {
1299  switch (mnObjType)
1300  {
1301  case EXC_OBJTYPE_CHECKBOX:
1302  {
1303  sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
1304 
1305  rWorksheet->startElement(FSNS(XML_mc, XML_AlternateContent),
1306  FSNS(XML_xmlns, XML_mc), rStrm.getNamespaceURL(OOX_NS(mce)));
1307  rWorksheet->startElement(FSNS(XML_mc, XML_Choice), XML_Requires, "x14");
1308 
1309  rWorksheet->startElement(
1310  XML_control,
1311  XML_shapeId, OString::number(mnShapeId).getStr(),
1312  FSNS(XML_r, XML_id), aIdFormControlPr,
1313  XML_name, msLabel); // text to display with checkbox button
1314 
1315  rWorksheet->write("<controlPr defaultSize=\"0\" locked=\"1\" autoFill=\"0\" autoLine=\"0\" autoPict=\"0\"");
1316 
1317  if (mbPrint)
1318  rWorksheet->write(" print=\"true\"");
1319  else
1320  rWorksheet->write(" print=\"false\"");
1321 
1322  if (!msCtrlName.isEmpty())
1323  {
1324  rWorksheet->write(" altText=\"");
1325  rWorksheet->write(msCtrlName); // alt text
1326  rWorksheet->write("\"");
1327  }
1328 
1329  rWorksheet->write(">");
1330 
1331  rWorksheet->startElement(XML_anchor, XML_moveWithCells, "true", XML_sizeWithCells, "false");
1332  rWorksheet->startElement(XML_from);
1333  lcl_WriteAnchorVertex(rWorksheet, maAreaFrom);
1334  rWorksheet->endElement(XML_from);
1335  rWorksheet->startElement(XML_to);
1336  lcl_WriteAnchorVertex(rWorksheet, maAreaTo);
1337  rWorksheet->endElement(XML_to);
1338  rWorksheet->endElement( XML_anchor );
1339 
1340  rWorksheet->write("</controlPr>");
1341 
1342  rWorksheet->endElement(XML_control);
1343  rWorksheet->endElement( FSNS( XML_mc, XML_Choice ) );
1344  rWorksheet->endElement( FSNS( XML_mc, XML_AlternateContent ) );
1345 
1346  break;
1347  }
1348  }
1349 }
1350 
1351 //#endif
1352 
1353 XclExpChartObj::XclExpChartObj( XclExpObjectManager& rObjMgr, Reference< XShape > const & xShape, const tools::Rectangle* pChildAnchor, ScDocument* pDoc ) :
1354  XclObj( rObjMgr, EXC_OBJTYPE_CHART ),
1355  XclExpRoot( rObjMgr.GetRoot() ), mxShape( xShape ),
1356  mpDoc(pDoc)
1357 {
1358  // create the MSODRAWING record contents for the chart object
1360  mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty );
1361  EscherPropertyContainer aPropOpt;
1362  aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x01040104 );
1363  aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 );
1364  aPropOpt.AddOpt( ESCHER_Prop_fillColor, 0x0800004E );
1365  aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0x0800004D );
1366  aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00110010 );
1367  aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x0800004D );
1368  aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080008 );
1369  aPropOpt.AddOpt( ESCHER_Prop_fshadowObscured, 0x00020000 );
1370  aPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x00080000 );
1371  aPropOpt.Commit( mrEscherEx.GetStream() );
1372 
1373  // anchor
1374  SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape );
1375  ImplWriteAnchor( pSdrObj, pChildAnchor );
1376 
1377  // client data (the following OBJ record)
1379  mrEscherEx.CloseContainer(); // ESCHER_SpContainer
1381 
1382  // load the chart OLE object
1383  if( SdrOle2Obj* pSdrOleObj = dynamic_cast< SdrOle2Obj* >( pSdrObj ) )
1384  svt::EmbeddedObjectRef::TryRunningState( pSdrOleObj->GetObjRef() );
1385 
1386  // create the chart substream object
1387  ScfPropertySet aShapeProp( xShape );
1388  Reference< XModel > xModel;
1389  aShapeProp.GetProperty( xModel, "Model" );
1390  mxChartDoc.set( xModel,UNO_QUERY );
1391  css::awt::Rectangle aBoundRect;
1392  aShapeProp.GetProperty( aBoundRect, "BoundRect" );
1393  tools::Rectangle aChartRect( Point( aBoundRect.X, aBoundRect.Y ), Size( aBoundRect.Width, aBoundRect.Height ) );
1394  mxChart = std::make_shared<XclExpChart>( GetRoot(), xModel, aChartRect );
1395 }
1396 
1398 {
1399 }
1400 
1402 {
1403  // content of OBJ record
1404  XclObj::Save( rStrm );
1405  // chart substream
1406  mxChart->Save( rStrm );
1407 }
1408 
1410 {
1411  sax_fastparser::FSHelperPtr pDrawing = rStrm.GetCurrentStream();
1412 
1413  // FIXME: two cell? it seems the two cell anchor is incorrect.
1414  pDrawing->startElement( FSNS( XML_xdr, XML_twoCellAnchor ), // OOXTODO: oneCellAnchor, absoluteAnchor
1415  XML_editAs, "oneCell" );
1416  Reference< XPropertySet > xPropSet( mxShape, UNO_QUERY );
1417  if (xPropSet.is())
1418  {
1419  XclObjAny::WriteFromTo( rStrm, mxShape, GetTab() );
1420  ChartExport aChartExport(XML_xdr, pDrawing, mxChartDoc, &rStrm, drawingml::DOCUMENT_XLSX);
1421  auto pURLTransformer = std::make_shared<ScURLTransformer>(*mpDoc);
1422  aChartExport.SetURLTranslator(pURLTransformer);
1423  static sal_Int32 nChartCount = 0;
1424  nChartCount++;
1425  sal_Int32 nID = rStrm.GetUniqueId();
1426  aChartExport.WriteChartObj( mxShape, nID, nChartCount );
1427  // TODO: get the correcto chart number
1428  }
1429 
1430  pDrawing->singleElement( FSNS( XML_xdr, XML_clientData)
1431  // OOXTODO: XML_fLocksWithSheet
1432  // OOXTODO: XML_fPrintsWithSheet
1433  );
1434  pDrawing->endElement( FSNS( XML_xdr, XML_twoCellAnchor ) );
1435 }
1436 
1437 const css::uno::Reference<css::chart::XChartDocument>& XclExpChartObj::GetChartDoc() const
1438 {
1439  return mxChartDoc;
1440 }
1441 
1442 XclExpNote::XclExpNote(const XclExpRoot& rRoot, const ScAddress& rScPos,
1443  const ScPostIt* pScNote, std::u16string_view rAddText)
1445  , mrRoot(rRoot)
1446  , maScPos(rScPos)
1447  , mnObjId(EXC_OBJ_INVALID_ID)
1448  , mbVisible(pScNote && pScNote->IsCaptionShown())
1449  , meTHA(SDRTEXTHORZADJUST_LEFT)
1450  , meTVA(SDRTEXTVERTADJUST_TOP)
1451  , mbAutoScale(false)
1452  , mbLocked(false)
1453  , mbAutoFill(false)
1454  , mbColHidden(false)
1455  , mbRowHidden(false)
1456 {
1457  // get the main note text
1458  OUString aNoteText;
1459  if( pScNote )
1460  {
1461  aNoteText = pScNote->GetText();
1462  const EditTextObject *pEditObj = pScNote->GetEditTextObject();
1463  if( pEditObj )
1464  mpNoteContents = XclExpStringHelper::CreateString( rRoot, *pEditObj );
1465  }
1466  // append additional text
1467  aNoteText = ScGlobal::addToken( aNoteText, rAddText, '\n', 2 );
1468 
1469  // initialize record dependent on BIFF type
1470  switch( rRoot.GetBiff() )
1471  {
1472  case EXC_BIFF5:
1473  maNoteText = OUStringToOString(aNoteText, rRoot.GetTextEncoding());
1474  break;
1475 
1476  case EXC_BIFF8:
1477  {
1478  // TODO: additional text
1479  if( pScNote )
1480  {
1481  if( SdrCaptionObj* pCaption = pScNote->GetOrCreateCaption( maScPos ) )
1482  {
1483  lcl_GetFromTo( rRoot, pCaption->GetLogicRect(), maScPos.Tab(), maCommentFrom, maCommentTo );
1484  if( const OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
1485  mnObjId = rRoot.GetObjectManager().AddObj( std::make_unique<XclObjComment>( rRoot.GetObjectManager(), pCaption->GetLogicRect(), pOPO->GetTextObject(), pCaption, mbVisible, maScPos, maCommentFrom, maCommentTo ) );
1486 
1487  SfxItemSet aItemSet = pCaption->GetMergedItemSet();
1488  meTVA = pCaption->GetTextVerticalAdjust();
1489  meTHA = pCaption->GetTextHorizontalAdjust();
1490  mbAutoScale = pCaption->GetFitToSize() != drawing::TextFitToSizeType_NONE;
1491  mbLocked = pCaption->IsMoveProtect() || pCaption->IsResizeProtect();
1492 
1493  // AutoFill style would change if Postit.cxx object creation values are changed
1494  OUString aCol(aItemSet.Get(XATTR_FILLCOLOR).GetValue());
1495  mbAutoFill = aCol.isEmpty() && (aItemSet.Get(XATTR_FILLSTYLE).GetValue() == drawing::FillStyle_SOLID);
1496  mbRowHidden = (rRoot.GetDoc().RowHidden(maScPos.Row(),maScPos.Tab()));
1497  mbColHidden = (rRoot.GetDoc().ColHidden(maScPos.Col(),maScPos.Tab()));
1498  }
1499  // stAuthor (variable): An XLUnicodeString that specifies the name of the comment
1500  // author. String length MUST be greater than or equal to 1 and less than or equal
1501  // to 54.
1502  if( pScNote->GetAuthor().isEmpty() )
1503  maAuthor = XclExpString( " " );
1504  else
1505  maAuthor = XclExpString( pScNote->GetAuthor(), XclStrFlags::NONE, 54 );
1506  }
1507 
1508  SetRecSize( 9 + maAuthor.GetSize() );
1509  }
1510  break;
1511 
1512  default: DBG_ERROR_BIFF();
1513  }
1514 }
1515 
1517 {
1518  switch( rStrm.GetRoot().GetBiff() )
1519  {
1520  case EXC_BIFF5:
1521  {
1522  // write the NOTE record directly, there may be the need to create more than one
1523  const char* pcBuffer = maNoteText.getStr();
1524  sal_uInt16 nCharsLeft = static_cast< sal_uInt16 >( maNoteText.getLength() );
1525 
1526  while( nCharsLeft )
1527  {
1528  sal_uInt16 nWriteChars = ::std::min( nCharsLeft, EXC_NOTE5_MAXLEN );
1529 
1530  rStrm.StartRecord( EXC_ID_NOTE, 6 + nWriteChars );
1531  if( pcBuffer == maNoteText.getStr() )
1532  {
1533  // first record: row, col, length of complete text
1534  rStrm << static_cast< sal_uInt16 >( maScPos.Row() )
1535  << static_cast< sal_uInt16 >( maScPos.Col() )
1536  << nCharsLeft; // still contains full length
1537  }
1538  else
1539  {
1540  // next records: -1, 0, length of current text segment
1541  rStrm << sal_uInt16( 0xFFFF )
1542  << sal_uInt16( 0 )
1543  << nWriteChars;
1544  }
1545  rStrm.Write( pcBuffer, nWriteChars );
1546  rStrm.EndRecord();
1547 
1548  pcBuffer += nWriteChars;
1549  nCharsLeft = nCharsLeft - nWriteChars;
1550  }
1551  }
1552  break;
1553 
1554  case EXC_BIFF8:
1555  if( mnObjId != EXC_OBJ_INVALID_ID )
1556  XclExpRecord::Save( rStrm );
1557  break;
1558 
1559  default: DBG_ERROR_BIFF();
1560  }
1561 }
1562 
1564 {
1565  // BIFF5/BIFF7 is written separately
1566  OSL_ENSURE_BIFF( rStrm.GetRoot().GetBiff() == EXC_BIFF8 );
1567 
1568  sal_uInt16 nFlags = 0;
1570 
1571  rStrm << static_cast< sal_uInt16 >( maScPos.Row() )
1572  << static_cast< sal_uInt16 >( maScPos.Col() )
1573  << nFlags
1574  << mnObjId
1575  << maAuthor
1576  << sal_uInt8( 0 );
1577 }
1578 
1579 void XclExpNote::WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm )
1580 {
1581  sax_fastparser::FSHelperPtr rComments = rStrm.GetCurrentStream();
1582 
1583  rComments->startElement( XML_comment,
1585  XML_authorId, OString::number(nAuthorId)
1586  // OOXTODO: XML_guid
1587  );
1588  rComments->startElement(XML_text);
1589  // OOXTODO: phoneticPr, rPh, r
1590  if( mpNoteContents )
1591  mpNoteContents->WriteXml( rStrm );
1592  rComments->endElement( XML_text );
1593 
1594 /*
1595  Export of commentPr is disabled, since the current (Oct 2010)
1596  version of MSO 2010 doesn't yet support commentPr
1597  */
1598 #if 1//def XLSX_OOXML_FUTURE
1599  if( rStrm.getVersion() == oox::core::ISOIEC_29500_2008 )
1600  {
1601  rComments->startElement(FSNS(XML_mc, XML_AlternateContent));
1602  rComments->startElement(FSNS(XML_mc, XML_Choice), XML_Requires, "v2");
1603  rComments->startElement( XML_commentPr,
1604  XML_autoFill, ToPsz( mbAutoFill ),
1605  XML_autoScale, ToPsz( mbAutoScale ),
1606  XML_colHidden, ToPsz( mbColHidden ),
1607  XML_locked, ToPsz( mbLocked ),
1608  XML_rowHidden, ToPsz( mbRowHidden ),
1609  XML_textHAlign, ToHorizAlign( meTHA ),
1610  XML_textVAlign, ToVertAlign( meTVA ) );
1611  rComments->startElement(XML_anchor, XML_moveWithCells, "false", XML_sizeWithCells, "false");
1612  rComments->startElement(FSNS(XML_xdr, XML_from));
1613  lcl_WriteAnchorVertex( rComments, maCommentFrom );
1614  rComments->endElement( FSNS( XML_xdr, XML_from ) );
1615  rComments->startElement(FSNS(XML_xdr, XML_to));
1616  lcl_WriteAnchorVertex( rComments, maCommentTo );
1617  rComments->endElement( FSNS( XML_xdr, XML_to ) );
1618  rComments->endElement( XML_anchor );
1619  rComments->endElement( XML_commentPr );
1620 
1621  rComments->endElement( FSNS( XML_mc, XML_Choice ) );
1622  rComments->startElement(FSNS(XML_mc, XML_Fallback));
1623  // Any fallback code ?
1624  rComments->endElement( FSNS( XML_mc, XML_Fallback ) );
1625  rComments->endElement( FSNS( XML_mc, XML_AlternateContent ) );
1626  }
1627 #endif
1628  rComments->endElement( XML_comment );
1629 }
1630 
1632  XclExpControlHelper( rRoot )
1633 {
1634 }
1635 
1637 {
1638 }
1639 
1641 {
1642  if( mxMacroLink )
1644 }
1645 
1646 bool
1647 XclMacroHelper::SetMacroLink( const ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType )
1648 {
1649  OUString aMacroName = XclControlHelper::ExtractFromMacroDescriptor( rEvent, nEventType );
1650  if( !aMacroName.isEmpty() )
1651  {
1652  return SetMacroLink( aMacroName );
1653  }
1654  return false;
1655 }
1656 
1657 bool
1658 XclMacroHelper::SetMacroLink( const OUString& rMacroName )
1659 {
1660  if( !rMacroName.isEmpty() )
1661  {
1662  sal_uInt16 nExtSheet = GetLocalLinkManager().FindExtSheet( EXC_EXTSH_OWNDOC );
1663  sal_uInt16 nNameIdx = GetNameManager().InsertMacroCall( rMacroName, true, false );
1664  mxMacroLink = GetFormulaCompiler().CreateNameXFormula( nExtSheet, nNameIdx );
1665  return true;
1666  }
1667  return false;
1668 }
1669 
1670 XclExpShapeObj::XclExpShapeObj( XclExpObjectManager& rRoot, css::uno::Reference< css::drawing::XShape > const & xShape, ScDocument* pDoc ) :
1671  XclObjAny( rRoot, xShape, pDoc ),
1672  XclMacroHelper( rRoot )
1673 {
1674  if( SdrObject* pSdrObj = ::GetSdrObjectFromXShape( xShape ) )
1675  {
1676  ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pSdrObj );
1677  if ( pInfo && !pInfo->GetMacro().isEmpty() )
1678 // FIXME ooo330-m2: XclControlHelper::GetXclMacroName was removed in upstream sources; they started to call XclTools::GetXclMacroName instead; is this enough? it has only one parameter
1679 // SetMacroLink( XclControlHelper::GetXclMacroName( pInfo->GetMacro(), rRoot.GetDocShell() ) );
1681  }
1682 }
1683 
1685 {
1686 }
1687 
1689 {
1690  XclObjAny::WriteSubRecs( rStrm );
1691  WriteMacroSubRec( rStrm );
1692 }
1693 
1695  : mnTab( nTab ), mrNotes( rNotes )
1696 {
1697 }
1698 
1700 {
1701  if( mrNotes.IsEmpty() )
1702  return;
1703 
1705  XclXmlUtils::GetStreamName( "xl/", "comments", mnTab + 1 ),
1706  XclXmlUtils::GetStreamName( "../", "comments", mnTab + 1 ),
1707  rStrm.GetCurrentStream()->getOutputStream(),
1708  "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
1709  oox::getRelationship(Relationship::COMMENTS));
1710  rStrm.PushStream( rComments );
1711 
1712  if( rStrm.getVersion() == oox::core::ISOIEC_29500_2008 )
1713  rComments->startElement( XML_comments,
1714  XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)),
1715  FSNS(XML_xmlns, XML_mc), rStrm.getNamespaceURL(OOX_NS(mce)),
1716  FSNS(XML_xmlns, XML_xdr), rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr)),
1717  FSNS(XML_xmlns, XML_v2), rStrm.getNamespaceURL(OOX_NS(mceTest)),
1718  FSNS( XML_mc, XML_Ignorable ), "v2" );
1719  else
1720  rComments->startElement( XML_comments,
1721  XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)),
1722  FSNS(XML_xmlns, XML_xdr), rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr)) );
1723 
1724  rComments->startElement(XML_authors);
1725 
1726  typedef std::set<OUString> Authors;
1727  Authors aAuthors;
1728 
1729  size_t nNotes = mrNotes.GetSize();
1730  for( size_t i = 0; i < nNotes; ++i )
1731  {
1732  aAuthors.insert( XclXmlUtils::ToOUString( mrNotes.GetRecord( i )->GetAuthor() ) );
1733  }
1734 
1735  for( const auto& rAuthor : aAuthors )
1736  {
1737  rComments->startElement(XML_author);
1738  rComments->writeEscaped( rAuthor );
1739  rComments->endElement( XML_author );
1740  }
1741 
1742  rComments->endElement( XML_authors );
1743  rComments->startElement(XML_commentList);
1744 
1745  Authors::const_iterator aAuthorsBegin = aAuthors.begin();
1746  for( size_t i = 0; i < nNotes; ++i )
1747  {
1749  Authors::const_iterator aAuthor = aAuthors.find(
1750  XclXmlUtils::ToOUString( xNote->GetAuthor() ) );
1751  sal_Int32 nAuthorId = distance( aAuthorsBegin, aAuthor );
1752  xNote->WriteXml( nAuthorId, rStrm );
1753  }
1754 
1755  rComments->endElement( XML_commentList );
1756  rComments->endElement( XML_comments );
1757 
1758  rStrm.PopStream();
1759 }
1760 
1761 // object manager =============================================================
1762 
1764  XclExpRoot( rRoot )
1765 {
1766  InitStream( true );
1767  mxEscherEx = std::make_shared<XclEscherEx>( GetRoot(), *this, *mxDffStrm );
1768 }
1769 
1771  XclExpRoot( rParent.GetRoot() )
1772 {
1773  InitStream( false );
1774  mxEscherEx = std::make_shared<XclEscherEx>( GetRoot(), *this, *mxDffStrm, rParent.mxEscherEx.get() );
1775 }
1776 
1778 {
1779 }
1780 
1782 {
1783  return new XclExpDffSheetAnchor( GetRoot() );
1784 }
1785 
1787 {
1788  return new XclExpMsoDrawingGroup( *mxEscherEx );
1789 }
1790 
1792 {
1794 }
1795 
1797 {
1798  if( pSdrPage )
1799  mxEscherEx->AddSdrPage( *pSdrPage, GetOutput() != EXC_OUTPUT_BINARY );
1800  // the first dummy object may still be open
1801  OSL_ENSURE( mxEscherEx->GetGroupLevel() <= 1, "XclExpObjectManager::ProcessDrawing - still groups open?" );
1802  while( mxEscherEx->GetGroupLevel() )
1803  mxEscherEx->LeaveGroup();
1804  mxObjList->EndSheet();
1805  return mxObjList;
1806 }
1807 
1808 rtl::Reference< XclExpRecordBase > XclExpObjectManager::ProcessDrawing( const Reference< XShapes >& rxShapes )
1809 {
1810  if( rxShapes.is() )
1811  mxEscherEx->AddUnoShapes( rxShapes, GetOutput() != EXC_OUTPUT_BINARY );
1812  // the first dummy object may still be open
1813  OSL_ENSURE( mxEscherEx->GetGroupLevel() <= 1, "XclExpObjectManager::ProcessDrawing - still groups open?" );
1814  while( mxEscherEx->GetGroupLevel() )
1815  mxEscherEx->LeaveGroup();
1816  mxObjList->EndSheet();
1817  return mxObjList;
1818 }
1819 
1821 {
1822  mxEscherEx->EndDocument();
1823 }
1824 
1826 {
1827  return mxObjList->GetMsodrawingPerSheet();
1828 }
1829 
1831 {
1832  return !mxObjList->empty();
1833 }
1834 
1835 sal_uInt16 XclExpObjectManager::AddObj( std::unique_ptr<XclObj> pObjRec )
1836 {
1837  return mxObjList->Add( std::move(pObjRec) );
1838 }
1839 
1840 std::unique_ptr<XclObj> XclExpObjectManager::RemoveLastObj()
1841 {
1842  return mxObjList->pop_back();
1843 }
1844 
1845 void XclExpObjectManager::InitStream( bool bTempFile )
1846 {
1847  if( bTempFile )
1848  {
1849  mxTempFile = std::make_shared<::utl::TempFile>();
1850  if( mxTempFile->IsValid() )
1851  {
1852  mxTempFile->EnableKillingFile();
1853  mxDffStrm = ::utl::UcbStreamHelper::CreateStream( mxTempFile->GetURL(), StreamMode::STD_READWRITE );
1854  }
1855  }
1856 
1857  if( !mxDffStrm )
1858  mxDffStrm = std::make_unique<SvMemoryStream>();
1859 
1860  mxDffStrm->SetEndian( SvStreamEndian::LITTLE );
1861 }
1862 
1864  const XclExpObjectManager& rParent, const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY ) :
1865  XclExpObjectManager( rParent ),
1866  maPageSize( rPageSize ),
1867  mnScaleX( nScaleX ),
1868  mnScaleY( nScaleY )
1869 {
1870 }
1871 
1873 {
1875 }
1876 
1877 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvStream & WriteXclObjAnchor(SvStream &rStrm, const XclObjAnchor &rAnchor)
Definition: xlescher.hxx:341
XclFontPropSetHelper & GetFontPropSetHelper() const
Returns the property set helper for fonts.
Definition: xlroot.cxx:409
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:47
double mnHeight
const sal_uInt16 EXC_NOTE5_MAXLEN
Definition: xlescher.hxx:40
bool mbRowHidden
Column containing the comment is hidden.
Definition: xeescher.hxx:377
virtual void WriteData(EscherEx &rEscherEx, const tools::Rectangle &rRect) override
Called from SVX DFF converter.
Definition: xeescher.cxx:266
SdrTextHorzAdjust meTHA
true = permanently visible.
Definition: xeescher.hxx:371
XclExpDffAnchorBase(const XclExpRoot &rRoot, sal_uInt16 nFlags=0)
Constructs a dummy client anchor.
Definition: xeescher.cxx:242
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:33
::std::vector< sal_uInt8 > ScfUInt8Vec
Definition: ftools.hxx:253
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
Definition: address.cxx:2116
std::size_t Write(const void *pData, std::size_t nBytes)
Writes nBytes bytes from memory.
Definition: xestream.cxx:216
static OString ToOString(const Color &rColor)
Definition: xestream.cxx:699
ScAddress maScPos
Text and formatting data (OOXML)
Definition: xeescher.hxx:368
SDRTEXTVERTADJUST_TOP
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the record (without record header).
Definition: xeescher.cxx:346
const sal_uInt16 EXC_ID_OBJSBS
Radio button group data.
Definition: xlescher.hxx:215
tools::Long Height() const
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:146
sal_Int32 nIndex
void WriteCellLinkSubRec(XclExpStream &rStrm, sal_uInt16 nSubRecId)
Writes a subrecord containing a cell link, or nothing, if no link present.
Definition: xeescher.cxx:1056
ScAddress aStart
Definition: address.hxx:499
sal_uInt16 mnScrollMin
Scrollbar: Current value.
Definition: xeescher.hxx:283
The MSODRAWINGGROUP record contains the DGGCONTAINER with global DFF data such as the picture contain...
Definition: xeescher.hxx:132
virtual const tools::Rectangle & GetCurrentBoundRect() const
sal_uInt32 mnStrmStart
Class name of the control.
Definition: xeescher.hxx:240
const XclExpString & GetAuthor() const
Definition: xeescher.hxx:358
#define ESCHER_Prop_fshadowObscured
bool IsExportTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet will be exported.
Definition: xelink.cxx:772
void SetAutoLine(bool b)
Definition: xcl97rec.hxx:135
XclExpChartRef mxChart
Definition: xeescher.hxx:323
std::unique_ptr< XclExpMsoDrawing > pClientTextbox
Definition: xcl97rec.hxx:101
virtual void Save(XclExpStream &rStrm) override
Writes the BITMAP record.
Definition: xeescher.cxx:394
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:993
SvStream & WriteUInt16(sal_uInt16 nUInt16)
const OUString & GetMacro() const
Definition: userdat.hxx:82
const sal_uInt16 EXC_OBJTYPE_UNKNOWN
Definition: xlescher.hxx:71
This class is used to export Excel record streams.
Definition: xestream.hxx:72
SCROW Row() const
Definition: address.hxx:261
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xeescher.cxx:1409
#define ESCHER_Prop_pictureId
const sal_uInt16 EXC_OBJ_SCROLLBAR_DEFFLAGS
Definition: xlescher.hxx:184
const sal_uInt16 EXC_ID_NOTE
Definition: xlescher.hxx:38
sal_uLong GetStreamPos() const
sal_uInt16 mnRX
Y offset in top row (1/256 of row height).
Definition: xlescher.hxx:287
sal_uInt16 mnObjId
Calc cell address of the note.
Definition: xeescher.hxx:369
const sal_uInt16 EXC_OBJ_INVALID_ID
Definition: xlescher.hxx:46
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
#define ESCHER_OPT
XclExpLinkManager & GetLocalLinkManager() const
Returns the local link manager for the current sheet.
Definition: xeroot.cxx:135
static OUString ToOUString(const char *s)
Definition: xestream.cxx:784
rtl::Reference< XclExpRecordBase > CreateDrawingGroup()
Creates and returns the MSODRAWINGGROUP record containing global DFF data in the DGGCONTAINER.
Definition: xeescher.cxx:1786
XclTokenArrayRef mxMacroLink
Definition: xeescher.hxx:196
const sal_uInt16 EXC_ID_OBJPICTFMLA
Option flags.
Definition: xlescher.hxx:212
SdrTextHorzAdjust
std::unique_ptr< XclObj > RemoveLastObj()
Definition: xeescher.cxx:1840
const OUString & GetAuthor() const
Returns the author date of this note.
Definition: postit.hxx:213
XclObjAnchor maAnchor
Definition: xeescher.hxx:64
void ConvertSheetLinks(css::uno::Reference< css::drawing::XShape > const &xShape)
Tries to get spreadsheet cell link and source range link from the passed shape.
Definition: xeescher.cxx:456
static ScMacroInfo * GetMacroInfo(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2630
long Long
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
sal_uInt16 Insert(const XclFontData &rFontData, XclExpColorType eColorType, bool bAppFont=false)
Inserts a new font with the passed font data into the buffer if not present.
Definition: xestyle.cxx:1189
const sal_uInt8 EXC_OBJ_LISTBOX_MULTI
Single selection.
Definition: xlescher.hxx:189
const sal_uInt16 EXC_ID_MSODRAWINGGROUP
Definition: xlescher.hxx:259
OoxmlVersion getVersion() const
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
virtual void WriteSubRecs(XclExpStream &rStrm) override
Definition: xeescher.cxx:583
const sal_uInt16 EXC_OBJ_SCROLLBAR_HOR
Definition: xlescher.hxx:182
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:285
virtual void Save(XclExpStream &rStrm) override
Writes the NOTE record, if the respective Escher object is present.
Definition: xeescher.cxx:1516
void Commit(SvStream &rSt, sal_uInt16 nVersion=3, sal_uInt16 nRecType=ESCHER_OPT)
#define ESCHER_Prop_pib
XclEscherEx & mrEscherEx
Definition: xeescher.hxx:125
XclExpFormulaCompiler & GetFormulaCompiler() const
Returns the formula compiler to produce formula token arrays.
Definition: xeroot.cxx:87
void SetRecSize(std::size_t nRecSize)
Sets a new record size prediction.
Definition: xerecord.hxx:162
void EndDocument()
Finalizes the object manager after conversion of all sheets.
Definition: xeescher.cxx:1820
#define ESCHER_ClientAnchor
bool mbAutoFill
Position & Size locked.
Definition: xeescher.hxx:375
virtual ~XclExpObjectManager() override
Definition: xeescher.cxx:1777
sal_uInt16 mnScrollPage
Scrollbar: Single step.
Definition: xeescher.hxx:286
sal_uInt16 mnHeight
Font color.
Definition: xlstyle.hxx:290
bool GetBoolProperty(const OUString &rPropName) const
Gets the specified Boolean property from the property set.
Definition: fapihelper.cxx:188
std::shared_ptr< XclEscherEx > mxEscherEx
Definition: xeescher.hxx:438
SDRTEXTVERTADJUST_BLOCK
XclTokenArrayRef CreateNameXFormula(sal_uInt16 nExtSheet, sal_uInt16 nExtName)
Creates a single tNameXR token for a reference to an external name.
Definition: xeformula.cxx:2687
ScAddress aEnd
Definition: address.hxx:500
bool mbFlatButton
Scrollbar: Page step.
Definition: xeescher.hxx:287
#define SC_UNONAME_BOUNDCELL
Definition: unonames.hxx:651
void set_flag(Type &rnBitField, Type nMask, bool bSet=true)
Sets or clears (according to bSet) all set bits of nMask in rnBitField.
Definition: ftools.hxx:95
XclAddress maLast
Definition: xladdress.hxx:60
sal_uInt32 mnRow
Definition: xladdress.hxx:32
const sal_uInt16 EXC_IMGDATA_BMP
Definition: xlescher.hxx:245
sal_uInt16 GetSize() const
Returns the size of the token array in bytes.
Definition: xlformula.cxx:735
ReturnType limit_cast(Type nValue, ReturnType nMin, ReturnType nMax)
Returns the value, if it is not less than nMin and not greater than nMax, otherwise one of the limits...
Definition: ftools.hxx:63
XclAddress maFirst
Definition: xladdress.hxx:59
void FindExtSheet(sal_uInt16 &rnExtSheet, sal_uInt16 &rnXclTab, SCTAB nScTab, XclExpRefLogEntry *pRefLogEntry=nullptr)
Searches for an EXTERNSHEET index for the given Calc sheet.
Definition: xelink.cxx:2564
virtual void AddShape(sal_uInt32 nShpInstance, ShapeFlag nFlagIds, sal_uInt32 nShapeID=0)
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:276
XclExpShapeObj(XclExpObjectManager &rRoot, css::uno::Reference< css::drawing::XShape > const &xShape, ScDocument *pDoc)
Definition: xeescher.cxx:1670
virtual void ImplSetFlags(const SdrObject &rSdrObj) override
Definition: xeescher.cxx:289
void SetSdrObject(const SdrObject &rSdrObj)
Sets the anchor position and flags according to the passed SdrObject.
Definition: xeescher.cxx:253
bool SetMacroLink(const css::script::ScriptEventDescriptor &rEvent)
Sets the name of a macro attached to this control.
Definition: xeescher.cxx:915
#define ESCHER_ClientTextbox
void SetPrintable(bool b)
Definition: xcl97rec.hxx:133
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: xcl97rec.cxx:478
void StartSheet()
Initializes the object manager for a new sheet.
Definition: xeescher.cxx:1791
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xeescher.cxx:1699
void SetFlags(const SdrObject &rSdrObj)
Sets the flags according to the passed SdrObject.
Definition: xeescher.cxx:248
virtual ~XclExpControlHelper() override
Definition: xeescher.cxx:452
const sal_uInt16 EXC_ID_OBJFLAGS
Clipboard format.
Definition: xlescher.hxx:211
const sal_uInt16 EXC_ID_OBJSBSFMLA
Note data.
Definition: xlescher.hxx:217
XAdjustmentListener.adjustmentValueChanged.
Definition: xlescher.hxx:411
XTextListener.textChanged.
Definition: xlescher.hxx:410
sal_Int16 mnLineCount
Checked/unchecked state.
Definition: xeescher.hxx:280
uno::Reference< drawing::XShape > const mxShape
#define SC_SERVICENAME_VALBIND
Definition: unonames.hxx:23
FuncFlags mnFlags
Information about all parameters.
XclExpOcxControlObj(XclExpObjectManager &rObjMgr, css::uno::Reference< css::drawing::XShape > const &xShape, const tools::Rectangle *pChildAnchor, const OUString &rClassName, sal_uInt32 nStrmStart, sal_uInt32 nStrmSize)
Definition: xeescher.cxx:528
SvStream & GetStream() const
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
Access to global data from other classes.
Definition: xeroot.hxx:112
const sal_uInt16 EXC_FONT_APP
Definition: xlstyle.hxx:76
#define ESCHER_Prop_wzName
const sal_uInt16 EXC_OBJ_LISTBOX_FLAT
Definition: xlescher.hxx:193
const css::uno::Reference< css::chart::XChartDocument > & GetChartDoc() const
Definition: xeescher.cxx:1437
static void WriteFormulaSubRec(XclExpStream &rStrm, sal_uInt16 nSubRecId, const XclTokenArray &rTokArr)
Writes a formula subrecord with special style only valid in OBJ records.
Definition: xeescher.cxx:518
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
const sal_uInt16 EXC_OBJTYPE_SCROLLBAR
Definition: xlescher.hxx:65
OUString getNamespaceURL(sal_Int32 nNSID) const
tools::Long Left() const
const sal_uInt8 EXC_OBJ_LISTBOX_SINGLE
Definition: xlescher.hxx:188
MS Excel 4.0.
Definition: xlconst.hxx:34
Additional class containing cell annotation data.
Definition: postit.hxx:159
bool SetMacroLink(const css::script::ScriptEventDescriptor &rEvent, const XclTbxEventType &nEventType)
Sets the name of a macro for object of passed type.
Scanline GetScanline(tools::Long nY) const
XclExpDffEmbeddedAnchor(const XclExpRoot &rRoot, const Size &rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY)
Definition: xeescher.cxx:303
bool HasObj() const
Definition: xeescher.cxx:1830
sal_uInt16 GetSourceEntryCount() const
Returns the number of entries in the source range, or 0, if no source set.
Definition: xeescher.hxx:179
XclTbxEventType
Definition: xlescher.hxx:405
SCTAB GetTab() const
Definition: xcl97rec.hxx:130
void ImplWriteAnchor(const SdrObject *pSdrObj, const tools::Rectangle *pChildAnchor)
Definition: xcl97rec.cxx:396
static OUString GetXclMacroName(const OUString &rSbMacroUrl)
Returns the Excel macro name from a full StarBasic macro URL.
Definition: xltools.cxx:718
void WriteArray(XclExpStream &rStrm) const
Writes the tokens of the token array (without size field).
Definition: xlformula.cxx:764
tools::Long Bottom() const
sal_uInt32 GetDffFragmentSize(sal_uInt32 nFragmentKey)
Returns the size of the specified DFF stream fragment.
Definition: xcl97esc.cxx:141
#define ESCHER_Prop_wzDescription
void PushStream(sax_fastparser::FSHelperPtr const &aStream)
Definition: xestream.cxx:917
const ::basegfx::B2DSize maPageSize
void SaveSheetXml(XclExpXmlStream &rStrm, const OUString &aIdFormControlPr) const
Definition: xeescher.cxx:1297
#define ESCHER_ShpInst_HostControl
const sal_uInt16 EXC_IMGDATA_WIN
Definition: xlescher.hxx:247
SDRTEXTHORZADJUST_CENTER
SCTAB Tab() const
Definition: address.hxx:270
#define ESCHER_Prop_LockAgainstGrouping
const sal_uInt16 EXC_ESC_ANCHOR_POSLOCKED
Definition: xlescher.hxx:266
void SetAutoFill(bool b)
Definition: xcl97rec.hxx:134
Base class for records holding DFF stream fragments.
Definition: xeescher.hxx:116
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
sal_uInt16 mnScrollStep
Scrollbar: Maximum value.
Definition: xeescher.hxx:285
OString maNoteText
Name of the author.
Definition: xeescher.hxx:366
sax_fastparser::FSHelperPtr & GetCurrentStream()
Definition: xestream.cxx:911
OUString getRelationship(Relationship eRelationship)
tools::Rectangle maAreaTo
Definition: xeescher.hxx:297
void PopStream()
Definition: xestream.cxx:922
virtual void ImplCalcAnchorRect(const tools::Rectangle &rRect, MapUnit eMapUnit) override
Definition: xeescher.cxx:298
SvStream * QueryPictureStream()
Represents the position (anchor) of a shape in an embedded draw page.
Definition: xeescher.hxx:83
constexpr auto convert(N n, sal_Int64 mul, sal_Int64 div)
virtual void WriteBody(XclExpStream &rStrm) override
Writes the body of the NOTE record.
Definition: xeescher.cxx:1563
bool mbPrint
Scrollbar: true = horizontal.
Definition: xeescher.hxx:291
XclExpMsoDrawingGroup(XclEscherEx &rEscherEx)
Definition: xeescher.cxx:353
void UpdateDffFragmentEnd()
Called after some data has been written to the DFF stream, to update the end position of the DFF frag...
Definition: xcl97esc.cxx:128
bool mbAutoScale
text vertical adjust
Definition: xeescher.hxx:373
void WriteXml(sal_Int32 nAuthorId, XclExpXmlStream &rStrm)
Definition: xeescher.cxx:1579
double distance
const sal_uInt16 EXC_OBJ_SCROLLBAR_FLAT
Definition: xlescher.hxx:185
const XclTokenArray * GetCellLinkTokArr() const
Returns the Excel token array of the cell link, or 0, if no link present.
Definition: xeescher.hxx:175
#define ESCHER_Prop_fNoLineDrawDash
bool IsValid() const
Definition: address.hxx:292
sal_uInt32 mnBY
X offset in right column (1/1024 of column width).
Definition: xlescher.hxx:288
static sal_Int32 GetHmmFromTwips(sal_Int32 nTwips)
Returns the length in 1/100 mm calculated from a length in twips.
Definition: xltools.cxx:302
void WriteSbs(XclExpStream &rStrm)
Writes the ftSbs sub structure containing scrollbar data.
Definition: xeescher.cxx:1062
void SetLocked(bool b)
Definition: xcl97rec.hxx:132
SDRTEXTVERTADJUST_BOTTOM
static void WriteFormula(XclExpStream &rStrm, const XclTokenArray &rTokArr)
Writes a formula with special style only valid in OBJ records.
Definition: xeescher.cxx:509
SDRTEXTHORZADJUST_BLOCK
const sal_uInt16 EXC_OBJTYPE_DROPDOWN
Definition: xlescher.hxx:68
SDRTEXTHORZADJUST_LEFT
const sal_uInt16 EXC_OBJTYPE_GROUPBOX
Definition: xlescher.hxx:67
SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
Definition: document.cxx:4437
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xeescher.cxx:1088
sal_uInt8 * Scanline
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35
const sal_uInt16 EXC_ID_MSODRAWING
Definition: xlescher.hxx:263
vcl::PixelFormat getPixelFormat() const
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:142
const sal_uInt16 EXC_OBJ_GROUPBOX_FLAT
Dropdown style: filtered.
Definition: xlescher.hxx:203
static OUString ExtractFromMacroDescriptor(const css::script::ScriptEventDescriptor &rDescriptor, XclTbxEventType eEventType)
Tries to extract an Excel macro name from the passed macro descriptor.
Definition: xlescher.cxx:324
XclExpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xeroot.cxx:81
tools::Rectangle maCommentFrom
Row containing the comment is hidden.
Definition: xeescher.hxx:378
sal_uInt16 mnLX
Definition: xlescher.hxx:285
ScAddress mxCellLinkAddress
Number of entries in source range.
Definition: xeescher.hxx:191
int i
XclExpDffDropDownAnchor(const XclExpRoot &rRoot, const ScAddress &rScPos)
Definition: xeescher.cxx:328
SVXCORE_DLLPUBLIC SdrObject * GetSdrObjectFromXShape(const css::uno::Reference< css::drawing::XShape > &xShape)
const sal_uInt8 EXC_OBJ_VER_CENTER
Definition: xlescher.hxx:128
Graphic maGraphic
Definition: xeescher.hxx:158
#define ESCHER_Prop_WrapText
Base class for DFF client anchor atoms used in spreadsheets.
Definition: xeescher.hxx:41
static ScAnchorType GetAnchorType(const SdrObject &)
Definition: drwlayer.cxx:2435
const sal_uInt16 EXC_OBJ_CHECKBOX_FLAT
Definition: xlescher.hxx:169
bool mbMultiSel
False = 3D border style; True = Flat border style.
Definition: xeescher.hxx:289
virtual void ImplCalcAnchorRect(const tools::Rectangle &rRect, MapUnit eMapUnit) override
Definition: xeescher.cxx:317
const sal_uInt16 EXC_OBJ_SCROLLBAR_MAX
Definition: xlescher.hxx:180
const sal_uInt16 EXC_OBJTYPE_LABEL
Definition: xlescher.hxx:62
XclEscherEx & mrEscherEx
Definition: xcl97rec.hxx:99
const sal_uInt8 EXC_OBJ_HOR_CENTER
Definition: xlescher.hxx:123
#define SC_UNONAME_CELLRANGE
Definition: unonames.hxx:653
sal_uInt16 mnEntryCount
Formula for source data range.
Definition: xeescher.hxx:189
sal_Int64 convertHmmToEmu(sal_Int32 nValue)
const sal_uInt16 EXC_ESC_ANCHOR_LOCKED
Definition: xlescher.hxx:268
tools::Long Width() const
void InitStream(bool bTempFile)
Definition: xeescher.cxx:1845
std::size_t WriteBytes(const void *pData, std::size_t nSize)
virtual void WriteSubRecs(XclExpStream &rStrm) override
Definition: xcl97rec.cxx:1061
static void WriteFromTo(XclExpXmlStream &rStrm, const XclObjAny &rObj)
Definition: xcl97rec.cxx:1146
OUString GetText() const
Returns the caption text of this note.
Definition: postit.cxx:914
void EndRecord()
Checks and corrects real record length.
Definition: xestream.cxx:121
const sal_uInt16 EXC_ID_OBJGBODATA
Scroll bar/list box/combo box cell link.
Definition: xlescher.hxx:218
XclExpStringRef mpNoteContents
Main text of the note (<=BIFF7).
Definition: xeescher.hxx:367
const sal_uInt16 EXC_NOTE_VISIBLE
Definition: xlescher.hxx:39
SdrCaptionObj * GetOrCreateCaption(const ScAddress &rPos) const
Returns the caption object of this note.
Definition: postit.cxx:951
std::unique_ptr< SvStream > mxDffStrm
Definition: xeescher.hxx:437
XclExpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
Definition: xeroot.cxx:141
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
Definition: xeroot.cxx:75
#define ESCHER_Prop_FitTextToShape
sal_uInt16 mnScrollMax
Scrollbar: Minimum value.
Definition: xeescher.hxx:284
virtual ~XclExpShapeObj() override
Definition: xeescher.cxx:1684
sal_uInt16 mnState
Height of the control.
Definition: xeescher.hxx:279
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1988
sal_uInt16 mnCol
Definition: xladdress.hxx:31
XclExpRecordList< XclExpNote > & mrNotes
Definition: xeescher.hxx:391
XclExpTbxControlObj(XclExpObjectManager &rObjMgr, css::uno::Reference< css::drawing::XShape > const &xShape, const tools::Rectangle *pChildAnchor)
Definition: xeescher.cxx:634
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
virtual void ImplSetFlags(const SdrObject &rSdrObj)
Definition: xeescher.cxx:273
virtual void ImplCalcAnchorRect(const tools::Rectangle &rRect, MapUnit eMapUnit)
Definition: xeescher.cxx:278
#define MSPROP_DESCRIPTION_MAX_LEN
tools::Rectangle maAreaFrom
Definition: xeescher.hxx:296
static SC_DLLPUBLIC OUString addToken(const OUString &rTokenList, std::u16string_view rToken, sal_Unicode cSep, sal_Int32 nSepCount=1, bool bForceSep=false)
Adds the string rToken to rTokenList, using a list separator character.
Definition: global.cxx:654
tools::Long Top() const
void CopyFromStream(SvStream &rInStrm, sal_uInt64 nBytes=STREAM_SEEK_TO_END)
Copies nBytes bytes from current position of the stream rInStrm.
Definition: xestream.cxx:284
XclExpImgData(const Graphic &rGraphic, sal_uInt16 nRecId)
Definition: xeescher.cxx:388
const XclTokenArray * GetSourceRangeTokArr() const
Returns the Excel token array of the source range, or 0, if no link present.
Definition: xeescher.hxx:177
std::shared_ptr< FastSerializerHelper > FSHelperPtr
virtual void ImplSetFlags(const SdrObject &rSdrObj) override
Definition: xeescher.cxx:312
const sal_uInt16 EXC_ID_OBJCBLS
OLE link formula.
Definition: xlescher.hxx:213
const sal_uInt16 EXC_OBJ_CHECKBOX_CHECKED
Definition: xlescher.hxx:167
static void FillScAddress(ScAddress &rScAddress, const css::table::CellAddress &rApiAddress)
Definition: convuno.hxx:63
const XclExpRoot & mrRoot
Definition: xeescher.hxx:364
sal_uInt16 mnObjType
Definition: xcl97rec.hxx:103
sal_Int16 mnSelEntry
Combobox dropdown line count.
Definition: xeescher.hxx:281
const sal_uInt16 EXC_OBJ_CHECKBOX_TRISTATE
Definition: xlescher.hxx:168
SCCOL Col() const
Definition: address.hxx:266
virtual ~XclExpChartObj() override
Definition: xeescher.cxx:1397
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xeroot.hxx:118
std::unique_ptr< XclTxo > pTxo
Definition: xcl97rec.hxx:102
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:160
sal_uInt32 mnFragmentKey
Reference to the DFF converter containing the DFF stream.
Definition: xeescher.hxx:126
#define ESCHER_Prop_fillBackColor
bool Is() const
Returns true, if the contained XPropertySet interface is valid.
Definition: fapihelper.hxx:128
void ReadFontProperties(XclFontData &rFontData, const ScfPropertySet &rPropSet, XclFontPropSetType eType, sal_Int16 nScript=-1)
Reads all font properties from the passed property set.
Definition: xlstyle.cxx:624
Bitmap GetBitmap(Color aTransparentReplaceColor) const
XclMacroHelper(const XclExpRoot &rRoot)
Token array containing a link to an attached macro.
Definition: xeescher.cxx:1631
sal_uInt16 mnFlags
The client anchor data.
Definition: xeescher.hxx:65
static OUString GetStreamName(const char *sStreamDir, const char *sStream, sal_Int32 nId)
Definition: xestream.cxx:684
sal_uInt32 GetDffFragmentPos(sal_uInt32 nFragmentKey)
Returns the position of the specified DFF stream fragment.
Definition: xcl97esc.cxx:134
XclExpComments(SCTAB nTab, XclExpRecordList< XclExpNote > &rNotes)
Definition: xeescher.cxx:1694
One or more MSODRAWING records contain the DFF stream data for a drawing shape.
Definition: xeescher.hxx:141
SdrTextVertAdjust meTVA
text horizontal adjust
Definition: xeescher.hxx:372
const sal_uInt16 EXC_OBJTYPE_CHECKBOX
Definition: xlescher.hxx:59
#define ESCHER_Prop_fillColor
XclTbxEventType meEventType
Indexes of all selected entries in a multi selection.
Definition: xeescher.hxx:277
SDRTEXTHORZADJUST_RIGHT
RecType * GetRecord(size_t nPos) const
Returns reference to an existing record or empty reference on error.
Definition: xerecord.hxx:332
#define ESCHER_DggContainer
Binary representation of an Excel token array.
Definition: xlformula.hxx:376
const sal_uInt16 EXC_OBJ_CHECKBOX_UNCHECKED
Definition: xlescher.hxx:166
XclTokenArrayRef mxSrcRange
Formula for linked cell.
Definition: xeescher.hxx:188
A wrapper for a UNO property set.
Definition: fapihelper.hxx:103
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
rtl::Reference< XclExpRecordBase > ProcessDrawing(const SdrPage *pSdrPage)
Processes a drawing page and returns the record block containing all related records (MSODRAWING...
Definition: xeescher.cxx:1796
OUString maClassName
Definition: xeescher.hxx:239
#define ESCHER_SpContainer
XclExpNote(const XclExpRoot &rRoot, const ScAddress &rScPos, const ScPostIt *pScNote, std::u16string_view rAddText)
Constructs a NOTE record from the passed note object and/or the text.
Definition: xeescher.cxx:1442
OUString SaveControlPropertiesXml(XclExpXmlStream &rStrm) const
Definition: xeescher.cxx:1235
const sal_uInt16 EXC_OBJTYPE_SPIN
Definition: xlescher.hxx:64
virtual void CloseContainer()
bool mbVisible
sal_uInt16 mnRecId
The VCL graphic.
Definition: xeescher.hxx:159
#define OSL_ENSURE_BIFF(c)
Definition: xltools.hxx:34
const sal_uInt16 EXC_ESC_ANCHOR_SIZELOCKED
Definition: xlescher.hxx:267
void AddAtom(sal_uInt32 nAtomSitze, sal_uInt16 nRecType, int nRecVersion=0, int nRecInstance=0)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 InsertMacroCall(const OUString &rMacroName, bool bVBasic, bool bFunc, bool bHidden=false)
Searches or inserts a defined name describing a macro name.
Definition: xename.cxx:835
unsigned char sal_uInt8
css::uno::Reference< css::chart::XChartDocument > mxChartDoc
Definition: xeescher.hxx:325
#define ESCHER_Prop_lineColor
XclExpControlHelper(const XclExpRoot &rRoot)
Definition: xeescher.cxx:446
rtl::Reference< XclExpObjList > mxObjList
Definition: xeescher.hxx:439
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
Definition: xestring.cxx:249
#define ESCHER_Prop_fNoFillHitTest
bool Convert(BmpConversion eConversion)
bool mbFlatBorder
False = 3D button style; True = Flat button style.
Definition: xeescher.hxx:288
void setShapeId(sal_Int32 aShapeId)
Definition: xeescher.cxx:1082
virtual void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance=0)
#define SC_SERVICENAME_LISTSOURCE
Definition: unonames.hxx:25
#define DEFTBINS
const css::uno::Reference< css::drawing::XShape > mxShape
Definition: xeescher.hxx:275
bool mbScrollHor
true = Multi selection in listbox.
Definition: xeescher.hxx:290
virtual void WriteSubRecs(XclExpStream &rStrm) override
Definition: xeescher.cxx:1688
std::shared_ptr< ::utl::TempFile > mxTempFile
Definition: xeescher.hxx:436
const sal_uInt16 EXC_ID_OBJLBSDATA
Check box/radio button data.
Definition: xlescher.hxx:222
sax_fastparser::FSHelperPtr CreateOutputStream(const OUString &sFullStream, const OUString &sRelativeStream, const css::uno::Reference< css::io::XOutputStream > &xParentRelation, const char *sContentType, std::u16string_view sRelationshipType, OUString *pRelationshipId=nullptr)
Definition: xestream.cxx:940
bool mbVisible
Escher object ID (BIFF8).
Definition: xeescher.hxx:370
virtual XclExpDffAnchorBase * CreateDffAnchor() const
Creates a new DFF client anchor object.
Definition: xeescher.cxx:1781
void WriteDffData(EscherEx &rEscherEx) const
Writes the DFF client anchor structure with the current anchor position.
Definition: xeescher.cxx:259
css::uno::Reference< css::drawing::XShape > mxShape
The chart itself (BOF/EOF substream data).
Definition: xeescher.hxx:324
XclTokenArrayRef CreateFormula(XclFormulaType eType, const ScTokenArray &rScTokArr, const ScAddress *pScBasePos=nullptr, XclExpRefLog *pRefLog=nullptr)
Creates and returns the token array of a formula.
Definition: xeformula.cxx:2637
void insert_value(Type &rnBitField, InsertType nValue, sal_uInt8 nStartBit, sal_uInt8 nBitCount)
Inserts a value into a bitfield.
Definition: ftools.hxx:102
const sal_uInt16 EXC_ID_OBJCBLSFMLA
List box/combo box data.
Definition: xlescher.hxx:223
const sal_uInt16 EXC_OBJTYPE_LISTBOX
Definition: xlescher.hxx:66
void AddOpt(sal_uInt16 nPropID, bool bBlib, sal_uInt32 nSizeReduction, SvMemoryStream &rStream)
virtual void Save(XclExpStream &rStrm) override
Writes the OBJ record and the entire chart substream.
Definition: xeescher.cxx:1401
XclExpObjectManager & GetObjectManager() const
Returns the drawing object manager.
Definition: xeroot.cxx:147
XActionListener.actionPerformed.
Definition: xlescher.hxx:408
sal_Int32 mnShapeId
Definition: xeescher.hxx:295
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: xeescher.cxx:437
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:140
const sal_uInt8 EXC_OBJ_HOR_LEFT
Definition: xlescher.hxx:122
sal_Int32 mnHeight
Type of supported macro event.
Definition: xeescher.hxx:278
const sal_uInt16 EXC_OBJTYPE_CHART
Definition: xlescher.hxx:54
void SetInvalid()
Definition: address.hxx:286
BitmapColor GetPixelFromData(const sal_uInt8 *pData, tools::Long nX) const
sal_uInt32 mnTY
X offset in left column (1/1024 of column width).
Definition: xlescher.hxx:286
virtual XclExpDffAnchorBase * CreateDffAnchor() const override
Creates a new DFF client anchor object for embedded objects according to the scaling data passed to t...
Definition: xeescher.cxx:1872
sal_uInt16 mnScrollValue
Selected entry in combobox (1-based).
Definition: xeescher.hxx:282
constexpr sal_Int32 FSNS(sal_Int32 namespc, sal_Int32 element)
size_t GetSize() const
Definition: xerecord.hxx:326
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4421
tools::Rectangle maCommentTo
From and From Offset.
Definition: xeescher.hxx:379
const std::u16string_view aStringList[]
Definition: vbadialog.cxx:31
void StartRecord(sal_uInt16 nRecId, std::size_t nRecSize)
Starts a new record: writes header data, stores calculated record size.
Definition: xestream.cxx:109
#define ESCHER_SplitMenuColors
Represents the position (anchor) of an object in a Calc sheet.
Definition: xeescher.hxx:69
const EditTextObject * GetEditTextObject() const
Returns the pointer to the current edit text object, or null.
Definition: postit.cxx:908
static XclExpStringRef CreateString(const XclExpRoot &rRoot, const OUString &rString, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Creates a new unformatted string from the passed string.
Definition: xehelper.cxx:526
MapUnit
XclExpObjectManager(const XclExpRoot &rRoot)
Definition: xeescher.cxx:1763
Reference< XModel > xModel
sal_uInt32 mnStrmSize
Start position in 'Ctls' stream.
Definition: xeescher.hxx:241
XclExpDffSheetAnchor(const XclExpRoot &rRoot)
Definition: xeescher.cxx:283
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
#define DEFLRINS
XclExpDffNoteAnchor(const XclExpRoot &rRoot, const tools::Rectangle &rRect)
Definition: xeescher.cxx:322
XclExpMsoDrawing(XclEscherEx &rEscherEx)
Definition: xeescher.cxx:383
#define ESCHER_Prop_fPrint
const XclExpRoot & GetRoot() const
Returns the filter root data.
Definition: xestream.hxx:87
virtual ~XclMacroHelper() override
Definition: xeescher.cxx:1636
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
Definition: convuno.hxx:79
virtual void WriteSubRecs(XclExpStream &rStrm) override
Definition: xeescher.cxx:920
Area in a chart.
Definition: xestyle.hxx:53
const sal_uInt16 EXC_OBJTYPE_PICTURE
Definition: xlescher.hxx:57
void WriteMacroSubRec(XclExpStream &rStrm)
Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present.
Definition: xeescher.cxx:1640
bool IsEmpty() const
Definition: xerecord.hxx:325
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: xerecord.cxx:150
Chart source ranges.
Definition: xlformula.hxx:168
const char * UseIf(const char *s, bool bUse)
XclExpFontBuffer & GetFontBuffer() const
Returns the font buffer.
Definition: xeroot.cxx:111
const sal_uInt16 EXC_OBJ_SCROLLBAR_MIN
Definition: xlescher.hxx:179
XclExpChartObj(XclExpObjectManager &rObjMgr, css::uno::Reference< css::drawing::XShape > const &xShape, const tools::Rectangle *pChildAnchor, ScDocument *pDoc)
Definition: xeescher.cxx:1353
XclExpEmbeddedObjectManager(const XclExpObjectManager &rParent, const Size &rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY)
Definition: xeescher.cxx:1863
bool GetProperty(Type &rValue, const OUString &rPropName) const
Gets the specified property from the property set.
Definition: fapihelper.hxx:148
const sal_uInt16 EXC_ID_OBJMACRO
End of OBJ.
Definition: xlescher.hxx:207
XclExpString maAuthor
Definition: xeescher.hxx:365
const sal_uInt16 EXC_OBJTYPE_BUTTON
Definition: xlescher.hxx:56
XclExpMsoDrawing * GetMsodrawingPerSheet()
Definition: xeescher.cxx:1825
Helper class for form controls to manage spreadsheet links .
Definition: xeescher.hxx:163
bool mbLocked
Auto scale text.
Definition: xeescher.hxx:374
tools::Long Right() const
SdrTextVertAdjust
const sal_uInt16 EXC_OBJTYPE_OPTIONBUTTON
Definition: xlescher.hxx:60
ScfInt16Vec maMultiSel
Definition: xeescher.hxx:276
bool ConvertAddress(XclAddress &rXclPos, const ScAddress &rScPos, bool bWarn)
Converts the passed Calc cell address to an Excel cell address.
Definition: xehelper.cxx:186
XclTokenArrayRef mxCellLink
Definition: xeescher.hxx:187
const Graphic maGraphic
sal_uInt16 AddObj(std::unique_ptr< XclObj > pObjRec)
Definition: xeescher.cxx:1835
All text objects in charts.
Definition: xlstyle.hxx:398
const sal_uInt16 EXC_ID_OBJCF
Group marker.
Definition: xlescher.hxx:210
Base class for single records with any content.
Definition: xerecord.hxx:141
sal_Int16 SCTAB
Definition: types.hxx:22
#define ESCHER_Prop_lTxid
EscherGraphicProvider & GetGraphicProvider()
void SetRect(const XclRoot &rRoot, SCTAB nScTab, const tools::Rectangle &rRect, MapUnit eMapUnit)
Initializes the anchor coordinates for a sheet.
Definition: xlescher.cxx:154
#define ESCHER_ClientData
XclExpMsoDrawingBase(XclEscherEx &rEscherEx, sal_uInt16 nRecId)
Definition: xeescher.cxx:339
SDRTEXTVERTADJUST_CENTER
static css::uno::Reference< css::awt::XControlModel > GetControlModel(css::uno::Reference< css::drawing::XShape > const &xShape)
Returns the API control model from the passed API shape object.
Definition: xlescher.cxx:282
void WriteZeroBytes(std::size_t nBytes)
Writes a sequence of nBytes zero bytes (respects slice setting).
Definition: xestream.cxx:257
OUString maName
Definition: xlstyle.hxx:287
bool mbColHidden
Auto Fill Style.
Definition: xeescher.hxx:376