summaryrefslogtreecommitdiff
path: root/sc/source/ui/unoobj/fielduno.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 08:50:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 13:48:25 +0200
commita7ce8404befaf59df5f1a476c8dd414633bbf823 (patch)
treedc617344e2ac5a1b144614421a87d27a17ee0f36 /sc/source/ui/unoobj/fielduno.cxx
parent5c54b6523f74db4f79540361fc1630aaee06bcd5 (diff)
loplugin:flatten in pyuno..sc
Change-Id: I7ddc0b76532d26910f78642200750459508c2861 Reviewed-on: https://gerrit.libreoffice.org/42617 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/unoobj/fielduno.cxx')
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx122
1 files changed, 58 insertions, 64 deletions
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index d87bd6f1aa8d..cd434056ce6d 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -356,10 +356,10 @@ uno::Any SAL_CALL ScCellFieldsObj::getByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
- if (xField.is())
- return uno::makeAny(xField);
- else
+ if (!xField.is())
throw lang::IndexOutOfBoundsException();
+
+ return uno::makeAny(xField);
}
uno::Type SAL_CALL ScCellFieldsObj::getElementType()
@@ -512,10 +512,10 @@ uno::Any SAL_CALL ScHeaderFieldsObj::getByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
- if (xField.is())
- return uno::makeAny(xField);
- else
+ if (!xField.is())
throw lang::IndexOutOfBoundsException();
+
+ return uno::makeAny(xField);
}
uno::Type SAL_CALL ScHeaderFieldsObj::getElementType()
@@ -752,67 +752,65 @@ uno::Any ScEditFieldObj::getPropertyValueURL(const OUString& rName)
void ScEditFieldObj::setPropertyValueFile(const OUString& rName, const uno::Any& rVal)
{
- if (rName == SC_UNONAME_FILEFORM)
+ if (rName != SC_UNONAME_FILEFORM)
+ throw beans::UnknownPropertyException();
+
+ sal_Int16 nIntVal = 0;
+ if (rVal >>= nIntVal)
{
- sal_Int16 nIntVal = 0;
- if (rVal >>= nIntVal)
+ SvxFileFormat eFormat = lcl_UnoToSvxFileFormat(nIntVal);
+ if (mpEditSource)
{
- SvxFileFormat eFormat = lcl_UnoToSvxFileFormat(nIntVal);
- if (mpEditSource)
- {
- ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
- ScUnoEditEngine aTempEngine(pEditEngine);
- SvxFieldData* pField = aTempEngine.FindByPos(
- aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
- OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
- if (pField)
- {
- SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField); // local to the ScUnoEditEngine
- pExtFile->SetFormat(eFormat);
- pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
- mpEditSource->UpdateData();
- }
- }
- else
+ ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+ SvxFieldData* pField = aTempEngine.FindByPos(
+ aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
+ OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
+ if (pField)
{
- SvxFieldData* pField = getData();
- SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField);
+ SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField); // local to the ScUnoEditEngine
pExtFile->SetFormat(eFormat);
+ pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
+ mpEditSource->UpdateData();
}
}
+ else
+ {
+ SvxFieldData* pField = getData();
+ SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField);
+ pExtFile->SetFormat(eFormat);
+ }
}
- else
- throw beans::UnknownPropertyException();
+
}
uno::Any ScEditFieldObj::getPropertyValueFile(const OUString& rName)
{
uno::Any aRet;
- if (rName == SC_UNONAME_FILEFORM)
- {
- SvxFileFormat eFormat = SvxFileFormat::NameAndExt;
- const SvxFieldData* pField = nullptr;
- if (mpEditSource)
- {
- ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
- ScUnoEditEngine aTempEngine(pEditEngine);
- pField = aTempEngine.FindByPos(
- aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
- }
- else
- pField = getData();
-
- OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
- if (!pField)
- throw uno::RuntimeException();
+ if (rName != SC_UNONAME_FILEFORM)
+ throw beans::UnknownPropertyException();
- const SvxExtFileField* pExtFile = static_cast<const SvxExtFileField*>(pField);
- eFormat = pExtFile->GetFormat();
- sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
- aRet <<= nIntVal;
+ SvxFileFormat eFormat = SvxFileFormat::NameAndExt;
+ const SvxFieldData* pField = nullptr;
+ if (mpEditSource)
+ {
+ ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+ pField = aTempEngine.FindByPos(
+ aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
}
else
- throw beans::UnknownPropertyException();
+ pField = getData();
+
+ OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
+ if (!pField)
+ throw uno::RuntimeException();
+
+ const SvxExtFileField* pExtFile = static_cast<const SvxExtFileField*>(pField);
+ eFormat = pExtFile->GetFormat();
+ sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
+ aRet <<= nIntVal;
+
return aRet;
}
@@ -1037,14 +1035,13 @@ void ScEditFieldObj::setPropertyValueSheet(const OUString& rName, const uno::Any
SvxTableField* p = static_cast<SvxTableField*>(pField);
- if (rName == SC_UNONAME_TABLEPOS)
- {
- sal_Int32 nTab = rVal.get<sal_Int32>();
- p->SetTab(nTab);
- }
- else
+ if (rName != SC_UNONAME_TABLEPOS)
throw beans::UnknownPropertyException();
+ sal_Int32 nTab = rVal.get<sal_Int32>();
+ p->SetTab(nTab);
+
+
pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
mpEditSource->UpdateData();
return;
@@ -1056,14 +1053,11 @@ void ScEditFieldObj::setPropertyValueSheet(const OUString& rName, const uno::Any
throw uno::RuntimeException();
SvxTableField* p = static_cast<SvxTableField*>(pData);
- if (rName == SC_UNONAME_TABLEPOS)
- {
- sal_Int32 nTab = rVal.get<sal_Int32>();
- p->SetTab(nTab);
- }
- else
+ if (rName != SC_UNONAME_TABLEPOS)
throw beans::UnknownPropertyException();
+ sal_Int32 nTab = rVal.get<sal_Int32>();
+ p->SetTab(nTab);
}
ScEditFieldObj::ScEditFieldObj(