[Libreoffice-commits] core.git: Branch 'private/lmamane/for-julien2412' - sc/source

Lionel Elie Mamane lionel at mamane.lu
Sun Jun 25 15:50:03 UTC 2017


 sc/source/ui/unoobj/filtuno.cxx |   37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

New commits:
commit a3735079d820c4d98d878061a02ac48bb59d1c52
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Sun Jun 25 17:49:28 2017 +0200

    utiliser la détection automatique
    
    Change-Id: I355396794a883e131698d56046b9226095dd8414

diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index 3b82771df6ae..2fdea70d8d11 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -298,6 +298,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException, st
         bool bMultiByte = true;
         bool bDBEnc     = false;
         bool bAscii     = false;
+        bool skipDialog = false;
 
         sal_Unicode cStrDel = '"';
         sal_Unicode cAsciiDel = ';';
@@ -339,7 +340,11 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException, st
                 //  dBase import
                 aTitle = ScGlobal::GetRscString( STR_IMPORT_DBF );
             }
-            load_CharSet( eEncoding, bExport );
+            switch(load_CharSet( eEncoding, bExport, aFileName ))
+            {
+            case charset_from_file:
+                skipDialog = true;
+            }
             bDBEnc = true;
         }
         else if ( aFilterString == ScDocShell::GetDifFilterName() )
@@ -359,20 +364,36 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException, st
         }
 
         ScImportOptions aOptions( cAsciiDel, cStrDel, eEncoding);
-
-        ScopedVclPtr<AbstractScImportOptionsDlg> pDlg(pFact->CreateScImportOptionsDlg(
+        if(skipDialog)
+        {
+            // TODO: check we are not missing some of the stuff that ScImportOptionsDlg::GetImportOptions
+            // (file sc/source/ui/dbgui/scuiimoptdlg.cxx) does
+            // that is, if the dialog sets options that are not selected by the user (!)
+            // then we are missing them here.
+            // Then we may need to rip them out of the dialog.
+            // Or we actually change the dialog to not display if skipDialog==true
+            // in that case, add an argument skipDialog to CreateScImportOptionsDlg
+            nRet = ui::dialogs::ExecutableDialogResults::OK;
+        }
+        else
+        {
+            ScopedVclPtr<AbstractScImportOptionsDlg> pDlg(pFact->CreateScImportOptionsDlg(
                                                                             bAscii, &aOptions, &aTitle, bMultiByte, bDBEnc,
                                                                             !bExport));
-        OSL_ENSURE(pDlg, "Dialog create fail!");
-        if ( pDlg->Execute() == RET_OK )
+            OSL_ENSURE(pDlg, "Dialog create fail!");
+            if ( pDlg->Execute() == RET_OK )
+            {
+                pDlg->GetImportOptions( aOptions );
+                save_CharSet( aOptions.eCharSet, bExport );
+                nRet = ui::dialogs::ExecutableDialogResults::OK;
+            }
+        }
+        if (nRet == ui::dialogs::ExecutableDialogResults::OK)
         {
-            pDlg->GetImportOptions( aOptions );
-            save_CharSet( aOptions.eCharSet, bExport );
             if ( bAscii )
                 aFilterOptions = aOptions.BuildString();
             else
                 aFilterOptions = aOptions.aStrFont;
-            nRet = ui::dialogs::ExecutableDialogResults::OK;
         }
     }
 


More information about the Libreoffice-commits mailing list