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);
205static void setTextStyle( Reference< beans::XPropertySet >
const & rxPropSet,
const XmlFilterBase& rFilter,
209 if( pTextParagraphPropertiesPtr ==
nullptr )
229 Reference< style::XStyleFamiliesSupplier > aXStyleFamiliesSupplier( rFilterBase.getModel(), UNO_QUERY_THROW );
230 Reference< container::XNameAccess > aXNameAccess( aXStyleFamiliesSupplier->getStyleFamilies() );
231 Reference< container::XNamed > aXNamed(
mxPage, UNO_QUERY_THROW );
233 if ( aXNameAccess.is() )
239 static const OUStringLiteral sOutline(
u"outline1" );
240 static const OUStringLiteral sTitle(
u"title" );
241 static const OUStringLiteral sStandard(
u"standard" );
242 static const OUStringLiteral sSubtitle(
u"subtitle" );
244 for(
int i = 0;
i < 4;
i++ )
252 aFamily= aXNamed->getName();
259 aFamily= aXNamed->getName();
266 aFamily= aXNamed->getName();
273 aFamily =
"graphics";
280 aFamily = aXNamed->getName();
284 Reference< container::XNameAccess > xFamilies;
285 if ( aXNameAccess->hasByName( aFamily ) )
287 if( aXNameAccess->getByName( aFamily ) >>= xFamilies )
289 if ( xFamilies->hasByName( aStyle ) )
291 Reference< style::XStyle > aXStyle;
292 if ( xFamilies->getByName( aStyle ) >>= aXStyle )
294 Reference< beans::XPropertySet > xPropSet( aXStyle, UNO_QUERY_THROW );
296 setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, 0 );
299 for (
int nLevel = 1; nLevel < 5; nLevel++ )
302 char pOutline[ 9 ] =
"outline1";
303 pOutline[ 7 ] =
static_cast< char >(
'0' + nLevel );
304 OUString sOutlineStyle( OUString::createFromAscii( pOutline ) );
305 if ( xFamilies->hasByName( sOutlineStyle ) )
307 xFamilies->getByName( sOutlineStyle ) >>= aXStyle;
309 xPropSet.set( aXStyle, UNO_QUERY_THROW );
313 setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, nLevel );
330 std::vector< oox::drawingml::ShapePtr >& rShapes(
maShapesPtr->getChildren() );
331 for (
auto const& shape : rShapes)
333 std::vector< oox::drawingml::ShapePtr >& rChildren( shape->getChildren() );
334 for (
auto const& child : rChildren)
345static sal_Int32
lcl_GetAngle(uno::Reference<drawing::XShape>& rXShape, awt::Point& rPt)
349 sal_Int32 nLeftX = rPt.X - aR.
Left();
350 sal_Int32 nTopY = rPt.Y - aR.
Top();
351 sal_Int32 nRightX = aR.
Right() - rPt.X;
352 sal_Int32 nBottomY = aR.
Bottom() - rPt.Y;
353 sal_Int32 nX = std::min(nLeftX, nRightX);
354 sal_Int32 nY = std::min(nTopY, nBottomY);
359 if (nLeftX < nRightX)
366 if (nTopY < nBottomY)
378 return pIter->second;
380 Reference<XAnimationNode> aResult;
388 awt::Point aStartPt, aEndPt;
390 uno::Reference<drawing::XShape> xStartSp, xEndSp;
391 uno::Reference<beans::XPropertySet> xPropSet(rXConnector, uno::UNO_QUERY);
392 xPropSet->getPropertyValue(
"EdgeStartPoint") >>= aStartPt;
393 xPropSet->getPropertyValue(
"EdgeEndPoint") >>= aEndPt;
394 xPropSet->getPropertyValue(
"StartShape") >>= xStartSp;
395 xPropSet->getPropertyValue(
"EndShape") >>= xEndSp;
396 xPropSet->setPropertyValue(
"EdgeNode1HorzDist",
Any(sal_Int32(0)));
397 xPropSet->setPropertyValue(
"EdgeNode1VertDist",
Any(sal_Int32(0)));
398 xPropSet->setPropertyValue(
"EdgeNode2HorzDist",
Any(sal_Int32(0)));
399 xPropSet->setPropertyValue(
"EdgeNode2VertDist",
Any(sal_Int32(0)));
404 sal_Int32 nStartSpLineW = 0;
405 sal_Int32 nStartA = -1;
406 sal_Int32 nEndA = -1;
410 uno::Reference<beans::XPropertySet> xPropxStartSp(xStartSp, uno::UNO_QUERY);
411 xPropxStartSp->getPropertyValue(
"LineWidth") >>= nStartSpLineW;
413 nStartSpLineW = nStartSpLineW / 2;
416 sal_Int32 nEndSpLineW = 0;
420 uno::Reference<beans::XPropertySet> xPropxEndSp(xEndSp, uno::UNO_QUERY);
421 xPropxEndSp->getPropertyValue(
"LineWidth") >>= nEndSpLineW;
423 nEndSpLineW = nEndSpLineW / 2;
427 const OUString sConnectorName = rShapePtr->getConnectorName();
428 if (sConnectorName ==
"bentConnector2")
430 awt::Size aConnSize = rXConnector->getSize();
431 if (xStartSp.is() || xEndSp.is())
437 case 0: nEdge = aEndPt.X - aStartRect.
Right();
break;
438 case 180: nEdge = aEndPt.X - aStartRect.
Left();
break;
439 case 90: nEdge = aEndPt.Y - aStartRect.
Bottom();
break;
440 case 270: nEdge = aEndPt.Y - aStartRect.
Top();
break;
442 nEdge += nStartSpLineW * (nStartA >= 180 ? +1 : -1);
446 case 0: nEdge = aStartPt.X - aEndRect.
Right();
break;
447 case 180: nEdge = aStartPt.X - aEndRect.
Left();
break;
448 case 90: nEdge = aStartPt.Y - aEndRect.
Bottom();
break;
449 case 270: nEdge = aStartPt.Y - aEndRect.
Top();
break;
451 nEdge += nEndSpLineW * (nEndA >= 180 ? +1 : -1);
456 bool bFlipH = rShapePtr->getFlipH();
457 bool bFlipV = rShapePtr->getFlipV();
458 sal_Int32 nConnectorAngle = rShapePtr->getRotation() / 60000;
459 if (aConnSize.Height < aConnSize.Width)
461 if ((nConnectorAngle == 90 && bFlipH && bFlipV) || (nConnectorAngle == 180)
462 || (nConnectorAngle == 270 && bFlipH))
463 nEdge -= aConnSize.Width;
465 nEdge += aConnSize.Width;
469 if ((nConnectorAngle == 180 && bFlipV) || (nConnectorAngle == 270 && bFlipV)
470 || (nConnectorAngle == 90 && bFlipH && bFlipV)
471 || (nConnectorAngle == 0 && !bFlipV))
472 nEdge -= aConnSize.Height;
474 nEdge += aConnSize.Height;
477 xPropSet->setPropertyValue(
"EdgeLine1Delta",
Any(nEdge / 2));
485 for (sal_Int32
i = 0;
i < nConnectorShapeCount;
i++)
491 = pIt->second->getConnectorShapeProperties();
492 uno::Reference<drawing::XShape> xConnector(pIt->second->getXShape(), uno::UNO_QUERY);
493 uno::Reference<beans::XPropertySet> xPropertySet(xConnector, uno::UNO_QUERY);
497 sal_Int32
nCount = aConnectorShapeProperties.size();
498 for (sal_Int32 j = 0; j <
nCount; j++)
500 OUString aDestShapeId = aConnectorShapeProperties[j].maDestShapeId;
501 const auto& pShape =
maShapeMap.find(aDestShapeId);
504 uno::Reference<drawing::XShape> xShape(pShape->second->getXShape(), uno::UNO_QUERY);
507 uno::Reference<drawing::XGluePointsSupplier> xSupplier(xShape, uno::UNO_QUERY);
508 css::uno::Reference<css::container::XIdentifierContainer> xGluePoints(
509 xSupplier->getGluePoints(), uno::UNO_QUERY);
511 sal_Int32 nCountGluePoints = xGluePoints->getIdentifiers().getLength();
512 sal_Int32 nGlueId = aConnectorShapeProperties[j].mnDestGlueId;
515 if (nCountGluePoints > 4)
522 else if (nGlueId == 3)
526 bool bStart = aConnectorShapeProperties[j].mbStartShape;
529 xPropertySet->setPropertyValue(
"StartShape",
uno::Any(xShape));
530 xPropertySet->setPropertyValue(
"StartGluePointIndex",
uno::Any(nGlueId));
534 xPropertySet->setPropertyValue(
"EndShape",
uno::Any(xShape));
535 xPropertySet->setPropertyValue(
"EndGluePointIndex",
uno::Any(nGlueId));
539 uno::Reference<beans::XPropertySetInfo> xPropInfo = xPropertySet->getPropertySetInfo();
540 if (xPropInfo->hasPropertyByName(
"EdgeKind"))
542 ConnectorType aConnectorType;
543 xPropertySet->getPropertyValue(
"EdgeKind") >>= aConnectorType;
544 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