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 #pragma once
20 
21 #include <vcl/customweld.hxx>
22 #include <vcl/event.hxx>
23 #include <vcl/weld.hxx>
24 #include <editeng/hangulhanja.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
27 #include <svtools/valueset.hxx>
28 
29 #include <vector>
30 #include <memory>
31 
32 namespace svx
33 {
34 
35  class SuggestionSet : public ValueSet
36  {
37  public:
38  SuggestionSet(std::unique_ptr<weld::ScrolledWindow> xScrolledWindow);
39 
40  virtual void UserDraw( const UserDrawEvent& rUDEvt ) override;
41  };
42 
44  {
45  public:
47 
48  void DisplayListBox( bool bDisplayListBox );
49 
50  void SetSelectHdl( const Link<SuggestionDisplay&,void>& rLink );
51 
52  void Clear();
53  void InsertEntry( const OUString& rStr );
54  void SelectEntryPos( sal_uInt16 nPos );
55 
56  sal_uInt16 GetEntryCount() const;
57 
58  OUString GetEntry( sal_uInt16 nPos ) const;
59  OUString GetSelectedEntry() const;
60 
61  DECL_LINK( SelectSuggestionListBoxHdl, weld::TreeView&, void );
62  DECL_LINK( SelectSuggestionValueSetHdl, ValueSet*, void );
63  void SelectSuggestionHdl(bool bListBox);
64 
65  void SetHelpIds();
66 
67  void set_size_request(int nWidth, int nHeight)
68  {
69  m_xValueSetWin->set_size_request(nWidth, nHeight);
70  m_xListBox->set_size_request(nWidth, nHeight);
71  }
72 
73  private:
74  void implUpdateDisplay();
76 
77  private:
78  bool m_bDisplayListBox; //otherwise ValueSet
81 
82  std::unique_ptr<SuggestionSet> m_xValueSet;
83  std::unique_ptr<weld::CustomWeld> m_xValueSetWin;
84  std::unique_ptr<weld::TreeView> m_xListBox;
85  };
86 
87  class RubyRadioButton;
88 
90  {
91  private:
97 
100 
101  std::unique_ptr<weld::Button> m_xFind;
102  std::unique_ptr<weld::Button> m_xIgnore;
103  std::unique_ptr<weld::Button> m_xIgnoreAll;
104  std::unique_ptr<weld::Button> m_xReplace;
105  std::unique_ptr<weld::Button> m_xReplaceAll;
106  std::unique_ptr<weld::Button> m_xOptions;
107  std::unique_ptr<SuggestionDisplay> m_xSuggestions;
108  std::unique_ptr<weld::RadioButton> m_xSimpleConversion;
109  std::unique_ptr<weld::RadioButton> m_xHangulBracketed;
110  std::unique_ptr<weld::RadioButton> m_xHanjaBracketed;
111  std::unique_ptr<weld::Entry> m_xWordInput;
112  std::unique_ptr<weld::Label> m_xOriginalWord;
113  std::unique_ptr<RubyRadioButton> m_xHanjaAbove;
114  std::unique_ptr<RubyRadioButton> m_xHanjaBelow;
115  std::unique_ptr<RubyRadioButton> m_xHangulAbove;
116  std::unique_ptr<RubyRadioButton> m_xHangulBelow;
117  std::unique_ptr<weld::CheckButton> m_xHangulOnly;
118  std::unique_ptr<weld::CheckButton> m_xHanjaOnly;
119  std::unique_ptr<weld::CheckButton> m_xReplaceByChar;
120  public:
122  virtual ~HangulHanjaConversionDialog() override;
123 
124  public:
125  void SetOptionsChangedHdl( const Link<LinkParamNone*,void>& _rHdl );
126  void SetIgnoreHdl( const Link<weld::Button&,void>& _rHdl );
127  void SetIgnoreAllHdl( const Link<weld::Button&,void>& _rHdl );
128  void SetChangeHdl( const Link<weld::Button&,void>& _rHdl );
129  void SetChangeAllHdl( const Link<weld::Button&,void>& _rHdl );
130 
133  void SetFindHdl( const Link<weld::Button&,void>& _rHdl );
134 
135  OUString GetCurrentString( ) const;
136  void SetCurrentString(
137  const OUString& _rNewString,
138  const css::uno::Sequence< OUString >& _rSuggestions,
139  bool _bOriginatesFromDocument
140  );
141 
142  void FocusSuggestion( );
143 
145  OUString GetCurrentSuggestion( ) const;
146 
149 
150  void SetByCharacter( bool _bByCharacter );
151  void SetConversionDirectionState( bool _bTryBothDirections, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection );
152 
154  bool GetUseBothDirections( ) const;
155 
159 
161  void EnableRubySupport( bool bVal );
162 
163  private:
164  DECL_LINK( OnOption, weld::Button&, void );
165  DECL_LINK( OnSuggestionModified, weld::Entry&, void );
166  DECL_LINK( OnSuggestionSelected, SuggestionDisplay&, void );
167  DECL_LINK( OnConversionDirectionClicked, weld::ToggleButton&, void );
168  DECL_LINK( ClickByCharacterHdl, weld::ToggleButton&, void );
169 
171  void FillSuggestions( const css::uno::Sequence< OUString >& _rSuggestions );
172  };
173 
174 
175  typedef std::vector< css::uno::Reference< css::linguistic2::XConversionDictionary > > HHDictList;
176 
178  {
179  private:
180  HHDictList m_aDictList;
181  css::uno::Reference< css::linguistic2::XConversionDictionaryList > m_xConversionDictionaryList;
182 
183  std::unique_ptr<weld::TreeView> m_xDictsLB;
184  std::unique_ptr<weld::CheckButton> m_xIgnorepostCB;
185  std::unique_ptr<weld::CheckButton> m_xShowrecentlyfirstCB;
186  std::unique_ptr<weld::CheckButton> m_xAutoreplaceuniqueCB;
187  std::unique_ptr<weld::Button> m_xNewPB;
188  std::unique_ptr<weld::Button> m_xEditPB;
189  std::unique_ptr<weld::Button> m_xDeletePB;
190  std::unique_ptr<weld::Button> m_xOkPB;
191 
192  DECL_LINK( OkHdl, weld::Button&, void );
193  DECL_LINK( DictsLB_SelectHdl, weld::TreeView&, void );
194  DECL_LINK( NewDictHdl, weld::Button&, void );
195  DECL_LINK( EditDictHdl, weld::Button&, void );
196  DECL_LINK( DeleteDictHdl, weld::Button&, void );
197 
198  void Init();
199  public:
201  virtual ~HangulHanjaOptionsDialog() override;
202 
203  void AddDict( const OUString& _rName, bool _bChecked );
204  };
205 
207  {
208  private:
210 
211  std::unique_ptr<weld::Button> m_xOkBtn;
212  std::unique_ptr<weld::Entry> m_xDictNameED;
213 
214  DECL_LINK(OKHdl, weld::Button&, void);
215  DECL_LINK(ModifyHdl, weld::Entry&, void);
216  public:
218  virtual ~HangulHanjaNewDictDialog() override;
219 
220  bool GetName( OUString& _rRetName ) const;
221  };
222 
223  class SuggestionList;
225 
227  {
228  private:
233  std::unique_ptr<weld::Entry> m_xEntry;
234 
235  bool ShouldScroll( bool _bUp ) const;
236  void DoJump( bool _bUp );
237  public:
238  SuggestionEdit(std::unique_ptr<weld::Entry> xEntry, HangulHanjaEditDictDialog* pParent);
239  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
240  void init(weld::ScrolledWindow* pScrollBar, SuggestionEdit* pPrev, SuggestionEdit* pNext);
241 
242  void grab_focus() { m_xEntry->grab_focus(); }
243  void set_text(const OUString& rText) { m_xEntry->set_text(rText); }
244  void connect_changed(const Link<weld::Entry&, void>& rLink) { m_xEntry->connect_changed(rLink); }
245  };
246 
248  {
249  private:
250  const OUString m_aEditHintText;
251  HHDictList& m_rDictList;
252  sal_uInt32 m_nCurrentDict;
253 
254  OUString m_aOriginal;
255  std::unique_ptr<SuggestionList> m_xSuggestions;
256 
257  sal_uInt16 m_nTopPos;
260 
261  std::unique_ptr<weld::ComboBox> m_xBookLB;
262  std::unique_ptr<weld::ComboBox> m_xOriginalLB;
263  std::unique_ptr<SuggestionEdit> m_xEdit1;
264  std::unique_ptr<SuggestionEdit> m_xEdit2;
265  std::unique_ptr<SuggestionEdit> m_xEdit3;
266  std::unique_ptr<SuggestionEdit> m_xEdit4;
267  std::unique_ptr<weld::Widget> m_xContents;
268  std::unique_ptr<weld::ScrolledWindow> m_xScrollSB;
269  std::unique_ptr<weld::Button> m_xNewPB;
270  std::unique_ptr<weld::Button> m_xDeletePB;
271 
272  DECL_LINK( OriginalModifyHdl, weld::ComboBox&, void );
273  DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void );
274  DECL_LINK( EditModifyHdl1, weld::Entry&, void );
275  DECL_LINK( EditModifyHdl2, weld::Entry&, void );
276  DECL_LINK( EditModifyHdl3, weld::Entry&, void );
277  DECL_LINK( EditModifyHdl4, weld::Entry&, void );
278 
279  DECL_LINK( BookLBSelectHdl, weld::ComboBox&, void );
280  DECL_LINK( NewPBPushHdl, weld::Button&, void );
281  DECL_LINK( DeletePBPushHdl, weld::Button&, void );
282 
283  void InitEditDictDialog(sal_uInt32 nSelDict);
284  void UpdateOriginalLB();
285  void UpdateSuggestions();
286  void UpdateButtonStates();
287 
288  void SetEditText( SuggestionEdit& rEdit, sal_uInt16 nEntryNum );
289  void EditModify( const weld::Entry* pEdit, sal_uInt8 nEntryOffset );
290 
291  bool DeleteEntryFromDictionary( const css::uno::Reference< css::linguistic2::XConversionDictionary >& xDict );
292 
293  public:
294  HangulHanjaEditDictDialog(weld::Window* pParent, HHDictList& rDictList, sal_uInt32 nSelDict);
295  virtual ~HangulHanjaEditDictDialog() override;
296 
297  void UpdateScrollbar();
298  };
299 }
300 
301 /* 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
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
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)
sal_uInt16 nPos
HangulHanjaEditDictDialog * m_pParent
HangulHanjaOptionsDialog(weld::Window *pParent)