LibreOffice Module oox (master)  1
vmlshape.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 <algorithm>
21 
22 #include <optional>
23 
24 #include <o3tl/safeint.hxx>
25 #include <oox/vml/vmlshape.hxx>
26 #include <vcl/wmfexternal.hxx>
27 
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
30 #include <com/sun/star/drawing/FillStyle.hpp>
31 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
32 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
33 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
34 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
35 #include <com/sun/star/drawing/XShapes.hpp>
36 #include <com/sun/star/drawing/XControlShape.hpp>
37 #include <com/sun/star/graphic/XGraphic.hpp>
38 #include <com/sun/star/table/BorderLine2.hpp>
39 #include <com/sun/star/text/HoriOrientation.hpp>
40 #include <com/sun/star/text/RelOrientation.hpp>
41 #include <com/sun/star/text/SizeType.hpp>
42 #include <com/sun/star/text/VertOrientation.hpp>
43 #include <com/sun/star/text/WrapTextMode.hpp>
44 #include <com/sun/star/lang/XServiceInfo.hpp>
45 #include <com/sun/star/text/TextContentAnchorType.hpp>
46 #include <com/sun/star/text/GraphicCrop.hpp>
47 #include <com/sun/star/security/DocumentDigitalSignatures.hpp>
48 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
49 #include <com/sun/star/text/WritingMode2.hpp>
50 #include <com/sun/star/drawing/ColorMode.hpp>
51 #include <sal/log.hxx>
55 #include <oox/ole/axcontrol.hxx>
58 #include <oox/token/properties.hxx>
59 #include <oox/token/tokens.hxx>
60 #include <oox/vml/vmldrawing.hxx>
62 #include <oox/vml/vmltextbox.hxx>
66 #include <svx/sdtagitm.hxx>
67 #include <svx/svdobj.hxx>
68 #include <comphelper/sequence.hxx>
72 #include <o3tl/string_view.hxx>
73 
74 using ::com::sun::star::beans::XPropertySet;
75 using ::com::sun::star::uno::Any;
76 
77 using namespace ::com::sun::star;
78 using namespace ::com::sun::star::text;
79 
80 namespace oox::vml {
81 
82 using namespace ::com::sun::star::drawing;
83 using namespace ::com::sun::star::graphic;
84 using namespace ::com::sun::star::uno;
85 using namespace ::com::sun::star::io;
86 
87 using ::oox::core::XmlFilterBase;
88 
89 namespace {
90 
91 const sal_Int32 VML_SHAPETYPE_PICTUREFRAME = 75;
92 const sal_Int32 VML_SHAPETYPE_HOSTCONTROL = 201;
93 
94 awt::Point lclGetAbsPoint( const awt::Point& rRelPoint, const awt::Rectangle& rShapeRect, const awt::Rectangle& rCoordSys )
95 {
96  double fWidthRatio = static_cast< double >( rShapeRect.Width ) / rCoordSys.Width;
97  double fHeightRatio = static_cast< double >( rShapeRect.Height ) / rCoordSys.Height;
98  awt::Point aAbsPoint;
99  aAbsPoint.X = static_cast< sal_Int32 >( rShapeRect.X + fWidthRatio * (rRelPoint.X - rCoordSys.X) + 0.5 );
100  aAbsPoint.Y = static_cast< sal_Int32 >( rShapeRect.Y + fHeightRatio * (rRelPoint.Y - rCoordSys.Y) + 0.5 );
101  return aAbsPoint;
102 }
103 
104 awt::Rectangle lclGetAbsRect( const awt::Rectangle& rRelRect, const awt::Rectangle& rShapeRect, const awt::Rectangle& rCoordSys )
105 {
106  double fWidthRatio = static_cast< double >( rShapeRect.Width ) / rCoordSys.Width;
107  double fHeightRatio = static_cast< double >( rShapeRect.Height ) / rCoordSys.Height;
108  awt::Rectangle aAbsRect;
109  aAbsRect.X = static_cast< sal_Int32 >( rShapeRect.X + fWidthRatio * (rRelRect.X - rCoordSys.X) + 0.5 );
110  aAbsRect.Y = static_cast< sal_Int32 >( rShapeRect.Y + fHeightRatio * (rRelRect.Y - rCoordSys.Y) + 0.5 );
111  aAbsRect.Width = static_cast< sal_Int32 >( fWidthRatio * rRelRect.Width + 0.5 );
112  aAbsRect.Height = static_cast< sal_Int32 >( fHeightRatio * rRelRect.Height + 0.5 );
113  return aAbsRect;
114 }
115 
117 sal_Int32 lclConvertCrop(const OUString& rCrop, sal_uInt32 nSize)
118 {
119  if (rCrop.endsWith("f"))
120  {
121  // Numeric value is specified in 1/65536-ths.
122  sal_uInt32 nCrop = o3tl::toUInt32(rCrop.subView(0, rCrop.getLength() - 1));
123  return (nCrop * nSize) / 65536;
124  }
125 
126  return 0;
127 }
128 
129 } // namespace
130 
132  mbAutoHeight( false ),
133  mbVisible( true )
134 {
135 }
136 
138 {
142  /* The style properties position, left, top, width, height, margin-left,
143  margin-top are not derived from shape template to shape. */
148 }
149 
151  mrDrawing( rDrawing )
152 {
153 }
154 
156 {
157 }
158 
159 sal_Int32 ShapeType::getShapeType() const
160 {
161  return maTypeModel.moShapeType.get( 0 );
162 }
163 
165 {
166  return maTypeModel.moGraphicPath.get( OUString() );
167 }
168 
169 awt::Rectangle ShapeType::getCoordSystem() const
170 {
171  Int32Pair aCoordPos = maTypeModel.moCoordPos.get( Int32Pair( 0, 0 ) );
172  Int32Pair aCoordSize = maTypeModel.moCoordSize.get( Int32Pair( 1000, 1000 ) );
173  if( aCoordSize.first == 0 )
174  aCoordSize.first = 1;
175  if( aCoordSize.second == 0 )
176  aCoordSize.second = 1;
177  return awt::Rectangle( aCoordPos.first, aCoordPos.second, aCoordSize.first, aCoordSize.second );
178 }
179 
180 awt::Rectangle ShapeType::getRectangle( const ShapeParentAnchor* pParentAnchor ) const
181 {
182  return pParentAnchor ?
183  lclGetAbsRect( getRelRectangle(), pParentAnchor->maShapeRect, pParentAnchor->maCoordSys ) :
184  getAbsRectangle();
185 }
186 
187 awt::Rectangle ShapeType::getAbsRectangle() const
188 {
189  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
190 
191  sal_Int32 nWidth = ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maWidth, 0, true, true );
192  if ( nWidth == 0 )
193  nWidth = 1;
194 
195  sal_Int32 nHeight = ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maHeight, 0, false, true );
196  if ( nHeight == 0 )
197  nHeight = 1;
198 
199  sal_Int32 nLeft;
200  if (o3tl::checked_add<sal_Int32>(ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maLeft, 0, true, true),
201  ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maMarginLeft, 0, true, true),
202  nLeft))
203  {
204  SAL_WARN("oox", "overflow in addition");
205  nLeft = 0;
206  }
207  if (nLeft == 0 && maTypeModel.maPosition == "absolute")
208  nLeft = 1;
209 
210  return awt::Rectangle(
211  nLeft,
212  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maTop, 0, false, true ) + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maMarginTop, 0, false, true ),
213  nWidth, nHeight );
214 }
215 
216 awt::Rectangle ShapeType::getRelRectangle() const
217 {
218  sal_Int32 nWidth = maTypeModel.maWidth.toInt32();
219  if ( nWidth == 0 )
220  nWidth = 1;
221 
222  sal_Int32 nHeight = maTypeModel.maHeight.toInt32();
223  if ( nHeight == 0 )
224  nHeight = 1;
225 
226  return awt::Rectangle(
227  maTypeModel.maLeft.toInt32(),
228  maTypeModel.maTop.toInt32(),
229  nWidth, nHeight );
230 }
231 
233  mnObjType( XML_TOKEN_INVALID ),
234  mnTextHAlign( XML_Left ),
235  mnTextVAlign( XML_Top ),
236  mnCol( -1 ),
237  mnRow( -1 ),
238  mnChecked( VML_CLIENTDATA_UNCHECKED ),
239  mnDropStyle( XML_Combo ),
240  mnDropLines( 1 ),
241  mnVal( 0 ),
242  mnMin( 0 ),
243  mnMax( 0 ),
244  mnInc( 0 ),
245  mnPage( 0 ),
246  mnSelType( XML_Single ),
247  mnVTEdit( VML_CLIENTDATA_TEXT ),
248  mbPrintObject( true ),
249  mbVisible( false ),
250  mbDde( false ),
251  mbNo3D( false ),
252  mbNo3D2( false ),
253  mbMultiLine( false ),
254  mbVScroll( false ),
255  mbSecretEdit( false )
256 {
257 }
258 
260  : mbIsSignatureLine(false)
261  , mbSignatureLineShowSignDate(true)
262  , mbSignatureLineCanAddComment(false)
263  , mbInGroup(false)
264 {
265 }
266 
268 {
269 }
270 
272 {
273  mxTextBox.reset( new TextBox(rModel) );
274  return *mxTextBox;
275 }
276 
278 {
279  mxClientData.reset( new ClientData );
280  return *mxClientData;
281 }
282 
284  ShapeType( rDrawing )
285 {
286 }
287 
289 {
290  if( maShapeModel.maType.getLength() <= 1 )
291  return;
292 
293  OUString aType = maShapeModel.maType;
294  if (aType[ 0 ] == '#')
295  aType = aType.copy(1);
296  if( const ShapeType* pShapeType = mrDrawing.getShapes().getShapeTypeById( aType ) )
297  {
298  // Make sure that the props from maTypeModel have priority over the props from
299  // the shape type.
300  StrokeModel aMergedStrokeModel;
301  aMergedStrokeModel.assignUsed(pShapeType->getTypeModel().maStrokeModel);
302  aMergedStrokeModel.assignUsed(maTypeModel.maStrokeModel);
303  FillModel aMergedFillModel;
304  aMergedFillModel.assignUsed(pShapeType->getTypeModel().maFillModel);
305  aMergedFillModel.assignUsed(maTypeModel.maFillModel);
306 
307  maTypeModel.assignUsed( pShapeType->getTypeModel() );
308  maTypeModel.maStrokeModel = aMergedStrokeModel;
309  maTypeModel.maFillModel = aMergedFillModel;
310  }
311  else {
312  // Temporary fix, shapetype not found if referenced from different substream
313  // FIXME: extend scope of ShapeContainer to store all shapetypes from the document
314  static const OUStringLiteral sShapeTypePrefix = u"shapetype_";
315  OUString tmp;
316  if (aType.startsWith(sShapeTypePrefix)) {
317  maTypeModel.moShapeType = o3tl::toInt32(aType.subView(sShapeTypePrefix.getLength()));
318  }
319  else if (aType.startsWith("_x0000_t", &tmp)) {
320  maTypeModel.moShapeType = tmp.toInt32();
321  }
322  }
323 }
324 
325 OUString ShapeBase::getShapeName() const
326 {
327  if( !maTypeModel.maShapeName.isEmpty() )
328  return maTypeModel.maShapeName;
329 
330  OUString aBaseName = mrDrawing.getShapeBaseName( *this );
331  if( !aBaseName.isEmpty() )
332  {
333  sal_Int32 nShapeIdx = mrDrawing.getLocalShapeIndex( getShapeId() );
334  if( nShapeIdx > 0 )
335  return aBaseName + OUStringChar(' ') + OUString::number( nShapeIdx );
336  }
337 
338  return OUString();
339 }
340 
341 const ShapeType* ShapeBase::getChildTypeById( const OUString& ) const
342 {
343  return nullptr;
344 }
345 
346 const ShapeBase* ShapeBase::getChildById( const OUString& ) const
347 {
348  return nullptr;
349 }
350 
351 Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxShapes, const ShapeParentAnchor* pParentAnchor ) const
352 {
353  Reference< XShape > xShape;
354  if( mrDrawing.isShapeSupported( *this ) )
355  {
356  /* Calculate shape rectangle. Applications may do something special
357  according to some imported shape client data (e.g. Excel cell anchor). */
358  awt::Rectangle aShapeRect = calcShapeRectangle( pParentAnchor );
359 
360  if( ((aShapeRect.Width > 0) || (aShapeRect.Height > 0)) && rxShapes.is() )
361  {
362  xShape = implConvertAndInsert( rxShapes, aShapeRect );
363  if( xShape.is() )
364  {
365  // set imported or generated shape name (not supported by form controls)
366  PropertySet aShapeProp( xShape );
367  if( aShapeProp.hasProperty( PROP_Name ) )
368  aShapeProp.setProperty( PROP_Name, getShapeName() );
369  uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW );
370 
371  OUString sLinkChainName = getTypeModel().maLegacyId;
372  sal_Int32 id = 0;
373  sal_Int32 idPos = sLinkChainName.indexOf("_x");
374  sal_Int32 seq = 0;
375  if (idPos >= 0)
376  {
377  sal_Int32 seqPos = sLinkChainName.indexOf("_s",idPos);
378  if (idPos < seqPos)
379  {
380  auto idPosEnd = idPos+2;
381  id = o3tl::toInt32(sLinkChainName.subView(idPosEnd, seqPos - idPosEnd));
382  seq = o3tl::toInt32(sLinkChainName.subView(seqPos+2));
383  }
384  }
385 
386  OUString s_mso_next_textbox;
387  if( getTextBox() )
388  s_mso_next_textbox = getTextBox()->msNextTextbox;
389  if( s_mso_next_textbox.startsWith("#") )
390  s_mso_next_textbox = s_mso_next_textbox.copy(1);
391 
392  if (xSInfo->supportsService("com.sun.star.text.TextFrame"))
393  {
394  uno::Reference<beans::XPropertySet> propertySet (xShape, uno::UNO_QUERY);
395  uno::Any aAny = propertySet->getPropertyValue("FrameInteropGrabBag");
396  auto aGrabBag = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aAny.get< uno::Sequence<beans::PropertyValue> >());
397 
398  aGrabBag.push_back(comphelper::makePropertyValue("VML-Z-ORDER", maTypeModel.maZIndex.toInt32()));
399 
400  if( !s_mso_next_textbox.isEmpty() )
401  aGrabBag.push_back(comphelper::makePropertyValue("mso-next-textbox", s_mso_next_textbox));
402 
403  if( !sLinkChainName.isEmpty() )
404  {
405  aGrabBag.push_back(comphelper::makePropertyValue("TxbxHasLink", true));
406  aGrabBag.push_back(comphelper::makePropertyValue("Txbx-Id", id));
407  aGrabBag.push_back(comphelper::makePropertyValue("Txbx-Seq", seq));
408  aGrabBag.push_back(comphelper::makePropertyValue("LinkChainName", sLinkChainName));
409  }
410 
411  if(!maTypeModel.maRotation.isEmpty())
412  aGrabBag.push_back(comphelper::makePropertyValue("mso-rotation-angle", ConversionHelper::decodeRotation(maTypeModel.maRotation).get()));
413  propertySet->setPropertyValue("FrameInteropGrabBag", uno::Any(comphelper::containerToSequence(aGrabBag)));
414  sal_Int32 backColorTransparency = 0;
415  propertySet->getPropertyValue("BackColorTransparency")
416  >>= backColorTransparency;
417  if (propertySet->getPropertyValue("FillStyle") == FillStyle_NONE &&
418  backColorTransparency == 100)
419  {
420  // If there is no fill, the Word default is 100% transparency.
421  propertySet->setPropertyValue("FillTransparence", Any(sal_Int16(100)));
422  }
423  }
424  else
425  {
426  if( maTypeModel.maZIndex.toInt32() )
427  {
428  uno::Sequence<beans::PropertyValue> aGrabBag;
429  uno::Reference<beans::XPropertySet> propertySet (xShape, uno::UNO_QUERY);
430  propertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
431  sal_Int32 length;
432 
433  length = aGrabBag.getLength();
434  aGrabBag.realloc( length+1 );
435  auto pGrabBag = aGrabBag.getArray();
436  pGrabBag[length].Name = "VML-Z-ORDER";
437  pGrabBag[length].Value <<= maTypeModel.maZIndex.toInt32();
438 
439  if( !s_mso_next_textbox.isEmpty() )
440  {
441  length = aGrabBag.getLength();
442  aGrabBag.realloc( length+1 );
443  pGrabBag = aGrabBag.getArray();
444  pGrabBag[length].Name = "mso-next-textbox";
445  pGrabBag[length].Value <<= s_mso_next_textbox;
446  }
447 
448  if( !sLinkChainName.isEmpty() )
449  {
450  length = aGrabBag.getLength();
451  aGrabBag.realloc( length+4 );
452  pGrabBag = aGrabBag.getArray();
453  pGrabBag[length].Name = "TxbxHasLink";
454  pGrabBag[length].Value <<= true;
455  pGrabBag[length+1].Name = "Txbx-Id";
456  pGrabBag[length+1].Value <<= id;
457  pGrabBag[length+2].Name = "Txbx-Seq";
458  pGrabBag[length+2].Value <<= seq;
459  pGrabBag[length+3].Name = "LinkChainName";
460  pGrabBag[length+3].Value <<= sLinkChainName;
461  }
462  propertySet->setPropertyValue( "InteropGrabBag", uno::Any(aGrabBag) );
463  }
464  }
465  Reference< XControlShape > xControlShape( xShape, uno::UNO_QUERY );
466  if ( xControlShape.is() && !getTypeModel().mbVisible )
467  {
468  PropertySet aControlShapeProp( xControlShape->getControl() );
469  aControlShapeProp.setProperty( PROP_EnableVisible, uno::Any( false ) );
470  }
471 
472  xShape = finalImplConvertAndInsert(xShape);
473  /* Notify the drawing that a new shape has been inserted. For
474  convenience, pass the rectangle that contains position and
475  size of the shape. */
476  bool bGroupChild = pParentAnchor != nullptr;
477  mrDrawing.notifyXShapeInserted( xShape, aShapeRect, *this, bGroupChild );
478  }
479  }
480  else
481  SAL_WARN("oox", "not converting shape, as calculated rectangle is empty");
482  }
483  return xShape;
484 }
485 
486 void ShapeBase::convertFormatting( const Reference< XShape >& rxShape ) const
487 {
488  if( !rxShape.is() )
489  return;
490 
491  /* Calculate shape rectangle. Applications may do something special
492  according to some imported shape client data (e.g. Excel cell anchor). */
493  awt::Rectangle aShapeRect = calcShapeRectangle( nullptr );
494 
495  // convert the shape, if the calculated rectangle is not empty
496  if( (aShapeRect.Width > 0) || (aShapeRect.Height > 0) )
497  {
498  rxShape->setPosition( awt::Point( aShapeRect.X, aShapeRect.Y ) );
499  rxShape->setSize( awt::Size( aShapeRect.Width, aShapeRect.Height ) );
500  convertShapeProperties( rxShape );
501  }
502 }
503 
504 void ShapeBase::setContainer(ShapeContainer* pContainer) { mpContainer = pContainer; }
505 
507 
508 // protected ------------------------------------------------------------------
509 
510 awt::Rectangle ShapeBase::calcShapeRectangle( const ShapeParentAnchor* pParentAnchor ) const
511 {
512  /* Calculate shape rectangle. Applications may do something special
513  according to some imported shape client data (e.g. Excel cell anchor). */
514  awt::Rectangle aShapeRect;
515  const ClientData* pClientData = getClientData();
516  if( !pClientData || !mrDrawing.convertClientAnchor( aShapeRect, pClientData->maAnchor ) )
517  aShapeRect = getRectangle( pParentAnchor );
518  return aShapeRect;
519 }
520 
521 void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) const
522 {
524  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
525  maTypeModel.maStrokeModel.pushToPropMap( aPropMap, rGraphicHelper );
526  maTypeModel.maFillModel.pushToPropMap( aPropMap, rGraphicHelper );
527 
528  uno::Reference<lang::XServiceInfo> xSInfo(rxShape, uno::UNO_QUERY_THROW);
529  if (xSInfo->supportsService("com.sun.star.text.TextFrame"))
530  {
531  // Any other service supporting the ShadowFormat property?
532  maTypeModel.maShadowModel.pushToPropMap(aPropMap, rGraphicHelper);
533  // TextFrames have BackColor, not FillColor
534  if (aPropMap.hasProperty(PROP_FillColor))
535  {
536  aPropMap.setAnyProperty(PROP_BackColor, aPropMap.getProperty(PROP_FillColor));
537  aPropMap.erase(PROP_FillColor);
538  }
539  // TextFrames have BackColorTransparency, not FillTransparence
540  if (aPropMap.hasProperty(PROP_FillTransparence))
541  {
542  aPropMap.setAnyProperty(PROP_BackColorTransparency, aPropMap.getProperty(PROP_FillTransparence));
543  aPropMap.erase(PROP_FillTransparence);
544  }
545  // And no LineColor property; individual borders can have colors and widths
546  std::optional<sal_Int32> oLineWidth;
549  rGraphicHelper, maTypeModel.maStrokeModel.moWeight.get(), 0, false, false);
550  if (aPropMap.hasProperty(PROP_LineColor))
551  {
552  uno::Reference<beans::XPropertySet> xPropertySet(rxShape, uno::UNO_QUERY);
553  static const sal_Int32 aBorders[] = {
554  PROP_TopBorder, PROP_LeftBorder, PROP_BottomBorder, PROP_RightBorder
555  };
556  for (sal_Int32 nBorder : aBorders)
557  {
558  table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(PropertyMap::getPropertyName(nBorder)).get<table::BorderLine2>();
559  aBorderLine.Color = aPropMap.getProperty(PROP_LineColor).get<sal_Int32>();
560  if (oLineWidth)
561  aBorderLine.LineWidth = *oLineWidth;
562  aPropMap.setProperty(nBorder, aBorderLine);
563  }
564  aPropMap.erase(PROP_LineColor);
565  }
566  }
567  else if (xSInfo->supportsService("com.sun.star.drawing.CustomShape"))
568  maTypeModel.maTextpathModel.pushToPropMap(aPropMap, rxShape, rGraphicHelper);
569 
570  PropertySet( rxShape ).setProperties( aPropMap );
571 }
572 
573 SimpleShape::SimpleShape( Drawing& rDrawing, const OUString& rService ) :
574  ShapeBase( rDrawing ),
575  maService( rService )
576 {
577 }
578 
579 static void lcl_setSurround(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel, const GraphicHelper& rGraphicHelper)
580 {
581  OUString aWrapType = rTypeModel.moWrapType.get();
582 
583  // Extreme negative top margin? Then the shape will end up at the top of the page, it's pointless to perform any kind of wrapping.
584  sal_Int32 nMarginTop = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, rTypeModel.maMarginTop, 0, false, true);
585  if (nMarginTop < -35277) // Less than 1000 points.
586  aWrapType.clear();
587 
588  css::text::WrapTextMode nSurround = css::text::WrapTextMode_THROUGH;
589  if ( aWrapType == "square" || aWrapType == "tight" ||
590  aWrapType == "through" )
591  {
592  nSurround = css::text::WrapTextMode_PARALLEL;
593  if ( rTypeModel.moWrapSide.get() == "left" )
594  nSurround = css::text::WrapTextMode_LEFT;
595  else if ( rTypeModel.moWrapSide.get() == "right" )
596  nSurround = css::text::WrapTextMode_RIGHT;
597  }
598  else if ( aWrapType == "topAndBottom" )
599  nSurround = css::text::WrapTextMode_NONE;
600 
601  rPropSet.setProperty(PROP_Surround, static_cast<sal_Int32>(nSurround));
602  rPropSet.setProperty(PROP_SurroundContour, aWrapType == "tight");
603 }
604 
605 static void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel, const GraphicHelper& rGraphicHelper)
606 {
607  if ( rTypeModel.maPosition == "absolute" )
608  {
609  // Word supports as-character (inline) and at-character only, absolute can't be inline.
610  rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_CHARACTER);
611  // anchor is set after insertion, so reset to NONE
612  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::NONE));
613 
614  if ( rTypeModel.maPositionVerticalRelative == "page" )
615  {
616  rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
617  }
618  else if ( rTypeModel.maPositionVerticalRelative == "margin" )
619  {
620  rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_PRINT_AREA);
621  }
622  else if (rTypeModel.maPositionVerticalRelative == "top-margin-area")
623  {
624  rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_PRINT_AREA_TOP);
625  }
626  else if (rTypeModel.maPositionVerticalRelative == "bottom-margin-area")
627  {
628  rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_PRINT_AREA_BOTTOM);
629  }
630  else
631  {
632  rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::FRAME);
633  }
634  }
635  else if( rTypeModel.maPosition == "relative" )
636  { // I'm not very sure this is correct either.
637  rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PARAGRAPH);
638  // anchor is set after insertion, so reset to NONE
639  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::NONE));
640  }
641  else // static (is the default) means anchored inline
642  {
643  rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AS_CHARACTER);
644  // Use top orientation, this one seems similar to what MSO uses as inline
645  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::TOP));
646  }
647 
648  if ( rTypeModel.maPositionHorizontal == "center" )
649  rPropSet.setAnyProperty(PROP_HoriOrient, Any(text::HoriOrientation::CENTER));
650  else if ( rTypeModel.maPositionHorizontal == "left" )
651  rPropSet.setAnyProperty(PROP_HoriOrient, Any(text::HoriOrientation::LEFT));
652  else if ( rTypeModel.maPositionHorizontal == "right" )
653  rPropSet.setAnyProperty(PROP_HoriOrient, Any(text::HoriOrientation::RIGHT));
654  else if ( rTypeModel.maPositionHorizontal == "inside" )
655  {
656  rPropSet.setAnyProperty(PROP_HoriOrient, Any(text::HoriOrientation::LEFT));
657  rPropSet.setAnyProperty(PROP_PageToggle, Any(true));
658  }
659  else if ( rTypeModel.maPositionHorizontal == "outside" )
660  {
661  rPropSet.setAnyProperty(PROP_HoriOrient, Any(text::HoriOrientation::RIGHT));
662  rPropSet.setAnyProperty(PROP_PageToggle, Any(true));
663  }
664 
665  if ( rTypeModel.maPositionHorizontalRelative == "page" )
666  rPropSet.setAnyProperty(PROP_HoriOrientRelation, Any(text::RelOrientation::PAGE_FRAME));
667  else if ( rTypeModel.maPositionHorizontalRelative == "margin" )
668  rPropSet.setProperty(PROP_HoriOrientRelation, text::RelOrientation::PAGE_PRINT_AREA);
669  else if (rTypeModel.maPositionHorizontalRelative == "right-margin-area" ||
670  rTypeModel.maPositionHorizontalRelative == "inner-margin-area")
671  rPropSet.setProperty(PROP_HoriOrientRelation, text::RelOrientation::PAGE_RIGHT);
672  else if (rTypeModel.maPositionHorizontalRelative == "left-margin-area" ||
673  rTypeModel.maPositionHorizontalRelative == "outer-margin-area")
674  rPropSet.setProperty(PROP_HoriOrientRelation, text::RelOrientation::PAGE_LEFT);
675  else if ( rTypeModel.maPositionHorizontalRelative == "text" )
676  rPropSet.setProperty(PROP_HoriOrientRelation, text::RelOrientation::FRAME);
677 
678  if ( rTypeModel.maPositionVertical == "center" )
679  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::CENTER));
680  else if ( rTypeModel.maPositionVertical == "top" )
681  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::TOP));
682  else if ( rTypeModel.maPositionVertical == "bottom" )
683  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::BOTTOM));
684  else if ( rTypeModel.maPositionVertical == "inside" )
685  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::TOP));
686  else if ( rTypeModel.maPositionVertical == "outside" )
687  rPropSet.setAnyProperty(PROP_VertOrient, Any(text::VertOrientation::BOTTOM));
688 
689  lcl_setSurround( rPropSet, rTypeModel, rGraphicHelper );
690 }
691 
692 Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
693 {
694  awt::Rectangle aShapeRect(rShapeRect);
695  std::optional<Degree100> oRotation;
696  bool bFlipX = false, bFlipY = false;
697  // tdf#137765: skip this rotation for line shapes
698  if (!maTypeModel.maRotation.isEmpty() && maService != "com.sun.star.drawing.LineShape")
700  if (!maTypeModel.maFlip.isEmpty())
701  {
702  if (maTypeModel.maFlip.startsWith("x"))
703  {
704  bFlipX = true;
705  }
706  if (maTypeModel.maFlip.endsWith("y"))
707  {
708  bFlipY = true;
709  }
710  }
711 
712  Reference< XShape > xShape = mrDrawing.createAndInsertXShape( maService, rxShapes, aShapeRect );
714  if( pShape && getShapeType() >= 0 )
715  {
716  OUString aShapeType = EnhancedCustomShapeTypeNames::Get( static_cast< MSO_SPT >(getShapeType()) );
717  //The resize autoshape to fit text attr of FontWork/Word-Art should always be false
718  //for the fallback geometry.
719  if(aShapeType.startsWith("fontwork"))
720  {
723  }
724  }
725  convertShapeProperties( xShape );
726 
727  // Handle left/right/top/bottom wrap distance.
728  // Default value of mso-wrap-distance-left/right is supposed to be 0 (see
729  // 19.1.2.19 of the VML spec), but Word implements a non-zero value.
730  // [MS-ODRAW] says the below default value in 2.3.4.9.
731  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
732  OUString aWrapDistanceLeft = OUString::number(0x0001BE7C);
733  if (!maTypeModel.maWrapDistanceLeft.isEmpty())
734  aWrapDistanceLeft = maTypeModel.maWrapDistanceLeft;
735  sal_Int32 nWrapDistanceLeft = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, aWrapDistanceLeft, 0, true, false);
736  PropertySet(xShape).setAnyProperty(PROP_LeftMargin, uno::Any(nWrapDistanceLeft));
737  OUString aWrapDistanceRight = OUString::number(0x0001BE7C);
738  if (!maTypeModel.maWrapDistanceRight.isEmpty())
739  aWrapDistanceRight = maTypeModel.maWrapDistanceRight;
740  sal_Int32 nWrapDistanceRight = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, aWrapDistanceRight, 0, true, false);
741  PropertySet(xShape).setAnyProperty(PROP_RightMargin, uno::Any(nWrapDistanceRight));
742  sal_Int32 nWrapDistanceTop = 0;
743  if (!maTypeModel.maWrapDistanceTop.isEmpty())
744  nWrapDistanceTop = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceTop, 0, false, true);
745  PropertySet(xShape).setAnyProperty(PROP_TopMargin, uno::Any(nWrapDistanceTop));
746  sal_Int32 nWrapDistanceBottom = 0;
747  if (!maTypeModel.maWrapDistanceBottom.isEmpty())
748  nWrapDistanceBottom = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceBottom, 0, false, true);
749  PropertySet(xShape).setAnyProperty(PROP_BottomMargin, uno::Any(nWrapDistanceBottom));
750 
751  if ( maService == "com.sun.star.text.TextFrame" )
752  {
753  PropertySet( xShape ).setAnyProperty( PROP_FrameIsAutomaticHeight, Any( maTypeModel.mbAutoHeight ) );
754  PropertySet( xShape ).setAnyProperty( PROP_SizeType, Any( maTypeModel.mbAutoHeight ? SizeType::MIN : SizeType::FIX ) );
755  if( getTextBox()->borderDistanceSet )
756  {
757  PropertySet( xShape ).setAnyProperty( PROP_LeftBorderDistance, Any( sal_Int32( getTextBox()->borderDistanceLeft )));
758  PropertySet( xShape ).setAnyProperty( PROP_TopBorderDistance, Any( sal_Int32( getTextBox()->borderDistanceTop )));
759  PropertySet( xShape ).setAnyProperty( PROP_RightBorderDistance, Any( sal_Int32( getTextBox()->borderDistanceRight )));
760  PropertySet( xShape ).setAnyProperty( PROP_BottomBorderDistance, Any( sal_Int32( getTextBox()->borderDistanceBottom )));
761  }
762 
763  sal_Int16 nWritingMode = text::WritingMode2::LR_TB;
764  if (getTextBox()->maLayoutFlow == "vertical" && maTypeModel.maLayoutFlowAlt.isEmpty())
765  {
766  nWritingMode = text::WritingMode2::TB_RL;
767  }
768  else if (maTypeModel.maLayoutFlowAlt == "bottom-to-top")
769  {
770  nWritingMode = text::WritingMode2::BT_LR;
771  }
772  if (nWritingMode != text::WritingMode2::LR_TB)
773  {
774  PropertySet(xShape).setAnyProperty(PROP_WritingMode, uno::Any(nWritingMode));
775  }
776  // tdf#123626
777  if (!maShapeModel.maHyperlink.isEmpty())
778  PropertySet(xShape).setAnyProperty(PROP_HyperLinkURL, Any(maShapeModel.maHyperlink));
779  }
780  else
781  {
782  // FIXME Setting the relative width/height only for everything but text frames as
783  // TextFrames already have relative width/height feature... but currently not working
784  // in the way we need.
785 
786  // Set the relative width / height if any
787  if ( !maTypeModel.maWidthPercent.isEmpty( ) )
788  {
789  // Only page-relative width is supported ATM
790  if ( maTypeModel.maWidthRelative.isEmpty() || maTypeModel.maWidthRelative == "page" )
791  {
792  sal_Int16 nWidth = maTypeModel.maWidthPercent.toInt32() / 10;
793  // Only apply if nWidth != 0
794  if ( nWidth )
795  PropertySet( xShape ).setAnyProperty(PROP_RelativeWidth, Any( nWidth ) );
796  }
797  }
798  if ( !maTypeModel.maHeightPercent.isEmpty( ) )
799  {
800  // Only page-relative height is supported ATM
801  if ( maTypeModel.maHeightRelative.isEmpty() || maTypeModel.maHeightRelative == "page" )
802  {
803  sal_Int16 nHeight = maTypeModel.maHeightPercent.toInt32() / 10;
804  // Only apply if nHeight != 0
805  if ( nHeight )
806  PropertySet( xShape ).setAnyProperty(PROP_RelativeHeight, Any( nHeight ) );
807  }
808  }
809 
810  // drawinglayer default is center, MSO default is top.
811  drawing::TextVerticalAdjust eTextVerticalAdjust = drawing::TextVerticalAdjust_TOP;
812  if (maTypeModel.maVTextAnchor == "middle")
813  eTextVerticalAdjust = drawing::TextVerticalAdjust_CENTER;
814  else if (maTypeModel.maVTextAnchor == "bottom")
815  eTextVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM;
816  PropertySet(xShape).setAnyProperty(PROP_TextVerticalAdjust, Any(eTextVerticalAdjust));
817 
818  // tdf#97618
819  if(!maTypeModel.maWrapStyle.isEmpty())
820  PropertySet(xShape).setAnyProperty(PROP_TextWordWrap, Any(maTypeModel.maWrapStyle == "square"));
821 
822  // tdf#123626
823  if (!maShapeModel.maHyperlink.isEmpty())
824  PropertySet(xShape).setAnyProperty(PROP_Hyperlink, Any(maShapeModel.maHyperlink));
825 
826  PropertySet(xShape).setAnyProperty(PROP_TextAutoGrowHeight,
828 
829  if (getTextBox())
830  {
831  getTextBox()->convert(xShape);
832  if (getTextBox()->borderDistanceSet)
833  {
834  awt::Size aSize = xShape->getSize();
835  PropertySet(xShape).setAnyProperty(PROP_TextLeftDistance, Any(sal_Int32(getTextBox()->borderDistanceLeft)));
836  PropertySet(xShape).setAnyProperty(PROP_TextUpperDistance, Any(sal_Int32(getTextBox()->borderDistanceTop)));
837  PropertySet(xShape).setAnyProperty(PROP_TextRightDistance, Any(sal_Int32(getTextBox()->borderDistanceRight)));
838  PropertySet(xShape).setAnyProperty(PROP_TextLowerDistance, Any(sal_Int32(getTextBox()->borderDistanceBottom)));
839  xShape->setSize(aSize);
840  }
841  }
842  }
843 
844  // Import Legacy Fragments (if any)
845  if( xShape.is() && !maShapeModel.maLegacyDiagramPath.isEmpty() )
846  {
848  if( xInStrm.is() )
849  PropertySet( xShape ).setProperty( PROP_LegacyFragment, xInStrm );
850  }
851 
852  PropertySet aPropertySet(xShape);
853  if (xShape.is())
854  {
855  if (oRotation)
856  {
857  aPropertySet.setAnyProperty(PROP_RotateAngle, Any((*oRotation).get()));
858  uno::Reference<lang::XServiceInfo> xServiceInfo(rxShapes, uno::UNO_QUERY);
859  if (!xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
860  {
861  // If rotation is used, simple setPosition() is not enough.
862  aPropertySet.setAnyProperty(PROP_HoriOrientPosition, Any(aShapeRect.X));
863  aPropertySet.setAnyProperty(PROP_VertOrientPosition, Any(aShapeRect.Y));
864  }
865  }
866 
867  // custom shape geometry attributes
868  std::vector<css::beans::PropertyValue> aPropVec;
869 
870  // When flip has 'x' or 'y', the associated ShapeRect will be changed but direction change doesn't occur.
871  // It might occur internally in SdrObject of "sw" module, not here.
872  // The associated properties "PROP_MirroredX" and "PROP_MirroredY" have to be set here so that direction change will occur internally.
873  if (bFlipX)
874  aPropVec.push_back(comphelper::makePropertyValue("MirroredX", true));
875  if (bFlipY)
876  aPropVec.push_back(comphelper::makePropertyValue("MirroredY", true));
877 
878  if (!maTypeModel.maAdjustments.isEmpty())
879  {
880  std::vector<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentValues;
881  sal_Int32 nIndex = 0;
882  do
883  {
884  std::u16string_view aToken = o3tl::getToken(maTypeModel.maAdjustments, 0, ',', nIndex);
885  drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue;
886  if (aToken.empty())
887  aAdjustmentValue.State = css::beans::PropertyState::PropertyState_DEFAULT_VALUE;
888  else
889  aAdjustmentValue.Value <<= o3tl::toInt32(aToken);
890  aAdjustmentValues.push_back(aAdjustmentValue);
891  } while (nIndex >= 0);
892 
893  css::beans::PropertyValue aProp;
894  aProp.Name = "AdjustmentValues";
895  aProp.Value <<= comphelper::containerToSequence(aAdjustmentValues);
896  aPropVec.push_back(aProp);
897  }
898 
899  if (!aPropVec.empty())
900  aPropertySet.setAnyProperty(PROP_CustomShapeGeometry, Any(comphelper::containerToSequence(aPropVec)));
901  }
902 
903  lcl_SetAnchorType(aPropertySet, maTypeModel, rGraphicHelper );
904 
905  return xShape;
906 }
907 
908 Reference<XShape> SimpleShape::finalImplConvertAndInsert(const css::uno::Reference<css::drawing::XShape>& rxShape) const
909 {
910  // tdf#41466 This setting must be done here, because the position of textbox will be set as an
911  // effect of the PROP_TextBox property setting, and if we do this setting earlier (setting of
912  // properties of position and size) then the position of textbox will be set with wrong data.
913  // TODO: TextShape is set if we have rect shape in group; we should use the shape-with-textbox
914  // mechanism to handle this situation
915  if (getTextBox() && maService != "com.sun.star.text.TextFrame" && maService != "com.sun.star.drawing.TextShape"
917  {
918  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
919  const auto& nLeft = ConversionHelper::decodeMeasureToHmm(
920  rGraphicHelper, maTypeModel.maMarginLeft, 0, true, true);
921  PropertySet aPropertySet(rxShape);
922  aPropertySet.setProperty(PROP_HoriOrientPosition, nLeft);
923  const auto& nTop = ConversionHelper::decodeMeasureToHmm(
924  rGraphicHelper, maTypeModel.maMarginTop, 0, true, true);
925  aPropertySet.setProperty(PROP_VertOrientPosition, nTop);
926  aPropertySet.setProperty(PROP_TextBox, true);
927 
928  // And these properties must be set after textbox creation (set PROP_Textbox property).
929  // Note: if you set a new property then you have to handle it in the proper
930  // SwTextBoxHelper::syncProperty function.
931  if (maTypeModel.maLayoutFlowAlt == "bottom-to-top")
932  aPropertySet.setAnyProperty(PROP_TextWritingMode, uno::Any(text::WritingMode2::BT_LR));
933  }
934  return ShapeBase::finalImplConvertAndInsert(rxShape);
935 }
936 Reference< XShape > SimpleShape::createEmbeddedPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const
937 {
938  Reference<XGraphic> xGraphic = mrDrawing.getFilter().getGraphicHelper().importEmbeddedGraphic(rGraphicPath);
939  return SimpleShape::createPictureObject(rxShapes, rShapeRect, xGraphic);
940 }
941 
942 Reference< XShape > SimpleShape::createPictureObject(const Reference< XShapes >& rxShapes,
943  const awt::Rectangle& rShapeRect,
944  uno::Reference<graphic::XGraphic> const & rxGraphic) const
945 {
946  Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect );
947  if( xShape.is() )
948  {
949  PropertySet aPropSet(xShape);
950  if (rxGraphic.is())
951  {
952  aPropSet.setProperty(PROP_Graphic, rxGraphic);
953  }
954  uno::Reference< lang::XServiceInfo > xServiceInfo(rxShapes, uno::UNO_QUERY);
955  // If the shape has an absolute position, set the properties accordingly, unless we're inside a group shape.
956  if ( maTypeModel.maPosition == "absolute" && !xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
957  {
958  aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X);
959  aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
960  aPropSet.setProperty(PROP_Opaque, false);
961  }
962  // fdo#70457: preserve rotation information
963  if ( !maTypeModel.maRotation.isEmpty() )
965 
966  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
967  lcl_SetAnchorType(aPropSet, maTypeModel, rGraphicHelper);
968 
969  const sal_Int32 nWrapDistanceLeft = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceLeft, 0, true, true);
970  const sal_Int32 nWrapDistanceRight = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceRight, 0, true, true);
971  const sal_Int32 nWrapDistanceTop = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceTop, 0, false, true);
972  const sal_Int32 nWrapDistanceBottom = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceBottom, 0, false, true);
973  aPropSet.setProperty(PROP_LeftMargin, uno::Any(nWrapDistanceLeft));
974  aPropSet.setProperty(PROP_RightMargin, uno::Any(nWrapDistanceRight));
975  aPropSet.setProperty(PROP_TopMargin, uno::Any(nWrapDistanceTop));
976  aPropSet.setProperty(PROP_BottomMargin, uno::Any(nWrapDistanceBottom));
977 
979  {
980  text::GraphicCrop aGraphicCrop;
981  awt::Size aOriginalSize = rGraphicHelper.getOriginalSize(rxGraphic);
982 
984  aGraphicCrop.Bottom = lclConvertCrop(maTypeModel.moCropBottom.get(), aOriginalSize.Height);
985  if (maTypeModel.moCropLeft.has())
986  aGraphicCrop.Left = lclConvertCrop(maTypeModel.moCropLeft.get(), aOriginalSize.Width);
988  aGraphicCrop.Right = lclConvertCrop(maTypeModel.moCropRight.get(), aOriginalSize.Width);
989  if (maTypeModel.moCropTop.has())
990  aGraphicCrop.Top = lclConvertCrop(maTypeModel.moCropTop.get(), aOriginalSize.Height);
991 
992  aPropSet.setProperty(PROP_GraphicCrop, aGraphicCrop);
993  }
994 
995  if (maTypeModel.mnGain == -70 && maTypeModel.mnBlacklevel == 70)
996  {
997  // Map MSO 'washout' to our watermark colormode.
998  aPropSet.setProperty(PROP_GraphicColorMode, uno::Any(drawing::ColorMode_WATERMARK));
999  }
1000  }
1001  return xShape;
1002 }
1003 
1005  SimpleShape( rDrawing, "com.sun.star.drawing.RectangleShape" )
1006 {
1007 }
1008 
1009 Reference<XShape> RectangleShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const awt::Rectangle& rShapeRect) const
1010 {
1011  OUString aGraphicPath = getGraphicPath();
1012 
1013  // try to create a picture object
1014  if(!aGraphicPath.isEmpty())
1015  return SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath);
1016 
1017  // default: try to create a rectangle shape
1018  Reference<XShape> xShape = SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
1019  OUString sArcsize = maTypeModel.maArcsize;
1020  if ( !sArcsize.isEmpty( ) )
1021  {
1022  sal_Unicode cLastChar = sArcsize[sArcsize.getLength() - 1];
1023  sal_Int32 nValue = o3tl::toInt32(sArcsize.subView( 0, sArcsize.getLength() - 1 ));
1024  // Get the smallest half-side
1025  double size = std::min( rShapeRect.Height, rShapeRect.Width ) / 2.0;
1026  sal_Int32 nRadius = 0;
1027  if ( cLastChar == 'f' )
1028  nRadius = size * nValue / 65536;
1029  else if ( cLastChar == '%' )
1030  nRadius = size * nValue / 100;
1031  PropertySet( xShape ).setAnyProperty( PROP_CornerRadius, Any( nRadius ) );
1032  }
1033  return xShape;
1034 }
1035 
1037  SimpleShape( rDrawing, "com.sun.star.drawing.EllipseShape" )
1038 {
1039 }
1040 
1042  SimpleShape( rDrawing, "com.sun.star.drawing.PolyLineShape" )
1043 {
1044 }
1045 
1046 Reference< XShape > PolyLineShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
1047 {
1048  ::std::vector<awt::Point> aAbsPoints;
1049  awt::Rectangle aCoordSys = getCoordSystem();
1050  if (!maShapeModel.maPoints.empty() && (aCoordSys.Width > 0) && (aCoordSys.Height > 0))
1051  {
1052  for (auto const& point : maShapeModel.maPoints)
1053  aAbsPoints.push_back(lclGetAbsPoint(point, rShapeRect, aCoordSys));
1054  // A polyline cannot be filled but only a polygon. We treat first point == last point as
1055  // indicator for being closed. In that case we force to type PolyPolygonShape.
1056  if (aAbsPoints.size() > 2 && aAbsPoints.front().X == aAbsPoints.back().X
1057  && aAbsPoints.front().Y == aAbsPoints.back().Y)
1058  {
1059  const_cast<PolyLineShape*>(this)->setService("com.sun.star.drawing.PolyPolygonShape");
1060  }
1061  }
1062 
1063  Reference<XShape> xShape = SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
1064 
1065  // polygon path
1066 
1067  if (!aAbsPoints.empty())
1068  {
1069  PointSequenceSequence aPointSeq{ comphelper::containerToSequence( aAbsPoints ) };
1070  PropertySet aPropSet( xShape );
1071  aPropSet.setProperty( PROP_PolyPolygon, aPointSeq );
1072  }
1073  return xShape;
1074 }
1075 
1076 namespace
1077 {
1078  void doMirrorX(SdrObject* pShape)
1079  {
1080  Point aCenter(pShape->GetSnapRect().Center());
1081  Point aPoint2(aCenter);
1082  aPoint2.setY(aPoint2.getY() + 1);
1083  pShape->NbcMirror(aCenter, aPoint2);
1084  }
1085 
1086  void doMirrorY(SdrObject* pShape)
1087  {
1088  Point aCenter(pShape->GetSnapRect().Center());
1089  Point aPoint2(aCenter);
1090  aPoint2.setX(aPoint2.getX() + 1);
1091  pShape->NbcMirror(aCenter, aPoint2);
1092  }
1093 
1094  void handleMirroring(const ShapeTypeModel& rTypeModel, const Reference<XShape>& rxShape)
1095  {
1096  if (!rTypeModel.maFlip.isEmpty())
1097  {
1098  if (SdrObject* pShape = SdrObject::getSdrObjectFromXShape(rxShape))
1099  {
1100  if (rTypeModel.maFlip.startsWith("x"))
1101  doMirrorX(pShape);
1102  if (rTypeModel.maFlip.endsWith("y"))
1103  doMirrorY(pShape);
1104  }
1105  }
1106  }
1107 
1108  void handleRotation(const ShapeTypeModel& rTypeModel, const Reference<XShape>& rxShape)
1109  {
1110  if (!rTypeModel.maRotation.isEmpty())
1111  {
1112  if (SdrObject* pShape = SdrObject::getSdrObjectFromXShape(rxShape))
1113  {
1114  // The needed factor -1 for opposite direction and factor 100 for Degree100 is
1115  // contained in method decodeRotation().
1116  Degree100 nAngle(ConversionHelper::decodeRotation(rTypeModel.maRotation));
1117  pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle);
1118  }
1119  }
1120  }
1121 }
1122 
1124  : SimpleShape(rDrawing, "com.sun.star.drawing.LineShape")
1125 {
1126 }
1127 
1128 Reference<XShape> LineShape::implConvertAndInsert(const Reference<XShapes>& rxShapes, const awt::Rectangle& rShapeRect) const
1129 {
1130  Reference<XShape> xShape = SimpleShape::implConvertAndInsert(rxShapes, rShapeRect);
1131  // tdf#137765
1132  handleRotation(maTypeModel, xShape);
1133  // tdf#97517 tdf#137678
1134  // The MirroredX and MirroredY properties (in the CustomShapeGeometry property) are not
1135  // supported for the LineShape by UNO, so we have to make the mirroring here.
1136  handleMirroring(maTypeModel, xShape);
1137  return xShape;
1138 }
1139 
1140 awt::Rectangle LineShape::getAbsRectangle() const
1141 {
1142  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
1143  awt::Rectangle aShapeRect;
1144  sal_Int32 nIndex = 0;
1145 
1146  aShapeRect.X = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex), 0, true, true);
1147  aShapeRect.Y = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex), 0, false, true);
1148  nIndex = 0;
1149  aShapeRect.Width = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex), 0, true, true) - aShapeRect.X;
1150  aShapeRect.Height = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex), 0, false, true) - aShapeRect.Y;
1151  return aShapeRect;
1152 }
1153 
1154 awt::Rectangle LineShape::getRelRectangle() const
1155 {
1156  awt::Rectangle aShapeRect;
1157  sal_Int32 nIndex = 0;
1158 
1159  aShapeRect.X = o3tl::toInt32(o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex));
1160  aShapeRect.Y = o3tl::toInt32(o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex));
1161  nIndex = 0;
1162  aShapeRect.Width = o3tl::toInt32(o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex)) - aShapeRect.X;
1163  aShapeRect.Height = o3tl::toInt32(o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex)) - aShapeRect.Y;
1164  return aShapeRect;
1165 }
1166 
1168  : SimpleShape(rDrawing, "com.sun.star.drawing.OpenBezierShape")
1169 {
1170 }
1171 
1172 Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
1173 {
1174  // If we have an 'x' in the last part of the path it means it is closed...
1175  sal_Int32 nPos = maShapeModel.maVmlPath.lastIndexOf(',');
1176  if ( nPos != -1 && maShapeModel.maVmlPath.indexOf('x', nPos) != -1 )
1177  {
1178  const_cast<BezierShape*>( this )->setService( "com.sun.star.drawing.ClosedBezierShape" );
1179  }
1180 
1181  awt::Rectangle aCoordSys = getCoordSystem();
1182  PolyPolygonBezierCoords aBezierCoords;
1183 
1184  if( (aCoordSys.Width > 0) && (aCoordSys.Height > 0) )
1185  {
1186  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
1187 
1188  // Bezier paths may consist of one or more sub-paths
1189  typedef ::std::vector< ::std::vector< PolygonFlags > > FlagsList;
1190  std::vector< ::std::vector< awt::Point > > aCoordLists;
1191  FlagsList aFlagLists;
1192 
1193  // Curve defined by to, from, control1 and control2 attributes
1194  if ( maShapeModel.maVmlPath.isEmpty() )
1195  {
1196  aCoordLists.emplace_back( );
1197  aFlagLists.emplace_back( );
1198  sal_Int32 nIndex = 0;
1199 
1200  // Start point
1201  aCoordLists[ 0 ].emplace_back(
1202  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex ), 0, true, true ),
1203  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maFrom, 0, ',', nIndex ), 0, false, true ) );
1204  // Control point 1
1205  aCoordLists[ 0 ].emplace_back(
1206  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maControl1, 0, ',', nIndex ), 0, true, true ),
1207  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maControl1, 0, ',', nIndex ), 0, false, true ) );
1208  // Control point 2
1209  aCoordLists[ 0 ].emplace_back(
1210  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maControl2, 0, ',', nIndex ), 0, true, true ),
1211  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maControl2, 0, ',', nIndex ), 0, false, true ) );
1212  // End point
1213  aCoordLists[ 0 ].emplace_back(
1214  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex ), 0, true, true ),
1215  ConversionHelper::decodeMeasureToHmm( rGraphicHelper, o3tl::getToken(maShapeModel.maTo, 0, ',', nIndex ), 0, false, true ) );
1216 
1217  // First and last points are normals, points 2 and 4 are controls
1218  aFlagLists[ 0 ].resize( aCoordLists[ 0 ].size(), PolygonFlags_CONTROL );
1219  aFlagLists[ 0 ][ 0 ] = PolygonFlags_NORMAL;
1220  aFlagLists[ 0 ].back() = PolygonFlags_NORMAL;
1221  }
1222  // Curve defined by path attribute
1223  else
1224  {
1225  // Parse VML path string and convert to absolute coordinates
1226  ConversionHelper::decodeVmlPath( aCoordLists, aFlagLists, maShapeModel.maVmlPath );
1227 
1228  for (auto & coordList : aCoordLists)
1229  for (auto & point : coordList)
1230  {
1231  point = lclGetAbsPoint( point, rShapeRect, aCoordSys );
1232  }
1233  }
1234 
1235  aBezierCoords.Coordinates.realloc( aCoordLists.size() );
1236  auto pCoordinates = aBezierCoords.Coordinates.getArray();
1237  for ( size_t i = 0; i < aCoordLists.size(); i++ )
1238  pCoordinates[i] = comphelper::containerToSequence( aCoordLists[i] );
1239 
1240  aBezierCoords.Flags.realloc( aFlagLists.size() );
1241  auto pFlags = aBezierCoords.Flags.getArray();
1242  for ( size_t i = 0; i < aFlagLists.size(); i++ )
1243  pFlags[i] = comphelper::containerToSequence( aFlagLists[i] );
1244 
1245  if( !aCoordLists.front().empty() && !aCoordLists.back().empty()
1246  && aCoordLists.front().front().X == aCoordLists.back().back().X
1247  && aCoordLists.front().front().Y == aCoordLists.back().back().Y )
1248  { // HACK: If the shape is in fact closed, which can be found out only when the path is known,
1249  // force to closed bezier shape (otherwise e.g. fill won't work).
1250  const_cast< BezierShape* >( this )->setService( "com.sun.star.drawing.ClosedBezierShape" );
1251  }
1252  }
1253 
1254  Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, rShapeRect );
1255 
1256  if( aBezierCoords.Coordinates.hasElements())
1257  {
1258  PropertySet aPropSet( xShape );
1259  aPropSet.setProperty( PROP_PolyPolygonBezier, aBezierCoords );
1260  }
1261 
1262  // tdf#105875 handle rotation
1263  // Note: must rotate before flip!
1264  handleRotation(maTypeModel, xShape);
1265 
1266  // Handle horizontal and vertical flip.
1267  handleMirroring(maTypeModel, xShape);
1268 
1269  return xShape;
1270 }
1271 
1273  SimpleShape( rDrawing, "com.sun.star.drawing.CustomShape" )
1274 {
1275 }
1276 
1277 Reference< XShape > CustomShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
1278 {
1279  // try to create a custom shape
1280  Reference< XShape > xShape = SimpleShape::implConvertAndInsert( rxShapes, rShapeRect );
1281  if( xShape.is() ) try
1282  {
1283  // create the custom shape geometry
1284  Reference< XEnhancedCustomShapeDefaulter > xDefaulter( xShape, UNO_QUERY_THROW );
1285  xDefaulter->createCustomShapeDefaults( OUString::number( getShapeType() ) );
1286  // convert common properties
1287  convertShapeProperties( xShape );
1288  }
1289  catch( Exception& )
1290  {
1291  }
1292  return xShape;
1293 }
1294 
1296  CustomShape( rDrawing )
1297 {
1298 }
1299 
1300 Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
1301 {
1302  XmlFilterBase& rFilter = mrDrawing.getFilter();
1303  sal_Int32 nShapeType = getShapeType();
1304  OUString aGraphicPath = getGraphicPath();
1305 
1306  // try to find registered OLE object info
1307  if( const OleObjectInfo* pOleObjectInfo = mrDrawing.getOleObjectInfo( maTypeModel.maShapeId ) )
1308  {
1309  SAL_WARN_IF(
1310  nShapeType != VML_SHAPETYPE_PICTUREFRAME, "oox",
1311  "ComplexShape::implConvertAndInsert - unexpected shape type");
1312 
1313  // if OLE object is embedded into a DrawingML shape (PPTX), do not create it here
1314  if( pOleObjectInfo->mbDmlShape )
1315  return Reference< XShape >();
1316 
1317  PropertyMap aOleProps;
1318  awt::Size aOleSize( rShapeRect.Width, rShapeRect.Height );
1319  if( rFilter.getOleObjectHelper().importOleObject( aOleProps, *pOleObjectInfo, aOleSize ) )
1320  {
1321  Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.OLE2Shape", rxShapes, rShapeRect );
1322  if( xShape.is() )
1323  {
1324  // set the replacement graphic
1325  if( !aGraphicPath.isEmpty() )
1326  {
1327  WmfExternal aExtHeader;
1328  aExtHeader.mapMode = 8;
1329  aExtHeader.xExt = rShapeRect.Width;
1330  aExtHeader.yExt = rShapeRect.Height;
1331 
1332  Reference< XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic(aGraphicPath, &aExtHeader);
1333  if (xGraphic.is())
1334  aOleProps.setProperty( PROP_Graphic, xGraphic);
1335  }
1336 
1337  PropertySet aPropSet( xShape );
1338  aPropSet.setProperties( aOleProps );
1339 
1340  return xShape;
1341  }
1342  }
1343  }
1344 
1345  // try to find registered form control info
1346  const ControlInfo* pControlInfo = mrDrawing.getControlInfo( maTypeModel.maShapeId );
1347  if( pControlInfo && !pControlInfo->maFragmentPath.isEmpty() )
1348  {
1349  if( !pControlInfo->maName.isEmpty() )
1350  {
1351  // load the control properties from fragment
1352  ::oox::ole::EmbeddedControl aControl(pControlInfo->maName);
1353  if( rFilter.importFragment( new ::oox::ole::AxControlFragment( rFilter, pControlInfo->maFragmentPath, aControl ) ) )
1354  {
1355  // create and return the control shape (including control model)
1356  sal_Int32 nCtrlIndex = -1;
1357  Reference< XShape > xShape = mrDrawing.createAndInsertXControlShape( aControl, rxShapes, rShapeRect, nCtrlIndex );
1358 
1359  if (pControlInfo->mbTextContentShape)
1360  {
1361  PropertySet aPropertySet(xShape);
1363  }
1364  // on error, proceed and try to create picture from replacement image
1365  if( xShape.is() )
1366  return xShape;
1367  }
1368  }
1369  }
1370 
1371  // host application wants to create the shape (do not try failed OLE controls again)
1372  if( (nShapeType == VML_SHAPETYPE_HOSTCONTROL) && !pControlInfo )
1373  {
1374  OSL_ENSURE( getClientData(), "ComplexShape::implConvertAndInsert - missing client data" );
1375  Reference< XShape > xShape = mrDrawing.createAndInsertClientXShape( *this, rxShapes, rShapeRect );
1376  if( xShape.is() )
1377  return xShape;
1378  }
1379 
1380 
1382  {
1383  uno::Reference<graphic::XGraphic> xGraphic;
1384  bool bIsSigned(false);
1385  try
1386  {
1387  // Get the document signatures
1388  Reference<security::XDocumentDigitalSignatures> xSignatures(
1389  security::DocumentDigitalSignatures::createDefault(
1391 
1392  uno::Reference<embed::XStorage> xStorage
1395  embed::ElementModes::READ);
1396  SAL_WARN_IF(!xStorage.is(), "oox.vml", "No xStorage!");
1397 
1398  const uno::Sequence<security::DocumentSignatureInformation> xSignatureInfo
1399  = xSignatures->verifyScriptingContentSignatures(xStorage,
1400  uno::Reference<io::XInputStream>());
1401 
1402  // Try to find matching signature line image - if none exists that is fine,
1403  // then the signature line is not digitally signed.
1404  auto pSignInfo = std::find_if(xSignatureInfo.begin(), xSignatureInfo.end(),
1405  [this](const security::DocumentSignatureInformation& rSigInfo) {
1406  return rSigInfo.SignatureLineId == getShapeModel().maSignatureId; });
1407  if (pSignInfo != xSignatureInfo.end())
1408  {
1409  bIsSigned = true;
1410  if (pSignInfo->SignatureIsValid)
1411  {
1412  // Signature is valid, use the 'valid' image
1413  SAL_WARN_IF(!pSignInfo->ValidSignatureLineImage.is(), "oox.vml",
1414  "No ValidSignatureLineImage!");
1415  xGraphic = pSignInfo->ValidSignatureLineImage;
1416  }
1417  else
1418  {
1419  // Signature is invalid, use the 'invalid' image
1420  SAL_WARN_IF(!pSignInfo->InvalidSignatureLineImage.is(), "oox.vml",
1421  "No InvalidSignatureLineImage!");
1422  xGraphic = pSignInfo->InvalidSignatureLineImage;
1423  }
1424  }
1425  }
1426  catch (css::uno::Exception&)
1427  {
1428  // DocumentDigitalSignatures service not available.
1429  // We continue by rendering the "unsigned" shape instead.
1430  }
1431 
1432  Reference< XShape > xShape;
1433  if (xGraphic.is())
1434  {
1435  // If available, use the signed image from the signature
1436  xShape = SimpleShape::createPictureObject(rxShapes, rShapeRect, xGraphic);
1437  }
1438  else
1439  {
1440  // Create shape with the fallback "unsigned" image
1441  xShape = SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath);
1442  }
1443 
1444  // Store signature line properties
1445  uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
1446  xPropertySet->setPropertyValue("IsSignatureLine", uno::Any(true));
1447  xPropertySet->setPropertyValue("SignatureLineId",
1448  uno::Any(getShapeModel().maSignatureId));
1449  xPropertySet->setPropertyValue(
1450  "SignatureLineSuggestedSignerName",
1451  uno::Any(getShapeModel().maSignatureLineSuggestedSignerName));
1452  xPropertySet->setPropertyValue(
1453  "SignatureLineSuggestedSignerTitle",
1454  uno::Any(getShapeModel().maSignatureLineSuggestedSignerTitle));
1455  xPropertySet->setPropertyValue(
1456  "SignatureLineSuggestedSignerEmail",
1457  uno::Any(getShapeModel().maSignatureLineSuggestedSignerEmail));
1458  xPropertySet->setPropertyValue(
1459  "SignatureLineSigningInstructions",
1460  uno::Any(getShapeModel().maSignatureLineSigningInstructions));
1461  xPropertySet->setPropertyValue(
1462  "SignatureLineShowSignDate",
1463  uno::Any(getShapeModel().mbSignatureLineShowSignDate));
1464  xPropertySet->setPropertyValue(
1465  "SignatureLineCanAddComment",
1466  uno::Any(getShapeModel().mbSignatureLineCanAddComment));
1467  xPropertySet->setPropertyValue("SignatureLineIsSigned", uno::Any(bIsSigned));
1468 
1469  if (!aGraphicPath.isEmpty())
1470  {
1471  xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic(aGraphicPath);
1472  xPropertySet->setPropertyValue("SignatureLineUnsignedImage", uno::Any(xGraphic));
1473  }
1474  return xShape;
1475  }
1476 
1477  // try to create a picture object
1478  if( !aGraphicPath.isEmpty() )
1479  {
1480  Reference<XShape> xShape = SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath);
1481  // AS_CHARACTER shape: vertical orientation default is bottom, MSO default is top.
1482  if ( maTypeModel.maPosition != "absolute" && maTypeModel.maPosition != "relative" )
1483  PropertySet( xShape ).setAnyProperty( PROP_VertOrient, Any(text::VertOrientation::TOP));
1484 
1485  // Apply stroke props from the type model.
1487  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
1488  maTypeModel.maStrokeModel.pushToPropMap(aPropMap, rGraphicHelper);
1489  // And, fill-color properties as well...
1490  maTypeModel.maFillModel.pushToPropMap(aPropMap, rGraphicHelper);
1491  PropertySet(xShape).setProperties(aPropMap);
1492 
1493  return xShape;
1494  }
1495 
1496  // default: try to create a custom shape
1497  return CustomShape::implConvertAndInsert( rxShapes, rShapeRect );
1498 }
1499 
1501  ShapeBase( rDrawing ),
1502  mxChildren( new ShapeContainer( rDrawing ) )
1503 {
1504 }
1505 
1507 {
1508 }
1509 
1511 {
1512  // basic shape processing
1514  // finalize all child shapes
1515  mxChildren->finalizeFragmentImport();
1516 }
1517 
1518 const ShapeType* GroupShape::getChildTypeById( const OUString& rShapeId ) const
1519 {
1520  return mxChildren->getShapeTypeById( rShapeId );
1521 }
1522 
1523 const ShapeBase* GroupShape::getChildById( const OUString& rShapeId ) const
1524 {
1525  return mxChildren->getShapeById( rShapeId );
1526 }
1527 
1528 Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
1529 {
1530  Reference< XShape > xGroupShape;
1531  // check that this shape contains children and a valid coordinate system
1532  ShapeParentAnchor aParentAnchor;
1533  aParentAnchor.maShapeRect = rShapeRect;
1534  aParentAnchor.maCoordSys = getCoordSystem();
1535  if( !mxChildren->empty() && (aParentAnchor.maCoordSys.Width > 0) && (aParentAnchor.maCoordSys.Height > 0) ) try
1536  {
1537  xGroupShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GroupShape", rxShapes, rShapeRect );
1538  Reference< XShapes > xChildShapes( xGroupShape, UNO_QUERY_THROW );
1539  mxChildren->convertAndInsert( xChildShapes, &aParentAnchor );
1540  if( !xChildShapes->hasElements() )
1541  {
1542  SAL_WARN("oox", "no child shape has been created - deleting the group shape");
1543  rxShapes->remove( xGroupShape );
1544  xGroupShape.clear();
1545  }
1546  }
1547  catch( Exception& )
1548  {
1549  }
1550 
1551  uno::Reference<beans::XPropertySet> xPropertySet;
1552  if (!maTypeModel.maEditAs.isEmpty())
1553  xPropertySet = uno::Reference<beans::XPropertySet>(xGroupShape, uno::UNO_QUERY);
1554  if (xPropertySet.is())
1555  {
1556  uno::Sequence<beans::PropertyValue> aGrabBag;
1557  xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
1558  sal_Int32 nLength = aGrabBag.getLength();
1559  aGrabBag.realloc(nLength + 1);
1560  aGrabBag.getArray()[nLength] = comphelper::makePropertyValue("mso-edit-as", maTypeModel.maEditAs);
1561  xPropertySet->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag));
1562  }
1563  // Make sure group shapes are inline as well, unless there is an explicit different style.
1564  PropertySet aPropertySet(xGroupShape);
1565  const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
1566  lcl_SetAnchorType(aPropertySet, maTypeModel, rGraphicHelper);
1567  if (!maTypeModel.maRotation.isEmpty())
1568  aPropertySet.setAnyProperty(PROP_RotateAngle, Any(ConversionHelper::decodeRotation(maTypeModel.maRotation).get()));
1569  return xGroupShape;
1570 }
1571 
1572 } // namespace oox
1573 
1574 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The shape model structure contains all properties shared by all types of shapes.
Definition: vmlshape.hxx:60
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
OptValue< OUString > moGraphicTitle
Title of the graphic.
Definition: vmlshape.hxx:100
css::awt::Rectangle maShapeRect
virtual css::uno::Reference< css::drawing::XShape > finalImplConvertAndInsert(const css::uno::Reference< css::drawing::XShape > &rxShape) const
Always called after implConvertAndInsert for the same task.
Definition: vmlshape.hxx:287
css::uno::Reference< css::graphic::XGraphic > importEmbeddedGraphic(const OUString &rStreamName, const WmfExternal *pExtHeader=nullptr) const
Imports a graphic from the storage stream with the passed path and name.
const TextBox * getTextBox() const
Returns read access to the shape textbox.
Definition: vmlshape.hxx:249
const OleObjectInfo * getOleObjectInfo(const OUString &rShapeId) const
Returns the registered info structure for an OLE object, if extant.
Definition: vmldrawing.cxx:250
sal_Int32 nIndex
virtual bool isShapeSupported(const ShapeBase &rShape) const
Derived classes may disable conversion of specific shapes.
Definition: vmldrawing.cxx:318
std::unique_ptr< ClientData > mxClientData
Excel specific client data.
Definition: vmlshape.hxx:210
ShapeModel maShapeModel
The model structure containing shape data.
Definition: vmlshape.hxx:303
A helper that maps property identifiers to property values.
Definition: propertymap.hxx:51
A shape object that is part of a drawing.
Definition: vmlshape.hxx:240
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:1046
void pushToPropMap(oox::drawingml::ShapePropertyMap &rPropMap, const css::uno::Reference< css::drawing::XShape > &xShape, const GraphicHelper &rGraphicHelper) const
Writes the properties to the passed property map.
OUString maZIndex
ZIndex of the shape.
Definition: vmlshape.hxx:70
BezierShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1167
OUString maSignatureId
ID of the signature.
Definition: vmlshape.hxx:218
void convertFormatting(const css::uno::Reference< css::drawing::XShape > &rxShape) const
Converts position and formatting into the passed existing XShape.
Definition: vmlshape.cxx:486
OUString maTop
Y position of the shape bounding box (number with unit).
Definition: vmlshape.hxx:72
OUString maPositionVertical
The Y position orientation.
Definition: vmlshape.hxx:80
bool mbIsSignatureLine
Shape is a signature line.
Definition: vmlshape.hxx:217
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
The stroke model structure contains all shape border properties.
css::awt::Rectangle calcShapeRectangle(const ShapeParentAnchor *pParentAnchor) const
Calculates the final shape rectangle according to the passed anchor, if present, otherwise according ...
Definition: vmlshape.cxx:510
sal_Int32 getShapeType() const
Returns the application defined shape type.
Definition: vmlshape.cxx:159
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Excel specific shape client data (such as cell anchor).
Definition: vmlshape.hxx:167
ShapeContainer & getShapes()
Returns read/write access to the container of shapes and templates.
Definition: vmldrawing.hxx:108
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
A shape template contains all formatting properties of shapes and can serve as templates for several ...
Definition: vmlshape.hxx:130
sal_Int32 mnCol
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
def point()
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:1172
OUString maHeight
Height of the shape bounding box (number with unit).
Definition: vmlshape.hxx:74
OUString maService
Name of the UNO shape service.
Definition: vmlshape.hxx:335
virtual css::uno::Reference< css::drawing::XShape > createAndInsertClientXShape(const ShapeBase &rShape, const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const
Derived classes create a UNO shape according to the passed shape model.
Definition: vmldrawing.cxx:333
OUString maMarginTop
Y position of the shape bounding box to shape anchor (number with unit).
Definition: vmlshape.hxx:76
OUString maHeightPercent
The height in percents of the HeightRelative.
Definition: vmlshape.hxx:82
ModelObjectHelper & getModelObjectHelper() const
Returns a helper with containers for various named drawing objects for the imported document...
Definition: filterbase.cxx:353
const sal_Int32 VML_CLIENTDATA_UNCHECKED
Definition: vmlshape.hxx:48
OUString maLegacyId
Plaintext identifier of the shape.
Definition: vmlshape.hxx:63
bool hasProperty(sal_Int32 nPropId) const
Returns true, if the specified property is supported by the property set.
Definition: propertyset.cxx:47
OUString maWidthRelative
To what the width is relative.
Definition: vmlshape.hxx:83
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:1528
OptValue< sal_Int32 > moShapeType
Builtin shape type identifier.
Definition: vmlshape.hxx:65
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:1128
const ControlInfo * getControlInfo(const OUString &rShapeId) const
Returns the registered info structure for a form control, if extant.
Definition: vmldrawing.cxx:255
void pushToPropMap(oox::drawingml::ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper) const
Writes the properties to the passed property map.
virtual void notifyXShapeInserted(const css::uno::Reference< css::drawing::XShape > &rxShape, const css::awt::Rectangle &rShapeRect, const ShapeBase &rShape, bool bGroupChild)
Derived classes may want to know that a UNO shape has been inserted.
Definition: vmldrawing.cxx:339
EllipseShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1036
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
virtual OUString getShapeBaseName(const ShapeBase &rShape) const
Derived classes may return additional base names for automatic shape name creation.
Definition: vmldrawing.cxx:323
virtual css::awt::Rectangle getRelRectangle() const override
Returns the rectangle relative to the parent coordinate system.
Definition: vmlshape.cxx:1154
void convertShapeProperties(const css::uno::Reference< css::drawing::XShape > &rxShape) const
Converts common shape properties such as formatting attributes.
Definition: vmlshape.cxx:521
virtual const tools::Rectangle & GetSnapRect() const
GraphicHelper & getGraphicHelper() const
Returns a helper for the handling of graphics and graphic objects.
Definition: filterbase.cxx:346
void setContainer(ShapeContainer *pContainer)
Definition: vmlshape.cxx:504
A form control embedded in a document draw page.
Definition: axcontrol.hxx:897
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
RectangleShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1004
sal_uInt16 sal_Unicode
void convert(const css::uno::Reference< css::drawing::XShape > &xShape) const
Definition: vmltextbox.cxx:77
OUString maVmlPath
VML path for this shape.
Definition: vmlshape.hxx:216
OUString maEditAs
Edit As type (e.g. "canvas" etc)
Definition: vmlshape.hxx:91
OUString maType
Shape template with default properties.
Definition: vmlshape.hxx:207
TextBox & createTextBox(ShapeTypeModel &rModel)
Creates and returns a new shape textbox structure.
Definition: vmlshape.cxx:271
OUString maWrapDistanceLeft
Distance from the left side of the shape to the text that wraps around it.
Definition: vmlshape.hxx:106
const OUString & getShapeId() const
Returns the shape identifier (which is unique through the containing drawing).
Definition: vmlshape.hxx:142
css::uno::Reference< css::drawing::XShape > createAndInsertXShape(const OUString &rService, const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const
Creates a new UNO shape object, inserts it into the passed UNO shape container, and sets the shape po...
Definition: vmldrawing.cxx:260
OUString getShapeName() const
Returns the real shape name if existing, or a generated shape name.
Definition: vmlshape.cxx:325
The fill model structure contains all shape fill properties.
Bezier shape object that supports to, from, control1 and control2 attribute or path attribute specifi...
Definition: vmlshape.hxx:395
const Type & get() const
Definition: helper.hxx:185
OptValue< Int32Pair > moCoordPos
Top-left position of coordinate system for children scaling.
Definition: vmlshape.hxx:67
virtual css::awt::Rectangle getRelRectangle() const
Returns the rectangle relative to the parent coordinate system.
Definition: vmlshape.cxx:216
virtual ~GroupShape() override
Definition: vmlshape.cxx:1506
virtual css::uno::Reference< css::drawing::XShape > finalImplConvertAndInsert(const css::uno::Reference< css::drawing::XShape > &rxShape) const override
Always called after implConvertAndInsert for the same task.
Definition: vmlshape.cxx:908
OOX_DLLPUBLIC Degree100 decodeRotation(std::u16string_view rValue)
Converts the passed VML rotation value to degrees.
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
sal_Int16 mnBlacklevel
The image brightness, on a 0..0x10000 scale.
Definition: vmlshape.hxx:120
bool setAnyProperty(sal_Int32 nPropId, const css::uno::Any &rValue)
Puts the passed any into the property set.
Definition: propertyset.cxx:70
XML_TOKEN_INVALID
StrokeModel maStrokeModel
Border line formatting.
Definition: vmlshape.hxx:94
std::unique_ptr< TextBox > mxTextBox
Text contents and properties.
Definition: vmlshape.hxx:209
CustomShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1272
OUString maHeightRelative
To what the height is relative.
Definition: vmlshape.hxx:84
OUString maHyperlink
The hyperlink assigned to the shape.
Definition: vmlshape.hxx:226
OUString maAnchor
Cell anchor as comma-separated string.
Definition: vmlshape.hxx:169
sal_uInt16 mapMode
css::awt::Rectangle getCoordSystem() const
Returns the coordinate system of this shape.
Definition: vmlshape.cxx:169
css::uno::Reference< css::drawing::XShape > createPictureObject(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect, css::uno::Reference< css::graphic::XGraphic > const &rxGraphic) const
Definition: vmlshape.cxx:942
ShapeContainer * mpContainer
Definition: vmlshape.hxx:304
Contains information about a form control embedded in a draw page.
Definition: vmldrawing.hxx:78
bool mbVisible
Visible or Hidden.
Definition: vmlshape.hxx:88
OUString maAdjustments
Shape adjustment values.
Definition: vmlshape.hxx:92
sal_Int32 getLocalShapeIndex(const OUString &rShapeId) const
Returns the local shape index from the passed global shape identifier.
Definition: vmldrawing.cxx:209
ShapeTypeModel & getTypeModel()
Returns read/write access to the shape template model structure.
Definition: vmlshape.hxx:137
Container that holds a list of shapes and shape templates.
OUString maControl1
Bezier control point 1.
Definition: vmlshape.hxx:214
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:1277
OUString maPositionHorizontalRelative
The X position is relative to this.
Definition: vmlshape.hxx:77
UNDERLYING_TYPE get() const
void assignUsed(const ShapeTypeModel &rSource)
Definition: vmlshape.cxx:137
sal_Int32 mnGain
An adjustment for the intensity of all colors, i.e. contrast, on a 0..0x10000 scale.
Definition: vmlshape.hxx:117
bool mbTextContentShape
Whether this control shape will be imported to Writer or not (has AnchorType property or not)...
Definition: vmldrawing.hxx:83
OUString maPositionVerticalRelative
The Y position is relative to this.
Definition: vmlshape.hxx:78
The textbox contains all text contents and properties.
Definition: vmltextbox.hxx:79
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const =0
Derived classes create the corresponding XShape and insert it into the passed container.
Contains information about an OLE object embedded in a draw page.
Definition: vmldrawing.hxx:62
void assignIfUsed(const OptValue &rValue)
Definition: helper.hxx:196
virtual void NbcMirror(const Point &rRef1, const Point &rRef2)
::oox::core::XmlFilterBase & getFilter() const
Returns the filter object that imports/exports this VML drawing.
Definition: vmldrawing.hxx:104
A polygon shape object.
Definition: vmlshape.hxx:362
ClientData & createClientData()
Creates and returns a new shape client data structure.
Definition: vmlshape.cxx:277
virtual css::awt::Rectangle getAbsRectangle() const override
Returns the absolute shape rectangle.
Definition: vmlshape.cxx:1140
OUString maRotation
Rotation of the shape, in degrees.
Definition: vmlshape.hxx:85
OUString maLegacyDiagramPath
Legacy Diagram Fragment Path.
Definition: vmlshape.hxx:211
OptValue< OUString > moWeight
Line width.
ComplexShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1295
OOX_DLLPUBLIC sal_Int32 decodeMeasureToHmm(const GraphicHelper &rGraphicHelper, std::u16string_view rValue, sal_Int32 nRefValue, bool bPixelX, bool bDefaultAsPixel)
Converts the passed VML measure string to 1/100 mm.
virtual void finalizeFragmentImport()
Final processing after import of the drawing fragment.
Definition: vmlshape.cxx:288
float u
OUString maFlip
Flip type of the shape (can be "x" or "y").
Definition: vmlshape.hxx:86
const ShapeType * getShapeTypeById(const OUString &rShapeId) const
Returns the shape template with the passed identifier.
OptValue< OUString > moWrapSide
On which side to wrap the text around the object.
Definition: vmlshape.hxx:104
OUString maName
Programmatical name of the form control.
Definition: vmldrawing.hxx:82
size
ShadowModel maShadowModel
Shape shadow formatting.
Definition: vmlshape.hxx:96
void SetMergedItem(const SfxPoolItem &rItem)
css::awt::Rectangle getRectangle(const ShapeParentAnchor *pParentAnchor) const
Returns the absolute shape rectangle according to the passed anchor.
Definition: vmlshape.cxx:180
static void lcl_SetAnchorType(PropertySet &rPropSet, const ShapeTypeModel &rTypeModel, const GraphicHelper &rGraphicHelper)
Definition: vmlshape.cxx:605
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
OOX_DLLPUBLIC void decodeVmlPath(::std::vector< ::std::vector< css::awt::Point > > &rPoints,::std::vector< ::std::vector< css::drawing::PolygonFlags > > &rFlags, const OUString &rPath)
Converts VML path string into point and flag vectors.
void assignUsed(const StrokeModel &rSource)
OUString maArcsize
round rectangles arc size
Definition: vmlshape.hxx:90
A wrapper for a UNO property set.
Definition: propertyset.hxx:57
OUString maFragmentPath
Path to the fragment describing the form control properties.
Definition: vmldrawing.hxx:81
const sal_Int32 VML_CLIENTDATA_TEXT
Definition: vmlshape.hxx:52
A simple shape object based on a specific UNO shape service.
Definition: vmlshape.hxx:309
OptValue< OUString > moCropTop
Specifies how much to crop the image from the top down as a fraction of picture size.
Definition: vmlshape.hxx:113
static void lcl_setSurround(PropertySet &rPropSet, const ShapeTypeModel &rTypeModel, const GraphicHelper &rGraphicHelper)
Definition: vmlshape.cxx:579
sal_uInt16 xExt
virtual void finalizeFragmentImport() override
Final processing after import of the drawing fragment.
Definition: vmlshape.cxx:1510
constexpr Point Center() const
OUString maWrapDistanceRight
Distance from the right side of the shape to the text that wraps around it.
Definition: vmlshape.hxx:107
static css::uno::Reference< css::embed::XStorage > GetStorageOfFormatFromURL(const OUString &aFormat, const OUString &aURL, sal_Int32 nStorageMode, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
css::awt::Rectangle maCoordSys
OUString maWidth
Width of the shape bounding box (number with unit).
Definition: vmlshape.hxx:73
tools::Long const nBorder
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:692
OptValue< OUString > moGraphicPath
Path to a graphic for this shape.
Definition: vmlshape.hxx:99
const ClientData * getClientData() const
Returns read access to the shape client data structure.
Definition: vmlshape.hxx:251
const OUString & getFileUrl() const
Returns the URL of the imported or exported file.
Definition: filterbase.cxx:250
OUString maWrapStyle
Wrapping mode for text.
Definition: vmlshape.hxx:89
OUString maLeft
X position of the shape bounding box (number with unit).
Definition: vmlshape.hxx:71
std::unique_ptr< ShapeContainer > mxChildren
Shapes and templates that are part of this group.
Definition: vmlshape.hxx:468
bool mbVisible
OptValue< OUString > moCropBottom
Specifies the how much to crop the image from the bottom up as a fraction of picture size...
Definition: vmlshape.hxx:110
static const OUString & getPropertyName(sal_Int32 nPropId)
Returns the name of the passed property identifier.
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:1009
sal_uInt16 yExt
OUString maFrom
Start point for line shape.
Definition: vmlshape.hxx:212
#define SAL_WARN_IF(condition, area, stream)
OUString maWrapDistanceTop
Distance from the top of the shape to the text that wraps around it.
Definition: vmlshape.hxx:108
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
virtual const ShapeType * getChildTypeById(const OUString &rShapeId) const override
Returns the shape template with the passed identifier from the child shapes.
Definition: vmlshape.cxx:1518
ShapeContainer * getContainer() const
Definition: vmlshape.cxx:506
OUString maControl2
Bezier control point 2.
Definition: vmlshape.hxx:215
css::uno::Reference< css::drawing::XShape > createAndInsertXControlShape(const ::oox::ole::EmbeddedControl &rControl, const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect, sal_Int32 &rnCtrlIndex) const
Creates a new UNO shape object for a form control, inserts the control model into the form...
Definition: vmldrawing.cxx:296
OptValue< OUString > moWrapType
How to wrap the text around the object.
Definition: vmlshape.hxx:103
ShapeType(Drawing &rDrawing)
Definition: vmlshape.cxx:150
OUString getGraphicPath() const
Returns the fragment path to the embedded graphic used by this shape.
Definition: vmlshape.cxx:164
LineShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1123
virtual ~ShapeType()
Definition: vmlshape.cxx:155
css::uno::Reference< css::io::XInputStream > openInputStream(const OUString &rStreamName) const
Opens and returns the specified input stream from the base storage.
Definition: filterbase.cxx:327
OUString maMarginLeft
X position of the shape bounding box to shape anchor (number with unit).
Definition: vmlshape.hxx:75
sal_uInt32 toUInt32(std::u16string_view str, sal_Int16 radix=10)
Drawing & mrDrawing
The VML drawing page that contains this shape.
Definition: vmlshape.hxx:161
css::uno::Reference< css::drawing::XShape > createEmbeddedPictureObject(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect, OUString const &rGraphicPath) const
Used by both RectangleShape and ComplexShape.
Definition: vmlshape.cxx:936
Reference< XComponentContext > getProcessComponentContext()
SimpleShape(Drawing &rDrawing, const OUString &rService)
Definition: vmlshape.cxx:573
PolyLineShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1041
css::uno::Reference< css::drawing::XShape > convertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const ShapeParentAnchor *pParentAnchor=nullptr) const
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:351
Represents the collection of VML shapes for a complete draw page.
Definition: vmldrawing.hxx:93
OUString maShapeId
Unique identifier of the shape.
Definition: vmlshape.hxx:62
virtual const ShapeBase * getChildById(const OUString &rShapeId) const override
Returns the shape with the passed identifier from the child shapes.
Definition: vmlshape.cxx:1523
ShapeModel & getShapeModel()
Returns read/write access to the shape model structure.
Definition: vmlshape.hxx:244
void setService(const OUString &aService)
Definition: vmlshape.hxx:314
GroupShape(Drawing &rDrawing)
Definition: vmlshape.cxx:1500
void assignUsed(const FillModel &rSource)
OUString maWrapDistanceBottom
Distance from the bottom of the shape to the text that wraps around it.
Definition: vmlshape.hxx:109
OUString msNextTextbox
Definition: vmltextbox.hxx:100
OptValue< Int32Pair > moCoordSize
Size of coordinate system for children scaling.
Definition: vmlshape.hxx:68
constexpr OUStringLiteral ZIP_STORAGE_FORMAT_STRING
#define SAL_WARN(area, stream)
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
OUString maVTextAnchor
How the text inside the shape is anchored vertically.
Definition: vmlshape.hxx:105
sal_Int32 nLength
css::awt::Size getOriginalSize(const css::uno::Reference< css::graphic::XGraphic > &rxGraphic) const
calculates the original size of a graphic which is necessary to be able to calculate cropping values ...
sal_Int32 mnRow
ShapeTypeModel maTypeModel
The model structure containing shape type data.
Definition: vmlshape.hxx:162
FillModel maFillModel
Shape fill formatting.
Definition: vmlshape.hxx:95
OUString maPosition
Position type of the shape.
Definition: vmlshape.hxx:69
::std::pair< sal_Int32, sal_Int32 > Int32Pair
OUString maLayoutFlowAlt
Specifies the alternate layout flow for text in textboxes.
Definition: vmlshape.hxx:114
A shape object with custom geometry.
Definition: vmlshape.hxx:410
bool has() const
Definition: helper.hxx:181
OUString maTo
End point for line shape.
Definition: vmlshape.hxx:213
ShapeBase(Drawing &rDrawing)
Definition: vmlshape.cxx:283
OptValue< OUString > moCropLeft
Specifies how much to crop the image from the left in as a fraction of picture size.
Definition: vmlshape.hxx:111
virtual css::uno::Reference< css::drawing::XShape > implConvertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const css::awt::Rectangle &rShapeRect) const override
Creates the corresponding XShape and inserts it into the passed container.
Definition: vmlshape.cxx:1300
virtual const ShapeBase * getChildById(const OUString &rShapeId) const
Returns the shape with the passed identifier from the child shapes.
Definition: vmlshape.cxx:346
OUString maShapeName
Name of the shape, if present.
Definition: vmlshape.hxx:64
virtual css::awt::Rectangle getAbsRectangle() const
Returns the absolute shape rectangle.
Definition: vmlshape.cxx:187
OUString maPositionHorizontal
The X position orientation (default: absolute).
Definition: vmlshape.hxx:79
virtual bool convertClientAnchor(css::awt::Rectangle &orShapeRect, const OUString &rShapeAnchor) const
Derived classes may calculate the shape rectangle from a non-standard anchor information string...
Definition: vmldrawing.cxx:328
void pushToPropMap(::oox::drawingml::ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper) const
Writes the properties to the passed property map.
bool mbAutoHeight
If true, the height value is a minimum value (mostly used for textboxes)
Definition: vmlshape.hxx:87
OUString maWidthPercent
The width in percents of the WidthRelative.
Definition: vmlshape.hxx:81
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
void pushToPropMap(::oox::drawingml::ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper) const
Writes the properties to the passed property map.
sal_uInt16 nPos
virtual const ShapeType * getChildTypeById(const OUString &rShapeId) const
Returns the shape template with the passed identifier from the child shapes.
Definition: vmlshape.cxx:341
OptValue< OUString > moCropRight
Specifies how much to crop the image from the right in as a fraction of picture size.
Definition: vmlshape.hxx:112
sal_Int16 nValue
TextpathModel maTextpathModel
Shape textpath formatting.
Definition: vmlshape.hxx:97
bool m_bDetectedRangeSegmentation false
PointVector maPoints
Points for the polyline shape.
Definition: vmlshape.hxx:208