LibreOffice Module sc (master)  1
addincol.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SC_INC_ADDINCOL_HXX
21 #define INCLUDED_SC_INC_ADDINCOL_HXX
22 
23 #include <memory>
24 #include <com/sun/star/uno/Any.h>
25 #include <com/sun/star/uno/Reference.h>
26 #include <com/sun/star/uno/Sequence.h>
27 #include <formula/errorcodes.hxx>
28 #include <i18nlangtag/lang.h>
29 #include "scdllapi.h"
30 #include <rtl/ustring.hxx>
31 #include <tools/long.hxx>
32 
33 #include "types.hxx"
34 
35 #include <vector>
36 #include <unordered_map>
37 
38 namespace com::sun::star::reflection { class XIdlMethod; }
39 namespace com::sun::star::sheet { class XVolatileResult; }
40 namespace com::sun::star::uno { class XInterface; }
41 
42 class SfxObjectShell;
43 class ScUnoAddInFuncData;
44 class ScFuncDesc;
45 
46 typedef std::unordered_map< OUString, const ScUnoAddInFuncData* > ScAddInHashMap;
47 
49 {
62 };
63 
65 {
66  OUString aInternalName;
67  OUString aName;
68  OUString aDescription;
70  bool bOptional;
71 };
72 
74 {
75 public:
77  {
78  OUString maLocale;
79  OUString maName;
80 
81  LocalizedName( const OUString& rLocale, const OUString& rName )
82  : maLocale( rLocale), maName( rName) { }
83  };
84 private:
85  OUString aOriginalName;
86  OUString aLocalName;
87  OUString aUpperName;
88  OUString aUpperLocal;
89  OUString aDescription;
90  css::uno::Reference< css::reflection::XIdlMethod> xFunction;
91  css::uno::Any aObject;
93  std::unique_ptr<ScAddInArgDesc[]>
96  sal_uInt16 nCategory;
97  OString sHelpId;
98  mutable ::std::vector< LocalizedName > maCompNames;
99  mutable bool bCompInitialized;
100 
101 public:
102  ScUnoAddInFuncData( const OUString& rNam, const OUString& rLoc,
103  const OUString& rDesc,
104  sal_uInt16 nCat, const OString&,
105  const css::uno::Reference< css::reflection::XIdlMethod>& rFunc,
106  const css::uno::Any& rO,
107  tools::Long nAC, const ScAddInArgDesc* pAD,
108  tools::Long nCP );
110 
111  const OUString& GetOriginalName() const { return aOriginalName; }
112  const OUString& GetLocalName() const { return aLocalName; }
113  const OUString& GetUpperName() const { return aUpperName; }
114  const OUString& GetUpperLocal() const { return aUpperLocal; }
115  const css::uno::Reference< css::reflection::XIdlMethod>& GetFunction() const
116  { return xFunction; }
117  const css::uno::Any& GetObject() const { return aObject; }
119  const ScAddInArgDesc* GetArguments() const { return pArgDescs.get(); }
120  tools::Long GetCallerPos() const { return nCallerPos; }
121  const OUString& GetDescription() const { return aDescription; }
122  sal_uInt16 GetCategory() const { return nCategory; }
123  const OString& GetHelpId() const { return sHelpId; }
124 
125  const ::std::vector< LocalizedName >& GetCompNames() const;
126  bool GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const;
127 
128  void SetFunction( const css::uno::Reference< css::reflection::XIdlMethod>& rNewFunc,
129  const css::uno::Any& rNewObj );
130  void SetArguments( tools::Long nNewCount, const ScAddInArgDesc* pNewDescs );
131  void SetCallerPos( tools::Long nNewPos );
132  void SetCompNames( const ::std::vector< LocalizedName >& rNew );
133 };
134 
136 {
137 private:
139  std::unique_ptr<std::unique_ptr<ScUnoAddInFuncData>[]> ppFuncData;
140  std::unique_ptr<ScAddInHashMap> pExactHashMap;
141  std::unique_ptr<ScAddInHashMap> pNameHashMap;
142  std::unique_ptr<ScAddInHashMap> pLocalHashMap;
144 
145  void Initialize();
146  void ReadConfiguration();
147  void ReadFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface );
148  void UpdateFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface,
149  const OUString& rServiceName );
150  void LoadComponent( const ScUnoAddInFuncData& rFuncData );
151 
152 public:
155 
157  const OUString & FindFunction( const OUString& rUpperName, bool bLocalFirst );
158 
162  const ScUnoAddInFuncData* GetFuncData( const OUString& rName, bool bComplete = false );
163 
168  const ScUnoAddInFuncData* GetFuncData( tools::Long nIndex );
169 
170  void Clear();
171 
172  void LocalizeString( OUString& rName );
173 
174  tools::Long GetFuncCount();
175  bool FillFunctionDesc( tools::Long nFunc, ScFuncDesc& rDesc );
176 
177  static bool FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc );
179  bool GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName );
181  bool GetCalcName( const OUString& rExcelName, OUString& rRetCalcName );
182 };
183 
185 {
186 private:
188  css::uno::Sequence<css::uno::Any> aArgs;
189  css::uno::Sequence<css::uno::Any> aVarArg;
190  css::uno::Reference<css::uno::XInterface> xCaller;
192  // result:
195  double fValue;
196  OUString aString;
198  css::uno::Reference<css::sheet::XVolatileResult> xVarRes;
199 
200  void ExecuteCallWithArgs(css::uno::Sequence<css::uno::Any>& rCallArgs);
201 
202 public:
203  // exact name
204  ScUnoAddInCall( ScUnoAddInCollection& rColl, const OUString& rName,
206  ~ScUnoAddInCall();
207 
208  bool NeedsCaller() const;
209  void SetCaller( const css::uno::Reference<css::uno::XInterface>& rInterface );
210  void SetCallerFromObjectShell( const SfxObjectShell* pSh );
211 
212  bool ValidParamCount() { return bValidCount;}
214  void SetParam( tools::Long nPos, const css::uno::Any& rValue );
215 
216  void ExecuteCall();
217 
218  void SetResult( const css::uno::Any& rNewRes );
219 
220  FormulaError GetErrCode() const { return nErrCode; }
221  bool HasString() const { return bHasString; }
222  bool HasMatrix() const { return bool(xMatrix); }
223  bool HasVarRes() const { return xVarRes.is(); }
224  double GetValue() const { return fValue; }
225  const OUString& GetString() const { return aString; }
226  const ScMatrixRef& GetMatrix() const { return xMatrix;}
227  const css::uno::Reference<css::sheet::XVolatileResult>&
228  GetVarRes() const { return xVarRes; }
229 };
230 
231 #endif
232 
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString aName
Definition: addincol.hxx:67
bool NeedsCaller() const
Definition: addincol.cxx:1291
const ::std::vector< LocalizedName > & GetCompNames() const
Definition: addincol.cxx:102
OUString aDescription
Definition: addincol.hxx:89
const css::uno::Reference< css::sheet::XVolatileResult > & GetVarRes() const
Definition: addincol.hxx:228
bool HasVarRes() const
Definition: addincol.hxx:223
ScMatrixRef xMatrix
Definition: addincol.hxx:197
double GetValue() const
Definition: addincol.hxx:224
long Long
const OUString & GetLocalName() const
Definition: addincol.hxx:112
OUString aDescription
Definition: addincol.hxx:68
void SetCallerPos(tools::Long nNewPos)
Definition: addincol.cxx:208
bool ValidParamCount()
Definition: addincol.hxx:212
tools::Long nFuncCount
Definition: addincol.hxx:138
std::unordered_map< OUString, const ScUnoAddInFuncData * > ScAddInHashMap
Definition: addincol.hxx:44
void SetParam(tools::Long nPos, const css::uno::Any &rValue)
Definition: addincol.cxx:1310
const OUString & GetUpperName() const
Definition: addincol.hxx:113
OUString aUpperName
for entering formulas
Definition: addincol.hxx:87
const OUString & GetDescription() const
Definition: addincol.hxx:121
const css::uno::Any & GetObject() const
Definition: addincol.hxx:117
css::uno::Reference< css::sheet::XVolatileResult > xVarRes
Definition: addincol.hxx:198
void SetFunction(const css::uno::Reference< css::reflection::XIdlMethod > &rNewFunc, const css::uno::Any &rNewObj)
Definition: addincol.cxx:189
std::unique_ptr< ScAddInHashMap > pExactHashMap
exact internal name
Definition: addincol.hxx:140
char sal_uInt16 & nParamCount
Definition: callform.cxx:53
OUString aOriginalName
kept in formula
Definition: addincol.hxx:85
void SetCaller(const css::uno::Reference< css::uno::XInterface > &rInterface)
Definition: addincol.cxx:1296
ScAddInArgumentType eType
Definition: addincol.hxx:69
LocalizedName(const OUString &rLocale, const OUString &rName)
Definition: addincol.hxx:81
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:26
void ExecuteCall()
Definition: addincol.cxx:1335
ScAddInArgumentType GetArgType(tools::Long nPos)
Definition: addincol.cxx:1274
void SetArguments(tools::Long nNewCount, const ScAddInArgDesc *pNewDescs)
Definition: addincol.cxx:195
const OUString & GetUpperLocal() const
Definition: addincol.hxx:114
css::uno::Reference< css::uno::XInterface > xCaller
Definition: addincol.hxx:190
FormulaError GetErrCode() const
Definition: addincol.hxx:220
XPropertySet.
Definition: addincol.hxx:60
bool HasMatrix() const
Definition: addincol.hxx:222
OUString aUpperLocal
for entering formulas
Definition: addincol.hxx:88
std::unique_ptr< ScAddInHashMap > pLocalHashMap
localized name upper
Definition: addincol.hxx:142
mutable::std::vector< LocalizedName > maCompNames
Definition: addincol.hxx:98
std::unique_ptr< ScAddInHashMap > pNameHashMap
internal name upper
Definition: addincol.hxx:141
sal_uInt16 GetCategory() const
Definition: addincol.hxx:122
const OUString & GetOriginalName() const
Definition: addincol.hxx:111
sal_uInt16 nCategory
Definition: addincol.hxx:96
OUString aInternalName
used to match configuration and reflection information
Definition: addincol.hxx:66
const ScAddInArgDesc * GetArguments() const
Definition: addincol.hxx:119
FormulaError
std::unique_ptr< ScAddInArgDesc[]> pArgDescs
Definition: addincol.hxx:94
const css::uno::Reference< css::reflection::XIdlMethod > & GetFunction() const
Definition: addincol.hxx:115
css::uno::Sequence< css::uno::Any > aVarArg
Definition: addincol.hxx:189
FormulaError nErrCode
Definition: addincol.hxx:193
tools::Long nCallerPos
Definition: addincol.hxx:95
const OUString & GetString() const
Definition: addincol.hxx:225
css::uno::Sequence< css::uno::Any > aArgs
Definition: addincol.hxx:188
void SetCallerFromObjectShell(const SfxObjectShell *pSh)
Definition: addincol.cxx:1301
tools::Long GetArgumentCount() const
Definition: addincol.hxx:118
ScUnoAddInFuncData(const OUString &rNam, const OUString &rLoc, const OUString &rDesc, sal_uInt16 nCat, const OString &, const css::uno::Reference< css::reflection::XIdlMethod > &rFunc, const css::uno::Any &rO, tools::Long nAC, const ScAddInArgDesc *pAD, tools::Long nCP)
Definition: addincol.cxx:67
const ScUnoAddInFuncData * pFuncData
Definition: addincol.hxx:187
std::unique_ptr< std::unique_ptr< ScUnoAddInFuncData >[]> ppFuncData
Definition: addincol.hxx:139
css::uno::Reference< css::reflection::XIdlMethod > xFunction
Definition: addincol.hxx:90
tools::Long GetCallerPos() const
Definition: addincol.hxx:120
bool HasString() const
Definition: addincol.hxx:221
XCellRange.
Definition: addincol.hxx:59
OUString aString
Definition: addincol.hxx:196
void SetCompNames(const ::std::vector< LocalizedName > &rNew)
Definition: addincol.cxx:131
void SetResult(const css::uno::Any &rNewRes)
Definition: addincol.cxx:1436
const ScMatrixRef & GetMatrix() const
Definition: addincol.hxx:226
const OString & GetHelpId() const
Definition: addincol.hxx:123
OUString aLocalName
for display
Definition: addincol.hxx:86
ScAddInArgumentType
Definition: addincol.hxx:48
bool GetExcelName(LanguageType eDestLang, OUString &rRetExcelName) const
Definition: addincol.cxx:140
tools::Long nArgCount
Definition: addincol.hxx:92
void ExecuteCallWithArgs(css::uno::Sequence< css::uno::Any > &rCallArgs)
Definition: addincol.cxx:1378
css::uno::Any aObject
Definition: addincol.hxx:91
ScUnoAddInCall(ScUnoAddInCollection &rColl, const OUString &rName, tools::Long nParamCount)
Definition: addincol.cxx:1231
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
Definition: funcdesc.hxx:41
#define SC_DLLPUBLIC
Definition: scdllapi.h:28