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