Blame SOURCES/0001-rhbz-1980800-allow-convert-to-csv-to-write-each-shee.patch

76e0e0
From aec3e189e6e9aa1eb2fe91cbb1c46f308b074cd5 Mon Sep 17 00:00:00 2001
76e0e0
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
76e0e0
Date: Tue, 13 Jul 2021 12:38:07 +0100
76e0e0
Subject: [PATCH] rhbz#1980800 allow --convert-to csv to write each sheet to a
76e0e0
 separate file
76e0e0
76e0e0
Related: tdf#135762 except only currently implemented for command line use
76e0e0
76e0e0
sample usage:
76e0e0
soffice --convert-to csv:"Text - txt - csv (StarCalc)":44,34,UTF8,1,,0,false,true,false,false,false,-1 sample.ods
76e0e0
where the new (11th!) final token ("-1") enables writing each sheet to a
76e0e0
new file based on the suggested target name so output in this example
76e0e0
is files sample-Sheet1.csv and sample-Sheet2.csv
76e0e0
76e0e0
Only -1 for 'all sheets' vs 0 for existing 'current sheet only' (which
76e0e0
is always sheet 0 from the command line) are currently options but the
76e0e0
token could be expanded in the future to select specific sheets to
76e0e0
export.
76e0e0
76e0e0
Change-Id: Ib99a120f1a2c8d1008a7a3c59a6b39f572fb346e
76e0e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118850
76e0e0
Tested-by: Jenkins
76e0e0
Reviewed-by: Eike Rathke <erack@redhat.com>
76e0e0
(cherry picked from commit b8903bc106dad036acb3d117e5c4fc955697fe02)
76e0e0
76e0e0
Related: tdf#135762 Allow --convert-to csv to specify 1-based sheet number
76e0e0
76e0e0
Same multifile mechanism as for -1 all sheets is used, so
76e0e0
76e0e0
soffice --convert-to csv:"Text - txt - csv (StarCalc)":44,34,UTF8,1,,0,false,true,false,false,false,2 sample.ods
76e0e0
76e0e0
writes a file sample-Sheet2.csv
76e0e0
76e0e0
Change-Id: Ib9248c9561e4e340c88458ac5dfd159e443a4cfd
76e0e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118971
76e0e0
Reviewed-by: Eike Rathke <erack@redhat.com>
76e0e0
Tested-by: Jenkins
76e0e0
(cherry picked from commit fda91f8be16ba760e360940ebafd6244c648cb8c)
76e0e0
76e0e0
Related: tdf#135762 Suppress cout if not command line
76e0e0
76e0e0
Change-Id: I9431221aadf97739bb197871f25fa151ef4c391c
76e0e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119294
76e0e0
Reviewed-by: Eike Rathke <erack@redhat.com>
76e0e0
Tested-by: Jenkins
76e0e0
(cherry picked from commit 0cda081c9aa3b3dcb363f97bac60c845ce9a13e0)
76e0e0
---
76e0e0
 desktop/source/app/dispatchwatcher.cxx |  50 +++++++--
76e0e0
 sc/source/ui/dbgui/imoptdlg.cxx        |  16 ++-
76e0e0
 sc/source/ui/docshell/docsh.cxx        | 141 +++++++++++++++++++++----
76e0e0
 sc/source/ui/inc/docsh.hxx             |   2 +-
76e0e0
 sc/source/ui/inc/imoptdlg.hxx          |   6 +-
76e0e0
 5 files changed, 179 insertions(+), 36 deletions(-)
76e0e0
76e0e0
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
76e0e0
index 50b92ecb7834..3df4f34ccf83 100644
76e0e0
--- a/desktop/source/app/dispatchwatcher.cxx
76e0e0
+++ b/desktop/source/app/dispatchwatcher.cxx
76e0e0
@@ -30,6 +30,7 @@
76e0e0
 #include "officeipcthread.hxx"
76e0e0
 #include <rtl/ustring.hxx>
76e0e0
 #include <comphelper/processfactory.hxx>
76e0e0
+#include <comphelper/string.hxx>
76e0e0
 #include <comphelper/synchronousdispatch.hxx>
76e0e0
 #include <com/sun/star/io/IOException.hpp>
76e0e0
 #include <com/sun/star/util/XCloseable.hpp>
76e0e0
@@ -598,6 +599,8 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector
76e0e0
                                 aFilter = impl_GuessFilter( aOutFile, aDocService );
76e0e0
                             }
76e0e0
 
76e0e0
+                            bool bMultiFileTarget = false;
76e0e0
+
76e0e0
                             if (aFilter.isEmpty())
76e0e0
                             {
76e0e0
                                 std::cerr << "Error: no export filter" << std::endl;
76e0e0
@@ -605,29 +608,54 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector
76e0e0
                             else
76e0e0
                             {
76e0e0
                                 sal_Int32 nFilterOptionsIndex = aFilter.indexOf(':');
76e0e0
-                                sal_Int32 nProps = ( 0 < nFilterOptionsIndex ) ? 3 : 2;
76e0e0
+                                sal_Int32 nProps = ( 0 < nFilterOptionsIndex ) ? 4 : 3;
76e0e0
 
76e0e0
                                 if ( !aImgOut.isEmpty() )
76e0e0
                                     nProps +=1;
76e0e0
                                 Sequence<PropertyValue> conversionProperties( nProps );
76e0e0
-                                conversionProperties[0].Name = "Overwrite";
76e0e0
-                                conversionProperties[0].Value <<= true;
76e0e0
+                                conversionProperties[0].Name = "ConversionRequestOrigin";
76e0e0
+                                conversionProperties[0].Value <<= OUString("CommandLine");
76e0e0
+                                conversionProperties[1].Name = "Overwrite";
76e0e0
+                                conversionProperties[1].Value <<= true;
76e0e0
 
76e0e0
-                                conversionProperties[1].Name = "FilterName";
76e0e0
+                                conversionProperties[2].Name = "FilterName";
76e0e0
                                 if( 0 < nFilterOptionsIndex )
76e0e0
                                 {
76e0e0
-                                    conversionProperties[1].Value <<= aFilter.copy(0, nFilterOptionsIndex);
76e0e0
+                                    OUString sFilterName = aFilter.copy(0, nFilterOptionsIndex);
76e0e0
+                                    OUString sFilterOptions = aFilter.copy(nFilterOptionsIndex + 1);
76e0e0
+
76e0e0
+                                    if (sFilterName == "Text - txt - csv (StarCalc)")
76e0e0
+                                    {
76e0e0
+                                        sal_Int32 nIdx(0);
76e0e0
+                                        // If the 11th token is '-1' then we export a file
76e0e0
+                                        // per sheet where the file name is based on the suggested
76e0e0
+                                        // output filename concatenated with the sheet name, so adjust
76e0e0
+                                        // the output and overwrite messages
76e0e0
+                                        // If the 11th token is not present or numeric 0 then the
76e0e0
+                                        // default sheet is exported with the output filename. If it
76e0e0
+                                        // is numeric >0 then that sheet (1-based) with the output
76e0e0
+                                        // filename concatenated with the sheet name. So even if
76e0e0
+                                        // that is a single file, the multi file target mechanism is
76e0e0
+                                        // used.
76e0e0
+                                        const OUString aTok(sFilterOptions.getToken(11, ',', nIdx));
76e0e0
+                                        // Actual validity is checked in Calc, here just check for
76e0e0
+                                        // presence of numeric value at start.
76e0e0
+                                        bMultiFileTarget = (!aTok.isEmpty() && aTok.toInt32() != 0);
76e0e0
+                                    }
76e0e0
+
76e0e0
+                                    conversionProperties[2].Value <<= sFilterName;
76e0e0
 
76e0e0
-                                    conversionProperties[2].Name = "FilterOptions";
76e0e0
-                                    conversionProperties[2].Value <<= aFilter.copy(nFilterOptionsIndex + 1);
76e0e0
+                                    conversionProperties[3].Name = "FilterOptions";
76e0e0
+                                    conversionProperties[3].Value <<= sFilterOptions;
76e0e0
                                 }
76e0e0
                                 else
76e0e0
                                 {
76e0e0
-                                    conversionProperties[1].Value <<= aFilter;
76e0e0
+                                    conversionProperties[2].Value <<= aFilter;
76e0e0
                                 }
76e0e0
 
76e0e0
                                 if ( !aImgOut.isEmpty() )
76e0e0
                                 {
76e0e0
+                                    assert(conversionProperties[nProps-1].Name.isEmpty());
76e0e0
                                     conversionProperties[nProps-1].Name = "ImageFilter";
76e0e0
                                     conversionProperties[nProps-1].Value <<= aImgOut;
76e0e0
                                 }
76e0e0
@@ -639,9 +667,11 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector
76e0e0
                                 OString aTargetURL8 = OUStringToOString(aTempName, osl_getThreadTextEncoding());
76e0e0
                                 if (aDispatchRequest.aRequestType != REQUEST_CAT)
76e0e0
                                 {
76e0e0
-                                    std::cout << "convert " << aSource8 << " -> " << aTargetURL8;
76e0e0
+                                    std::cout << "convert " << aSource8;
76e0e0
+                                    if (!bMultiFileTarget)
76e0e0
+                                        std::cout << " -> " << aTargetURL8;
76e0e0
                                     std::cout << " using filter : " << OUStringToOString(aFilter, osl_getThreadTextEncoding()) << std::endl;
76e0e0
-                                    if (FStatHelper::IsDocument(aOutFile))
76e0e0
+                                    if (!bMultiFileTarget && FStatHelper::IsDocument(aOutFile))
76e0e0
                                         std::cout << "Overwriting: " << OUStringToOString(aTempName, osl_getThreadTextEncoding()) << std::endl ;
76e0e0
                                 }
76e0e0
                                 try
76e0e0
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
76e0e0
index 071f1b0257bc..a362e4df0ee7 100644
76e0e0
--- a/sc/source/ui/dbgui/imoptdlg.cxx
76e0e0
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
76e0e0
@@ -20,6 +20,7 @@
76e0e0
 #include <imoptdlg.hxx>
76e0e0
 #include <asciiopt.hxx>
76e0e0
 #include <comphelper/string.hxx>
76e0e0
+#include <unotools/charclass.hxx>
76e0e0
 #include <osl/thread.h>
76e0e0
 #include <global.hxx>
76e0e0
 
76e0e0
@@ -43,6 +44,7 @@ ScImportOptions::ScImportOptions( const OUString& rStr )
76e0e0
     bSaveNumberAsSuch = true;
76e0e0
     bSaveFormulas = false;
76e0e0
     bRemoveSpace = false;
76e0e0
+    nSheetToExport = 0;
76e0e0
     sal_Int32 nTokenCount = comphelper::string::getTokenCount(rStr, ',');
76e0e0
     if ( nTokenCount < 3 )
76e0e0
         return;
76e0e0
@@ -77,6 +79,16 @@ ScImportOptions::ScImportOptions( const OUString& rStr )
76e0e0
             bSaveFormulas = rStr.getToken(0, ',', nIdx) == "true";
76e0e0
         if ( nTokenCount >= 11 )
76e0e0
             bRemoveSpace = rStr.getToken(0, ',', nIdx) == "true";
76e0e0
+        if ( nTokenCount >= 12 )
76e0e0
+        {
76e0e0
+            const OUString aTok(rStr.getToken(0, ',', nIdx));
76e0e0
+            if (aTok == "-1")
76e0e0
+                nSheetToExport = -1;    // all
76e0e0
+            else if (aTok.isEmpty() || CharClass::isAsciiNumeric(aTok))
76e0e0
+                nSheetToExport = aTok.toInt32();
76e0e0
+            else
76e0e0
+                nSheetToExport = -23;   // invalid, force error
76e0e0
+        }
76e0e0
     }
76e0e0
 }
76e0e0
 
76e0e0
@@ -99,7 +111,9 @@ OUString ScImportOptions::BuildString() const
76e0e0
             "," +
76e0e0
             OUString::boolean( bSaveFormulas ) +  // "save formulas": not in ScAsciiOptions
76e0e0
             "," +
76e0e0
-            OUString::boolean( bRemoveSpace );    // same as "Remove space" in ScAsciiOptions
76e0e0
+            OUString::boolean( bRemoveSpace ) +  // same as "Remove space" in ScAsciiOptions
76e0e0
+            "," +
76e0e0
+            OUString::number(nSheetToExport) ;  // Only available for command line --convert-to
76e0e0
 
76e0e0
     return aResult;
76e0e0
 }
76e0e0
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
76e0e0
index 91020db0b2e0..5fdfddd0c89b 100644
76e0e0
--- a/sc/source/ui/docshell/docsh.cxx
76e0e0
+++ b/sc/source/ui/docshell/docsh.cxx
76e0e0
@@ -44,6 +44,7 @@
76e0e0
 #include <sfx2/objface.hxx>
76e0e0
 #include <sfx2/viewfrm.hxx>
76e0e0
 #include <svl/documentlockfile.hxx>
76e0e0
+#include <svl/fstathelper.hxx>
76e0e0
 #include <svl/sharecontrolfile.hxx>
76e0e0
 #include <svl/urihelper.hxx>
76e0e0
 #include <osl/file.hxx>
76e0e0
@@ -119,6 +120,7 @@
76e0e0
 #include <comphelper/processfactory.hxx>
76e0e0
 #include <comphelper/string.hxx>
76e0e0
 #include <unotools/configmgr.hxx>
76e0e0
+#include <unotools/ucbstreamhelper.hxx>
76e0e0
 #include <uiitems.hxx>
76e0e0
 #include <dpobject.hxx>
76e0e0
 #include <markdata.hxx>
76e0e0
@@ -1925,7 +1927,7 @@ void escapeTextSep(sal_Int32 nPos, const StrT& rStrDelim, StrT& rStr)
76e0e0
 
76e0e0
 }
76e0e0
 
76e0e0
-void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt )
76e0e0
+void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt, SCTAB nTab )
76e0e0
 {
76e0e0
     sal_Unicode cDelim    = rAsciiOpt.nFieldSepCode;
76e0e0
     sal_Unicode cStrDelim = rAsciiOpt.nTextSepCode;
76e0e0
@@ -1971,7 +1973,6 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
76e0e0
 
76e0e0
     SCCOL nStartCol = 0;
76e0e0
     SCROW nStartRow = 0;
76e0e0
-    SCTAB nTab = GetSaveTab();
76e0e0
     SCCOL nEndCol;
76e0e0
     SCROW nEndRow;
76e0e0
     m_aDocument.GetCellArea( nTab, nEndCol, nEndRow );
76e0e0
@@ -2389,35 +2390,129 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
76e0e0
     }
76e0e0
     else if (aFltName == pFilterAscii)
76e0e0
     {
76e0e0
-        SvStream* pStream = rMed.GetOutStream();
76e0e0
-        if (pStream)
76e0e0
+        OUString sItStr;
76e0e0
+        SfxItemSet*  pSet = rMed.GetItemSet();
76e0e0
+        const SfxPoolItem* pItem;
76e0e0
+        if ( pSet && SfxItemState::SET ==
76e0e0
+             pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
76e0e0
         {
76e0e0
-            OUString sItStr;
76e0e0
-            SfxItemSet*  pSet = rMed.GetItemSet();
76e0e0
-            const SfxPoolItem* pItem;
76e0e0
-            if ( pSet && SfxItemState::SET ==
76e0e0
-                 pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
76e0e0
+            sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
76e0e0
+        }
76e0e0
+
76e0e0
+        if ( sItStr.isEmpty() )
76e0e0
+        {
76e0e0
+            //  default for ascii export (from API without options):
76e0e0
+            //  ISO8859-1/MS_1252 encoding, comma, double quotes
76e0e0
+
76e0e0
+            ScImportOptions aDefOptions( ',', '"', RTL_TEXTENCODING_MS_1252 );
76e0e0
+            sItStr = aDefOptions.BuildString();
76e0e0
+        }
76e0e0
+
76e0e0
+        weld::WaitObject aWait( GetActiveDialogParent() );
76e0e0
+        ScImportOptions aOptions( sItStr );
76e0e0
+
76e0e0
+        if (aOptions.nSheetToExport)
76e0e0
+        {
76e0e0
+            // Only from command line --convert-to
76e0e0
+            bRet = true;
76e0e0
+
76e0e0
+            // Verbose only from command line, not UI (in case we actually
76e0e0
+            // implement that) nor macro filter options.
76e0e0
+            bool bVerbose = false;
76e0e0
+            const css::uno::Sequence<css::beans::PropertyValue> & rArgs = rMed.GetArgs();
76e0e0
+            const auto pProp = std::find_if( rArgs.begin(), rArgs.end(),
76e0e0
+                    [](const css::beans::PropertyValue& rProp) { return rProp.Name == "ConversionRequestOrigin"; });
76e0e0
+            if (pProp != rArgs.end())
76e0e0
             {
76e0e0
-                sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
76e0e0
+                OUString aOrigin;
76e0e0
+                pProp->Value >>= aOrigin;
76e0e0
+                bVerbose = (aOrigin == "CommandLine");
76e0e0
             }
76e0e0
 
76e0e0
-            if ( sItStr.isEmpty() )
76e0e0
+            SCTAB nStartTab;
76e0e0
+            SCTAB nCount = m_aDocument.GetTableCount();
76e0e0
+            if (aOptions.nSheetToExport == -1)
76e0e0
             {
76e0e0
-                //  default for ascii export (from API without options):
76e0e0
-                //  ISO8859-1/MS_1252 encoding, comma, double quotes
76e0e0
-
76e0e0
-                ScImportOptions aDefOptions( ',', '"', RTL_TEXTENCODING_MS_1252 );
76e0e0
-                sItStr = aDefOptions.BuildString();
76e0e0
+                // All sheets.
76e0e0
+                nStartTab = 0;
76e0e0
+            }
76e0e0
+            else if (0 < aOptions.nSheetToExport && aOptions.nSheetToExport <= nCount)
76e0e0
+            {
76e0e0
+                // One sheet, 1-based.
76e0e0
+                nCount = aOptions.nSheetToExport;
76e0e0
+                nStartTab = nCount - 1;
76e0e0
+            }
76e0e0
+            else
76e0e0
+            {
76e0e0
+                // Usage error, no export but log.
76e0e0
+                if (bVerbose)
76e0e0
+                {
76e0e0
+                    if (aOptions.nSheetToExport < 0)
76e0e0
+                        std::cout << "Bad sheet number string given." << std::endl;
76e0e0
+                    else
76e0e0
+                        std::cout << "No sheet number " << aOptions.nSheetToExport
76e0e0
+                            << ", number of sheets is " << nCount << std::endl;
76e0e0
+                }
76e0e0
+                nStartTab = 0;
76e0e0
+                nCount = 0;
76e0e0
+                SetError(SCERR_EXPORT_DATA);
76e0e0
+                bRet = false;
76e0e0
             }
76e0e0
 
76e0e0
-            weld::WaitObject aWait( GetActiveDialogParent() );
76e0e0
-            ScImportOptions aOptions( sItStr );
76e0e0
-            AsciiSave( *pStream, aOptions );
76e0e0
-            bRet = true;
76e0e0
+            INetURLObject aURLObject(rMed.GetURLObject());
76e0e0
+            OUString sExt = aURLObject.CutExtension();
76e0e0
+            OUString sBaseName = aURLObject.GetLastName();
76e0e0
+            aURLObject.CutLastName();
76e0e0
 
76e0e0
-            if (m_aDocument.GetTableCount() > 1)
76e0e0
-                if (!rMed.GetError())
76e0e0
-                    rMed.SetError(SCWARN_EXPORT_ASCII);
76e0e0
+            for (SCTAB i = nStartTab; i < nCount; ++i)
76e0e0
+            {
76e0e0
+                OUString sTabName;
76e0e0
+                if (!m_aDocument.GetName(i, sTabName))
76e0e0
+                    sTabName = OUString::number(i);
76e0e0
+                INetURLObject aSheetURLObject(aURLObject);
76e0e0
+                OUString sFileName = sBaseName + "-" + sTabName;
76e0e0
+                if (!sExt.isEmpty())
76e0e0
+                    sFileName = sFileName + "." + sExt;
76e0e0
+                aSheetURLObject.Append(sFileName);
76e0e0
+
76e0e0
+                // log similar to DispatchWatcher::executeDispatchRequests
76e0e0
+                OUString aOutFile = aSheetURLObject.GetMainURL(INetURLObject::DecodeMechanism::NONE);
76e0e0
+                if (bVerbose)
76e0e0
+                {
76e0e0
+                    OUString aDisplayedName;
76e0e0
+                    if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(aOutFile, aDisplayedName))
76e0e0
+                        aDisplayedName = aOutFile;
76e0e0
+                    std::cout << "Writing sheet " << OUStringToOString(sTabName, osl_getThreadTextEncoding()) << " -> "
76e0e0
+                                                  << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
76e0e0
+                                                  << std::endl;
76e0e0
+
76e0e0
+                    if (FStatHelper::IsDocument(aOutFile))
76e0e0
+                        std::cout << "Overwriting: " << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
76e0e0
+                                                     << std::endl ;
76e0e0
+                }
76e0e0
+
76e0e0
+                std::unique_ptr<SvStream> xStm = ::utl::UcbStreamHelper::CreateStream(aOutFile, StreamMode::TRUNC | StreamMode::WRITE);
76e0e0
+                if (!xStm)
76e0e0
+                {
76e0e0
+                    SetError(ERRCODE_IO_CANTCREATE);
76e0e0
+                    bRet = false;
76e0e0
+                    break;
76e0e0
+                }
76e0e0
+                AsciiSave(*xStm, aOptions, i);
76e0e0
+            }
76e0e0
+        }
76e0e0
+        else
76e0e0
+        {
76e0e0
+            SvStream* pStream = rMed.GetOutStream();
76e0e0
+            if (pStream)
76e0e0
+            {
76e0e0
+                AsciiSave(*pStream, aOptions, GetSaveTab());
76e0e0
+                bRet = true;
76e0e0
+
76e0e0
+                if (m_aDocument.GetTableCount() > 1)
76e0e0
+                    if (!rMed.GetError())
76e0e0
+                        rMed.SetError(SCWARN_EXPORT_ASCII);
76e0e0
+            }
76e0e0
         }
76e0e0
     }
76e0e0
     else if (aFltName == pFilterDBase)
76e0e0
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
76e0e0
index 41c0b30a42a8..3aa5f6caf311 100644
76e0e0
--- a/sc/source/ui/inc/docsh.hxx
76e0e0
+++ b/sc/source/ui/inc/docsh.hxx
76e0e0
@@ -227,7 +227,7 @@ public:
76e0e0
 
76e0e0
     ScDrawLayer*    MakeDrawLayer();
76e0e0
 
76e0e0
-    void            AsciiSave( SvStream& rStream, const ScImportOptions& rOpt );
76e0e0
+    void            AsciiSave( SvStream& rStream, const ScImportOptions& rOpt, SCTAB nTab );
76e0e0
 
76e0e0
     void            Execute( SfxRequest& rReq );
76e0e0
     void            GetState( SfxItemSet &rSet );
76e0e0
diff --git a/sc/source/ui/inc/imoptdlg.hxx b/sc/source/ui/inc/imoptdlg.hxx
76e0e0
index bac941c2a377..382067d67813 100644
76e0e0
--- a/sc/source/ui/inc/imoptdlg.hxx
76e0e0
+++ b/sc/source/ui/inc/imoptdlg.hxx
76e0e0
@@ -32,7 +32,8 @@ public:
76e0e0
         ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, rtl_TextEncoding nEnc )
76e0e0
             : nFieldSepCode(nFieldSep), nTextSepCode(nTextSep),
76e0e0
             bFixedWidth(false), bSaveAsShown(false), bQuoteAllText(false),
76e0e0
-            bSaveNumberAsSuch(true), bSaveFormulas(false), bRemoveSpace(false)
76e0e0
+            bSaveNumberAsSuch(true), bSaveFormulas(false), bRemoveSpace(false),
76e0e0
+            nSheetToExport(0)
76e0e0
         { SetTextEncoding( nEnc ); }
76e0e0
 
76e0e0
     ScImportOptions& operator=( const ScImportOptions& rCpy ) = default;
76e0e0
@@ -51,6 +52,9 @@ public:
76e0e0
     bool        bSaveNumberAsSuch;
76e0e0
     bool        bSaveFormulas;
76e0e0
     bool        bRemoveSpace;
76e0e0
+    // "0" for 'current sheet', "-1" for all sheets (each to a separate file),
76e0e0
+    // or 1-based specific sheet number (to a separate file).
76e0e0
+    sal_Int32   nSheetToExport;
76e0e0
 };
76e0e0
 
76e0e0
 #endif // INCLUDED_SC_SOURCE_UI_INC_IMOPTDLG_HXX
76e0e0
-- 
76e0e0
2.31.1
76e0e0