SmartArt edit UI: fix crash on empty node text
Change-Id: Idacbbb50cbdd8ae4c78f3159bc362c7ee2137149
Reviewed-on: https://gerrit.libreoffice.org/79848
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com>
diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index 835f1c3..38996ab 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -62,6 +62,7 @@ public:
const TextCharacterProperties& rTextStyleProperties,
const TextListStylePtr& pMasterTextListStyle ) const;
bool isEmpty() const;
OUString toString() const;
void ApplyStyleEmpty(
const ::oox::core::XmlFilterBase& rFilterBase,
diff --git a/oox/source/drawingml/diagram/datamodel.cxx b/oox/source/drawingml/diagram/datamodel.cxx
index bfbd675..fcad85b 100644
--- a/oox/source/drawingml/diagram/datamodel.cxx
+++ b/oox/source/drawingml/diagram/datamodel.cxx
@@ -96,7 +96,7 @@ void DiagramData::getChildrenString(OUStringBuffer& rBuf, const dgm::Point* pPoi
rBuf.append('\t');
rBuf.append('+');
rBuf.append(' ');
rBuf.append(pPoint->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText());
rBuf.append(pPoint->mpShape->getTextBody()->toString());
rBuf.append('\n');
}
@@ -136,7 +136,7 @@ std::vector<std::pair<OUString, OUString>> DiagramData::getChildren(const OUStri
if (pChild != maPointNameMap.end())
aChildren[rCxn.mnSourceOrder] = std::make_pair(
pChild->second->msModelId,
pChild->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText());
pChild->second->mpShape->getTextBody()->toString());
}
// HACK: empty items shouldn't appear there
@@ -361,8 +361,7 @@ void DiagramData::build()
// does currpoint have any text set?
if( point.mpShape &&
point.mpShape->getTextBody() &&
!point.mpShape->getTextBody()->getParagraphs().empty() &&
!point.mpShape->getTextBody()->getParagraphs().front()->getRuns().empty() )
!point.mpShape->getTextBody()->isEmpty() )
{
#ifdef DEBUG_OOX_DIAGRAM
static sal_Int32 nCount=0;
@@ -371,7 +370,7 @@ void DiagramData::build()
<< " ["
<< "label=\""
<< OUStringToOString(
point.mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText(),
point.mpShape->getTextBody()->toString(),
RTL_TEXTENCODING_UTF8).getStr()
<< "\"" << "];" << std::endl;
output << "\t"
diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx
index 55989a4..80ebb4d 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -96,6 +96,14 @@ bool TextBody::isEmpty() const
return aRuns[0]->getText().getLength() <= 0;
}
OUString TextBody::toString() const
{
if (!isEmpty())
return maParagraphs.front()->getRuns().front()->getText();
else
return OUString();
}
void TextBody::ApplyStyleEmpty(
const ::oox::core::XmlFilterBase& rFilterBase,
const Reference < XText > & xText,