summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2020-11-14 19:37:31 +0800
committerMark Hung <marklh9@gmail.com>2020-11-21 02:32:49 +0100
commit8c14adfa76956e76bac98330ce67f080c90af184 (patch)
tree2211e147055dd911dfc89492a59e1e689c977534 /writerfilter
parent13d41ac495e5c081340756e016d2da44f2875b99 (diff)
tdf#138210 check if CustomShapeGeometry exist first.
CustomShapeGeometry does not exist for a text frame. Getting the property throws an Exception and cause a general IO error. Change-Id: I0e31780292d45211bfd1250d0d359c72def50583 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105834 Tested-by: Jenkins Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx74
1 files changed, 35 insertions, 39 deletions
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index b98723e5aee3..01af8259ff91 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -918,46 +918,43 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
}
// Creating CustomShapeGeometry property
- std::vector<beans::PropertyValue> aGeometry;
- if (aViewBox.X || aViewBox.Y || aViewBox.Width || aViewBox.Height)
+ if (bCustom && xPropertySet.is())
{
- aViewBox.Width -= aViewBox.X;
- aViewBox.Height -= aViewBox.Y;
- aPropertyValue.Name = "ViewBox";
- aPropertyValue.Value <<= aViewBox;
- aGeometry.push_back(aPropertyValue);
- }
- if (!aPath.empty())
- {
- aPropertyValue.Name = "Path";
- aPropertyValue.Value <<= comphelper::containerToSequence(aPath);
- aGeometry.push_back(aPropertyValue);
- }
- if (!aGeometry.empty() && xPropertySet.is() && !m_bTextFrame)
- xPropertySet->setPropertyValue("CustomShapeGeometry",
- uno::Any(comphelper::containerToSequence(aGeometry)));
+ bool bChanged = false;
+ comphelper::SequenceAsHashMap aCustomShapeGeometry(
+ xPropertySet->getPropertyValue("CustomShapeGeometry"));
- if (!aShapeText.isEmpty())
- {
- auto aGeomPropSeq = xPropertySet->getPropertyValue("CustomShapeGeometry")
- .get<uno::Sequence<beans::PropertyValue>>();
- auto aGeomPropVec
- = comphelper::sequenceToContainer<std::vector<beans::PropertyValue>>(aGeomPropSeq);
- uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({
- { "TextPath", uno::makeAny(true) },
- }));
- auto it = std::find_if(
- aGeomPropVec.begin(), aGeomPropVec.end(),
- [](const beans::PropertyValue& rValue) { return rValue.Name == "TextPath"; });
- if (it == aGeomPropVec.end())
- aGeomPropVec.push_back(comphelper::makePropertyValue("TextPath", aPropertyValues));
- else
- it->Value <<= aPropertyValues;
+ if (aViewBox.X || aViewBox.Y || aViewBox.Width || aViewBox.Height)
+ {
+ aViewBox.Width -= aViewBox.X;
+ aViewBox.Height -= aViewBox.Y;
+ aCustomShapeGeometry["ViewBox"] <<= aViewBox;
+ bChanged = true;
+ }
+
+ if (!aPath.empty())
+ {
+ aCustomShapeGeometry["Path"] <<= comphelper::containerToSequence(aPath);
+ bChanged = true;
+ }
+
+ if (!aShapeText.isEmpty())
+ {
+ uno::Sequence<beans::PropertyValue> aSequence(comphelper::InitPropertySequence({
+ { "TextPath", uno::makeAny(true) },
+ }));
+ aCustomShapeGeometry["TextPath"] <<= aSequence;
+ xPropertySet->setPropertyValue("TextAutoGrowHeight", uno::makeAny(false));
+ xPropertySet->setPropertyValue("TextAutoGrowWidth", uno::makeAny(false));
+ bChanged = true;
+ }
- xPropertySet->setPropertyValue("CustomShapeGeometry",
- uno::makeAny(comphelper::containerToSequence(aGeomPropVec)));
- xPropertySet->setPropertyValue("TextAutoGrowHeight", uno::makeAny(false));
- xPropertySet->setPropertyValue("TextAutoGrowWidth", uno::makeAny(false));
+ if (bChanged)
+ {
+ xPropertySet->setPropertyValue(
+ "CustomShapeGeometry",
+ uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));
+ }
}
if (!boost::logic::indeterminate(obRelFlipV) && xPropertySet.is())
@@ -1033,8 +1030,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
if (obFlipH == true || obFlipV == true)
{
- // Line shapes have no CustomShapeGeometry.
- if (nType != ESCHER_ShpInst_Line)
+ if (bCustom)
{
// This has to be set after position and size is set, otherwise flip will affect the position.
comphelper::SequenceAsHashMap aCustomShapeGeometry(