diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2017-06-25 17:49:28 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2017-07-02 11:55:32 +0200 |
commit | 1ca5ed457e0851e574e6c070577f39de4ecfd425 (patch) | |
tree | 82bd3e2b45480c379fd55a533b4a5a77ad616f21 | |
parent | 58ad75baeafd9ca1835a6405dd03c0b65b08871e (diff) |
utiliser la détection automatique
Change-Id: I355396794a883e131698d56046b9226095dd8414
-rw-r--r-- | sc/source/ui/unoobj/filtuno.cxx | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx index c7b88e5fd345..09a6a78a9867 100644 --- a/sc/source/ui/unoobj/filtuno.cxx +++ b/sc/source/ui/unoobj/filtuno.cxx @@ -292,6 +292,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() { bool bDBEnc = false; bool bAscii = false; + bool skipDialog = false; sal_Unicode const cStrDel = '"'; sal_Unicode cAsciiDel = ';'; @@ -333,7 +334,11 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() // 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() ) @@ -353,21 +358,37 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() } ScImportOptions aOptions( cAsciiDel, cStrDel, eEncoding); - - ScopedVclPtr<AbstractScImportOptionsDlg> pDlg(pFact->CreateScImportOptionsDlg( - bAscii, &aOptions, &aTitle, true/*bMultiByte*/, bDBEnc, - !bExport)); - OSL_ENSURE(pDlg, "Dialog create fail!"); - if ( pDlg->Execute() == RET_OK ) + 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/*bMultiByte*/, + bDBEnc, !bExport)); + OSL_ENSURE(pDlg, "Dialog create fail!"); + if ( pDlg->Execute() == RET_OK ) + { + pDlg->SaveImportOptions(); + pDlg->GetImportOptions( aOptions ); + save_CharSet( aOptions.eCharSet, bExport ); + nRet = ui::dialogs::ExecutableDialogResults::OK; + } + } + if (nRet == ui::dialogs::ExecutableDialogResults::OK) { - pDlg->SaveImportOptions(); - pDlg->GetImportOptions( aOptions ); - save_CharSet( aOptions.eCharSet, bExport ); if ( bAscii ) aFilterOptions = aOptions.BuildString(); else aFilterOptions = aOptions.aStrFont; - nRet = ui::dialogs::ExecutableDialogResults::OK; } } |