summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-12-21 23:41:16 +0100
committerEike Rathke <erack@redhat.com>2017-12-21 23:44:29 +0100
commit8f3f6755d7f7355493e873954513fdaeb4dceca9 (patch)
tree1fe86714f97d8f104045621e841e60f2831ba20c
parent993bbae2d43d3e4dea445cccbee3bb16d883af02 (diff)
Have one getSkipEmptyCellsIndex(), assert array length, tdf#113979 follow-up
Change-Id: Iac38405ac7d246dfe13766b1eefc6310756bffe6
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx26
1 files changed, 16 insertions, 10 deletions
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 69cfdc65324a..4340244a0706 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -84,6 +84,13 @@ const OUString aSep_Path = "Office.Calc/Dialogs/CSVImport";
const OUString aSep_Path_Clpbrd = "Office.Calc/Dialogs/ClipboardTextImport";
const OUString aSep_Path_Text2Col = "Office.Calc/Dialogs/TextToColumnsImport";
+namespace {
+CSVImportOptionsIndex getSkipEmptyCellsIndex( ScImportAsciiCall eCall )
+{
+ return eCall == SC_TEXTTOCOLUMNS ? CSVIO_Text2ColSkipEmptyCells : CSVIO_PasteSkipEmptyCells;
+}
+}
+
static void lcl_FillCombo( ComboBox& rCombo, const OUString& rList, sal_Unicode cSelect )
{
sal_Int32 i;
@@ -165,9 +172,9 @@ void lcl_CreatePropertiesNames ( OUString& rSepPath, Sequence<OUString>& rNames,
}
if (eCall != SC_IMPORTFILE)
{
- pNames[ eCall == SC_TEXTTOCOLUMNS ?
- CSVIO_Text2ColSkipEmptyCells :
- CSVIO_PasteSkipEmptyCells ] = CSVImportOptionNames[ CSVIO_PasteSkipEmptyCells ];
+ const sal_Int32 nSkipEmptyCells = getSkipEmptyCellsIndex(eCall);
+ assert( nSkipEmptyCells < rNames.getLength());
+ pNames[ nSkipEmptyCells ] = CSVImportOptionNames[ CSVIO_PasteSkipEmptyCells ];
}
}
@@ -216,10 +223,9 @@ static void lcl_LoadSeparators( OUString& rFieldSeparators, OUString& rTextSepar
}
if (eCall != SC_IMPORTFILE)
{
- sal_Int32 nSkipEmptyCells = eCall == SC_TEXTTOCOLUMNS ?
- CSVIO_Text2ColSkipEmptyCells :
- CSVIO_PasteSkipEmptyCells;
- if( pProperties[nSkipEmptyCells].hasValue() )
+ const sal_Int32 nSkipEmptyCells = getSkipEmptyCellsIndex(eCall);
+ assert( nSkipEmptyCells < aValues.getLength());
+ if ( pProperties[nSkipEmptyCells].hasValue() )
rSkipEmptyCells = ScUnoHelpFunctions::GetBoolFromAny( pProperties[nSkipEmptyCells] );
}
}
@@ -254,9 +260,9 @@ static void lcl_SaveSeparators(
}
if (eCall != SC_IMPORTFILE)
{
- pProperties[ eCall == SC_TEXTTOCOLUMNS ?
- CSVIO_Text2ColSkipEmptyCells :
- CSVIO_PasteSkipEmptyCells ] <<= bSkipEmptyCells;
+ const sal_Int32 nSkipEmptyCells = getSkipEmptyCellsIndex(eCall);
+ assert( nSkipEmptyCells < aValues.getLength());
+ pProperties[ nSkipEmptyCells ] <<= bSkipEmptyCells;
}
aItem.PutProperties(aNames, aValues);