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