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  InitControlBase(m_xWidget.get());
46 
47  m_xWidget->connect_key_press(LINK(this, InputEdit, KeyInputHdl));
48  m_xWidget->connect_activate(LINK(this, InputEdit, ActivateHdl));
49  SetSizePixel(m_xWidget->get_preferred_size());
50  }
51 
52  void UpdateRange(const OUString& rSel, const OUString& rTableName);
53 
54  virtual void dispose() override
55  {
56  m_xWidget.reset();
58  }
59 
60  void set_text(const OUString& rText)
61  {
62  m_xWidget->set_text(rText);
63  }
64 
65  OUString get_text() const
66  {
67  return m_xWidget->get_text();
68  }
69 
70  void set_accessible_name(const OUString& rName)
71  {
72  m_xWidget->set_accessible_name(rName);
73  }
74 
75  void replace_selection(const OUString& rText)
76  {
77  m_xWidget->replace_selection(rText);
78  }
79 
80  void select_region(int nStartPos, int nEndPos)
81  {
82  m_xWidget->select_region(nStartPos, nEndPos);
83  }
84 
86  {
87  m_xWidget->connect_changed(rLink);
88  }
89 
90  virtual ~InputEdit() override
91  {
92  disposeOnce();
93  }
94 };
95 
96 
97 class PosEdit final : public InterimItemWindow
98 {
99 private:
100  std::unique_ptr<weld::Entry> m_xWidget;
101 
102  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
103 public:
105  : InterimItemWindow(pParent, "modules/swriter/ui/poseditbox.ui", "PosEditBox")
106  , m_xWidget(m_xBuilder->weld_entry("entry"))
107  {
108  InitControlBase(m_xWidget.get());
109 
110  m_xWidget->connect_key_press(LINK(this, PosEdit, KeyInputHdl));
111  SetSizePixel(m_xWidget->get_preferred_size());
112  }
113 
114  virtual void dispose() override
115  {
116  m_xWidget.reset();
118  }
119 
120  void set_text(const OUString& rText)
121  {
122  m_xWidget->set_text(rText);
123  }
124 
125  void set_accessible_name(const OUString& rName)
126  {
127  m_xWidget->set_accessible_name(rName);
128  }
129 
130  virtual ~PosEdit() override
131  {
132  disposeOnce();
133  }
134 };
135 
136 class SwInputWindow final : public ToolBox
137 {
138 friend class InputEdit;
139 
142  std::unique_ptr<SwFieldMgr> pMgr;
146 
147  bool bFirst : 1; // initialisations at first call
148  bool bIsTable : 1;
149  bool bDelSel : 1;
150  bool m_bDoesUndo : 1;
151  bool m_bResetUndo : 1;
152  bool m_bCallUndo : 1;
153 
155 
156  void DelBoxContent();
157  DECL_LINK(ModifyHdl, weld::Entry&, void);
158 
159  using Window::IsActive;
160 
161  virtual void Resize() override;
162  virtual void Click() override;
163  DECL_LINK( MenuHdl, Menu *, bool );
164  DECL_LINK( DropdownClickHdl, ToolBox*, void );
165  void ApplyFormula();
166  void CancelFormula();
167 
168 public:
169  SwInputWindow(vcl::Window* pParent, SfxDispatcher const * pDispatcher);
170  virtual ~SwInputWindow() override;
171  virtual void dispose() override;
172 
173  void ShowWin();
174 
175  DECL_LINK( SelTableCellsNotify, SwWrtShell&, void );
176 
177  void SetFormula( const OUString& rFormula );
178  const SwView* GetView() const{return pView;}
179 };
180 
182 {
184 public:
186  sal_uInt16 nId,
187  SfxBindings const *,
188  SfxChildWinInfo* );
189  virtual ~SwInputChild() override;
191  void SetFormula( const OUString& rFormula )
192  { static_cast<SwInputWindow*>(GetWindow())->SetFormula( rFormula ); }
193  const SwView* GetView() const
194  { return static_cast<SwInputWindow*>(GetWindow())->GetView();}
195 
196 };
197 
198 #endif
199 
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void replace_selection(const OUString &rText)
Definition: inputwin.hxx:75
virtual void Resize() override
Definition: inputwin.cxx:173
bool m_bCallUndo
Definition: inputwin.hxx:152
virtual void dispose() override
Definition: inputwin.cxx:137
SwWrtShell * pWrtShell
Definition: inputwin.hxx:143
virtual ~InputEdit() override
Definition: inputwin.hxx:90
void ApplyFormula()
Definition: inputwin.cxx:334
void DelBoxContent()
Definition: inputwin.cxx:466
SwView * pView
Definition: inputwin.hxx:144
SwInputWindow(vcl::Window *pParent, SfxDispatcher const *pDispatcher)
Definition: inputwin.cxx:66
virtual void SetSizePixel(const Size &rNewSize)
void CancelFormula()
Definition: inputwin.cxx:367
std::unique_ptr< weld::Entry > m_xWidget
Definition: inputwin.hxx:36
vcl::Window * GetWindow() const
VclPtr< PosEdit > mxPos
Definition: inputwin.hxx:140
virtual void Click() override
Definition: inputwin.cxx:315
virtual void dispose() override
Definition: inputwin.hxx:114
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:104
void CleanupUglyHackWithUndo()
Definition: inputwin.cxx:156
SFX_DECL_CHILDWINDOW_WITHID(SwInputChild)
void set_text(const OUString &rText)
Definition: inputwin.hxx:120
SwInputChild(vcl::Window *, sal_uInt16 nId, SfxBindings const *, SfxChildWinInfo *)
Definition: inputwin.cxx:599
void SetFormula(const OUString &rFormula)
Definition: inputwin.hxx:191
InputEdit(vcl::Window *pParent)
Definition: inputwin.hxx:41
void UpdateRange(const OUString &rSel, const OUString &rTableName)
Definition: inputwin.cxx:504
virtual ~SwInputChild() override
Definition: inputwin.cxx:611
void set_text(const OUString &rText)
Definition: inputwin.hxx:60
OUString aCurrentTableName
Definition: inputwin.hxx:145
void set_accessible_name(const OUString &rName)
Definition: inputwin.hxx:70
void ShowWin()
Definition: inputwin.cxx:185
std::unique_ptr< SwFieldMgr > pMgr
Definition: inputwin.hxx:142
SfxDispatcher * pDispatch
Definition: inputwin.hxx:183
virtual ~SwInputWindow() override
Definition: inputwin.cxx:132
OUString sOldFormula
Definition: inputwin.hxx:145
void connect_changed(const Link< weld::Entry &, void > &rLink)
Definition: inputwin.hxx:85
virtual ~PosEdit() override
Definition: inputwin.hxx:130
virtual void dispose() override
Definition: inputwin.hxx:54
DECL_LINK(ModifyHdl, weld::Entry &, void)
virtual void dispose() override
bool m_bDoesUndo
Definition: inputwin.hxx:150
std::unique_ptr< weld::Entry > m_xWidget
Definition: inputwin.hxx:100
void select_region(int nStartPos, int nEndPos)
Definition: inputwin.hxx:80
std::unique_ptr< weld::Builder > m_xBuilder
const SwView * GetView() const
Definition: inputwin.hxx:178
OUString get_text() const
Definition: inputwin.hxx:65
const SwView * GetView() const
Definition: inputwin.hxx:193
void set_accessible_name(const OUString &rName)
Definition: inputwin.hxx:125
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
Definition: view.hxx:144
void InitControlBase(weld::Widget *pWidget)
bool m_bResetUndo
Definition: inputwin.hxx:151
VclPtr< InputEdit > mxEdit
Definition: inputwin.hxx:141
void SetFormula(const OUString &rFormula)
Definition: inputwin.cxx:437