LibreOffice Module sc (master)  1
appluno.cxx
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 #include <appluno.hxx>
21 #include <sal/types.h>
22 #include <osl/diagnose.h>
23 #include <cppuhelper/factory.hxx>
24 #include <formula/funcvarargs.h>
25 
26 #include <vcl/svapp.hxx>
27 #include <sfx2/app.hxx>
28 #include <sfx2/sfxmodelfactory.hxx>
29 #include <miscuno.hxx>
30 #include <scmod.hxx>
31 #include <appoptio.hxx>
32 #include <inputopt.hxx>
33 #include <printopt.hxx>
34 #include <userlist.hxx>
35 #include <scdll.hxx>
36 #include <unonames.hxx>
37 #include <funcdesc.hxx>
38 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
39 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
40 #include <com/sun/star/sheet/FunctionArgument.hpp>
41 #include <memory>
42 
43 using namespace com::sun::star;
44 
45 // Special value for zoom
47 #define SC_ZOOMVAL_OPTIMAL (-1)
48 #define SC_ZOOMVAL_WHOLEPAGE (-2)
49 #define SC_ZOOMVAL_PAGEWIDTH (-3)
50 
51 // Number of PropertyValues in a function description
52 #define SC_FUNCDESC_PROPCOUNT 5
53 
54 // everything without Which-ID, map only for PropertySetInfo
55 
57 {
58  static const SfxItemPropertyMapEntry aSettingsPropertyMap_Impl[] =
59  {
60  {OUString(SC_UNONAME_DOAUTOCP), 0, cppu::UnoType<bool>::get(), 0, 0},
61  {OUString(SC_UNONAME_ENTERED), 0, cppu::UnoType<bool>::get(), 0, 0},
62  {OUString(SC_UNONAME_EXPREF), 0, cppu::UnoType<bool>::get(), 0, 0},
63  {OUString(SC_UNONAME_EXTFMT), 0, cppu::UnoType<bool>::get(), 0, 0},
64  {OUString(SC_UNONAME_LINKUPD), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
65  {OUString(SC_UNONAME_MARKHDR), 0, cppu::UnoType<bool>::get(), 0, 0},
66  {OUString(SC_UNONAME_METRIC), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
67  {OUString(SC_UNONAME_MOVEDIR), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
68  {OUString(SC_UNONAME_MOVESEL), 0, cppu::UnoType<bool>::get(), 0, 0},
69  {OUString(SC_UNONAME_PRALLSH), 0, cppu::UnoType<bool>::get(), 0, 0},
70  {OUString(SC_UNONAME_PREMPTY), 0, cppu::UnoType<bool>::get(), 0, 0},
71  {OUString(SC_UNONAME_RANGEFIN), 0, cppu::UnoType<bool>::get(), 0, 0},
72  {OUString(SC_UNONAME_SCALE), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
73  {OUString(SC_UNONAME_STBFUNC), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
74  {OUString(SC_UNONAME_ULISTS), 0, cppu::UnoType<uno::Sequence<OUString>>::get(), 0, 0},
75  {OUString(SC_UNONAME_PRMETRICS),0, cppu::UnoType<bool>::get(), 0, 0},
76  {OUString(SC_UNONAME_USETABCOL),0, cppu::UnoType<bool>::get(), 0, 0},
77  {OUString(SC_UNONAME_REPLWARN), 0, cppu::UnoType<bool>::get(), 0, 0},
78  { OUString(), 0, css::uno::Type(), 0, 0 }
79  };
80  return aSettingsPropertyMap_Impl;
81 }
82 
83 #define SCFUNCTIONLISTOBJ_SERVICE "com.sun.star.sheet.FunctionDescriptions"
84 #define SCRECENTFUNCTIONSOBJ_SERVICE "com.sun.star.sheet.RecentFunctions"
85 #define SCSPREADSHEETSETTINGS_SERVICE "com.sun.star.sheet.GlobalSheetSettings"
86 
87 SC_SIMPLE_SERVICE_INFO( ScFunctionListObj, "stardiv.StarCalc.ScFunctionListObj", SCFUNCTIONLISTOBJ_SERVICE )
88 SC_SIMPLE_SERVICE_INFO( ScRecentFunctionsObj, "stardiv.StarCalc.ScRecentFunctionsObj", SCRECENTFUNCTIONSOBJ_SERVICE )
89 SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettings, "stardiv.StarCalc.ScSpreadsheetSettings", SCSPREADSHEETSETTINGS_SERVICE )
90 
91 
92 ScSpreadsheetSettings::ScSpreadsheetSettings() :
93  aPropSet( lcl_GetSettingsPropertyMap() )
94 {
95 }
96 
98 {
99 }
100 
101 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
103  css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
104 {
105  SolarMutexGuard aGuard;
106  ScDLL::Init();
107  return cppu::acquire(static_cast<cppu::OWeakObject*>(new ScSpreadsheetSettings()));
108 }
109 
110 
111 bool ScSpreadsheetSettings::getPropertyBool(const OUString& aPropertyName)
112 {
113  uno::Any any = getPropertyValue(aPropertyName);
114  bool b = false;
115  any >>= b;
116  return b;
117 }
118 
119 sal_Int16 ScSpreadsheetSettings::getPropertyInt16(const OUString& aPropertyName)
120 {
121  uno::Any any = getPropertyValue(aPropertyName);
122  sal_Int16 b = 0;
123  any >>= b;
124  return b;
125 }
126 
127 // XPropertySet
128 
129 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettings::getPropertySetInfo()
130 {
131  SolarMutexGuard aGuard;
132  static uno::Reference<beans::XPropertySetInfo> aRef(
133  new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
134  return aRef;
135 }
136 
138  const OUString& aPropertyName, const uno::Any& aValue )
139 {
140  SolarMutexGuard aGuard;
141 
142  ScModule* pScMod = SC_MOD();
143  ScAppOptions aAppOpt(pScMod->GetAppOptions());
144  ScInputOptions aInpOpt(pScMod->GetInputOptions());
145  bool bSaveApp = false;
146  bool bSaveInp = false;
147  // print options aren't loaded until needed
148 
149  if (aPropertyName == SC_UNONAME_DOAUTOCP)
150  {
151  aAppOpt.SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
152  bSaveApp = true;
153  }
154  else if (aPropertyName == SC_UNONAME_ENTERED)
155  {
157  bSaveInp = true;
158  }
159  else if (aPropertyName == SC_UNONAME_EXPREF)
160  {
161  aInpOpt.SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
162  bSaveInp = true;
163  }
164  else if (aPropertyName == SC_UNONAME_EXTFMT)
165  {
166  aInpOpt.SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
167  bSaveInp = true;
168  }
169  else if (aPropertyName == SC_UNONAME_LINKUPD)
170  {
171  // XXX NOTE: this is not css::document::Settings property
172  // LinkUpdateMode but css::sheet::XGlobalSheetSettings attribute
173  // LinkUpdateMode.
174  sal_Int16 n;
175  if (!(aValue >>= n) || n < 0 || n >= ScLkUpdMode::LM_UNKNOWN)
176  {
177  throw css::lang::IllegalArgumentException(
178  ("LinkUpdateMode property value must be a SHORT with a value in the range of 0--2"
179  " as documented for css::sheet::XGlobalSheetSettings attribute LinkUpdateMode"),
180  css::uno::Reference<css::uno::XInterface>(), -1);
181  }
182  aAppOpt.SetLinkMode( static_cast<ScLkUpdMode>(n) );
183  bSaveApp = true;
184  }
185  else if (aPropertyName == SC_UNONAME_MARKHDR)
186  {
187  aInpOpt.SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
188  bSaveInp = true;
189  }
190  else if (aPropertyName == SC_UNONAME_MOVESEL)
191  {
192  aInpOpt.SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
193  bSaveInp = true;
194  }
195  else if (aPropertyName == SC_UNONAME_RANGEFIN)
196  {
197  aInpOpt.SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
198  bSaveInp = true;
199  }
200  else if (aPropertyName == SC_UNONAME_USETABCOL)
201  {
202  aInpOpt.SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
203  bSaveInp = true;
204  }
205  else if (aPropertyName == SC_UNONAME_PRMETRICS)
206  {
207  aInpOpt.SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
208  bSaveInp = true;
209  }
210  else if (aPropertyName == SC_UNONAME_REPLWARN)
211  {
212  aInpOpt.SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
213  bSaveInp = true;
214  }
215  else if (aPropertyName == SC_UNONAME_METRIC)
216  {
217  aAppOpt.SetAppMetric( static_cast<FieldUnit>(ScUnoHelpFunctions::GetInt16FromAny( aValue )) );
218  bSaveApp = true;
219  }
220  else if (aPropertyName == SC_UNONAME_MOVEDIR)
221  {
222  aInpOpt.SetMoveDir( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
223  bSaveInp = true;
224  }
225  else if (aPropertyName == SC_UNONAME_SCALE)
226  {
227  short nVal = ScUnoHelpFunctions::GetInt16FromAny( aValue );
228  if ( nVal < 0 )
229  {
230  SvxZoomType eType = SvxZoomType::PERCENT;
231  switch (nVal)
232  {
233  case SC_ZOOMVAL_OPTIMAL: eType = SvxZoomType::OPTIMAL; break;
234  case SC_ZOOMVAL_WHOLEPAGE: eType = SvxZoomType::WHOLEPAGE; break;
235  case SC_ZOOMVAL_PAGEWIDTH: eType = SvxZoomType::PAGEWIDTH; break;
236  }
237  aAppOpt.SetZoomType( eType );
238  }
239  else if ( nVal >= MINZOOM && nVal <= MAXZOOM )
240  {
241  aAppOpt.SetZoom( nVal );
242  aAppOpt.SetZoomType( SvxZoomType::PERCENT );
243  }
244  bSaveApp = true;
245  }
246  else if (aPropertyName == SC_UNONAME_STBFUNC)
247  {
248  aAppOpt.SetStatusFunc( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
249  bSaveApp = true;
250  }
251  else if (aPropertyName == SC_UNONAME_ULISTS)
252  {
253  ScUserList* pUserList = ScGlobal::GetUserList();
254  uno::Sequence<OUString> aSeq;
255  if ( pUserList && ( aValue >>= aSeq ) )
256  {
257  // directly change the active list
258  // ScGlobal::SetUseTabCol does not do much else
259 
260  pUserList->clear();
261  for (const OUString& aEntry : std::as_const(aSeq))
262  {
263  ScUserListData* pData = new ScUserListData(aEntry);
264  pUserList->push_back(pData);
265  }
266  bSaveApp = true; // List with App-Options are saved
267  }
268  }
269  else if (aPropertyName == SC_UNONAME_PRALLSH)
270  {
271  ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
272  aPrintOpt.SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
273  pScMod->SetPrintOptions( aPrintOpt );
274  }
275  else if (aPropertyName == SC_UNONAME_PREMPTY)
276  {
277  ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
278  aPrintOpt.SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); // reversed
279  pScMod->SetPrintOptions( aPrintOpt );
280  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScPrintOptions ) ); // update previews
281  }
282 
283  if ( bSaveApp )
284  pScMod->SetAppOptions( aAppOpt );
285  if ( bSaveInp )
286  pScMod->SetInputOptions( aInpOpt );
287 }
288 
289 uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const OUString& aPropertyName )
290 {
291  SolarMutexGuard aGuard;
292  uno::Any aRet;
293 
294  ScModule* pScMod = SC_MOD();
295  ScAppOptions aAppOpt = pScMod->GetAppOptions();
296  ScInputOptions aInpOpt = pScMod->GetInputOptions();
297  // print options aren't loaded until needed
298 
299  if (aPropertyName == SC_UNONAME_DOAUTOCP) aRet <<= aAppOpt.GetAutoComplete();
300  else if (aPropertyName == SC_UNONAME_ENTERED ) aRet <<= aInpOpt.GetEnterEdit();
301  else if (aPropertyName == SC_UNONAME_EXPREF ) aRet <<= aInpOpt.GetExpandRefs();
302  else if (aPropertyName == SC_UNONAME_EXTFMT ) aRet <<= aInpOpt.GetExtendFormat();
303  else if (aPropertyName == SC_UNONAME_LINKUPD ) aRet <<= static_cast<sal_Int16>(aAppOpt.GetLinkMode());
304  else if (aPropertyName == SC_UNONAME_MARKHDR ) aRet <<= aInpOpt.GetMarkHeader();
305  else if (aPropertyName == SC_UNONAME_MOVESEL ) aRet <<= aInpOpt.GetMoveSelection();
306  else if (aPropertyName == SC_UNONAME_RANGEFIN ) aRet <<= aInpOpt.GetRangeFinder();
307  else if (aPropertyName == SC_UNONAME_USETABCOL ) aRet <<= aInpOpt.GetUseTabCol();
308  else if (aPropertyName == SC_UNONAME_PRMETRICS ) aRet <<= aInpOpt.GetTextWysiwyg();
309  else if (aPropertyName == SC_UNONAME_REPLWARN ) aRet <<= aInpOpt.GetReplaceCellsWarn();
310  else if (aPropertyName == SC_UNONAME_METRIC ) aRet <<= static_cast<sal_Int16>(aAppOpt.GetAppMetric());
311  else if (aPropertyName == SC_UNONAME_MOVEDIR ) aRet <<= static_cast<sal_Int16>(aInpOpt.GetMoveDir());
312  else if (aPropertyName == SC_UNONAME_STBFUNC ) aRet <<= static_cast<sal_Int16>(aAppOpt.GetStatusFunc());
313  else if (aPropertyName == SC_UNONAME_SCALE )
314  {
315  sal_Int16 nZoomVal = 0;
316  switch ( aAppOpt.GetZoomType() )
317  {
318  case SvxZoomType::PERCENT: nZoomVal = aAppOpt.GetZoom(); break;
319  case SvxZoomType::OPTIMAL: nZoomVal = SC_ZOOMVAL_OPTIMAL; break;
320  case SvxZoomType::WHOLEPAGE: nZoomVal = SC_ZOOMVAL_WHOLEPAGE; break;
321  case SvxZoomType::PAGEWIDTH: nZoomVal = SC_ZOOMVAL_PAGEWIDTH; break;
322  default:
323  {
324  // added to avoid warnings
325  }
326  }
327  aRet <<= nZoomVal;
328  }
329  else if (aPropertyName == SC_UNONAME_ULISTS )
330  {
331  ScUserList* pUserList = ScGlobal::GetUserList();
332  if (pUserList)
333  {
334  size_t nCount = pUserList->size();
335  uno::Sequence<OUString> aSeq(nCount);
336  OUString* pAry = aSeq.getArray();
337  for (size_t i=0; i<nCount; ++i)
338  {
339  OUString aEntry((*pUserList)[i].GetString());
340  pAry[i] = aEntry;
341  }
342  aRet <<= aSeq;
343  }
344  }
345  else if (aPropertyName == SC_UNONAME_PRALLSH )
346  aRet <<= pScMod->GetPrintOptions().GetAllSheets();
347  else if (aPropertyName == SC_UNONAME_PREMPTY )
348  aRet <<= !pScMod->GetPrintOptions().GetSkipEmpty(); // reversed
349 
350  return aRet;
351 }
352 
354 
356 {
357 }
358 
360 {
361 }
362 
363 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
364 ScRecentFunctionsObj_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
365 {
366  SolarMutexGuard aGuard;
367  ScDLL::Init();
368  return cppu::acquire(new ScRecentFunctionsObj());
369 }
370 
371 // XRecentFunctions
372 
373 uno::Sequence<sal_Int32> SAL_CALL ScRecentFunctionsObj::getRecentFunctionIds()
374 {
375  SolarMutexGuard aGuard;
376  const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
377  sal_uInt16 nCount = rOpt.GetLRUFuncListCount();
378  const sal_uInt16* pFuncs = rOpt.GetLRUFuncList();
379  if (pFuncs)
380  {
381  uno::Sequence<sal_Int32> aSeq(nCount);
382  sal_Int32* pAry = aSeq.getArray();
383  for (sal_uInt16 i=0; i<nCount; i++)
384  pAry[i] = pFuncs[i];
385  return aSeq;
386  }
387  return uno::Sequence<sal_Int32>(0);
388 }
389 
391  const uno::Sequence<sal_Int32>& aRecentFunctionIds )
392 {
393  SolarMutexGuard aGuard;
394  sal_uInt16 nCount = static_cast<sal_uInt16>(std::min( aRecentFunctionIds.getLength(), sal_Int32(LRU_MAX) ));
395  const sal_Int32* pAry = aRecentFunctionIds.getConstArray();
396 
397  std::unique_ptr<sal_uInt16[]> pFuncs(nCount ? new sal_uInt16[nCount] : nullptr);
398  for (sal_uInt16 i=0; i<nCount; i++)
399  pFuncs[i] = static_cast<sal_uInt16>(pAry[i]);
400 
401  ScModule* pScMod = SC_MOD();
402  ScAppOptions aNewOpts(pScMod->GetAppOptions());
403  aNewOpts.SetLRUFuncList(pFuncs.get(), nCount);
404  pScMod->SetAppOptions(aNewOpts);
405 }
406 
408 {
409  return LRU_MAX;
410 }
411 
413 {
414 }
415 
417 {
418 }
419 
420 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
421 ScFunctionListObj_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
422 {
423  SolarMutexGuard aGuard;
424  ScDLL::Init();
425  return cppu::acquire(new ScFunctionListObj());
426 }
427 
428 static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, const ScFuncDesc& rDesc )
429 {
430  rDesc.initArgumentInfo(); // full argument info is needed
431 
432  OSL_ENSURE( rSequence.getLength() == SC_FUNCDESC_PROPCOUNT, "Wrong count" );
433 
434  beans::PropertyValue* pArray = rSequence.getArray();
435 
436  pArray[0].Name = SC_UNONAME_ID;
437  pArray[0].Value <<= static_cast<sal_Int32>(rDesc.nFIndex);
438 
439  pArray[1].Name = SC_UNONAME_CATEGORY;
440  pArray[1].Value <<= static_cast<sal_Int32>(rDesc.nCategory);
441 
442  pArray[2].Name = SC_UNONAME_NAME;
443  if (rDesc.mxFuncName)
444  pArray[2].Value <<= *rDesc.mxFuncName;
445 
446  pArray[3].Name = SC_UNONAME_DESCRIPTION;
447  if (rDesc.mxFuncDesc)
448  pArray[3].Value <<= *rDesc.mxFuncDesc;
449 
450  pArray[4].Name = SC_UNONAME_ARGUMENTS;
451  if (!rDesc.maDefArgNames.empty() && !rDesc.maDefArgDescs.empty() && rDesc.pDefArgFlags )
452  {
453  sal_uInt16 nCount = rDesc.nArgCount;
454  if (nCount >= PAIRED_VAR_ARGS)
455  nCount -= PAIRED_VAR_ARGS - 2;
456  else if (nCount >= VAR_ARGS)
457  nCount -= VAR_ARGS - 1;
458  sal_uInt16 nSeqCount = rDesc.GetSuppressedArgCount();
459  if (nSeqCount >= PAIRED_VAR_ARGS)
460  nSeqCount -= PAIRED_VAR_ARGS - 2;
461  else if (nSeqCount >= VAR_ARGS)
462  nSeqCount -= VAR_ARGS - 1;
463 
464  if (nSeqCount)
465  {
466  uno::Sequence<sheet::FunctionArgument> aArgSeq(nSeqCount);
467  sheet::FunctionArgument* pArgAry = aArgSeq.getArray();
468  for (sal_uInt16 i=0, j=0; i<nCount; i++)
469  {
470  sheet::FunctionArgument aArgument;
471  aArgument.Name = rDesc.maDefArgNames[i];
472  aArgument.Description = rDesc.maDefArgDescs[i];
473  aArgument.IsOptional = rDesc.pDefArgFlags[i].bOptional;
474  pArgAry[j++] = aArgument;
475  }
476  pArray[4].Value <<= aArgSeq;
477  }
478  }
479 }
480 
481 // XFunctionDescriptions
482 
483 uno::Sequence<beans::PropertyValue> SAL_CALL ScFunctionListObj::getById( sal_Int32 nId )
484 {
485  SolarMutexGuard aGuard;
487  if ( !pFuncList )
488  throw uno::RuntimeException(); // should not happen
489 
490  sal_uInt16 nCount = static_cast<sal_uInt16>(pFuncList->GetCount());
491  for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
492  {
493  const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
494  if ( pDesc && pDesc->nFIndex == nId )
495  {
496  uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
497  lcl_FillSequence( aSeq, *pDesc );
498  return aSeq;
499  }
500  }
501 
502  throw lang::IllegalArgumentException(); // not found
503 }
504 
505 // XNameAccess
506 
507 uno::Any SAL_CALL ScFunctionListObj::getByName( const OUString& aName )
508 {
509  SolarMutexGuard aGuard;
511  if ( !pFuncList )
512  throw uno::RuntimeException(); // should not happen
513 
514  sal_uInt16 nCount = static_cast<sal_uInt16>(pFuncList->GetCount());
515  for (sal_uInt16 nIndex=0; nIndex<nCount; nIndex++)
516  {
517  const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
519  if ( pDesc && pDesc->mxFuncName && aName == *pDesc->mxFuncName )
520  {
521  uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
522  lcl_FillSequence( aSeq, *pDesc );
523  return uno::makeAny(aSeq);
524  }
525  }
526 
527  throw container::NoSuchElementException(); // not found
528 }
529 
530 // XIndexAccess
531 
532 sal_Int32 SAL_CALL ScFunctionListObj::getCount()
533 {
534  SolarMutexGuard aGuard;
535  sal_Int32 nCount = 0;
537  if ( pFuncList )
538  nCount = static_cast<sal_Int32>(pFuncList->GetCount());
539  return nCount;
540 }
541 
542 uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex )
543 {
544  SolarMutexGuard aGuard;
546  if ( !pFuncList )
547  throw uno::RuntimeException(); // should not happen
548 
549  if ( nIndex >= 0 && nIndex < static_cast<sal_Int32>(pFuncList->GetCount()) )
550  {
551  const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
552  if ( pDesc )
553  {
554  uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
555  lcl_FillSequence( aSeq, *pDesc );
556  return uno::makeAny(aSeq);
557  }
558  }
559 
560  throw lang::IndexOutOfBoundsException(); // illegal index
561 }
562 
563 // XEnumerationAccess
564 
565 uno::Reference<container::XEnumeration> SAL_CALL ScFunctionListObj::createEnumeration()
566 {
567  SolarMutexGuard aGuard;
568  return new ScIndexEnumeration(this, "com.sun.star.sheet.FunctionDescriptionEnumeration");
569 }
570 
571 // XElementAccess
572 
574 {
575  SolarMutexGuard aGuard;
577 }
578 
580 {
581  SolarMutexGuard aGuard;
582  return ( getCount() > 0 );
583 }
584 
585 uno::Sequence<OUString> SAL_CALL ScFunctionListObj::getElementNames()
586 {
587  SolarMutexGuard aGuard;
589  if ( pFuncList )
590  {
591  sal_uInt32 nCount = pFuncList->GetCount();
592  uno::Sequence<OUString> aSeq(nCount);
593  OUString* pAry = aSeq.getArray();
594  for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
595  {
596  const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
597  if ( pDesc && pDesc->mxFuncName )
598  pAry[nIndex] = *pDesc->mxFuncName;
599  }
600  return aSeq;
601  }
602  return uno::Sequence<OUString>(0);
603 }
604 
605 sal_Bool SAL_CALL ScFunctionListObj::hasByName( const OUString& aName )
606 {
607  SolarMutexGuard aGuard;
609  if ( pFuncList )
610  {
611  sal_uInt32 nCount = pFuncList->GetCount();
612  for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
613  {
614  const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
616  if ( pDesc && pDesc->mxFuncName && aName == *pDesc->mxFuncName )
617  return true;
618  }
619  }
620  return false;
621 }
622 
623 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define MAXZOOM
Definition: global.hxx:76
virtual void SAL_CALL setRecentFunctionIds(const css::uno::Sequence< sal_Int32 > &aRecentFunctionIds) override
Definition: appluno.cxx:390
#define SC_UNONAME_METRIC
Definition: unonames.hxx:240
List of spreadsheet functions.
Definition: funcdesc.hxx:242
#define SC_UNONAME_ID
Definition: unonames.hxx:230
#define SC_UNONAME_PRALLSH
Definition: unonames.hxx:249
#define SC_UNONAME_PREMPTY
Definition: unonames.hxx:250
Collection of user-defined sort lists.
Definition: userlist.hxx:66
virtual sal_Int32 SAL_CALL getCount() override
Definition: appluno.cxx:532
sal_Int32 nIndex
static const SfxItemPropertyMapEntry * lcl_GetSettingsPropertyMap()
Definition: appluno.cxx:56
bool GetMoveSelection() const
Definition: inputopt.hxx:50
bool GetAutoComplete() const
Definition: appoptio.hxx:55
virtual ~ScSpreadsheetSettings() override
Definition: appluno.cxx:97
#define PAIRED_VAR_ARGS
sal_uInt16 GetSuppressedArgCount() const
Returns the number of non-suppressed arguments.
Definition: funcdesc.cxx:278
bool bOptional
Parameter is optional.
Definition: funcdesc.hxx:212
#define SC_UNONAME_PRMETRICS
Definition: unonames.hxx:248
static void lcl_FillSequence(uno::Sequence< beans::PropertyValue > &rSequence, const ScFuncDesc &rDesc)
Definition: appluno.cxx:428
ScLkUpdMode GetLinkMode() const
Definition: appoptio.hxx:68
std::unique_ptr< ContentProperties > pData
#define SC_UNONAME_STBFUNC
Definition: unonames.hxx:245
#define SC_UNONAME_MOVEDIR
Definition: unonames.hxx:241
sal_uInt16 char char * pDesc
Definition: callform.cxx:58
sal_uInt16 GetLRUFuncListCount() const
Definition: appoptio.hxx:48
#define SC_UNONAME_SCALE
Definition: unonames.hxx:244
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: appluno.cxx:289
void SetLRUFuncList(const sal_uInt16 *pList, const sal_uInt16 nCount)
Definition: appoptio.cxx:111
sal_Int64 n
#define SC_UNONAME_MARKHDR
Definition: unonames.hxx:239
#define SC_ZOOMVAL_PAGEWIDTH
Definition: appluno.cxx:49
#define SC_FUNCDESC_PROPCOUNT
Definition: appluno.cxx:52
virtual ~ScFunctionListObj() override
Definition: appluno.cxx:416
size_t size() const
Definition: userlist.cxx:345
SvxZoomType GetZoomType() const
Definition: appoptio.hxx:45
virtual sal_Int32 SAL_CALL getMaxRecentFunctions() override
Definition: appluno.cxx:407
#define SC_UNONAME_CATEGORY
Definition: unonames.hxx:228
virtual css::uno::Type SAL_CALL getElementType() override
Definition: appluno.cxx:573
void SetEnterEdit(bool bSet)
Definition: inputopt.hxx:51
#define SC_UNONAME_MOVESEL
Definition: unonames.hxx:242
SfxApplication * SfxGetpApp()
FieldUnit GetAppMetric() const
Definition: appoptio.hxx:41
void push_back(ScUserListData *p)
Definition: userlist.cxx:350
Stores individual user-defined sort list.
Definition: userlist.hxx:33
#define SC_UNONAME_EXPREF
Definition: unonames.hxx:236
#define SC_UNONAME_RANGEFIN
Definition: unonames.hxx:243
bool GetMarkHeader() const
Definition: inputopt.hxx:62
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: appluno.cxx:565
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: appluno.cxx:605
sal_uInt16 GetZoom() const
Definition: appoptio.hxx:43
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
int nCount
sal_uInt16 * GetLRUFuncList() const
Definition: appoptio.hxx:49
virtual sal_Bool SAL_CALL hasElements() override
Definition: appluno.cxx:579
virtual ~ScRecentFunctionsObj() override
Definition: appluno.cxx:359
ParameterFlags * pDefArgFlags
Flags for each parameter.
Definition: funcdesc.hxx:221
#define SC_UNONAME_USETABCOL
Definition: unonames.hxx:247
SC_DLLPUBLIC void SetInputOptions(const ScInputOptions &rOpt)
Definition: scmod.cxx:772
bool GetTextWysiwyg() const
Definition: inputopt.hxx:66
DocumentType eType
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:719
sal_uInt16 nCategory
Function category.
Definition: funcdesc.hxx:223
#define SC_UNONAME_DESCRIPTION
Definition: unonames.hxx:229
bool GetUseTabCol() const
Definition: inputopt.hxx:64
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: appluno.cxx:137
int i
bool GetReplaceCellsWarn() const
Definition: inputopt.hxx:68
bool GetEnterEdit() const
Definition: inputopt.hxx:52
void SetAllSheets(bool bVal)
Definition: printopt.hxx:40
SC_DLLPUBLIC const ScPrintOptions & GetPrintOptions()
Definition: scmod.cxx:796
#define VAR_ARGS
std::vector< OUString > maDefArgDescs
Description(s) of parameter(s)
Definition: funcdesc.hxx:220
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
Definition: scdll.cxx:105
#define SC_MOD()
Definition: scmod.hxx:253
void SetPrintOptions(const ScPrintOptions &rOpt)
Definition: scmod.cxx:788
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ScRecentFunctionsObj_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: appluno.cxx:364
const Any & any
sal_Int16 getPropertyInt16(const OUString &aPropertyName)
Definition: appluno.cxx:119
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:732
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ScFunctionListObj_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: appluno.cxx:421
#define SC_UNONAME_ULISTS
Definition: unonames.hxx:246
unsigned char sal_Bool
static SC_DLLPUBLIC ScUserList * GetUserList()
Definition: global.cxx:277
std::optional< OUString > mxFuncDesc
Description of function.
Definition: funcdesc.hxx:218
#define LRU_MAX
Definition: funcdesc.hxx:35
css::uno::Type const & get()
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
Definition: miscuno.hxx:64
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
Definition: funcdesc.cxx:1015
static sal_Int16 GetInt16FromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:144
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
Definition: miscuno.hxx:73
static ScFunctionList * GetStarCalcFunctionList()
Definition: global.cxx:619
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_ScSpreadsheetSettings_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: appluno.cxx:102
#define SC_ZOOMVAL_OPTIMAL
somewhere central
Definition: appluno.cxx:47
bool GetExtendFormat() const
Definition: inputopt.hxx:54
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getRecentFunctionIds() override
Definition: appluno.cxx:373
bool GetExpandRefs() const
Definition: inputopt.hxx:58
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getById(sal_Int32 nId) override
Definition: appluno.cxx:483
bool getPropertyBool(const OUString &aPropertyName)
Definition: appluno.cxx:111
std::optional< OUString > mxFuncName
Function name.
Definition: funcdesc.hxx:217
Any makeAny(Color const &value)
#define SCFUNCTIONLISTOBJ_SERVICE
Definition: appluno.cxx:83
#define SCSPREADSHEETSETTINGS_SERVICE
Definition: appluno.cxx:85
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: appluno.cxx:507
#define SC_UNONAME_DOAUTOCP
Definition: unonames.hxx:234
bool GetAllSheets() const
Definition: printopt.hxx:39
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: appluno.cxx:129
#define SC_UNONAME_NAME
Definition: unonames.hxx:231
virtual void initArgumentInfo() const override
Requests function data from AddInCollection.
Definition: funcdesc.cxx:327
void clear()
Definition: userlist.cxx:340
sal_uInt16 GetMoveDir() const
Definition: inputopt.hxx:48
SC_DLLPUBLIC const ScInputOptions & GetInputOptions()
Definition: scmod.cxx:780
Sequence< sal_Int8 > aSeq
sal_uInt16 nFIndex
Unique function index.
Definition: funcdesc.hxx:222
#define SC_ZOOMVAL_WHOLEPAGE
Definition: appluno.cxx:48
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: appluno.cxx:585
sal_uInt32 GetCount() const
Definition: funcdesc.hxx:248
void SetSkipEmpty(bool bVal)
Definition: printopt.hxx:38
#define SCRECENTFUNCTIONSOBJ_SERVICE
Definition: appluno.cxx:84
#define SC_UNONAME_EXTFMT
Definition: unonames.hxx:237
#define SC_UNONAME_ENTERED
Definition: unonames.hxx:235
sal_uInt32 GetStatusFunc() const
Definition: appoptio.hxx:53
bool GetRangeFinder() const
Definition: inputopt.hxx:56
#define MINZOOM
Definition: global.hxx:75
#define SC_UNONAME_ARGUMENTS
Definition: unonames.hxx:227
std::vector< OUString > maDefArgNames
Parameter name(s)
Definition: funcdesc.hxx:219
bool GetSkipEmpty() const
Definition: printopt.hxx:37
SvxZoomType
#define SC_UNONAME_LINKUPD
Definition: unonames.hxx:238
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:138
#define SC_UNONAME_REPLWARN
Definition: unonames.hxx:251
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
Definition: funcdesc.hxx:41
sal_uInt16 nArgCount
All parameter count, suppressed and unsuppressed.
Definition: funcdesc.hxx:224
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: appluno.cxx:542
OUString GetString(double f, bool bLeadingSign, sal_uInt16 nMaxDig)