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 RPTUI_FORMULA_HXX 25 #define RPTUI_FORMULA_HXX 26 27 #include <formula/formula.hxx> 28 #include <formula/IFunctionDescription.hxx> 29 #include <formula/IControlReferenceHandler.hxx> 30 #include <boost/shared_ptr.hpp> 31 #include <com/sun/star/beans/XPropertySet.hpp> 32 #include <com/sun/star/report/meta/XFormulaParser.hpp> 33 34 class SvLBoxEntry; 35 //============================================================================ 36 namespace rptui 37 { 38 //============================================================================ 39 class FunctionManager; 40 class OAddFieldWindow; 41 42 //============================================================================ 43 class FormulaDialog : public formula::FormulaModalDialog, 44 public formula::IFormulaEditorHelper, 45 public formula::IControlReferenceHandler 46 { 47 ::boost::shared_ptr< formula::IFunctionManager > m_aFunctionManager; 48 formula::FormEditData* m_pFormulaData; 49 OAddFieldWindow* m_pAddField; 50 ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > m_xRowSet; 51 ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFormulaParser> m_xParser; 52 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> m_xOpCodeMapper; 53 formula::RefEdit* m_pEdit; 54 String m_sFormula; 55 xub_StrLen m_nStart; 56 xub_StrLen m_nEnd; 57 58 DECL_LINK( OnClickHdl, OAddFieldWindow*); 59 public: 60 FormulaDialog( Window* pParent 61 , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xServiceFactory 62 , const ::boost::shared_ptr< formula::IFunctionManager >& _pFunctionMgr 63 , const ::rtl::OUString& _sFormula 64 , const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& _xRowSet); 65 virtual ~FormulaDialog(); 66 67 // IFormulaEditorHelper 68 virtual void notifyChange(); 69 virtual void fill(); 70 virtual bool calculateValue(const String& _sExpression,String& _rResult); 71 virtual void doClose(sal_Bool _bOk); 72 virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc); 73 virtual void showReference(const String& _sFormula); 74 virtual void dispatch(sal_Bool _bOK,sal_Bool _bMartixChecked); 75 virtual void setDispatcherLock( sal_Bool bLock ); 76 virtual void setReferenceInput(const formula::FormEditData* _pData); 77 virtual void deleteFormData(); 78 virtual void clear(); 79 virtual void switchBack(); 80 virtual formula::FormEditData* getFormEditData() const; 81 virtual void setCurrentFormula(const String& _sReplacement); 82 virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd); 83 virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const; 84 virtual String getCurrentFormula() const; 85 86 virtual formula::IFunctionManager* getFunctionManager(); 87 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const; 88 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const; 89 virtual ::com::sun::star::table::CellAddress getReferencePosition() const; 90 91 virtual ::std::auto_ptr<formula::FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList); 92 93 // IControlReferenceHandler 94 virtual void ShowReference(const String& _sRef); 95 virtual void HideReference( sal_Bool bDoneRefMode = sal_True ); 96 virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); 97 virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ); 98 99 protected: 100 void HighlightFunctionParas(const String& aFormula); 101 }; 102 103 // ============================================================================= 104 } // rptui 105 // ============================================================================= 106 107 #endif // RPTUI_FORMULA_HXX 108 109