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 bool CloseOnHide() const override { return false; }
182
183 virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override
184 {
186 (m_pHandler->*m_pSetReferenceHdl)( rRef, rDoc );
187 }
188
189 virtual void SetActive() override
190 {
193 }
194
195 bool IsRefInputting() const { return m_bRefInputting; }
197
198 virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override
199 {
200 if( !CanInputStart( pEdit ) )
201 return;
202
204 (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton );
205 m_bRefInputting = true;
206 ScValidationDlgBase::RefInputStart( pEdit, pButton );
207 }
208
209 virtual void RefInputDone( bool bForced = false ) override
210 {
211 if( !CanInputDone( bForced ) )
212 return;
213
215 m_bRefInputting = false;
216
219 }
220
221 bool IsChildFocus() const;
222
223 enum { SLOTID = SID_VALIDITY_REFERENCE };
224
225 virtual void Close() override
226 {
227 if (m_bOwnRefHdlr)
228 {
230 static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(false);
231 }
233 }
234};
235
237{
238private:
239 std::unique_ptr<weld::CheckButton> m_xTsbHelp;
240 std::unique_ptr<weld::Entry> m_xEdtTitle;
241 std::unique_ptr<weld::TextView> m_xEdInputHelp;
242
243public:
244 ScTPValidationHelp(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
245 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
246 virtual ~ScTPValidationHelp() override;
247
248 virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
249 virtual void Reset ( const SfxItemSet* rArgSet ) override;
250};
251
253{
254private:
255 std::unique_ptr<weld::CheckButton> m_xTsbShow;
256 std::unique_ptr<weld::ComboBox> m_xLbAction;
257 std::unique_ptr<weld::Button> m_xBtnSearch;
258 std::unique_ptr<weld::Entry> m_xEdtTitle;
259 std::unique_ptr<weld::Label> m_xFtError;
260 std::unique_ptr<weld::TextView> m_xEdError;
261
262 void Init();
263
264 // Handler ------------------------
265 DECL_LINK(SelectActionHdl, weld::ComboBox&, void);
266 DECL_LINK(ClickSearchHdl, weld::Button&, void);
267
268public:
269 ScTPValidationError(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
270 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
271 virtual ~ScTPValidationError() override;
272
273 virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
274 virtual void Reset ( const SfxItemSet* rArgSet ) override;
275};
276
277/* 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:745
virtual void RefInputDone(bool bForced=false) override
Definition: anyrefdg.cxx:775
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:259
std::unique_ptr< weld::Button > m_xBtnSearch
Definition: validate.hxx:257
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:784
std::unique_ptr< weld::ComboBox > m_xLbAction
Definition: validate.hxx:256
virtual ~ScTPValidationError() override
Definition: validate.cxx:764
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:778
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:809
std::unique_ptr< weld::TextView > m_xEdError
Definition: validate.hxx:260
ScTPValidationError(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:747
std::unique_ptr< weld::CheckButton > m_xTsbShow
Definition: validate.hxx:255
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: validate.hxx:258
std::unique_ptr< weld::TextView > m_xEdInputHelp
Definition: validate.hxx:241
virtual ~ScTPValidationHelp() override
Definition: validate.cxx:708
std::unique_ptr< weld::CheckButton > m_xTsbHelp
Definition: validate.hxx:239
virtual bool FillItemSet(SfxItemSet *rArgSet) override
Definition: validate.cxx:736
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:712
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: validate.hxx:240
ScTPValidationHelp(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
Definition: validate.cxx:699
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:718
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:471
void SetFirstFormula(const OUString &rFmlaStr)
Definition: validate.cxx:507
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:350
static const WhichRangesContainer & GetRanges()
Definition: validate.hxx:84
formula::RefEdit * m_pRefEdit
Definition: validate.hxx:114
void RefInputDonePostHdl()
Definition: validate.cxx:177
std::unique_ptr< weld::Container > m_xRefGrid
Definition: validate.hxx:130
virtual void Reset(const SfxItemSet *rArgSet) override
Definition: validate.cxx:432
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:400
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
Definition: validate.cxx:427
void SetReferenceHdl(const ScRange &, const ScDocument &)
Definition: validate.cxx:125
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:150
std::unique_ptr< weld::CheckButton > m_xCbSort
Show selection list in cell.
Definition: validate.hxx:119
void SetSecondFormula(const OUString &rFmlaStr)
Definition: validate.cxx:526
DECL_LINK(KillEditFocusHdl, formula::RefEdit &, void)
OUString GetFirstFormula() const
Definition: validate.cxx:492
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:531
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:502
void RemoveRefDlg(bool bRestoreModal)
Definition: validate.cxx:573
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:886
virtual ~ScValidationDlg() override
Definition: validate.cxx:119
virtual void EndDialog(int nResponse) override
Definition: validate.cxx:105
bool m_bRefInputting
Definition: validate.hxx:155
bool IsRefInputting() const
Definition: validate.hxx:195
bool LeaveRefStatus()
Definition: validate.cxx:858
virtual void RefInputDone(bool bForced=false) override
Definition: validate.hxx:209
bool IsChildFocus() const
Definition: validate.cxx:926
virtual void Close() override
Definition: validate.hxx:225
bool SetupRefDlg()
Definition: validate.cxx:873
virtual void SetActive() override
Definition: validate.hxx:189
ScRefHdlrControllerImpl< SfxTabDialogController, false > ScValidationDlgBase
Definition: validate.hxx:150
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: validate.hxx:198
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:183
virtual bool CloseOnHide() const override
Definition: validate.hxx:181
std::unique_ptr< weld::Container > m_xHBox
Definition: validate.hxx:157
void SetModal(bool bModal)
Definition: validate.hxx:177
OUString m_sValuePageId
Definition: validate.hxx:153
ScTabViewShell * m_pTabVwSh
Definition: validate.hxx:152
bool EnterRefStatus()
Definition: validate.cxx:841
weld::Container * get_refinput_shrink_parent()
Definition: validate.hxx:196
static std::shared_ptr< SfxDialogController > Find1AliveObject(const weld::Window *pAncestor)
Definition: validate.hxx:165
virtual void Close()
SfxTabPage * GetTabPage(std::u16string_view rPageId) const
#define SC_MOD()
Definition: scmod.hxx:247
virtual ~ScRefHandlerCaller()
Definition: validate.hxx:29
sal_uInt16 sal_Unicode