xref: /aoo42x/main/sc/source/ui/inc/formula.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_FORMULA_HXX
25 #define SC_FORMULA_HXX
26 
27 #include "anyrefdg.hxx"
28 #include "global.hxx"		// ScAddress
29 #include <svtools/stdctrl.hxx>
30 #ifndef _LSTBOX_HXX //autogen
31 #include <vcl/lstbox.hxx>
32 #endif
33 #include <vcl/group.hxx>
34 #include <svtools/svmedit.hxx>
35 #include <vcl/tabpage.hxx>
36 
37 #ifndef _SVSTDARR_STRINGS
38 
39 #define _SVSTDARR_STRINGS
40 #include <svl/svstdarr.hxx>
41 
42 #endif
43 #include "compiler.hxx"
44 #include "cell.hxx"
45 
46 #include "formula/formula.hxx"
47 #include "IAnyRefDialog.hxx"
48 #include "anyrefdg.hxx"
49 #include <formula/IFunctionDescription.hxx>
50 
51 class ScViewData;
52 class ScDocument;
53 class ScFuncDesc;
54 class ScInputHandler;
55 class ScDocShell;
56 class SvLBoxEntry;
57 
58 //============================================================================
59 typedef ScTabViewShell* PtrTabViewShell;
60 //============================================================================
61 
62 class ScFormulaDlg : public formula::FormulaDlg,
63                      public IAnyRefDialog,
64                      public formula::IFormulaEditorHelper
65 {
66     ScFormulaReferenceHelper m_aHelper;
67     ScFormulaCell*	pCell;
68 	::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser>          m_xParser;
69     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper>    m_xOpCodeMapper;
70 
71     static ScDocument*	pDoc;
72 	static ScAddress	aCursorPos;
73 public:
74 					ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
75                         Window* pParent, ScViewData* pViewData ,formula::IFunctionManager* _pFunctionMgr);
76 					~ScFormulaDlg();
77 
78     // IFormulaEditorHelper
79     virtual void notifyChange();
80     virtual void fill();
81     virtual bool calculateValue(const String& _sExpression,String& _rResult);
82     virtual void doClose(sal_Bool _bOk);
83     virtual void insertEntryToLRUList(const formula::IFunctionDescription*	pDesc);
84     virtual void showReference(const String& _sFormula);
85     virtual void dispatch(sal_Bool _bOK,sal_Bool _bMartixChecked);
86     virtual void setDispatcherLock( sal_Bool bLock );
87     virtual void setReferenceInput(const formula::FormEditData* _pData);
88     virtual void deleteFormData();
89     virtual void clear();
90     virtual void switchBack();
91     virtual formula::FormEditData* getFormEditData() const;
92     virtual void setCurrentFormula(const String& _sReplacement);
93     virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd);
94     virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const;
95     virtual String getCurrentFormula() const;
96 
97     virtual formula::IFunctionManager* getFunctionManager();
98     virtual ::std::auto_ptr<formula::FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList);
99     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const;
100     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const;
101     virtual ::com::sun::star::table::CellAddress getReferencePosition() const;
102 
103 	virtual sal_Bool	Close();
104 
105     // sc::IAnyRefDialog
106     virtual void ShowReference(const String& _sRef);
107     virtual void HideReference( sal_Bool bDoneRefMode = sal_True );
108     virtual void SetReference( const ScRange& rRef, ScDocument* pD );
109 
110     virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
111     virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
112     virtual void RefInputDone( sal_Bool bForced = sal_False );
113     virtual sal_Bool IsTableLocked() const;
114     virtual sal_Bool IsRefInputMode() const;
115 
116     virtual sal_Bool IsDocAllowed( SfxObjectShell* pDocSh ) const;
117     virtual void AddRefEntry();
118     virtual void SetActive();
119     virtual void ViewShellChanged( ScTabViewShell* pScViewShell );
120 protected:
121 
122 	virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
123 	sal_uLong		 FindFocusWin(Window *pWin);
124 	void		 SaveLRUEntry(const ScFuncDesc*	pFuncDesc);
125 	void		 HighlightFunctionParas(const String& aFormula);
126 
127     sal_Bool        IsInputHdl(ScInputHandler* pHdl);
128     ScInputHandler* GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh);
129 };
130 
131 
132 
133 #endif // SC_CRNRDLG_HXX
134 
135