21#include <com/sun/star/drawing/XDrawPage.hpp>
22#include <com/sun/star/drawing/XShapes.hpp>
23#include <com/sun/star/frame/XModel.hpp>
32#include <oox/token/properties.hxx>
33#include <oox/token/tokens.hxx>
38#include <osl/diagnose.h>
40#include <com/sun/star/style/XStyle.hpp>
41#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
42#include <com/sun/star/container/XNamed.hpp>
43#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
44#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
45#include <com/sun/star/container/XIdentifierContainer.hpp>
46#include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
47#include <com/sun/star/drawing/ConnectorType.hpp>
62 const css::uno::Reference< css::drawing::XDrawPage >& rxPage,
66, maShapesPtr(
std::move( pShapesPtr ))
67, mnLayoutValueToken( 0 )
70, maDefaultTextStylePtr(
std::move( pDefaultTextStyle ))
76#if OSL_DEBUG_LEVEL > 0
81#if OSL_DEBUG_LEVEL > 0
91 sal_Int16 nLayout = 20;
94 case XML_blank: nLayout = 20;
break;
95 case XML_chart: nLayout = 2;
break;
96 case XML_chartAndTx: nLayout = 7;
break;
97 case XML_clipArtAndTx: nLayout = 9;
break;
98 case XML_clipArtAndVertTx: nLayout = 24;
break;
99 case XML_fourObj: nLayout = 18;
break;
100 case XML_obj: nLayout = 11;
break;
101 case XML_objAndTx: nLayout = 13;
break;
102 case XML_objOverTx: nLayout = 14;
break;
103 case XML_tbl: nLayout = 8;
break;
104 case XML_title: nLayout = 0;
break;
105 case XML_titleOnly: nLayout = 19;
break;
107 case XML_twoColTx: nLayout = 3;
break;
108 case XML_twoObjAndTx: nLayout = 15;
break;
109 case XML_twoObjOverTx: nLayout = 16;
break;
110 case XML_tx: nLayout = 1;
break;
111 case XML_txAndChart: nLayout = 4;
break;
112 case XML_txAndClipArt: nLayout = 6;
break;
113 case XML_txAndMedia: nLayout = 6;
break;
114 case XML_txAndObj: nLayout = 10;
break;
115 case XML_txAndTwoObj: nLayout = 12;
break;
116 case XML_txOverObj: nLayout = 17;
break;
117 case XML_vertTitleAndTx: nLayout = 22;
break;
118 case XML_vertTitleAndTxOverChart: nLayout = 21;
break;
119 case XML_vertTx: nLayout = 23;
break;
121 case XML_twoTxTwoObj:
122 case XML_twoObjAndObj:
127 case XML_objAndTwoObj:
141 Reference< XShapes > xShapes(
getPage() );
142 std::vector< oox::drawingml::ShapePtr >& rShapes(
maShapesPtr->getChildren() );
144 for (
auto const& shape : rShapes)
146 std::vector< oox::drawingml::ShapePtr >& rChildren( shape->getChildren() );
147 for (
auto const& child : rChildren)
173 Reference< XAnimationNodeSupplier > xNodeSupplier(
getPage(), UNO_QUERY);
174 if( !xNodeSupplier.is() )
177 Reference< XAnimationNode > xNode( xNodeSupplier->getAnimationNode() );
182 OSL_ENSURE( pNode,
"pNode" );
184 Reference<XAnimationNode> xDummy;
185 pNode->setNode(rFilterBase, xNode, pSlidePtr, xDummy);
196 css::awt::Size aSize;
197 Reference< css::beans::XPropertySet > xSet(
mxPage, UNO_QUERY);
198 xSet->getPropertyValue(
"Width") >>= aSize.Width;
199 xSet->getPropertyValue(
"Height") >>= aSize.Height;
210static void setTextStyle( Reference< beans::XPropertySet >
const & rxPropSet,
const XmlFilterBase& rFilter,
214 if( pTextParagraphPropertiesPtr ==
nullptr )
234 Reference< style::XStyleFamiliesSupplier > aXStyleFamiliesSupplier( rFilterBase.getModel(), UNO_QUERY_THROW );
235 Reference< container::XNameAccess > aXNameAccess( aXStyleFamiliesSupplier->getStyleFamilies() );
236 Reference< container::XNamed > aXNamed(
mxPage, UNO_QUERY_THROW );
238 if ( aXNameAccess.is() )
244 static constexpr OUStringLiteral sOutline(
u"outline1" );
245 static constexpr OUStringLiteral sTitle(
u"title" );
246 static constexpr OUStringLiteral sStandard(
u"standard" );
247 static constexpr OUStringLiteral sSubtitle(
u"subtitle" );
249 for(
int i = 0;
i < 4;
i++ )
257 aFamily= aXNamed->getName();
264 aFamily= aXNamed->getName();
271 aFamily= aXNamed->getName();
278 aFamily =
"graphics";
285 aFamily = aXNamed->getName();
289 Reference< container::XNameAccess > xFamilies;
290 if ( aXNameAccess->hasByName( aFamily ) )
292 if( aXNameAccess->getByName( aFamily ) >>= xFamilies )
294 if ( xFamilies->hasByName( aStyle ) )
296 Reference< style::XStyle > aXStyle;
297 if ( xFamilies->getByName( aStyle ) >>= aXStyle )
299 Reference< beans::XPropertySet > xPropSet( aXStyle, UNO_QUERY_THROW );
301 setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, 0 );
304 for (
int nLevel = 1; nLevel < 5; nLevel++ )
307 char pOutline[ 9 ] =
"outline1";
308 pOutline[ 7 ] =
static_cast< char >(
'0' + nLevel );
309 OUString sOutlineStyle( OUString::createFromAscii( pOutline ) );
310 if ( xFamilies->hasByName( sOutlineStyle ) )
312 xFamilies->getByName( sOutlineStyle ) >>= aXStyle;
314 xPropSet.set( aXStyle, UNO_QUERY_THROW );
318 setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, nLevel );
335 std::vector< oox::drawingml::ShapePtr >& rShapes(
maShapesPtr->getChildren() );
336 for (
auto const& shape : rShapes)
338 std::vector< oox::drawingml::ShapePtr >& rChildren( shape->getChildren() );
339 for (
auto const& child : rChildren)
350static sal_Int32
lcl_GetAngle(uno::Reference<drawing::XShape>& rXShape, awt::Point& rPt)
354 sal_Int32 nLeftX = rPt.X - aR.
Left();
355 sal_Int32 nTopY = rPt.Y - aR.
Top();
356 sal_Int32 nRightX = aR.
Right() - rPt.X;
357 sal_Int32 nBottomY = aR.
Bottom() - rPt.Y;
358 sal_Int32 nX = std::min(nLeftX, nRightX);
359 sal_Int32 nY = std::min(nTopY, nBottomY);
364 if (nLeftX < nRightX)
371 if (nTopY < nBottomY)
383 return pIter->second;
385 Reference<XAnimationNode> aResult;
393 awt::Point aStartPt, aEndPt;
395 uno::Reference<drawing::XShape> xStartSp, xEndSp;
396 uno::Reference<beans::XPropertySet> xPropSet(rXConnector, uno::UNO_QUERY);
397 xPropSet->getPropertyValue(
"EdgeStartPoint") >>= aStartPt;
398 xPropSet->getPropertyValue(
"EdgeEndPoint") >>= aEndPt;
399 xPropSet->getPropertyValue(
"StartShape") >>= xStartSp;
400 xPropSet->getPropertyValue(
"EndShape") >>= xEndSp;
401 xPropSet->setPropertyValue(
"EdgeNode1HorzDist",
Any(sal_Int32(0)));
402 xPropSet->setPropertyValue(
"EdgeNode1VertDist",
Any(sal_Int32(0)));
403 xPropSet->setPropertyValue(
"EdgeNode2HorzDist",
Any(sal_Int32(0)));
404 xPropSet->setPropertyValue(
"EdgeNode2VertDist",
Any(sal_Int32(0)));
409 sal_Int32 nStartA = -1;
410 sal_Int32 nEndA = -1;
423 if (!rShapePtr->getConnectorAdjustments().empty())
425 sal_Int32 nAdjustValue = 0;
426 for (
size_t i = 0;
i < rShapePtr->getConnectorAdjustments().
size();
i++)
428 bool bVertical =
false;
429 if (xStartSp.is() || xEndSp.is())
430 bVertical = xStartSp.is() ? ((nStartA == 90 || nStartA == 270) ?
true :
false)
431 : ((nEndA == 90 || nEndA == 270) ?
true :
false);
434 sal_Int32 nAng = rShapePtr->getRotation() / 60000;
435 bVertical = (nAng == 90 || nAng == 270) ?
true :
false;
439 bVertical = !bVertical;
441 nAdjustValue = rShapePtr->getConnectorAdjustments()[
i].toInt32();
444 sal_Int32 nY = aStartPt.Y + ((nAdjustValue * (aEndPt.Y - aStartPt.Y)) / 100000);
445 if (xStartSp.is() && xEndSp.is())
449 if (nStartA == 270 &&
i != 2)
450 nEdge = nY - aS.
Top();
453 if (aS.
Bottom() < aE.
Top() && nEndA != 90)
463 if (nStartA == 90 &&
i != 2)
467 if (aE.
Bottom() < aS.
Top() && nEndA != 270)
468 nEdge = nY - (aS.
Top() + ((aE.
Bottom() - aS.
Top()) / 2));
470 nEdge = nY - aE.
Top();
474 else if ((xStartSp.is() && !xEndSp.is()) || (!xStartSp.is() && xEndSp.is()))
476 if (aStartPt.Y < aEndPt.Y)
479 nEdge = (nStartA == 90)
480 ? nY - (aEndPt.Y - ((aEndPt.Y - aS.
Bottom()) / 2))
483 nEdge = (nEndA == 90)
485 : nY - (aStartPt.Y + ((aE.
Top() - aStartPt.Y) / 2));
490 nEdge = (nStartA == 90) ? nY - aS.
Bottom()
491 : nY - (aEndPt.Y + ((aS.
Top() - aEndPt.Y) / 2));
493 nEdge = (nEndA == 90)
494 ? nY - (aStartPt.Y - ((aStartPt.Y - aE.
Bottom()) / 2))
500 nEdge = (aStartPt.Y < aEndPt.Y)
501 ? nY - (aStartPt.Y + (rXConnector->getSize().Height / 2))
502 : nY - (aStartPt.Y - (rXConnector->getSize().Height / 2));
507 sal_Int32 nX = aStartPt.X + ((nAdjustValue * (aEndPt.X - aStartPt.X)) / 100000);
508 if (xStartSp.is() && xEndSp.is())
512 if (nStartA == 180 &&
i != 2)
513 nEdge = nX - aS.
Left();
516 if (aS.
Right() < aE.
Left() && nEndA != 0)
519 nEdge = nX - aE.
Right();
524 if (nStartA == 0 &&
i != 2)
525 nEdge = nX - aS.
Right();
528 if (aE.
Right() < aS.
Left() && nEndA != 180)
531 nEdge = nX - aE.
Left();
535 else if ((xStartSp.is() && !xEndSp.is()) || (!xStartSp.is() && xEndSp.is()))
537 if (aStartPt.X < aEndPt.X)
540 nEdge = (nStartA == 0)
541 ? nX - (aS.
Right() + ((aEndPt.X - aS.
Right()) / 2))
546 : nX - (aStartPt.X + ((aE.
Left() - aStartPt.X) / 2));
551 nEdge = (nStartA == 0) ? nX - aS.
Right()
552 : nX - (aEndPt.X + ((aS.
Left() - aEndPt.X) / 2));
555 ? nX - (aE.
Right() + ((aStartPt.X - aE.
Right()) / 2))
561 nEdge = (aStartPt.X < aEndPt.X)
562 ? nX - (aStartPt.X + (rXConnector->getSize().Width / 2))
563 : nX - (aStartPt.X - (rXConnector->getSize().Width / 2));
566 xPropSet->setPropertyValue(
"EdgeLine" + OUString::number(
i + 1) +
"Delta",
Any(nEdge));
571 const OUString sConnectorName = rShapePtr->getConnectorName();
572 if (sConnectorName ==
"bentConnector2")
574 awt::Size aConnSize = rXConnector->getSize();
575 if (xStartSp.is() || xEndSp.is())
581 case 0: nEdge = aEndPt.X - aS.
Right();
break;
582 case 180: nEdge = aEndPt.X - aS.
Left();
break;
583 case 90: nEdge = aEndPt.Y - aS.
Bottom();
break;
584 case 270: nEdge = aEndPt.Y - aS.
Top();
break;
589 case 0: nEdge = aStartPt.X - aE.
Right();
break;
590 case 180: nEdge = aStartPt.X - aE.
Left();
break;
591 case 90: nEdge = aStartPt.Y - aE.
Bottom();
break;
592 case 270: nEdge = aStartPt.Y - aE.
Top();
break;
598 bool bFlipH = rShapePtr->getFlipH();
599 bool bFlipV = rShapePtr->getFlipV();
600 sal_Int32 nConnectorAngle = rShapePtr->getRotation() / 60000;
601 if (aConnSize.Height < aConnSize.Width)
603 if ((nConnectorAngle == 90 && bFlipH && bFlipV) || (nConnectorAngle == 180)
604 || (nConnectorAngle == 270 && bFlipH))
605 nEdge -= aConnSize.Width;
607 nEdge += aConnSize.Width;
611 if ((nConnectorAngle == 180 && bFlipV) || (nConnectorAngle == 270 && bFlipV)
612 || (nConnectorAngle == 90 && bFlipH && bFlipV)
613 || (nConnectorAngle == 0 && !bFlipV))
614 nEdge -= aConnSize.Height;
616 nEdge += aConnSize.Height;
619 xPropSet->setPropertyValue(
"EdgeLine1Delta",
Any(nEdge / 2));
628 for (sal_Int32
i = 0;
i < nConnectorShapeCount;
i++)
634 = pIt->second->getConnectorShapeProperties();
635 uno::Reference<drawing::XShape> xConnector(pIt->second->getXShape(), uno::UNO_QUERY);
636 uno::Reference<beans::XPropertySet> xPropertySet(xConnector, uno::UNO_QUERY);
640 sal_Int32
nCount = aConnectorShapeProperties.size();
641 for (sal_Int32 j = 0; j <
nCount; j++)
643 OUString aDestShapeId = aConnectorShapeProperties[j].maDestShapeId;
644 const auto& pShape =
maShapeMap.find(aDestShapeId);
647 uno::Reference<drawing::XShape> xShape(pShape->second->getXShape(), uno::UNO_QUERY);
650 uno::Reference<drawing::XGluePointsSupplier> xSupplier(xShape, uno::UNO_QUERY);
651 css::uno::Reference<css::container::XIdentifierContainer> xGluePoints(
652 xSupplier->getGluePoints(), uno::UNO_QUERY);
654 sal_Int32 nCountGluePoints = xGluePoints->getIdentifiers().getLength();
655 sal_Int32 nGlueId = aConnectorShapeProperties[j].mnDestGlueId;
658 if (nCountGluePoints > 4)
662 bool bFlipH = pShape->second->getFlipH();
663 bool bFlipV = pShape->second->getFlipV();
664 if ((!bFlipH && !bFlipV) || (bFlipH && bFlipV))
669 else if (nGlueId == 3)
674 bool bStart = aConnectorShapeProperties[j].mbStartShape;
677 xPropertySet->setPropertyValue(
"StartShape",
uno::Any(xShape));
678 xPropertySet->setPropertyValue(
"StartGluePointIndex",
uno::Any(nGlueId));
682 xPropertySet->setPropertyValue(
"EndShape",
uno::Any(xShape));
683 xPropertySet->setPropertyValue(
"EndGluePointIndex",
uno::Any(nGlueId));
687 uno::Reference<beans::XPropertySetInfo> xPropInfo = xPropertySet->getPropertySetInfo();
688 if (xPropInfo->hasPropertyByName(
"EdgeKind"))
690 ConnectorType aConnectorType;
691 xPropertySet->getPropertyValue(
"EdgeKind") >>= aConnectorType;
692 if (aConnectorType == ConnectorType_STANDARD)
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
virtual const tools::Rectangle & GetSnapRect() const
A helper that maps property identifiers to property values.
css::uno::Reference< css::beans::XPropertySet > makePropertySet() const
Creates a property set supporting the XPropertySet interface and inserts all properties.
A wrapper for a UNO property set.
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
bool isUsed() const
Returns true, if the color is initialized.
::Color getColor(const GraphicHelper &rGraphicHelper, ::Color nPhClr=API_RGB_TRANSPARENT) const
Returns the final RGB color value.
std::vector< ShapePtr > & getChildren()
const OUString & getId() const
void setHiddenMasterShape(bool bHiddenMasterShape)
bool isConnectorShape() const
TextCharacterProperties & getTextCharacterProperties()
PropertyMap & getTextParagraphPropertyMap()
void addShape(oox::core::XmlFilterBase &rFilterBase, const SlidePersist &rPersist, const oox::drawingml::Theme *pTheme, const css::uno::Reference< css::drawing::XShapes > &rxShapes, basegfx::B2DHomMatrix &aTransformation, ::oox::drawingml::ShapeIdMap *pShapeMap)
void createConnectorShapeConnection()
::oox::drawingml::ShapeIdMap & getShapeMap()
oox::drawingml::TextListStylePtr maOtherTextStylePtr
std::map< OUString, ::oox::drawingml::ShapePtr > maShapeMap
void createBackground(const oox::core::XmlFilterBase &rFilterBase)
oox::drawingml::TextListStylePtr maBodyTextStylePtr
oox::drawingml::TextListStylePtr maTitleTextStylePtr
const css::uno::Reference< css::drawing::XDrawPage > & getPage() const
sal_Int32 mnLayoutValueToken
oox::drawingml::ShapePtr maShapesPtr
void createXShapes(oox::core::XmlFilterBase &rFilterBase)
static css::uno::WeakReference< css::drawing::XDrawPage > mxDebugPage
std::vector< OUString > maConnectorShapeId
const oox::drawingml::ThemePtr & getTheme() const
css::uno::Reference< css::drawing::XDrawPage > mxPage
oox::drawingml::TextListStylePtr maDefaultTextStylePtr
css::uno::Reference< css::animations::XAnimationNode > getAnimationNode(const OUString &sId) const
oox::drawingml::TextListStylePtr maNotesTextStylePtr
void applyTextStyles(const oox::core::XmlFilterBase &rFilterBase)
std::map< OUString, css::uno::Reference< css::animations::XAnimationNode > > maAnimNodesMap
SlidePersist(oox::core::XmlFilterBase &rFilter, bool bMaster, bool bNotes, const css::uno::Reference< css::drawing::XDrawPage > &, oox::drawingml::ShapePtr pShapesPtr, ::oox::drawingml::TextListStylePtr)
oox::drawingml::Color maBackgroundColor
::std::vector< std::shared_ptr< TimeNode > > maTimeNodeList
void hideShapesAsMasterShapes()
oox::drawingml::FillPropertiesPtr mpBackgroundPropertiesPtr
sal_Int16 getLayoutFromValueToken() const
std::shared_ptr< T > make_shared(Args &&... args)
@ FillGradient
Explicit fill gradient or name of a fill gradient stored in a global container.
std::shared_ptr< Shape > ShapePtr
std::vector< ConnectorShapeProperties > ConnectorShapePropertiesList
std::shared_ptr< TextListStyle > TextListStylePtr
std::shared_ptr< TimeNode > TimeNodePtr
std::shared_ptr< SlidePersist > SlidePersistPtr
static sal_Int32 lcl_GetAngle(uno::Reference< drawing::XShape > &rXShape, awt::Point &rPt)
static void setTextStyle(Reference< beans::XPropertySet > const &rxPropSet, const XmlFilterBase &rFilter, oox::drawingml::TextListStylePtr const &pTextListStylePtr, int nLevel)
static void lcl_SetEdgeLineValue(uno::Reference< drawing::XShape > &rXConnector, oox::drawingml::ShapePtr &rShapePtr)
@ VMLDRAWING_POWERPOINT
PowerPoint: OLE objects are part of DrawingML.
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.
const ShapePropertyIds & mrPropertyIds
static ShapePropertyInfo DEFAULT
True = use named fill hatch instead of explicit fill hatch.
void pushToPropSet(PropertySet &rPropSet, const ::oox::core::XmlFilterBase &rFilter) const
Writes the properties to the passed property set.
constexpr OUStringLiteral PROP_FillGradientName