Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "chinese_translationdialog.hxx"
31 : : #include "chinese_translationdialog.hrc"
32 : : #include "resid.hxx"
33 : : #include "chinese_dictionarydialog.hxx"
34 : : #include <com/sun/star/i18n/TextConversionOption.hpp>
35 : : // header for define RET_OK
36 : : #include <vcl/msgbox.hxx>
37 : : // header for class SvtLinguConfigItem
38 : : #include <unotools/lingucfg.hxx>
39 : : #include <unotools/linguprops.hxx>
40 : : #include "helpid.hrc"
41 : :
42 : : //disable compiler warning C4355: 'this' : used in base member initializer list
43 : : #ifdef _MSC_VER
44 : : # pragma warning (disable : 4355)
45 : : #endif
46 : :
47 : : //.............................................................................
48 : : namespace textconversiondlgs
49 : : {
50 : : //.............................................................................
51 : :
52 : : using namespace ::com::sun::star;
53 : : using namespace ::com::sun::star::uno;
54 : :
55 : 0 : ChineseTranslationDialog::ChineseTranslationDialog( Window* pParent )
56 : : : ModalDialog( pParent, TextConversionDlgs_ResId( DLG_CHINESETRANSLATION ) )
57 : : , m_aFL_Direction( this, TextConversionDlgs_ResId( FL_DIRECTION ) )
58 : : , m_aRB_To_Simplified( this, TextConversionDlgs_ResId( RB_TO_SIMPLIFIED ) )
59 : : , m_aRB_To_Traditional( this, TextConversionDlgs_ResId( RB_TO_TRADITIONAL ) )
60 : : , m_aCB_Use_Variants( this, TextConversionDlgs_ResId( CB_USE_VARIANTS ) )
61 : : , m_aFL_Commonterms( this, TextConversionDlgs_ResId( FL_COMMONTERMS ) )
62 : : , m_aCB_Translate_Commonterms( this, TextConversionDlgs_ResId( CB_TRANSLATE_COMMONTERMS ) )
63 : : , m_aPB_Editterms( this, TextConversionDlgs_ResId( PB_EDITTERMS ) )
64 : : , m_aFL_Bottomline( this, TextConversionDlgs_ResId( T_FL_BOTTOMLINE ) )
65 : : , m_aBP_OK( this, TextConversionDlgs_ResId( PB_OK ) )
66 : : , m_aBP_Cancel( this, TextConversionDlgs_ResId( PB_CANCEL ) )
67 : : , m_aBP_Help( this, TextConversionDlgs_ResId( PB_HELP ) )
68 : 0 : , m_pDictionaryDialog(0)
69 : : {
70 : 0 : FreeResource();
71 : :
72 : 0 : m_aRB_To_Simplified.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_SIMPLIFIED );
73 : 0 : m_aRB_To_Traditional.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_TRADITIONAL );
74 : 0 : m_aCB_Use_Variants.SetHelpId( HID_SVX_CHINESE_TRANSLATION_CB_USE_VARIANTS );
75 : :
76 : 0 : SvtLinguConfig aLngCfg;
77 : 0 : sal_Bool bValue = sal_Bool();
78 : 0 : Any aAny( aLngCfg.GetProperty( rtl::OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ) );
79 : 0 : aAny >>= bValue;
80 : 0 : if( bValue )
81 : 0 : m_aRB_To_Simplified.Check();
82 : : else
83 : 0 : m_aRB_To_Traditional.Check();
84 : :
85 : 0 : aAny = aLngCfg.GetProperty( rtl::OUString( UPN_IS_USE_CHARACTER_VARIANTS ) );
86 : 0 : if( aAny >>= bValue )
87 : 0 : m_aCB_Use_Variants.Check( bValue );
88 : :
89 : : // #117820# (search for other occurrences!)
90 : : // disable and hide that checkbox until it is decided if it is needed or not.
91 : : // If it is to be removed later the respective code needs to be removed as
92 : : // well, otherwise we just have to remove the next lines again.
93 : 0 : m_aCB_Use_Variants.Check( sal_False );
94 : 0 : m_aCB_Use_Variants.Enable( sal_False );
95 : 0 : m_aCB_Use_Variants.Show( sal_False );
96 : :
97 : 0 : aAny = aLngCfg.GetProperty( rtl::OUString( UPN_IS_TRANSLATE_COMMON_TERMS ) );
98 : 0 : if( aAny >>= bValue )
99 : 0 : m_aCB_Translate_Commonterms.Check( bValue );
100 : :
101 : 0 : m_aPB_Editterms.SetClickHdl( LINK( this, ChineseTranslationDialog, DictionaryHdl ) );
102 : 0 : m_aRB_To_Simplified.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
103 : 0 : m_aRB_To_Traditional.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
104 : 0 : m_aCB_Translate_Commonterms.SetClickHdl( LINK( this, ChineseTranslationDialog, CommonTermsHdl ) );
105 : 0 : m_aBP_OK.SetClickHdl( LINK( this, ChineseTranslationDialog, OkHdl ) );
106 : :
107 : 0 : impl_UpdateVariantsCheckBox();
108 : 0 : }
109 : :
110 : 0 : ChineseTranslationDialog::~ChineseTranslationDialog()
111 : : {
112 : 0 : if(m_pDictionaryDialog)
113 : : {
114 : 0 : if(m_pDictionaryDialog->IsInExecute())
115 : 0 : m_pDictionaryDialog->EndDialog();
116 : 0 : delete m_pDictionaryDialog;
117 : : }
118 : 0 : }
119 : :
120 : 0 : void ChineseTranslationDialog::getSettings( sal_Bool& rbDirectionToSimplified
121 : : , sal_Bool& rbUseCharacterVariants
122 : : , sal_Bool& rbTranslateCommonTerms ) const
123 : : {
124 : 0 : rbDirectionToSimplified = m_aRB_To_Simplified.IsChecked();
125 : 0 : rbUseCharacterVariants = m_aCB_Use_Variants.IsChecked();
126 : 0 : rbTranslateCommonTerms = m_aCB_Translate_Commonterms.IsChecked();
127 : 0 : }
128 : :
129 : 0 : void ChineseTranslationDialog::impl_UpdateVariantsCheckBox()
130 : : {
131 : : // #117820# (search for other occurrences!)
132 : : // m_aCB_Use_Variants.Enable( m_aRB_To_Traditional.IsChecked() );
133 : 0 : }
134 : :
135 : 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, DirectionHdl)
136 : : {
137 : 0 : impl_UpdateVariantsCheckBox();
138 : 0 : return 0;
139 : : }
140 : :
141 : 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, CommonTermsHdl)
142 : : {
143 : : // #117820# (search for other occurrences!)
144 : : // if( m_aCB_Translate_Commonterms.IsChecked() && m_aRB_To_Traditional.IsChecked() )
145 : : // m_aCB_Use_Variants.Check( true );
146 : 0 : return 0;
147 : : }
148 : :
149 : 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, OkHdl)
150 : : {
151 : : //save settings to configuration
152 : 0 : SvtLinguConfig aLngCfg;
153 : 0 : Any aAny;
154 : 0 : aAny <<= sal_Bool( !!m_aRB_To_Simplified.IsChecked() );
155 : 0 : aLngCfg.SetProperty( rtl::OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ), aAny );
156 : 0 : aAny <<= sal_Bool( !!m_aCB_Use_Variants.IsChecked() );
157 : 0 : aLngCfg.SetProperty( rtl::OUString( UPN_IS_USE_CHARACTER_VARIANTS ), aAny );
158 : 0 : aAny <<= sal_Bool( !!m_aCB_Translate_Commonterms.IsChecked() );
159 : 0 : aLngCfg.SetProperty( rtl::OUString( UPN_IS_TRANSLATE_COMMON_TERMS ), aAny );
160 : :
161 : 0 : EndDialog( RET_OK );
162 : 0 : return 0;
163 : : }
164 : :
165 : 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, DictionaryHdl)
166 : : {
167 : 0 : if( !m_pDictionaryDialog )
168 : : {
169 : 0 : m_pDictionaryDialog = new ChineseDictionaryDialog(this);
170 : : }
171 : 0 : if( m_pDictionaryDialog )
172 : : {
173 : 0 : if( m_pDictionaryDialog->IsInExecute() )
174 : : {
175 : 0 : if( !m_pDictionaryDialog->IsReallyVisible() )
176 : : {
177 : 0 : m_pDictionaryDialog->ToTop();
178 : 0 : m_pDictionaryDialog->GrabFocusToFirstControl();
179 : : }
180 : : }
181 : : else
182 : : {
183 : 0 : sal_Int32 nTextConversionOptions = i18n::TextConversionOption::NONE;
184 : 0 : if( !m_aCB_Translate_Commonterms.IsChecked() )
185 : 0 : nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
186 : 0 : if( m_aCB_Use_Variants.IsChecked() )
187 : 0 : nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::USE_CHARACTER_VARIANTS;
188 : :
189 : 0 : m_pDictionaryDialog->setDirectionAndTextConversionOptions( m_aRB_To_Simplified.IsChecked(), nTextConversionOptions );
190 : 0 : m_pDictionaryDialog->Execute();
191 : : }
192 : : }
193 : 0 : return 0;
194 : : }
195 : :
196 : : //.............................................................................
197 : : } //end namespace
198 : : //.............................................................................
199 : :
200 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|