tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / validate.hxx
blob5fdbdc7568ce449d31189fbd17ce13e1563c1174
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sfx2/tabdlg.hxx>
24 #include "anyrefdg.hxx"
25 #include <sc.hrc>
26 #include <scmod.hxx>
28 struct ScRefHandlerCaller{
29 virtual ~ScRefHandlerCaller(){}
32 class ScRefHandlerHelper
34 protected:
35 ScRefHandlerCaller* m_pHandler;
36 // workaround VS2013 issue with pointers to things that contain virtual base class
37 #ifdef _WIN32
38 #pragma pack(push, 16)
39 #endif
40 void (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , const ScDocument& );
41 void (ScRefHandlerCaller::*m_pSetActiveHdl)();
42 void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::RefEdit* pEdit, const formula::RefButton* pButton );
43 void (ScRefHandlerCaller::*m_pRefInputDonePostHdl)();
44 #if defined( _WIN32)
45 #pragma pack(pop)
46 #endif
48 public:
49 typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , const ScDocument& );
50 typedef void (ScRefHandlerCaller::*PCOMMONHDLTYPE)();
51 typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::RefEdit* pEdit, const formula::RefButton* pButton );
53 void SetSetRefHdl( PFUNCSETREFHDLTYPE pNewHdl )
55 m_pSetReferenceHdl = pNewHdl;
58 void SetSetActHdl( PCOMMONHDLTYPE pNewHdl )
60 m_pSetActiveHdl = pNewHdl;
63 void SetHandler( ScRefHandlerCaller *pNewHandler )
65 m_pHandler = pNewHandler;
67 void SetRefInputStartPreHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPreHdl = pNewHdl; }
68 void SetRefInputDonePostHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePostHdl = pNewHdl; }
70 ScRefHandlerHelper():m_pHandler(nullptr), m_pSetReferenceHdl( nullptr ), m_pSetActiveHdl(nullptr), m_pRefInputStartPreHdl( nullptr ), m_pRefInputDonePostHdl( nullptr ){}
73 class ScValidationDlg;
75 /** The tab page "Criteria" from the Validation dialog. */
76 class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage
78 static const WhichRangesContainer 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;
84 static const WhichRangesContainer& GetRanges() { return pValueRanges; }
86 virtual bool FillItemSet( SfxItemSet* rArgSet ) override;
87 virtual void Reset( const SfxItemSet* rArgSet ) override;
89 private:
90 void Init();
92 OUString GetFirstFormula() const;
93 OUString GetSecondFormula() const;
95 void SetFirstFormula( const OUString& rFmlaStr );
96 void SetSecondFormula( const OUString& rFmlaStr );
98 DECL_LINK(SelectHdl, weld::ComboBox&, void);
99 DECL_LINK(CheckHdl, weld::Toggleable&, void);
101 OUString maStrMin;
102 OUString maStrMax;
103 OUString maStrValue;
104 OUString maStrFormula;
105 OUString maStrRange;
106 OUString maStrList;
107 sal_Unicode mcFmlaSep; /// List separator in formulas.
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 );
114 formula::RefEdit* m_pRefEdit;
116 std::unique_ptr<weld::ComboBox> m_xLbAllow;
117 std::unique_ptr<weld::CheckButton> m_xCbAllow; /// Allow blank cells.
118 std::unique_ptr<weld::CheckButton> m_xCbCaseSens; /// Allow Case sensitive.
119 std::unique_ptr<weld::CheckButton> m_xCbShow; /// Show selection list in cell.
120 std::unique_ptr<weld::CheckButton> m_xCbSort; /// Sort selection list in cell.
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; /// Entries for explicit list
127 std::unique_ptr<weld::Label> m_xFtMax;
128 std::unique_ptr<formula::RefEdit> m_xEdMax;
129 std::unique_ptr<weld::Label> m_xFtHint; /// Hint text for cell range validity.
130 std::unique_ptr<formula::RefButton> m_xBtnRef;
131 std::unique_ptr<weld::Container> m_xRefGrid;
133 weld::Container* m_pRefEditParent;
134 weld::Container* m_pBtnRefParent;
136 void SetReferenceHdl( const ScRange& , const ScDocument& );
137 void SetActiveHdl();
138 void RefInputStartPreHdl(formula::RefEdit* pEdit, const formula::RefButton* pButton);
139 void RefInputDonePostHdl();
140 ScValidationDlg * GetValidationDlg();
141 public:
142 void SetupRefDlg();
143 void RemoveRefDlg(bool bRestoreModal);
146 /** The "Validity" tab dialog. */
147 class ScValidationDlg
148 : public ScRefHdlrControllerImpl<SfxTabDialogController, false>
149 , public ScRefHandlerHelper
151 typedef ScRefHdlrControllerImpl<SfxTabDialogController, false> ScValidationDlgBase;
153 ScTabViewShell * m_pTabVwSh;
154 OUString m_sValuePageId;
155 bool m_bOwnRefHdlr:1;
156 bool m_bRefInputting:1;
158 std::unique_ptr<weld::Container> m_xHBox;
160 bool EnterRefStatus();
161 bool LeaveRefStatus();
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)
168 return ScModule::get()->Find1RefWindow(SLOTID, pAncestor);
170 ScTabViewShell *GetTabViewShell()
172 return m_pTabVwSh;
175 bool SetupRefDlg();
176 bool RemoveRefDlg(bool bRestoreModal);
178 void SetModal(bool bModal) { m_xDialog->set_modal(bModal); }
180 virtual void EndDialog(int nResponse) override;
182 virtual bool CloseOnHide() const override { return false; }
184 virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override
186 if ( m_pHandler && m_pSetReferenceHdl )
187 (m_pHandler->*m_pSetReferenceHdl)( rRef, rDoc );
190 virtual void SetActive() override
192 if ( m_pHandler && m_pSetActiveHdl )
193 (m_pHandler->*m_pSetActiveHdl)();
196 bool IsRefInputting() const { return m_bRefInputting; }
197 weld::Container* get_refinput_shrink_parent() { return m_xHBox.get(); }
199 virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override
201 if( !CanInputStart( pEdit ) )
202 return;
204 if ( m_pHandler && m_pRefInputStartPreHdl )
205 (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton );
206 m_bRefInputting = true;
207 ScValidationDlgBase::RefInputStart( pEdit, pButton );
210 virtual void RefInputDone( bool bForced = false ) override
212 if( !CanInputDone( bForced ) )
213 return;
215 ScValidationDlgBase::RefInputDone( bForced );
216 m_bRefInputting = false;
218 if ( m_pHandler && m_pRefInputDonePostHdl )
219 (m_pHandler->*m_pRefInputDonePostHdl)();
222 bool IsChildFocus() const;
224 enum { SLOTID = SID_VALIDITY_REFERENCE };
226 virtual void Close() override
228 if (m_bOwnRefHdlr)
230 if (SfxTabPage* pPage = GetTabPage(m_sValuePageId))
231 static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg(false);
233 ScValidationDlgBase::Close();
237 class ScTPValidationHelp : public SfxTabPage
239 private:
240 std::unique_ptr<weld::CheckButton> m_xTsbHelp;
241 std::unique_ptr<weld::Entry> m_xEdtTitle;
242 std::unique_ptr<weld::TextView> m_xEdInputHelp;
244 public:
245 ScTPValidationHelp(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
246 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
247 virtual ~ScTPValidationHelp() override;
249 virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
250 virtual void Reset ( const SfxItemSet* rArgSet ) override;
253 class ScTPValidationError : public SfxTabPage
255 private:
256 std::unique_ptr<weld::CheckButton> m_xTsbShow;
257 std::unique_ptr<weld::ComboBox> m_xLbAction;
258 std::unique_ptr<weld::Button> m_xBtnSearch;
259 std::unique_ptr<weld::Entry> m_xEdtTitle;
260 std::unique_ptr<weld::Label> m_xFtError;
261 std::unique_ptr<weld::TextView> m_xEdError;
263 void Init();
265 // Handler ------------------------
266 DECL_LINK(SelectActionHdl, weld::ComboBox&, void);
267 DECL_LINK(ClickSearchHdl, weld::Button&, void);
269 public:
270 ScTPValidationError(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
271 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rArgSet);
272 virtual ~ScTPValidationError() override;
274 virtual bool FillItemSet ( SfxItemSet* rArgSet ) override;
275 virtual void Reset ( const SfxItemSet* rArgSet ) override;
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */