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
30};
31
33{
34protected:
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
48public:
49 typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , const ScDocument& );
51 typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::RefEdit* pEdit, const formula::RefButton* pButton );
52
54 {
55 m_pSetReferenceHdl = pNewHdl;
56 }
57
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
71};
72
73class ScValidationDlg;
74
77{
79public:
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
89private:
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();
140public:
141 void SetupRefDlg();
142 void RemoveRefDlg(bool bRestoreModal);
143};
144
147 : public ScRefHdlrControllerImpl<SfxTabDialogController, false>
148 , public ScRefHandlerHelper
149{
151
156
157 std::unique_ptr<weld::Container> m_xHBox;
158
159 bool EnterRefStatus();
160 bool LeaveRefStatus();
161
162public:
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(int nResponse) override;
180
181 virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override
182 {
184 (m_pHandler->*m_pSetReferenceHdl)( rRef, rDoc );
185 }
186
187 virtual void SetActive() override
188 {
191 }
192
193 bool IsRefInputting() const { return m_bRefInputting; }
195
196 virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override
197 {
198 if( !CanInputStart( pEdit ) )
199 return;
200
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
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 {
228 static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(false);
229 }
231 }
232};
233
235{
236private:
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
241public:
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{
252private:
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
266public:
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: */
Reference< XExecutableDialog > m_xDialog
ScRefHandlerCaller * m_pHandler
Definition: validate.hxx:35
void(ScRefHandlerCaller::* PINPUTSTARTDLTYPE)(formula::RefEdit *pEdit, const formula::RefButton *pButton)
Definition: validate.hxx:51
void(ScRefHandlerCaller::* m_pRefInputDonePostHdl)()
Definition: validate.hxx:43
void SetRefInputDonePostHdl(void(ScRefHandlerCaller::*pNewHdl)())
Definition: validate.hxx:68
void(ScRefHandlerCaller::* m_pSetActiveHdl)()
Definition: validate.hxx:41
void SetSetActHdl(PCOMMONHDLTYPE pNewHdl)
Definition: validate.hxx:58
void SetRefInputStartPreHdl(PINPUTSTARTDLTYPE pNewHdl)
Definition: validate.hxx:67
void(ScRefHandlerCaller::* PFUNCSETREFHDLTYPE)(const ScRange &, const ScDocument &)
Definition: validate.hxx:49
void(ScRefHandlerCaller::* m_pSetReferenceHdl)(const ScRange &, const ScDocument &)
Definition: validate.hxx:40
void(ScRefHandlerCaller::* PCOMMONHDLTYPE)()
Definition: validate.hxx:50
void(ScRefHandlerCaller::* m_pRefInputStartPreHdl)(formula::RefEdit *pEdit, const formula::RefButton *pButton)
Definition: validate.hxx:42
void SetHandler(ScRefHandlerCaller *pNewHandler)
Definition: validate.hxx:63
void SetSetRefHdl(PFUNCSETREFHDLTYPE pNewHdl)
Definition: validate.hxx:53
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: anyrefdg.cxx:749
virtual void RefInputDone(bool bForced=false) override
Definition: anyrefdg.cxx:779
static bool CanInputStart(const formula::RefEdit *pEdit)
Definition: anyrefdg.hxx:129
bool CanInputDone(bool bForced)
Definition: anyrefdg.hxx:133
std::unique_ptr< weld::Label > m_xFtError
Definition: validate.hxx:257
std::unique_ptr< weld::Button > m_xBtnSearch
Definition: validate.hxx:255
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:780
std::unique_ptr< weld::ComboBox > m_xLbAction
Definition: validate.hxx:254
virtual ~ScTPValidationError() override
Definition: validate.cxx:760
DECL_LINK(ClickSearchHdl, weld::Button &, void)
DECL_LINK(SelectActionHdl, weld::ComboBox &, void)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:774
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:805
std::unique_ptr< weld::TextView > m_xEdError
Definition: validate.hxx:258
ScTPValidationError(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:742
std::unique_ptr< weld::CheckButton > m_xTsbShow
Definition: validate.hxx:253
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: validate.hxx:256
std::unique_ptr< weld::TextView > m_xEdInputHelp
Definition: validate.hxx:239
virtual ~ScTPValidationHelp() override
Definition: validate.cxx:703
std::unique_ptr< weld::CheckButton > m_xTsbHelp
Definition: validate.hxx:237
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:731
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:707
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: validate.hxx:238
ScTPValidationHelp(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:693
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:713
The tab page "Criteria" from the Validation dialog.
Definition: validate.hxx:77
DECL_LINK(KillButtonFocusHdl, formula::RefButton &, void)
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:465
void SetFirstFormula(const OUString &rFmlaStr)
Definition: validate.cxx:501
std::unique_ptr< weld::Label > m_xFtValue
Sort selection list in cell.
Definition: validate.hxx:120
DECL_LINK(ClickHdl, formula::RefButton &, void)
ScTPValidationValue(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:344
static const WhichRangesContainer & GetRanges()
Definition: validate.hxx:84
formula::RefEdit * m_pRefEdit
Definition: validate.hxx:114
void RefInputDonePostHdl()
Definition: validate.cxx:171
std::unique_ptr< weld::Container > m_xRefGrid
Definition: validate.hxx:130
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:426
OUString maStrFormula
Definition: validate.hxx:104
std::unique_ptr< formula::RefEdit > m_xEdMin
Definition: validate.hxx:124
std::unique_ptr< weld::CheckButton > m_xCbAllow
Definition: validate.hxx:117
weld::Container * m_pBtnRefParent
Definition: validate.hxx:133
std::unique_ptr< formula::RefButton > m_xBtnRef
Hint text for cell range validity.
Definition: validate.hxx:129
sal_Unicode mcFmlaSep
Definition: validate.hxx:107
virtual ~ScTPValidationValue() override
Definition: validate.cxx:394
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:421
void SetReferenceHdl(const ScRange &, const ScDocument &)
Definition: validate.cxx:119
std::unique_ptr< formula::RefEdit > m_xEdMax
Definition: validate.hxx:127
weld::Container * m_pRefEditParent
Definition: validate.hxx:132
std::unique_ptr< weld::CheckButton > m_xCbShow
Allow blank cells.
Definition: validate.hxx:118
std::unique_ptr< weld::Widget > m_xMinGrid
Definition: validate.hxx:123
void RefInputStartPreHdl(formula::RefEdit *pEdit, const formula::RefButton *pButton)
Definition: validate.cxx:144
std::unique_ptr< weld::CheckButton > m_xCbSort
Show selection list in cell.
Definition: validate.hxx:119
void SetSecondFormula(const OUString &rFmlaStr)
Definition: validate.cxx:520
DECL_LINK(KillEditFocusHdl, formula::RefEdit &, void)
OUString GetFirstFormula() const
Definition: validate.cxx:486
std::unique_ptr< weld::Label > m_xFtMin
Definition: validate.hxx:122
DECL_LINK(SelectHdl, weld::ComboBox &, void)
std::unique_ptr< weld::Label > m_xFtMax
Entries for explicit list.
Definition: validate.hxx:126
ScValidationDlg * GetValidationDlg()
Definition: validate.cxx:525
std::unique_ptr< weld::ComboBox > m_xLbValue
Definition: validate.hxx:121
static const WhichRangesContainer pValueRanges
Definition: validate.hxx:78
std::unique_ptr< weld::Label > m_xFtHint
Definition: validate.hxx:128
OUString GetSecondFormula() const
Definition: validate.cxx:496
void RemoveRefDlg(bool bRestoreModal)
Definition: validate.cxx:567
std::unique_ptr< weld::TextView > m_xEdList
Definition: validate.hxx:125
DECL_LINK(CheckHdl, weld::Toggleable &, void)
std::unique_ptr< weld::ComboBox > m_xLbAllow
Definition: validate.hxx:116
DECL_LINK(EditSetFocusHdl, formula::RefEdit &, void)
List separator in formulas.
The "Validity" tab dialog.
Definition: validate.hxx:149
ScTabViewShell * GetTabViewShell()
Definition: validate.hxx:169
bool RemoveRefDlg(bool bRestoreModal)
Definition: validate.cxx:882
virtual ~ScValidationDlg() override
Definition: validate.cxx:113
virtual void EndDialog(int nResponse) override
Definition: validate.cxx:105
bool m_bRefInputting
Definition: validate.hxx:155
bool IsRefInputting() const
Definition: validate.hxx:193
OString m_sValuePageId
Definition: validate.hxx:153
bool LeaveRefStatus()
Definition: validate.cxx:854
virtual void RefInputDone(bool bForced=false) override
Definition: validate.hxx:207
bool IsChildFocus() const
Definition: validate.cxx:922
virtual void Close() override
Definition: validate.hxx:223
bool SetupRefDlg()
Definition: validate.cxx:869
virtual void SetActive() override
Definition: validate.hxx:187
ScRefHdlrControllerImpl< SfxTabDialogController, false > ScValidationDlgBase
Definition: validate.hxx:150
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: validate.hxx:196
ScValidationDlg(weld::Window *pParent, const SfxItemSet *pArgSet, ScTabViewShell *pTabViewSh)
Definition: validate.cxx:84
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
Definition: validate.hxx:181
std::unique_ptr< weld::Container > m_xHBox
Definition: validate.hxx:157
void SetModal(bool bModal)
Definition: validate.hxx:177
ScTabViewShell * m_pTabVwSh
Definition: validate.hxx:152
bool EnterRefStatus()
Definition: validate.cxx:837
weld::Container * get_refinput_shrink_parent()
Definition: validate.hxx:194
static std::shared_ptr< SfxDialogController > Find1AliveObject(const weld::Window *pAncestor)
Definition: validate.hxx:165
virtual void Close()
SfxTabPage * GetTabPage(std::string_view rPageId) const
#define SC_MOD()
Definition: scmod.hxx:249
virtual ~ScRefHandlerCaller()
Definition: validate.hxx:29
sal_uInt16 sal_Unicode