| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 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 . |
| 18 |
*/ |
| 19 |
|
| 20 |
|
| 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> |
| 26 |
|
| 27 |
namespace textconversiondlgs |
| 28 |
{ |
| 29 |
|
| 30 |
using namespace ::com::sun::star; |
| 31 |
using namespace ::com::sun::star::uno; |
| 32 |
|
| 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)) |
| 40 |
{ |
| 41 |
SvtLinguConfig aLngCfg; |
| 42 |
bool bValue = false; |
| 43 |
Any aAny( aLngCfg.GetProperty( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ); |
| 44 |
aAny >>= bValue; |
| 45 |
if( bValue ) |
| 46 |
m_xRB_To_Simplified->set_active(true); |
| 47 |
else |
| 48 |
m_xRB_To_Traditional->set_active(true); |
| 49 |
|
| 50 |
aAny = aLngCfg.GetProperty( UPN_IS_TRANSLATE_COMMON_TERMS ); |
| 51 |
if( aAny >>= bValue ) |
| 52 |
m_xCB_Translate_Commonterms->set_active( bValue ); |
| 53 |
|
| 54 |
m_xPB_Editterms->connect_clicked( LINK( this, ChineseTranslationDialog, DictionaryHdl ) ); |
| 55 |
m_xBP_OK->connect_clicked( LINK( this, ChineseTranslationDialog, OkHdl ) ); |
| 56 |
} |
| 57 |
|
| 58 |
ChineseTranslationDialog::~ChineseTranslationDialog() |
| 59 |
{ |
| 60 |
} |
| 61 |
|
| 62 |
void ChineseTranslationDialog::getSettings( bool& rbDirectionToSimplified |
| 63 |
, bool& rbTranslateCommonTerms ) const |
| 64 |
{ |
| 65 |
rbDirectionToSimplified = m_xRB_To_Simplified->get_active(); |
| 66 |
rbTranslateCommonTerms = m_xCB_Translate_Commonterms->get_active(); |
| 67 |
} |
| 68 |
|
| 69 |
IMPL_LINK_NOARG(ChineseTranslationDialog, OkHdl, weld::Button&, void) |
| 70 |
{ |
| 71 |
//save settings to configuration |
| 72 |
SvtLinguConfig aLngCfg; |
| 73 |
Any aAny; |
| 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 ); |
| 78 |
|
| 79 |
m_xDialog->response(RET_OK); |
| 80 |
} |
| 81 |
|
| 82 |
IMPL_LINK_NOARG(ChineseTranslationDialog, DictionaryHdl, weld::Button&, void) |
| 83 |
{ |
| 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(); |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
} //end namespace |
| 95 |
|
| 96 |
|
| 97 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |