LibreOffice Module sw (master) 1
inputwin.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_SW_SOURCE_UIBASE_INC_INPUTWIN_HXX
20#define INCLUDED_SW_SOURCE_UIBASE_INC_INPUTWIN_HXX
21
22#include <sal/config.h>
23
24#include <string_view>
25
27#include <vcl/toolbox.hxx>
28
29#include <sfx2/childwin.hxx>
30
31class SwFieldMgr;
32class SwWrtShell;
33class SwView;
34class SfxDispatcher;
35
36class InputEdit final : public InterimItemWindow
37{
38private:
39 std::unique_ptr<weld::Entry> m_xWidget;
40
41 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
42 DECL_LINK(ActivateHdl, weld::Entry&, bool);
43public:
45 : InterimItemWindow(pParent, "modules/swriter/ui/inputeditbox.ui", "InputEditBox")
46 , m_xWidget(m_xBuilder->weld_entry("entry"))
47 {
49
50 m_xWidget->connect_key_press(LINK(this, InputEdit, KeyInputHdl));
51 m_xWidget->connect_activate(LINK(this, InputEdit, ActivateHdl));
52 SetSizePixel(m_xWidget->get_preferred_size());
53 }
54
55 void UpdateRange(std::u16string_view rSel, const OUString& rTableName);
56
57 virtual void dispose() override
58 {
59 m_xWidget.reset();
61 }
62
63 void set_text(const OUString& rText)
64 {
65 m_xWidget->set_text(rText);
66 }
67
68 OUString get_text() const
69 {
70 return m_xWidget->get_text();
71 }
72
73 void set_accessible_name(const OUString& rName)
74 {
75 m_xWidget->set_accessible_name(rName);
76 }
77
78 void replace_selection(const OUString& rText)
79 {
80 int nStartPos, nEndPos;
81 m_xWidget->get_selection_bounds(nStartPos, nEndPos);
82 if (nStartPos > nEndPos)
83 std::swap(nStartPos, nEndPos);
84
85 m_xWidget->replace_selection(rText);
86
87 nStartPos = nStartPos + rText.getLength();
88 m_xWidget->select_region(nStartPos, nStartPos);
89 }
90
91 void select_region(int nStartPos, int nEndPos)
92 {
93 m_xWidget->select_region(nStartPos, nEndPos);
94 }
95
97 {
98 m_xWidget->connect_changed(rLink);
99 }
100
101 virtual ~InputEdit() override
102 {
103 disposeOnce();
104 }
105};
106
107
108class PosEdit final : public InterimItemWindow
109{
110private:
111 std::unique_ptr<weld::Entry> m_xWidget;
112
113 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
114public:
116 : InterimItemWindow(pParent, "modules/swriter/ui/poseditbox.ui", "PosEditBox")
117 , m_xWidget(m_xBuilder->weld_entry("entry"))
118 {
120
121 m_xWidget->connect_key_press(LINK(this, PosEdit, KeyInputHdl));
122 SetSizePixel(m_xWidget->get_preferred_size());
123 }
124
125 virtual void dispose() override
126 {
127 m_xWidget.reset();
129 }
130
131 void set_text(const OUString& rText)
132 {
133 m_xWidget->set_text(rText);
134 }
135
136 void set_accessible_name(const OUString& rName)
137 {
138 m_xWidget->set_accessible_name(rName);
139 }
140
141 virtual ~PosEdit() override
142 {
143 disposeOnce();
144 }
145};
146
147class SwInputWindow final : public ToolBox
148{
149friend class InputEdit;
150
153 std::unique_ptr<SwFieldMgr> m_pMgr;
157
158 bool m_bFirst : 1; // initialisations at first call
159 bool m_bIsTable : 1;
160 bool m_bDelSel : 1;
161 bool m_bDoesUndo : 1;
162 bool m_bResetUndo : 1;
163 bool m_bCallUndo : 1;
164
166
167 void DelBoxContent();
168 DECL_LINK(ModifyHdl, weld::Entry&, void);
169
170 using Window::IsActive;
171
172 virtual void Resize() override;
173 virtual void Click() override;
174 void MenuHdl(std::u16string_view command);
175 DECL_LINK( DropdownClickHdl, ToolBox*, void );
176 void ApplyFormula();
177 void CancelFormula();
178
179public:
180 SwInputWindow(vcl::Window* pParent, SfxDispatcher const * pDispatcher);
181 virtual ~SwInputWindow() override;
182 virtual void dispose() override;
183
184 void ShowWin();
185
186 DECL_LINK( SelTableCellsNotify, SwWrtShell&, void );
187
188 void SetFormula( const OUString& rFormula );
189 const SwView* GetView() const{return m_pView;}
190};
191
192class SwInputChild final : public SfxChildWindow
193{
195public:
197 sal_uInt16 nId,
198 SfxBindings const *,
200 virtual ~SwInputChild() override;
202 void SetFormula( const OUString& rFormula )
203 { static_cast<SwInputWindow*>(GetWindow())->SetFormula( rFormula ); }
204 const SwView* GetView() const
205 { return static_cast<SwInputWindow*>(GetWindow())->GetView();}
206
207};
208
209#endif
210
211/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void set_accessible_name(const OUString &rName)
Definition: inputwin.hxx:73
void replace_selection(const OUString &rText)
Definition: inputwin.hxx:78
std::unique_ptr< weld::Entry > m_xWidget
Definition: inputwin.hxx:39
void set_text(const OUString &rText)
Definition: inputwin.hxx:63
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
DECL_LINK(ActivateHdl, weld::Entry &, bool)
OUString get_text() const
Definition: inputwin.hxx:68
virtual void dispose() override
Definition: inputwin.hxx:57
virtual ~InputEdit() override
Definition: inputwin.hxx:101
void connect_changed(const Link< weld::Entry &, void > &rLink)
Definition: inputwin.hxx:96
void UpdateRange(std::u16string_view rSel, const OUString &rTableName)
Definition: inputwin.cxx:521
void select_region(int nStartPos, int nEndPos)
Definition: inputwin.hxx:91
InputEdit(vcl::Window *pParent)
Definition: inputwin.hxx:44
virtual void dispose() override
std::unique_ptr< weld::Builder > m_xBuilder
void InitControlBase(weld::Widget *pWidget)
virtual ~PosEdit() override
Definition: inputwin.hxx:141
virtual void dispose() override
Definition: inputwin.hxx:125
PosEdit(vcl::Window *pParent)
Definition: inputwin.hxx:115
void set_accessible_name(const OUString &rName)
Definition: inputwin.hxx:136
void set_text(const OUString &rText)
Definition: inputwin.hxx:131
std::unique_ptr< weld::Entry > m_xWidget
Definition: inputwin.hxx:111
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
vcl::Window * GetWindow() const
const SwView * GetView() const
Definition: inputwin.hxx:204
SFX_DECL_CHILDWINDOW_WITHID(SwInputChild)
SfxDispatcher * m_pDispatch
Definition: inputwin.hxx:194
void SetFormula(const OUString &rFormula)
Definition: inputwin.hxx:202
SwInputChild(vcl::Window *, sal_uInt16 nId, SfxBindings const *, SfxChildWinInfo *)
Definition: inputwin.cxx:616
virtual ~SwInputChild() override
Definition: inputwin.cxx:628
DECL_LINK(DropdownClickHdl, ToolBox *, void)
void CleanupUglyHackWithUndo()
Definition: inputwin.cxx:161
bool m_bResetUndo
Definition: inputwin.hxx:162
SwWrtShell * m_pWrtShell
Definition: inputwin.hxx:154
void SetFormula(const OUString &rFormula)
Definition: inputwin.cxx:454
void ShowWin()
Definition: inputwin.cxx:190
const SwView * GetView() const
Definition: inputwin.hxx:189
OUString m_aCurrentTableName
Definition: inputwin.hxx:156
bool m_bCallUndo
Definition: inputwin.hxx:163
bool m_bDoesUndo
Definition: inputwin.hxx:161
VclPtr< InputEdit > mxEdit
Definition: inputwin.hxx:152
void CancelFormula()
Definition: inputwin.cxx:382
void ApplyFormula()
Definition: inputwin.cxx:347
DECL_LINK(ModifyHdl, weld::Entry &, void)
SwView * m_pView
Definition: inputwin.hxx:155
SwInputWindow(vcl::Window *pParent, SfxDispatcher const *pDispatcher)
Definition: inputwin.cxx:71
void DelBoxContent()
Definition: inputwin.cxx:483
void MenuHdl(std::u16string_view command)
Definition: inputwin.cxx:313
virtual void Click() override
Definition: inputwin.cxx:333
VclPtr< PosEdit > mxPos
Definition: inputwin.hxx:151
virtual void Resize() override
Definition: inputwin.cxx:178
std::unique_ptr< SwFieldMgr > m_pMgr
Definition: inputwin.hxx:153
OUString m_sOldFormula
Definition: inputwin.hxx:156
DECL_LINK(SelTableCellsNotify, SwWrtShell &, void)
virtual void dispose() override
Definition: inputwin.cxx:142
virtual ~SwInputWindow() override
Definition: inputwin.cxx:137
Definition: view.hxx:146
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
virtual void SetSizePixel(const Size &rNewSize)