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