diff options
author | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-08-18 16:27:54 +0200 |
---|---|---|
committer | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-08-18 18:09:28 +0200 |
commit | 8639ef9b70b8242651ef4d1a3b23b8c8eeeda52b (patch) | |
tree | 30b3a4d1942561e513f41330597941fd29816a57 /oox | |
parent | 935a2fa0f7ee5dbe6402e0d202a581c05a7b01a2 (diff) |
SmartArt: implement DiagramData::getString()
Allows to get data representation of diagram as text.
It will be useful as a starting point for displaying data on diagram dialog.
Change-Id: I9765d7de64a68224a6d36b7c3bc4862ce6610bdf
Reviewed-on: https://gerrit.libreoffice.org/77669
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagram.cxx | 38 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagram.hxx | 4 |
2 files changed, 41 insertions, 1 deletions
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 2c0c47899ffa..fb1fc916c349 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -100,6 +100,44 @@ void DiagramData::dump() const rPoint.dump(); } +void DiagramData::getChildrenString(OUStringBuffer& rBuf, const dgm::Point* pPoint, sal_Int32 nLevel) const +{ + if (!pPoint) + return; + + if (nLevel > 0) + { + for (sal_Int32 i = 0; i < nLevel-1; i++) + rBuf.append('\t'); + rBuf.append('+'); + rBuf.append(' '); + rBuf.append(pPoint->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText()); + rBuf.append('\n'); + } + + std::vector<const dgm::Point*> aChildren; + for (const auto& rCxn : maConnections) + if (rCxn.mnType == XML_parOf && rCxn.msSourceId == pPoint->msModelId) + { + if (rCxn.mnSourceOrder >= static_cast<sal_Int32>(aChildren.size())) + aChildren.resize(rCxn.mnSourceOrder + 1); + const auto pChild = maPointNameMap.find(rCxn.msDestId); + if (pChild != maPointNameMap.end()) + aChildren[rCxn.mnSourceOrder] = pChild->second; + } + + for (auto pChild : aChildren) + getChildrenString(rBuf, pChild, nLevel + 1); +} + +OUString DiagramData::getString() const +{ + OUStringBuffer aBuf; + const dgm::Point* pPoint = getRootPoint(); + getChildrenString(aBuf, pPoint, 0); + return aBuf.makeStringAndClear(); +} + #ifdef DEBUG_OOX_DIAGRAM OString normalizeDotName( const OUString& rStr ) { diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx index 656caacadb3a..62609b39fab1 100644 --- a/oox/source/drawingml/diagram/diagram.hxx +++ b/oox/source/drawingml/diagram/diagram.hxx @@ -192,9 +192,11 @@ public: { return maExtDrawings; } const dgm::Point* getRootPoint() const; void dump() const; - OUString getString() const override { return OUString(); } + OUString getString() const override; private: + void getChildrenString(OUStringBuffer& rBuf, const dgm::Point* pPoint, sal_Int32 nLevel) const; + ::std::vector<OUString> maExtDrawings; FillPropertiesPtr mpFillProperties; dgm::Connections maConnections; |