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 #ifndef INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DATAMODEL_HXX 21 #define INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DATAMODEL_HXX 22 23 #include <map> 24 #include <memory> 25 #include <vector> 26 27 #include <rtl/ustring.hxx> 28 29 #include <oox/drawingml/drawingmltypes.hxx> 30 #include <oox/token/tokens.hxx> 31 #include <svx/DiagramDataInterface.hxx> 32 33 namespace oox::drawingml { 34 35 namespace dgm { 36 37 /** A Connection 38 */ 39 struct Connection 40 { Connectionoox::drawingml::dgm::Connection41 Connection() : 42 mnType( 0 ), 43 mnSourceOrder( 0 ), 44 mnDestOrder( 0 ) 45 {} 46 47 void dump() const; 48 49 sal_Int32 mnType; 50 OUString msModelId; 51 OUString msSourceId; 52 OUString msDestId; 53 OUString msParTransId; 54 OUString msPresId; 55 OUString msSibTransId; 56 sal_Int32 mnSourceOrder; 57 sal_Int32 mnDestOrder; 58 59 }; 60 61 typedef std::vector< Connection > Connections; 62 63 /** A point 64 */ 65 struct Point 66 { Pointoox::drawingml::dgm::Point67 Point() : 68 mnType(0), 69 mnMaxChildren(-1), 70 mnPreferredChildren(-1), 71 mnDirection(XML_norm), 72 mnResizeHandles(XML_rel), 73 mnCustomAngle(-1), 74 mnPercentageNeighbourWidth(-1), 75 mnPercentageNeighbourHeight(-1), 76 mnPercentageOwnWidth(-1), 77 mnPercentageOwnHeight(-1), 78 mnIncludeAngleScale(-1), 79 mnRadiusScale(-1), 80 mnWidthScale(-1), 81 mnHeightScale(-1), 82 mnWidthOverride(-1), 83 mnHeightOverride(-1), 84 mnLayoutStyleCount(-1), 85 mnLayoutStyleIndex(-1), 86 87 mbOrgChartEnabled(false), 88 mbBulletEnabled(false), 89 mbCoherent3DOffset(false), 90 mbCustomHorizontalFlip(false), 91 mbCustomVerticalFlip(false), 92 mbCustomText(false), 93 mbIsPlaceholder(false) 94 {} 95 void dump() const; 96 97 ShapePtr mpShape; 98 99 OUString msCnxId; 100 OUString msModelId; 101 OUString msColorTransformCategoryId; 102 OUString msColorTransformTypeId; 103 OUString msLayoutCategoryId; 104 OUString msLayoutTypeId; 105 OUString msPlaceholderText; 106 OUString msPresentationAssociationId; 107 OUString msPresentationLayoutName; 108 OUString msPresentationLayoutStyleLabel; 109 OUString msQuickStyleCategoryId; 110 OUString msQuickStyleTypeId; 111 112 sal_Int32 mnType; 113 sal_Int32 mnMaxChildren; 114 sal_Int32 mnPreferredChildren; 115 sal_Int32 mnDirection; 116 OptValue<sal_Int32> moHierarchyBranch; 117 sal_Int32 mnResizeHandles; 118 sal_Int32 mnCustomAngle; 119 sal_Int32 mnPercentageNeighbourWidth; 120 sal_Int32 mnPercentageNeighbourHeight; 121 sal_Int32 mnPercentageOwnWidth; 122 sal_Int32 mnPercentageOwnHeight; 123 sal_Int32 mnIncludeAngleScale; 124 sal_Int32 mnRadiusScale; 125 sal_Int32 mnWidthScale; 126 sal_Int32 mnHeightScale; 127 sal_Int32 mnWidthOverride; 128 sal_Int32 mnHeightOverride; 129 sal_Int32 mnLayoutStyleCount; 130 sal_Int32 mnLayoutStyleIndex; 131 132 bool mbOrgChartEnabled; 133 bool mbBulletEnabled; 134 bool mbCoherent3DOffset; 135 bool mbCustomHorizontalFlip; 136 bool mbCustomVerticalFlip; 137 bool mbCustomText; 138 bool mbIsPlaceholder; 139 }; 140 141 typedef std::vector< Point > Points; 142 143 } 144 145 class DiagramData : public DiagramDataInterface 146 { 147 public: 148 typedef std::map< OUString, dgm::Point* > PointNameMap; 149 typedef std::map< OUString, 150 std::vector<dgm::Point*> > PointsNameMap; 151 typedef std::map< OUString, const dgm::Connection* > ConnectionNameMap; 152 struct SourceIdAndDepth 153 { 154 OUString msSourceId; 155 sal_Int32 mnDepth = 0; 156 }; 157 /// Tracks connections: destination id -> {destination order, details} map. 158 typedef std::map< OUString, 159 std::map<sal_Int32, SourceIdAndDepth > > StringMap; 160 161 DiagramData(); ~DiagramData()162 virtual ~DiagramData() {} 163 void build(); getFillProperties()164 FillPropertiesPtr & getFillProperties() 165 { return mpFillProperties; } getConnections()166 dgm::Connections & getConnections() 167 { return maConnections; } getPoints()168 dgm::Points & getPoints() 169 { return maPoints; } getPresOfNameMap()170 StringMap & getPresOfNameMap() 171 { return maPresOfNameMap; } getPointNameMap()172 PointNameMap & getPointNameMap() 173 { return maPointNameMap; } getPointsPresNameMap()174 PointsNameMap & getPointsPresNameMap() 175 { return maPointsPresNameMap; } getExtDrawings()176 ::std::vector<OUString> &getExtDrawings() 177 { return maExtDrawings; } 178 const dgm::Point* getRootPoint() const; 179 void dump() const; 180 OUString getString() const override; 181 std::vector<std::pair<OUString, OUString>> getChildren(const OUString& rParentId) const override; 182 OUString addNode(const OUString& rText) override; 183 bool removeNode(const OUString& rNodeId) override; 184 185 private: 186 void getChildrenString(OUStringBuffer& rBuf, const dgm::Point* pPoint, sal_Int32 nLevel) const; 187 void addConnection(sal_Int32 nType, const OUString& sSourceId, const OUString& sDestId); 188 189 ::std::vector<OUString> maExtDrawings; 190 FillPropertiesPtr mpFillProperties; 191 dgm::Connections maConnections; 192 dgm::Points maPoints; 193 PointNameMap maPointNameMap; 194 PointsNameMap maPointsPresNameMap; 195 ConnectionNameMap maConnectionNameMap; 196 StringMap maPresOfNameMap; 197 }; 198 199 typedef std::shared_ptr< DiagramData > DiagramDataPtr; 200 201 } 202 203 #endif 204 205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 206