1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 #undef SC_DLLIMPLEMENTATION
28 
29 //------------------------------------------------------------------------
30 
31 #include "textimportoptions.hxx"
32 #include "textimportoptions.hrc"
33 
34 #include "scresid.hxx"
35 #include "vcl/window.hxx"
36 #include "vcl/msgbox.hxx"
37 #include "vcl/svapp.hxx"
38 
39 ScTextImportOptionsDlg::ScTextImportOptionsDlg(Window* pParent) :
40     ModalDialog(pParent, ScResId(RID_SCDLG_TEXT_IMPORT_OPTIONS)),
41 
42     maBtnOk(this, ScResId(BTN_OK)),
43     maBtnCancel(this, ScResId(BTN_CANCEL)),
44     maBtnHelp(this, ScResId(BTN_HELP)),
45     maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)),
46     maRbAutomatic(this, ScResId(RB_AUTOMATIC)),
47     maRbCustom(this, ScResId(RB_CUSTOM)),
48     maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)),
49     maFlOption(this, ScResId(FL_OPTION)),
50     maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE))
51 {
52     FreeResource();
53     init();
54 }
55 
56 ScTextImportOptionsDlg::~ScTextImportOptionsDlg()
57 {
58 }
59 
60 short ScTextImportOptionsDlg::Execute()
61 {
62     return ModalDialog::Execute();
63 }
64 
65 LanguageType ScTextImportOptionsDlg::getLanguageType() const
66 {
67     if (maRbAutomatic.IsChecked())
68         return LANGUAGE_SYSTEM;
69 
70     return maLbCustomLang.GetSelectLanguage();
71 }
72 
73 bool ScTextImportOptionsDlg::isDateConversionSet() const
74 {
75     return maBtnConvertDate.IsChecked();
76 }
77 
78 void ScTextImportOptionsDlg::init()
79 {
80     Link aLink = LINK( this, ScTextImportOptionsDlg, OKHdl );
81     maBtnOk.SetClickHdl(aLink);
82     aLink = LINK( this, ScTextImportOptionsDlg, RadioHdl );
83     maRbAutomatic.SetClickHdl(aLink);
84     maRbCustom.SetClickHdl(aLink);
85 
86     maRbAutomatic.Check(true);
87 
88     maLbCustomLang.SetLanguageList(
89         LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
90 
91     LanguageType eLang = Application::GetSettings().GetLanguage();
92     maLbCustomLang.SelectLanguage(eLang);
93     maLbCustomLang.Disable();
94 }
95 
96 IMPL_LINK( ScTextImportOptionsDlg, OKHdl, OKButton*, EMPTYARG )
97 {
98     EndDialog(RET_OK);
99     return 0;
100 }
101 
102 IMPL_LINK( ScTextImportOptionsDlg, RadioHdl, RadioButton*, pBtn )
103 {
104     if (pBtn == &maRbAutomatic)
105     {
106         maLbCustomLang.Disable();
107     }
108     else if (pBtn == &maRbCustom)
109     {
110         maLbCustomLang.Enable();
111     }
112     return 0;
113 }
114 
115