tdf#120703 PVS: V547 Expression is always true/false
Let ScEditFieldObj::getData() return reference.
Change-Id: I4deed9a1692953088cf6d939508b9045e3e6cb3c
Reviewed-on: https://gerrit.libreoffice.org/62816
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 9b62451..70b3aa3 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -185,7 +185,7 @@
bool mbIsFixed:1;
private:
SvxFieldData* getData();
SvxFieldData& getData();
void setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal);
css::uno::Any getPropertyValueURL(const OUString& rName);
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index a1036df..666eb8c 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -441,11 +441,8 @@
{
lang::EventObject aEvent;
aEvent.Source = static_cast<cppu::OWeakObject*>(this);
if (mpRefreshListeners)
{
mpRefreshListeners->disposeAndClear(aEvent);
DELETEZ( mpRefreshListeners );
}
mpRefreshListeners->disposeAndClear(aEvent);
DELETEZ(mpRefreshListeners);
}
}
@@ -579,7 +576,7 @@
}
}
SvxFieldData* ScEditFieldObj::getData()
SvxFieldData& ScEditFieldObj::getData()
{
if (!mpData)
{
@@ -623,7 +620,7 @@
mpData.reset(new SvxFieldData);
}
}
return mpData.get();
return *mpData.get();
}
void ScEditFieldObj::setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal)
@@ -672,25 +669,21 @@
}
// Edit engine instance not yet present. Store the item data for later use.
SvxFieldData* pData = getData();
if (!pData)
throw uno::RuntimeException();
SvxURLField* p = static_cast<SvxURLField*>(pData);
SvxURLField& rData = static_cast<SvxURLField&>(getData());
if (rName == SC_UNONAME_URL)
{
if (rVal >>= aStrVal)
p->SetURL(aStrVal);
rData.SetURL(aStrVal);
}
else if (rName == SC_UNONAME_REPR)
{
if (rVal >>= aStrVal)
p->SetRepresentation(aStrVal);
rData.SetRepresentation(aStrVal);
}
else if (rName == SC_UNONAME_TARGET)
{
if (rVal >>= aStrVal)
p->SetTargetFrame(aStrVal);
rData.SetTargetFrame(aStrVal);
}
else
throw beans::UnknownPropertyException();
@@ -731,17 +724,14 @@
}
else // not inserted yet
{
const SvxFieldData* pField = getData();
if (!pField)
return aRet;
const SvxURLField& rURL = static_cast<const SvxURLField&>(getData());
const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
if (rName == SC_UNONAME_URL)
aRet <<= pURL->GetURL();
aRet <<= rURL.GetURL();
else if (rName == SC_UNONAME_REPR)
aRet <<= pURL->GetRepresentation();
aRet <<= rURL.GetRepresentation();
else if (rName == SC_UNONAME_TARGET)
aRet <<= pURL->GetTargetFrame();
aRet <<= rURL.GetTargetFrame();
else
throw beans::UnknownPropertyException();
}
@@ -774,9 +764,8 @@
}
else
{
SvxFieldData* pField = getData();
SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField);
pExtFile->SetFormat(eFormat);
SvxExtFileField& rExtFile = static_cast<SvxExtFileField&>(getData());
rExtFile.SetFormat(eFormat);
}
}
@@ -798,7 +787,7 @@
aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
}
else
pField = getData();
pField = &getData();
OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
if (!pField)
@@ -809,7 +798,6 @@
sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
aRet <<= nIntVal;
return aRet;
}
@@ -1046,16 +1034,12 @@
}
// Edit engine instance not yet present. Store the item data for later use.
SvxFieldData* pData = getData();
if (!pData)
throw uno::RuntimeException();
SvxTableField* p = static_cast<SvxTableField*>(pData);
SvxTableField& r = static_cast<SvxTableField&>(getData());
if (rName != SC_UNONAME_TABLEPOS)
throw beans::UnknownPropertyException();
sal_Int32 nTab = rVal.get<sal_Int32>();
p->SetTab(nTab);
r.SetTab(nTab);
}
ScEditFieldObj::ScEditFieldObj(
@@ -1111,7 +1095,7 @@
SvxFieldItem ScEditFieldObj::CreateFieldItem()
{
OSL_ENSURE( !mpEditSource, "CreateFieldItem with inserted field" );
return SvxFieldItem(*getData(), EE_FEATURE_FIELD);
return SvxFieldItem(getData(), EE_FEATURE_FIELD);
}
void ScEditFieldObj::DeleteField()