1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hangulhanjadlg.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef SVX_HANGUL_HANJA_DLG_HXX
31 #define SVX_HANGUL_HANJA_DLG_HXX
33 #include <vcl/dialog.hxx>
34 #ifndef _SV_BUTTON_HXX
35 #include <vcl/button.hxx>
37 #include <vcl/lstbox.hxx>
38 #include <vcl/combobox.hxx>
39 #include <vcl/fixed.hxx>
40 #include <vcl/scrbar.hxx>
41 #include <svx/checklbx.hxx>
42 #include <svx/hangulhanja.hxx>
43 #include <com/sun/star/uno/Sequence.hxx>
44 #include "unolingu.hxx"
45 #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
46 #include <svtools/valueset.hxx>
49 #include <memory> // for auto_ptr
51 class SvxCommonLinguisticControl
;
52 //.............................................................................
55 //.............................................................................
57 //=========================================================================
58 //= HangulHanjaConversionDialog
59 //=========================================================================
61 class SuggestionSet
: public ValueSet
64 SuggestionSet( Window
* pParent
);
65 virtual ~SuggestionSet();
67 virtual void UserDraw( const UserDrawEvent
& rUDEvt
);
71 class SuggestionDisplay
: public Control
74 SuggestionDisplay( Window
* pParent
, const ResId
& rResId
);
75 virtual ~SuggestionDisplay();
77 void DisplayListBox( bool bDisplayListBox
);
79 void SetSelectHdl( const Link
& rLink
);
82 void InsertEntry( const XubString
& rStr
);
83 void SelectEntryPos( USHORT nPos
);
85 USHORT
GetEntryCount() const;
87 XubString
GetEntry( USHORT nPos
) const;
88 XubString
GetSelectEntry() const;
90 virtual void StateChanged( StateChangedType nStateChange
);
92 virtual void KeyInput( const KeyEvent
& rKEvt
);
93 virtual void KeyUp( const KeyEvent
& rKEvt
);
94 virtual void Activate();
95 virtual void Deactivate();
96 virtual void GetFocus();
97 virtual void LoseFocus();
98 virtual void Command( const CommandEvent
& rCEvt
);
100 DECL_LINK( SelectSuggestionHdl
, Control
* );
105 void implUpdateDisplay();
106 Control
& implGetCurrentControl();
109 bool m_bDisplayListBox
;//otherwise ValueSet
110 SuggestionSet m_aValueSet
;
114 bool m_bInSelectionUpdate
;
117 class HangulHanjaConversionDialog
: public ModalDialog
120 ::std::auto_ptr
< SvxCommonLinguisticControl
>
121 m_pPlayground
; // order matters: before all other controls!
124 SuggestionDisplay m_aSuggestions
;
126 RadioButton m_aSimpleConversion
;
127 RadioButton m_aHangulBracketed
;
128 RadioButton m_aHanjaBracketed
;
129 ::std::auto_ptr
< RadioButton
> m_pHanjaAbove
;
130 ::std::auto_ptr
< RadioButton
> m_pHanjaBelow
;
131 ::std::auto_ptr
< RadioButton
> m_pHangulAbove
;
132 ::std::auto_ptr
< RadioButton
> m_pHangulBelow
;
133 FixedText m_aConversion
;
134 CheckBox m_aHangulOnly
;
135 CheckBox m_aHanjaOnly
;
136 CheckBox m_aReplaceByChar
;
138 CheckBox
* m_pIgnoreNonPrimary
;
139 bool m_bDocumentMode
;
140 // are we working for a document? This is normally true, but in case
141 // the user uses the "find" functionality, we switch to working
142 // with what the user entered, which then does not have any relation to
143 // the document anymore. Some functionality must be disabled then
145 Link m_aOptionsChangedLink
;
146 Link m_aClickByCharacterLink
;
149 HangulHanjaConversionDialog(
151 HangulHanjaConversion::ConversionDirection _ePrimaryDirection
);
152 ~HangulHanjaConversionDialog( );
155 void SetOptionsChangedHdl( const Link
& _rHdl
);
156 void SetIgnoreHdl( const Link
& _rHdl
);
157 void SetIgnoreAllHdl( const Link
& _rHdl
);
158 void SetChangeHdl( const Link
& _rHdl
);
159 void SetChangeAllHdl( const Link
& _rHdl
);
160 void SetOptionsHdl( const Link
& _rHdl
);
162 void SetClickByCharacterHdl( const Link
& _rHdl
);
163 void SetConversionFormatChangedHdl( const Link
& _rHdl
);
164 void SetFindHdl( const Link
& _rHdl
);
166 String
GetCurrentString( ) const;
167 void SetCurrentString(
168 const String
& _rNewString
,
169 const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _rSuggestions
,
170 bool _bOriginatesFromDocument
= true
173 void FocusSuggestion( );
175 // retrieves the current suggestion
176 String
GetCurrentSuggestion( ) const;
178 void SetConversionFormat( HangulHanjaConversion::ConversionFormat _eType
);
179 HangulHanjaConversion::ConversionFormat
GetConversionFormat( ) const;
181 void SetByCharacter( sal_Bool _bByCharacter
);
182 sal_Bool
GetByCharacter( ) const;
184 void SetConversionDirectionState( sal_Bool _bTryBothDirections
, HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection
);
186 // should text which does not match the primary conversion direction be ignored?
187 sal_Bool
GetUseBothDirections( ) const;
189 // get current conversion direction to use
190 // (return argument if GetUseBothDirections is true)
191 HangulHanjaConversion::ConversionDirection
GetDirection( HangulHanjaConversion::ConversionDirection eDefaultDirection
) const;
193 // enables or disbales the checkboxes for ruby formatted replacements
194 void EnableRubySupport( sal_Bool bVal
);
197 DECL_LINK( OnClose
, void* );
198 DECL_LINK( OnOption
, void* );
199 DECL_LINK( OnSuggestionModified
, void* );
200 DECL_LINK( OnSuggestionSelected
, void* );
201 DECL_LINK( OnConversionDirectionClicked
, CheckBox
* );
202 DECL_LINK( ClickByCharacterHdl
, CheckBox
* );
204 // fill the suggestion list box with suggestions for the actual input
205 void FillSuggestions( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _rSuggestions
);
209 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionary
> > HHDictList
;
211 class HangulHanjaOptionsDialog
: public ModalDialog
214 FixedText m_aUserdefdictFT
;
215 SvxCheckListBox m_aDictsLB
;
216 FixedLine m_aOptionsFL
;
217 CheckBox m_aIgnorepostCB
;
218 CheckBox m_aShowrecentlyfirstCB
;
219 CheckBox m_aAutoreplaceuniqueCB
;
221 PushButton m_aEditPB
;
222 PushButton m_aDeletePB
;
224 CancelButton m_aCancelPB
;
225 HelpButton m_aHelpPB
;
227 SvLBoxButtonData
* m_pCheckButtonData
;
229 HHDictList m_aDictList
;
230 ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionaryList
> m_xConversionDictionaryList
;
232 DECL_LINK( OkHdl
, void* );
233 DECL_LINK( OnNew
, void* );
234 DECL_LINK( OnEdit
, void* );
235 DECL_LINK( OnDelete
, void* );
236 DECL_LINK( DictsLB_SelectHdl
, void* );
237 DECL_LINK( NewDictHdl
, void* );
238 DECL_LINK( EditDictHdl
, void* );
239 DECL_LINK( DeleteDictHdl
, void* );
241 void Init( void ); // reads settings from core and init controls
243 HangulHanjaOptionsDialog( Window
* _pParent
);
244 virtual ~HangulHanjaOptionsDialog();
246 void AddDict( const String
& _rName
, bool _bChecked
);
250 class HangulHanjaNewDictDialog
: public ModalDialog
253 FixedLine m_aNewDictFL
;
254 FixedText m_aDictNameFT
;
257 CancelButton m_aCancelBtn
;
258 HelpButton m_aHelpBtn
;
262 DECL_LINK( OKHdl
, void* );
263 DECL_LINK( ModifyHdl
, void* );
266 HangulHanjaNewDictDialog( Window
* _pParent
);
267 virtual ~HangulHanjaNewDictDialog();
269 bool GetName( String
& _rRetName
) const;
273 class SuggestionList
;
275 class SuggestionEdit
: public Edit
278 SuggestionEdit
* m_pPrev
;
279 SuggestionEdit
* m_pNext
;
280 ScrollBar
& m_rScrollBar
;
282 bool ShouldScroll( bool _bUp
) const;
283 void DoJump( bool _bUp
);
285 SuggestionEdit( Window
* pParent
, const ResId
& rResId
,
286 ScrollBar
& _rScrollBar
,
287 SuggestionEdit
* _pPrev
, SuggestionEdit
* _pNext
);
288 virtual ~SuggestionEdit();
289 virtual long PreNotify( NotifyEvent
& rNEvt
);
293 class HangulHanjaEditDictDialog
: public ModalDialog
296 const String m_aEditHintText
;
297 HHDictList
& m_rDictList
;
298 sal_uInt32 m_nCurrentDict
;
301 SuggestionList
* m_pSuggestions
;
305 FixedText m_aOriginalFT
;
306 ComboBox m_aOriginalLB
;
307 FixedText m_aSuggestionsFT
;
308 SuggestionEdit m_aEdit1
;
309 SuggestionEdit m_aEdit2
;
310 SuggestionEdit m_aEdit3
;
311 SuggestionEdit m_aEdit4
;
312 ScrollBar m_aScrollSB
;
314 PushButton m_aDeletePB
;
315 HelpButton m_aHelpPB
;
316 CancelButton m_aClosePB
;
318 sal_uInt16 m_nTopPos
;
319 bool m_bModifiedSuggestions
;
320 bool m_bModifiedOriginal
;
322 DECL_LINK( OriginalModifyHdl
, void* );
323 DECL_LINK( ScrollHdl
, void* );
324 DECL_LINK( EditModifyHdl1
, Edit
* );
325 DECL_LINK( EditModifyHdl2
, Edit
* );
326 DECL_LINK( EditModifyHdl3
, Edit
* );
327 DECL_LINK( EditModifyHdl4
, Edit
* );
329 DECL_LINK( BookLBSelectHdl
, void* );
330 DECL_LINK( NewPBPushHdl
, void* );
331 DECL_LINK( DeletePBPushHdl
, void* );
333 void InitEditDictDialog( sal_uInt32 _nSelDict
);
334 void UpdateOriginalLB( void );
335 void UpdateSuggestions( void );
336 void UpdateButtonStates();
338 void SetEditText( Edit
& _rEdit
, sal_uInt16 _nEntryNum
);
339 void EditModify( Edit
* _pEdit
, sal_uInt8 _nEntryOffset
);
340 void EditFocusLost( Edit
* _pEdit
, sal_uInt8 _nEntryOffset
);
342 bool DeleteEntryFromDictionary( const ::rtl::OUString
& rEntry
, const ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionary
>& xDict
);
345 HangulHanjaEditDictDialog( Window
* _pParent
, HHDictList
& _rDictList
, sal_uInt32 _nSelDict
);
346 ~HangulHanjaEditDictDialog();
348 void UpdateScrollbar( void );
351 //.............................................................................
353 //.............................................................................
355 #endif // SVX_HANGUL_HANJA_HXX