1*9ee13d13SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9ee13d13SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9ee13d13SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9ee13d13SAndrew Rist  * distributed with this work for additional information
6*9ee13d13SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9ee13d13SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9ee13d13SAndrew Rist  * "License"); you may not use this file except in compliance
9*9ee13d13SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9ee13d13SAndrew Rist  *
11*9ee13d13SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9ee13d13SAndrew Rist  *
13*9ee13d13SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9ee13d13SAndrew Rist  * software distributed under the License is distributed on an
15*9ee13d13SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9ee13d13SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9ee13d13SAndrew Rist  * specific language governing permissions and limitations
18*9ee13d13SAndrew Rist  * under the License.
19*9ee13d13SAndrew Rist  *
20*9ee13d13SAndrew Rist  *************************************************************/
21*9ee13d13SAndrew Rist 
22*9ee13d13SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef RPTUI_FORMULA_HXX
25cdf0e10cSrcweir #define RPTUI_FORMULA_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <formula/formula.hxx>
28cdf0e10cSrcweir #include <formula/IFunctionDescription.hxx>
29cdf0e10cSrcweir #include <formula/IControlReferenceHandler.hxx>
30cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
31cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
32cdf0e10cSrcweir #include <com/sun/star/report/meta/XFormulaParser.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir class SvLBoxEntry;
35cdf0e10cSrcweir //============================================================================
36cdf0e10cSrcweir namespace rptui
37cdf0e10cSrcweir {
38cdf0e10cSrcweir //============================================================================
39cdf0e10cSrcweir class FunctionManager;
40cdf0e10cSrcweir class OAddFieldWindow;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //============================================================================
43cdf0e10cSrcweir class FormulaDialog : public formula::FormulaModalDialog,
44cdf0e10cSrcweir                       public formula::IFormulaEditorHelper,
45cdf0e10cSrcweir                       public formula::IControlReferenceHandler
46cdf0e10cSrcweir {
47cdf0e10cSrcweir     ::boost::shared_ptr< formula::IFunctionManager > m_aFunctionManager;
48cdf0e10cSrcweir     formula::FormEditData*      m_pFormulaData;
49cdf0e10cSrcweir     OAddFieldWindow*		    m_pAddField;
50cdf0e10cSrcweir     ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >          m_xRowSet;
51cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFormulaParser>   m_xParser;
52cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper>    m_xOpCodeMapper;
53cdf0e10cSrcweir     formula::RefEdit*           m_pEdit;
54cdf0e10cSrcweir     String                      m_sFormula;
55cdf0e10cSrcweir     xub_StrLen                  m_nStart;
56cdf0e10cSrcweir     xub_StrLen                  m_nEnd;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     DECL_LINK( OnClickHdl, OAddFieldWindow*);
59cdf0e10cSrcweir public:
60cdf0e10cSrcweir 	FormulaDialog( Window* pParent
61cdf0e10cSrcweir         , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xServiceFactory
62cdf0e10cSrcweir         , const ::boost::shared_ptr< formula::IFunctionManager >& _pFunctionMgr
63cdf0e10cSrcweir         , const ::rtl::OUString& _sFormula
64cdf0e10cSrcweir         , const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& _xRowSet);
65cdf0e10cSrcweir 	virtual ~FormulaDialog();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     // IFormulaEditorHelper
68cdf0e10cSrcweir     virtual void notifyChange();
69cdf0e10cSrcweir     virtual void fill();
70cdf0e10cSrcweir     virtual bool calculateValue(const String& _sExpression,String& _rResult);
71cdf0e10cSrcweir     virtual void doClose(sal_Bool _bOk);
72cdf0e10cSrcweir     virtual void insertEntryToLRUList(const formula::IFunctionDescription*	pDesc);
73cdf0e10cSrcweir     virtual void showReference(const String& _sFormula);
74cdf0e10cSrcweir     virtual void dispatch(sal_Bool _bOK,sal_Bool _bMartixChecked);
75cdf0e10cSrcweir     virtual void setDispatcherLock( sal_Bool bLock );
76cdf0e10cSrcweir     virtual void setReferenceInput(const formula::FormEditData* _pData);
77cdf0e10cSrcweir     virtual void deleteFormData();
78cdf0e10cSrcweir     virtual void clear();
79cdf0e10cSrcweir     virtual void switchBack();
80cdf0e10cSrcweir     virtual formula::FormEditData* getFormEditData() const;
81cdf0e10cSrcweir     virtual void setCurrentFormula(const String& _sReplacement);
82cdf0e10cSrcweir     virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd);
83cdf0e10cSrcweir     virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const;
84cdf0e10cSrcweir     virtual String getCurrentFormula() const;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     virtual formula::IFunctionManager* getFunctionManager();
87cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const;
88cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const;
89cdf0e10cSrcweir     virtual ::com::sun::star::table::CellAddress getReferencePosition() const;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     virtual ::std::auto_ptr<formula::FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     // IControlReferenceHandler
94cdf0e10cSrcweir     virtual void ShowReference(const String& _sRef);
95cdf0e10cSrcweir     virtual void HideReference( sal_Bool bDoneRefMode = sal_True );
96cdf0e10cSrcweir     virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
97cdf0e10cSrcweir     virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir protected:
100cdf0e10cSrcweir 	void		 HighlightFunctionParas(const String& aFormula);
101cdf0e10cSrcweir };
102cdf0e10cSrcweir 
103cdf0e10cSrcweir // =============================================================================
104cdf0e10cSrcweir } // rptui
105cdf0e10cSrcweir // =============================================================================
106cdf0e10cSrcweir 
107cdf0e10cSrcweir #endif // RPTUI_FORMULA_HXX
108cdf0e10cSrcweir 
109