summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2020-11-14 19:37:31 +0800
committerXisco Fauli <xiscofauli@libreoffice.org>2020-11-23 10:26:13 +0100
commit9db952d2e793577f44df7a4a5b98c19ea87c8db0 (patch)
treed13b8256ace6da5c6c930401c0890c5a7662d73c
parent986f39e24901b8056ba365f81f76cb5139f8573f (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> (cherry picked from commit 8c14adfa76956e76bac98330ce67f080c90af184) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106237 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rwxr-xr-xsw/qa/extras/rtfexport/data/tdf138210.rtfbin0 -> 1281 bytes
-rw-r--r--sw/qa/extras/rtfexport/rtfexport5.cxx9
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx74
3 files changed, 44 insertions, 39 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf138210.rtf b/sw/qa/extras/rtfexport/data/tdf138210.rtf
new file mode 100755
index 000000000000..d91a87d901e6
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf138210.rtf
Binary files differ
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index e005ce674b92..25cd2ee423bb 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
@@ -1253,6 +1254,14 @@ DECLARE_RTFEXPORT_TEST(testTdf129513, "tdf129513.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("In table"), xCell->getString());
}
+DECLARE_RTFEXPORT_TEST(testTdf138210, "tdf138210.rtf")
+{
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 1ecde8a8a684..ef2c92afac4d 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -917,46 +917,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())
@@ -1032,8 +1029,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(