Kaydet (Commit) 1459ffdf authored tarafından Mike Kaganski's avatar Mike Kaganski

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: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 49747ff2
......@@ -185,7 +185,7 @@ class ScEditFieldObj : public cppu::WeakImplHelper<
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);
......
......@@ -441,11 +441,8 @@ ScHeaderFieldsObj::~ScHeaderFieldsObj()
{
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 @@ void SAL_CALL ScHeaderFieldsObj::removeRefreshListener( const uno::Reference<uti
}
}
SvxFieldData* ScEditFieldObj::getData()
SvxFieldData& ScEditFieldObj::getData()
{
if (!mpData)
{
......@@ -623,7 +620,7 @@ SvxFieldData* ScEditFieldObj::getData()
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 @@ void ScEditFieldObj::setPropertyValueURL(const OUString& rName, const css::uno::
}
// 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 @@ uno::Any ScEditFieldObj::getPropertyValueURL(const OUString& rName)
}
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 @@ void ScEditFieldObj::setPropertyValueFile(const OUString& rName, const uno::Any&
}
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 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName)
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 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName)
sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
aRet <<= nIntVal;
return aRet;
}
......@@ -1046,16 +1034,12 @@ void ScEditFieldObj::setPropertyValueSheet(const OUString& rName, const uno::Any
}
// 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 @@ ScEditFieldObj::~ScEditFieldObj()
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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment