summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-05-05 14:11:45 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-05-05 14:20:48 +0200
commit315503314aaeed11d1e25d5a379d56fd3051dba0 (patch)
tree3efa4f86a208f96c9351cb6b53499dd1979a6604 /oox
parent7623bc31584b38da980016db25fb5dfc702beb10 (diff)
oox: don't try to set Writer-specific properties on non-TextFrames...
... during DOCX import of shapes with text, so that we don't crash when the currently always active setServiceName("com.sun.star.text.TextFrame") call is not present. Change-Id: I5b005583ddcee81b9683e3b34e8f0a2e5faa4f95
Diffstat (limited to 'oox')
-rw-r--r--oox/source/shape/WpsContext.cxx31
1 files changed, 18 insertions, 13 deletions
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 57237095c5e6..fa1730471727 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -73,20 +73,24 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
}
}
- // Handle inset attributes for Writer textframes.
- sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
- boost::optional<sal_Int32> oInsets[4];
- for (size_t i = 0; i < SAL_N_ELEMENTS(aInsets); ++i)
+ uno::Reference<lang::XServiceInfo> xServiceInfo(mxShape, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
+ if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
{
- OptValue<OUString> oValue = rAttribs.getString(aInsets[i]);
- if (oValue.has())
- oInsets[i] = oox::drawingml::GetCoordinate(oValue.get());
+ // Handle inset attributes for Writer textframes.
+ sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
+ boost::optional<sal_Int32> oInsets[4];
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aInsets); ++i)
+ {
+ OptValue<OUString> oValue = rAttribs.getString(aInsets[i]);
+ if (oValue.has())
+ oInsets[i] = oox::drawingml::GetCoordinate(oValue.get());
+ }
+ OUString aProps[] = { OUString("LeftBorderDistance"), OUString("TopBorderDistance"), OUString("RightBorderDistance"), OUString("BottomBorderDistance") };
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i)
+ if (oInsets[i])
+ xPropertySet->setPropertyValue(aProps[i], uno::makeAny(*oInsets[i]));
}
- OUString aProps[] = { OUString("LeftBorderDistance"), OUString("TopBorderDistance"), OUString("RightBorderDistance"), OUString("BottomBorderDistance") };
- uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
- for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i)
- if (oInsets[i])
- xPropertySet->setPropertyValue(aProps[i], uno::makeAny(*oInsets[i]));
// Handle text vertical adjustment inside a text frame
if (rAttribs.hasAttribute(XML_anchor))
@@ -100,11 +104,12 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
case XML_noAutofit:
case XML_spAutoFit:
{
+ uno::Reference<lang::XServiceInfo> xServiceInfo(mxShape, uno::UNO_QUERY);
// We can't use oox::drawingml::TextBodyPropertiesContext here, as this
// is a child context of bodyPr, so the shape is already sent: we need
// to alter the XShape directly.
uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
- if (xPropertySet.is())
+ if (xPropertySet.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
xPropertySet->setPropertyValue("FrameIsAutomaticHeight", uno::makeAny(getBaseToken(nElementToken) == XML_spAutoFit));
}
break;