Line data Source code
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 "resid.hxx"
23 : #include "chinese_dictionarydialog.hxx"
24 : #include <com/sun/star/i18n/TextConversionOption.hpp>
25 : // header for define RET_OK
26 : #include <vcl/msgbox.hxx>
27 : // header for class SvtLinguConfigItem
28 : #include <unotools/lingucfg.hxx>
29 : #include <unotools/linguprops.hxx>
30 : #include "helpid.hrc"
31 :
32 : //disable compiler warning C4355: 'this' : used in base member initializer list
33 : #ifdef _MSC_VER
34 : # pragma warning (disable : 4355)
35 : #endif
36 :
37 : //.............................................................................
38 : namespace textconversiondlgs
39 : {
40 : //.............................................................................
41 :
42 : using namespace ::com::sun::star;
43 : using namespace ::com::sun::star::uno;
44 :
45 0 : ChineseTranslationDialog::ChineseTranslationDialog( Window* pParent )
46 : : ModalDialog(pParent, "ChineseConversionDialog", "svx/ui/chineseconversiondialog.ui")
47 0 : , m_pDictionaryDialog(0)
48 : {
49 0 : get(m_pBP_OK, "ok");
50 0 : get(m_pPB_Editterms, "editterms");
51 0 : get(m_pRB_To_Simplified, "tosimplified");
52 0 : get(m_pRB_To_Traditional, "totraditional");
53 0 : get(m_pCB_Translate_Commonterms, "commonterms");
54 :
55 0 : m_pRB_To_Simplified->SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_SIMPLIFIED );
56 0 : m_pRB_To_Traditional->SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_TRADITIONAL );
57 :
58 0 : SvtLinguConfig aLngCfg;
59 0 : sal_Bool bValue = sal_Bool();
60 0 : Any aAny( aLngCfg.GetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ) );
61 0 : aAny >>= bValue;
62 0 : if( bValue )
63 0 : m_pRB_To_Simplified->Check();
64 : else
65 0 : m_pRB_To_Traditional->Check();
66 :
67 0 : aAny = aLngCfg.GetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS ) );
68 0 : if( aAny >>= bValue )
69 0 : m_pCB_Translate_Commonterms->Check( bValue );
70 :
71 0 : m_pPB_Editterms->SetClickHdl( LINK( this, ChineseTranslationDialog, DictionaryHdl ) );
72 0 : m_pBP_OK->SetClickHdl( LINK( this, ChineseTranslationDialog, OkHdl ) );
73 0 : }
74 :
75 0 : ChineseTranslationDialog::~ChineseTranslationDialog()
76 : {
77 0 : if(m_pDictionaryDialog)
78 : {
79 0 : if(m_pDictionaryDialog->IsInExecute())
80 0 : m_pDictionaryDialog->EndDialog();
81 0 : delete m_pDictionaryDialog;
82 : }
83 0 : }
84 :
85 0 : void ChineseTranslationDialog::getSettings( sal_Bool& rbDirectionToSimplified
86 : , sal_Bool& rbTranslateCommonTerms ) const
87 : {
88 0 : rbDirectionToSimplified = m_pRB_To_Simplified->IsChecked();
89 0 : rbTranslateCommonTerms = m_pCB_Translate_Commonterms->IsChecked();
90 0 : }
91 :
92 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, OkHdl)
93 : {
94 : //save settings to configuration
95 0 : SvtLinguConfig aLngCfg;
96 0 : Any aAny;
97 0 : aAny <<= sal_Bool( !!m_pRB_To_Simplified->IsChecked() );
98 0 : aLngCfg.SetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ), aAny );
99 0 : aAny <<= sal_Bool( !!m_pCB_Translate_Commonterms->IsChecked() );
100 0 : aLngCfg.SetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS ), aAny );
101 :
102 0 : EndDialog( RET_OK );
103 0 : return 0;
104 : }
105 :
106 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, DictionaryHdl)
107 : {
108 0 : if( !m_pDictionaryDialog )
109 : {
110 0 : m_pDictionaryDialog = new ChineseDictionaryDialog(this);
111 : }
112 0 : if( m_pDictionaryDialog )
113 : {
114 0 : if( m_pDictionaryDialog->IsInExecute() )
115 : {
116 0 : if( !m_pDictionaryDialog->IsReallyVisible() )
117 : {
118 0 : m_pDictionaryDialog->ToTop();
119 0 : m_pDictionaryDialog->GrabFocusToFirstControl();
120 : }
121 : }
122 : else
123 : {
124 0 : sal_Int32 nTextConversionOptions = i18n::TextConversionOption::NONE;
125 0 : if( !m_pCB_Translate_Commonterms->IsChecked() )
126 0 : nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
127 0 : m_pDictionaryDialog->setDirectionAndTextConversionOptions( m_pRB_To_Simplified->IsChecked(), nTextConversionOptions );
128 0 : m_pDictionaryDialog->Execute();
129 : }
130 : }
131 0 : return 0;
132 : }
133 :
134 : //.............................................................................
135 0 : } //end namespace
136 : //.............................................................................
137 :
138 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|