summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2014-03-07 17:06:11 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2014-03-07 20:33:55 -0600
commit5aed432830a2af9e74d35198515b5ab5beff253f (patch)
treee579000987c976ea99055e4b2390ad9c1f5d600d
parent7b4d53699cf93188aa768d92e94409f245995b26 (diff)
coverity#704558 Unchecked dynamic cast
Change-Id: I45ce419c65e0fac28879747787ccf1ebc25e7698
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx80
1 files changed, 42 insertions, 38 deletions
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 799a151ad595..60c759ca33d4 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -3172,52 +3172,56 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co
pNewControl = pControl;
OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl);
- uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY);
- xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY);
- uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
- uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
-
- const OUString sProps[] = { OUString(PROPERTY_NAME)
- ,OUString(PROPERTY_FONTDESCRIPTOR)
- ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
- ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
- ,OUString(PROPERTY_ORIENTATION)
- ,OUString(PROPERTY_BORDER)
- ,OUString(PROPERTY_FORMATSSUPPLIER)
- ,OUString(PROPERTY_BACKGROUNDCOLOR)
- };
- for(size_t i = 0; i < sizeof (sProps) / sizeof (sProps[0]); ++i)
+ assert(pObj);
+ if(pObj)
{
- if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) )
- xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i]));
- }
+ uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY);
+ xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
+ uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
+
+ const OUString sProps[] = { OUString(PROPERTY_NAME)
+ ,OUString(PROPERTY_FONTDESCRIPTOR)
+ ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
+ ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
+ ,OUString(PROPERTY_ORIENTATION)
+ ,OUString(PROPERTY_BORDER)
+ ,OUString(PROPERTY_FORMATSSUPPLIER)
+ ,OUString(PROPERTY_BACKGROUNDCOLOR)
+ };
+ for(size_t i = 0; i < sizeof (sProps) / sizeof (sProps[0]); ++i)
+ {
+ if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) )
+ xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i]));
+ }
- if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
- xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
+ if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
+ xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
- if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && !_sFunction.isEmpty() )
- {
- ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction );
- xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) );
- }
+ if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && !_sFunction.isEmpty() )
+ {
+ ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction );
+ xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) );
+ }
- sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0));
- if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
- xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) );
+ sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0));
+ if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
+ xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) );
- OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,OUString());
- if ( !sUrl.isEmpty() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) )
- xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) );
+ OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,OUString());
+ if ( !sUrl.isEmpty() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) )
+ xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) );
- pObj->CreateMediator(sal_True);
+ pObj->CreateMediator(sal_True);
- if ( _nObjectId == OBJ_DLG_FIXEDTEXT ) // special case for fixed text
- xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj)));
- else if ( _nObjectId == OBJ_DLG_VFIXEDLINE )
- {
- awt::Size aOlSize = xShapeProp->getSize();
- xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width
+ if ( _nObjectId == OBJ_DLG_FIXEDTEXT ) // special case for fixed text
+ xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj)));
+ else if ( _nObjectId == OBJ_DLG_VFIXEDLINE )
+ {
+ awt::Size aOlSize = xShapeProp->getSize();
+ xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width
+ }
}
}