xref: /trunk/main/sc/source/ui/inc/formula.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_FORMULA_HXX
29 #define SC_FORMULA_HXX
30 
31 #include "anyrefdg.hxx"
32 #include "global.hxx"		// ScAddress
33 #include <svtools/stdctrl.hxx>
34 #ifndef _LSTBOX_HXX //autogen
35 #include <vcl/lstbox.hxx>
36 #endif
37 #include <vcl/group.hxx>
38 #include <svtools/svmedit.hxx>
39 #include <vcl/tabpage.hxx>
40 
41 #ifndef _SVSTDARR_STRINGS
42 
43 #define _SVSTDARR_STRINGS
44 #include <svl/svstdarr.hxx>
45 
46 #endif
47 #include "compiler.hxx"
48 #include "cell.hxx"
49 
50 #include "formula/formula.hxx"
51 #include "IAnyRefDialog.hxx"
52 #include "anyrefdg.hxx"
53 #include <formula/IFunctionDescription.hxx>
54 
55 class ScViewData;
56 class ScDocument;
57 class ScFuncDesc;
58 class ScInputHandler;
59 class ScDocShell;
60 class SvLBoxEntry;
61 
62 //============================================================================
63 typedef ScTabViewShell* PtrTabViewShell;
64 //============================================================================
65 
66 class ScFormulaDlg : public formula::FormulaDlg,
67                      public IAnyRefDialog,
68                      public formula::IFormulaEditorHelper
69 {
70     ScFormulaReferenceHelper m_aHelper;
71     ScFormulaCell*	pCell;
72 	::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser>          m_xParser;
73     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper>    m_xOpCodeMapper;
74 
75     static ScDocument*	pDoc;
76 	static ScAddress	aCursorPos;
77 public:
78 					ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
79                         Window* pParent, ScViewData* pViewData ,formula::IFunctionManager* _pFunctionMgr);
80 					~ScFormulaDlg();
81 
82     // IFormulaEditorHelper
83     virtual void notifyChange();
84     virtual void fill();
85     virtual bool calculateValue(const String& _sExpression,String& _rResult);
86     virtual void doClose(sal_Bool _bOk);
87     virtual void insertEntryToLRUList(const formula::IFunctionDescription*	pDesc);
88     virtual void showReference(const String& _sFormula);
89     virtual void dispatch(sal_Bool _bOK,sal_Bool _bMartixChecked);
90     virtual void setDispatcherLock( sal_Bool bLock );
91     virtual void setReferenceInput(const formula::FormEditData* _pData);
92     virtual void deleteFormData();
93     virtual void clear();
94     virtual void switchBack();
95     virtual formula::FormEditData* getFormEditData() const;
96     virtual void setCurrentFormula(const String& _sReplacement);
97     virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd);
98     virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const;
99     virtual String getCurrentFormula() const;
100 
101     virtual formula::IFunctionManager* getFunctionManager();
102     virtual ::std::auto_ptr<formula::FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList);
103     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const;
104     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const;
105     virtual ::com::sun::star::table::CellAddress getReferencePosition() const;
106 
107 	virtual sal_Bool	Close();
108 
109     // sc::IAnyRefDialog
110     virtual void ShowReference(const String& _sRef);
111     virtual void HideReference( sal_Bool bDoneRefMode = sal_True );
112     virtual void SetReference( const ScRange& rRef, ScDocument* pD );
113 
114     virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
115     virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
116     virtual void RefInputDone( sal_Bool bForced = sal_False );
117     virtual sal_Bool IsTableLocked() const;
118     virtual sal_Bool IsRefInputMode() const;
119 
120     virtual sal_Bool IsDocAllowed( SfxObjectShell* pDocSh ) const;
121     virtual void AddRefEntry();
122     virtual void SetActive();
123     virtual void ViewShellChanged( ScTabViewShell* pScViewShell );
124 protected:
125 
126 	virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
127 	sal_uLong		 FindFocusWin(Window *pWin);
128 	void		 SaveLRUEntry(const ScFuncDesc*	pFuncDesc);
129 	void		 HighlightFunctionParas(const String& aFormula);
130 
131     sal_Bool        IsInputHdl(ScInputHandler* pHdl);
132     ScInputHandler* GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh);
133 };
134 
135 
136 
137 #endif // SC_CRNRDLG_HXX
138 
139