Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx
Line
Count
Source
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
#include <vcl/vclenum.hxx>
27
#include <vcl/weld/Builder.hxx>
28
#include <vcl/weld/Dialog.hxx>
29
30
namespace textconversiondlgs
31
{
32
33
using namespace ::com::sun::star;
34
using namespace ::com::sun::star::uno;
35
36
ChineseTranslationDialog::ChineseTranslationDialog(weld::Window* pParent)
37
0
    : GenericDialogController(pParent, u"svx/ui/chineseconversiondialog.ui"_ustr, u"ChineseConversionDialog"_ustr)
38
0
    , m_xBP_OK(m_xBuilder->weld_button(u"ok"_ustr))
39
0
    , m_xPB_Editterms(m_xBuilder->weld_button(u"editterms"_ustr))
40
0
    , m_xRB_To_Simplified(m_xBuilder->weld_radio_button(u"tosimplified"_ustr))
41
0
    , m_xRB_To_Traditional(m_xBuilder->weld_radio_button(u"totraditional"_ustr))
42
0
    , m_xCB_Translate_Commonterms(m_xBuilder->weld_check_button(u"commonterms"_ustr))
43
0
{
44
0
    SvtLinguConfig  aLngCfg;
45
0
    bool bValue = false;
46
0
    Any aAny( aLngCfg.GetProperty( UPN_IS_DIRECTION_TO_SIMPLIFIED ) );
47
0
    aAny >>= bValue;
48
0
    if( bValue )
49
0
        m_xRB_To_Simplified->set_active(true);
50
0
    else
51
0
        m_xRB_To_Traditional->set_active(true);
52
53
0
    aAny = aLngCfg.GetProperty( UPN_IS_TRANSLATE_COMMON_TERMS );
54
0
    if( aAny >>= bValue )
55
0
        m_xCB_Translate_Commonterms->set_active( bValue );
56
57
0
    m_xPB_Editterms->connect_clicked( LINK( this, ChineseTranslationDialog, DictionaryHdl ) );
58
0
    m_xBP_OK->connect_clicked( LINK( this, ChineseTranslationDialog, OkHdl ) );
59
0
}
60
61
ChineseTranslationDialog::~ChineseTranslationDialog()
62
0
{
63
0
}
64
65
void ChineseTranslationDialog::getSettings( bool& rbDirectionToSimplified
66
                                          , bool& rbTranslateCommonTerms ) const
67
0
{
68
0
    rbDirectionToSimplified = m_xRB_To_Simplified->get_active();
69
0
    rbTranslateCommonTerms = m_xCB_Translate_Commonterms->get_active();
70
0
}
71
72
IMPL_LINK_NOARG(ChineseTranslationDialog, OkHdl, weld::Button&, void)
73
0
{
74
    //save settings to configuration
75
0
    SvtLinguConfig  aLngCfg;
76
0
    Any aAny;
77
0
    aAny <<= m_xRB_To_Simplified->get_active();
78
0
    aLngCfg.SetProperty( UPN_IS_DIRECTION_TO_SIMPLIFIED, aAny );
79
0
    aAny <<= m_xCB_Translate_Commonterms->get_active();
80
0
    aLngCfg.SetProperty( UPN_IS_TRANSLATE_COMMON_TERMS, aAny );
81
82
0
    m_xDialog->response(RET_OK);
83
0
}
84
85
IMPL_LINK_NOARG(ChineseTranslationDialog, DictionaryHdl, weld::Button&, void)
86
0
{
87
0
    if( !m_xDictionaryDialog )
88
0
        m_xDictionaryDialog.reset(new ChineseDictionaryDialog(m_xDialog.get()));
89
0
    sal_Int32 nTextConversionOptions = i18n::TextConversionOption::NONE;
90
0
    if (!m_xCB_Translate_Commonterms->get_active())
91
0
        nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
92
0
    m_xDictionaryDialog->setDirectionAndTextConversionOptions(m_xRB_To_Simplified->get_active(), nTextConversionOptions);
93
0
    m_xDictionaryDialog->run();
94
0
}
95
96
97
} //end namespace
98
99
100
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */