LibreOffice Module oox (master)  1
shape.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 <config_wasm_strip.h>
21 
22 #include <oox/drawingml/shape.hxx>
24 #include <oox/drawingml/theme.hxx>
30 #include "effectproperties.hxx"
32 #include <drawingml/textbody.hxx>
39 #include <o3tl/safeint.hxx>
40 #include <o3tl/unit_conversion.hxx>
41 #include <oox/ppt/pptimport.hxx>
42 #include <oox/vml/vmldrawing.hxx>
43 #include <oox/vml/vmlshape.hxx>
50 #include <oox/mathml/import.hxx>
51 #include <oox/token/properties.hxx>
52 #include "diagram/datamodel.hxx"
54 
55 #include <comphelper/classids.hxx>
58 #include <comphelper/sequence.hxx>
59 #include <tools/diagnose_ex.h>
60 #include <tools/gen.hxx>
61 #include <tools/globname.hxx>
62 #include <tools/mapunit.hxx>
63 #include <editeng/unoprnms.hxx>
64 #include <com/sun/star/awt/FontSlant.hpp>
65 #include <com/sun/star/awt/Size.hpp>
66 #include <com/sun/star/awt/XBitmap.hpp>
67 #include <com/sun/star/awt/FontWeight.hpp>
68 #include <com/sun/star/graphic/XGraphic.hpp>
69 #include <com/sun/star/container/XNamed.hpp>
70 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
71 #include <com/sun/star/xml/dom/XDocument.hpp>
72 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
73 #include <com/sun/star/drawing/FillStyle.hpp>
74 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
75 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
76 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
77 #include <com/sun/star/drawing/XShapes.hpp>
78 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
79 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
80 #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
81 #include <com/sun/star/drawing/ConnectorType.hpp>
82 #include <com/sun/star/embed/XEmbeddedObject.hpp>
83 #include <com/sun/star/text/XText.hpp>
84 #include <com/sun/star/table/BorderLine2.hpp>
85 #include <com/sun/star/table/ShadowFormat.hpp>
86 #include <com/sun/star/chart2/XChartDocument.hpp>
87 #include <com/sun/star/style/ParagraphAdjust.hpp>
88 #include <com/sun/star/io/XOutputStream.hpp>
89 
93 #include <com/sun/star/document/XActionLockable.hpp>
94 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
95 #include <com/sun/star/text/GraphicCrop.hpp>
96 #include <svx/svdobj.hxx>
97 #include <svx/svdtrans.hxx>
98 #include <tools/stream.hxx>
99 #include <unotools/streamwrap.hxx>
100 #include <unotools/fltrcfg.hxx>
101 #include <vcl/graph.hxx>
102 #include <vcl/graphicfilter.hxx>
103 #include <vcl/svapp.hxx>
104 #include <vcl/wmfexternal.hxx>
105 #include <sal/log.hxx>
106 #include <svx/sdtaitm.hxx>
108 
109 using namespace ::oox::core;
110 using namespace ::com::sun::star;
111 using namespace ::com::sun::star::uno;
112 using namespace ::com::sun::star::beans;
113 using namespace ::com::sun::star::frame;
114 using namespace ::com::sun::star::text;
115 using namespace ::com::sun::star::drawing;
116 using namespace ::com::sun::star::style;
117 
118 namespace oox::drawingml {
119 
120 Shape::Shape( const char* pServiceName, bool bDefaultHeight )
121 : mpLinePropertiesPtr( std::make_shared<LineProperties>() )
122 , mpShapeRefLinePropPtr( std::make_shared<LineProperties>() )
123 , mpFillPropertiesPtr( std::make_shared<FillProperties>() )
124 , mpShapeRefFillPropPtr( std::make_shared<FillProperties>() )
125 , mpGraphicPropertiesPtr( std::make_shared<GraphicProperties>() )
126 , mpCustomShapePropertiesPtr( std::make_shared<CustomShapeProperties>() )
127 , mp3DPropertiesPtr( std::make_shared<Shape3DProperties>() )
128 , mpEffectPropertiesPtr( std::make_shared<EffectProperties>() )
129 , mpShapeRefEffectPropPtr( std::make_shared<EffectProperties>() )
130 , mpMasterTextListStyle( std::make_shared<TextListStyle>() )
131 , mnSubType( 0 )
132 , meFrameType( FRAMETYPE_GENERIC )
133 , mnRotation( 0 )
134 , mnDiagramRotation( 0 )
135 , mbFlipH( false )
136 , mbFlipV( false )
137 , mbHidden( false )
138 , mbHiddenMasterShape( false )
139 , mbLocked( false )
140 , mbWPGChild(false)
141 , mbLockedCanvas( false )
142 , mbWps( false )
143 , mbTextBox( false )
144 , mbHasLinkedTxbx( false )
145 , maDiagramDoms( 0 )
146 , mpDiagramHelper( nullptr )
147 {
148  if ( pServiceName )
149  msServiceName = OUString::createFromAscii( pServiceName );
150  setDefaults(bDefaultHeight);
151 }
152 
153 Shape::Shape( const ShapePtr& pSourceShape )
154 : mpTextBody(pSourceShape->mpTextBody)
155 , mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
156 , mpShapeRefLinePropPtr( pSourceShape->mpShapeRefLinePropPtr )
157 , mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
158 , mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr )
159 , mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
160 , mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
161 , mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
162 , mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
163 , mpEffectPropertiesPtr (pSourceShape->mpEffectPropertiesPtr)
164 , mpShapeRefEffectPropPtr(pSourceShape->mpShapeRefEffectPropPtr)
165 , maShapeProperties( pSourceShape->maShapeProperties )
166 , mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
167 , msServiceName( pSourceShape->msServiceName )
168 , msName( pSourceShape->msName )
169 , msInternalName( pSourceShape->msInternalName )
170 , msId( pSourceShape->msId )
171 , mnSubType( pSourceShape->mnSubType )
172 , moSubTypeIndex( pSourceShape->moSubTypeIndex )
173 , maShapeStyleRefs( pSourceShape->maShapeStyleRefs )
174 , maSize( pSourceShape->maSize )
175 , maPosition( pSourceShape->maPosition )
176 , meFrameType( pSourceShape->meFrameType )
177 , mnRotation( pSourceShape->mnRotation )
178 , mnDiagramRotation( pSourceShape->mnDiagramRotation )
179 , mbFlipH( pSourceShape->mbFlipH )
180 , mbFlipV( pSourceShape->mbFlipV )
181 , mbHidden( pSourceShape->mbHidden )
182 , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
183 , mbLocked( pSourceShape->mbLocked )
184 , mbWPGChild( pSourceShape->mbWPGChild )
185 , mbLockedCanvas( pSourceShape->mbLockedCanvas )
186 , mbWps( pSourceShape->mbWps )
187 , mbTextBox( pSourceShape->mbTextBox )
188 , mbHasLinkedTxbx(false)
189 , maDiagramDoms( pSourceShape->maDiagramDoms )
190 , mnZOrder(pSourceShape->mnZOrder)
191 , mnZOrderOff(pSourceShape->mnZOrderOff)
192 , mnDataNodeType(pSourceShape->mnDataNodeType)
193 , mfAspectRatio(pSourceShape->mfAspectRatio)
194 , mpDiagramHelper( nullptr )
195 , msDiagramDataModelID(pSourceShape->msDiagramDataModelID)
196 {}
197 
199 {
200  // DiagramHelper should not be set here anymore, see
201  // propagateDiagramHelper below (maybe assert..?)
202  delete mpDiagramHelper;
203 }
204 
206  const std::shared_ptr< Diagram >& rDiagramPtr,
207  const std::shared_ptr<::oox::drawingml::Theme>& rTheme)
208 {
209  // Prepare Diagram data collecting for this Shape
210  if( nullptr == mpDiagramHelper && FRAMETYPE_DIAGRAM == meFrameType )
211  {
213  rDiagramPtr,
214  rTheme,
215  getSize());
216  }
217 }
218 
220 {
221  // Propagate collected Diagram data to data holder
222  if (FRAMETYPE_DIAGRAM == meFrameType && nullptr != mpDiagramHelper)
223  {
224  SdrObjGroup* pAnchorObj = dynamic_cast<SdrObjGroup*>(SdrObject::getSdrObjectFromXShape(mxShape));
225 
226  if(pAnchorObj)
227  {
228  static_cast<AdvancedDiagramHelper*>(mpDiagramHelper)->doAnchor(*pAnchorObj, *this);
229  mpDiagramHelper = nullptr;
230  }
231  }
232 
233  // If propagation failed, delete/cleanup here. Since the DiagramHelper
234  // holds a Diagram and that this Shape it is necessary - the destructor
235  // will not be called and will be too late
236  if (nullptr != mpDiagramHelper)
237  {
238  delete mpDiagramHelper;
239  mpDiagramHelper = nullptr;
240  }
241 }
242 
244 {
245  if(!mpDiagramHelper)
246  {
247  return;
248  }
249 
250  if(!pTarget)
251  {
252  // no migrate target, but cleanup helper
253  delete mpDiagramHelper;
254  mpDiagramHelper = nullptr;
255  return;
256  }
257 
258  if(pTarget->mpDiagramHelper)
259  {
260  // this should no happen, but if there is already a helper, clean it up
261  delete pTarget->mpDiagramHelper;
262  pTarget->mpDiagramHelper = nullptr;
263  }
264 
265  // exchange and reset to nullptr
266  pTarget->mpDiagramHelper = mpDiagramHelper;
267  mpDiagramHelper = nullptr;
268 }
269 
271 {
272  if ( !mpTablePropertiesPtr )
273  mpTablePropertiesPtr = std::make_shared<table::TableProperties>();
274  return mpTablePropertiesPtr;
275 }
276 
277 void Shape::setDefaults(bool bHeight)
278 {
279  maDefaultShapeProperties.setProperty(PROP_TextAutoGrowHeight, false);
280  maDefaultShapeProperties.setProperty(PROP_TextWordWrap, true);
281  maDefaultShapeProperties.setProperty(PROP_TextLeftDistance, static_cast< sal_Int32 >( 250 ));
282  maDefaultShapeProperties.setProperty(PROP_TextUpperDistance, static_cast< sal_Int32 >( 125 ));
283  maDefaultShapeProperties.setProperty(PROP_TextRightDistance, static_cast< sal_Int32 >( 250 ));
284  maDefaultShapeProperties.setProperty(PROP_TextLowerDistance, static_cast< sal_Int32 >( 125 ));
285  if (bHeight)
286  maDefaultShapeProperties.setProperty(PROP_CharHeight, static_cast< float >( 18.0 ));
287  maDefaultShapeProperties.setProperty(PROP_TextVerticalAdjust, TextVerticalAdjust_TOP);
288  maDefaultShapeProperties.setProperty(PROP_ParaAdjust,
289  static_cast<sal_Int16>(ParagraphAdjust_LEFT));
290 }
291 
293 {
294  OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setOleObjectType - multiple frame types" );
296  mxOleObjectInfo = std::make_shared<::oox::vml::OleObjectInfo>( true );
297  return *mxOleObjectInfo;
298 }
299 
300 ChartShapeInfo& Shape::setChartType( bool bEmbedShapes )
301 {
302  OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setChartType - multiple frame types" );
304  if (mbWps)
305  msServiceName = "com.sun.star.drawing.temporaryForXMLImportOLE2Shape";
306  else
307  msServiceName = "com.sun.star.drawing.OLE2Shape";
308  mxChartShapeInfo = std::make_shared<ChartShapeInfo>( bEmbedShapes );
309  return *mxChartShapeInfo;
310 }
311 
313 {
314  OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setDiagramType - multiple frame types" );
316  msServiceName = "com.sun.star.drawing.GroupShape";
317  mnSubType = 0;
318 }
319 
321 {
322  OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setTableType - multiple frame types" );
324  msServiceName = "com.sun.star.drawing.TableShape";
325  mnSubType = 0;
326 }
327 
328 void Shape::setServiceName( const char* pServiceName )
329 {
330  if ( pServiceName )
331  msServiceName = OUString::createFromAscii( pServiceName );
332 }
333 
334 const ShapeStyleRef* Shape::getShapeStyleRef( sal_Int32 nRefType ) const
335 {
336  ShapeStyleRefMap::const_iterator aIt = maShapeStyleRefs.find( nRefType );
337  return (aIt == maShapeStyleRefs.end()) ? nullptr : &aIt->second;
338 }
339 
341  ::oox::core::XmlFilterBase& rFilterBase,
342  const Theme* pTheme,
343  const Reference< XShapes >& rxShapes,
344  const basegfx::B2DHomMatrix& aTransformation,
345  const FillProperties& rShapeOrParentShapeFillProps,
346  ShapeIdMap* pShapeMap,
347  oox::drawingml::ShapePtr pParentGroupShape)
348 {
349  SAL_INFO("oox.drawingml", "Shape::addShape: id='" << msId << "'");
350 
351  try
352  {
353  OUString sServiceName( msServiceName );
354  if( !sServiceName.isEmpty() )
355  {
356  basegfx::B2DHomMatrix aMatrix( aTransformation );
357  Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, false, false, aMatrix, rShapeOrParentShapeFillProps, pParentGroupShape) );
358 
359  if( pShapeMap && !msId.isEmpty() )
360  {
361  (*pShapeMap)[ msId ] = shared_from_this();
362  }
363 
364  // if this is a group shape, we have to add also each child shape
365  Reference< XShapes > xShapes( xShape, UNO_QUERY );
366  if ( xShapes.is() )
367  addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, aMatrix );
368 
369  if (isWPGChild() && xShape)
370  {
371  // This is a wps shape and it is the child of the WPG, now copy the
372  // the text body properties to the xshape.
373  Reference<XPropertySet> xChildWPSProperties(xShape, uno::UNO_QUERY);
374 
375  if (getTextBody() && xChildWPSProperties)
376  {
377  xChildWPSProperties->setPropertyValue(
379  uno::Any(getTextBody()->getTextProperties().meVA));
380 
381  xChildWPSProperties->setPropertyValue(
383  uno::Any(getTextBody()->getTextProperties().moInsets[0].has_value()
384  ? *getTextBody()->getTextProperties().moInsets[0]
385  : 0));
386  xChildWPSProperties->setPropertyValue(
388  uno::Any(getTextBody()->getTextProperties().moInsets[1].has_value()
389  ? *getTextBody()->getTextProperties().moInsets[1]
390  : 0));
391  xChildWPSProperties->setPropertyValue(
393  uno::Any(getTextBody()->getTextProperties().moInsets[2].has_value()
394  ? *getTextBody()->getTextProperties().moInsets[2]
395  : 0));
396  xChildWPSProperties->setPropertyValue(
398  uno::Any(getTextBody()->getTextProperties().moInsets[3].has_value()
399  ? *getTextBody()->getTextProperties().moInsets[3]
400  : 0));
401  }
402  }
403 
405  {
407 
408  // set DiagramHelper at SdrObjGroup
410 
411  // Check if this is the PPTX import, so far converting SmartArt to a non-editable
412  // metafile is only implemented for DOCX.
413  bool bPowerPoint = dynamic_cast<oox::ppt::PowerPointImport*>(&rFilterBase) != nullptr;
414 
415  if (!SvtFilterOptions::Get().IsSmartArt2Shape() && !bPowerPoint)
416  convertSmartArtToMetafile( rFilterBase );
417  }
418 
419  NamedShapePairs* pNamedShapePairs = rFilterBase.getDiagramFontHeights();
420  if (xShape.is() && pNamedShapePairs)
421  {
422  auto itPairs = pNamedShapePairs->find(getInternalName());
423  if (itPairs != pNamedShapePairs->end())
424  {
425  auto it = itPairs->second.find(shared_from_this());
426  if (it != itPairs->second.end())
427  {
428  // Our drawingml::Shape is in the list of an internal name, remember the now
429  // inserted XShape.
430  it->second = xShape;
431  }
432  }
433  }
434  }
435  }
436  catch( const Exception& )
437  {
438  TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::addShape" );
439  }
440 }
441 
442 void Shape::setLockedCanvas(bool bLockedCanvas)
443 {
444  mbLockedCanvas = bLockedCanvas;
445 }
446 
447 void Shape::setWPGChild(bool bWPG)
448 {
449  mbWPGChild = bWPG;
450 }
451 
452 void Shape::setWps(bool bWps)
453 {
454  mbWps = bWps;
455 }
456 
457 void Shape::setTextBox(bool bTextBox)
458 {
459  mbTextBox = bTextBox;
460 }
461 
462 void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
463 {
464  SAL_INFO("oox.drawingml", "Shape::applyShapeReference: apply '" << rReferencedShape.msId << "' to '" << msId << "'");
465 
466  if ( rReferencedShape.mpTextBody && bUseText )
467  mpTextBody = std::make_shared<TextBody>( *rReferencedShape.mpTextBody );
468  else
469  mpTextBody.reset();
470  maShapeProperties = rReferencedShape.maShapeProperties;
471  mpShapeRefLinePropPtr = std::make_shared<LineProperties>( rReferencedShape.getActualLineProperties(nullptr) );
472  mpShapeRefFillPropPtr = std::make_shared<FillProperties>( rReferencedShape.getActualFillProperties(nullptr, nullptr) );
473  mpCustomShapePropertiesPtr = std::make_shared<CustomShapeProperties>( *rReferencedShape.mpCustomShapePropertiesPtr );
474  mpTablePropertiesPtr = rReferencedShape.mpTablePropertiesPtr ? std::make_shared<table::TableProperties>( *rReferencedShape.mpTablePropertiesPtr ) : nullptr;
475  mpShapeRefEffectPropPtr = std::make_shared<EffectProperties>( rReferencedShape.getActualEffectProperties(nullptr) );
476  mpMasterTextListStyle = std::make_shared<TextListStyle>( *rReferencedShape.mpMasterTextListStyle );
477  maSize = rReferencedShape.maSize;
478  maPosition = rReferencedShape.maPosition;
479  mnRotation = rReferencedShape.mnRotation;
480  mbFlipH = rReferencedShape.mbFlipH;
481  mbFlipV = rReferencedShape.mbFlipV;
482  mbHidden = rReferencedShape.mbHidden;
483  mbLocked = rReferencedShape.mbLocked;
484 }
485 
486 namespace {
487 
488 struct ActionLockGuard
489 {
490  explicit ActionLockGuard(Reference<drawing::XShape> const& xShape)
491  : m_xLockable(xShape, UNO_QUERY)
492  {
493  if (m_xLockable.is()) {
494  m_xLockable->addActionLock();
495  }
496  }
497  ~ActionLockGuard()
498  {
499  if (m_xLockable.is()) {
500  m_xLockable->removeActionLock();
501  }
502  }
503 private:
504  Reference<document::XActionLockable> m_xLockable;
505 };
506 
507 }
508 
509 // for group shapes, the following method is also adding each child
511  XmlFilterBase& rFilterBase,
512  Shape& rMaster,
513  const Theme* pTheme,
514  const Reference< XShapes >& rxShapes,
515  ShapeIdMap* pShapeMap,
516  const basegfx::B2DHomMatrix& aTransformation )
517 {
518  for (auto const& child : rMaster.maChildren)
519  {
520  child->setMasterTextListStyle( mpMasterTextListStyle );
521  child->addShape( rFilterBase, pTheme, rxShapes, aTransformation, getFillProperties(), pShapeMap, rMaster.shared_from_this());
522  }
523 }
524 
525 static void lcl_resetPropertyValue( std::vector<beans::PropertyValue>& rPropVec, const OUString& rName )
526 {
527  auto aIterator = std::find_if( rPropVec.begin(), rPropVec.end(),
528  [rName]( const beans::PropertyValue& rValue ) { return rValue.Name == rName; } );
529 
530  if (aIterator != rPropVec.end())
531  rPropVec.erase( aIterator );
532 }
533 
534 static void lcl_setPropertyValue( std::vector<beans::PropertyValue>& rPropVec,
535  const OUString& rName,
536  const beans::PropertyValue& rPropertyValue )
537 {
538  lcl_resetPropertyValue( rPropVec, rName );
539 
540  rPropVec.push_back( rPropertyValue );
541 }
542 
543 static SdrTextHorzAdjust lcl_convertAdjust( ParagraphAdjust eAdjust )
544 {
545  if (eAdjust == ParagraphAdjust_LEFT)
546  return SDRTEXTHORZADJUST_LEFT;
547  else if (eAdjust == ParagraphAdjust_RIGHT)
549  else if (eAdjust == ParagraphAdjust_CENTER)
551  return SDRTEXTHORZADJUST_LEFT;
552 }
553 
554 static void lcl_createPresetShape(const uno::Reference<drawing::XShape>& xShape,
555  const OUString& rClass, const OUString& rPresetType,
556  const CustomShapePropertiesPtr& pCustomShapePropertiesPtr,
557  const TextBodyPtr& pTextBody,
558  const GraphicHelper& rGraphicHelper)
559 {
560  if (!xShape.is() || !pCustomShapePropertiesPtr || !pTextBody)
561  return;
562 
563  uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter( xShape,
564  uno::UNO_QUERY );
565 
566  if (!xDefaulter.is() || rClass.isEmpty())
567  return;
568 
569  Reference<XPropertySet> xSet( xShape, UNO_QUERY );
570  if (!xSet.is())
571  return;
572 
573  // The DrawingML shapes from the presetTextWarpDefinitions are mapped to the definitions
574  // in svx/../EnhancedCustomShapeGeometry.cxx, which are used for WordArt shapes from
575  // binary MS Office. Therefore all adjustment values need to be adapted.
576  auto aAdjGdList = pCustomShapePropertiesPtr->getAdjustmentGuideList();
578  !aAdjGdList.empty() ? aAdjGdList.size() : 1 );
579  auto pAdjustment = aAdjustment.getArray();
580  int nIndex = 0;
581  for (const auto& aEntry : aAdjGdList)
582  {
583  double fValue = aEntry.maFormula.toDouble();
584  // then: polar-handle, else: XY-handle
585  // There exist only 8 polar-handles at all in presetTextWarp.
586  if ((rClass == "fontwork-arch-down-curve")
587  || (rClass == "fontwork-arch-down-pour" && aEntry.maName == "adj1")
588  || (rClass == "fontwork-arch-up-curve")
589  || (rClass == "fontwork-arch-up-pour" && aEntry.maName == "adj1")
590  || (rClass == "fontwork-open-circle-curve")
591  || (rClass == "fontwork-open-circle-pour" && aEntry.maName == "adj1")
592  || (rClass == "fontwork-circle-curve")
593  || (rClass == "fontwork-circle-pour" && aEntry.maName == "adj1"))
594  {
595  // DrawingML has 1/60000 degree unit, but WordArt simple degree. Range [0..360[
596  // or range ]-180..180] doesn't matter, because only cos(angle) and
597  // sin(angle) are used.
598  fValue = NormAngle360(fValue / 60000.0);
599  }
600  else
601  {
602  // DrawingML writes adjustment guides as relative value with 100% = 100000,
603  // but WordArt definitions use values absolute in viewBox 0 0 21600 21600,
604  // so scale with 21600/100000 = 0.216, with two exceptions:
605  // X-handles of waves describe increase/decrease relative to horizontal center.
606  // The gdRefR of pour-shapes is not relative to viewBox but to radius.
607  if ((rClass == "mso-spt158" && aEntry.maName == "adj2") // textDoubleWave1
608  || (rClass == "fontwork-wave" && aEntry.maName == "adj2") // textWave1
609  || (rClass == "mso-spt157" && aEntry.maName == "adj2") // textWave2
610  || (rClass == "mso-spt159" && aEntry.maName == "adj2")) // textWave4
611  {
612  fValue = (fValue + 50000.0) * 0.216;
613  }
614  else if ( (rClass == "fontwork-arch-down-pour" && aEntry.maName == "adj2")
615  || (rClass == "fontwork-arch-up-pour" && aEntry.maName == "adj2")
616  || (rClass == "fontwork-open-circle-pour" && aEntry.maName == "adj2")
617  || (rClass == "fontwork-circle-pour" && aEntry.maName == "adj2"))
618  {
619  fValue *= 0.108;
620  }
621  else
622  {
623  fValue *= 0.216;
624  }
625  }
626 
627  pAdjustment[nIndex].Value <<= fValue;
628  pAdjustment[nIndex++].State = css::beans::PropertyState_DIRECT_VALUE;
629  }
630 
631  // Set properties
632  xSet->setPropertyValue( UNO_NAME_TEXT_AUTOGROWHEIGHT, uno::Any( false ) );
633  xSet->setPropertyValue( UNO_NAME_TEXT_AUTOGROWWIDTH, uno::Any( false ) );
634  xSet->setPropertyValue( UNO_NAME_FILLSTYLE, uno::Any( drawing::FillStyle_SOLID ) );
635 
636  // ToDo: Old binary WordArt does not allow different styles for different paragraphs, so it
637  // was not necessary to examine all paragraphs. Solution for DrawingML is needed.
638  // Currently different alignment of paragraphs are lost, for example.
639  const TextParagraphVector& rParagraphs = pTextBody->getParagraphs();
640  if (!rParagraphs.empty() && !rParagraphs[0]->getRuns().empty())
641  {
642  std::shared_ptr<TextParagraph> pParagraph = rParagraphs[0];
643  std::shared_ptr<TextRun> pRun = pParagraph->getRuns()[0];
644  TextCharacterProperties& pProperties = pRun->getTextCharacterProperties();
645 
646  if (pProperties.moBold.has_value() && pProperties.moBold.get())
647  {
648  xSet->setPropertyValue( UNO_NAME_CHAR_WEIGHT, uno::Any( css::awt::FontWeight::BOLD ) );
649  }
650  if (pProperties.moItalic.has_value() && pProperties.moItalic.get())
651  {
652  xSet->setPropertyValue( UNO_NAME_CHAR_POSTURE, uno::Any( css::awt::FontSlant::FontSlant_ITALIC ) );
653  }
654  if (pProperties.moHeight.has_value())
655  {
656  sal_Int32 nHeight = pProperties.moHeight.get() / 100;
657  xSet->setPropertyValue( UNO_NAME_CHAR_HEIGHT, uno::Any( nHeight ) );
658  }
659  if (pProperties.maFillProperties.maFillColor.isUsed())
660  {
661  const sal_Int32 aFillColor = static_cast<sal_Int32>(
662  pProperties.maFillProperties.maFillColor.getColor( rGraphicHelper ).GetRGBColor() );
663  xSet->setPropertyValue( UNO_NAME_FILLCOLOR, uno::Any( aFillColor ) );
664  }
665  else
666  {
667  // Set default color
668  xSet->setPropertyValue( UNO_NAME_FILLCOLOR, uno::Any( COL_BLACK ) );
669  }
670  {
671  ParagraphAdjust eAdjust = ParagraphAdjust_LEFT;
672  if (pParagraph->getProperties().getParaAdjust())
673  eAdjust = *pParagraph->getProperties().getParaAdjust();
674  xSet->setPropertyValue( "ParaAdjust", uno::Any( eAdjust ) );
675  SdrObject* pShape = SdrObject::getSdrObjectFromXShape( xShape );
676  assert(pShape);
677  SdrTextHorzAdjust eHorzAdjust = lcl_convertAdjust( eAdjust );
678  pShape->SetMergedItem( SdrTextHorzAdjustItem( eHorzAdjust ) );
679  }
680  }
681 
682  // Apply vertical adjustment for text on arc
683  // ToDo: The property is currently not evaluated.
685  assert(pShape);
686  if (rClass == "fontwork-arch-up-curve" || rClass == "fontwork-circle-curve")
687  pShape->SetMergedItem( SdrTextVertAdjustItem( SdrTextVertAdjust::SDRTEXTVERTADJUST_BOTTOM ) );
688  else if (rClass == "fontwork-arch-down-curve")
689  pShape->SetMergedItem( SdrTextVertAdjustItem( SdrTextVertAdjust::SDRTEXTVERTADJUST_TOP ) );
690 
691  // Apply preset shape
692  xDefaulter->createCustomShapeDefaults( rClass );
693 
694  auto aGeomPropSeq = xSet->getPropertyValue( "CustomShapeGeometry" )
695  .get<uno::Sequence<beans::PropertyValue>>();
696  auto aGeomPropVec
697  = comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(
698  aGeomPropSeq );
699 
700  // Reset old properties
701  static const OUStringLiteral sTextPath( u"TextPath" );
702  static const OUStringLiteral sAdjustmentValues( u"AdjustmentValues" );
703  static const OUStringLiteral sPresetTextWarp( u"PresetTextWarp" );
704 
705  lcl_resetPropertyValue( aGeomPropVec, "CoordinateSize" );
706  lcl_resetPropertyValue( aGeomPropVec, "Equations" );
707  lcl_resetPropertyValue( aGeomPropVec, "Path" );
708  lcl_resetPropertyValue( aGeomPropVec, sAdjustmentValues);
709 
710  bool bFromWordArt(false);
711  pTextBody->getTextProperties().maPropertyMap.getProperty(PROP_FromWordArt) >>= bFromWordArt;
712 
713  bool bScaleX(false);
714  if (!bFromWordArt
715  && (rPresetType == "textArchDown" || rPresetType == "textArchUp"
716  || rPresetType == "textCircle" || rPresetType == "textButton"))
717  {
718  bScaleX = true;
719  }
720 
721  // Apply geometry properties
722  uno::Sequence<beans::PropertyValue> aPropertyValues(
724  { { sTextPath, uno::Any( true ) },
725  { "TextPathMode",
726  uno::Any( drawing::EnhancedCustomShapeTextPathMode_PATH ) },
727  { "ScaleX", uno::Any(bScaleX) } } ) );
728 
729  lcl_setPropertyValue( aGeomPropVec, sTextPath,
730  comphelper::makePropertyValue( sTextPath, aPropertyValues ) );
731 
732  lcl_setPropertyValue( aGeomPropVec, sPresetTextWarp,
733  comphelper::makePropertyValue( sPresetTextWarp, rPresetType ) );
734 
735  if (!aAdjGdList.empty())
736  {
737  lcl_setPropertyValue( aGeomPropVec, sAdjustmentValues,
738  comphelper::makePropertyValue( sAdjustmentValues, aAdjustment ) );
739  }
740 
741  xSet->setPropertyValue(
742  "CustomShapeGeometry",
744 }
745 
746 // Some helper methods for createAndInsert
747 namespace
748 {
749 // mirrors aTransformation at its center axis
750 // only valid if neither rotation or shear included
751 void lcl_mirrorAtCenter(basegfx::B2DHomMatrix& aTransformation, bool bFlipH, bool bFlipV)
752 {
753  if (!bFlipH && !bFlipV)
754  return;
755  basegfx::B2DPoint aCenter(0.5, 0.5);
756  aCenter *= aTransformation;
757  aTransformation.translate(-aCenter);
758  aTransformation.scale(bFlipH ? -1.0 : 1.0, bFlipV ? -1.0 : 1.0);
759  aTransformation.translate(aCenter);
760  return;
761 }
762 
763 // only valid if neither rotation or shear included
764 void lcl_doSpecialMSOWidthHeightToggle(basegfx::B2DHomMatrix& aTransformation)
765 {
766  // The values are directly set at the matrix without any matrix multiplication.
767  // That way it is valid for lines too. Those have zero width or height.
768  const double fSx(aTransformation.get(0, 0));
769  const double fSy(aTransformation.get(1, 1));
770  const double fTx(aTransformation.get(0, 2));
771  const double fTy(aTransformation.get(1, 2));
772  aTransformation.set(0, 0, fSy);
773  aTransformation.set(1, 1, fSx);
774  aTransformation.set(0, 2, fTx + 0.5 * (fSx - fSy));
775  aTransformation.set(1, 2, fTy + 0.5 * (fSy - fSx));
776  return;
777 }
778 
779 void lcl_RotateAtCenter(basegfx::B2DHomMatrix& aTransformation,sal_Int32 nMSORotationAngle)
780 {
781  if (nMSORotationAngle == 0)
782  return;
783  double fRad = basegfx::deg2rad<60000>(nMSORotationAngle);
784  basegfx::B2DPoint aCenter(0.5, 0.5);
785  aCenter *= aTransformation;
786  aTransformation.translate(-aCenter);
787  aTransformation.rotate(fRad);
788  aTransformation.translate(aCenter);
789  return;
790 }
791 }
792 
794  ::oox::core::XmlFilterBase& rFilterBase,
795  const OUString& rServiceName,
796  const Theme* pTheme,
797  const css::uno::Reference< css::drawing::XShapes >& rxShapes,
798  bool bClearText,
799  bool bDoNotInsertEmptyTextBody,
800  basegfx::B2DHomMatrix& aParentTransformation,
801  const FillProperties& rShapeOrParentShapeFillProps,
802  oox::drawingml::ShapePtr pParentGroupShape)
803 {
804  bool bIsEmbMedia = false;
805  SAL_INFO("oox.drawingml", "Shape::createAndInsert: id='" << msId << "' service='" << rServiceName << "'");
806 
807  formulaimport::XmlStreamBuilder * pMathXml(nullptr);
808  if (mpTextBody)
809  {
810  for (auto const& it : mpTextBody->getParagraphs())
811  {
812  if (it->HasMathXml())
813  {
814  if (!mpTextBody->isEmpty() || pMathXml != nullptr)
815  {
816  SAL_WARN("oox.drawingml", "losing a Math object...");
817  }
818  else
819  {
820  pMathXml = &it->GetMathXml();
821  }
822  }
823  }
824  }
825 
826  // tdf#90403 PowerPoint ignores a:ext cx and cy values of p:xfrm, and uses real table width and height
827  if ( mpTablePropertiesPtr && rServiceName == "com.sun.star.drawing.TableShape" )
828  {
829  maSize.Width = 0;
830  for (auto const& elem : mpTablePropertiesPtr->getTableGrid())
831  {
832  maSize.Width = o3tl::saturating_add(maSize.Width, static_cast<sal_Int32>(elem));
833  }
834  maSize.Height = 0;
835  for (auto const& elem : mpTablePropertiesPtr->getTableRows())
836  {
837  maSize.Height = o3tl::saturating_add(maSize.Height, elem.getHeight());
838  }
839  }
840 
841  awt::Rectangle aShapeRectHmm(
846 
847  OUString aServiceName;
848  if (pMathXml)
849  {
850  // convert this shape to OLE
851  aServiceName = "com.sun.star.drawing.OLE2Shape";
852  msServiceName = aServiceName;
853  meFrameType = FRAMETYPE_GENERIC; // not OLEOBJECT, no stream in package
854  mnSubType = 0;
855  }
856  else if (rServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
857  mpGraphicPropertiesPtr && !mpGraphicPropertiesPtr->m_sMediaPackageURL.isEmpty())
858  {
859  aServiceName = finalizeServiceName( rFilterBase, "com.sun.star.presentation.MediaShape", aShapeRectHmm );
860  bIsEmbMedia = true;
861  }
862  else
863  {
864  aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
865  }
866  // Use custom shape instead of GraphicObjectShape if the image is cropped to
867  // shape. Except rectangle, which does not require further cropping
868  bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
869  !mpCustomShapePropertiesPtr->representsDefaultShape());
870 
871  bool bIsCustomShape = (aServiceName == "com.sun.star.drawing.CustomShape" || bIsCroppedGraphic);
872  bool bIsConnectorShape = (aServiceName == "com.sun.star.drawing.ConnectorShape");
873  if(bIsCroppedGraphic)
874  {
875  aServiceName = "com.sun.star.drawing.CustomShape";
876  mpGraphicPropertiesPtr->mbIsCustomShape = true;
877  }
878  bool bUseRotationTransform = ( !mbWps ||
879  aServiceName == "com.sun.star.drawing.LineShape" ||
880  aServiceName == "com.sun.star.drawing.GroupShape" ||
881  mbFlipH ||
882  mbFlipV );
883 
884  basegfx::B2DHomMatrix aTransformation; // will be cumulative transformation of this object
885 
886  // Special for SmartArt import. Rotate diagram's shape around object's center before sizing.
887  if (bUseRotationTransform && mnDiagramRotation != 0)
888  {
889  aTransformation.translate(-0.5, -0.5);
890  aTransformation.rotate(basegfx::deg2rad<60000>(mnDiagramRotation));
891  aTransformation.translate(0.5, 0.5);
892  }
893 
894  // Build object matrix from shape size and position; corresponds to MSO ext and off
895  // Only LineShape and ConnectorShape may have zero width or height.
896  if (aServiceName == "com.sun.star.drawing.LineShape"
897  || aServiceName == "com.sun.star.drawing.ConnectorShape")
898  aTransformation.scale(maSize.Width, maSize.Height);
899  else
900  {
901  aTransformation.scale(maSize.Width ? maSize.Width : 1.0,
902  maSize.Height ? maSize.Height : 1.0);
903  }
904 
905  // Evaluate object flip. Other shapes than custom shapes have no attribute for flip but use
906  // negative scale. Flip in MSO is at object center.
907  if (!bIsCustomShape && (mbFlipH || mbFlipV))
908  lcl_mirrorAtCenter(aTransformation, mbFlipH, mbFlipV);
909 
910  // Evaluate parent flip.
911  // A CustomShape has mirror not as negative scale, but as attributes.
912  basegfx::B2DVector aParentScale(1.0, 1.0);
913  basegfx::B2DVector aParentTranslate(0.0, 0.0);
914  double fParentRotate(0.0);
915  double fParentShearX(0.0);
916  if (pParentGroupShape)
917  {
918  aParentTransformation.decompose(aParentScale, aParentTranslate, fParentRotate, fParentShearX);
919  if (bIsCustomShape)
920  {
921  lcl_mirrorAtCenter(aTransformation, aParentScale.getX() < 0, aParentScale.getY() < 0);
922  if(aParentScale.getX() < 0)
923  mbFlipH = !mbFlipH;
924  if(aParentScale.getY() < 0)
925  mbFlipV = !mbFlipV;
926  }
927  }
928 
929  if (maPosition.X != 0 || maPosition.Y != 0)
930  {
931  // if global position is used, add it to transformation
932  if (mbWps && pParentGroupShape == nullptr)
933  aTransformation.translate(
936  else
937  aTransformation.translate(maPosition.X, maPosition.Y);
938  }
939 
940  // Apply further parent transformations. First scale object then rotate. Other way round would
941  // introduce shearing.
942 
943  // The attributes chExt and chOff of the group in oox file contain the values on which the size
944  // and position of the child is based on. If they differ from the actual size of the group as
945  // given in its ext and off attributes, the child has to be transformed according the new values.
946  if (pParentGroupShape)
947  {
948  // ToDo: A diagram in a group might need special handling because it cannot flip and only
949  // resize uniformly. But currently it is imported with zero size, see tdf#139575. That needs
950  // to be fixed beforehand.
951 
952  // Scaling is done from left/top edges of the group. So these need to become coordinate axes.
953  aTransformation.translate(-pParentGroupShape->maChPosition.X,
954  -pParentGroupShape->maChPosition.Y);
955 
956  // oox allows zero or missing attribute chExt. In that case the scaling factor is 1.
957  // Transform2DContext::onCreateContext has set maChSize to maSize for groups in oox file in
958  // such cases. For own made groups (e.g. diagrams) that is missing.
959  // The factors cumulate on the way through the parent groups, so we do not use maSize of the
960  // direct parent group but the cumulated value from aParentScale.
961  double fFactorX = 1.0;
962  double fFactorY = 1.0;
963  if (pParentGroupShape->maChSize.Width != 0)
964  fFactorX = aParentScale.getX() / pParentGroupShape->maChSize.Width;
965  if (pParentGroupShape->maChSize.Height != 0)
966  fFactorY = aParentScale.getY() / pParentGroupShape->maChSize.Height;
967  if (fFactorX != 1 || fFactorY != 1)
968  {
969  // It depends on the object rotation angle whether scaling is applied to switched
970  // width and height. MSO acts strange in that case (as of May 2021).
971  const sal_Int32 nDeg(mnRotation / 60000);
972  const bool bNeedsMSOWidhtHeightToggle
973  = (nDeg >= 45 && nDeg < 135) || (nDeg >= 225 && nDeg < 315);
974  if (bNeedsMSOWidhtHeightToggle)
975  lcl_doSpecialMSOWidthHeightToggle(aTransformation);
976 
977  aTransformation.scale(fFactorX, fFactorY);
978 
979  if (bNeedsMSOWidhtHeightToggle)
980  {
981  lcl_doSpecialMSOWidthHeightToggle(aTransformation);
982  // In case of flip the special case needs an additional 180deg rotation.
983  if ((aParentScale.getX() < 0) != (aParentScale.getY() < 0))
984  lcl_RotateAtCenter(aTransformation, 10800000);
985  }
986  }
987  }
988 
989  // Apply object rotation at current object center
990  // The flip contained in aParentScale will affect orientation of object rotation angle.
991  sal_Int16 nOrientation = ((aParentScale.getX() < 0) != (aParentScale.getY() < 0)) ? -1 : 1;
992  // ToDo: Not sure about the restrictions given by bUseRotationTransform.
993  // Since LibreOffice doesn't have 3D camera options for 2D shapes, rotate the shape opposite of
994  // the camera Z axis rotation, in order to produce the same visual result from MSO
995  const sal_Int32 nCameraRotation = get3DProperties().maCameraRotation.mnRevolution.get(0);
996  if (bUseRotationTransform && (mnRotation != 0 || nCameraRotation != 0))
997  lcl_RotateAtCenter(aTransformation, nOrientation * (mnRotation - nCameraRotation));
998 
999  if (fParentRotate != 0.0)
1000  aTransformation.rotate(fParentRotate);
1001  if (!aParentTranslate.equalZero())
1002  aTransformation.translate(aParentTranslate);
1003 
1004  aParentTransformation = aTransformation;
1005 
1006  constexpr double fEmuToMm100 = o3tl::convert(1.0, o3tl::Length::emu, o3tl::Length::mm100);
1007  aTransformation.scale(fEmuToMm100, fEmuToMm100);
1008 
1009  // OOXML flips shapes before rotating them, so the rotation needs to be inverted
1010  if( bIsCustomShape && mbFlipH != mbFlipV )
1011  {
1012  basegfx::B2DVector aScale, aTranslate;
1013  double fRotate, fShearX;
1014  aTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
1015 
1016  if(fRotate != 0)
1017  {
1018  basegfx::B2DPoint aCenter(0.5, 0.5);
1019  aCenter *= aTransformation;
1020  aTransformation.translate( -aCenter.getX(), -aCenter.getY() );
1021  aTransformation.rotate( fRotate * -2.0 );
1022  aTransformation.translate( aCenter.getX(), aCenter.getY() );
1023  }
1024  }
1025 
1026  // special for lineshape
1027  if ( aServiceName == "com.sun.star.drawing.LineShape" )
1028  {
1029  ::basegfx::B2DPolygon aPoly;
1030  aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
1031  aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
1032  aPoly.transform( aTransformation );
1033 
1034  // now creating the corresponding PolyPolygon
1035  sal_Int32 i, nNumPoints = aPoly.count();
1036  uno::Sequence< awt::Point > aPointSequence( nNumPoints );
1037  awt::Point* pPoints = aPointSequence.getArray();
1038  for( i = 0; i < nNumPoints; ++i )
1039  {
1040  basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
1041 
1042  // Guard against zero width or height.
1043  if (i)
1044  {
1045  const basegfx::B2DPoint& rPreviousPoint = aPoly.getB2DPoint(i - 1);
1046  if (aPoint.getX() - rPreviousPoint.getX() == 0)
1047  aPoint.setX(aPoint.getX() + 1);
1048  if (aPoint.getY() - rPreviousPoint.getY() == 0)
1049  aPoint.setY(aPoint.getY() + 1);
1050  }
1051 
1052  pPoints[i] = awt::Point(static_cast<sal_Int32>(aPoint.getX()), static_cast<sal_Int32>(aPoint.getY()));
1053  }
1054  uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
1055  aPolyPolySequence.getArray()[ 0 ] = aPointSequence;
1056 
1057  maShapeProperties.setProperty(PROP_PolyPolygon, aPolyPolySequence);
1058  }
1059  else if ( aServiceName == "com.sun.star.drawing.ConnectorShape" )
1060  {
1061  ::basegfx::B2DPolygon aPoly;
1062  aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
1063  aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
1064  aPoly.transform( aTransformation );
1065 
1066  basegfx::B2DPoint aStartPosition( aPoly.getB2DPoint( 0 ) );
1067  basegfx::B2DPoint aEndPosition( aPoly.getB2DPoint( 1 ) );
1068  awt::Point aAWTStartPosition( static_cast< sal_Int32 >( aStartPosition.getX() ), static_cast< sal_Int32 >( aStartPosition.getY() ) );
1069  awt::Point aAWTEndPosition( static_cast< sal_Int32 >( aEndPosition.getX() ), static_cast< sal_Int32 >( aEndPosition.getY() ) );
1070 
1071  maShapeProperties.setProperty(PROP_StartPosition, aAWTStartPosition);
1072  maShapeProperties.setProperty(PROP_EndPosition, aAWTEndPosition);
1073  }
1074  else
1075  {
1076  // now set transformation for this object
1077  HomogenMatrix3 aMatrix;
1078 
1079  aMatrix.Line1.Column1 = aTransformation.get(0,0);
1080  aMatrix.Line1.Column2 = aTransformation.get(0,1);
1081  aMatrix.Line1.Column3 = aTransformation.get(0,2);
1082 
1083  aMatrix.Line2.Column1 = aTransformation.get(1,0);
1084  aMatrix.Line2.Column2 = aTransformation.get(1,1);
1085  aMatrix.Line2.Column3 = aTransformation.get(1,2);
1086 
1087  aMatrix.Line3.Column1 = aTransformation.get(2,0);
1088  aMatrix.Line3.Column2 = aTransformation.get(2,1);
1089  aMatrix.Line3.Column3 = aTransformation.get(2,2);
1090 
1091  maShapeProperties.setProperty(PROP_Transformation, aMatrix);
1092  }
1093 
1094  Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
1095  if ( !mxShape.is() )
1096  {
1097  mxShape.set( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW );
1098  }
1099 
1100  Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
1101  if (xSet.is())
1102  {
1103  if( !msName.isEmpty() )
1104  {
1105  Reference< container::XNamed > xNamed( mxShape, UNO_QUERY );
1106  if( xNamed.is() )
1107  xNamed->setName( msName );
1108  }
1109  if( !msDescription.isEmpty() )
1110  {
1111  xSet->setPropertyValue( "Description", Any( msDescription ) );
1112  }
1113  if (aServiceName != "com.sun.star.text.TextFrame")
1114  rxShapes->add( mxShape );
1115 
1116  if ( mbHidden || mbHiddenMasterShape )
1117  {
1118  SAL_INFO("oox.drawingml", "Shape::createAndInsert: invisible shape with id='" << msId << "'");
1119  xSet->setPropertyValue( "Visible", Any( false ) );
1120  // In Excel hidden means not printed, let's use visibility for now until that's handled separately
1121  xSet->setPropertyValue( "Printable", Any( false ) );
1122  }
1123 
1124  if (mbLocked)
1125  {
1126  xSet->setPropertyValue("MoveProtect", Any(true));
1127  xSet->setPropertyValue("SizeProtect", Any(true));
1128  }
1129 
1130  ActionLockGuard const alg(mxShape);
1131 
1132  // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
1133  if ( bClearText )
1134  {
1135  uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1136  if ( xText.is() )
1137  {
1138  xText->setString( "" );
1139  }
1140  }
1141 
1142  if (pMathXml)
1143  {
1144  // the "EmbeddedObject" property is read-only, so we have to create
1145  // the shape first, and it can be read only after the shape is
1146  // inserted into the document, so delay the actual import until here
1148  xSet->setPropertyValue("CLSID", uno::Any(name.GetHexName()));
1149  uno::Reference<embed::XEmbeddedObject> const xObj(
1150  xSet->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY);
1151  if (xObj.is())
1152  {
1153  uno::Reference<uno::XInterface> const xMathModel(xObj->getComponent());
1154  oox::FormulaImportBase *const pMagic(
1155  dynamic_cast<oox::FormulaImportBase*>(xMathModel.get()));
1156  assert(pMagic);
1157  pMagic->readFormulaOoxml(*pMathXml);
1158  }
1159  }
1160 
1161  const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper();
1162 
1163  ::Color nLinePhClr(ColorTransparency, 0xffffffff);
1164  ::Color nFillPhClr(ColorTransparency, 0xffffffff);
1165  sal_Int16 nFillPhClrTheme = -1;
1166  // TODO: use ph color when applying effect properties
1167  //sal_Int32 nEffectPhClr = -1;
1168 
1169  // dmapper needs the original rotation angle for calculating square wrap. This angle is not
1170  // available as property there, so store it in InteropGrabBag.
1171  putPropertyToGrabBag("mso-rotation-angle", Any(mnRotation));
1172 
1173  if( pTheme )
1174  {
1175  if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
1176  {
1177  LineProperties aLineProperties;
1178  aLineProperties.maLineFill.moFillType = XML_noFill;
1179  if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
1180  aLineProperties.assignUsed( *pLineProps );
1181  nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper );
1182 
1183  // Store style-related properties to InteropGrabBag to be able to export them back
1184  uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1185  {
1186  {"SchemeClr", uno::Any(pLineRef->maPhClr.getSchemeColorName())},
1187  {"Idx", uno::Any(pLineRef->mnThemedIdx)},
1188  {"Color", uno::Any(nLinePhClr)},
1189  {"LineStyle", uno::Any(aLineProperties.getLineStyle())},
1190  {"LineCap", uno::Any(aLineProperties.getLineCap())},
1191  {"LineJoint", uno::Any(aLineProperties.getLineJoint())},
1192  {"LineWidth", uno::Any(aLineProperties.getLineWidth())},
1193  {"Transformations", uno::Any(pLineRef->maPhClr.getTransformations())}
1194  });
1195  putPropertyToGrabBag( "StyleLnRef", Any( aProperties ) );
1196  }
1197  if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
1198  {
1199  if (!getFillProperties().moUseBgFill.get(false))
1200  {
1201  nFillPhClr = pFillRef->maPhClr.getColor(rGraphicHelper);
1202  nFillPhClrTheme = pFillRef->maPhClr.getSchemeColorIndex();
1203  }
1204 
1205  OUString sColorScheme = pFillRef->maPhClr.getSchemeColorName();
1206  if( !sColorScheme.isEmpty() )
1207  {
1208  uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1209  {
1210  {"SchemeClr", uno::Any(sColorScheme)},
1211  {"Idx", uno::Any(pFillRef->mnThemedIdx)},
1212  {"Color", uno::Any(nFillPhClr)},
1213  {"Transformations", uno::Any(pFillRef->maPhClr.getTransformations())}
1214  });
1215 
1216  putPropertyToGrabBag( "StyleFillRef", Any( aProperties ) );
1217  }
1218  }
1219  if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
1220  {
1221  // TODO: use ph color when applying effect properties
1222  // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
1223 
1224  // Store style-related properties to InteropGrabBag to be able to export them back
1225  uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
1226  {
1227  {"SchemeClr", uno::Any(pEffectRef->maPhClr.getSchemeColorName())},
1228  {"Idx", uno::Any(pEffectRef->mnThemedIdx)},
1229  {"Transformations", uno::Any(pEffectRef->maPhClr.getTransformations())}
1230  });
1231  putPropertyToGrabBag( "StyleEffectRef", Any( aProperties ) );
1232  }
1233  }
1234  ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() );
1235 
1236  // add properties from textbody to shape properties
1237  if( mpTextBody )
1238  {
1239  mpTextBody->getTextProperties().pushTextDistances(Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
1240  aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
1241  // Push char properties as well - specifically useful when this is a placeholder
1242  if( mpMasterTextListStyle && mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.has_value() )
1243  aShapeProps.setProperty(PROP_CharHeight, GetFontHeight( mpMasterTextListStyle->getListStyle()[0].getTextCharacterProperties().moHeight.get() ));
1244  }
1245 
1246  // applying properties
1247  aShapeProps.assignUsed( getShapeProperties() );
1248  aShapeProps.assignUsed( maDefaultShapeProperties );
1249  if(mnRotation != 0 && bIsCustomShape)
1250  aShapeProps.setProperty( PROP_RotateAngle, sal_Int32( NormAngle36000( Degree100(mnRotation / -600) ) ));
1251  if( bIsEmbMedia ||
1252  bIsCustomShape ||
1253  aServiceName == "com.sun.star.drawing.GraphicObjectShape" ||
1254  aServiceName == "com.sun.star.drawing.OLE2Shape")
1255  {
1256  mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper, mbFlipH, mbFlipV );
1257  }
1258  if ( mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape" )
1259  mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
1260 
1261  FillProperties aFillProperties = getActualFillProperties(pTheme, &rShapeOrParentShapeFillProps);
1262  if (getFillProperties().moFillType.has_value() && getFillProperties().moFillType.get() == XML_grpFill)
1263  getFillProperties().assignUsed(aFillProperties);
1264  if(!bIsCroppedGraphic)
1265  aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, nFillPhClrTheme, mbFlipH, mbFlipV, bIsCustomShape );
1266  LineProperties aLineProperties = getActualLineProperties(pTheme);
1267  aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
1268  EffectProperties aEffectProperties = getActualEffectProperties(pTheme);
1269  // TODO: use ph color when applying effect properties
1270  aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
1271 
1272  // applying autogrowheight property before setting shape size, because
1273  // the shape size might be changed if currently autogrowheight is true
1274  // we must also check that the PropertySet supports the property.
1275  Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1276  const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight );
1277  if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) )
1278  if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) )
1279  xSet->setPropertyValue( rPropName, Any( false ) );
1280 
1281  // do not set properties at a group shape (this causes
1282  // assertions from svx) ...
1283  if( aServiceName != "com.sun.star.drawing.GroupShape" )
1284  {
1285  if (aServiceName == "com.sun.star.text.TextFrame")
1286  {
1287  if (mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getShapeTypeOverride())
1288  {
1289  uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1290  uno::Sequence<beans::PropertyValue> aGrabBag;
1291  propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
1292  sal_Int32 length = aGrabBag.getLength();
1293  aGrabBag.realloc( length+1);
1294  auto pGrabBag = aGrabBag.getArray();
1295  pGrabBag[length].Name = "mso-orig-shape-type";
1296  uno::Sequence< sal_Int8 > const & aNameSeq =
1297  mpCustomShapePropertiesPtr->getShapePresetTypeName();
1298  OUString sShapePresetTypeName(reinterpret_cast< const char* >(
1299  aNameSeq.getConstArray()), aNameSeq.getLength(), RTL_TEXTENCODING_UTF8);
1300  pGrabBag[length].Value <<= sShapePresetTypeName;
1301  propertySet->setPropertyValue("FrameInteropGrabBag",uno::Any(aGrabBag));
1302  }
1303  //If the text box has links then save the link information so that
1304  //it can be accessed in DomainMapper_Impl.cxx while chaining the text frames.
1305  if (isLinkedTxbx())
1306  {
1307  uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1308  uno::Sequence<beans::PropertyValue> aGrabBag;
1309  propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
1310  sal_Int32 length = aGrabBag.getLength();
1311  aGrabBag.realloc( length + 3 );
1312  auto pGrabBag = aGrabBag.getArray();
1313  pGrabBag[length].Name = "TxbxHasLink";
1314  pGrabBag[length].Value <<= isLinkedTxbx();
1315  pGrabBag[length + 1 ].Name = "Txbx-Id";
1316  pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id;
1317  pGrabBag[length + 2 ].Name = "Txbx-Seq";
1318  pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq;
1319  propertySet->setPropertyValue("FrameInteropGrabBag",uno::Any(aGrabBag));
1320  }
1321 
1322  // TextFrames have BackColor, not FillColor
1323  if (aShapeProps.hasProperty(PROP_FillColor))
1324  {
1325  aShapeProps.setAnyProperty(PROP_BackColor, aShapeProps.getProperty(PROP_FillColor));
1326  aShapeProps.erase(PROP_FillColor);
1327  }
1328  // TextFrames have BackColorTransparency, not FillTransparence
1329  if (aShapeProps.hasProperty(PROP_FillTransparence))
1330  {
1331  aShapeProps.setAnyProperty(PROP_BackColorTransparency, aShapeProps.getProperty(PROP_FillTransparence));
1332  aShapeProps.erase(PROP_FillTransparence);
1333  }
1334  // TextFrames have BackGraphic, not FillBitmap
1335  if (aShapeProps.hasProperty(PROP_FillBitmap))
1336  {
1337  aShapeProps.setAnyProperty(PROP_BackGraphic, aShapeProps.getProperty(PROP_FillBitmap));
1338  aShapeProps.erase(PROP_FillBitmap);
1339  }
1340  if (aShapeProps.hasProperty(PROP_FillBitmapName))
1341  {
1342  uno::Any aAny = aShapeProps.getProperty(PROP_FillBitmapName);
1343  OUString aFillBitmapName = aAny.get<OUString>();
1344  uno::Reference<awt::XBitmap> xBitmap = rFilterBase.getModelObjectHelper().getFillBitmap(aFillBitmapName);
1345  uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
1346  aShapeProps.setProperty(PROP_BackGraphic, xGraphic);
1347  // aShapeProps.erase(PROP_FillBitmapName); // Maybe, leave the name as well
1348  }
1349  // And no LineColor property; individual borders can have colors
1350  if (aShapeProps.hasProperty(PROP_LineColor))
1351  {
1352  uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
1353  static const sal_Int32 aBorders[] =
1354  {
1355  PROP_TopBorder, PROP_LeftBorder, PROP_BottomBorder, PROP_RightBorder
1356  };
1357  for (sal_Int32 nBorder : aBorders)
1358  {
1359  css::table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(PropertyMap::getPropertyName(nBorder)).get<css::table::BorderLine2>();
1360  aBorderLine.Color = aShapeProps.getProperty(PROP_LineColor).get<sal_Int32>();
1361  if (aLineProperties.moLineWidth.has_value())
1362  aBorderLine.LineWidth = convertEmuToHmm(aLineProperties.moLineWidth.get());
1363  aShapeProps.setProperty(nBorder, aBorderLine);
1364  }
1365  aShapeProps.erase(PROP_LineColor);
1366  }
1367  if(mnRotation)
1368  {
1369  uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
1370  static const OUStringLiteral aGrabBagPropName = u"FrameInteropGrabBag";
1371  uno::Sequence<beans::PropertyValue> aGrabBag;
1372  xPropertySet->getPropertyValue(aGrabBagPropName) >>= aGrabBag;
1373  beans::PropertyValue aPair(comphelper::makePropertyValue("mso-rotation-angle",
1374  mnRotation));
1375  if (aGrabBag.hasElements())
1376  {
1377  sal_Int32 nLength = aGrabBag.getLength();
1378  aGrabBag.realloc(nLength + 1);
1379  aGrabBag.getArray()[nLength] = aPair;
1380  }
1381  else
1382  {
1383  aGrabBag = { aPair };
1384  }
1385  xPropertySet->setPropertyValue(aGrabBagPropName, uno::Any(aGrabBag));
1386  }
1387  // TextFrames have ShadowFormat, not individual shadow properties.
1388  std::optional<sal_Int32> oShadowDistance;
1389  if (aShapeProps.hasProperty(PROP_ShadowXDistance))
1390  {
1391  oShadowDistance = aShapeProps.getProperty(PROP_ShadowXDistance).get<sal_Int32>();
1392  aShapeProps.erase(PROP_ShadowXDistance);
1393  }
1394  if (aShapeProps.hasProperty(PROP_ShadowYDistance))
1395  {
1396  // There is a single 'dist' attribute, so no need to count the avg of x and y.
1397  aShapeProps.erase(PROP_ShadowYDistance);
1398  }
1399  std::optional<sal_Int32> oShadowColor;
1400  if (aShapeProps.hasProperty(PROP_ShadowColor))
1401  {
1402  oShadowColor = aShapeProps.getProperty(PROP_ShadowColor).get<sal_Int32>();
1403  aShapeProps.erase(PROP_ShadowColor);
1404  }
1405  if (aShapeProps.hasProperty(PROP_Shadow))
1406  aShapeProps.erase(PROP_Shadow);
1407 
1408  if (oShadowDistance || oShadowColor || aEffectProperties.maShadow.moShadowDir.has_value())
1409  {
1410  css::table::ShadowFormat aFormat;
1411  if (oShadowColor)
1412  aFormat.Color = *oShadowColor;
1413  if (aEffectProperties.maShadow.moShadowDir.has_value())
1414  {
1415  css::table::ShadowLocation nLocation = css::table::ShadowLocation_NONE;
1416  switch (aEffectProperties.maShadow.moShadowDir.get())
1417  {
1418  case 13500000:
1419  nLocation = css::table::ShadowLocation_TOP_LEFT;
1420  break;
1421  case 18900000:
1422  nLocation = css::table::ShadowLocation_TOP_RIGHT;
1423  break;
1424  case 8100000:
1425  nLocation = css::table::ShadowLocation_BOTTOM_LEFT;
1426  break;
1427  case 2700000:
1428  nLocation = css::table::ShadowLocation_BOTTOM_RIGHT;
1429  break;
1430  }
1431  aFormat.Location = nLocation;
1432  }
1433  aFormat.ShadowWidth = *oShadowDistance;
1434  aShapeProps.setProperty(PROP_ShadowFormat, aFormat);
1435  }
1436 
1437  }
1438  else if (mbTextBox)
1439  {
1440  aShapeProps.setProperty(PROP_TextBox, true);
1441  }
1442 
1443  if (aServiceName != "com.sun.star.text.TextFrame" && isLinkedTxbx())
1444  {
1445  uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1446  uno::Sequence<beans::PropertyValue> aGrabBag;
1447  propertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
1448  sal_Int32 length = aGrabBag.getLength();
1449  aGrabBag.realloc( length + 3 );
1450  auto pGrabBag = aGrabBag.getArray();
1451  pGrabBag[length].Name = "TxbxHasLink";
1452  pGrabBag[length].Value <<= isLinkedTxbx();
1453  pGrabBag[length + 1 ].Name = "Txbx-Id";
1454  pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id;
1455  pGrabBag[length + 2 ].Name = "Txbx-Seq";
1456  pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq;
1457  propertySet->setPropertyValue("InteropGrabBag",uno::Any(aGrabBag));
1458  }
1459 
1460  // If the shape is a picture placeholder.
1461  if (aServiceName == "com.sun.star.presentation.GraphicObjectShape" && !bClearText)
1462  {
1463  // Placeholder text should be in center of the shape.
1464  aShapeProps.setProperty(PROP_TextContourFrame, false);
1465 
1466  /* Placeholder icon should be at the center of the parent shape.
1467  * We use negative graphic crop property because of that we don't
1468  * have padding support.
1469  */
1470  uno::Reference<beans::XPropertySet> xGraphic(xSet->getPropertyValue("Graphic"), uno::UNO_QUERY);
1471  if (xGraphic.is())
1472  {
1473  awt::Size aBitmapSize;
1474  xGraphic->getPropertyValue("Size100thMM") >>= aBitmapSize;
1475  sal_Int32 nXMargin = (aShapeRectHmm.Width - aBitmapSize.Width) / 2;
1476  sal_Int32 nYMargin = (aShapeRectHmm.Height - aBitmapSize.Height) / 2;
1477  if (nXMargin > 0 && nYMargin > 0)
1478  {
1479  text::GraphicCrop aGraphicCrop;
1480  aGraphicCrop.Top = nYMargin * -1;
1481  aGraphicCrop.Bottom = nYMargin * -1;
1482  aGraphicCrop.Left = nXMargin * -1;
1483  aGraphicCrop.Right = nXMargin * -1;
1484  aShapeProps.setProperty(PROP_GraphicCrop, aGraphicCrop);
1485  }
1486  }
1487  }
1488 
1489  PropertySet( xSet ).setProperties( aShapeProps );
1490  if (mbLockedCanvas)
1491  {
1492  putPropertyToGrabBag( "LockedCanvas", Any( true ) );
1493  if (aServiceName == "com.sun.star.drawing.LineShape")
1494  {
1495  // It seems the position and size for lines inside a locked canvas is absolute.
1496  mxShape->setPosition(awt::Point(aShapeRectHmm.X, aShapeRectHmm.Y));
1497  mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
1498  }
1499  }
1500 
1501  // Store original fill and line colors of the shape and the theme color name to InteropGrabBag
1502  std::vector<beans::PropertyValue> aProperties
1503  {
1504  comphelper::makePropertyValue("EmuLineWidth", aLineProperties.moLineWidth.get(0)),
1505  comphelper::makePropertyValue("OriginalSolidFillClr", aShapeProps.getProperty(PROP_FillColor)),
1506  comphelper::makePropertyValue("OriginalLnSolidFillClr", aShapeProps.getProperty(PROP_LineColor))
1507  };
1508  OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeColorName();
1509  if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() )
1510  {
1511  aProperties.push_back(comphelper::makePropertyValue("SpPrSolidFillSchemeClr", sColorFillScheme));
1512  aProperties.push_back(comphelper::makePropertyValue("SpPrSolidFillSchemeClrTransformations", aFillProperties.maFillColor.getTransformations()));
1513  }
1514  OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeColorName();
1515  if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() )
1516  {
1517  aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillSchemeClr", sLnColorFillScheme));
1518  auto aResolvedSchemeClr = aLineProperties.maLineFill.maFillColor;
1519  aResolvedSchemeClr.clearTransformations();
1520  aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillResolvedSchemeClr", aResolvedSchemeClr.getColor(rGraphicHelper, nFillPhClr)));
1521  aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillSchemeClrTransformations", aLineProperties.maLineFill.maFillColor.getTransformations()));
1522  }
1524 
1525  // Store original gradient fill of the shape to InteropGrabBag
1526  // LibreOffice doesn't support all the kinds of gradient so we save its complete definition
1527  if( aShapeProps.hasProperty( PROP_FillGradient ) )
1528  {
1529  std::vector<beans::PropertyValue> aGradientStops;
1530  size_t i = 0;
1531  for( const auto& [rPos, rColor] : aFillProperties.maGradientProps.maGradientStops )
1532  { // for each stop in the gradient definition:
1533 
1534  // save position
1535  std::vector<beans::PropertyValue> aGradientStop
1536  {
1537  comphelper::makePropertyValue("Pos", rPos)
1538  };
1539 
1540  OUString sStopColorScheme = rColor.getSchemeColorName();
1541  if( sStopColorScheme.isEmpty() )
1542  {
1543  // save RGB color
1544  aGradientStop.push_back(comphelper::makePropertyValue("RgbClr", rColor.getColor(rGraphicHelper, nFillPhClr)));
1545  // in the case of a RGB color, transformations are already applied to
1546  // the color with the exception of alpha transformations. We only need
1547  // to keep the transparency value to calculate the alpha value later.
1548  if( rColor.hasTransparency() )
1549  aGradientStop.push_back(comphelper::makePropertyValue("Transparency", rColor.getTransparency()));
1550  }
1551  else
1552  {
1553  // save color with scheme name
1554  aGradientStop.push_back(comphelper::makePropertyValue("SchemeClr", sStopColorScheme));
1555  // save all color transformations
1556  aGradientStop.push_back(comphelper::makePropertyValue("Transformations", rColor.getTransformations()));
1557  }
1558 
1559  aGradientStops.push_back(comphelper::makePropertyValue(OUString::number(i), comphelper::containerToSequence(aGradientStop)));
1560  ++i;
1561  }
1562  // If getFillProperties.moFillType is unused that means gradient is defined by a theme
1563  // which is already saved into StyleFillRef property, so no need to save the explicit values too
1564  if( getFillProperties().moFillType.has_value() )
1565  putPropertyToGrabBag( "GradFillDefinition", uno::Any(comphelper::containerToSequence(aGradientStops)));
1566  putPropertyToGrabBag( "OriginalGradFill", aShapeProps.getProperty(PROP_FillGradient) );
1567  }
1568 
1569  // store unsupported effect attributes in the grab bag
1570  if (!aEffectProperties.m_Effects.empty())
1571  {
1572  std::vector<beans::PropertyValue> aEffects;
1573  for (auto const& it : aEffectProperties.m_Effects)
1574  {
1575  PropertyValue aEffect = it->getEffect();
1576  if( !aEffect.Name.isEmpty() )
1577  {
1578  std::vector<beans::PropertyValue> aEffectsGrabBag
1579  {
1580  comphelper::makePropertyValue("Attribs", aEffect.Value)
1581  };
1582 
1583  Color& aColor( it->moColor );
1584  OUString sColorScheme = aColor.getSchemeColorName();
1585  if( sColorScheme.isEmpty() )
1586  {
1587  // RGB color and transparency value
1588  aEffectsGrabBag.push_back(comphelper::makePropertyValue("RgbClr", aColor.getColor(rGraphicHelper, nFillPhClr)));
1589  aEffectsGrabBag.push_back(comphelper::makePropertyValue("RgbClrTransparency", aColor.getTransparency()));
1590  }
1591  else
1592  {
1593  // scheme color with name and transformations
1594  aEffectsGrabBag.push_back(comphelper::makePropertyValue("SchemeClr", sColorScheme));
1595  aEffectsGrabBag.push_back(comphelper::makePropertyValue("SchemeClrTransformations", aColor.getTransformations()));
1596  }
1597  aEffects.push_back(comphelper::makePropertyValue(aEffect.Name, comphelper::containerToSequence(aEffectsGrabBag)));
1598  }
1599  }
1600  putPropertyToGrabBag("EffectProperties", uno::Any(comphelper::containerToSequence(aEffects)));
1601  }
1602 
1603  // add 3D effects if any
1606  Sequence< PropertyValue > aShape3DEffects = get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
1607  if( aCamera3DEffects.hasElements() || aLightRig3DEffects.hasElements() || aShape3DEffects.hasElements() )
1608  {
1609  uno::Sequence<beans::PropertyValue> a3DEffectsGrabBag = comphelper::InitPropertySequence(
1610  {
1611  {"Camera", uno::Any(aCamera3DEffects)},
1612  {"LightRig", uno::Any(aLightRig3DEffects)},
1613  {"Shape3D", uno::Any(aShape3DEffects)}
1614  });
1615  putPropertyToGrabBag( "3DEffectProperties", Any( a3DEffectsGrabBag ) );
1616  }
1617 
1618  if( bIsCustomShape && getTextBody())
1619  {
1620 
1621  Sequence< PropertyValue > aTextCamera3DEffects = getTextBody()->get3DProperties().getCameraAttributes();
1622  Sequence< PropertyValue > aTextLightRig3DEffects = getTextBody()->get3DProperties().getLightRigAttributes();
1623  Sequence< PropertyValue > aTextShape3DEffects = getTextBody()->get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
1624  if( aTextCamera3DEffects.hasElements() || aTextLightRig3DEffects.hasElements() || aTextShape3DEffects.hasElements() )
1625  {
1626  uno::Sequence<beans::PropertyValue> aText3DEffectsGrabBag = comphelper::InitPropertySequence(
1627  {
1628  {"Camera", uno::Any(aTextCamera3DEffects)},
1629  {"LightRig", uno::Any(aTextLightRig3DEffects)},
1630  {"Shape3D", uno::Any(aTextShape3DEffects)}
1631  });
1632  putPropertyToGrabBag( "Text3DEffectProperties", Any( aText3DEffectsGrabBag ) );
1633  }
1634  }
1635 
1636  // store bitmap artistic effects in the grab bag
1637  if( !mpGraphicPropertiesPtr->maBlipProps.maEffect.isEmpty() )
1638  putPropertyToGrabBag( "ArtisticEffectProperties",
1639  Any( mpGraphicPropertiesPtr->maBlipProps.maEffect.getEffect() ) );
1640  }
1641 
1642  else if( mbLockedCanvas )
1643  {
1644  //If we have aServiceName as "com.sun.star.drawing.GroupShape" and lockedCanvas
1645  putPropertyToGrabBag( "LockedCanvas", Any( true ) );
1646  }
1647 
1648  // These can have a custom geometry, so position should be set here,
1649  // after creation but before custom shape handling, using the position
1650  // we got from the caller.
1651  if (mbWps && aServiceName == "com.sun.star.drawing.LineShape" && !pParentGroupShape)
1652  mxShape->setPosition(maPosition);
1653 
1654  if (bIsConnectorShape)
1655  {
1656  sal_Int32 nType = mpCustomShapePropertiesPtr->getShapePresetType();
1657  switch (nType)
1658  {
1659  case XML_line:
1660  case XML_straightConnector1:
1661  xSet->setPropertyValue("EdgeKind", Any(ConnectorType_LINE));
1662  break;
1663  case XML_bentConnector2:
1664  case XML_bentConnector3:
1665  case XML_bentConnector4:
1666  case XML_bentConnector5:
1667  xSet->setPropertyValue("EdgeKind", Any(ConnectorType_STANDARD));
1668  break;
1669  case XML_curvedConnector2:
1670  case XML_curvedConnector3:
1671  case XML_curvedConnector4:
1672  case XML_curvedConnector5:
1673  xSet->setPropertyValue("EdgeKind", Any(ConnectorType_CURVE));
1674  break;
1675  default:
1676  break;
1677  }
1678  }
1679 
1680  if( bIsCustomShape )
1681  {
1682  if ( mbFlipH )
1683  mpCustomShapePropertiesPtr->setMirroredX( true );
1684  if ( mbFlipV )
1685  mpCustomShapePropertiesPtr->setMirroredY( true );
1686  if( getTextBody() )
1687  {
1688  sal_Int32 nTextCameraZRotation = static_cast< sal_Int32 >( getTextBody()->get3DProperties().maCameraRotation.mnRevolution.get() );
1689  mpCustomShapePropertiesPtr->setTextCameraZRotateAngle( nTextCameraZRotation / 60000 );
1690 
1691  sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) );
1692 
1693  nTextRotateAngle -= mnDiagramRotation;
1694  /* OOX measures text rotation clockwise in 1/60000th degrees,
1695  relative to the containing shape. setTextRotateAngle wants degrees anticlockwise. */
1696  nTextRotateAngle = -1 * nTextRotateAngle / 60000;
1697 
1698  if (getTextBody()->getTextProperties().moUpright)
1699  {
1700  // When upright is set, we want the text without any rotation.
1701  // But if we set 0 here, the text is still rotated if the
1702  // shape containing it is rotated.
1703  // Hence, we rotate the text into the opposite direction of
1704  // the rotation of the shape, by as much as the shape was rotated.
1705  mpCustomShapePropertiesPtr->setTextRotateAngle((mnRotation / 60000) + nTextRotateAngle);
1706  // Also put the initial angles away in a GrabBag.
1707  putPropertyToGrabBag("Upright", Any(true));
1708  putPropertyToGrabBag("nShapeRotationAtImport", Any(mnRotation / 60000));
1709  putPropertyToGrabBag("nTextRotationAtImport", Any(nTextRotateAngle));
1710  }
1711  else
1712  {
1713  mpCustomShapePropertiesPtr->setTextRotateAngle(nTextRotateAngle);
1714  }
1715 
1716  auto sHorzOverflow = getTextBody()->getTextProperties().msHorzOverflow;
1717  if (!sHorzOverflow.isEmpty())
1718  putPropertyToGrabBag("horzOverflow", uno::Any(getTextBody()->getTextProperties().msHorzOverflow));
1719  auto nVertOverflow = getTextBody()->getTextProperties().msVertOverflow;
1720  if (!nVertOverflow.isEmpty())
1721  putPropertyToGrabBag("vertOverflow", uno::Any(getTextBody()->getTextProperties().msVertOverflow));
1722  }
1723 
1724  // Note that the script oox/source/drawingml/customshapes/generatePresetsData.pl looks
1725  // for these ==cscode== and ==csdata== markers, so don't "clean up" these SAL_INFOs
1726  SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'");
1727  SAL_INFO("oox.csdata", "==csdata== shape name: '" << msName << "'");
1728  mpCustomShapePropertiesPtr->pushToPropSet(xSet, maSize);
1729 
1730  if (mpTextBody)
1731  {
1732  bool bIsPresetShape = !mpTextBody->getTextProperties().msPrst.isEmpty();
1733  if (bIsPresetShape)
1734  {
1735  OUString sClass;
1736  const OUString sPresetType = mpTextBody->getTextProperties().msPrst;
1737  sClass = PresetGeometryTypeNames::GetFontworkType( sPresetType );
1738 
1739  lcl_createPresetShape( mxShape, sClass, sPresetType, mpCustomShapePropertiesPtr, mpTextBody, rGraphicHelper );
1740  }
1741  }
1742  }
1743  else if( getTextBody() )
1744  getTextBody()->getTextProperties().pushVertSimulation();
1745 
1746  // tdf#133037: a bit hackish: force Shape to rotate in the opposite direction the camera would rotate
1747  PropertySet aPropertySet(mxShape);
1748  if ( !bUseRotationTransform && (mnRotation != 0 || nCameraRotation != 0) )
1749  {
1750  // use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
1751  Degree100 nAngle = NormAngle36000( Degree100((mnRotation - nCameraRotation) / -600) );
1752  aPropertySet.setAnyProperty( PROP_RotateAngle, Any( sal_Int32( nAngle.get() ) ) );
1753  aPropertySet.setAnyProperty( PROP_HoriOrientPosition, Any( maPosition.X ) );
1754  aPropertySet.setAnyProperty( PROP_VertOrientPosition, Any( maPosition.Y ) );
1755  }
1756 
1757  // in some cases, we don't have any text body.
1758  if( mpTextBody && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) )
1759  {
1760  Reference < XText > xText( mxShape, UNO_QUERY );
1761  if ( xText.is() ) // not every shape is supporting an XText interface (e.g. GroupShape)
1762  {
1763  TextCharacterProperties aCharStyleProperties;
1764  if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) )
1765  {
1766  if( pFontRef->mnThemedIdx != 0 )
1767  {
1768  if( pTheme )
1769  if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) )
1770  aCharStyleProperties.assignUsed( *pCharProps );
1771  SAL_INFO("oox.drawingml", "Shape::createAndInsert: use font color");
1772  if ( pFontRef->maPhClr.isUsed() )
1773  {
1774  aCharStyleProperties.maFillProperties.maFillColor = pFontRef->maPhClr;
1775  aCharStyleProperties.maFillProperties.moFillType = XML_solidFill;
1776  }
1777  }
1778  }
1779  xText->setString("");
1780  Reference < XTextCursor > xAt = xText->createTextCursor();
1781  getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
1782 
1783  const TextParagraphVector& rParagraphs = getTextBody()->getParagraphs();
1784  if (!rParagraphs.empty())
1785  {
1786  const std::shared_ptr<TextParagraph>& pParagraph = rParagraphs[0];
1787  if (pParagraph->getProperties().getParaAdjust())
1788  {
1789  style::ParagraphAdjust eAdjust = *pParagraph->getProperties().getParaAdjust();
1790  if (eAdjust == style::ParagraphAdjust_CENTER)
1791  {
1792  // If the first paragraph is centered, then set the para adjustment of
1793  // the shape itself to centered as well.
1794  aPropertySet.setAnyProperty(PROP_ParaAdjust, uno::Any(eAdjust));
1795  }
1796  }
1797  }
1798  }
1799  }
1800  else if (mbTextBox)
1801  {
1802  // No drawingML text, but WPS text is expected: save the theme
1803  // character color on the shape, then.
1804  if(const ShapeStyleRef* pFontRef = getShapeStyleRef(XML_fontRef))
1805  {
1806  ::Color nCharColor = pFontRef->maPhClr.getColor(rGraphicHelper);
1807  aPropertySet.setAnyProperty(PROP_CharColor, uno::Any(nCharColor));
1808  }
1809  }
1810 
1811  // Set glow effect properties
1812  if ( aEffectProperties.maGlow.moGlowRad.has_value() )
1813  {
1814  uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
1815  propertySet->setPropertyValue("GlowEffectRadius", Any(convertEmuToHmm(aEffectProperties.maGlow.moGlowRad.get())));
1816  propertySet->setPropertyValue("GlowEffectColor", Any(aEffectProperties.maGlow.moGlowColor.getColor(rGraphicHelper)));
1817  propertySet->setPropertyValue("GlowEffectTransparency", Any(aEffectProperties.maGlow.moGlowColor.getTransparency()));
1818  }
1819 
1820  // Set soft edge effect properties
1821  if (aEffectProperties.maSoftEdge.moRad.has_value())
1822  {
1823  uno::Reference<beans::XPropertySet> propertySet(mxShape, uno::UNO_QUERY);
1824  propertySet->setPropertyValue(
1825  "SoftEdgeRadius", Any(convertEmuToHmm(aEffectProperties.maSoftEdge.moRad.get())));
1826  }
1827  }
1828 
1829  if (mxShape.is())
1830  {
1831  finalizeXShape( rFilterBase, rxShapes );
1832 
1833  if (mpTextBody)
1834  mpTextBody->getTextProperties().readjustTextDistances(mxShape);
1835  }
1836 
1837  return mxShape;
1838 }
1839 
1840 void Shape::keepDiagramDrawing(XmlFilterBase& rFilterBase, const OUString& rFragmentPath)
1841 {
1842 
1843  sal_Int32 length = maDiagramDoms.getLength();
1844  maDiagramDoms.realloc(length + 1);
1845 
1846  // drawingValue[0] => dom, drawingValue[1] => Sequence of associated relationships
1847  uno::Sequence<uno::Any> diagramDrawing{
1848  uno::Any(rFilterBase.importFragment(rFragmentPath)),
1849  uno::Any(resolveRelationshipsOfTypeFromOfficeDoc(rFilterBase, rFragmentPath, u"image"))
1850  };
1851 
1852  beans::PropertyValue* pValue = maDiagramDoms.getArray();
1853  pValue[length].Name = "OOXDrawing";
1854  pValue[length].Value <<= diagramDrawing;
1855 }
1856 
1858 {
1859  try
1860  {
1861  if( !maDiagramDoms.hasElements() )
1862  return;
1863 
1864  Reference < XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
1865  Reference < XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1866  if ( !xSetInfo.is() )
1867  return;
1868 
1869  const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
1870  if( !xSetInfo->hasPropertyByName( aGrabBagPropName ) )
1871  return;
1872 
1873  Sequence < PropertyValue > aGrabBag;
1874  xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
1875 
1876  // We keep the previous items, if present
1877  if ( aGrabBag.hasElements() )
1878  xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, maDiagramDoms) ) );
1879  else
1880  xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) );
1881  }
1882  catch( const Exception& )
1883  {
1884  TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::keepDiagramCompatibilityInfo" );
1885  }
1886 }
1887 
1889 {
1890  try
1891  {
1892  Reference<XPropertySet> xSet(mxShape, UNO_QUERY_THROW);
1893 
1894  xSet->setPropertyValue("MoveProtect", Any(true));
1895  xSet->setPropertyValue("SizeProtect", Any(true));
1896 
1897  // Replace existing shapes with a new Graphic Object rendered
1898  // from them
1899  Reference<XShape> xShape(renderDiagramToGraphic(rFilterBase));
1900  Reference<XShapes> xShapes(mxShape, UNO_QUERY_THROW);
1901  while (xShapes->hasElements())
1902  xShapes->remove(Reference<XShape>(xShapes->getByIndex(0), UNO_QUERY_THROW));
1903  xShapes->add(xShape);
1904  }
1905  catch (const Exception&)
1906  {
1907  TOOLS_WARN_EXCEPTION("oox.drawingml", "Shape::convertSmartArtToMetafile");
1908  }
1909 }
1910 
1912 {
1913  Reference< XShape > xShape;
1914 
1915  try
1916  {
1917  if( !maDiagramDoms.hasElements() )
1918  return xShape;
1919 
1920  // Stream in which to place the rendered shape
1921  SvMemoryStream aTempStream;
1923  Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
1924 
1925  // Size of the rendering
1926  awt::Size aActualSize = mxShape->getSize();
1927  Size aResolution(Application::GetDefaultDevice()->LogicToPixel(Size(100, 100), MapMode(MapUnit::MapCM)));
1928  double fPixelsPer100thmm = static_cast < double > ( aResolution.Width() ) / 100000.0;
1929  awt::Size aSize( static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Width ) + 0.5 ),
1930  static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Height ) + 0.5 ) );
1931 
1932  Sequence< PropertyValue > aFilterData{
1933  comphelper::makePropertyValue("PixelWidth", aSize.Width),
1934  comphelper::makePropertyValue("PixelHeight", aSize.Height),
1935  comphelper::makePropertyValue("LogicalWidth", aActualSize.Width),
1936  comphelper::makePropertyValue("LogicalHeight", aActualSize.Height)
1937  };
1938 
1939  Sequence < PropertyValue > aDescriptor{
1940  comphelper::makePropertyValue("OutputStream", xOutputStream),
1941  comphelper::makePropertyValue("FilterName", OUString("SVM")), // Rendering format
1942  comphelper::makePropertyValue("FilterData", aFilterData)
1943  };
1944 
1945  Reference < lang::XComponent > xSourceDoc( mxShape, UNO_QUERY_THROW );
1946  Reference < XGraphicExportFilter > xGraphicExporter = GraphicExportFilter::create( rFilterBase.getComponentContext() );
1947  xGraphicExporter->setSourceDocument( xSourceDoc );
1948  xGraphicExporter->filter( aDescriptor );
1949 
1950  aTempStream.Seek( STREAM_SEEK_TO_BEGIN );
1951 
1952  Graphic aGraphic;
1953  GraphicFilter aFilter( false );
1954  if ( aFilter.ImportGraphic( aGraphic, u"", aTempStream, GRFILTER_FORMAT_NOTFOUND, nullptr, GraphicFilterImportFlags::NONE ) != ERRCODE_NONE )
1955  {
1956  SAL_WARN( "oox.drawingml", "Shape::renderDiagramToGraphic: Unable to import rendered stream into graphic object" );
1957  return xShape;
1958  }
1959 
1960  Reference < graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() );
1961  Reference < lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
1962  xShape.set( xServiceFact->createInstance( "com.sun.star.drawing.GraphicObjectShape" ), UNO_QUERY_THROW );
1963  Reference < XPropertySet > xPropSet( xShape, UNO_QUERY_THROW );
1964  xPropSet->setPropertyValue( "Graphic", Any( xGraphic ) );
1965  xPropSet->setPropertyValue( "MoveProtect", Any( true ) );
1966  xPropSet->setPropertyValue( "SizeProtect", Any( true ) );
1967  xPropSet->setPropertyValue( "Name", Any( OUString( "RenderedShapes" ) ) );
1968  }
1969  catch( const Exception& )
1970  {
1971  TOOLS_WARN_EXCEPTION( "oox.drawingml", "Shape::renderDiagramToGraphic" );
1972  }
1973 
1974  return xShape;
1975 }
1976 
1977 void Shape::setTextBody(const TextBodyPtr & pTextBody)
1978 {
1979  mpTextBody = pTextBody;
1980 }
1981 
1982 void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
1983 {
1984  SAL_INFO("oox.drawingml", "Shape::setMasterTextListStyle: Set master text list style to shape id='" << msId << "'");
1985 
1986  mpMasterTextListStyle = pMasterTextListStyle;
1987 }
1988 
1989 OUString Shape::finalizeServiceName( XmlFilterBase& rFilter, const OUString& rServiceName, const awt::Rectangle& rShapeRect )
1990 {
1991  OUString aServiceName = rServiceName;
1992  switch( meFrameType )
1993  {
1994  case FRAMETYPE_OLEOBJECT:
1995  {
1996  awt::Size aOleSize( rShapeRect.Width, rShapeRect.Height );
1998  aServiceName = "com.sun.star.drawing.OLE2Shape";
1999 
2000  // get the path to the representation graphic
2001  OUString aGraphicPath;
2002  if( !mxOleObjectInfo->maShapeId.isEmpty() )
2003  if( ::oox::vml::Drawing* pVmlDrawing = rFilter.getVmlDrawing() )
2004  if( const ::oox::vml::ShapeBase* pVmlShape = pVmlDrawing->getShapes().getShapeById( mxOleObjectInfo->maShapeId ) )
2005  aGraphicPath = pVmlShape->getGraphicPath();
2006 
2007  // import and store the graphic
2008  if( !aGraphicPath.isEmpty() )
2009  {
2010  // Transfer shape's width and height to graphicsfilter (can be used by WMF/EMF)
2011  WmfExternal aExtHeader;
2012  aExtHeader.mapMode = 8; // MM_ANISOTROPIC
2013  aExtHeader.xExt = rShapeRect.Width;
2014  aExtHeader.yExt = rShapeRect.Height;
2015 
2016  Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath, &aExtHeader );
2017  if( xGraphic.is() )
2018  maShapeProperties.setProperty(PROP_Graphic, xGraphic);
2019  }
2020  }
2021  break;
2022 
2023  default:;
2024  }
2025  return aServiceName;
2026 }
2027 
2028 void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
2029 {
2030  switch( meFrameType )
2031  {
2032  case FRAMETYPE_CHART:
2033  {
2034  OSL_ENSURE( !mxChartShapeInfo->maFragmentPath.isEmpty(), "Shape::finalizeXShape - missing chart fragment" );
2035  if( mxShape.is() && !mxChartShapeInfo->maFragmentPath.isEmpty() ) try
2036  {
2037  // set the chart2 OLE class ID at the OLE shape
2038  PropertySet aShapeProp( mxShape );
2039  aShapeProp.setProperty( PROP_CLSID, OUString( "12dcae26-281f-416f-a234-c3086127382e" ) );
2040 
2041  // get the XModel interface of the embedded object from the OLE shape
2042  Reference< frame::XModel > xDocModel;
2043  aShapeProp.getProperty( xDocModel, PROP_Model );
2044  Reference< chart2::XChartDocument > xChartDoc( xDocModel, UNO_QUERY_THROW );
2045 
2046  // load the chart data from the XML fragment
2047 #if ENABLE_WASM_STRIP_CHART
2048  (void) rFilter;
2049  (void) rxShapes;
2050 #else
2051  // WASM_CHART change
2052  // TODO: Instead of using convertFromModel an alternative may be
2053  // added to convert not to Chart/OLE SdrObejct, but to GraphicObject
2054  // with the Chart visualization. There should be a preview available
2055  // in the imported chart data
2056  bool bMSO2007Doc = rFilter.isMSO2007Document();
2057  chart::ChartSpaceModel aModel(bMSO2007Doc);
2059  rFilter, mxChartShapeInfo->maFragmentPath, aModel );
2060  const OUString aThemeOverrideFragmentPath( pChartSpaceFragment->
2061  getFragmentPathFromFirstTypeFromOfficeDoc(u"themeOverride") );
2062  rFilter.importFragment( pChartSpaceFragment );
2063  ::oox::ppt::PowerPointImport *pPowerPointImport =
2064  dynamic_cast< ::oox::ppt::PowerPointImport* >(&rFilter);
2065 
2066  // The original theme.
2067  ThemePtr pTheme;
2068 
2069  if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport)
2070  {
2071  // Handle theme override.
2072  uno::Reference< xml::sax::XFastSAXSerializable > xDoc(
2073  rFilter.importFragment(aThemeOverrideFragmentPath), uno::UNO_QUERY_THROW);
2074  pTheme = pPowerPointImport->getActualSlidePersist()->getTheme();
2075  auto pThemeOverride = std::make_shared<Theme>(*pTheme);
2076  rFilter.importFragment(
2077  new ThemeOverrideFragmentHandler(rFilter, aThemeOverrideFragmentPath,
2078  *pThemeOverride),
2079  xDoc);
2080  pPowerPointImport->getActualSlidePersist()->setTheme(pThemeOverride);
2081  }
2082 
2083  // convert imported chart model to chart document
2084  Reference< drawing::XShapes > xExternalPage;
2085  if( !mxChartShapeInfo->mbEmbedShapes )
2086  xExternalPage = rxShapes;
2087  if( rFilter.getChartConverter() )
2088  {
2089  rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
2090  if( !xChartDoc->hasInternalDataProvider() )
2091  {
2092  Reference< chart2::data::XDataReceiver > xDataRec( xChartDoc, UNO_QUERY );
2093  Reference< chart2::data::XDataSource > xData = xDataRec->getUsedData();
2094  if( !xData->getDataSequences().hasElements() || !xData->getDataSequences()[0]->getValues().is() ||
2095  !xData->getDataSequences()[0]->getValues()->getData().hasElements() )
2096  {
2097  rFilter.useInternalChartDataTable( true );
2098  rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
2099  rFilter.useInternalChartDataTable( false );
2100  }
2101  }
2102 
2103  }
2104 
2105  if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport)
2106  {
2107  // Restore the original theme.
2108  pPowerPointImport->getActualSlidePersist()->setTheme(pTheme);
2109  }
2110 #endif
2111  }
2112  catch( Exception& )
2113  {
2114  }
2115  }
2116  break;
2117 
2118  default:;
2119  }
2120 }
2121 
2122 void Shape::putPropertyToGrabBag( const OUString& sPropertyName, const Any& aPropertyValue )
2123 {
2124  PropertyValue aNewProperty;
2125  aNewProperty.Name = sPropertyName;
2126  aNewProperty.Value = aPropertyValue;
2127  putPropertyToGrabBag( aNewProperty );
2128 }
2129 
2130 void Shape::putPropertyToGrabBag( const PropertyValue& pProperty )
2131 {
2132  Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
2133  Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2134  const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
2135  if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
2136  {
2137  Sequence< PropertyValue > aGrabBag;
2138  xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
2139 
2140  sal_Int32 length = aGrabBag.getLength();
2141  aGrabBag.realloc( length + 1 );
2142  aGrabBag.getArray()[length] = pProperty;
2143 
2144  xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
2145  }
2146 }
2147 
2149 {
2150  Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
2151  Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2152  const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
2153  if( !(mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName )) )
2154  return;
2155 
2156  // get existing grab bag
2157  Sequence< PropertyValue > aGrabBag;
2158  xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
2159 
2160  std::vector<PropertyValue> aVec;
2161  aVec.reserve(aProperties.getLength());
2162 
2163  // put the new items
2164  std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aVec),
2165  [](const PropertyValue& rProp) {
2166  PropertyValue aProp;
2167  aProp.Name = rProp.Name;
2168  aProp.Value = rProp.Value;
2169  return aProp;
2170  });
2171 
2172  // put it back to the shape
2173  xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, aVec) ) );
2174 }
2175 
2176 FillProperties Shape::getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const
2177 {
2178  FillProperties aFillProperties;
2179  aFillProperties.moFillType = XML_noFill;
2180 
2181  // Reference shape properties
2182  aFillProperties.assignUsed( *mpShapeRefFillPropPtr );
2183 
2184  // Theme
2185  if( pTheme != nullptr )
2186  {
2187  if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
2188  {
2189  if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) )
2190  aFillProperties.assignUsed( *pFillProps );
2191  }
2192  }
2193 
2194  // Properties specified directly for this shape
2195  aFillProperties.assignUsed(getFillProperties());
2196 
2197  // Parent shape's properties
2198  if ( pParentShapeFillProps != nullptr)
2199  if( getFillProperties().moFillType.has_value() && getFillProperties().moFillType.get() == XML_grpFill )
2200  aFillProperties.assignUsed( *pParentShapeFillProps );
2201 
2202  return aFillProperties;
2203 }
2204 
2206 {
2207  LineProperties aLineProperties;
2208  aLineProperties.maLineFill.moFillType = XML_noFill;
2209 
2210  // Reference shape properties
2211  aLineProperties.assignUsed( *mpShapeRefLinePropPtr );
2212 
2213  // Theme
2214  if( pTheme != nullptr )
2215  {
2216  if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
2217  {
2218  if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
2219  aLineProperties.assignUsed( *pLineProps );
2220  }
2221  }
2222 
2223  // Properties specified directly for this shape
2224  aLineProperties.assignUsed( getLineProperties() );
2225 
2226  return aLineProperties;
2227 }
2228 
2230 {
2231  EffectProperties aEffectProperties;
2232 
2233  // Reference shape properties
2234  aEffectProperties.assignUsed( *mpShapeRefEffectPropPtr );
2235 
2236  // Theme
2237  if( pTheme != nullptr )
2238  {
2239  if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
2240  {
2241  if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
2242  aEffectProperties.assignUsed( *pEffectProps );
2243  }
2244  }
2245 
2246  // Properties specified directly for this shape
2247  aEffectProperties.assignUsed ( getEffectProperties() );
2248 
2249  return aEffectProperties;
2250 }
2251 
2252 uno::Sequence< uno::Sequence< uno::Any > > Shape::resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase& rFilter, const OUString& sFragment, std::u16string_view sType )
2253 {
2254  uno::Sequence< uno::Sequence< uno::Any > > xRelListTemp;
2255  sal_Int32 counter = 0;
2256 
2257  core::RelationsRef xRels = rFilter.importRelations( sFragment );
2258  if ( xRels )
2259  {
2260  core::RelationsRef xImageRels = xRels->getRelationsFromTypeFromOfficeDoc( sType );
2261  if ( xImageRels )
2262  {
2263  xRelListTemp.realloc( xImageRels->size() );
2264  auto pxRelListTemp = xRelListTemp.getArray();
2265  for (auto const& imageRel : *xImageRels)
2266  {
2267  uno::Sequence< uno::Any > diagramRelTuple (3);
2268  auto pdiagramRelTuple = diagramRelTuple.getArray();
2269  // [0] => RID, [1] => InputStream [2] => extension
2270  OUString sRelId = imageRel.second.maId;
2271 
2272  pdiagramRelTuple[0] <<= sRelId;
2273  OUString sTarget = xImageRels->getFragmentPathFromRelId( sRelId );
2274 
2275  uno::Reference< io::XInputStream > xImageInputStrm( rFilter.openInputStream( sTarget ), uno::UNO_SET_THROW );
2276  StreamDataSequence dataSeq;
2277  if ( rFilter.importBinaryData( dataSeq, sTarget ) )
2278  {
2279  pdiagramRelTuple[1] <<= dataSeq;
2280  }
2281 
2282  pdiagramRelTuple[2] <<= sTarget.copy( sTarget.lastIndexOf(".") );
2283 
2284  pxRelListTemp[counter] = diagramRelTuple;
2285  ++counter;
2286  }
2287  xRelListTemp.realloc(counter);
2288 
2289  }
2290  }
2291  return xRelListTemp;
2292 }
2293 
2295 {
2296  auto pFillProperties = std::make_shared<FillProperties>();
2297  pFillProperties->assignUsed(*mpFillPropertiesPtr);
2298  mpFillPropertiesPtr = pFillProperties;
2299 }
2300 }
2301 
2302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral UNO_NAME_MISC_OBJ_INTEROPGRABBAG
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
std::shared_ptr< Relations > RelationsRef
Definition: relations.hxx:63
double getY() const
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 OUString & getSchemeColorName() const
Returns the scheme name from the a:schemeClr element for interoperability purposes.
Definition: color.hxx:100
FrameType meFrameType
Type for graphic frame shapes.
Definition: shape.hxx:365
void keepDiagramDrawing(::oox::core::XmlFilterBase &rFilterBase, const OUString &rFragmentPath)
Definition: shape.cxx:1840
GraphicPropertiesPtr mpGraphicPropertiesPtr
Definition: shape.hxx:338
Shape(const char *pServiceType=nullptr, bool bDefaultHeight=true)
Definition: shape.cxx:120
Shape3DProperties & get3DProperties()
Definition: shape.hxx:146
virtual void useInternalChartDataTable(bool)
Helper to switch chart data table - specifically for xlsx imports.
sal_Int32 nIndex
sal_Int32 convertEmuToHmm(sal_Int64 nValue)
Converts the passed 64-bit integer value from EMUs to 1/100 mm.
std::vector< std::unique_ptr< Effect > > m_Effects
Stores all effect properties, including those not supported by core yet.
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
bool isLinkedTxbx() const
Definition: shape.hxx:237
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
void putPropertiesToGrabBag(const css::uno::Sequence< css::beans::PropertyValue > &aProperties)
Definition: shape.cxx:2148
bool isWPGChild() const
Definition: shape.hxx:225
This class is used for creating XmlStream.
OUString msServiceName
Definition: shape.hxx:350
const EffectProperties * getEffectStyle(sal_Int32 nIndex) const
Definition: theme.cxx:55
void addChildren(::oox::core::XmlFilterBase &rFilterBase, Shape &rMaster, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, ShapeIdMap *pShapeMap, const basegfx::B2DHomMatrix &aTransformation)
Definition: shape.cxx:510
PropertyMap & getShapeProperties()
Definition: shape.hxx:126
Handler for a chart fragment (c:chartSpace root element).
std::map< OUString, ShapePairs > NamedShapePairs
std::shared_ptr< TableProperties > TablePropertiesPtr
OptValue< sal_Int32 > moFillType
static SdrTextHorzAdjust lcl_convertAdjust(ParagraphAdjust eAdjust)
Definition: shape.cxx:543
SdrTextHorzAdjust
sal_Int32 mnSubType
Definition: shape.hxx:355
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
const ShapeStyleRef * getShapeStyleRef(sal_Int32 nRefType) const
Definition: shape.cxx:334
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
void putPropertyToGrabBag(const OUString &sPropertyName, const css::uno::Any &aPropertyValue)
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
Definition: propertymap.hxx:72
CustomShapePropertiesPtr mpCustomShapePropertiesPtr
Definition: shape.hxx:339
constexpr OUStringLiteral UNO_NAME_TEXT_UPPERDIST
void setMasterTextListStyle(const TextListStylePtr &pMasterTextListStyle)
Definition: shape.cxx:1982
sal_uInt64 Seek(sal_uInt64 nPos)
bool importFragment(const rtl::Reference< FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
bool has_value() const
Definition: helper.hxx:181
ModelObjectHelper & getModelObjectHelper() const
Returns a helper with containers for various named drawing objects for the imported document...
Definition: filterbase.cxx:353
geometry::RealPoint2D maPosition
ChartShapeInfo & setChartType(bool bEmbedShapes)
Definition: shape.cxx:300
void migrateDiagramHelperToNewShape(const ShapePtr &pTarget)
Definition: shape.cxx:243
PropertyMap maDefaultShapeProperties
Definition: shape.hxx:345
static void lcl_setPropertyValue(std::vector< beans::PropertyValue > &rPropVec, const OUString &rName, const beans::PropertyValue &rPropertyValue)
Definition: shape.cxx:534
sal_Int32 getLineWidth() const
Calculates the line width attribute from the internal state of the object.
#define SO3_SM_CLASSID
std::shared_ptr< T > make_shared(Args &&...args)
const OUString & getInternalName() const
Definition: shape.hxx:172
constexpr OUStringLiteral UNO_NAME_FILLSTYLE
OUString GetFontworkType(const OUString &rMsoType)
bool mbTextBox
This shape has a textbox.
Definition: shape.hxx:387
css::drawing::LineJoint getLineJoint() const
Calculates the line joint attribute from the internal state of the object.
void setX(double fX)
constexpr OUStringLiteral UNO_NAME_CHAR_HEIGHT
css::uno::Reference< css::awt::XBitmap > getFillBitmap(OUString const &rGraphicName)
::oox::vml::OleObjectInfo & setOleObjectType()
Definition: shape.cxx:292
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
constexpr OUStringLiteral UNO_NAME_TEXT_VERTADJUST
constexpr OUStringLiteral UNO_NAME_TEXT_LEFTDIST
GraphicHelper & getGraphicHelper() const
Returns a helper for the handling of graphics and graphic objects.
Definition: filterbase.cxx:346
static OutputDevice * GetDefaultDevice()
bool equalZero() const
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
constexpr tools::Long Width() const
LinePropertiesPtr mpShapeRefLinePropPtr
Definition: shape.hxx:335
void setTextBody(const TextBodyPtr &pTextBody)
Definition: shape.cxx:1977
void setLockedCanvas(bool bLockedCanvas)
Definition: shape.cxx:442
void addShape(::oox::core::XmlFilterBase &rFilterBase, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, const basegfx::B2DHomMatrix &aTransformation, const FillProperties &rShapeOrParentShapeFillProps, ShapeIdMap *pShapeMap=nullptr, oox::drawingml::ShapePtr pParentGroupShape=nullptr)
Definition: shape.cxx:340
bool importBinaryData(StreamDataSequence &orDataSeq, const OUString &rStreamName)
Imports the raw binary data from the specified stream.
Definition: filterbase.cxx:382
Reference< document::XActionLockable > m_xLockable
Definition: shape.cxx:504
Reference< XInputStream > xStream
PropertiesInfo aProperties
constexpr OUStringLiteral sServiceName
OUString finalizeServiceName(::oox::core::XmlFilterBase &rFilter, const OUString &rServiceName, const css::awt::Rectangle &rShapeRect)
Definition: shape.cxx:1989
void pushToPropMap(ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper, sal_Int32 nShapeRotation=0,::Color nPhClr=API_RGB_TRANSPARENT, sal_Int16 nPhClrTheme=-1, bool bFlipH=false, bool bFlipV=false, bool bIsCustomShape=false) const
Writes the properties to the passed property map.
void insert(sal_uInt32 nIndex, const basegfx::B2DPoint &rPoint, sal_uInt32 nCount=1)
const Type & get() const
Definition: helper.hxx:184
css::awt::Point maPosition
Definition: shape.hxx:361
SDRTEXTHORZADJUST_CENTER
EffectProperties & getEffectProperties() const
Definition: shape.hxx:151
void setTextBox(bool bTextBox)
Definition: shape.cxx:457
bool setAnyProperty(sal_Int32 nPropId, const css::uno::Any &rValue)
Puts the passed any into the property set.
Definition: propertyset.cxx:70
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
float GetFontHeight(sal_Int32 nHeight)
ChartShapeInfoRef mxChartShapeInfo
Additional data for chart shapes.
Definition: shape.hxx:373
css::uno::Reference< css::drawing::XShape > mxShape
Definition: shape.hxx:347
sal_Int32 mnRotation
Definition: shape.hxx:375
EffectSoftEdgeProperties maSoftEdge
OLE object embedded in a shape.
Definition: shape.hxx:276
sal_uInt16 mapMode
T NormAngle360(T angle)
css::drawing::LineStyle getLineStyle() const
Calculates the line style attribute from the internal state of the object.
table::TablePropertiesPtr mpTablePropertiesPtr
Definition: shape.hxx:340
void pushToPropMap(ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper,::Color nPhClr=API_RGB_TRANSPARENT) const
Writes the properties to the passed property map.
std::vector< ShapePtr > maChildren
Definition: shape.hxx:329
bool mbWps
Is this a wps shape?
Definition: shape.hxx:386
SDRTEXTHORZADJUST_LEFT
css::uno::Sequence< sal_Int8 > StreamDataSequence
UNDERLYING_TYPE get() const
Interface class, StarMath will implement readFormulaOoxml() to read OOXML representing the formula an...
Definition: import.hxx:29
#define TOOLS_WARN_EXCEPTION(area, stream)
::Color getColor(const GraphicHelper &rGraphicHelper,::Color nPhClr=API_RGB_TRANSPARENT) const
Returns the final RGB color value.
Definition: color.cxx:531
static SvtFilterOptions & Get()
virtual void finalizeXShape(::oox::core::XmlFilterBase &rFilter, const css::uno::Reference< css::drawing::XShapes > &rxShapes)
void clearTransformations()
Removes all color transformations.
Definition: color.cxx:362
OleObjectInfoRef mxOleObjectInfo
Additional data for OLE objects.
Definition: shape.hxx:372
LineProperties & getLineProperties()
Definition: shape.hxx:128
css::awt::Size maSize
Definition: shape.hxx:360
void setWPGChild(bool bWPG)
Definition: shape.cxx:447
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:87
bool mbLockedCanvas
Is this shape part of a locked canvas?
Definition: shape.hxx:385
::oox::ole::OleObjectHelper & getOleObjectHelper() const
Returns a helper for the handling of OLE objects.
Definition: filterbase.cxx:368
constexpr OUStringLiteral UNO_NAME_TEXT_RIGHTDIST
Contains information about an OLE object embedded in a draw page.
Definition: vmldrawing.hxx:62
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void rotate(double fRadiant)
OUString GetHexName() const
#define STREAM_SEEK_TO_BEGIN
virtual ~Shape()
Definition: shape.cxx:198
bool importOleObject(PropertyMap &rPropMap, const OleObjectInfo &rOleObject, const css::awt::Size &rObjSize)
constexpr OUStringLiteral UNO_NAME_TEXT_AUTOGROWHEIGHT
TextBodyPtr mpTextBody
Definition: shape.hxx:333
constexpr OUStringLiteral UNO_NAME_CHAR_POSTURE
A table embedded in a shape.
Definition: shape.hxx:279
void pushToPropMap(PropertyMap &rPropMap, const GraphicHelper &rGraphicHelper) const
Writes the properties to the passed property map.
void setDefaults(bool bHeight)
Definition: shape.cxx:277
GradientFillProperties maGradientProps
Whether the background is used as fill type.
float u
FillProperties getActualFillProperties(const Theme *pTheme, const FillProperties *pParentShapeFillProps) const
Definition: shape.cxx:2176
void scale(double fX, double fY)
const css::uno::Reference< css::uno::XComponentContext > & getComponentContext() const
Returns the component context passed in the filter constructor (always existing). ...
Definition: filterbase.cxx:215
void SetMergedItem(const SfxPoolItem &rItem)
void convertSmartArtToMetafile(::oox::core::XmlFilterBase const &rFilterBase)
Definition: shape.cxx:1888
Additional information for a chart embedded in a drawing shape.
Definition: shape.hxx:91
ColorTransparency
PropertyValueVector_t aPropertyValues
std::shared_ptr< TextBody > TextBodyPtr
A wrapper for a UNO property set.
Definition: propertyset.hxx:57
void propagateDiagramHelper()
Definition: shape.cxx:219
virtual ::oox::vml::Drawing * getVmlDrawing()=0
Has to be implemented by each filter to return the collection of VML shapes.
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
void prepareDiagramHelper(const std::shared_ptr< Diagram > &rDiagramPtr, const std::shared_ptr<::oox::drawingml::Theme > &rTheme)
Definition: shape.cxx:205
void convertFromModel(::oox::core::XmlFilterBase &rFilter, ChartSpaceModel &rChartModel, const css::uno::Reference< css::chart2::XChartDocument > &rxChartDoc, const css::uno::Reference< css::drawing::XShapes > &rxExternalPage, const css::awt::Point &rChartPos, const css::awt::Size &rChartSize)
Converts the passed OOXML chart model to the passed chart2 document.
constexpr OUStringLiteral UNO_NAME_TEXT_AUTOGROWWIDTH
LineProperties getActualLineProperties(const Theme *pTheme) const
Definition: shape.cxx:2205
EffectPropertiesPtr mpShapeRefEffectPropPtr
Definition: shape.hxx:343
const css::uno::Sequence< css::beans::PropertyValue > & getTransformations() const
Returns the unaltered list of transformations for interoperability purposes.
Definition: color.hxx:107
const css::uno::Reference< css::frame::XModel > & getModel() const
Returns the document model (always existing).
Definition: filterbase.cxx:220
sal_uInt16 xExt
Degree100 NormAngle36000(Degree100 a)
void transform(const basegfx::B2DHomMatrix &rMatrix)
const LineProperties * getLineStyle(sal_Int32 nIndex) const
Returns the line properties of the passed one-based themed style index.
Definition: theme.cxx:50
tools::Long const nBorder
const SlidePersistPtr & getActualSlidePersist() const
Definition: pptimport.hxx:68
static void lcl_createPresetShape(const uno::Reference< drawing::XShape > &xShape, const OUString &rClass, const OUString &rPresetType, const CustomShapePropertiesPtr &pCustomShapePropertiesPtr, const TextBodyPtr &pTextBody, const GraphicHelper &rGraphicHelper)
Definition: shape.cxx:554
const TextCharacterProperties * getFontStyle(sal_Int32 nSchemeType) const
Returns theme font properties by scheme type (major/minor).
Definition: theme.cxx:60
SDRTEXTHORZADJUST_RIGHT
const TextBodyPtr & getTextBody() const
Definition: shape.hxx:193
std::shared_ptr< TextListStyle > TextListStylePtr
T saturating_add(T a, T b)
bool IsSmartArt2Shape() const
sal_Int16 getSchemeColorIndex() const
Definition: color.cxx:713
void assignUsed(const EffectProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
static const OUString & getPropertyName(sal_Int32 nPropId)
Returns the name of the passed property identifier.
sal_uInt16 yExt
FillProperties maLineFill
End line arrow style.
#define ERRCODE_NONE
TextListStylePtr mpMasterTextListStyle
Definition: shape.hxx:346
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::uno::Sequence< css::beans::PropertyValue > getShape3DAttributes(const GraphicHelper &rGraphicHelper,::Color rPhClr)
EffectProperties getActualEffectProperties(const Theme *pTheme) const
Definition: shape.cxx:2229
#define SAL_INFO(area, stream)
NamedShapePairs * getDiagramFontHeights()
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
css::drawing::LineCap getLineCap() const
Calculates the line cap attribute from the internal state of the object.
::std::map< OUString, ShapePtr > ShapeIdMap
Definition: shape.hxx:77
constexpr OUStringLiteral UNO_NAME_CHAR_WEIGHT
svx::diagram::IDiagramHelper * mpDiagramHelper
Definition: shape.hxx:416
const css::awt::Size & getSize() const
Definition: shape.hxx:160
bool isPlaceHolder() const
Returns true, if the color is a placeholder color in theme style lists.
Definition: color.hxx:89
void keepDiagramCompatibilityInfo()
Definition: shape.cxx:1857
QPRO_FUNC_TYPE nType
const char * name
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
sal_Int16 getTransparency() const
Returns the transparency of the color (0 = opaque, 100 = full transparent).
Definition: color.cxx:708
void assignUsed(const TextCharacterProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
virtual ::oox::drawingml::chart::ChartConverter * getChartConverter()=0
Has to be implemented by each filter, returns a filter-specific chart converter object, that should be global per imported document.
void translate(double fX, double fY)
ShapeStyleRefMap maShapeStyleRefs
Definition: shape.hxx:358
RelationsRef importRelations(const OUString &rFragmentPath)
Imports the relations fragment associated with the specified fragment.
void assignUsed(const FillProperties &rSourceProps)
Properties for bitmap fills.
Represents the collection of VML shapes for a complete draw page.
Definition: vmldrawing.hxx:93
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
constexpr OUStringLiteral UNO_NAME_FILLCOLOR
std::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr
static void lcl_resetPropertyValue(std::vector< beans::PropertyValue > &rPropVec, const OUString &rName)
Definition: shape.cxx:525
#define SAL_WARN(area, stream)
double getX() const
OUString msDescription
Definition: shape.hxx:354
std::shared_ptr< Shape > ShapePtr
Color maFillColor
Fill type (OOXML token).
sal_Int32 nLength
css::uno::Sequence< css::beans::PropertyValue > getCameraAttributes()
css::uno::Reference< css::drawing::XShape > renderDiagramToGraphic(::oox::core::XmlFilterBase const &rFilterBase)
Definition: shape.cxx:1911
void setServiceName(const char *pServiceName)
Definition: shape.cxx:328
void assignUsed(const LineProperties &rSourceProps)
Line joint type (OOXML token).
void applyShapeReference(const Shape &rReferencedShape, bool bUseText=true)
Definition: shape.cxx:462
FillPropertiesPtr mpShapeRefFillPropPtr
Definition: shape.hxx:337
OptValue< sal_Int32 > moLineWidth
User-defined line dash style.
constexpr OUStringLiteral UNO_NAME_TEXT_LOWERDIST
FillProperties & getFillProperties()
Definition: shape.hxx:131
PropertyMap maShapeProperties
Definition: shape.hxx:344
sal_Int32 mnDiagramRotation
Definition: shape.hxx:376
Complex diagram drawing shape.
Definition: shape.hxx:278
Chart embedded in a shape.
Definition: shape.hxx:277
void setWps(bool bWps)
Definition: shape.cxx:452
css::uno::Sequence< css::uno::Sequence< css::uno::Any > > resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase &rFilter, const OUString &sFragment, std::u16string_view sType)
Definition: shape.cxx:2252
std::shared_ptr< Theme > ThemePtr
Generic shape, no special type.
Definition: shape.hxx:275
const FillProperties * getFillStyle(sal_Int32 nIndex) const
Returns the fill properties of the passed one-based themed style index.
Definition: theme.cxx:43
void cloneFillProperties()
Changes reference semantics to value semantics for fill properties.
Definition: shape.cxx:2294
OUString msName
const LinkedTxbxAttr & getLinkedTxbxAttributes() const
Definition: shape.hxx:236
css::uno::Reference< css::drawing::XShape > const & createAndInsert(::oox::core::XmlFilterBase &rFilterBase, const OUString &rServiceName, const Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, bool bClearText, bool bDoNotInsertEmptyTextBody, basegfx::B2DHomMatrix &aTransformation, const FillProperties &rShapeOrParentShapeFillProps, oox::drawingml::ShapePtr pParentGroupShape=nullptr)
Definition: shape.cxx:793
table::TablePropertiesPtr const & getTableProperties()
Definition: shape.cxx:270
FillPropertiesPtr mpFillPropertiesPtr
Definition: shape.hxx:336
::basegfx::B2IVector maSize
sal_uInt32 count() const
#define GRFILTER_FORMAT_NOTFOUND
bool m_bDetectedRangeSegmentation false
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
css::uno::Sequence< css::beans::PropertyValue > getLightRigAttributes()
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
css::uno::Sequence< css::beans::PropertyValue > maDiagramDoms
Definition: shape.hxx:391