merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / inc / anyrefdg.hxx
blobd912d670f7e4b6026bd7efbf2c52e95864d8e827
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: anyrefdg.hxx,v $
10 * $Revision: 1.11.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_ANYREFDG_HXX
32 #define SC_ANYREFDG_HXX
34 #ifndef _IMAGEBTN_HXX
35 #include <vcl/imagebtn.hxx>
36 #endif
37 #ifndef _EDIT_HXX
38 #include <vcl/edit.hxx>
39 #endif
40 #ifndef _ACCEL_HXX
41 #include <vcl/accel.hxx>
42 #endif
43 #include <sfx2/basedlgs.hxx>
44 #include "address.hxx"
45 #include "formula/funcutl.hxx"
46 #include "IAnyRefDialog.hxx"
47 #include <memory>
49 class SfxObjectShell;
50 class ScRange;
51 class ScDocument;
52 class ScTabViewShell;
53 class ScAnyRefDlg;
54 class ScFormulaCell;
55 class ScCompiler;
56 class ScRangeList;
58 class ScFormulaReferenceHelper
60 IAnyRefDialog* m_pDlg;
61 ::std::auto_ptr<ScFormulaCell> pRefCell;
62 ::std::auto_ptr<ScCompiler> pRefComp;
63 formula::RefEdit* pRefEdit; // aktives Eingabefeld
64 formula::RefButton* pRefBtn; // Button dazu
65 Window* m_pWindow;
66 SfxBindings* m_pBindings;
67 ::std::auto_ptr<Accelerator>
68 pAccel; // fuer Enter/Escape
69 BOOL* pHiddenMarks; // Merkfeld fuer versteckte Controls
70 SCTAB nRefTab; // used for ShowReference
72 String sOldDialogText; // Originaltitel des Dialogfensters
73 Size aOldDialogSize; // Originalgroesse Dialogfenster
74 Point aOldEditPos; // Originalposition des Eingabefeldes
75 Size aOldEditSize; // Originalgroesse des Eingabefeldes
76 Point aOldButtonPos; // Originalpositiuon des Buttons
78 BOOL bEnableColorRef;
79 BOOL bHighLightRef;
80 BOOL bAccInserted;
82 DECL_LINK( AccelSelectHdl, Accelerator* );
84 public:
85 ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings);
86 ~ScFormulaReferenceHelper();
88 void ShowSimpleReference( const XubString& rStr );
89 void ShowFormulaReference( const XubString& rStr );
90 bool ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
91 void Init();
93 void ShowReference( const XubString& rStr );
94 void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
95 void HideReference( BOOL bDoneRefMode = TRUE );
96 void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
97 void RefInputDone( BOOL bForced = FALSE );
98 void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
100 inline void SetWindow(Window* _pWindow) { m_pWindow = _pWindow; }
101 BOOL DoClose( USHORT nId );
102 void SetDispatcherLock( BOOL bLock );
103 void EnableSpreadsheets( BOOL bFlag = TRUE, BOOL bChilds = TRUE );
104 void ViewShellChanged( ScTabViewShell* pScViewShell );
106 static void enableInput(BOOL _bInput);
108 //============================================================================
110 class ScAnyRefDlg : public SfxModelessDialog,
111 public IAnyRefDialog
113 friend class formula::RefButton;
114 friend class formula::RefEdit;
116 private:
117 ScFormulaReferenceHelper
118 m_aHelper;
119 SfxBindings* pMyBindings;
121 Window* pActiveWin;
122 Timer aTimer;
123 String aDocName; // document on which the dialog was opened
125 DECL_LINK( UpdateFocusHdl, Timer* );
128 protected:
129 virtual BOOL DoClose( USHORT nId );
131 void SetDispatcherLock( BOOL bLock );
133 virtual long PreNotify( NotifyEvent& rNEvt );
135 virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
136 virtual void RefInputDone( BOOL bForced = FALSE );
137 void ShowSimpleReference( const XubString& rStr );
138 void ShowFormulaReference( const XubString& rStr );
140 bool ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
142 public:
143 ScAnyRefDlg( SfxBindings* pB, SfxChildWindow* pCW,
144 Window* pParent, USHORT nResId);
145 virtual ~ScAnyRefDlg();
147 virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0;
148 virtual void AddRefEntry();
150 virtual BOOL IsRefInputMode() const;
151 virtual BOOL IsTableLocked() const;
152 virtual BOOL IsDocAllowed( SfxObjectShell* pDocSh ) const;
154 virtual void ShowReference( const XubString& rStr );
155 virtual void HideReference( BOOL bDoneRefMode = TRUE );
157 virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
158 virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
160 virtual void ViewShellChanged( ScTabViewShell* pScViewShell );
161 void SwitchToDocument();
162 SfxBindings& GetBindings();
164 virtual void SetActive() = 0;
165 // virtual BOOL Close();
166 virtual void StateChanged( StateChangedType nStateChange );
170 //============================================================================
172 #endif // SC_ANYREFDG_HXX