Kaydet (Commit) 0252f24c authored tarafından Michael Stahl's avatar Michael Stahl

sw: clean up some defensive programming in modcfg.cxx

Change-Id: I901d934d1c2bdf6f15760292481091eb740dfda1
üst c150d910
...@@ -347,16 +347,14 @@ void SwRevisionConfig::Load() ...@@ -347,16 +347,14 @@ void SwRevisionConfig::Load()
const Sequence<OUString>& aNames = GetPropertyNames(); const Sequence<OUString>& aNames = GetPropertyNames();
Sequence<Any> aValues = GetProperties(aNames); Sequence<Any> aValues = GetProperties(aNames);
const Any* pValues = aValues.getConstArray(); const Any* pValues = aValues.getConstArray();
OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); assert(aValues.getLength() == aNames.getLength());
if(aValues.getLength() == aNames.getLength()) for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp)
{ {
for(int nProp = 0; nProp < aNames.getLength(); nProp++) if (pValues[nProp].hasValue())
{
if(pValues[nProp].hasValue())
{ {
sal_Int32 nVal = 0; sal_Int32 nVal = 0;
pValues[nProp] >>= nVal; pValues[nProp] >>= nVal;
switch(nProp) switch (nProp)
{ {
case 0 : lcl_ConvertCfgToAttr(nVal, aInsertAttr); break; case 0 : lcl_ConvertCfgToAttr(nVal, aInsertAttr); break;
case 1 : aInsertAttr.nColor = nVal; break; case 1 : aInsertAttr.nColor = nVal; break;
...@@ -369,7 +367,6 @@ void SwRevisionConfig::Load() ...@@ -369,7 +367,6 @@ void SwRevisionConfig::Load()
} }
} }
} }
}
} }
enum InsertConfigProp enum InsertConfigProp
...@@ -874,9 +871,7 @@ void SwInsertConfig::Load() ...@@ -874,9 +871,7 @@ void SwInsertConfig::Load()
const Sequence<OUString>& aNames = GetPropertyNames(); const Sequence<OUString>& aNames = GetPropertyNames();
Sequence<Any> aValues = GetProperties(aNames); Sequence<Any> aValues = GetProperties(aNames);
const Any* pValues = aValues.getConstArray(); const Any* pValues = aValues.getConstArray();
OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); assert(aValues.getLength() == aNames.getLength());
if(aValues.getLength() == aNames.getLength())
{
InsCaptionOpt* pWriterTableOpt = 0; InsCaptionOpt* pWriterTableOpt = 0;
InsCaptionOpt* pWriterFrameOpt = 0; InsCaptionOpt* pWriterFrameOpt = 0;
InsCaptionOpt* pWriterGraphicOpt = 0; InsCaptionOpt* pWriterGraphicOpt = 0;
...@@ -885,7 +880,7 @@ void SwInsertConfig::Load() ...@@ -885,7 +880,7 @@ void SwInsertConfig::Load()
InsCaptionOpt* pOLEChartOpt = 0; InsCaptionOpt* pOLEChartOpt = 0;
InsCaptionOpt* pOLEFormulaOpt = 0; InsCaptionOpt* pOLEFormulaOpt = 0;
InsCaptionOpt* pOLEDrawOpt = 0; InsCaptionOpt* pOLEDrawOpt = 0;
if(pCapOptions) if (pCapOptions)
{ {
pWriterTableOpt = pCapOptions->Find(TABLE_CAP, 0); pWriterTableOpt = pCapOptions->Find(TABLE_CAP, 0);
pWriterFrameOpt = pCapOptions->Find(FRAME_CAP, 0); pWriterFrameOpt = pCapOptions->Find(FRAME_CAP, 0);
...@@ -896,16 +891,16 @@ void SwInsertConfig::Load() ...@@ -896,16 +891,16 @@ void SwInsertConfig::Load()
pOLEFormulaOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_MATH ]); pOLEFormulaOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_MATH ]);
pOLEChartOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_CHART ]); pOLEChartOpt = pCapOptions->Find(OLE_CAP, &aGlobalNames[GLOB_NAME_CHART ]);
} }
else if(!bIsWeb) else if (!bIsWeb)
return; return;
sal_uInt16 nInsTblFlags = 0; sal_uInt16 nInsTblFlags = 0;
for(int nProp = 0; nProp < aNames.getLength(); nProp++) for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp)
{ {
if(pValues[nProp].hasValue()) if (pValues[nProp].hasValue())
{ {
bool bBool = nProp < INS_PROP_CAP_OBJECT_TABLE_ENABLE && *static_cast<sal_Bool const *>(pValues[nProp].getValue()); bool bBool = nProp < INS_PROP_CAP_OBJECT_TABLE_ENABLE && *static_cast<sal_Bool const *>(pValues[nProp].getValue());
switch(nProp) switch (nProp)
{ {
case INS_PROP_TABLE_HEADER: case INS_PROP_TABLE_HEADER:
{ {
...@@ -1087,7 +1082,7 @@ void SwInsertConfig::Load() ...@@ -1087,7 +1082,7 @@ void SwInsertConfig::Load()
break; break;
} }
} }
else if(nProp == INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST) else if (nProp == INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST)
{ {
//#i61007# initialize caption order, right now only HUNGARIAN seems to need a different order //#i61007# initialize caption order, right now only HUNGARIAN seems to need a different order
SvtSysLocaleOptions aSysLocaleOptions; SvtSysLocaleOptions aSysLocaleOptions;
...@@ -1097,7 +1092,6 @@ void SwInsertConfig::Load() ...@@ -1097,7 +1092,6 @@ void SwInsertConfig::Load()
} }
aInsTblOpts.mnInsMode = nInsTblFlags; aInsTblOpts.mnInsMode = nInsTblFlags;
}
} }
const Sequence<OUString>& SwTableConfig::GetPropertyNames() const Sequence<OUString>& SwTableConfig::GetPropertyNames()
...@@ -1162,15 +1156,13 @@ void SwTableConfig::Load() ...@@ -1162,15 +1156,13 @@ void SwTableConfig::Load()
const Sequence<OUString>& aNames = GetPropertyNames(); const Sequence<OUString>& aNames = GetPropertyNames();
Sequence<Any> aValues = GetProperties(aNames); Sequence<Any> aValues = GetProperties(aNames);
const Any* pValues = aValues.getConstArray(); const Any* pValues = aValues.getConstArray();
OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); assert(aValues.getLength() == aNames.getLength());
if(aValues.getLength() == aNames.getLength()) for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp)
{
for(int nProp = 0; nProp < aNames.getLength(); nProp++)
{ {
if(pValues[nProp].hasValue()) if (pValues[nProp].hasValue())
{ {
sal_Int32 nTemp = 0; sal_Int32 nTemp = 0;
switch(nProp) switch (nProp)
{ {
case 0 : pValues[nProp] >>= nTemp; nTblHMove = (sal_uInt16)convertMm100ToTwip(nTemp); break; //"Shift/Row", case 0 : pValues[nProp] >>= nTemp; nTblHMove = (sal_uInt16)convertMm100ToTwip(nTemp); break; //"Shift/Row",
case 1 : pValues[nProp] >>= nTemp; nTblVMove = (sal_uInt16)convertMm100ToTwip(nTemp); break; //"Shift/Column", case 1 : pValues[nProp] >>= nTemp; nTblVMove = (sal_uInt16)convertMm100ToTwip(nTemp); break; //"Shift/Column",
...@@ -1183,7 +1175,6 @@ void SwTableConfig::Load() ...@@ -1183,7 +1175,6 @@ void SwTableConfig::Load()
} }
} }
} }
}
} }
SwMiscConfig::SwMiscConfig() : SwMiscConfig::SwMiscConfig() :
...@@ -1271,15 +1262,13 @@ void SwMiscConfig::Load() ...@@ -1271,15 +1262,13 @@ void SwMiscConfig::Load()
const Sequence<OUString>& aNames = GetPropertyNames(); const Sequence<OUString>& aNames = GetPropertyNames();
Sequence<Any> aValues = GetProperties(aNames); Sequence<Any> aValues = GetProperties(aNames);
const Any* pValues = aValues.getConstArray(); const Any* pValues = aValues.getConstArray();
OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); assert(aValues.getLength() == aNames.getLength());
if(aValues.getLength() == aNames.getLength())
{
OUString sTmp; OUString sTmp;
for(int nProp = 0; nProp < aNames.getLength(); nProp++) for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp)
{ {
if(pValues[nProp].hasValue()) if (pValues[nProp].hasValue())
{ {
switch(nProp) switch (nProp)
{ {
case 0 : pValues[nProp] >>= sTmp; case 0 : pValues[nProp] >>= sTmp;
sWordDelimiter = SwModuleOptions::ConvertWordDelimiter(sTmp, true); sWordDelimiter = SwModuleOptions::ConvertWordDelimiter(sTmp, true);
...@@ -1298,7 +1287,6 @@ void SwMiscConfig::Load() ...@@ -1298,7 +1287,6 @@ void SwMiscConfig::Load()
} }
} }
} }
}
} }
const Sequence<OUString>& SwCompareConfig::GetPropertyNames() const Sequence<OUString>& SwCompareConfig::GetPropertyNames()
...@@ -1360,12 +1348,10 @@ void SwCompareConfig::Load() ...@@ -1360,12 +1348,10 @@ void SwCompareConfig::Load()
const Sequence<OUString>& aNames = GetPropertyNames(); const Sequence<OUString>& aNames = GetPropertyNames();
Sequence<Any> aValues = GetProperties(aNames); Sequence<Any> aValues = GetProperties(aNames);
const Any* pValues = aValues.getConstArray(); const Any* pValues = aValues.getConstArray();
DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); assert(aValues.getLength() == aNames.getLength());
if(aValues.getLength() == aNames.getLength()) for (sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++)
{ {
for(int nProp = 0; nProp < aNames.getLength(); nProp++) if (pValues[nProp].hasValue())
{
if(pValues[nProp].hasValue())
{ {
sal_Int32 nVal = 0; sal_Int32 nVal = 0;
pValues[nProp] >>= nVal; pValues[nProp] >>= nVal;
...@@ -1380,7 +1366,6 @@ void SwCompareConfig::Load() ...@@ -1380,7 +1366,6 @@ void SwCompareConfig::Load()
} }
} }
} }
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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