LibreOffice Module sc (master)  1
validate.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 
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX
22 
23 #include <sfx2/tabdlg.hxx>
24 
25 #include "anyrefdg.hxx"
26 #include <sc.hrc>
27 #include <scmod.hxx>
28 
30  virtual ~ScRefHandlerCaller(){}
31 };
32 
34 {
35 protected:
37 // workaround VS2013 issue with pointers to things that contain virtual base class
38 #ifdef _WIN32
39  #pragma pack(push, 16)
40 #endif
45 #if defined( _WIN32)
46  #pragma pack(pop)
47 #endif
48 
49 public:
53 
55  {
56  m_pSetReferenceHdl = pNewHdl;
57  }
58 
59  void SetSetActHdl( PCOMMONHDLTYPE pNewHdl )
60  {
61  m_pSetActiveHdl = pNewHdl;
62  }
63 
64  void SetHandler( ScRefHandlerCaller *pNewHandler )
65  {
66  m_pHandler = pNewHandler;
67  }
69  void SetRefInputDonePostHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePostHdl = pNewHdl; }
70 
71  ScRefHandlerHelper():m_pHandler(nullptr), m_pSetReferenceHdl( nullptr ), m_pSetActiveHdl(nullptr), m_pRefInputStartPreHdl( nullptr ), m_pRefInputDonePostHdl( nullptr ){}
72 };
73 
74 class ScValidationDlg;
75 
78 {
79  static const sal_uInt16 pValueRanges[];
80 public:
81  explicit ScTPValidationValue(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
82  static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet );
83  virtual ~ScTPValidationValue() override;
84 
85  static const sal_uInt16* GetRanges() { return pValueRanges; }
86 
87  virtual bool FillItemSet( SfxItemSet* rArgSet ) override;
88  virtual void Reset( const SfxItemSet* rArgSet ) override;
89 
90 private:
91  void Init();
92 
93  OUString GetFirstFormula() const;
94  OUString GetSecondFormula() const;
95 
96  void SetFirstFormula( const OUString& rFmlaStr );
97  void SetSecondFormula( const OUString& rFmlaStr );
98 
99  DECL_LINK(SelectHdl, weld::ComboBox&, void);
100  DECL_LINK(CheckHdl, weld::Button&, void);
101 
102  OUString maStrMin;
103  OUString maStrMax;
104  OUString maStrValue;
105  OUString maStrFormula;
106  OUString maStrRange;
107  OUString maStrList;
109 
110  DECL_LINK( EditSetFocusHdl, formula::RefEdit&, void );
111  DECL_LINK( KillEditFocusHdl, formula::RefEdit&, void );
112  DECL_LINK( KillButtonFocusHdl, formula::RefButton&, void );
113  DECL_LINK( ClickHdl, formula::RefButton&, void );
114 
116 
117  std::unique_ptr<weld::ComboBox> m_xLbAllow;
118  std::unique_ptr<weld::CheckButton> m_xCbAllow;
119  std::unique_ptr<weld::CheckButton> m_xCbShow;
120  std::unique_ptr<weld::CheckButton> m_xCbSort;
121  std::unique_ptr<weld::Label> m_xFtValue;
122  std::unique_ptr<weld::ComboBox> m_xLbValue;
123  std::unique_ptr<weld::Label> m_xFtMin;
124  std::unique_ptr<weld::Widget> m_xMinGrid;
125  std::unique_ptr<formula::RefEdit> m_xEdMin;
126  std::unique_ptr<weld::TextView> m_xEdList;
127  std::unique_ptr<weld::Label> m_xFtMax;
128  std::unique_ptr<formula::RefEdit> m_xEdMax;
129  std::unique_ptr<weld::Label> m_xFtHint;
130  std::unique_ptr<formula::RefButton> m_xBtnRef;
131  std::unique_ptr<weld::Container> m_xRefGrid;
132 
135 
136  void SetReferenceHdl( const ScRange& , const ScDocument& );
137  void SetActiveHdl();
138  void RefInputStartPreHdl(formula::RefEdit* pEdit, const formula::RefButton* pButton);
139  void RefInputDonePostHdl();
141 public:
142  void SetupRefDlg();
143  void RemoveRefDlg(bool bRestoreModal);
144 };
145 
148  : public ScRefHdlrControllerImpl<SfxTabDialogController, false>
149  , public ScRefHandlerHelper
150 {
152 
154  OString m_sValuePageId;
157 
158  std::unique_ptr<weld::Container> m_xHBox;
159 
160  bool EnterRefStatus();
161  bool LeaveRefStatus();
162 
163 public:
164  explicit ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell* pTabViewSh);
165  virtual ~ScValidationDlg() override;
166  static std::shared_ptr<SfxDialogController> Find1AliveObject(const weld::Window *pAncestor)
167  {
168  return SC_MOD()->Find1RefWindow(SLOTID, pAncestor);
169  }
171  {
172  return m_pTabVwSh;
173  }
174 
175  bool SetupRefDlg();
176  bool RemoveRefDlg(bool bRestoreModal);
177 
178  void SetModal(bool bModal) { m_xDialog->set_modal(bModal); }
179 
180  virtual void EndDialog() override;
181 
182  virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override
183  {
184  if ( m_pHandler && m_pSetReferenceHdl )
185  (m_pHandler->*m_pSetReferenceHdl)( rRef, rDoc );
186  }
187 
188  virtual void SetActive() override
189  {
190  if ( m_pHandler && m_pSetActiveHdl )
191  (m_pHandler->*m_pSetActiveHdl)();
192  }
193 
194  bool IsRefInputting() const { return m_bRefInputting; }
195  weld::Container* get_refinput_shrink_parent() { return m_xHBox.get(); }
196 
197  virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override
198  {
199  if( !CanInputStart( pEdit ) )
200  return;
201 
202  if ( m_pHandler && m_pRefInputStartPreHdl )
203  (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton );
204  m_bRefInputting = true;
205  ScValidationDlgBase::RefInputStart( pEdit, pButton );
206  }
207 
208  virtual void RefInputDone( bool bForced = false ) override
209  {
210  if( !CanInputDone( bForced ) )
211  return;
212 
214  m_bRefInputting = false;
215 
216  if ( m_pHandler && m_pRefInputDonePostHdl )
217  (m_pHandler->*m_pRefInputDonePostHdl)();
218  }
219 
220  bool IsChildFocus() const;
221 
222  enum { SLOTID = SID_VALIDITY_REFERENCE };
223 
224  virtual void Close() override
225  {
226  if (m_bOwnRefHdlr)
227  {
228  if (SfxTabPage* pPage = GetTabPage(m_sValuePageId))
229  static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(false);
230  }
232  }
233 };
234 
236 {
237 private:
238  std::unique_ptr<weld::CheckButton> m_xTsbHelp;
239  std::unique_ptr<weld::Entry> m_xEdtTitle;
240  std::unique_ptr<weld::TextView> m_xEdInputHelp;
241 
242 public:
243  ScTPValidationHelp(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
244  static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
245  virtual ~ScTPValidationHelp() override;
246 
247  virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
248  virtual void Reset ( const SfxItemSet* rArgSet ) override;
249 };
250 
252 {
253 private:
254  std::unique_ptr<weld::CheckButton> m_xTsbShow;
255  std::unique_ptr<weld::ComboBox> m_xLbAction;
256  std::unique_ptr<weld::Button> m_xBtnSearch;
257  std::unique_ptr<weld::Entry> m_xEdtTitle;
258  std::unique_ptr<weld::Label> m_xFtError;
259  std::unique_ptr<weld::TextView> m_xEdError;
260 
261  void Init();
262 
263  // Handler ------------------------
264  DECL_LINK(SelectActionHdl, weld::ComboBox&, void);
265  DECL_LINK(ClickSearchHdl, weld::Button&, void);
266 
267 public:
268  ScTPValidationError(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
269  static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
270  virtual ~ScTPValidationError() override;
271 
272  virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
273  virtual void Reset ( const SfxItemSet* rArgSet ) override;
274 };
275 
276 #endif // INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX
277 
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Close()
ScTabViewShell * m_pTabVwSh
Definition: validate.hxx:153
OString m_sValuePageId
Definition: validate.hxx:154
std::unique_ptr< weld::CheckButton > m_xCbSort
Show selection list in cell.
Definition: validate.hxx:120
ScTPValidationError(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:749
std::unique_ptr< weld::TextView > m_xEdError
Definition: validate.hxx:259
void SetRefInputDonePostHdl(void(ScRefHandlerCaller::*pNewHdl)())
Definition: validate.hxx:69
void(ScRefHandlerCaller::* PFUNCSETREFHDLTYPE)(const ScRange &, const ScDocument &)
Definition: validate.hxx:50
virtual void EndDialog() override
Definition: validate.cxx:106
virtual void Close() override
Definition: validate.hxx:224
OUString GetFirstFormula() const
Definition: validate.cxx:491
std::unique_ptr< weld::Label > m_xFtHint
Definition: validate.hxx:129
std::unique_ptr< weld::Label > m_xFtValue
Sort selection list in cell.
Definition: validate.hxx:121
ScValidationDlg * GetValidationDlg()
Definition: validate.cxx:530
std::unique_ptr< weld::Label > m_xFtMin
Definition: validate.hxx:123
static std::shared_ptr< SfxDialogController > Find1AliveObject(const weld::Window *pAncestor)
Definition: validate.hxx:166
void SetFirstFormula(const OUString &rFmlaStr)
Definition: validate.cxx:506
void SetHandler(ScRefHandlerCaller *pNewHandler)
Definition: validate.hxx:64
std::unique_ptr< weld::Container > m_xRefGrid
Definition: validate.hxx:131
static const sal_uInt16 * GetRanges()
Definition: validate.hxx:85
weld::Container * get_refinput_shrink_parent()
Definition: validate.hxx:195
sal_Unicode mcFmlaSep
Definition: validate.hxx:108
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:814
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: validate.hxx:239
std::unique_ptr< weld::TextView > m_xEdList
Definition: validate.hxx:126
bool EnterRefStatus()
Definition: validate.cxx:846
bool IsRefInputting() const
Definition: validate.hxx:194
void SetSetActHdl(PCOMMONHDLTYPE pNewHdl)
Definition: validate.hxx:59
sal_uInt16 sal_Unicode
The tab page "Criteria" from the Validation dialog.
Definition: validate.hxx:77
DECL_LINK(SelectActionHdl, weld::ComboBox &, void)
std::unique_ptr< weld::Label > m_xFtError
Definition: validate.hxx:258
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:787
DECL_LINK(SelectHdl, weld::ComboBox &, void)
std::unique_ptr< weld::ComboBox > m_xLbValue
Definition: validate.hxx:122
void(ScRefHandlerCaller::* m_pRefInputStartPreHdl)(formula::RefEdit *pEdit, const formula::RefButton *pButton)
Definition: validate.hxx:43
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: validate.hxx:257
OUString maStrFormula
Definition: validate.hxx:105
void RefInputStartPreHdl(formula::RefEdit *pEdit, const formula::RefButton *pButton)
Definition: validate.cxx:145
std::unique_ptr< weld::ComboBox > m_xLbAllow
Definition: validate.hxx:117
std::unique_ptr< weld::TextView > m_xEdInputHelp
Definition: validate.hxx:240
static const sal_uInt16 pValueRanges[]
Definition: validate.hxx:79
void SetRefInputStartPreHdl(PINPUTSTARTDLTYPE pNewHdl)
Definition: validate.hxx:68
virtual void RefInputDone(bool bForced=false) override
Definition: validate.hxx:208
virtual void SetActive() override
Definition: validate.hxx:188
bool LeaveRefStatus()
Definition: validate.cxx:863
std::unique_ptr< weld::CheckButton > m_xTsbHelp
Definition: validate.hxx:238
The "Validity" tab dialog.
Definition: validate.hxx:147
formula::RefEdit * m_pRefEdit
Definition: validate.hxx:115
void RefInputDonePostHdl()
Definition: validate.cxx:172
#define SC_MOD()
Definition: scmod.hxx:250
ScRefHandlerCaller * m_pHandler
Definition: validate.hxx:36
std::unique_ptr< weld::Widget > m_xMinGrid
Definition: validate.hxx:124
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:712
ScTabViewShell * GetTabViewShell()
Definition: validate.hxx:170
virtual ~ScTPValidationHelp() override
Definition: validate.cxx:708
virtual ~ScValidationDlg() override
Definition: validate.cxx:114
virtual ~ScTPValidationError() override
Definition: validate.cxx:767
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:738
virtual void RefInputDone(bool bForced=false) override
Definition: anyrefdg.cxx:755
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:422
std::unique_ptr< weld::ComboBox > m_xLbAction
Definition: validate.hxx:255
bool m_bRefInputting
Definition: validate.hxx:156
void SetModal(bool bModal)
Definition: validate.hxx:178
void(ScRefHandlerCaller::* m_pSetActiveHdl)()
Definition: validate.hxx:42
void(ScRefHandlerCaller::* PINPUTSTARTDLTYPE)(formula::RefEdit *pEdit, const formula::RefButton *pButton)
Definition: validate.hxx:52
bool RemoveRefDlg(bool bRestoreModal)
Definition: validate.cxx:891
std::unique_ptr< weld::Container > m_xHBox
Definition: validate.hxx:158
std::unique_ptr< formula::RefEdit > m_xEdMin
Definition: validate.hxx:125
bool CanInputDone(bool bForced)
Definition: anyrefdg.hxx:134
OUString GetSecondFormula() const
Definition: validate.cxx:501
virtual ~ScRefHandlerCaller()
Definition: validate.hxx:30
std::unique_ptr< weld::CheckButton > m_xCbAllow
Definition: validate.hxx:118
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
Definition: validate.hxx:182
ScTPValidationValue(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:345
ScTPValidationHelp(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:698
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: validate.hxx:197
void RemoveRefDlg(bool bRestoreModal)
Definition: validate.cxx:572
weld::Container * m_pBtnRefParent
Definition: validate.hxx:134
std::unique_ptr< weld::CheckButton > m_xTsbShow
Definition: validate.hxx:254
void(ScRefHandlerCaller::* m_pRefInputDonePostHdl)()
Definition: validate.hxx:44
void SetSetRefHdl(PFUNCSETREFHDLTYPE pNewHdl)
Definition: validate.hxx:54
Reference< XExecutableDialog > m_xDialog
virtual ~ScTPValidationValue() override
Definition: validate.cxx:395
std::unique_ptr< weld::Label > m_xFtMax
Entries for explicit list.
Definition: validate.hxx:127
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:470
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:427
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:718
void SetReferenceHdl(const ScRange &, const ScDocument &)
Definition: validate.cxx:120
ScValidationDlg(weld::Window *pParent, const SfxItemSet *pArgSet, ScTabViewShell *pTabViewSh)
Definition: validate.cxx:85
std::unique_ptr< weld::CheckButton > m_xCbShow
Allow blank cells.
Definition: validate.hxx:119
bool IsChildFocus() const
Definition: validate.cxx:931
std::unique_ptr< weld::Button > m_xBtnSearch
Definition: validate.hxx:256
SfxTabPage * GetTabPage(std::string_view rPageId) const
std::unique_ptr< formula::RefEdit > m_xEdMax
Definition: validate.hxx:128
void(ScRefHandlerCaller::* m_pSetReferenceHdl)(const ScRange &, const ScDocument &)
Definition: validate.hxx:41
weld::Container * m_pRefEditParent
Definition: validate.hxx:133
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:781
static bool CanInputStart(const formula::RefEdit *pEdit)
Definition: anyrefdg.hxx:130
std::unique_ptr< formula::RefButton > m_xBtnRef
Hint text for cell range validity.
Definition: validate.hxx:130
bool SetupRefDlg()
Definition: validate.cxx:878
ScRefHdlrControllerImpl< SfxTabDialogController, false > ScValidationDlgBase
Definition: validate.hxx:151
void SetSecondFormula(const OUString &rFmlaStr)
Definition: validate.cxx:525
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: anyrefdg.cxx:725
void(ScRefHandlerCaller::* PCOMMONHDLTYPE)()
Definition: validate.hxx:51
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo