[Libreoffice-commits] core.git: sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Nov 3 20:18:10 UTC 2018
sc/inc/fielduno.hxx | 2 -
sc/source/ui/unoobj/fielduno.cxx | 52 +++++++++++++--------------------------
2 files changed, 19 insertions(+), 35 deletions(-)
New commits:
commit 1459ffdffee61f3c4a552a28c5aa43facb3f4fcf
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat Nov 3 20:38:21 2018 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Nov 3 21:17:38 2018 +0100
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 at collabora.com>
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 9b6245131c85..70b3aa31639b 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -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);
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index a1036dfa8dea..666eb8c7c88e 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -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()
More information about the Libreoffice-commits
mailing list