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 INCLUDE_FUNCTION_DESCRIPTION 25 #define INCLUDE_FUNCTION_DESCRIPTION 26 27 #include <vector> 28 #include <memory> 29 #include "formula/formuladllapi.h" 30 #include <rtl/ustring.hxx> 31 #include <tools/string.hxx> 32 #include <com/sun/star/sheet/XFormulaParser.hpp> 33 #include <com/sun/star/sheet/XFormulaOpCodeMapper.hpp> 34 35 class SvLBoxEntry; 36 37 namespace formula 38 { 39 class IFunctionCategory; 40 class IFunctionDescription; 41 class FormEditData; 42 class FormulaTokenArray; 43 44 // ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); 45 class SAL_NO_VTABLE IFunctionManager 46 { 47 public: IFunctionManager()48 IFunctionManager(){} 49 enum EToken 50 { 51 eOk, 52 eClose, 53 eSep, 54 eArrayOpen, 55 eArrayClose 56 }; 57 virtual sal_uInt32 getCount() const = 0; 58 virtual const IFunctionCategory* getCategory(sal_uInt32 nPos) const = 0; 59 virtual void fillLastRecentlyUsedFunctions(::std::vector< const IFunctionDescription*>& _rLastRUFunctions) const = 0; 60 virtual const IFunctionDescription* getFunctionByName(const ::rtl::OUString& _sFunctionName) const = 0; 61 62 virtual sal_Unicode getSingleToken(const EToken _eToken) const = 0; 63 }; 64 65 class SAL_NO_VTABLE IFunctionCategory 66 { 67 public: IFunctionCategory()68 IFunctionCategory(){} 69 virtual const IFunctionManager* getFunctionManager() const = 0; 70 virtual sal_uInt32 getCount() const = 0; 71 virtual const IFunctionDescription* getFunction(sal_uInt32 _nPos) const = 0; 72 virtual sal_uInt32 getNumber() const = 0; 73 virtual ::rtl::OUString getName() const = 0; 74 }; 75 76 class SAL_NO_VTABLE IFunctionDescription 77 { 78 public: IFunctionDescription()79 IFunctionDescription(){} 80 virtual ::rtl::OUString getFunctionName() const = 0; 81 virtual const IFunctionCategory* getCategory() const = 0; 82 virtual ::rtl::OUString getDescription() const = 0; 83 // GetSuppressedArgCount 84 virtual xub_StrLen getSuppressedArgumentCount() const = 0; 85 // GetFormulaString 86 virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& _aArguments) const = 0; 87 // GetVisibleArgMapping 88 virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const = 0; 89 virtual void initArgumentInfo() const = 0; 90 virtual ::rtl::OUString getSignature() const = 0; 91 virtual rtl::OString getHelpId() const = 0; 92 93 // parameter 94 virtual sal_uInt32 getParameterCount() const = 0; 95 virtual ::rtl::OUString getParameterName(sal_uInt32 _nPos) const = 0; 96 virtual ::rtl::OUString getParameterDescription(sal_uInt32 _nPos) const = 0; 97 virtual bool isParameterOptional(sal_uInt32 _nPos) const = 0; 98 }; 99 100 class SAL_NO_VTABLE IFormulaToken 101 { 102 public: 103 virtual bool isFunction() const = 0; 104 /* 105 OpCode eOp = pToken->GetOpCode(); 106 if(!(pToken->IsFunction()|| ocArcTan2<=eOp)) 107 */ 108 virtual sal_uInt32 getArgumentCount() const = 0; 109 }; 110 111 class SAL_NO_VTABLE IStructHelper 112 { 113 public: IStructHelper()114 IStructHelper(){} 115 virtual SvLBoxEntry* InsertEntry(const XubString& rText, SvLBoxEntry* pParent, 116 sal_uInt16 nFlag,sal_uLong nPos=0,IFormulaToken* pScToken=NULL) = 0; 117 118 virtual String GetEntryText(SvLBoxEntry* pEntry) const = 0; 119 virtual SvLBoxEntry* GetParent(SvLBoxEntry* pEntry) const = 0; 120 }; 121 122 class SAL_NO_VTABLE IFormulaEditorHelper 123 { 124 public: IFormulaEditorHelper()125 IFormulaEditorHelper(){} 126 virtual void notifyChange() = 0; 127 virtual void fill() = 0; 128 129 virtual String getCurrentFormula() const = 0; 130 virtual void setCurrentFormula(const String& _sReplacement) = 0; 131 132 virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const = 0; 133 virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd) = 0; 134 135 virtual FormEditData* getFormEditData() const = 0; 136 virtual bool calculateValue(const String& _sExpression,String& _rResult) = 0; 137 138 virtual void switchBack() = 0; 139 140 virtual void clear() = 0; 141 virtual void deleteFormData() = 0; 142 virtual void setReferenceInput(const FormEditData* _pData) = 0; 143 144 virtual IFunctionManager* getFunctionManager() = 0; 145 virtual ::std::auto_ptr<FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList) = 0; 146 147 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const = 0; 148 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const = 0; 149 virtual ::com::sun::star::table::CellAddress getReferencePosition() const = 0; 150 151 virtual void setDispatcherLock( sal_Bool bLock ) = 0; 152 virtual void dispatch(sal_Bool _bOK,sal_Bool _bMartixChecked) = 0; 153 virtual void doClose(sal_Bool _bOk) = 0; 154 virtual void insertEntryToLRUList(const IFunctionDescription* pDesc) = 0; 155 virtual void showReference(const String& _sFormula) = 0; 156 }; 157 158 } 159 #endif //INCLUDE_FUNCTION_DESCRIPTION 160