LCOV - code coverage report
Current view: top level - libreoffice/svx/source/unodialogs/textconversiondlgs - chinese_translationdialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 74 0.0 %
Date: 2012-12-27 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

          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 "chinese_translationdialog.hrc"
      23             : #include "resid.hxx"
      24             : #include "chinese_dictionarydialog.hxx"
      25             : #include <com/sun/star/i18n/TextConversionOption.hpp>
      26             : // header for define RET_OK
      27             : #include <vcl/msgbox.hxx>
      28             : // header for class SvtLinguConfigItem
      29             : #include <unotools/lingucfg.hxx>
      30             : #include <unotools/linguprops.hxx>
      31             : #include "helpid.hrc"
      32             : 
      33             : //disable compiler warning C4355: 'this' : used in base member initializer list
      34             : #ifdef _MSC_VER
      35             : #  pragma warning (disable : 4355)
      36             : #endif
      37             : 
      38             : //.............................................................................
      39             : namespace textconversiondlgs
      40             : {
      41             : //.............................................................................
      42             : 
      43             : using namespace ::com::sun::star;
      44             : using namespace ::com::sun::star::uno;
      45             : 
      46           0 : ChineseTranslationDialog::ChineseTranslationDialog( Window* pParent )
      47             :     : ModalDialog( pParent, TextConversionDlgs_ResId( DLG_CHINESETRANSLATION ) )
      48             :     , m_aFL_Direction( this, TextConversionDlgs_ResId( FL_DIRECTION ) )
      49             :     , m_aRB_To_Simplified( this, TextConversionDlgs_ResId( RB_TO_SIMPLIFIED ) )
      50             :     , m_aRB_To_Traditional( this, TextConversionDlgs_ResId( RB_TO_TRADITIONAL ) )
      51             :     , m_aCB_Use_Variants( this, TextConversionDlgs_ResId( CB_USE_VARIANTS ) )
      52             :     , m_aFL_Commonterms( this, TextConversionDlgs_ResId( FL_COMMONTERMS ) )
      53             :     , m_aCB_Translate_Commonterms( this, TextConversionDlgs_ResId( CB_TRANSLATE_COMMONTERMS ) )
      54             :     , m_aPB_Editterms( this, TextConversionDlgs_ResId( PB_EDITTERMS ) )
      55             :     , m_aFL_Bottomline( this, TextConversionDlgs_ResId( T_FL_BOTTOMLINE ) )
      56             :     , m_aBP_OK( this, TextConversionDlgs_ResId( PB_OK ) )
      57             :     , m_aBP_Cancel( this, TextConversionDlgs_ResId( PB_CANCEL ) )
      58             :     , m_aBP_Help( this, TextConversionDlgs_ResId( PB_HELP ) )
      59           0 :     , m_pDictionaryDialog(0)
      60             : {
      61           0 :     FreeResource();
      62             : 
      63           0 :     m_aRB_To_Simplified.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_SIMPLIFIED );
      64           0 :     m_aRB_To_Traditional.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_TRADITIONAL );
      65           0 :     m_aCB_Use_Variants.SetHelpId( HID_SVX_CHINESE_TRANSLATION_CB_USE_VARIANTS );
      66             : 
      67           0 :     SvtLinguConfig  aLngCfg;
      68           0 :     sal_Bool bValue = sal_Bool();
      69           0 :     Any aAny( aLngCfg.GetProperty( rtl::OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ) );
      70           0 :     aAny >>= bValue;
      71           0 :     if( bValue )
      72           0 :         m_aRB_To_Simplified.Check();
      73             :     else
      74           0 :         m_aRB_To_Traditional.Check();
      75             : 
      76           0 :     aAny = aLngCfg.GetProperty( rtl::OUString( UPN_IS_USE_CHARACTER_VARIANTS ) );
      77           0 :     if( aAny >>= bValue )
      78           0 :         m_aCB_Use_Variants.Check( bValue );
      79             : 
      80             :     // #117820# (search for other occurrences!)
      81             :     // disable and hide that checkbox until it is decided if it is needed or not.
      82             :     // If it is to be removed later the respective code needs to be removed as
      83             :     // well, otherwise we just have to remove the next lines again.
      84           0 :     m_aCB_Use_Variants.Check( sal_False );
      85           0 :     m_aCB_Use_Variants.Enable( sal_False );
      86           0 :     m_aCB_Use_Variants.Show( sal_False );
      87             : 
      88           0 :     aAny = aLngCfg.GetProperty( rtl::OUString( UPN_IS_TRANSLATE_COMMON_TERMS ) );
      89           0 :     if( aAny >>= bValue )
      90           0 :         m_aCB_Translate_Commonterms.Check( bValue );
      91             : 
      92           0 :     m_aPB_Editterms.SetClickHdl( LINK( this, ChineseTranslationDialog, DictionaryHdl ) );
      93           0 :     m_aRB_To_Simplified.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
      94           0 :     m_aRB_To_Traditional.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
      95           0 :     m_aCB_Translate_Commonterms.SetClickHdl( LINK( this, ChineseTranslationDialog, CommonTermsHdl ) );
      96           0 :     m_aBP_OK.SetClickHdl( LINK( this, ChineseTranslationDialog, OkHdl ) );
      97             : 
      98           0 :     impl_UpdateVariantsCheckBox();
      99           0 : }
     100             : 
     101           0 : ChineseTranslationDialog::~ChineseTranslationDialog()
     102             : {
     103           0 :     if(m_pDictionaryDialog)
     104             :     {
     105           0 :         if(m_pDictionaryDialog->IsInExecute())
     106           0 :             m_pDictionaryDialog->EndDialog();
     107           0 :         delete m_pDictionaryDialog;
     108             :     }
     109           0 : }
     110             : 
     111           0 : void ChineseTranslationDialog::getSettings( sal_Bool& rbDirectionToSimplified
     112             :                                           , sal_Bool& rbUseCharacterVariants
     113             :                                           , sal_Bool& rbTranslateCommonTerms ) const
     114             : {
     115           0 :     rbDirectionToSimplified = m_aRB_To_Simplified.IsChecked();
     116           0 :     rbUseCharacterVariants = m_aCB_Use_Variants.IsChecked();
     117           0 :     rbTranslateCommonTerms = m_aCB_Translate_Commonterms.IsChecked();
     118           0 : }
     119             : 
     120           0 : void ChineseTranslationDialog::impl_UpdateVariantsCheckBox()
     121             : {
     122             : // #117820# (search for other occurrences!)
     123             : //    m_aCB_Use_Variants.Enable( m_aRB_To_Traditional.IsChecked() );
     124           0 : }
     125             : 
     126           0 : IMPL_LINK_NOARG(ChineseTranslationDialog, DirectionHdl)
     127             : {
     128           0 :     impl_UpdateVariantsCheckBox();
     129           0 :     return 0;
     130             : }
     131             : 
     132           0 : IMPL_LINK_NOARG(ChineseTranslationDialog, CommonTermsHdl)
     133             : {
     134             : // #117820# (search for other occurrences!)
     135             : //    if( m_aCB_Translate_Commonterms.IsChecked() && m_aRB_To_Traditional.IsChecked() )
     136             : //        m_aCB_Use_Variants.Check( true );
     137           0 :     return 0;
     138             : }
     139             : 
     140           0 : IMPL_LINK_NOARG(ChineseTranslationDialog, OkHdl)
     141             : {
     142             :     //save settings to configuration
     143           0 :     SvtLinguConfig  aLngCfg;
     144           0 :     Any aAny;
     145           0 :     aAny <<= sal_Bool( !!m_aRB_To_Simplified.IsChecked() );
     146           0 :     aLngCfg.SetProperty( rtl::OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ), aAny );
     147           0 :     aAny <<= sal_Bool( !!m_aCB_Use_Variants.IsChecked() );
     148           0 :     aLngCfg.SetProperty( rtl::OUString( UPN_IS_USE_CHARACTER_VARIANTS ), aAny );
     149           0 :     aAny <<= sal_Bool( !!m_aCB_Translate_Commonterms.IsChecked() );
     150           0 :     aLngCfg.SetProperty( rtl::OUString( UPN_IS_TRANSLATE_COMMON_TERMS ), aAny );
     151             : 
     152           0 :     EndDialog( RET_OK );
     153           0 :     return 0;
     154             : }
     155             : 
     156           0 : IMPL_LINK_NOARG(ChineseTranslationDialog, DictionaryHdl)
     157             : {
     158           0 :     if( !m_pDictionaryDialog )
     159             :     {
     160           0 :         m_pDictionaryDialog = new ChineseDictionaryDialog(this);
     161             :     }
     162           0 :     if( m_pDictionaryDialog )
     163             :     {
     164           0 :         if( m_pDictionaryDialog->IsInExecute() )
     165             :         {
     166           0 :             if( !m_pDictionaryDialog->IsReallyVisible() )
     167             :             {
     168           0 :                 m_pDictionaryDialog->ToTop();
     169           0 :                 m_pDictionaryDialog->GrabFocusToFirstControl();
     170             :             }
     171             :         }
     172             :         else
     173             :         {
     174           0 :             sal_Int32 nTextConversionOptions = i18n::TextConversionOption::NONE;
     175           0 :             if( !m_aCB_Translate_Commonterms.IsChecked() )
     176           0 :                 nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
     177           0 :             if( m_aCB_Use_Variants.IsChecked() )
     178           0 :                 nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::USE_CHARACTER_VARIANTS;
     179             : 
     180           0 :             m_pDictionaryDialog->setDirectionAndTextConversionOptions( m_aRB_To_Simplified.IsChecked(), nTextConversionOptions );
     181           0 :             m_pDictionaryDialog->Execute();
     182             :         }
     183             :     }
     184           0 :     return 0;
     185             : }
     186             : 
     187             : //.............................................................................
     188             : } //end namespace
     189             : //.............................................................................
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10