update dev300-m58
[ooovba.git] / svx / source / cui / hangulhanjadlg.hxx
blob9830de4cabface451c0020844eb108eef33e5026
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hangulhanjadlg.hxx,v $
10 * $Revision: 1.9 $
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>
36 #endif
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>
48 #include <vector>
49 #include <memory> // for auto_ptr
51 class SvxCommonLinguisticControl;
52 //.............................................................................
53 namespace svx
55 //.............................................................................
57 //=========================================================================
58 //= HangulHanjaConversionDialog
59 //=========================================================================
61 class SuggestionSet : public ValueSet
63 public:
64 SuggestionSet( Window* pParent );
65 virtual ~SuggestionSet();
67 virtual void UserDraw( const UserDrawEvent& rUDEvt );
68 void ClearSet();
71 class SuggestionDisplay : public Control
73 public:
74 SuggestionDisplay( Window* pParent, const ResId& rResId );
75 virtual ~SuggestionDisplay();
77 void DisplayListBox( bool bDisplayListBox );
79 void SetSelectHdl( const Link& rLink );
81 void Clear();
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* );
102 void SetHelpIds();
104 private:
105 void implUpdateDisplay();
106 Control& implGetCurrentControl();
108 private:
109 bool m_bDisplayListBox;//otherwise ValueSet
110 SuggestionSet m_aValueSet;
111 ListBox m_aListBox;
113 Link m_aSelectLink;
114 bool m_bInSelectionUpdate;
117 class HangulHanjaConversionDialog : public ModalDialog
119 private:
120 ::std::auto_ptr< SvxCommonLinguisticControl >
121 m_pPlayground; // order matters: before all other controls!
123 PushButton m_aFind;
124 SuggestionDisplay m_aSuggestions;
125 FixedText m_aFormat;
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;
148 public:
149 HangulHanjaConversionDialog(
150 Window* _pParent,
151 HangulHanjaConversion::ConversionDirection _ePrimaryDirection );
152 ~HangulHanjaConversionDialog( );
154 public:
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 );
196 private:
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
213 private:
214 FixedText m_aUserdefdictFT;
215 SvxCheckListBox m_aDictsLB;
216 FixedLine m_aOptionsFL;
217 CheckBox m_aIgnorepostCB;
218 CheckBox m_aShowrecentlyfirstCB;
219 CheckBox m_aAutoreplaceuniqueCB;
220 PushButton m_aNewPB;
221 PushButton m_aEditPB;
222 PushButton m_aDeletePB;
223 OKButton m_aOkPB;
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
242 public:
243 HangulHanjaOptionsDialog( Window* _pParent );
244 virtual ~HangulHanjaOptionsDialog();
246 void AddDict( const String& _rName, bool _bChecked );
250 class HangulHanjaNewDictDialog : public ModalDialog
252 private:
253 FixedLine m_aNewDictFL;
254 FixedText m_aDictNameFT;
255 Edit m_aDictNameED;
256 OKButton m_aOkBtn;
257 CancelButton m_aCancelBtn;
258 HelpButton m_aHelpBtn;
260 bool m_bEntered;
262 DECL_LINK( OKHdl, void* );
263 DECL_LINK( ModifyHdl, void* );
264 protected:
265 public:
266 HangulHanjaNewDictDialog( Window* _pParent );
267 virtual ~HangulHanjaNewDictDialog();
269 bool GetName( String& _rRetName ) const;
273 class SuggestionList;
275 class SuggestionEdit : public Edit
277 private:
278 SuggestionEdit* m_pPrev;
279 SuggestionEdit* m_pNext;
280 ScrollBar& m_rScrollBar;
282 bool ShouldScroll( bool _bUp ) const;
283 void DoJump( bool _bUp );
284 public:
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
295 private:
296 const String m_aEditHintText;
297 HHDictList& m_rDictList;
298 sal_uInt32 m_nCurrentDict;
300 String m_aOriginal;
301 SuggestionList* m_pSuggestions;
303 FixedText m_aBookFT;
304 ListBox m_aBookLB;
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;
313 PushButton m_aNewPB;
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 );
344 public:
345 HangulHanjaEditDictDialog( Window* _pParent, HHDictList& _rDictList, sal_uInt32 _nSelDict );
346 ~HangulHanjaEditDictDialog();
348 void UpdateScrollbar( void );
351 //.............................................................................
352 } // namespace svx
353 //.............................................................................
355 #endif // SVX_HANGUL_HANJA_HXX