summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-12-08 22:15:21 +0100
committerAndras Timar <andras.timar@collabora.com>2018-01-17 08:41:06 +0100
commit5023bece87a6d4bccf5fe8e72f21be70fac86b16 (patch)
treed451740f273d12234068d8b0a2ae4e955f289398
parenta611a418b7ea81405e1c146973d20a2971028e11 (diff)
tdf#114338 don't crash on watermark insert w/ existing header
Change-Id: I63abaf48c33d6660f1829b7d503de295e4a57f9c Reviewed-on: https://gerrit.libreoffice.org/46126 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/46156 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com> (cherry picked from commit cfa177e84de5b04be6ca9dadf62519fac5ed392f)
-rw-r--r--sw/source/core/edit/edfcol.cxx17
1 files changed, 13 insertions, 4 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index ce41b3e7a064..913fec92c2de 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -118,8 +118,10 @@ bool lcl_hasField(const uno::Reference<text::XText>& xText, const OUString& rSer
}
/// Search for a frame with WATERMARK_NAME in name of type rServiceName in xText. Returns found name in rShapeName.
-uno::Reference<drawing::XShape> lcl_getWatermark(const uno::Reference<text::XText>& xText, const OUString& rServiceName, OUString& rShapeName)
+uno::Reference<drawing::XShape> lcl_getWatermark(const uno::Reference<text::XText>& xText,
+ const OUString& rServiceName, OUString& rShapeName, bool& bSuccess)
{
+ bSuccess = false;
uno::Reference<container::XEnumerationAccess> xParagraphEnumerationAccess(xText, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParagraphs = xParagraphEnumerationAccess->createEnumeration();
while (xParagraphs->hasMoreElements())
@@ -128,6 +130,8 @@ uno::Reference<drawing::XShape> lcl_getWatermark(const uno::Reference<text::XTex
if (!xTextPortionEnumerationAccess.is())
continue;
+ bSuccess = true;
+
uno::Reference<container::XEnumeration> xTextPortions = xTextPortionEnumerationAccess->createEnumeration();
while (xTextPortions->hasMoreElements())
{
@@ -316,7 +320,8 @@ SfxWatermarkItem SwEditShell::GetWatermark()
OUString aShapeServiceName = "com.sun.star.drawing.CustomShape";
OUString sWatermark = "";
- uno::Reference<drawing::XShape> xWatermark = lcl_getWatermark(xHeaderText, aShapeServiceName, sWatermark);
+ bool bSuccess = false;
+ uno::Reference<drawing::XShape> xWatermark = lcl_getWatermark(xHeaderText, aShapeServiceName, sWatermark, bSuccess);
if (xWatermark.is())
{
@@ -350,10 +355,14 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark,
const uno::Reference<beans::XPropertySet>& xPageStyle,
const uno::Reference<text::XText>& xHeaderText)
{
+ if (!xHeaderText.is())
+ return;
+
uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, uno::UNO_QUERY);
OUString aShapeServiceName = "com.sun.star.drawing.CustomShape";
OUString sWatermark = WATERMARK_NAME;
- uno::Reference<drawing::XShape> xWatermark = lcl_getWatermark(xHeaderText, aShapeServiceName, sWatermark);
+ bool bSuccess = false;
+ uno::Reference<drawing::XShape> xWatermark = lcl_getWatermark(xHeaderText, aShapeServiceName, sWatermark, bSuccess);
bool bDeleteWatermark = rWatermark.GetText().isEmpty();
if (xWatermark.is())
@@ -387,7 +396,7 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark,
}
}
- if (!xWatermark.is() && !bDeleteWatermark)
+ if (bSuccess && !xWatermark.is() && !bDeleteWatermark)
{
OUString sFont = rWatermark.GetFont();
sal_Int16 nAngle = rWatermark.GetAngle();