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 .
21 #include "chinese_translationdialog.hxx"
22 #include "chinese_dictionarydialog.hxx"
23 #include <com/sun/star/i18n/TextConversionOption.hpp>
24 #include <unotools/lingucfg.hxx>
25 #include <unotools/linguprops.hxx>
27 namespace textconversiondlgs
30 using namespace ::com::sun::star
;
31 using namespace ::com::sun::star::uno
;
33 ChineseTranslationDialog::ChineseTranslationDialog(weld::Window
* pParent
)
34 : GenericDialogController(pParent
, u
"svx/ui/chineseconversiondialog.ui"_ustr
, u
"ChineseConversionDialog"_ustr
)
35 , m_xBP_OK(m_xBuilder
->weld_button(u
"ok"_ustr
))
36 , m_xPB_Editterms(m_xBuilder
->weld_button(u
"editterms"_ustr
))
37 , m_xRB_To_Simplified(m_xBuilder
->weld_radio_button(u
"tosimplified"_ustr
))
38 , m_xRB_To_Traditional(m_xBuilder
->weld_radio_button(u
"totraditional"_ustr
))
39 , m_xCB_Translate_Commonterms(m_xBuilder
->weld_check_button(u
"commonterms"_ustr
))
41 SvtLinguConfig aLngCfg
;
43 Any
aAny( aLngCfg
.GetProperty( UPN_IS_DIRECTION_TO_SIMPLIFIED
) );
46 m_xRB_To_Simplified
->set_active(true);
48 m_xRB_To_Traditional
->set_active(true);
50 aAny
= aLngCfg
.GetProperty( UPN_IS_TRANSLATE_COMMON_TERMS
);
52 m_xCB_Translate_Commonterms
->set_active( bValue
);
54 m_xPB_Editterms
->connect_clicked( LINK( this, ChineseTranslationDialog
, DictionaryHdl
) );
55 m_xBP_OK
->connect_clicked( LINK( this, ChineseTranslationDialog
, OkHdl
) );
58 ChineseTranslationDialog::~ChineseTranslationDialog()
62 void ChineseTranslationDialog::getSettings( bool& rbDirectionToSimplified
63 , bool& rbTranslateCommonTerms
) const
65 rbDirectionToSimplified
= m_xRB_To_Simplified
->get_active();
66 rbTranslateCommonTerms
= m_xCB_Translate_Commonterms
->get_active();
69 IMPL_LINK_NOARG(ChineseTranslationDialog
, OkHdl
, weld::Button
&, void)
71 //save settings to configuration
72 SvtLinguConfig aLngCfg
;
74 aAny
<<= m_xRB_To_Simplified
->get_active();
75 aLngCfg
.SetProperty( UPN_IS_DIRECTION_TO_SIMPLIFIED
, aAny
);
76 aAny
<<= m_xCB_Translate_Commonterms
->get_active();
77 aLngCfg
.SetProperty( UPN_IS_TRANSLATE_COMMON_TERMS
, aAny
);
79 m_xDialog
->response(RET_OK
);
82 IMPL_LINK_NOARG(ChineseTranslationDialog
, DictionaryHdl
, weld::Button
&, void)
84 if( !m_xDictionaryDialog
)
85 m_xDictionaryDialog
.reset(new ChineseDictionaryDialog(m_xDialog
.get()));
86 sal_Int32 nTextConversionOptions
= i18n::TextConversionOption::NONE
;
87 if (!m_xCB_Translate_Commonterms
->get_active())
88 nTextConversionOptions
= nTextConversionOptions
| i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
89 m_xDictionaryDialog
->setDirectionAndTextConversionOptions(m_xRB_To_Simplified
->get_active(), nTextConversionOptions
);
90 m_xDictionaryDialog
->run();
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */