From b996107585efb7bed88351d2cea2e56d8500c2fb Mon Sep 17 00:00:00 2001 From: jan iversen Date: Thu, 21 Jan 2016 19:35:26 +0100 Subject: cid#1326113, 1326410, 1326411 Removed reference to elements in a null pointer. Change-Id: Ife6fc68128284e291130a9a81bb7557ce03197ed Reviewed-on: https://gerrit.libreoffice.org/21690 Tested-by: Jenkins Reviewed-by: jan iversen --- wizards/com/sun/star/wizards/document/Control.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/document/Control.java b/wizards/com/sun/star/wizards/document/Control.java index 17d12f0a4b32..9ff4691d2760 100644 --- a/wizards/com/sun/star/wizards/document/Control.java +++ b/wizards/com/sun/star/wizards/document/Control.java @@ -75,7 +75,7 @@ public class Control extends Shape try { icontroltype = _icontroltype; - String sServiceName = oFormHandler.sModelServices[getControlType()]; + String sServiceName = oFormHandler.sModelServices[icontroltype]; Object oControlModel = oFormHandler.xMSFDoc.createInstance(sServiceName); xControlModel = UnoRuntime.queryInterface( XControlModel.class, oControlModel ); xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oControlModel ); @@ -185,15 +185,21 @@ public class Control extends Shape else { Size aPeerSize = getPeerSize(); + int aWidth; + if (aPeerSize == null) + aWidth = 0; + else + aWidth = aPeerSize.Width; + // We increase the preferred Width a bit so that the control does not become too small // when we change the border from "3D" to "Flat" if (getControlType() == FormHandler.SOCHECKBOX) { - return aPeerSize.Width * oFormHandler.getXPixelFactor(); + return aWidth * oFormHandler.getXPixelFactor(); } else { - return (aPeerSize.Width * oFormHandler.getXPixelFactor()) + 200; + return (aWidth * oFormHandler.getXPixelFactor()) + 200; } } } @@ -208,6 +214,11 @@ public class Control extends Shape { Size aPeerSize = getPeerSize(); int nHeight = aPeerSize.Height; + if (aPeerSize == null) + nHeight = 0; + else + nHeight = aPeerSize.Height; + // We increase the preferred Height a bit so that the control does not become too small // when we change the border from "3D" to "Flat" return ((nHeight + 1) * oFormHandler.getYPixelFactor()); -- cgit