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 #pragma once
21 
22 #include <sfx2/tabdlg.hxx>
23 
24 #include "anyrefdg.hxx"
25 #include <sc.hrc>
26 #include <scmod.hxx>
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 {
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 WhichRangesContainer& 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::Toggleable&, 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 EndDialog() override;
180 
181  virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override
182  {
183  if ( m_pHandler && m_pSetReferenceHdl )
184  (m_pHandler->*m_pSetReferenceHdl)( rRef, rDoc );
185  }
186 
187  virtual void SetActive() override
188  {
189  if ( m_pHandler && m_pSetActiveHdl )
190  (m_pHandler->*m_pSetActiveHdl)();
191  }
192 
193  bool IsRefInputting() const { return m_bRefInputting; }
194  weld::Container* get_refinput_shrink_parent() { return m_xHBox.get(); }
195 
196  virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override
197  {
198  if( !CanInputStart( pEdit ) )
199  return;
200 
201  if ( m_pHandler && m_pRefInputStartPreHdl )
202  (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton );
203  m_bRefInputting = true;
204  ScValidationDlgBase::RefInputStart( pEdit, pButton );
205  }
206 
207  virtual void RefInputDone( bool bForced = false ) override
208  {
209  if( !CanInputDone( bForced ) )
210  return;
211 
213  m_bRefInputting = false;
214 
215  if ( m_pHandler && m_pRefInputDonePostHdl )
216  (m_pHandler->*m_pRefInputDonePostHdl)();
217  }
218 
219  bool IsChildFocus() const;
220 
221  enum { SLOTID = SID_VALIDITY_REFERENCE };
222 
223  virtual void Close() override
224  {
225  if (m_bOwnRefHdlr)
226  {
227  if (SfxTabPage* pPage = GetTabPage(m_sValuePageId))
228  static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(false);
229  }
231  }
232 };
233 
235 {
236 private:
237  std::unique_ptr<weld::CheckButton> m_xTsbHelp;
238  std::unique_ptr<weld::Entry> m_xEdtTitle;
239  std::unique_ptr<weld::TextView> m_xEdInputHelp;
240 
241 public:
242  ScTPValidationHelp(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
243  static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
244  virtual ~ScTPValidationHelp() override;
245 
246  virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
247  virtual void Reset ( const SfxItemSet* rArgSet ) override;
248 };
249 
251 {
252 private:
253  std::unique_ptr<weld::CheckButton> m_xTsbShow;
254  std::unique_ptr<weld::ComboBox> m_xLbAction;
255  std::unique_ptr<weld::Button> m_xBtnSearch;
256  std::unique_ptr<weld::Entry> m_xEdtTitle;
257  std::unique_ptr<weld::Label> m_xFtError;
258  std::unique_ptr<weld::TextView> m_xEdError;
259 
260  void Init();
261 
262  // Handler ------------------------
263  DECL_LINK(SelectActionHdl, weld::ComboBox&, void);
264  DECL_LINK(ClickSearchHdl, weld::Button&, void);
265 
266 public:
267  ScTPValidationError(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
268  static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
269  virtual ~ScTPValidationError() override;
270 
271  virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
272  virtual void Reset ( const SfxItemSet* rArgSet ) override;
273 };
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:747
std::unique_ptr< weld::TextView > m_xEdError
Definition: validate.hxx:258
void SetRefInputDonePostHdl(void(ScRefHandlerCaller::*pNewHdl)())
Definition: validate.hxx:68
void(ScRefHandlerCaller::* PFUNCSETREFHDLTYPE)(const ScRange &, const ScDocument &)
Definition: validate.hxx:49
virtual void EndDialog() override
Definition: validate.cxx:104
virtual void Close() override
Definition: validate.hxx:223
OUString GetFirstFormula() const
Definition: validate.cxx:489
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:528
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:504
void SetHandler(ScRefHandlerCaller *pNewHandler)
Definition: validate.hxx:63
std::unique_ptr< weld::Container > m_xRefGrid
Definition: validate.hxx:130
weld::Container * get_refinput_shrink_parent()
Definition: validate.hxx:194
sal_Unicode mcFmlaSep
Definition: validate.hxx:107
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:812
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: validate.hxx:238
static const WhichRangesContainer pValueRanges
Definition: validate.hxx:78
std::unique_ptr< weld::TextView > m_xEdList
Definition: validate.hxx:125
bool EnterRefStatus()
Definition: validate.cxx:844
bool IsRefInputting() const
Definition: validate.hxx:193
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:257
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:785
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:256
OUString maStrFormula
Definition: validate.hxx:104
void RefInputStartPreHdl(formula::RefEdit *pEdit, const formula::RefButton *pButton)
Definition: validate.cxx:143
std::unique_ptr< weld::ComboBox > m_xLbAllow
Definition: validate.hxx:116
std::unique_ptr< weld::TextView > m_xEdInputHelp
Definition: validate.hxx:239
void SetRefInputStartPreHdl(PINPUTSTARTDLTYPE pNewHdl)
Definition: validate.hxx:67
virtual void RefInputDone(bool bForced=false) override
Definition: validate.hxx:207
virtual void SetActive() override
Definition: validate.hxx:187
bool LeaveRefStatus()
Definition: validate.cxx:861
std::unique_ptr< weld::CheckButton > m_xTsbHelp
Definition: validate.hxx:237
The "Validity" tab dialog.
Definition: validate.hxx:146
formula::RefEdit * m_pRefEdit
Definition: validate.hxx:114
void RefInputDonePostHdl()
Definition: validate.cxx:170
#define SC_MOD()
Definition: scmod.hxx:250
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:710
ScTabViewShell * GetTabViewShell()
Definition: validate.hxx:169
virtual ~ScTPValidationHelp() override
Definition: validate.cxx:706
virtual ~ScValidationDlg() override
Definition: validate.cxx:112
virtual ~ScTPValidationError() override
Definition: validate.cxx:765
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:736
virtual void RefInputDone(bool bForced=false) override
Definition: anyrefdg.cxx:756
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:420
std::unique_ptr< weld::ComboBox > m_xLbAction
Definition: validate.hxx:254
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:889
std::unique_ptr< weld::Container > m_xHBox
Definition: validate.hxx:157
std::unique_ptr< formula::RefEdit > m_xEdMin
Definition: validate.hxx:124
bool CanInputDone(bool bForced)
Definition: anyrefdg.hxx:133
OUString GetSecondFormula() const
Definition: validate.cxx:499
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:181
ScTPValidationValue(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:343
ScTPValidationHelp(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:696
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: validate.hxx:196
void RemoveRefDlg(bool bRestoreModal)
Definition: validate.cxx:570
weld::Container * m_pBtnRefParent
Definition: validate.hxx:133
std::unique_ptr< weld::CheckButton > m_xTsbShow
Definition: validate.hxx:253
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:393
std::unique_ptr< weld::Label > m_xFtMax
Entries for explicit list.
Definition: validate.hxx:126
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:468
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:425
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:716
void SetReferenceHdl(const ScRange &, const ScDocument &)
Definition: validate.cxx:118
ScValidationDlg(weld::Window *pParent, const SfxItemSet *pArgSet, ScTabViewShell *pTabViewSh)
Definition: validate.cxx:83
std::unique_ptr< weld::CheckButton > m_xCbShow
Allow blank cells.
Definition: validate.hxx:118
bool IsChildFocus() const
Definition: validate.cxx:929
std::unique_ptr< weld::Button > m_xBtnSearch
Definition: validate.hxx:255
SfxTabPage * GetTabPage(std::string_view rPageId) const
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:779
static bool CanInputStart(const formula::RefEdit *pEdit)
Definition: anyrefdg.hxx:129
std::unique_ptr< formula::RefButton > m_xBtnRef
Hint text for cell range validity.
Definition: validate.hxx:129
bool SetupRefDlg()
Definition: validate.cxx:876
ScRefHdlrControllerImpl< SfxTabDialogController, false > ScValidationDlgBase
Definition: validate.hxx:150
static const WhichRangesContainer & GetRanges()
Definition: validate.hxx:84
void SetSecondFormula(const OUString &rFmlaStr)
Definition: validate.cxx:523
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: anyrefdg.cxx:726
void(ScRefHandlerCaller::* PCOMMONHDLTYPE)()
Definition: validate.hxx:50
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo