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>
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
32namespace 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
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:
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::Toggleable&, void );
168 DECL_LINK( ClickByCharacterHdl, weld::Toggleable&, 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:
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;
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: */
std::unique_ptr< weld::Button > m_xReplaceAll
editeng::HangulHanjaConversion::ConversionFormat GetConversionFormat() const
void SetChangeHdl(const Link< weld::Button &, void > &_rHdl)
void SetFindHdl(const Link< weld::Button &, void > &_rHdl)
std::unique_ptr< SuggestionDisplay > m_xSuggestions
Link< weld::Toggleable &, void > m_aClickByCharacterLink
editeng::HangulHanjaConversion::ConversionDirection GetDirection(editeng::HangulHanjaConversion::ConversionDirection eDefaultDirection) const
get current conversion direction to use (return argument if GetUseBothDirections is true)
bool GetUseBothDirections() const
should text which does not match the primary conversion direction be ignored?
HangulHanjaConversionDialog(weld::Widget *pParent)
DECL_LINK(OnConversionDirectionClicked, weld::Toggleable &, void)
void SetByCharacter(bool _bByCharacter)
std::unique_ptr< RubyRadioButton > m_xHangulAbove
std::unique_ptr< RubyRadioButton > m_xHangulBelow
DECL_LINK(OnOption, weld::Button &, void)
std::unique_ptr< weld::CheckButton > m_xHanjaOnly
void SetOptionsChangedHdl(const Link< LinkParamNone *, void > &_rHdl)
std::unique_ptr< weld::RadioButton > m_xHangulBracketed
std::unique_ptr< RubyRadioButton > m_xHanjaAbove
void SetConversionFormat(editeng::HangulHanjaConversion::ConversionFormat _eType)
void SetCurrentString(const OUString &_rNewString, const css::uno::Sequence< OUString > &_rSuggestions, bool _bOriginatesFromDocument)
void FillSuggestions(const css::uno::Sequence< OUString > &_rSuggestions)
fill the suggestion list box with suggestions for the actual input
std::unique_ptr< weld::Button > m_xFind
DECL_LINK(OnSuggestionModified, weld::Entry &, void)
std::unique_ptr< weld::CheckButton > m_xHangulOnly
DECL_LINK(OnSuggestionSelected, SuggestionDisplay &, void)
std::unique_ptr< weld::RadioButton > m_xHanjaBracketed
void SetIgnoreHdl(const Link< weld::Button &, void > &_rHdl)
Link< LinkParamNone *, void > m_aOptionsChangedLink
std::unique_ptr< weld::Entry > m_xWordInput
std::unique_ptr< weld::Button > m_xIgnore
std::unique_ptr< weld::Button > m_xOptions
std::unique_ptr< RubyRadioButton > m_xHanjaBelow
std::unique_ptr< weld::CheckButton > m_xReplaceByChar
void SetChangeAllHdl(const Link< weld::Button &, void > &_rHdl)
void SetConversionDirectionState(bool _bTryBothDirections, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection)
void SetIgnoreAllHdl(const Link< weld::Button &, void > &_rHdl)
std::unique_ptr< weld::Button > m_xReplace
OUString GetCurrentSuggestion() const
retrieves the current suggestion
void EnableRubySupport(bool bVal)
enables or disables the checkboxes for ruby formatted replacements
DECL_LINK(ClickByCharacterHdl, weld::Toggleable &, void)
std::unique_ptr< weld::RadioButton > m_xSimpleConversion
void SetConversionFormatChangedHdl(const Link< weld::Toggleable &, void > &_rHdl)
std::unique_ptr< weld::Label > m_xOriginalWord
bool m_bDocumentMode
are we working for a document? This is normally true, but in case the user uses the "find" functional...
virtual ~HangulHanjaConversionDialog() override
std::unique_ptr< weld::Button > m_xIgnoreAll
void SetClickByCharacterHdl(const Link< weld::Toggleable &, void > &_rHdl)
std::unique_ptr< weld::Button > m_xDeletePB
std::unique_ptr< weld::Widget > m_xContents
std::unique_ptr< SuggestionEdit > m_xEdit4
DECL_LINK(NewPBPushHdl, weld::Button &, void)
HangulHanjaEditDictDialog(weld::Window *pParent, HHDictList &rDictList, sal_uInt32 nSelDict)
std::unique_ptr< weld::ComboBox > m_xBookLB
DECL_LINK(DeletePBPushHdl, weld::Button &, void)
void EditModify(const weld::Entry *pEdit, sal_uInt8 nEntryOffset)
void SetEditText(SuggestionEdit &rEdit, sal_uInt16 nEntryNum)
std::unique_ptr< weld::ScrolledWindow > m_xScrollSB
std::unique_ptr< weld::ComboBox > m_xOriginalLB
std::unique_ptr< SuggestionEdit > m_xEdit2
DECL_LINK(BookLBSelectHdl, weld::ComboBox &, void)
std::unique_ptr< SuggestionEdit > m_xEdit1
DECL_LINK(OriginalModifyHdl, weld::ComboBox &, void)
DECL_LINK(EditModifyHdl1, weld::Entry &, void)
std::unique_ptr< SuggestionList > m_xSuggestions
DECL_LINK(EditModifyHdl2, weld::Entry &, void)
std::unique_ptr< SuggestionEdit > m_xEdit3
virtual ~HangulHanjaEditDictDialog() override
DECL_LINK(EditModifyHdl4, weld::Entry &, void)
void InitEditDictDialog(sal_uInt32 nSelDict)
bool DeleteEntryFromDictionary(const css::uno::Reference< css::linguistic2::XConversionDictionary > &xDict)
DECL_LINK(EditModifyHdl3, weld::Entry &, void)
DECL_LINK(ScrollHdl, weld::ScrolledWindow &, void)
std::unique_ptr< weld::Button > m_xNewPB
DECL_LINK(ModifyHdl, weld::Entry &, void)
HangulHanjaNewDictDialog(weld::Window *pParent)
virtual ~HangulHanjaNewDictDialog() override
std::unique_ptr< weld::Entry > m_xDictNameED
bool GetName(OUString &_rRetName) const
std::unique_ptr< weld::Button > m_xOkBtn
DECL_LINK(OKHdl, weld::Button &, void)
std::unique_ptr< weld::CheckButton > m_xIgnorepostCB
std::unique_ptr< weld::Button > m_xOkPB
DECL_LINK(EditDictHdl, weld::Button &, void)
css::uno::Reference< css::linguistic2::XConversionDictionaryList > m_xConversionDictionaryList
DECL_LINK(OkHdl, weld::Button &, void)
void AddDict(const OUString &_rName, bool _bChecked)
DECL_LINK(DictsLB_SelectHdl, weld::TreeView &, void)
std::unique_ptr< weld::Button > m_xNewPB
std::unique_ptr< weld::Button > m_xDeletePB
std::unique_ptr< weld::CheckButton > m_xAutoreplaceuniqueCB
DECL_LINK(DeleteDictHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xEditPB
void Init()
reads settings from core and init controls
virtual ~HangulHanjaOptionsDialog() override
DECL_LINK(NewDictHdl, weld::Button &, void)
std::unique_ptr< weld::CheckButton > m_xShowrecentlyfirstCB
std::unique_ptr< weld::TreeView > m_xDictsLB
HangulHanjaOptionsDialog(weld::Window *pParent)
OUString GetSelectedEntry() const
DECL_LINK(SelectSuggestionValueSetHdl, ValueSet *, void)
std::unique_ptr< weld::CustomWeld > m_xValueSetWin
void DisplayListBox(bool bDisplayListBox)
SuggestionDisplay(weld::Builder &rBuilder)
DECL_LINK(SelectSuggestionListBoxHdl, weld::TreeView &, void)
weld::Widget & implGetCurrentControl()
Link< SuggestionDisplay &, void > m_aSelectLink
OUString GetEntry(sal_uInt16 nPos) const
void SelectSuggestionHdl(bool bListBox)
std::unique_ptr< weld::TreeView > m_xListBox
void InsertEntry(const OUString &rStr)
void set_size_request(int nWidth, int nHeight)
void SetSelectHdl(const Link< SuggestionDisplay &, void > &rLink)
std::unique_ptr< SuggestionSet > m_xValueSet
void SelectEntryPos(sal_uInt16 nPos)
sal_uInt16 GetEntryCount() const
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
std::unique_ptr< weld::Entry > m_xEntry
void connect_changed(const Link< weld::Entry &, void > &rLink)
bool ShouldScroll(bool _bUp) const
void DoJump(bool _bUp)
HangulHanjaEditDictDialog * m_pParent
weld::ScrolledWindow * m_pScrollBar
SuggestionEdit(std::unique_ptr< weld::Entry > xEntry, HangulHanjaEditDictDialog *pParent)
void set_text(const OUString &rText)
SuggestionEdit * m_pPrev
void init(weld::ScrolledWindow *pScrollBar, SuggestionEdit *pPrev, SuggestionEdit *pNext)
SuggestionEdit * m_pNext
SuggestionSet(std::unique_ptr< weld::ScrolledWindow > xScrolledWindow)
virtual void UserDraw(const UserDrawEvent &rUDEvt) override
sal_uInt16 nPos
std::vector< css::uno::Reference< css::linguistic2::XConversionDictionary > > HHDictList
unsigned char sal_uInt8