merge the formfield patch from ooo-build
[ooovba.git] / svx / source / unodialogs / textconversiondlgs / chinese_translationdialog.cxx
blob85cb9a96765ded0e40619abdb3eeb6bc41f3e9b7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chinese_translationdialog.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "chinese_translationdialog.hxx"
35 #include "chinese_translationdialog.hrc"
36 #include "resid.hxx"
37 #include "chinese_dictionarydialog.hxx"
38 #include <com/sun/star/i18n/TextConversionOption.hpp>
39 // header for define RET_OK
40 #include <vcl/msgbox.hxx>
41 // header for class SvtLinguConfigItem
42 #include <svtools/lingucfg.hxx>
43 #include <svtools/linguprops.hxx>
44 #ifndef _SVX_HELPID_HRC
45 #include "helpid.hrc"
46 #endif
48 //disable compiler warning C4355: 'this' : used in base member initializer list
49 #ifdef _MSC_VER
50 # pragma warning (disable : 4355)
51 #endif
53 //.............................................................................
54 namespace textconversiondlgs
56 //.............................................................................
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
61 ChineseTranslationDialog::ChineseTranslationDialog( Window* pParent )
62 : ModalDialog( pParent, TextConversionDlgs_ResId( DLG_CHINESETRANSLATION ) )
63 , m_aFL_Direction( this, TextConversionDlgs_ResId( FL_DIRECTION ) )
64 , m_aRB_To_Simplified( this, TextConversionDlgs_ResId( RB_TO_SIMPLIFIED ) )
65 , m_aRB_To_Traditional( this, TextConversionDlgs_ResId( RB_TO_TRADITIONAL ) )
66 , m_aCB_Use_Variants( this, TextConversionDlgs_ResId( CB_USE_VARIANTS ) )
67 , m_aFL_Commonterms( this, TextConversionDlgs_ResId( FL_COMMONTERMS ) )
68 , m_aCB_Translate_Commonterms( this, TextConversionDlgs_ResId( CB_TRANSLATE_COMMONTERMS ) )
69 , m_aPB_Editterms( this, TextConversionDlgs_ResId( PB_EDITTERMS ) )
70 , m_aFL_Bottomline( this, TextConversionDlgs_ResId( FL_BOTTOMLINE ) )
71 , m_aBP_OK( this, TextConversionDlgs_ResId( PB_OK ) )
72 , m_aBP_Cancel( this, TextConversionDlgs_ResId( PB_CANCEL ) )
73 , m_aBP_Help( this, TextConversionDlgs_ResId( PB_HELP ) )
74 , m_pDictionaryDialog(0)
76 FreeResource();
78 m_aRB_To_Simplified.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_SIMPLIFIED );
79 m_aRB_To_Traditional.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_TRADITIONAL );
80 m_aCB_Use_Variants.SetHelpId( HID_SVX_CHINESE_TRANSLATION_CB_USE_VARIANTS );
82 SvtLinguConfig aLngCfg;
83 sal_Bool bValue = sal_Bool();
84 Any aAny( aLngCfg.GetProperty( rtl::OUString::createFromAscii( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ) );
85 aAny >>= bValue;
86 if( bValue )
87 m_aRB_To_Simplified.Check();
88 else
89 m_aRB_To_Traditional.Check();
91 aAny = aLngCfg.GetProperty( rtl::OUString::createFromAscii( UPN_IS_USE_CHARACTER_VARIANTS ) );
92 if( aAny >>= bValue )
93 m_aCB_Use_Variants.Check( bValue );
95 // #117820# (search for other occurences!)
96 // disable and hide that checkbox until it is decided if it is needed or not.
97 // If it is to be removed later the respective code needs to be removed as
98 // well, otherwise we just have to remove the next lines again.
99 m_aCB_Use_Variants.Check( sal_False );
100 m_aCB_Use_Variants.Enable( sal_False );
101 m_aCB_Use_Variants.Show( sal_False );
103 aAny = aLngCfg.GetProperty( rtl::OUString::createFromAscii( UPN_IS_TRANSLATE_COMMON_TERMS ) );
104 if( aAny >>= bValue )
105 m_aCB_Translate_Commonterms.Check( bValue );
107 m_aPB_Editterms.SetClickHdl( LINK( this, ChineseTranslationDialog, DictionaryHdl ) );
108 m_aRB_To_Simplified.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
109 m_aRB_To_Traditional.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
110 m_aCB_Translate_Commonterms.SetClickHdl( LINK( this, ChineseTranslationDialog, CommonTermsHdl ) );
111 m_aBP_OK.SetClickHdl( LINK( this, ChineseTranslationDialog, OkHdl ) );
113 impl_UpdateVariantsCheckBox();
116 ChineseTranslationDialog::~ChineseTranslationDialog()
118 if(m_pDictionaryDialog)
120 if(m_pDictionaryDialog->IsInExecute())
121 m_pDictionaryDialog->EndDialog();
122 delete m_pDictionaryDialog;
126 void ChineseTranslationDialog::getSettings( sal_Bool& rbDirectionToSimplified
127 , sal_Bool& rbUseCharacterVariants
128 , sal_Bool& rbTranslateCommonTerms ) const
130 rbDirectionToSimplified = m_aRB_To_Simplified.IsChecked();
131 rbUseCharacterVariants = m_aCB_Use_Variants.IsChecked();
132 rbTranslateCommonTerms = m_aCB_Translate_Commonterms.IsChecked();
135 void ChineseTranslationDialog::impl_UpdateVariantsCheckBox()
137 // #117820# (search for other occurences!)
138 // m_aCB_Use_Variants.Enable( m_aRB_To_Traditional.IsChecked() );
141 IMPL_LINK( ChineseTranslationDialog, DirectionHdl, void*, EMPTYARG )
143 impl_UpdateVariantsCheckBox();
144 return 0;
147 IMPL_LINK( ChineseTranslationDialog, CommonTermsHdl, void*, EMPTYARG )
149 // #117820# (search for other occurences!)
150 // if( m_aCB_Translate_Commonterms.IsChecked() && m_aRB_To_Traditional.IsChecked() )
151 // m_aCB_Use_Variants.Check( true );
152 return 0;
155 IMPL_LINK( ChineseTranslationDialog, OkHdl, void*, EMPTYARG )
157 //save settings to configuration
158 SvtLinguConfig aLngCfg;
159 Any aAny;
160 aAny <<= sal_Bool( !!m_aRB_To_Simplified.IsChecked() );
161 aLngCfg.SetProperty( rtl::OUString::createFromAscii( UPN_IS_DIRECTION_TO_SIMPLIFIED ), aAny );
162 aAny <<= sal_Bool( !!m_aCB_Use_Variants.IsChecked() );
163 aLngCfg.SetProperty( rtl::OUString::createFromAscii( UPN_IS_USE_CHARACTER_VARIANTS ), aAny );
164 aAny <<= sal_Bool( !!m_aCB_Translate_Commonterms.IsChecked() );
165 aLngCfg.SetProperty( rtl::OUString::createFromAscii( UPN_IS_TRANSLATE_COMMON_TERMS ), aAny );
167 EndDialog( RET_OK );
168 return 0;
171 IMPL_LINK( ChineseTranslationDialog, DictionaryHdl, void*, EMPTYARG )
173 if( !m_pDictionaryDialog )
175 m_pDictionaryDialog = new ChineseDictionaryDialog(this);
177 if( m_pDictionaryDialog )
179 if( m_pDictionaryDialog->IsInExecute() )
181 if( !m_pDictionaryDialog->IsReallyVisible() )
183 m_pDictionaryDialog->ToTop();
184 m_pDictionaryDialog->GrabFocusToFirstControl();
187 else
189 sal_Int32 nTextConversionOptions = i18n::TextConversionOption::NONE;
190 if( !m_aCB_Translate_Commonterms.IsChecked() )
191 nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
192 if( m_aCB_Use_Variants.IsChecked() )
193 nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::USE_CHARACTER_VARIANTS;
195 m_pDictionaryDialog->setDirectionAndTextConversionOptions( m_aRB_To_Simplified.IsChecked(), nTextConversionOptions );
196 m_pDictionaryDialog->Execute();
199 return 0;
202 //.............................................................................
203 } //end namespace
204 //.............................................................................