1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "chinese_translationdialog.hxx"
23 #include "chinese_dictionarydialog.hxx"
24 #include <com/sun/star/i18n/TextConversionOption.hpp>
25 // header for define RET_OK
26 #include <vcl/msgbox.hxx>
27 // header for class SvtLinguConfigItem
28 #include <unotools/lingucfg.hxx>
29 #include <unotools/linguprops.hxx>
32 //disable compiler warning C4355: 'this' : used in base member initializer list
34 # pragma warning (disable : 4355)
37 //.............................................................................
38 namespace textconversiondlgs
40 //.............................................................................
42 using namespace ::com::sun::star
;
43 using namespace ::com::sun::star::uno
;
45 ChineseTranslationDialog::ChineseTranslationDialog( Window
* pParent
)
46 : ModalDialog(pParent
, "ChineseConversionDialog", "svx/ui/chineseconversiondialog.ui")
47 , m_pDictionaryDialog(0)
50 get(m_pPB_Editterms
, "editterms");
51 get(m_pRB_To_Simplified
, "tosimplified");
52 get(m_pRB_To_Traditional
, "totraditional");
53 get(m_pCB_Translate_Commonterms
, "commonterms");
55 m_pRB_To_Simplified
->SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_SIMPLIFIED
);
56 m_pRB_To_Traditional
->SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_TRADITIONAL
);
58 SvtLinguConfig aLngCfg
;
59 sal_Bool bValue
= sal_Bool();
60 Any
aAny( aLngCfg
.GetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED
) ) );
63 m_pRB_To_Simplified
->Check();
65 m_pRB_To_Traditional
->Check();
67 aAny
= aLngCfg
.GetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS
) );
69 m_pCB_Translate_Commonterms
->Check( bValue
);
71 m_pPB_Editterms
->SetClickHdl( LINK( this, ChineseTranslationDialog
, DictionaryHdl
) );
72 m_pBP_OK
->SetClickHdl( LINK( this, ChineseTranslationDialog
, OkHdl
) );
75 ChineseTranslationDialog::~ChineseTranslationDialog()
77 if(m_pDictionaryDialog
)
79 if(m_pDictionaryDialog
->IsInExecute())
80 m_pDictionaryDialog
->EndDialog();
81 delete m_pDictionaryDialog
;
85 void ChineseTranslationDialog::getSettings( sal_Bool
& rbDirectionToSimplified
86 , sal_Bool
& rbTranslateCommonTerms
) const
88 rbDirectionToSimplified
= m_pRB_To_Simplified
->IsChecked();
89 rbTranslateCommonTerms
= m_pCB_Translate_Commonterms
->IsChecked();
92 IMPL_LINK_NOARG(ChineseTranslationDialog
, OkHdl
)
94 //save settings to configuration
95 SvtLinguConfig aLngCfg
;
97 aAny
<<= sal_Bool( !!m_pRB_To_Simplified
->IsChecked() );
98 aLngCfg
.SetProperty( OUString( UPN_IS_DIRECTION_TO_SIMPLIFIED
), aAny
);
99 aAny
<<= sal_Bool( !!m_pCB_Translate_Commonterms
->IsChecked() );
100 aLngCfg
.SetProperty( OUString( UPN_IS_TRANSLATE_COMMON_TERMS
), aAny
);
106 IMPL_LINK_NOARG(ChineseTranslationDialog
, DictionaryHdl
)
108 if( !m_pDictionaryDialog
)
110 m_pDictionaryDialog
= new ChineseDictionaryDialog(this);
112 if( m_pDictionaryDialog
)
114 if( m_pDictionaryDialog
->IsInExecute() )
116 if( !m_pDictionaryDialog
->IsReallyVisible() )
118 m_pDictionaryDialog
->ToTop();
119 m_pDictionaryDialog
->GrabFocusToFirstControl();
124 sal_Int32 nTextConversionOptions
= i18n::TextConversionOption::NONE
;
125 if( !m_pCB_Translate_Commonterms
->IsChecked() )
126 nTextConversionOptions
= nTextConversionOptions
| i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
127 m_pDictionaryDialog
->setDirectionAndTextConversionOptions( m_pRB_To_Simplified
->IsChecked(), nTextConversionOptions
);
128 m_pDictionaryDialog
->Execute();
134 //.............................................................................
136 //.............................................................................
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */