1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #undef SC_DLLIMPLEMENTATION
22 #include <textimportoptions.hxx>
23 #include <svx/langbox.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/settings.hxx>
26 #include <i18nlangtag/languagetag.hxx>
28 ScTextImportOptionsDlg::ScTextImportOptionsDlg(weld::Window
* pParent
)
29 : GenericDialogController(pParent
, u
"modules/scalc/ui/textimportoptions.ui"_ustr
, u
"TextImportOptionsDialog"_ustr
)
30 , m_xBtnOk(m_xBuilder
->weld_button(u
"ok"_ustr
))
31 , m_xRbAutomatic(m_xBuilder
->weld_radio_button(u
"automatic"_ustr
))
32 , m_xRbCustom(m_xBuilder
->weld_radio_button(u
"custom"_ustr
))
33 , m_xCkbConvertDate(m_xBuilder
->weld_check_button(u
"convertdata"_ustr
))
34 , m_xCkbConvertScientific(m_xBuilder
->weld_check_button(u
"convertscientificnotation"_ustr
))
35 , m_xCkbKeepAsking(m_xBuilder
->weld_check_button(u
"keepasking"_ustr
))
36 , m_xLbCustomLang(new SvxLanguageBox(m_xBuilder
->weld_combo_box(u
"lang"_ustr
)))
41 ScTextImportOptionsDlg::~ScTextImportOptionsDlg()
45 LanguageType
ScTextImportOptionsDlg::getLanguageType() const
47 if (m_xRbAutomatic
->get_active())
48 return LANGUAGE_SYSTEM
;
50 return m_xLbCustomLang
->get_active_id();
53 bool ScTextImportOptionsDlg::isDateConversionSet() const
55 return m_xCkbConvertDate
->get_active();
58 bool ScTextImportOptionsDlg::isScientificConversionSet() const
60 return m_xCkbConvertScientific
->get_active();
63 bool ScTextImportOptionsDlg::isKeepAskingSet() const
65 return m_xCkbKeepAsking
->get_active();
68 void ScTextImportOptionsDlg::init()
70 m_xBtnOk
->connect_clicked(LINK(this, ScTextImportOptionsDlg
, OKHdl
));
71 Link
<weld::Toggleable
&,void> aLink
= LINK(this, ScTextImportOptionsDlg
, RadioCheckHdl
);
72 m_xRbAutomatic
->connect_toggled(aLink
);
73 m_xRbCustom
->connect_toggled(aLink
);
74 m_xCkbConvertDate
->connect_toggled(aLink
);
75 m_xCkbConvertScientific
->connect_toggled(aLink
);
77 m_xRbAutomatic
->set_active(true);
79 m_xLbCustomLang
->SetLanguageList(
80 SvxLanguageListFlags::ALL
| SvxLanguageListFlags::ONLY_KNOWN
, false);
82 LanguageType eLang
= Application::GetSettings().GetLanguageTag().getLanguageType();
83 m_xLbCustomLang
->set_active_id(eLang
);
84 m_xLbCustomLang
->set_sensitive(false);
87 IMPL_LINK_NOARG(ScTextImportOptionsDlg
, OKHdl
, weld::Button
&, void)
89 m_xDialog
->response(RET_OK
);
92 IMPL_LINK(ScTextImportOptionsDlg
, RadioCheckHdl
, weld::Toggleable
&, rBtn
, void)
94 if (&rBtn
== m_xRbAutomatic
.get())
96 m_xLbCustomLang
->set_sensitive(false);
98 else if (&rBtn
== m_xRbCustom
.get())
100 m_xLbCustomLang
->set_sensitive(true);
102 else if (&rBtn
== m_xCkbConvertDate
.get())
104 if (m_xCkbConvertDate
->get_active())
106 m_xCkbConvertScientific
->set_active(true);
107 m_xCkbConvertScientific
->set_sensitive(false);
111 m_xCkbConvertScientific
->set_sensitive(true);
114 else if (&rBtn
== m_xCkbConvertScientific
.get())
116 assert( !m_xCkbConvertDate
->get_active() && "ScTextImportOptionsDlg::RadioCheckHdl - scientific option disabled if Detect numbers active" );
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */