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