20#include <unordered_set>
43, mnPreferredChildren(-1)
47, mnPercentageNeighbourWidth(-1)
48, mnPercentageNeighbourHeight(-1)
49, mnPercentageOwnWidth(-1)
50, mnPercentageOwnHeight(-1)
51, mnIncludeAngleScale(-1)
57, mnLayoutStyleCount(-1)
58, mnLayoutStyleIndex(-1)
59, mbOrgChartEnabled(false)
60, mbBulletEnabled(false)
61, mbCoherent3DOffset(false)
62, mbCustomHorizontalFlip(false)
63, mbCustomVerticalFlip(false)
65, mbIsPlaceholder(false)
79 for (
const auto & aCurrPoint :
maPoints)
83 SAL_WARN(
"svx.diagram",
"No root point");
92 return aBuf.makeStringAndClear();
101 SAL_WARN(
"svx.diagram",
"Node has children - can't be removed");
110 std::unordered_set<OUString> aIdsToRemove;
111 aIdsToRemove.insert(rNodeId);
118 if (aIdsToRemove.count(rPoint.msPresentationAssociationId))
119 aIdsToRemove.insert(rPoint.msModelId);
123 if (aIdsToRemove.count(aCxn.msSourceId) || aIdsToRemove.count(aCxn.msDestId))
124 if (!aCxn.msPresId.isEmpty())
125 aIdsToRemove.insert(aCxn.msPresId);
130 return aIdsToRemove.count(rCxn.msSourceId) || aIdsToRemove.count(rCxn.msDestId);
136 [aIdsToRemove](
const Point& rPoint) {
137 return aIdsToRemove.count(rPoint.msModelId);
146: maConnections(
std::move(aConnections))
173 OUStringBuffer& rBuf,
175 sal_Int32 nLevel)
const
182 for (sal_Int32
i = 0;
i < nLevel-1;
i++)
190 std::vector< const svx::diagram::Point* > aChildren;
194 if (rCxn.mnSourceOrder >=
static_cast<sal_Int32
>(aChildren.size()))
195 aChildren.resize(rCxn.mnSourceOrder + 1);
198 aChildren[rCxn.mnSourceOrder] = pChild->second;
201 for (
auto pChild : aChildren)
208 std::vector<std::pair<OUString, OUString>> aChildren;
212 if (rCxn.mnSourceOrder >=
static_cast<sal_Int32
>(aChildren.size()))
213 aChildren.resize(rCxn.mnSourceOrder + 1);
217 aChildren[rCxn.mnSourceOrder] = std::make_pair(
218 pChild->second->msModelId,
219 pChild->second->msTextBody->msText);
224 aChildren.erase(std::remove_if(aChildren.begin(), aChildren.end(),
225 [](
const std::pair<OUString, OUString>& aItem) { return aItem.first.isEmpty(); }),
237 sPresRoot = aCxn.msDestId;
239 if (sPresRoot.isEmpty())
249 OUString sDataSibling;
252 sDataSibling = aCxn.msDestId;
254 OUString sPresSibling;
257 sPresSibling = aCxn.msDestId;
264 if (!sPresSibling.isEmpty())
287 sal_Int32 nMaxOrd = -1;
289 if (aCxn.mnXMLType ==
nType && aCxn.msSourceId == sSourceId)
290 nMaxOrd = std::max(nMaxOrd, aCxn.mnSourceOrder);
300#ifdef DEBUG_OOX_DIAGRAM
301OString normalizeDotName(
const OUString& rStr )
306 const sal_Int32 nLen(rStr.getLength());
307 sal_Int32 nCurrIndex(0);
308 while( nCurrIndex < nLen )
310 const sal_Int32 aChar=rStr.iterateCodePoints(&nCurrIndex);
311 if( aChar !=
'-' && aChar !=
'{' && aChar !=
'}' )
316 RTL_TEXTENCODING_UTF8);
320static sal_Int32
calcDepth( std::u16string_view rNodeName,
324 for (
auto const& elem : rCnx)
326 if( !elem.msParTransId.isEmpty() &&
327 !elem.msSibTransId.isEmpty() &&
328 !elem.msSourceId.isEmpty() &&
329 !elem.msDestId.isEmpty() &&
331 rNodeName == elem.msDestId )
333 return calcDepth(elem.msSourceId, rCnx) + 1;
349#ifdef DEBUG_OOX_DIAGRAM
350 std::ofstream output(
"tree.dot");
352 output <<
"digraph datatree {" << std::endl;
355 for (
auto &
point : rPoints)
357#ifdef DEBUG_OOX_DIAGRAM
359 << normalizeDotName(
point.msModelId).getStr()
362 if( !
point.msPresentationLayoutName.isEmpty() )
365 point.msPresentationLayoutName,
366 RTL_TEXTENCODING_UTF8).getStr() <<
"\", ";
371 RTL_TEXTENCODING_UTF8).getStr() <<
"\", ";
373 switch(
point.mnXMLType )
384 output <<
"];" << std::endl;
388 if(!
point.msTextBody->msText.isEmpty())
390#ifdef DEBUG_OOX_DIAGRAM
391 static sal_Int32
nCount=0;
397 point.msTextBody->msText,
398 RTL_TEXTENCODING_UTF8).getStr()
399 <<
"\"" <<
"];" << std::endl;
401 << normalizeDotName(
point.msModelId).getStr()
409 std::make_pair(
point.msModelId,&
point)).second;
411 SAL_WARN_IF(!bInserted1,
"oox.drawingml",
"DiagramData::build(): non-unique point model id");
413 if( !
point.msPresentationLayoutName.isEmpty() )
415 DiagramData::PointsNameMap::value_type::second_type& rVec=
417 rVec.push_back(&
point);
422 for (
auto const& connection : rConnections)
424#ifdef DEBUG_OOX_DIAGRAM
425 if( !connection.msParTransId.isEmpty() ||
426 !connection.msSibTransId.isEmpty() )
428 if( !connection.msSourceId.isEmpty() ||
429 !connection.msDestId.isEmpty() )
432 << normalizeDotName(connection.msSourceId).getStr()
434 << normalizeDotName(connection.msParTransId).getStr()
436 << normalizeDotName(connection.msSibTransId).getStr()
438 << normalizeDotName(connection.msDestId).getStr()
443 RTL_TEXTENCODING_UTF8 ).getStr()
444 <<
"\"];" << std::endl;
449 << normalizeDotName(connection.msParTransId).getStr()
451 << normalizeDotName(connection.msSibTransId).getStr()
456 RTL_TEXTENCODING_UTF8 ).getStr()
457 <<
"\"];" << std::endl;
460 else if( !connection.msSourceId.isEmpty() ||
461 !connection.msDestId.isEmpty() )
463 << normalizeDotName(connection.msSourceId).getStr()
465 << normalizeDotName(connection.msDestId).getStr()
468 RTL_TEXTENCODING_UTF8 ).getStr()
474 std::make_pair(connection.msModelId,&connection)).second;
476 SAL_WARN_IF(!bInserted1,
"oox.drawingml",
"DiagramData::build(): non-unique connection model id");
480 DiagramData::StringMap::value_type::second_type& rVec =
getPresOfNameMap()[connection.msDestId];
481 rVec[connection.mnDestOrder] = { connection.msSourceId, sal_Int32(0) };
487 for (
auto & elemPresOf : rStringMap)
489 for (
auto & elem : elemPresOf.second)
492 elem.second.mnDepth = nDepth != 0 ? nDepth : -1;
495#ifdef DEBUG_OOX_DIAGRAM
496 output <<
"}" << std::endl;
temporaryPointVector maPoints
DiagramDataState(Connections aConnections, Points aPoints)
Connections & getConnections()
void addConnection(TypeConstant nType, const OUString &sSourceId, const OUString &sDestId)
std::map< OUString, std::map< sal_Int32, SourceIdAndDepth > > StringMap
Tracks connections: destination id -> {destination order, details} map.
OUString getString() const
virtual void buildDiagramDataModel(bool bClearOoxShapes)
OUString msBackgroundShapeModelID
bool removeNode(const OUString &rNodeId)
StringMap maPresOfNameMap
OUString addNode(const OUString &rText)
StringMap & getPresOfNameMap()
const Point * getRootPoint() const
PointNameMap maPointNameMap
PointsNameMap maPointsPresNameMap
void getChildrenString(OUStringBuffer &rBuf, const Point *pPoint, sal_Int32 nLevel) const
std::vector< std::pair< OUString, OUString > > getChildren(const OUString &rParentId) const
PointNameMap & getPointNameMap()
void applyDiagramDataState(const DiagramDataStatePtr &rState)
ConnectionNameMap maConnectionNameMap
DiagramDataStatePtr extractDiagramDataState() const
Connections maConnections
PointsNameMap & getPointsPresNameMap()
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
OString generateGUIDString()
std::shared_ptr< T > make_shared(Args &&... args)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
static sal_Int32 calcDepth(std::u16string_view rNodeName, const svx::diagram::Connections &rCnx)
std::shared_ptr< DiagramDataState > DiagramDataStatePtr
std::vector< Connection > Connections
std::vector< Point > Points
Styles for a Point (FillStyle/LineStyle/...)
sal_Int32 mnLayoutStyleIndex
sal_Int32 mnLayoutStyleCount
OUString msPresentationLayoutStyleLabel
OUString msPresentationAssociationId
OUString msPresentationLayoutName
Text and properties for a point For proof of concept to make TextData available in svx level this is ...