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 
32 #include "types.hxx"
33 
34 #include <vector>
35 #include <unordered_map>
36 
37 namespace com::sun::star::reflection { class XIdlMethod; }
38 namespace com::sun::star::sheet { class XVolatileResult; }
39 namespace com::sun::star::uno { class XInterface; }
40 
41 class SfxObjectShell;
42 class ScUnoAddInFuncData;
43 class ScFuncDesc;
44 
45 typedef std::unordered_map< OUString, const ScUnoAddInFuncData* > ScAddInHashMap;
46 
48 {
61 };
62 
64 {
65  OUString aInternalName;
66  OUString aName;
67  OUString aDescription;
69  bool bOptional;
70 };
71 
73 {
74 public:
76  {
77  OUString maLocale;
78  OUString maName;
79 
80  LocalizedName( const OUString& rLocale, const OUString& rName )
81  : maLocale( rLocale), maName( rName) { }
82  };
83 private:
84  OUString aOriginalName;
85  OUString aLocalName;
86  OUString aUpperName;
87  OUString aUpperLocal;
88  OUString aDescription;
89  css::uno::Reference< css::reflection::XIdlMethod> xFunction;
90  css::uno::Any aObject;
91  long nArgCount;
92  std::unique_ptr<ScAddInArgDesc[]>
94  long nCallerPos;
95  sal_uInt16 nCategory;
96  OString sHelpId;
97  mutable ::std::vector< LocalizedName > maCompNames;
98  mutable bool bCompInitialized;
99 
100 public:
101  ScUnoAddInFuncData( const OUString& rNam, const OUString& rLoc,
102  const OUString& rDesc,
103  sal_uInt16 nCat, const OString&,
104  const css::uno::Reference< css::reflection::XIdlMethod>& rFunc,
105  const css::uno::Any& rO,
106  long nAC, const ScAddInArgDesc* pAD,
107  long nCP );
109 
110  const OUString& GetOriginalName() const { return aOriginalName; }
111  const OUString& GetLocalName() const { return aLocalName; }
112  const OUString& GetUpperName() const { return aUpperName; }
113  const OUString& GetUpperLocal() const { return aUpperLocal; }
114  const css::uno::Reference< css::reflection::XIdlMethod>& GetFunction() const
115  { return xFunction; }
116  const css::uno::Any& GetObject() const { return aObject; }
117  long GetArgumentCount() const { return nArgCount; }
118  const ScAddInArgDesc* GetArguments() const { return pArgDescs.get(); }
119  long GetCallerPos() const { return nCallerPos; }
120  const OUString& GetDescription() const { return aDescription; }
121  sal_uInt16 GetCategory() const { return nCategory; }
122  const OString& GetHelpId() const { return sHelpId; }
123 
124  const ::std::vector< LocalizedName >& GetCompNames() const;
125  bool GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const;
126 
127  void SetFunction( const css::uno::Reference< css::reflection::XIdlMethod>& rNewFunc,
128  const css::uno::Any& rNewObj );
129  void SetArguments( long nNewCount, const ScAddInArgDesc* pNewDescs );
130  void SetCallerPos( long nNewPos );
131  void SetCompNames( const ::std::vector< LocalizedName >& rNew );
132 };
133 
135 {
136 private:
138  std::unique_ptr<std::unique_ptr<ScUnoAddInFuncData>[]> ppFuncData;
139  std::unique_ptr<ScAddInHashMap> pExactHashMap;
140  std::unique_ptr<ScAddInHashMap> pNameHashMap;
141  std::unique_ptr<ScAddInHashMap> pLocalHashMap;
143 
144  void Initialize();
145  void ReadConfiguration();
146  void ReadFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface );
147  void UpdateFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface,
148  const OUString& rServiceName );
149  void LoadComponent( const ScUnoAddInFuncData& rFuncData );
150 
151 public:
154 
156  const OUString & FindFunction( const OUString& rUpperName, bool bLocalFirst );
157 
161  const ScUnoAddInFuncData* GetFuncData( const OUString& rName, bool bComplete = false );
162 
167  const ScUnoAddInFuncData* GetFuncData( long nIndex );
168 
169  void Clear();
170 
171  void LocalizeString( OUString& rName );
172 
173  long GetFuncCount();
174  bool FillFunctionDesc( long nFunc, ScFuncDesc& rDesc );
175 
176  static bool FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc );
178  bool GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName );
180  bool GetCalcName( const OUString& rExcelName, OUString& rRetCalcName );
181 };
182 
184 {
185 private:
187  css::uno::Sequence<css::uno::Any> aArgs;
188  css::uno::Sequence<css::uno::Any> aVarArg;
189  css::uno::Reference<css::uno::XInterface> xCaller;
191  // result:
194  double fValue;
195  OUString aString;
197  css::uno::Reference<css::sheet::XVolatileResult> xVarRes;
198 
199  void ExecuteCallWithArgs(css::uno::Sequence<css::uno::Any>& rCallArgs);
200 
201 public:
202  // exact name
203  ScUnoAddInCall( ScUnoAddInCollection& rColl, const OUString& rName,
204  long nParamCount );
205  ~ScUnoAddInCall();
206 
207  bool NeedsCaller() const;
208  void SetCaller( const css::uno::Reference<css::uno::XInterface>& rInterface );
209  void SetCallerFromObjectShell( const SfxObjectShell* pSh );
210 
211  bool ValidParamCount() { return bValidCount;}
212  ScAddInArgumentType GetArgType( long nPos );
213  void SetParam( long nPos, const css::uno::Any& rValue );
214 
215  void ExecuteCall();
216 
217  void SetResult( const css::uno::Any& rNewRes );
218 
219  FormulaError GetErrCode() const { return nErrCode; }
220  bool HasString() const { return bHasString; }
221  bool HasMatrix() const { return bool(xMatrix); }
222  bool HasVarRes() const { return xVarRes.is(); }
223  double GetValue() const { return fValue; }
224  const OUString& GetString() const { return aString; }
225  const ScMatrixRef& GetMatrix() const { return xMatrix;}
226  const css::uno::Reference<css::sheet::XVolatileResult>&
227  GetVarRes() const { return xVarRes; }
228 };
229 
230 #endif
231 
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString aName
Definition: addincol.hxx:66
bool NeedsCaller() const
Definition: addincol.cxx:1293
const ::std::vector< LocalizedName > & GetCompNames() const
Definition: addincol.cxx:104
OUString aDescription
Definition: addincol.hxx:88
const css::uno::Reference< css::sheet::XVolatileResult > & GetVarRes() const
Definition: addincol.hxx:227
bool HasVarRes() const
Definition: addincol.hxx:222
ScMatrixRef xMatrix
Definition: addincol.hxx:196
double GetValue() const
Definition: addincol.hxx:223
const OUString & GetLocalName() const
Definition: addincol.hxx:111
OUString aDescription
Definition: addincol.hxx:67
bool ValidParamCount()
Definition: addincol.hxx:211
std::unordered_map< OUString, const ScUnoAddInFuncData * > ScAddInHashMap
Definition: addincol.hxx:43
const OUString & GetUpperName() const
Definition: addincol.hxx:112
OUString aUpperName
for entering formulas
Definition: addincol.hxx:86
long GetArgumentCount() const
Definition: addincol.hxx:117
const OUString & GetDescription() const
Definition: addincol.hxx:120
void SetParam(long nPos, const css::uno::Any &rValue)
Definition: addincol.cxx:1312
const css::uno::Any & GetObject() const
Definition: addincol.hxx:116
css::uno::Reference< css::sheet::XVolatileResult > xVarRes
Definition: addincol.hxx:197
void SetFunction(const css::uno::Reference< css::reflection::XIdlMethod > &rNewFunc, const css::uno::Any &rNewObj)
Definition: addincol.cxx:191
std::unique_ptr< ScAddInHashMap > pExactHashMap
exact internal name
Definition: addincol.hxx:139
char sal_uInt16 & nParamCount
Definition: callform.cxx:54
OUString aOriginalName
kept in formula
Definition: addincol.hxx:84
void SetCaller(const css::uno::Reference< css::uno::XInterface > &rInterface)
Definition: addincol.cxx:1298
ScAddInArgumentType eType
Definition: addincol.hxx:68
LocalizedName(const OUString &rLocale, const OUString &rName)
Definition: addincol.hxx:80
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:26
void ExecuteCall()
Definition: addincol.cxx:1337
const OUString & GetUpperLocal() const
Definition: addincol.hxx:113
css::uno::Reference< css::uno::XInterface > xCaller
Definition: addincol.hxx:189
FormulaError GetErrCode() const
Definition: addincol.hxx:219
XPropertySet.
Definition: addincol.hxx:59
void SetArguments(long nNewCount, const ScAddInArgDesc *pNewDescs)
Definition: addincol.cxx:197
bool HasMatrix() const
Definition: addincol.hxx:221
OUString aUpperLocal
for entering formulas
Definition: addincol.hxx:87
ScAddInArgumentType GetArgType(long nPos)
Definition: addincol.cxx:1276
std::unique_ptr< ScAddInHashMap > pLocalHashMap
localized name upper
Definition: addincol.hxx:141
mutable::std::vector< LocalizedName > maCompNames
Definition: addincol.hxx:97
std::unique_ptr< ScAddInHashMap > pNameHashMap
internal name upper
Definition: addincol.hxx:140
void SetCallerPos(long nNewPos)
Definition: addincol.cxx:210
sal_uInt16 GetCategory() const
Definition: addincol.hxx:121
const OUString & GetOriginalName() const
Definition: addincol.hxx:110
sal_uInt16 nCategory
Definition: addincol.hxx:95
OUString aInternalName
used to match configuration and reflection information
Definition: addincol.hxx:65
const ScAddInArgDesc * GetArguments() const
Definition: addincol.hxx:118
FormulaError
std::unique_ptr< ScAddInArgDesc[]> pArgDescs
Definition: addincol.hxx:93
ScUnoAddInCall(ScUnoAddInCollection &rColl, const OUString &rName, long nParamCount)
Definition: addincol.cxx:1233
long GetCallerPos() const
Definition: addincol.hxx:119
const css::uno::Reference< css::reflection::XIdlMethod > & GetFunction() const
Definition: addincol.hxx:114
css::uno::Sequence< css::uno::Any > aVarArg
Definition: addincol.hxx:188
FormulaError nErrCode
Definition: addincol.hxx:192
const OUString & GetString() const
Definition: addincol.hxx:224
css::uno::Sequence< css::uno::Any > aArgs
Definition: addincol.hxx:187
void SetCallerFromObjectShell(const SfxObjectShell *pSh)
Definition: addincol.cxx:1303
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, long nAC, const ScAddInArgDesc *pAD, long nCP)
Definition: addincol.cxx:69
const ScUnoAddInFuncData * pFuncData
Definition: addincol.hxx:186
std::unique_ptr< std::unique_ptr< ScUnoAddInFuncData >[]> ppFuncData
Definition: addincol.hxx:138
css::uno::Reference< css::reflection::XIdlMethod > xFunction
Definition: addincol.hxx:89
bool HasString() const
Definition: addincol.hxx:220
XCellRange.
Definition: addincol.hxx:58
OUString aString
Definition: addincol.hxx:195
void SetCompNames(const ::std::vector< LocalizedName > &rNew)
Definition: addincol.cxx:133
void SetResult(const css::uno::Any &rNewRes)
Definition: addincol.cxx:1438
const ScMatrixRef & GetMatrix() const
Definition: addincol.hxx:225
const OString & GetHelpId() const
Definition: addincol.hxx:122
OUString aLocalName
for display
Definition: addincol.hxx:85
ScAddInArgumentType
Definition: addincol.hxx:47
bool GetExcelName(LanguageType eDestLang, OUString &rRetExcelName) const
Definition: addincol.cxx:142
void ExecuteCallWithArgs(css::uno::Sequence< css::uno::Any > &rCallArgs)
Definition: addincol.cxx:1380
css::uno::Any aObject
Definition: addincol.hxx:90
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