LibreOffice Module cui (master)  1
hangulhanjadlg.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_CUI_SOURCE_INC_HANGULHANJADLG_HXX
20 #define INCLUDED_CUI_SOURCE_INC_HANGULHANJADLG_HXX
21 
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>
29 
30 #include <vector>
31 #include <memory>
32 
33 namespace svx
34 {
35 
36  class SuggestionSet : public SvtValueSet
37  {
38  public:
39  SuggestionSet(std::unique_ptr<weld::ScrolledWindow> xScrolledWindow);
40 
41  virtual void UserDraw( const UserDrawEvent& rUDEvt ) override;
42  };
43 
45  {
46  public:
48 
49  void DisplayListBox( bool bDisplayListBox );
50 
51  void SetSelectHdl( const Link<SuggestionDisplay&,void>& rLink );
52 
53  void Clear();
54  void InsertEntry( const OUString& rStr );
55  void SelectEntryPos( sal_uInt16 nPos );
56 
57  sal_uInt16 GetEntryCount() const;
58 
59  OUString GetEntry( sal_uInt16 nPos ) const;
60  OUString GetSelectedEntry() const;
61 
62  DECL_LINK( SelectSuggestionListBoxHdl, weld::TreeView&, void );
63  DECL_LINK( SelectSuggestionValueSetHdl, SvtValueSet*, void );
64  void SelectSuggestionHdl(bool bListBox);
65 
66  void SetHelpIds();
67 
68  void set_size_request(int nWidth, int nHeight)
69  {
70  m_xValueSetWin->set_size_request(nWidth, nHeight);
71  m_xListBox->set_size_request(nWidth, nHeight);
72  }
73 
74  private:
75  void implUpdateDisplay();
77 
78  private:
79  bool m_bDisplayListBox; //otherwise ValueSet
82 
83  std::unique_ptr<SuggestionSet> m_xValueSet;
84  std::unique_ptr<weld::CustomWeld> m_xValueSetWin;
85  std::unique_ptr<weld::TreeView> m_xListBox;
86  };
87 
88  class RubyRadioButton;
89 
91  {
92  private:
98 
101 
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;
121  public:
123  virtual ~HangulHanjaConversionDialog() override;
124 
125  public:
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 );
131 
134  void SetFindHdl( const Link<weld::Button&,void>& _rHdl );
135 
136  OUString GetCurrentString( ) const;
137  void SetCurrentString(
138  const OUString& _rNewString,
139  const css::uno::Sequence< OUString >& _rSuggestions,
140  bool _bOriginatesFromDocument
141  );
142 
143  void FocusSuggestion( );
144 
146  OUString GetCurrentSuggestion( ) const;
147 
150 
151  void SetByCharacter( bool _bByCharacter );
152  void SetConversionDirectionState( bool _bTryBothDirections, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection );
153 
155  bool GetUseBothDirections( ) const;
156 
160 
162  void EnableRubySupport( bool bVal );
163 
164  private:
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 );
170 
172  void FillSuggestions( const css::uno::Sequence< OUString >& _rSuggestions );
173  };
174 
175 
176  typedef std::vector< css::uno::Reference< css::linguistic2::XConversionDictionary > > HHDictList;
177 
179  {
180  private:
181  HHDictList m_aDictList;
182  css::uno::Reference< css::linguistic2::XConversionDictionaryList > m_xConversionDictionaryList;
183 
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;
192 
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 );
198 
199  void Init();
200  public:
202  virtual ~HangulHanjaOptionsDialog() override;
203 
204  void AddDict( const OUString& _rName, bool _bChecked );
205  };
206 
208  {
209  private:
211 
212  std::unique_ptr<weld::Button> m_xOkBtn;
213  std::unique_ptr<weld::Entry> m_xDictNameED;
214 
215  DECL_LINK(OKHdl, weld::Button&, void);
216  DECL_LINK(ModifyHdl, weld::Entry&, void);
217  public:
219  virtual ~HangulHanjaNewDictDialog() override;
220 
221  bool GetName( OUString& _rRetName ) const;
222  };
223 
224  class SuggestionList;
226 
228  {
229  private:
234  std::unique_ptr<weld::Entry> m_xEntry;
235 
236  bool ShouldScroll( bool _bUp ) const;
237  void DoJump( bool _bUp );
238  public:
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);
242 
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); }
247  };
248 
250  {
251  private:
252  const OUString m_aEditHintText;
253  HHDictList& m_rDictList;
254  sal_uInt32 m_nCurrentDict;
255 
256  OUString m_aOriginal;
257  std::unique_ptr<SuggestionList> m_xSuggestions;
258 
259  sal_uInt16 m_nTopPos;
262 
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;
273 
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 );
280 
281  DECL_LINK( BookLBSelectHdl, weld::ComboBox&, void );
282  DECL_LINK( NewPBPushHdl, weld::Button&, void );
283  DECL_LINK( DeletePBPushHdl, weld::Button&, void );
284 
285  void InitEditDictDialog(sal_uInt32 nSelDict);
286  void UpdateOriginalLB();
287  void UpdateSuggestions();
288  void UpdateButtonStates();
289 
290  void SetEditText( SuggestionEdit& rEdit, sal_uInt16 nEntryNum );
291  void EditModify( const weld::Entry* pEdit, sal_uInt8 nEntryOffset );
292 
293  bool DeleteEntryFromDictionary( const css::uno::Reference< css::linguistic2::XConversionDictionary >& xDict );
294 
295  public:
296  HangulHanjaEditDictDialog(weld::Window* pParent, HHDictList& rDictList, sal_uInt32 nSelDict);
297  virtual ~HangulHanjaEditDictDialog() override;
298 
299  void UpdateScrollbar();
300  };
301 }
302 
303 #endif // SVX_HANGUL_HANJA_HXX
304 
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetEditText(SuggestionEdit &rEdit, sal_uInt16 nEntryNum)
virtual ~HangulHanjaConversionDialog() override
std::unique_ptr< weld::Button > m_xFind
std::unique_ptr< RubyRadioButton > m_xHangulAbove
std::unique_ptr< weld::RadioButton > m_xHangulBracketed
OUString GetCurrentSuggestion() const
retrieves the current suggestion
void SetConversionFormat(editeng::HangulHanjaConversion::ConversionFormat _eType)
std::unique_ptr< RubyRadioButton > m_xHanjaAbove
std::unique_ptr< weld::Entry > m_xEntry
DECL_LINK(OriginalModifyHdl, weld::ComboBox &, void)
std::unique_ptr< weld::Widget > m_xContents
std::unique_ptr< weld::Label > m_xOriginalWord
DECL_LINK(OkHdl, weld::Button &, void)
void DoJump(bool _bUp)
std::unique_ptr< weld::Button > m_xIgnoreAll
void SelectEntryPos(sal_uInt16 nPos)
std::unique_ptr< weld::CheckButton > m_xHanjaOnly
void DisplayListBox(bool bDisplayListBox)
SuggestionSet(std::unique_ptr< weld::ScrolledWindow > xScrolledWindow)
SuggestionEdit(std::unique_ptr< weld::Entry > xEntry, HangulHanjaEditDictDialog *pParent)
std::unique_ptr< weld::Entry > m_xWordInput
std::unique_ptr< weld::Button > m_xEditPB
std::unique_ptr< weld::CheckButton > m_xReplaceByChar
virtual void UserDraw(const UserDrawEvent &rUDEvt) override
void SetIgnoreHdl(const Link< weld::Button &, void > &_rHdl)
std::vector< css::uno::Reference< css::linguistic2::XConversionDictionary > > HHDictList
virtual ~HangulHanjaOptionsDialog() override
HangulHanjaEditDictDialog(weld::Window *pParent, HHDictList &rDictList, sal_uInt32 nSelDict)
void connect_changed(const Link< weld::Entry &, void > &rLink)
void SetCurrentString(const OUString &_rNewString, const css::uno::Sequence< OUString > &_rSuggestions, bool _bOriginatesFromDocument)
css::uno::Reference< css::linguistic2::XConversionDictionaryList > m_xConversionDictionaryList
void set_size_request(int nWidth, int nHeight)
std::unique_ptr< weld::Button > m_xOptions
DECL_LINK(SelectSuggestionListBoxHdl, weld::TreeView &, void)
std::unique_ptr< weld::ScrolledWindow > m_xScrollSB
std::unique_ptr< RubyRadioButton > m_xHanjaBelow
std::unique_ptr< SuggestionEdit > m_xEdit4
std::unique_ptr< weld::Button > m_xDeletePB
std::unique_ptr< weld::Button > m_xNewPB
SuggestionEdit * m_pPrev
void set_text(const OUString &rText)
std::unique_ptr< weld::RadioButton > m_xSimpleConversion
OUString GetEntry(sal_uInt16 nPos) const
SuggestionDisplay(weld::Builder &rBuilder)
std::unique_ptr< weld::Button > m_xIgnore
void FillSuggestions(const css::uno::Sequence< OUString > &_rSuggestions)
fill the suggestion list box with suggestions for the actual input
HangulHanjaConversionDialog(weld::Window *pParent)
std::unique_ptr< weld::Button > m_xReplace
std::unique_ptr< weld::CustomWeld > m_xValueSetWin
bool ShouldScroll(bool _bUp) const
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
DECL_LINK(OnOption, weld::Button &, void)
void EnableRubySupport(bool bVal)
enables or disables the checkboxes for ruby formatted replacements
std::unique_ptr< weld::RadioButton > m_xHanjaBracketed
OUString get_text() const
bool m_bDocumentMode
are we working for a document? This is normally true, but in case the user uses the "find" functional...
void SetOptionsChangedHdl(const Link< LinkParamNone *, void > &_rHdl)
std::unique_ptr< weld::Button > m_xOkPB
void SetChangeHdl(const Link< weld::Button &, void > &_rHdl)
Link< LinkParamNone *, void > m_aOptionsChangedLink
void InitEditDictDialog(sal_uInt32 nSelDict)
void AddDict(const OUString &_rName, bool _bChecked)
std::unique_ptr< SuggestionDisplay > m_xSuggestions
bool GetUseBothDirections() const
should text which does not match the primary conversion direction be ignored?
std::unique_ptr< weld::Button > m_xDeletePB
void SelectSuggestionHdl(bool bListBox)
std::unique_ptr< SuggestionEdit > m_xEdit2
SuggestionEdit * m_pNext
std::unique_ptr< weld::CheckButton > m_xHangulOnly
virtual ~HangulHanjaEditDictDialog() override
Link< SuggestionDisplay &, void > m_aSelectLink
void SetSelectHdl(const Link< SuggestionDisplay &, void > &rLink)
weld::ScrolledWindow * m_pScrollBar
void SetIgnoreAllHdl(const Link< weld::Button &, void > &_rHdl)
void SetConversionDirectionState(bool _bTryBothDirections, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection)
void SetFindHdl(const Link< weld::Button &, void > &_rHdl)
void Init()
reads settings from core and init controls
unsigned char sal_uInt8
void SetClickByCharacterHdl(const Link< weld::ToggleButton &, void > &_rHdl)
std::unique_ptr< SuggestionSet > m_xValueSet
void EditModify(const weld::Entry *pEdit, sal_uInt8 nEntryOffset)
HangulHanjaNewDictDialog(weld::Window *pParent)
std::unique_ptr< weld::Button > m_xOkBtn
std::unique_ptr< weld::ComboBox > m_xOriginalLB
OUString GetSelectedEntry() const
sal_uInt16 GetEntryCount() const
std::unique_ptr< SuggestionEdit > m_xEdit3
std::unique_ptr< weld::TreeView > m_xListBox
virtual ~HangulHanjaNewDictDialog() override
std::unique_ptr< SuggestionList > m_xSuggestions
std::unique_ptr< weld::Entry > m_xDictNameED
std::unique_ptr< weld::CheckButton > m_xShowrecentlyfirstCB
void InsertEntry(const OUString &rStr)
std::unique_ptr< SuggestionEdit > m_xEdit1
editeng::HangulHanjaConversion::ConversionFormat GetConversionFormat() const
std::unique_ptr< weld::Button > m_xNewPB
std::unique_ptr< weld::ComboBox > m_xBookLB
void SetByCharacter(bool _bByCharacter)
std::unique_ptr< weld::Button > m_xReplaceAll
std::unique_ptr< weld::CheckButton > m_xAutoreplaceuniqueCB
std::unique_ptr< weld::CheckButton > m_xIgnorepostCB
std::unique_ptr< weld::TreeView > m_xDictsLB
sal_Int32 nPos
DECL_LINK(OKHdl, weld::Button &, void)
void SetChangeAllHdl(const Link< weld::Button &, void > &_rHdl)
bool GetName(OUString &_rRetName) const
editeng::HangulHanjaConversion::ConversionDirection GetDirection(editeng::HangulHanjaConversion::ConversionDirection eDefaultDirection) const
get current conversion direction to use (return argument if GetUseBothDirections is true) ...
void SetConversionFormatChangedHdl(const Link< weld::Button &, void > &_rHdl)
Link< weld::ToggleButton &, void > m_aClickByCharacterLink
std::unique_ptr< RubyRadioButton > m_xHangulBelow
bool DeleteEntryFromDictionary(const css::uno::Reference< css::linguistic2::XConversionDictionary > &xDict)
weld::Widget & implGetCurrentControl()
void init(weld::ScrolledWindow *pScrollBar, SuggestionEdit *pPrev, SuggestionEdit *pNext)
HangulHanjaEditDictDialog * m_pParent
HangulHanjaOptionsDialog(weld::Window *pParent)