summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui/imoptdlg.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2021-07-15 10:37:57 +0200
committerEike Rathke <erack@redhat.com>2021-07-15 13:02:04 +0200
commitfda91f8be16ba760e360940ebafd6244c648cb8c (patch)
tree35c56bba166691e0ad63792c69c940fe6cf7919e /sc/source/ui/dbgui/imoptdlg.cxx
parent246c766cadcafc5d26f39f832a683a13f2dfe40b (diff)
Related: tdf#135762 Allow --convert-to csv to specify 1-based sheet number
Same multifile mechanism as for -1 all sheets is used, so soffice --convert-to csv:"Text - txt - csv (StarCalc)":44,34,UTF8,1,,0,false,true,false,false,false,2 sample.ods writes a file sample-Sheet2.csv Change-Id: Ib9248c9561e4e340c88458ac5dfd159e443a4cfd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118971 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sc/source/ui/dbgui/imoptdlg.cxx')
-rw-r--r--sc/source/ui/dbgui/imoptdlg.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
index d8c4fd810ea3..a362e4df0ee7 100644
--- a/sc/source/ui/dbgui/imoptdlg.cxx
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -20,6 +20,7 @@
#include <imoptdlg.hxx>
#include <asciiopt.hxx>
#include <comphelper/string.hxx>
+#include <unotools/charclass.hxx>
#include <osl/thread.h>
#include <global.hxx>
@@ -43,7 +44,7 @@ ScImportOptions::ScImportOptions( const OUString& rStr )
bSaveNumberAsSuch = true;
bSaveFormulas = false;
bRemoveSpace = false;
- bNewFilePerSheet = false;
+ nSheetToExport = 0;
sal_Int32 nTokenCount = comphelper::string::getTokenCount(rStr, ',');
if ( nTokenCount < 3 )
return;
@@ -79,7 +80,15 @@ ScImportOptions::ScImportOptions( const OUString& rStr )
if ( nTokenCount >= 11 )
bRemoveSpace = rStr.getToken(0, ',', nIdx) == "true";
if ( nTokenCount >= 12 )
- bNewFilePerSheet = rStr.getToken(0, ',', nIdx) == "-1";
+ {
+ const OUString aTok(rStr.getToken(0, ',', nIdx));
+ if (aTok == "-1")
+ nSheetToExport = -1; // all
+ else if (aTok.isEmpty() || CharClass::isAsciiNumeric(aTok))
+ nSheetToExport = aTok.toInt32();
+ else
+ nSheetToExport = -23; // invalid, force error
+ }
}
}
@@ -104,7 +113,7 @@ OUString ScImportOptions::BuildString() const
"," +
OUString::boolean( bRemoveSpace ) + // same as "Remove space" in ScAsciiOptions
"," +
- std::u16string_view(bNewFilePerSheet ? u"-1" : u"0") ; // Only available for command line --convert-to
+ OUString::number(nSheetToExport) ; // Only available for command line --convert-to
return aResult;
}