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_dictionarydialog.hxx"
23 : #include <com/sun/star/i18n/TextConversionOption.hpp>
24 : // header for define RET_OK
25 : #include <vcl/msgbox.hxx>
26 : // header for class SvtLinguConfigItem
27 : #include <unotools/lingucfg.hxx>
28 : #include <unotools/linguprops.hxx>
29 : #include "helpid.hrc"
30 :
31 :
32 : namespace textconversiondlgs
33 : {
34 :
35 :
36 : using namespace ::com::sun::star;
37 : using namespace ::com::sun::star::uno;
38 :
39 0 : ChineseTranslationDialog::ChineseTranslationDialog( Window* pParent )
40 : : ModalDialog(pParent, "ChineseConversionDialog", "svx/ui/chineseconversiondialog.ui")
41 0 : , m_pDictionaryDialog(0)
42 : {
43 0 : get(m_pBP_OK, "ok");
44 0 : get(m_pPB_Editterms, "editterms");
45 0 : get(m_pRB_To_Simplified, "tosimplified");
46 0 : get(m_pRB_To_Traditional, "totraditional");
47 0 : get(m_pCB_Translate_Commonterms, "commonterms");
48 :
49 0 : SvtLinguConfig aLngCfg;
50 0 : sal_Bool bValue = sal_Bool();
51 0 : Any aAny( aLngCfg.GetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ) );
52 0 : aAny >>= bValue;
53 0 : if( bValue )
54 0 : m_pRB_To_Simplified->Check();
55 : else
56 0 : m_pRB_To_Traditional->Check();
57 :
58 0 : aAny = aLngCfg.GetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS ) );
59 0 : if( aAny >>= bValue )
60 0 : m_pCB_Translate_Commonterms->Check( bValue );
61 :
62 0 : m_pPB_Editterms->SetClickHdl( LINK( this, ChineseTranslationDialog, DictionaryHdl ) );
63 0 : m_pBP_OK->SetClickHdl( LINK( this, ChineseTranslationDialog, OkHdl ) );
64 0 : }
65 :
66 0 : ChineseTranslationDialog::~ChineseTranslationDialog()
67 : {
68 0 : if(m_pDictionaryDialog)
69 : {
70 0 : if(m_pDictionaryDialog->IsInExecute())
71 0 : m_pDictionaryDialog->EndDialog();
72 0 : delete m_pDictionaryDialog;
73 : }
74 0 : }
75 :
76 0 : void ChineseTranslationDialog::getSettings( sal_Bool& rbDirectionToSimplified
77 : , sal_Bool& rbTranslateCommonTerms ) const
78 : {
79 0 : rbDirectionToSimplified = m_pRB_To_Simplified->IsChecked();
80 0 : rbTranslateCommonTerms = m_pCB_Translate_Commonterms->IsChecked();
81 0 : }
82 :
83 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, OkHdl)
84 : {
85 : //save settings to configuration
86 0 : SvtLinguConfig aLngCfg;
87 0 : Any aAny;
88 0 : aAny <<= sal_Bool( !!m_pRB_To_Simplified->IsChecked() );
89 0 : aLngCfg.SetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED ), aAny );
90 0 : aAny <<= sal_Bool( !!m_pCB_Translate_Commonterms->IsChecked() );
91 0 : aLngCfg.SetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS ), aAny );
92 :
93 0 : EndDialog( RET_OK );
94 0 : return 0;
95 : }
96 :
97 0 : IMPL_LINK_NOARG(ChineseTranslationDialog, DictionaryHdl)
98 : {
99 0 : if( !m_pDictionaryDialog )
100 : {
101 0 : m_pDictionaryDialog = new ChineseDictionaryDialog(this);
102 : }
103 0 : if( m_pDictionaryDialog )
104 : {
105 0 : if( m_pDictionaryDialog->IsInExecute() )
106 : {
107 0 : if( !m_pDictionaryDialog->IsReallyVisible() )
108 : {
109 0 : m_pDictionaryDialog->ToTop();
110 0 : m_pDictionaryDialog->GrabFocusToFirstControl();
111 : }
112 : }
113 : else
114 : {
115 0 : sal_Int32 nTextConversionOptions = i18n::TextConversionOption::NONE;
116 0 : if( !m_pCB_Translate_Commonterms->IsChecked() )
117 0 : nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
118 0 : m_pDictionaryDialog->setDirectionAndTextConversionOptions( m_pRB_To_Simplified->IsChecked(), nTextConversionOptions );
119 0 : m_pDictionaryDialog->Execute();
120 : }
121 : }
122 0 : return 0;
123 : }
124 :
125 :
126 : } //end namespace
127 :
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|