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 INCLUDED_CUI_SOURCE_INC_HANGULHANJADLG_HXX
20 #define INCLUDED_CUI_SOURCE_INC_HANGULHANJADLG_HXX
22 #include <vcl/customweld.hxx>
23 #include <vcl/event.hxx>
24 #include <vcl/weld.hxx>
25 #include <editeng/hangulhanja.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
28 #include <svtools/valueset.hxx>
36 class SuggestionSet
: public SvtValueSet
39 SuggestionSet(std::unique_ptr
<weld::ScrolledWindow
> xScrolledWindow
);
41 virtual void UserDraw( const UserDrawEvent
& rUDEvt
) override
;
44 class SuggestionDisplay
47 SuggestionDisplay(weld::Builder
& rBuilder
);
49 void DisplayListBox( bool bDisplayListBox
);
51 void SetSelectHdl( const Link
<SuggestionDisplay
&,void>& rLink
);
54 void InsertEntry( const OUString
& rStr
);
55 void SelectEntryPos( sal_uInt16 nPos
);
57 sal_uInt16
GetEntryCount() const;
59 OUString
GetEntry( sal_uInt16 nPos
) const;
60 OUString
GetSelectedEntry() const;
62 DECL_LINK( SelectSuggestionListBoxHdl
, weld::TreeView
&, void );
63 DECL_LINK( SelectSuggestionValueSetHdl
, SvtValueSet
*, void );
64 void SelectSuggestionHdl(bool bListBox
);
68 void set_size_request(int nWidth
, int nHeight
)
70 m_xValueSetWin
->set_size_request(nWidth
, nHeight
);
71 m_xListBox
->set_size_request(nWidth
, nHeight
);
75 void implUpdateDisplay();
76 weld::Widget
& implGetCurrentControl();
79 bool m_bDisplayListBox
; //otherwise ValueSet
80 bool m_bInSelectionUpdate
;
81 Link
<SuggestionDisplay
&,void> m_aSelectLink
;
83 std::unique_ptr
<SuggestionSet
> m_xValueSet
;
84 std::unique_ptr
<weld::CustomWeld
> m_xValueSetWin
;
85 std::unique_ptr
<weld::TreeView
> m_xListBox
;
88 class RubyRadioButton
;
90 class HangulHanjaConversionDialog
: public weld::GenericDialogController
93 /** are we working for a document? This is normally true, but in case
94 the user uses the "find" functionality, we switch to working
95 with what the user entered, which then does not have any relation to
96 the document anymore. Some functionality must be disabled then */
99 Link
<LinkParamNone
*,void> m_aOptionsChangedLink
;
100 Link
<weld::ToggleButton
&,void> m_aClickByCharacterLink
;
102 std::unique_ptr
<weld::Button
> m_xFind
;
103 std::unique_ptr
<weld::Button
> m_xIgnore
;
104 std::unique_ptr
<weld::Button
> m_xIgnoreAll
;
105 std::unique_ptr
<weld::Button
> m_xReplace
;
106 std::unique_ptr
<weld::Button
> m_xReplaceAll
;
107 std::unique_ptr
<weld::Button
> m_xOptions
;
108 std::unique_ptr
<SuggestionDisplay
> m_xSuggestions
;
109 std::unique_ptr
<weld::RadioButton
> m_xSimpleConversion
;
110 std::unique_ptr
<weld::RadioButton
> m_xHangulBracketed
;
111 std::unique_ptr
<weld::RadioButton
> m_xHanjaBracketed
;
112 std::unique_ptr
<weld::Entry
> m_xWordInput
;
113 std::unique_ptr
<weld::Label
> m_xOriginalWord
;
114 std::unique_ptr
<RubyRadioButton
> m_xHanjaAbove
;
115 std::unique_ptr
<RubyRadioButton
> m_xHanjaBelow
;
116 std::unique_ptr
<RubyRadioButton
> m_xHangulAbove
;
117 std::unique_ptr
<RubyRadioButton
> m_xHangulBelow
;
118 std::unique_ptr
<weld::CheckButton
> m_xHangulOnly
;
119 std::unique_ptr
<weld::CheckButton
> m_xHanjaOnly
;
120 std::unique_ptr
<weld::CheckButton
> m_xReplaceByChar
;
122 HangulHanjaConversionDialog(weld::Window
* pParent
);
123 virtual ~HangulHanjaConversionDialog() override
;
126 void SetOptionsChangedHdl( const Link
<LinkParamNone
*,void>& _rHdl
);
127 void SetIgnoreHdl( const Link
<weld::Button
&,void>& _rHdl
);
128 void SetIgnoreAllHdl( const Link
<weld::Button
&,void>& _rHdl
);
129 void SetChangeHdl( const Link
<weld::Button
&,void>& _rHdl
);
130 void SetChangeAllHdl( const Link
<weld::Button
&,void>& _rHdl
);
132 void SetClickByCharacterHdl( const Link
<weld::ToggleButton
&,void>& _rHdl
);
133 void SetConversionFormatChangedHdl( const Link
<weld::Button
&,void>& _rHdl
);
134 void SetFindHdl( const Link
<weld::Button
&,void>& _rHdl
);
136 OUString
GetCurrentString( ) const;
137 void SetCurrentString(
138 const OUString
& _rNewString
,
139 const css::uno::Sequence
< OUString
>& _rSuggestions
,
140 bool _bOriginatesFromDocument
143 void FocusSuggestion( );
145 /// retrieves the current suggestion
146 OUString
GetCurrentSuggestion( ) const;
148 void SetConversionFormat( editeng::HangulHanjaConversion::ConversionFormat _eType
);
149 editeng::HangulHanjaConversion::ConversionFormat
GetConversionFormat( ) const;
151 void SetByCharacter( bool _bByCharacter
);
152 void SetConversionDirectionState( bool _bTryBothDirections
, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection
);
154 /// should text which does not match the primary conversion direction be ignored?
155 bool GetUseBothDirections( ) const;
157 /** get current conversion direction to use
158 (return argument if GetUseBothDirections is true) */
159 editeng::HangulHanjaConversion::ConversionDirection
GetDirection( editeng::HangulHanjaConversion::ConversionDirection eDefaultDirection
) const;
161 /// enables or disables the checkboxes for ruby formatted replacements
162 void EnableRubySupport( bool bVal
);
165 DECL_LINK( OnOption
, weld::Button
&, void );
166 DECL_LINK( OnSuggestionModified
, weld::Entry
&, void );
167 DECL_LINK( OnSuggestionSelected
, SuggestionDisplay
&, void );
168 DECL_LINK( OnConversionDirectionClicked
, weld::ToggleButton
&, void );
169 DECL_LINK( ClickByCharacterHdl
, weld::ToggleButton
&, void );
171 /// fill the suggestion list box with suggestions for the actual input
172 void FillSuggestions( const css::uno::Sequence
< OUString
>& _rSuggestions
);
176 typedef std::vector
< css::uno::Reference
< css::linguistic2::XConversionDictionary
> > HHDictList
;
178 class HangulHanjaOptionsDialog
: public weld::GenericDialogController
181 HHDictList m_aDictList
;
182 css::uno::Reference
< css::linguistic2::XConversionDictionaryList
> m_xConversionDictionaryList
;
184 std::unique_ptr
<weld::TreeView
> m_xDictsLB
;
185 std::unique_ptr
<weld::CheckButton
> m_xIgnorepostCB
;
186 std::unique_ptr
<weld::CheckButton
> m_xShowrecentlyfirstCB
;
187 std::unique_ptr
<weld::CheckButton
> m_xAutoreplaceuniqueCB
;
188 std::unique_ptr
<weld::Button
> m_xNewPB
;
189 std::unique_ptr
<weld::Button
> m_xEditPB
;
190 std::unique_ptr
<weld::Button
> m_xDeletePB
;
191 std::unique_ptr
<weld::Button
> m_xOkPB
;
193 DECL_LINK( OkHdl
, weld::Button
&, void );
194 DECL_LINK( DictsLB_SelectHdl
, weld::TreeView
&, void );
195 DECL_LINK( NewDictHdl
, weld::Button
&, void );
196 DECL_LINK( EditDictHdl
, weld::Button
&, void );
197 DECL_LINK( DeleteDictHdl
, weld::Button
&, void );
199 void Init(); ///< reads settings from core and init controls
201 HangulHanjaOptionsDialog(weld::Window
* pParent
);
202 virtual ~HangulHanjaOptionsDialog() override
;
204 void AddDict( const OUString
& _rName
, bool _bChecked
);
207 class HangulHanjaNewDictDialog
: public weld::GenericDialogController
212 std::unique_ptr
<weld::Button
> m_xOkBtn
;
213 std::unique_ptr
<weld::Entry
> m_xDictNameED
;
215 DECL_LINK(OKHdl
, weld::Button
&, void);
216 DECL_LINK(ModifyHdl
, weld::Entry
&, void);
218 HangulHanjaNewDictDialog(weld::Window
* pParent
);
219 virtual ~HangulHanjaNewDictDialog() override
;
221 bool GetName( OUString
& _rRetName
) const;
224 class SuggestionList
;
225 class HangulHanjaEditDictDialog
;
230 HangulHanjaEditDictDialog
* m_pParent
;
231 SuggestionEdit
* m_pPrev
;
232 SuggestionEdit
* m_pNext
;
233 weld::ScrolledWindow
* m_pScrollBar
;
234 std::unique_ptr
<weld::Entry
> m_xEntry
;
236 bool ShouldScroll( bool _bUp
) const;
237 void DoJump( bool _bUp
);
239 SuggestionEdit(std::unique_ptr
<weld::Entry
> xEntry
, HangulHanjaEditDictDialog
* pParent
);
240 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
241 void init(weld::ScrolledWindow
* pScrollBar
, SuggestionEdit
* pPrev
, SuggestionEdit
* pNext
);
243 void grab_focus() { m_xEntry
->grab_focus(); }
244 OUString
get_text() const { return m_xEntry
->get_text(); }
245 void set_text(const OUString
& rText
) { m_xEntry
->set_text(rText
); }
246 void connect_changed(const Link
<weld::Entry
&, void>& rLink
) { m_xEntry
->connect_changed(rLink
); }
249 class HangulHanjaEditDictDialog
: public weld::GenericDialogController
252 const OUString m_aEditHintText
;
253 HHDictList
& m_rDictList
;
254 sal_uInt32 m_nCurrentDict
;
256 OUString m_aOriginal
;
257 std::unique_ptr
<SuggestionList
> m_xSuggestions
;
259 sal_uInt16 m_nTopPos
;
260 bool m_bModifiedSuggestions
;
261 bool m_bModifiedOriginal
;
263 std::unique_ptr
<weld::ComboBox
> m_xBookLB
;
264 std::unique_ptr
<weld::ComboBox
> m_xOriginalLB
;
265 std::unique_ptr
<SuggestionEdit
> m_xEdit1
;
266 std::unique_ptr
<SuggestionEdit
> m_xEdit2
;
267 std::unique_ptr
<SuggestionEdit
> m_xEdit3
;
268 std::unique_ptr
<SuggestionEdit
> m_xEdit4
;
269 std::unique_ptr
<weld::Widget
> m_xContents
;
270 std::unique_ptr
<weld::ScrolledWindow
> m_xScrollSB
;
271 std::unique_ptr
<weld::Button
> m_xNewPB
;
272 std::unique_ptr
<weld::Button
> m_xDeletePB
;
274 DECL_LINK( OriginalModifyHdl
, weld::ComboBox
&, void );
275 DECL_LINK( ScrollHdl
, weld::ScrolledWindow
&, void );
276 DECL_LINK( EditModifyHdl1
, weld::Entry
&, void );
277 DECL_LINK( EditModifyHdl2
, weld::Entry
&, void );
278 DECL_LINK( EditModifyHdl3
, weld::Entry
&, void );
279 DECL_LINK( EditModifyHdl4
, weld::Entry
&, void );
281 DECL_LINK( BookLBSelectHdl
, weld::ComboBox
&, void );
282 DECL_LINK( NewPBPushHdl
, weld::Button
&, void );
283 DECL_LINK( DeletePBPushHdl
, weld::Button
&, void );
285 void InitEditDictDialog(sal_uInt32 nSelDict
);
286 void UpdateOriginalLB();
287 void UpdateSuggestions();
288 void UpdateButtonStates();
290 void SetEditText( SuggestionEdit
& rEdit
, sal_uInt16 nEntryNum
);
291 void EditModify( const weld::Entry
* pEdit
, sal_uInt8 nEntryOffset
);
293 bool DeleteEntryFromDictionary( const css::uno::Reference
< css::linguistic2::XConversionDictionary
>& xDict
);
296 HangulHanjaEditDictDialog(weld::Window
* pParent
, HHDictList
& rDictList
, sal_uInt32 nSelDict
);
297 virtual ~HangulHanjaEditDictDialog() override
;
299 void UpdateScrollbar();
303 #endif // SVX_HANGUL_HANJA_HXX
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */