fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / inc / validate.hxx
blob0cf1d9370e1f8a7f8b6d152690c8d75d3a98133c
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 #ifndef INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX
23 #include <sfx2/tabdlg.hxx>
24 #include <vcl/edit.hxx>
25 #include <vcl/fixed.hxx>
26 #include <vcl/layout.hxx>
27 #include <vcl/lstbox.hxx>
28 #include <vcl/vclmedit.hxx>
29 #include <svtools/svmedit.hxx>
31 #include "anyrefdg.hxx"
33 struct ScRefHandlerCaller{
34 virtual ~ScRefHandlerCaller(){}
36 class ScRefHandlerHelper
38 protected:
39 ScRefHandlerCaller *m_pHandler;
40 void (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , ScDocument* );
41 void (ScRefHandlerCaller::*m_pSetActiveHdl)();
42 void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( formula::RefEdit* pEdit, formula::RefButton* pButton );
43 void (ScRefHandlerCaller::*m_pRefInputStartPostHdl)( formula::RefEdit* pEdit, formula::RefButton* pButton );
44 void (ScRefHandlerCaller::*m_pRefInputDonePreHdl)();
45 void (ScRefHandlerCaller::*m_pRefInputDonePostHdl)();
47 public:
48 typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , ScDocument* );
49 typedef void (ScRefHandlerCaller::*PCOMMONHDLTYPE)();
50 typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( formula::RefEdit* pEdit, formula::RefButton* pButton );
52 PFUNCSETREFHDLTYPE SetSetRefHdl( PFUNCSETREFHDLTYPE pNewHdl )
54 PFUNCSETREFHDLTYPE pOldHdl = m_pSetReferenceHdl;
55 m_pSetReferenceHdl = pNewHdl;
56 return pOldHdl;
59 PCOMMONHDLTYPE SetSetActHdl( PCOMMONHDLTYPE pNewHdl )
61 PCOMMONHDLTYPE pOldHdl = m_pSetActiveHdl;
62 m_pSetActiveHdl = pNewHdl;
63 return pOldHdl;
66 ScRefHandlerCaller *SetHandler( ScRefHandlerCaller *pNewHandler )
68 ScRefHandlerCaller *pOldHandler = m_pHandler;
69 m_pHandler = pNewHandler;
70 return pOldHandler;
72 void SetRefInputStartPreHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPreHdl = pNewHdl; }
73 void SetRefInputDonePostHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePostHdl = pNewHdl; }
74 void SetRefInputStartPostHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPostHdl = pNewHdl; }
75 void SetRefInputDonePreHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePreHdl = pNewHdl; }
77 ScRefHandlerHelper():m_pHandler(NULL), m_pSetReferenceHdl( NULL ), m_pSetActiveHdl(NULL), m_pRefInputStartPreHdl( NULL ), m_pRefInputStartPostHdl( NULL ), m_pRefInputDonePreHdl( NULL ), m_pRefInputDonePostHdl( NULL ){}
80 class ScValidationDlg;
82 /** The tab page "Criteria" from the Validation dialog. */
83 class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage
85 static const sal_uInt16 pValueRanges[];
86 public:
87 explicit ScTPValidationValue( vcl::Window* pParent, const SfxItemSet& rArgSet );
88 virtual ~ScTPValidationValue();
89 virtual void dispose() SAL_OVERRIDE;
90 static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rArgSet );
91 static const sal_uInt16* GetRanges() { return pValueRanges; }
93 virtual bool FillItemSet( SfxItemSet* rArgSet ) SAL_OVERRIDE;
94 virtual void Reset( const SfxItemSet* rArgSet ) SAL_OVERRIDE;
96 private:
97 void Init();
99 OUString GetFirstFormula() const;
100 OUString GetSecondFormula() const;
102 void SetFirstFormula( const OUString& rFmlaStr );
103 void SetSecondFormula( const OUString& rFmlaStr );
105 DECL_LINK(SelectHdl, void *);
106 DECL_LINK(CheckHdl, void *);
108 VclPtr<ListBox> m_pLbAllow;
109 VclPtr<CheckBox> m_pCbAllow; /// Allow blank cells.
110 VclPtr<CheckBox> m_pCbShow; /// Show selection list in cell.
111 VclPtr<CheckBox> m_pCbSort; /// Sort selection list in cell.
112 VclPtr<FixedText> m_pFtValue;
113 VclPtr<ListBox> m_pLbValue;
114 VclPtr<FixedText> m_pFtMin;
115 VclPtr<VclContainer> m_pMinGrid;
116 VclPtr<formula::RefEdit> m_pEdMin;
117 VclPtr<VclMultiLineEdit> m_pEdList; /// Entries for explicit list
118 VclPtr<FixedText> m_pFtMax;
119 VclPtr<formula::RefEdit> m_pEdMax;
120 VclPtr<FixedText> m_pFtHint; /// Hint text for cell range validity.
122 OUString maStrMin;
123 OUString maStrMax;
124 OUString maStrValue;
125 OUString maStrRange;
126 OUString maStrList;
127 sal_Unicode mcFmlaSep; /// List separator in formulas.
129 DECL_LINK(EditSetFocusHdl, void *);
130 DECL_LINK( KillFocusHdl, vcl::Window *);
131 void OnClick( Button *pBtn );
132 VclPtr<formula::RefEdit> m_pRefEdit;
133 public:
134 class ScRefButtonEx : public ::formula::RefButton
136 VclPtr<ScTPValidationValue> m_pPage;
137 virtual void Click() SAL_OVERRIDE;
138 public:
139 ScRefButtonEx(vcl::Window* pParent, WinBits nStyle)
140 : ::formula::RefButton(pParent, nStyle)
141 , m_pPage(NULL)
144 virtual ~ScRefButtonEx();
145 virtual void dispose() SAL_OVERRIDE;
146 void SetParentPage(ScTPValidationValue *pPage)
148 m_pPage = pPage;
150 ScTPValidationValue* GetParentPage()
152 return m_pPage;
155 private:
156 VclPtr<ScRefButtonEx> m_pBtnRef;
157 VclPtr<VclContainer> m_pRefGrid;
158 friend class ScRefButtonEx;
159 void SetReferenceHdl( const ScRange& , ScDocument* );
160 void SetActiveHdl();
161 void RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton );
162 void RefInputDonePostHdl();
163 ScValidationDlg * GetValidationDlg();
164 public:
165 sal_uInt16 GetAllowEntryPos();
166 OUString GetMinText();
167 void SetupRefDlg();
168 void RemoveRefDlg();
171 /** The "Validity" tab dialog. */
172 class ScValidationDlg
173 : public ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false>
174 , public ScRefHandlerHelper
176 typedef ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false> ScValidationDlgBase;
178 DECL_LINK( OkHdl, Button * );
180 ScTabViewShell *m_pTabVwSh;
181 VclPtr<VclHBox> m_pHBox;
182 sal_uInt16 m_nValuePageId;
183 bool m_bOwnRefHdlr:1;
184 bool m_bRefInputting:1;
186 bool EnterRefStatus();
187 bool LeaveRefStatus();
189 public:
190 explicit ScValidationDlg( vcl::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell * pTabViewSh, SfxBindings *pB = NULL );
191 virtual ~ScValidationDlg() { disposeOnce(); }
192 virtual void dispose() SAL_OVERRIDE
194 if( m_bOwnRefHdlr )
195 RemoveRefDlg( false );
196 m_pHBox.clear();
197 ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false>::dispose();
199 static ScValidationDlg * Find1AliveObject( vcl::Window *pAncestor )
201 return static_cast<ScValidationDlg *>( SC_MOD()->Find1RefWindow( SLOTID, pAncestor ) );
203 ScTabViewShell *GetTabViewShell()
205 return m_pTabVwSh;
208 bool SetupRefDlg();
209 bool RemoveRefDlg( bool bRestoreModal = true );
211 void SetModal( bool bModal ){ ScValidationDlgBase::SetModalInputMode( bModal ); }
213 virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) SAL_OVERRIDE
215 if ( m_pHandler && m_pSetReferenceHdl )
216 (m_pHandler->*m_pSetReferenceHdl)( rRef, pDoc );
219 virtual void SetActive() SAL_OVERRIDE
221 if ( m_pHandler && m_pSetActiveHdl )
222 (m_pHandler->*m_pSetActiveHdl)();
225 void CloseRefDialog()
227 OSL_FAIL( "should not execute here!!!when the edit kill focus, should remove refhandler.\r\n" );
229 if ( IsInExecute() )
230 EndDialog( RET_CANCEL );
231 else if ( GetStyle() & WB_CLOSEABLE )
232 Close();
235 bool IsRefInputting(){ return m_bRefInputting; }
236 vcl::Window* get_refinput_shrink_parent() { return m_pHBox; }
238 virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) SAL_OVERRIDE
240 if( !CanInputStart( pEdit ) )
241 return;
243 if ( m_pHandler && m_pRefInputStartPreHdl )
244 (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton );
245 m_bRefInputting = true;
246 ScValidationDlgBase::RefInputStart( pEdit, pButton );
247 if ( m_pHandler && m_pRefInputStartPostHdl )
248 (m_pHandler->*m_pRefInputStartPostHdl)( pEdit, pButton );
251 virtual void RefInputDone( bool bForced = false ) SAL_OVERRIDE
253 if( !CanInputDone( bForced ) )
254 return;
256 if ( m_pHandler && m_pRefInputDonePreHdl )
257 (m_pHandler->*m_pRefInputDonePreHdl)();
259 ScValidationDlgBase::RefInputDone( bForced );
260 m_bRefInputting = false;
262 if ( m_pHandler && m_pRefInputDonePostHdl )
263 (m_pHandler->*m_pRefInputDonePostHdl)();
266 bool IsChildFocus();
268 enum { SLOTID = SID_VALIDITY_REFERENCE };
270 bool Close() SAL_OVERRIDE
272 if( m_bOwnRefHdlr )
274 if (SfxTabPage* pPage = GetTabPage(m_nValuePageId))
275 static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg();
278 return ScValidationDlgBase::Close();
282 class ScTPValidationHelp : public SfxTabPage
284 private:
285 VclPtr<TriStateBox> pTsbHelp;
286 VclPtr<Edit> pEdtTitle;
287 VclPtr<VclMultiLineEdit> pEdInputHelp;
289 void Init();
291 // Handler ------------------------
292 // DECL_LINK( SelectHdl, ListBox * );
294 public:
295 ScTPValidationHelp( vcl::Window* pParent, const SfxItemSet& rArgSet );
296 virtual ~ScTPValidationHelp();
297 virtual void dispose() SAL_OVERRIDE;
299 static VclPtr<SfxTabPage> Create ( vcl::Window* pParent, const SfxItemSet* rArgSet );
300 virtual bool FillItemSet ( SfxItemSet* rArgSet ) SAL_OVERRIDE;
301 virtual void Reset ( const SfxItemSet* rArgSet ) SAL_OVERRIDE;
304 class ScTPValidationError : public SfxTabPage
306 private:
307 VclPtr<TriStateBox> m_pTsbShow;
308 VclPtr<ListBox> m_pLbAction;
309 VclPtr<PushButton> m_pBtnSearch;
310 VclPtr<Edit> m_pEdtTitle;
311 VclPtr<FixedText> m_pFtError;
312 VclPtr<VclMultiLineEdit> m_pEdError;
314 void Init();
316 // Handler ------------------------
317 DECL_LINK(SelectActionHdl, void *);
318 DECL_LINK(ClickSearchHdl, void *);
320 public:
321 ScTPValidationError( vcl::Window* pParent, const SfxItemSet& rArgSet );
322 virtual ~ScTPValidationError();
323 virtual void dispose() SAL_OVERRIDE;
325 static VclPtr<SfxTabPage> Create ( vcl::Window* pParent, const SfxItemSet* rArgSet );
326 virtual bool FillItemSet ( SfxItemSet* rArgSet ) SAL_OVERRIDE;
327 virtual void Reset ( const SfxItemSet* rArgSet ) SAL_OVERRIDE;
330 #endif // INCLUDED_SC_SOURCE_UI_INC_VALIDATE_HXX
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */