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#pragma once
21
22#include <memory>
23#include <com/sun/star/uno/Any.h>
24#include <com/sun/star/uno/Reference.h>
25#include <com/sun/star/uno/Sequence.h>
27#include <i18nlangtag/lang.h>
28#include "scdllapi.h"
29#include <rtl/ustring.hxx>
30#include <tools/long.hxx>
31
32#include "types.hxx"
33
34#include <string_view>
35#include <utility>
36#include <vector>
37#include <unordered_map>
38
39namespace com::sun::star::reflection { class XIdlMethod; }
40namespace com::sun::star::sheet { class XVolatileResult; }
41namespace com::sun::star::uno { class XInterface; }
42
43class SfxObjectShell;
45class ScFuncDesc;
46class LanguageTag;
47class ScDocument;
48
49typedef std::unordered_map< OUString, const ScUnoAddInFuncData* > ScAddInHashMap;
50
52{
65};
66
68{
69 OUString aInternalName;
70 OUString aName;
71 OUString aDescription;
74};
75
77{
78public:
80 {
81 OUString maLocale;
82 OUString maName;
83
84 LocalizedName( OUString aLocale, OUString aName )
85 : maLocale(std::move(aLocale)), maName(std::move(aName)) { }
86 };
87private:
88 OUString aOriginalName;
89 OUString aLocalName;
90 OUString aUpperName;
91 OUString aUpperLocal;
92 OUString aUpperEnglish;
93 OUString aDescription;
94 css::uno::Reference< css::reflection::XIdlMethod> xFunction;
95 css::uno::Any aObject;
97 std::unique_ptr<ScAddInArgDesc[]>
100 sal_uInt16 nCategory;
101 OString sHelpId;
102 mutable ::std::vector< LocalizedName > maCompNames;
103 mutable bool bCompInitialized;
104
105public:
106 ScUnoAddInFuncData( const OUString& rNam, const OUString& rLoc,
107 OUString aDesc,
108 sal_uInt16 nCat, OString ,
109 css::uno::Reference< css::reflection::XIdlMethod> aFunc,
110 css::uno::Any aO,
111 tools::Long nAC, const ScAddInArgDesc* pAD,
112 tools::Long nCP );
114
115 const OUString& GetOriginalName() const { return aOriginalName; }
116 const OUString& GetLocalName() const { return aLocalName; }
117 const OUString& GetUpperName() const { return aUpperName; }
118 const OUString& GetUpperLocal() const { return aUpperLocal; }
119 const OUString& GetUpperEnglish() const { return aUpperEnglish; }
120 const css::uno::Reference< css::reflection::XIdlMethod>& GetFunction() const
121 { return xFunction; }
122 const css::uno::Any& GetObject() const { return aObject; }
124 const ScAddInArgDesc* GetArguments() const { return pArgDescs.get(); }
126 const OUString& GetDescription() const { return aDescription; }
127 sal_uInt16 GetCategory() const { return nCategory; }
128 const OString& GetHelpId() const { return sHelpId; }
129
130 const ::std::vector< LocalizedName >& GetCompNames() const;
131 bool GetExcelName( const LanguageTag& rDestLang, OUString& rRetExcelName,
132 bool bFallbackToAny = true ) const;
133
134 void SetFunction( const css::uno::Reference< css::reflection::XIdlMethod>& rNewFunc,
135 const css::uno::Any& rNewObj );
136 void SetArguments( tools::Long nNewCount, const ScAddInArgDesc* pNewDescs );
137 void SetCallerPos( tools::Long nNewPos );
138 void SetCompNames( ::std::vector< LocalizedName >&& rNew );
139
141 void SetEnglishName( const OUString& rEnglishName );
142};
143
145{
146private:
148 std::unique_ptr<std::unique_ptr<ScUnoAddInFuncData>[]> ppFuncData;
149 std::unique_ptr<ScAddInHashMap> pExactHashMap;
150 std::unique_ptr<ScAddInHashMap> pNameHashMap;
151 std::unique_ptr<ScAddInHashMap> pLocalHashMap;
152 std::unique_ptr<ScAddInHashMap> pEnglishHashMap;
154
155 void Initialize();
156 void ReadConfiguration();
157 void ReadFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface );
158 void UpdateFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface,
159 std::u16string_view rServiceName );
160 void LoadComponent( const ScUnoAddInFuncData& rFuncData );
161
162public:
165
167 OUString FindFunction( const OUString& rUpperName, bool bLocalFirst );
168
172 const ScUnoAddInFuncData* GetFuncData( const OUString& rName, bool bComplete = false );
173
178 const ScUnoAddInFuncData* GetFuncData( tools::Long nIndex );
179
180 void Clear();
181
182 void LocalizeString( OUString& rName );
183
184 tools::Long GetFuncCount();
185 bool FillFunctionDesc( tools::Long nFunc, ScFuncDesc& rDesc, bool bEnglishFunctionNames );
186
187 static bool FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc,
188 bool bEnglishFunctionNames );
190 bool GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName );
192 bool GetCalcName( const OUString& rExcelName, OUString& rRetCalcName );
193};
194
196{
197private:
199 css::uno::Sequence<css::uno::Any> aArgs;
200 css::uno::Sequence<css::uno::Any> aVarArg;
201 css::uno::Reference<css::uno::XInterface> xCaller;
204 // result:
207 double fValue;
208 OUString aString;
210 css::uno::Reference<css::sheet::XVolatileResult> xVarRes;
211
212 void ExecuteCallWithArgs(css::uno::Sequence<css::uno::Any>& rCallArgs);
213
214public:
215 // exact name
216 ScUnoAddInCall( ScDocument& rDoc, ScUnoAddInCollection& rColl, const OUString& rName,
217 tools::Long nParamCount );
219
220 bool NeedsCaller() const;
221 void SetCaller( const css::uno::Reference<css::uno::XInterface>& rInterface );
222 void SetCallerFromObjectShell( const SfxObjectShell* pSh );
223
224 bool ValidParamCount() { return bValidCount;}
226 void SetParam( tools::Long nPos, const css::uno::Any& rValue );
227
228 void ExecuteCall();
229
230 void SetResult( const css::uno::Any& rNewRes );
231
232 FormulaError GetErrCode() const { return nErrCode; }
233 bool HasString() const { return bHasString; }
234 bool HasMatrix() const { return bool(xMatrix); }
235 bool HasVarRes() const { return xVarRes.is(); }
236 double GetValue() const { return fValue; }
237 const OUString& GetString() const { return aString; }
238 const ScMatrixRef& GetMatrix() const { return xMatrix;}
239 const css::uno::Reference<css::sheet::XVolatileResult>&
240 GetVarRes() const { return xVarRes; }
241};
242
243/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unordered_map< OUString, const ScUnoAddInFuncData * > ScAddInHashMap
Definition: addincol.hxx:47
ScAddInArgumentType
Definition: addincol.hxx:52
@ SC_ADDINARG_VALUE_OR_ARRAY
any
Definition: addincol.hxx:61
@ SC_ADDINARG_INTEGER
long
Definition: addincol.hxx:54
@ SC_ADDINARG_STRING
string
Definition: addincol.hxx:56
@ SC_ADDINARG_VARARGS
sequence<any>
Definition: addincol.hxx:64
@ SC_ADDINARG_STRING_ARRAY
sequence<sequence<string>>
Definition: addincol.hxx:59
@ SC_ADDINARG_INTEGER_ARRAY
sequence<sequence<long>>
Definition: addincol.hxx:57
@ SC_ADDINARG_DOUBLE
double
Definition: addincol.hxx:55
@ SC_ADDINARG_NONE
Definition: addincol.hxx:53
@ SC_ADDINARG_CALLER
XPropertySet.
Definition: addincol.hxx:63
@ SC_ADDINARG_DOUBLE_ARRAY
sequence<sequence<double>>
Definition: addincol.hxx:58
@ SC_ADDINARG_CELLRANGE
XCellRange.
Definition: addincol.hxx:62
@ SC_ADDINARG_MIXED_ARRAY
sequence<sequence<any>>
Definition: addincol.hxx:60
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
Definition: funcdesc.hxx:41
ScUnoAddInCall(ScDocument &rDoc, ScUnoAddInCollection &rColl, const OUString &rName, tools::Long nParamCount)
Definition: addincol.cxx:1317
ScMatrixRef xMatrix
Definition: addincol.hxx:209
const ScMatrixRef & GetMatrix() const
Definition: addincol.hxx:238
FormulaError GetErrCode() const
Definition: addincol.hxx:232
void SetResult(const css::uno::Any &rNewRes)
Definition: addincol.cxx:1523
ScAddInArgumentType GetArgType(tools::Long nPos)
Definition: addincol.cxx:1361
FormulaError nErrCode
Definition: addincol.hxx:205
css::uno::Reference< css::sheet::XVolatileResult > xVarRes
Definition: addincol.hxx:210
const css::uno::Reference< css::sheet::XVolatileResult > & GetVarRes() const
Definition: addincol.hxx:240
OUString aString
Definition: addincol.hxx:208
css::uno::Sequence< css::uno::Any > aVarArg
Definition: addincol.hxx:200
bool NeedsCaller() const
Definition: addincol.cxx:1378
void ExecuteCall()
Definition: addincol.cxx:1422
void SetCaller(const css::uno::Reference< css::uno::XInterface > &rInterface)
Definition: addincol.cxx:1383
bool HasVarRes() const
Definition: addincol.hxx:235
const OUString & GetString() const
Definition: addincol.hxx:237
bool ValidParamCount()
Definition: addincol.hxx:224
bool HasString() const
Definition: addincol.hxx:233
void ExecuteCallWithArgs(css::uno::Sequence< css::uno::Any > &rCallArgs)
Definition: addincol.cxx:1465
ScDocument & mrDoc
Definition: addincol.hxx:202
double GetValue() const
Definition: addincol.hxx:236
const ScUnoAddInFuncData * pFuncData
Definition: addincol.hxx:198
css::uno::Sequence< css::uno::Any > aArgs
Definition: addincol.hxx:199
void SetParam(tools::Long nPos, const css::uno::Any &rValue)
Definition: addincol.cxx:1397
css::uno::Reference< css::uno::XInterface > xCaller
Definition: addincol.hxx:201
void SetCallerFromObjectShell(const SfxObjectShell *pSh)
Definition: addincol.cxx:1388
bool HasMatrix() const
Definition: addincol.hxx:234
std::unique_ptr< ScAddInHashMap > pLocalHashMap
localized name upper
Definition: addincol.hxx:151
std::unique_ptr< ScAddInHashMap > pEnglishHashMap
English name upper.
Definition: addincol.hxx:152
tools::Long nFuncCount
Definition: addincol.hxx:147
std::unique_ptr< std::unique_ptr< ScUnoAddInFuncData >[]> ppFuncData
Definition: addincol.hxx:148
std::unique_ptr< ScAddInHashMap > pExactHashMap
exact internal name
Definition: addincol.hxx:149
std::unique_ptr< ScAddInHashMap > pNameHashMap
internal name upper
Definition: addincol.hxx:150
void SetFunction(const css::uno::Reference< css::reflection::XIdlMethod > &rNewFunc, const css::uno::Any &rNewObj)
Definition: addincol.cxx:208
OUString aUpperName
for entering formulas
Definition: addincol.hxx:90
const ScAddInArgDesc * GetArguments() const
Definition: addincol.hxx:124
tools::Long GetCallerPos() const
Definition: addincol.hxx:125
tools::Long nCallerPos
Definition: addincol.hxx:99
OUString aOriginalName
kept in formula
Definition: addincol.hxx:88
OUString aUpperEnglish
for Function Wizard and tooltips
Definition: addincol.hxx:92
sal_uInt16 nCategory
Definition: addincol.hxx:100
css::uno::Reference< css::reflection::XIdlMethod > xFunction
Definition: addincol.hxx:94
const OUString & GetUpperLocal() const
Definition: addincol.hxx:118
ScUnoAddInFuncData(const OUString &rNam, const OUString &rLoc, OUString aDesc, sal_uInt16 nCat, OString, css::uno::Reference< css::reflection::XIdlMethod > aFunc, css::uno::Any aO, tools::Long nAC, const ScAddInArgDesc *pAD, tools::Long nCP)
Definition: addincol.cxx:71
OUString aDescription
Definition: addincol.hxx:93
const ::std::vector< LocalizedName > & GetCompNames() const
Definition: addincol.cxx:106
sal_uInt16 GetCategory() const
Definition: addincol.hxx:127
const OUString & GetDescription() const
Definition: addincol.hxx:126
const OUString & GetUpperEnglish() const
Definition: addincol.hxx:119
bool GetExcelName(const LanguageTag &rDestLang, OUString &rRetExcelName, bool bFallbackToAny=true) const
Definition: addincol.cxx:157
const OUString & GetUpperName() const
Definition: addincol.hxx:117
const OString & GetHelpId() const
Definition: addincol.hxx:128
void SetCallerPos(tools::Long nNewPos)
Definition: addincol.cxx:227
OUString aLocalName
for display
Definition: addincol.hxx:89
void SetCompNames(::std::vector< LocalizedName > &&rNew)
Definition: addincol.cxx:135
mutable ::std::vector< LocalizedName > maCompNames
Definition: addincol.hxx:102
const css::uno::Any & GetObject() const
Definition: addincol.hxx:122
std::unique_ptr< ScAddInArgDesc[]> pArgDescs
Definition: addincol.hxx:98
css::uno::Any aObject
Definition: addincol.hxx:95
OUString aUpperLocal
for entering formulas
Definition: addincol.hxx:91
tools::Long GetArgumentCount() const
Definition: addincol.hxx:123
const css::uno::Reference< css::reflection::XIdlMethod > & GetFunction() const
Definition: addincol.hxx:120
tools::Long nArgCount
Definition: addincol.hxx:96
const OUString & GetLocalName() const
Definition: addincol.hxx:116
void SetEnglishName(const OUString &rEnglishName)
Takes care of handling an empty name after upper local name was set.
Definition: addincol.cxx:144
void SetArguments(tools::Long nNewCount, const ScAddInArgDesc *pNewDescs)
Definition: addincol.cxx:214
const OUString & GetOriginalName() const
Definition: addincol.hxx:115
FormulaError
OUString aName
void Clear(EHistoryType eHistory)
long Long
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
ScAddInArgumentType eType
Definition: addincol.hxx:72
OUString aName
Definition: addincol.hxx:70
OUString aDescription
Definition: addincol.hxx:71
OUString aInternalName
used to match configuration and reflection information
Definition: addincol.hxx:69
LocalizedName(OUString aLocale, OUString aName)
Definition: addincol.hxx:84
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25