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