LibreOffice Module svx (master) 1
datamodel.hxx
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#ifndef INCLUDED_SVX_DIAGRAM_DATAMODEL_HXX
21#define INCLUDED_SVX_DIAGRAM_DATAMODEL_HXX
22
23#include <vector>
24#include <optional>
25#include <map>
26
27#include <svx/svxdllapi.h>
28#include <rtl/ustring.hxx>
29#include <rtl/ustrbuf.hxx>
30
31#include <com/sun/star/xml/dom/XDocument.hpp>
32#include <com/sun/star/drawing/XShape.hpp>
33
34namespace svx::diagram {
35
38 XML_type = 395,
39 XML_asst = 680,
40 XML_doc = 1924,
41 XML_node = 3596,
42 XML_norm = 3609,
43 XML_parOf = 3878,
45 XML_pres = 4085,
46 XML_presOf = 4090,
48 XML_rel = 4298,
50};
51
55{
56 Connection();
57
59 OUString msModelId;
60 OUString msSourceId;
61 OUString msDestId;
62 OUString msParTransId;
63 OUString msPresId;
64 OUString msSibTransId;
65 sal_Int32 mnSourceOrder;
66 sal_Int32 mnDestOrder;
67
68};
69
70typedef std::vector< Connection > Connections;
71
78{
79 // text from 1st paragraph (1st run)
80 OUString msText;
81
82 // attributes from TextBody::getTextProperties()
83 std::vector< std::pair< OUString, css::uno::Any >> maTextProps;
84};
85
86typedef std::shared_ptr< TextBody > TextBodyPtr;
87
91{
92 // attributes (LineStyle/FillStyle/...)
93 std::vector< std::pair< OUString, css::uno::Any >> maProperties;
94};
95
96typedef std::shared_ptr< PointStyle > PointStylePtr;
97
101{
102 Point();
103
104 // The minimal text data from the imported Diagram
105 // in source format
107
108 // The property sequence of pairs<OUString, css::uno::Any>,
109 // interpreted & assigned by the ::addShape(s) creators in the
110 // import filter that created a XShape associated/based on this entry
112
113 OUString msCnxId;
114 OUString msModelId;
125
127 sal_Int32 mnMaxChildren;
129 sal_Int32 mnDirection;
130 std::optional<sal_Int32> moHierarchyBranch;
132 sal_Int32 mnCustomAngle;
138 sal_Int32 mnRadiusScale;
139 sal_Int32 mnWidthScale;
140 sal_Int32 mnHeightScale;
145
153};
154
155typedef std::vector< Point > Points;
156
160{
163
164public:
165 DiagramDataState(Connections aConnections, Points aPoints);
166
167 Connections& getConnections() { return maConnections; }
168 Points& getPoints() { return maPoints; }
169};
170
171typedef std::shared_ptr< DiagramDataState > DiagramDataStatePtr;
172
176{
177public:
178 typedef std::map< OUString, Point* > PointNameMap;
179 typedef std::map< OUString, std::vector< Point* > > PointsNameMap;
180 typedef std::map< OUString, const Connection* > ConnectionNameMap;
181
183 {
184 OUString msSourceId;
185 sal_Int32 mnDepth = 0;
186 };
187
189 typedef std::map< OUString, std::map<sal_Int32, SourceIdAndDepth > > StringMap;
190
191protected:
192 // Make constructor protected to signal that this anyway pure virtual class
193 // shall not be incarnated - target to use is oox::drawingml::DiagramData
194 DiagramData();
195
196public:
197 virtual ~DiagramData();
198
199 // creates temporary processing data from model data
200 virtual void buildDiagramDataModel(bool bClearOoxShapes);
201
202 // dump to readable format
203 virtual void dump() const = 0;
204
205 // read accesses
206 Connections& getConnections() { return maConnections; }
207 Points& getPoints() { return maPoints; }
208 StringMap& getPresOfNameMap() { return maPresOfNameMap; }
209 PointNameMap& getPointNameMap() { return maPointNameMap; }
210 PointsNameMap& getPointsPresNameMap() { return maPointsPresNameMap; }
211 ::std::vector<OUString>& getExtDrawings() { return maExtDrawings; }
212 const Point* getRootPoint() const;
213 OUString getString() const;
214 std::vector<std::pair<OUString, OUString>> getChildren(const OUString& rParentId) const;
215
216 const css::uno::Reference< css::xml::dom::XDocument >& getThemeDocument() const { return mxThemeDocument; }
217 void setThemeDocument( const css::uno::Reference< css::xml::dom::XDocument >& xRef ) { mxThemeDocument = xRef; }
218
219 const OUString& getBackgroundShapeModelID() const { return msBackgroundShapeModelID; }
220 void setBackgroundShapeModelID( const OUString& rModelID ) { msBackgroundShapeModelID = rModelID; }
221
222 // model modifiers
223 OUString addNode(const OUString& rText);
224 bool removeNode(const OUString& rNodeId);
225
226 // Undo/Redo helpers to extract/restore Diagram-defining data
227 DiagramDataStatePtr extractDiagramDataState() const;
228 void applyDiagramDataState(const DiagramDataStatePtr& rState);
229
230protected:
231 // helpers
232 void getChildrenString(OUStringBuffer& rBuf, const Point* pPoint, sal_Int32 nLevel) const;
233 void addConnection(TypeConstant nType, const OUString& sSourceId, const OUString& sDestId);
234
235 // evtl. existing alternative imported visualization identifier
236 ::std::vector<OUString> maExtDrawings;
237
238 // The model definition, the parts available in svx.
239 // See evtl. parts in oox::drawingml::DiagramData that may need t obe accessed
240 // - logic connections/associations
242
243 // - data point entries
245
246 // - style for the BackgroundShape (if used)
247 // this is the property sequence of pairs<OUString, css::uno::Any>,
248 // as interpreted & assigned by the ::addShape(s) creators in the
249 // import filter
251
252 // - Theme definition as css::xml::dom::XDocument
253 // Note: I decided to use dom::XDocument which is already in use, instead of a
254 // temp file what is also possible (implemented that for POC) but would
255 // need to be created in PresentationFragmentHandler::importSlide. If
256 // this needs to be written to a File, please refer to
257 // fileDocxExport::WriteTheme(), look for "OOXTheme"
258 css::uno::Reference< css::xml::dom::XDocument > mxThemeDocument;
259
260 // temporary processing data, partially deleted when using build()
266};
267
268typedef std::shared_ptr< DiagramData > DiagramDataPtr;
269
270}
271
272#endif
273
274/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
temporaryPointVector maPoints
sal_Int32 mnDepth
Snippet of Diagram ModelData for Diagram-defining data undo/redo.
Definition: datamodel.hxx:160
Connections & getConnections()
Definition: datamodel.hxx:167
The collected Diagram ModelData.
Definition: datamodel.hxx:176
PointStylePtr maBackgroundShapeStyle
Definition: datamodel.hxx:250
Connections & getConnections()
Definition: datamodel.hxx:206
std::map< OUString, std::map< sal_Int32, SourceIdAndDepth > > StringMap
Tracks connections: destination id -> {destination order, details} map.
Definition: datamodel.hxx:189
::std::vector< OUString > maExtDrawings
Definition: datamodel.hxx:236
::std::vector< OUString > & getExtDrawings()
Definition: datamodel.hxx:211
void setBackgroundShapeModelID(const OUString &rModelID)
Definition: datamodel.hxx:220
css::uno::Reference< css::xml::dom::XDocument > mxThemeDocument
Definition: datamodel.hxx:258
std::map< OUString, const Connection * > ConnectionNameMap
Definition: datamodel.hxx:180
virtual void dump() const =0
std::map< OUString, Point * > PointNameMap
Definition: datamodel.hxx:178
void setThemeDocument(const css::uno::Reference< css::xml::dom::XDocument > &xRef)
Definition: datamodel.hxx:217
StringMap & getPresOfNameMap()
Definition: datamodel.hxx:208
PointNameMap maPointNameMap
Definition: datamodel.hxx:261
PointsNameMap maPointsPresNameMap
Definition: datamodel.hxx:262
PointNameMap & getPointNameMap()
Definition: datamodel.hxx:209
const css::uno::Reference< css::xml::dom::XDocument > & getThemeDocument() const
Definition: datamodel.hxx:216
ConnectionNameMap maConnectionNameMap
Definition: datamodel.hxx:263
const OUString & getBackgroundShapeModelID() const
Definition: datamodel.hxx:219
std::map< OUString, std::vector< Point * > > PointsNameMap
Definition: datamodel.hxx:179
PointsNameMap & getPointsPresNameMap()
Definition: datamodel.hxx:210
OUString getString(const Any &_rAny)
std::shared_ptr< PointStyle > PointStylePtr
Definition: datamodel.hxx:96
std::shared_ptr< DiagramDataState > DiagramDataStatePtr
Definition: datamodel.hxx:171
std::shared_ptr< TextBody > TextBodyPtr
Definition: datamodel.hxx:86
std::vector< Connection > Connections
Definition: datamodel.hxx:70
std::shared_ptr< DiagramData > DiagramDataPtr
Definition: datamodel.hxx:268
std::vector< Point > Points
Definition: datamodel.hxx:155
TypeConstant mnXMLType
Definition: datamodel.hxx:58
Styles for a Point (FillStyle/LineStyle/...)
Definition: datamodel.hxx:91
std::vector< std::pair< OUString, css::uno::Any > > maProperties
Definition: datamodel.hxx:93
OUString msPlaceholderText
Definition: datamodel.hxx:119
sal_Int32 mnWidthOverride
Definition: datamodel.hxx:141
sal_Int32 mnPercentageNeighbourHeight
Definition: datamodel.hxx:134
sal_Int32 mnDirection
Definition: datamodel.hxx:129
std::optional< sal_Int32 > moHierarchyBranch
Definition: datamodel.hxx:130
sal_Int32 mnPercentageNeighbourWidth
Definition: datamodel.hxx:133
sal_Int32 mnLayoutStyleIndex
Definition: datamodel.hxx:144
sal_Int32 mnLayoutStyleCount
Definition: datamodel.hxx:143
sal_Int32 mnHeightScale
Definition: datamodel.hxx:140
OUString msPresentationLayoutStyleLabel
Definition: datamodel.hxx:122
OUString msLayoutTypeId
Definition: datamodel.hxx:118
OUString msPresentationAssociationId
Definition: datamodel.hxx:120
sal_Int32 mnCustomAngle
Definition: datamodel.hxx:132
PointStylePtr msPointStylePtr
Definition: datamodel.hxx:111
sal_Int32 mnMaxChildren
Definition: datamodel.hxx:127
sal_Int32 mnResizeHandles
Definition: datamodel.hxx:131
OUString msPresentationLayoutName
Definition: datamodel.hxx:121
OUString msLayoutCategoryId
Definition: datamodel.hxx:117
sal_Int32 mnRadiusScale
Definition: datamodel.hxx:138
sal_Int32 mnPercentageOwnHeight
Definition: datamodel.hxx:136
sal_Int32 mnWidthScale
Definition: datamodel.hxx:139
OUString msColorTransformCategoryId
Definition: datamodel.hxx:115
sal_Int32 mnIncludeAngleScale
Definition: datamodel.hxx:137
TypeConstant mnXMLType
Definition: datamodel.hxx:126
OUString msColorTransformTypeId
Definition: datamodel.hxx:116
OUString msQuickStyleCategoryId
Definition: datamodel.hxx:123
TextBodyPtr msTextBody
Definition: datamodel.hxx:106
sal_Int32 mnHeightOverride
Definition: datamodel.hxx:142
OUString msQuickStyleTypeId
Definition: datamodel.hxx:124
sal_Int32 mnPreferredChildren
Definition: datamodel.hxx:128
sal_Int32 mnPercentageOwnWidth
Definition: datamodel.hxx:135
Text and properties for a point For proof of concept to make TextData available in svx level this is ...
Definition: datamodel.hxx:78
std::vector< std::pair< OUString, css::uno::Any > > maTextProps
Definition: datamodel.hxx:83
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35