1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2008 by Sun Microsystems, Inc.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * $RCSfile: langbox.hxx,v $
10  * $Revision: 1.4.242.1 $
11  *
12  * This file is part of OpenOffice.org.
13  *
14  * OpenOffice.org is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU Lesser General Public License version 3
16  * only, as published by the Free Software Foundation.
17  *
18  * OpenOffice.org is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU Lesser General Public License version 3 for more details
22  * (a copy is included in the LICENSE file that accompanied this code).
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * version 3 along with OpenOffice.org.  If not, see
26  * <http://www.openoffice.org/license.html>
27  * for a copy of the LGPLv3 License.
28  *
29  ************************************************************************/
30 
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
33 
34 #undef SC_DLLIMPLEMENTATION
35 
36 //------------------------------------------------------------------------
37 
38 #include "textimportoptions.hxx"
39 #include "textimportoptions.hrc"
40 
41 #include "scresid.hxx"
42 #include "vcl/window.hxx"
43 #include "vcl/msgbox.hxx"
44 #include "vcl/svapp.hxx"
45 
46 ScTextImportOptionsDlg::ScTextImportOptionsDlg(Window* pParent) :
47     ModalDialog(pParent, ScResId(RID_SCDLG_TEXT_IMPORT_OPTIONS)),
48 
49     maBtnOk(this, ScResId(BTN_OK)),
50     maBtnCancel(this, ScResId(BTN_CANCEL)),
51     maBtnHelp(this, ScResId(BTN_HELP)),
52     maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)),
53     maRbAutomatic(this, ScResId(RB_AUTOMATIC)),
54     maRbCustom(this, ScResId(RB_CUSTOM)),
55     maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)),
56     maFlOption(this, ScResId(FL_OPTION)),
57     maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE))
58 {
59     FreeResource();
60     init();
61 }
62 
63 ScTextImportOptionsDlg::~ScTextImportOptionsDlg()
64 {
65 }
66 
67 short ScTextImportOptionsDlg::Execute()
68 {
69     return ModalDialog::Execute();
70 }
71 
72 LanguageType ScTextImportOptionsDlg::getLanguageType() const
73 {
74     if (maRbAutomatic.IsChecked())
75         return LANGUAGE_SYSTEM;
76 
77     return maLbCustomLang.GetSelectLanguage();
78 }
79 
80 bool ScTextImportOptionsDlg::isDateConversionSet() const
81 {
82     return maBtnConvertDate.IsChecked();
83 }
84 
85 void ScTextImportOptionsDlg::init()
86 {
87     Link aLink = LINK( this, ScTextImportOptionsDlg, OKHdl );
88     maBtnOk.SetClickHdl(aLink);
89     aLink = LINK( this, ScTextImportOptionsDlg, RadioHdl );
90     maRbAutomatic.SetClickHdl(aLink);
91     maRbCustom.SetClickHdl(aLink);
92 
93     maRbAutomatic.Check(true);
94 
95     maLbCustomLang.SetLanguageList(
96         LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
97 
98     LanguageType eLang = Application::GetSettings().GetLanguage();
99     maLbCustomLang.SelectLanguage(eLang);
100     maLbCustomLang.Disable();
101 }
102 
103 IMPL_LINK( ScTextImportOptionsDlg, OKHdl, OKButton*, EMPTYARG )
104 {
105     EndDialog(RET_OK);
106     return 0;
107 }
108 
109 IMPL_LINK( ScTextImportOptionsDlg, RadioHdl, RadioButton*, pBtn )
110 {
111     if (pBtn == &maRbAutomatic)
112     {
113         maLbCustomLang.Disable();
114     }
115     else if (pBtn == &maRbCustom)
116     {
117         maLbCustomLang.Enable();
118     }
119     return 0;
120 }
121 
122