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