diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2017-06-25 17:49:28 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2017-06-25 17:49:28 +0200 |
commit | a3735079d820c4d98d878061a02ac48bb59d1c52 (patch) | |
tree | d0f85ff5e1260c25ac928396ea5b28bc912c9431 | |
parent | 960fbf5b6774f6d12b6cbddaba67f5788d68502f (diff) |
utiliser la détection automatique
Change-Id: I355396794a883e131698d56046b9226095dd8414
-rw-r--r-- | sc/source/ui/unoobj/filtuno.cxx | 37 |
1 files changed, 29 insertions, 8 deletions
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; } } |