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 .
19 #ifndef SVX_HANGUL_HANJA_DLG_HXX
20 #define SVX_HANGUL_HANJA_DLG_HXX
22 #include <vcl/dialog.hxx>
23 #include <vcl/button.hxx>
24 #include <vcl/lstbox.hxx>
25 #include <vcl/combobox.hxx>
26 #include <vcl/fixed.hxx>
27 #include <vcl/scrbar.hxx>
28 #include <svx/checklbx.hxx>
29 #include <editeng/hangulhanja.hxx>
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <editeng/unolingu.hxx>
32 #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
33 #include <svtools/valueset.hxx>
36 #include <memory> // for auto_ptr
38 class SvxCommonLinguisticControl
;
39 //.............................................................................
42 //.............................................................................
44 //=========================================================================
45 //= HangulHanjaConversionDialog
46 //=========================================================================
48 class SuggestionSet
: public ValueSet
51 SuggestionSet( Window
* pParent
);
52 virtual ~SuggestionSet();
54 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
58 class SuggestionDisplay
: public Control
61 SuggestionDisplay( Window
* pParent
, const ResId
& rResId
);
62 virtual ~SuggestionDisplay();
64 void DisplayListBox( bool bDisplayListBox
);
66 void SetSelectHdl( const Link
& rLink
);
69 void InsertEntry( const XubString
& rStr
);
70 void SelectEntryPos( sal_uInt16 nPos
);
72 sal_uInt16
GetEntryCount() const;
74 XubString
GetEntry( sal_uInt16 nPos
) const;
75 XubString
GetSelectEntry() const;
77 virtual void StateChanged( StateChangedType nStateChange
);
79 virtual void KeyInput( const KeyEvent
& rKEvt
);
80 virtual void KeyUp( const KeyEvent
& rKEvt
);
81 virtual void Activate();
82 virtual void Deactivate();
83 virtual void GetFocus();
84 virtual void LoseFocus();
85 virtual void Command( const CommandEvent
& rCEvt
);
87 DECL_LINK( SelectSuggestionHdl
, Control
* );
92 void implUpdateDisplay();
93 Control
& implGetCurrentControl();
96 bool m_bDisplayListBox
;//otherwise ValueSet
97 SuggestionSet m_aValueSet
;
101 bool m_bInSelectionUpdate
;
104 class HangulHanjaConversionDialog
: public ModalDialog
107 SAL_WNODEPRECATED_DECLARATIONS_PUSH
108 ::std::auto_ptr
< SvxCommonLinguisticControl
>
109 m_pPlayground
; // order matters: before all other controls!
110 SAL_WNODEPRECATED_DECLARATIONS_POP
113 SuggestionDisplay m_aSuggestions
;
115 RadioButton m_aSimpleConversion
;
116 RadioButton m_aHangulBracketed
;
117 RadioButton m_aHanjaBracketed
;
118 SAL_WNODEPRECATED_DECLARATIONS_PUSH
119 ::std::auto_ptr
< RadioButton
> m_pHanjaAbove
;
120 ::std::auto_ptr
< RadioButton
> m_pHanjaBelow
;
121 ::std::auto_ptr
< RadioButton
> m_pHangulAbove
;
122 ::std::auto_ptr
< RadioButton
> m_pHangulBelow
;
123 SAL_WNODEPRECATED_DECLARATIONS_POP
124 FixedText m_aConversion
;
125 CheckBox m_aHangulOnly
;
126 CheckBox m_aHanjaOnly
;
127 CheckBox m_aReplaceByChar
;
129 CheckBox
* m_pIgnoreNonPrimary
;
130 /** are we working for a document? This is normally true, but in case
131 the user uses the "find" functionality, we switch to working
132 with what the user entered, which then does not have any relation to
133 the document anymore. Some functionality must be disabled then */
134 bool m_bDocumentMode
;
136 Link m_aOptionsChangedLink
;
137 Link m_aClickByCharacterLink
;
140 HangulHanjaConversionDialog(
142 editeng::HangulHanjaConversion::ConversionDirection _ePrimaryDirection
);
143 ~HangulHanjaConversionDialog( );
146 void SetOptionsChangedHdl( const Link
& _rHdl
);
147 void SetIgnoreHdl( const Link
& _rHdl
);
148 void SetIgnoreAllHdl( const Link
& _rHdl
);
149 void SetChangeHdl( const Link
& _rHdl
);
150 void SetChangeAllHdl( const Link
& _rHdl
);
152 void SetClickByCharacterHdl( const Link
& _rHdl
);
153 void SetConversionFormatChangedHdl( const Link
& _rHdl
);
154 void SetFindHdl( const Link
& _rHdl
);
156 String
GetCurrentString( ) const;
157 void SetCurrentString(
158 const String
& _rNewString
,
159 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _rSuggestions
,
160 bool _bOriginatesFromDocument
= true
163 void FocusSuggestion( );
165 /// retrieves the current suggestion
166 String
GetCurrentSuggestion( ) const;
168 void SetConversionFormat( editeng::HangulHanjaConversion::ConversionFormat _eType
);
169 editeng::HangulHanjaConversion::ConversionFormat
GetConversionFormat( ) const;
171 void SetByCharacter( sal_Bool _bByCharacter
);
172 void SetConversionDirectionState( sal_Bool _bTryBothDirections
, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection
);
174 /// should text which does not match the primary conversion direction be ignored?
175 sal_Bool
GetUseBothDirections( ) const;
177 /** get current conversion direction to use
178 (return argument if GetUseBothDirections is true) */
179 editeng::HangulHanjaConversion::ConversionDirection
GetDirection( editeng::HangulHanjaConversion::ConversionDirection eDefaultDirection
) const;
181 /// enables or disbales the checkboxes for ruby formatted replacements
182 void EnableRubySupport( sal_Bool bVal
);
185 DECL_LINK( OnClose
, void* );
186 DECL_LINK( OnOption
, void* );
187 DECL_LINK( OnSuggestionModified
, void* );
188 DECL_LINK( OnSuggestionSelected
, void* );
189 DECL_LINK( OnConversionDirectionClicked
, CheckBox
* );
190 DECL_LINK( ClickByCharacterHdl
, CheckBox
* );
192 /// fill the suggestion list box with suggestions for the actual input
193 void FillSuggestions( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _rSuggestions
);
197 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionary
> > HHDictList
;
199 class HangulHanjaOptionsDialog
: public ModalDialog
202 FixedText m_aUserdefdictFT
;
203 SvxCheckListBox m_aDictsLB
;
204 FixedLine m_aOptionsFL
;
205 CheckBox m_aIgnorepostCB
;
206 CheckBox m_aShowrecentlyfirstCB
;
207 CheckBox m_aAutoreplaceuniqueCB
;
209 PushButton m_aEditPB
;
210 PushButton m_aDeletePB
;
212 CancelButton m_aCancelPB
;
213 HelpButton m_aHelpPB
;
215 SvLBoxButtonData
* m_pCheckButtonData
;
217 HHDictList m_aDictList
;
218 ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionaryList
> m_xConversionDictionaryList
;
220 DECL_LINK( OkHdl
, void* );
221 DECL_LINK( OnNew
, void* );
222 DECL_LINK( OnEdit
, void* );
223 DECL_LINK( OnDelete
, void* );
224 DECL_LINK( DictsLB_SelectHdl
, void* );
225 DECL_LINK( NewDictHdl
, void* );
226 DECL_LINK( EditDictHdl
, void* );
227 DECL_LINK( DeleteDictHdl
, void* );
229 void Init( void ); ///< reads settings from core and init controls
231 HangulHanjaOptionsDialog( Window
* _pParent
);
232 virtual ~HangulHanjaOptionsDialog();
234 void AddDict( const String
& _rName
, bool _bChecked
);
238 class HangulHanjaNewDictDialog
: public ModalDialog
241 FixedLine m_aNewDictFL
;
242 FixedText m_aDictNameFT
;
245 CancelButton m_aCancelBtn
;
246 HelpButton m_aHelpBtn
;
250 DECL_LINK( OKHdl
, void* );
251 DECL_LINK( ModifyHdl
, void* );
254 HangulHanjaNewDictDialog( Window
* _pParent
);
255 virtual ~HangulHanjaNewDictDialog();
257 bool GetName( String
& _rRetName
) const;
261 class SuggestionList
;
263 class SuggestionEdit
: public Edit
266 SuggestionEdit
* m_pPrev
;
267 SuggestionEdit
* m_pNext
;
268 ScrollBar
& m_rScrollBar
;
270 bool ShouldScroll( bool _bUp
) const;
271 void DoJump( bool _bUp
);
273 SuggestionEdit( Window
* pParent
, const ResId
& rResId
,
274 ScrollBar
& _rScrollBar
,
275 SuggestionEdit
* _pPrev
, SuggestionEdit
* _pNext
);
276 virtual ~SuggestionEdit();
277 virtual long PreNotify( NotifyEvent
& rNEvt
);
281 class HangulHanjaEditDictDialog
: public ModalDialog
284 const String m_aEditHintText
;
285 HHDictList
& m_rDictList
;
286 sal_uInt32 m_nCurrentDict
;
289 SuggestionList
* m_pSuggestions
;
293 FixedText m_aOriginalFT
;
294 ComboBox m_aOriginalLB
;
295 FixedText m_aSuggestionsFT
;
296 SuggestionEdit m_aEdit1
;
297 SuggestionEdit m_aEdit2
;
298 SuggestionEdit m_aEdit3
;
299 SuggestionEdit m_aEdit4
;
300 ScrollBar m_aScrollSB
;
302 PushButton m_aDeletePB
;
303 HelpButton m_aHelpPB
;
304 CancelButton m_aClosePB
;
306 sal_uInt16 m_nTopPos
;
307 bool m_bModifiedSuggestions
;
308 bool m_bModifiedOriginal
;
310 DECL_LINK( OriginalModifyHdl
, void* );
311 DECL_LINK( ScrollHdl
, void* );
312 DECL_LINK( EditModifyHdl1
, Edit
* );
313 DECL_LINK( EditModifyHdl2
, Edit
* );
314 DECL_LINK( EditModifyHdl3
, Edit
* );
315 DECL_LINK( EditModifyHdl4
, Edit
* );
317 DECL_LINK( BookLBSelectHdl
, void* );
318 DECL_LINK( NewPBPushHdl
, void* );
319 DECL_LINK( DeletePBPushHdl
, void* );
321 void InitEditDictDialog( sal_uInt32 _nSelDict
);
322 void UpdateOriginalLB( void );
323 void UpdateSuggestions( void );
324 void UpdateButtonStates();
326 void SetEditText( Edit
& _rEdit
, sal_uInt16 _nEntryNum
);
327 void EditModify( Edit
* _pEdit
, sal_uInt8 _nEntryOffset
);
328 void EditFocusLost( Edit
* _pEdit
, sal_uInt8 _nEntryOffset
);
330 bool DeleteEntryFromDictionary( const ::rtl::OUString
& rEntry
, const ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionary
>& xDict
);
333 HangulHanjaEditDictDialog( Window
* _pParent
, HHDictList
& _rDictList
, sal_uInt32 _nSelDict
);
334 ~HangulHanjaEditDictDialog();
336 void UpdateScrollbar( void );
339 //.............................................................................
341 //.............................................................................
343 #endif // SVX_HANGUL_HANJA_HXX
345 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */