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< ...@@ -185,7 +185,7 @@ class ScEditFieldObj : public cppu::WeakImplHelper<
bool mbIsFixed:1; bool mbIsFixed:1;
private: private:
SvxFieldData* getData(); SvxFieldData& getData();
void setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal); void setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal);
css::uno::Any getPropertyValueURL(const OUString& rName); css::uno::Any getPropertyValueURL(const OUString& rName);
......
...@@ -441,11 +441,8 @@ ScHeaderFieldsObj::~ScHeaderFieldsObj() ...@@ -441,11 +441,8 @@ ScHeaderFieldsObj::~ScHeaderFieldsObj()
{ {
lang::EventObject aEvent; lang::EventObject aEvent;
aEvent.Source = static_cast<cppu::OWeakObject*>(this); aEvent.Source = static_cast<cppu::OWeakObject*>(this);
if (mpRefreshListeners)
{
mpRefreshListeners->disposeAndClear(aEvent); mpRefreshListeners->disposeAndClear(aEvent);
DELETEZ( mpRefreshListeners ); DELETEZ(mpRefreshListeners);
}
} }
} }
...@@ -579,7 +576,7 @@ void SAL_CALL ScHeaderFieldsObj::removeRefreshListener( const uno::Reference<uti ...@@ -579,7 +576,7 @@ void SAL_CALL ScHeaderFieldsObj::removeRefreshListener( const uno::Reference<uti
} }
} }
SvxFieldData* ScEditFieldObj::getData() SvxFieldData& ScEditFieldObj::getData()
{ {
if (!mpData) if (!mpData)
{ {
...@@ -623,7 +620,7 @@ SvxFieldData* ScEditFieldObj::getData() ...@@ -623,7 +620,7 @@ SvxFieldData* ScEditFieldObj::getData()
mpData.reset(new SvxFieldData); mpData.reset(new SvxFieldData);
} }
} }
return mpData.get(); return *mpData.get();
} }
void ScEditFieldObj::setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal) void ScEditFieldObj::setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal)
...@@ -672,25 +669,21 @@ void ScEditFieldObj::setPropertyValueURL(const OUString& rName, const css::uno:: ...@@ -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. // Edit engine instance not yet present. Store the item data for later use.
SvxFieldData* pData = getData(); SvxURLField& rData = static_cast<SvxURLField&>(getData());
if (!pData)
throw uno::RuntimeException();
SvxURLField* p = static_cast<SvxURLField*>(pData);
if (rName == SC_UNONAME_URL) if (rName == SC_UNONAME_URL)
{ {
if (rVal >>= aStrVal) if (rVal >>= aStrVal)
p->SetURL(aStrVal); rData.SetURL(aStrVal);
} }
else if (rName == SC_UNONAME_REPR) else if (rName == SC_UNONAME_REPR)
{ {
if (rVal >>= aStrVal) if (rVal >>= aStrVal)
p->SetRepresentation(aStrVal); rData.SetRepresentation(aStrVal);
} }
else if (rName == SC_UNONAME_TARGET) else if (rName == SC_UNONAME_TARGET)
{ {
if (rVal >>= aStrVal) if (rVal >>= aStrVal)
p->SetTargetFrame(aStrVal); rData.SetTargetFrame(aStrVal);
} }
else else
throw beans::UnknownPropertyException(); throw beans::UnknownPropertyException();
...@@ -731,17 +724,14 @@ uno::Any ScEditFieldObj::getPropertyValueURL(const OUString& rName) ...@@ -731,17 +724,14 @@ uno::Any ScEditFieldObj::getPropertyValueURL(const OUString& rName)
} }
else // not inserted yet else // not inserted yet
{ {
const SvxFieldData* pField = getData(); const SvxURLField& rURL = static_cast<const SvxURLField&>(getData());
if (!pField)
return aRet;
const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
if (rName == SC_UNONAME_URL) if (rName == SC_UNONAME_URL)
aRet <<= pURL->GetURL(); aRet <<= rURL.GetURL();
else if (rName == SC_UNONAME_REPR) else if (rName == SC_UNONAME_REPR)
aRet <<= pURL->GetRepresentation(); aRet <<= rURL.GetRepresentation();
else if (rName == SC_UNONAME_TARGET) else if (rName == SC_UNONAME_TARGET)
aRet <<= pURL->GetTargetFrame(); aRet <<= rURL.GetTargetFrame();
else else
throw beans::UnknownPropertyException(); throw beans::UnknownPropertyException();
} }
...@@ -774,9 +764,8 @@ void ScEditFieldObj::setPropertyValueFile(const OUString& rName, const uno::Any& ...@@ -774,9 +764,8 @@ void ScEditFieldObj::setPropertyValueFile(const OUString& rName, const uno::Any&
} }
else else
{ {
SvxFieldData* pField = getData(); SvxExtFileField& rExtFile = static_cast<SvxExtFileField&>(getData());
SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField); rExtFile.SetFormat(eFormat);
pExtFile->SetFormat(eFormat);
} }
} }
...@@ -798,7 +787,7 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName) ...@@ -798,7 +787,7 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName)
aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE); aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
} }
else else
pField = getData(); pField = &getData();
OSL_ENSURE(pField, "setPropertyValueFile: Field not found"); OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
if (!pField) if (!pField)
...@@ -809,7 +798,6 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName) ...@@ -809,7 +798,6 @@ uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName)
sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat); sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
aRet <<= nIntVal; aRet <<= nIntVal;
return aRet; return aRet;
} }
...@@ -1046,16 +1034,12 @@ void ScEditFieldObj::setPropertyValueSheet(const OUString& rName, const uno::Any ...@@ -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. // Edit engine instance not yet present. Store the item data for later use.
SvxFieldData* pData = getData(); SvxTableField& r = static_cast<SvxTableField&>(getData());
if (!pData)
throw uno::RuntimeException();
SvxTableField* p = static_cast<SvxTableField*>(pData);
if (rName != SC_UNONAME_TABLEPOS) if (rName != SC_UNONAME_TABLEPOS)
throw beans::UnknownPropertyException(); throw beans::UnknownPropertyException();
sal_Int32 nTab = rVal.get<sal_Int32>(); sal_Int32 nTab = rVal.get<sal_Int32>();
p->SetTab(nTab); r.SetTab(nTab);
} }
ScEditFieldObj::ScEditFieldObj( ScEditFieldObj::ScEditFieldObj(
...@@ -1111,7 +1095,7 @@ ScEditFieldObj::~ScEditFieldObj() ...@@ -1111,7 +1095,7 @@ ScEditFieldObj::~ScEditFieldObj()
SvxFieldItem ScEditFieldObj::CreateFieldItem() SvxFieldItem ScEditFieldObj::CreateFieldItem()
{ {
OSL_ENSURE( !mpEditSource, "CreateFieldItem with inserted field" ); OSL_ENSURE( !mpEditSource, "CreateFieldItem with inserted field" );
return SvxFieldItem(*getData(), EE_FEATURE_FIELD); return SvxFieldItem(getData(), EE_FEATURE_FIELD);
} }
void ScEditFieldObj::DeleteField() 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