25#include <osl/diagnose.h>
32#include <document.hxx>
33#include <compiler.hxx>
47#include <tokenarray.hxx>
72 ~ScTempDocSource() COVERITY_NOEXCEPT_FALSE;
89 if ( rCache.IsInUse() )
90 pTempDoc.reset(CreateDocument());
93 rCache.SetInUse(
true );
94 if ( !rCache.GetDocument() )
95 rCache.SetDocument( CreateDocument() );
99ScTempDocSource::~ScTempDocSource() COVERITY_NOEXCEPT_FALSE
102 rCache.SetInUse(
false );
108 return pTempDoc.get();
110 return rCache.GetDocument();
120 OSL_ENSURE(!
xDoc,
"ScTempDocCache::SetDocument: already set");
126 OSL_ENSURE( !
bInUse,
"ScTempDocCache::Clear: bInUse" );
150 pSrcDoc->
CopyToClip(aClipParam, pClipDoc.get(), &aSourceMark,
false,
false);
152 if ( pClipDoc->HasAttrib( 0,0,nSrcTab, pClipDoc->MaxCol(), pClipDoc->MaxRow(),nSrcTab,
158 pClipDoc->ApplyPatternAreaTab( 0,0, pClipDoc->MaxCol(), pClipDoc->MaxRow(), nSrcTab, aPattern );
189 if ( rHint.
GetId() == SfxHintId::Deinitializing )
197extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
208 return "stardiv.StarCalc.ScFunctionAccess";
226 static uno::Reference<beans::XPropertySetInfo> aRef(
232 const OUString& aPropertyName,
const uno::Any& aValue )
236 if ( aPropertyName ==
"IsArrayFunction" )
239 throw lang::IllegalArgumentException();
250 throw beans::UnknownPropertyException(aPropertyName);
258 if ( aPropertyName ==
"IsArrayFunction" )
281 OpCode eOp = rCompiler.GetEnglishOpCode( aUpper );
284 rArray.AddOpCode( eOp );
292 rArray.AddExternal(aUpper.getStr());
300 if (!aIntName.isEmpty())
302 rArray.AddExternal(aIntName.getStr());
324 explicit SimpleVisitor(
ScDocument* pDoc ) : mbArgError( false ), mpDoc( pDoc ) {}
332 void visitElem( sal_Int32 nCol, sal_Int32 nRow, sal_Int16 elem )
336 void visitElem( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 elem )
340 void visitElem( sal_Int32 nCol, sal_Int32 nRow,
const double& elem )
344 void visitElem( sal_Int32 nCol, sal_Int32 nRow,
const OUString& elem )
353 void visitElem( sal_Int32 nCol, sal_Int32 nRow,
const uno::Any& rElement )
355 uno::TypeClass eElemClass = rElement.getValueTypeClass();
356 if ( eElemClass == uno::TypeClass_VOID )
360 else if ( eElemClass == uno::TypeClass_BYTE ||
361 eElemClass == uno::TypeClass_SHORT ||
362 eElemClass == uno::TypeClass_UNSIGNED_SHORT ||
363 eElemClass == uno::TypeClass_LONG ||
364 eElemClass == uno::TypeClass_UNSIGNED_LONG ||
365 eElemClass == uno::TypeClass_FLOAT ||
366 eElemClass == uno::TypeClass_DOUBLE )
372 visitElem( nCol, nRow, fVal );
374 else if ( eElemClass == uno::TypeClass_STRING )
378 visitElem( nCol, nRow, aUStr );
383 bool hasArgError()
const {
return mbArgError; }
387class SequencesContainer
389 uno::Sequence< uno::Sequence< seq > > maSeq;
399 mrDocRow( rDocRow ), mbOverflow(false), mbArgError(false), mpDoc( pDoc ), mrTokenArr( rTokenArr )
406 SimpleVisitor aVisitor(mpDoc);
407 sal_Int32 nStartRow = mrDocRow;
408 sal_Int32 nRowCount = maSeq.getLength();
409 sal_Int32 nMaxColCount = 0;
410 for (
const uno::Sequence< seq >& rRow : std::as_const(maSeq) )
412 sal_Int32 nColCount = rRow.getLength();
413 if ( nColCount > nMaxColCount )
414 nMaxColCount = nColCount;
415 for (sal_Int32 nCol=0; nCol<nColCount; nCol++)
416 if ( nCol <= mpDoc->MaxCol() && mrDocRow <= mpDoc->MaxRow() )
417 aVisitor.visitElem( nCol, mrDocRow, rRow[ nCol ] );
422 mbArgError = aVisitor.hasArgError();
425 if (nRowCount && nMaxColCount)
426 lcl_AddRef( mrTokenArr, nStartRow, nMaxColCount, nRowCount );
427 else if (nRowCount == 1 && !nMaxColCount)
432 bool getOverflow()
const {
return mbOverflow; }
433 bool getArgError()
const {
return mbArgError; }
437class ArrayOfArrayProc
441 sal_Int32& rDocRow,
bool& rArgErr,
bool& rOverflow )
443 SequencesContainer< T > aContainer( rArg, rTokenArr, rDocRow, pDoc );
444 aContainer.process();
445 rArgErr = aContainer.getArgError();
446 rOverflow = aContainer.getOverflow();
453 const uno::Sequence<uno::Any>& aArguments )
458 throw uno::RuntimeException();
464 const static SCTAB nTempSheet = 1;
467 if ( !pDoc->
HasTable( nTempSheet ) )
480 throw container::NoSuchElementException();
490 bool bArgErr =
false;
491 bool bOverflow =
false;
492 sal_Int32 nDocRow = 0;
505 uno::TypeClass eClass = rArg.getValueTypeClass();
506 const uno::Type& aType = rArg.getValueType();
507 if ( eClass == uno::TypeClass_BYTE ||
508 eClass == uno::TypeClass_BOOLEAN ||
509 eClass == uno::TypeClass_SHORT ||
510 eClass == uno::TypeClass_UNSIGNED_SHORT ||
511 eClass == uno::TypeClass_LONG ||
512 eClass == uno::TypeClass_UNSIGNED_LONG ||
513 eClass == uno::TypeClass_FLOAT ||
514 eClass == uno::TypeClass_DOUBLE )
522 else if ( eClass == uno::TypeClass_STRING )
528 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<sal_Int16> >>::get() ) )
530 ArrayOfArrayProc<sal_Int16>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
532 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<sal_Int32> >>::get() ) )
534 ArrayOfArrayProc<sal_Int32>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
536 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<double> >>::get() ) )
538 ArrayOfArrayProc<double>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
540 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<OUString> >>::get() ) )
542 ArrayOfArrayProc<OUString>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
544 else if ( aType.equals(
cppu::UnoType<uno::Sequence< uno::Sequence<uno::Any> >>::get() ) )
546 ArrayOfArrayProc<uno::Any>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
552 uno::Reference<table::XCellRange> xRange(rArg, uno::UNO_QUERY);
553 ScCellRangesBase* pImpl =
dynamic_cast<ScCellRangesBase*
>( xRange.get() );
557 const ScRangeList& rRanges = pImpl->GetRangeList();
558 if ( pSrcDoc && rRanges.
size() == 1 )
560 ScRange const & rSrcRange = rRanges[ 0 ];
562 sal_Int32 nStartRow = nDocRow;
575 nDocRow += nRowCount;
577 lcl_AddRef( aTokenArr, nStartRow, nColCount, nRowCount );
594 if ( !bArgErr && !bOverflow && nDocRow <= pDoc->GetSheetLimits().GetMaxRowCount() )
596 ScAddress aFormulaPos( 0, 0, nTempSheet );
611 if ( nErrCode == FormulaError::NONE )
618 else if ( pFormula->
IsValue() )
630 else if ( nErrCode == FormulaError::NotAvailable )
645 throw uno::RuntimeException();
648 throw lang::IllegalArgumentException();
SfxApplication * SfxGetpApp()
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
static bool setPropertyValue(ScDocOptions &rOptions, const SfxItemPropertyMap &rPropMap, std::u16string_view aPropertyName, const css::uno::Any &aValue)
static css::uno::Any getPropertyValue(const ScDocOptions &rOptions, const SfxItemPropertyMap &rPropMap, std::u16string_view PropertyName)
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC void CopyFromClip(const ScRange &rDestRange, const ScMarkData &rMark, InsertDeleteFlags nInsFlag, ScDocument *pRefUndoDoc, ScDocument *pClipDoc, bool bResetCut=true, bool bAsLink=false, bool bIncludeFiltered=true, bool bSkipEmptyCells=false, const ScRangeList *pDestRanges=nullptr)
Paste data from a clipboard document into this document.
SC_DLLPUBLIC ScFormulaCell * SetFormulaCell(const ScAddress &rPos, ScFormulaCell *pCell)
Set formula cell, and transfer its ownership to the document.
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
SC_DLLPUBLIC void CopyToClip(const ScClipParam &rClipParam, ScDocument *pClipDoc, const ScMarkData *pMarks, bool bKeepScenarioFlags, bool bIncludeObjects)
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, InsertDeleteFlags nDelFlag)
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
SfxItemPropertyMap aPropertyMap
virtual ~ScFunctionAccess() override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual OUString SAL_CALL getImplementationName() override
std::unique_ptr< ScDocOptions > pOptions
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual css::uno::Any SAL_CALL callFunction(const OUString &aName, const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
static LegacyFuncCollection * GetLegacyFuncCollection()
static SC_DLLPUBLIC ScUnoAddInCollection * GetAddInCollection()
static SC_DLLPUBLIC const CharClass & getCharClass()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SelectOneTable(SCTAB nTab)
void SetMarkArea(const ScRange &rRange)
Matrix data type that can store values of mixed types.
SfxItemSet & GetItemSet()
static bool FillMixedArray(css::uno::Any &rAny, ScDocument &rDoc, const ScRange &rRange, bool bAllowNV=false)
void SetDocument(ScDocument *pNew)
virtual formula::FormulaToken * AddOpCode(OpCode eCode) override
formula::FormulaToken * AddDoubleReference(const ScComplexRefData &rRef)
OUString FindFunction(const OUString &rUpperName, bool bLocalFirst)
User entered name. rUpperName MUST already be upper case!
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
SharedString intern(const OUString &rStr)
const OUString & getString() const
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
@ SCDOCMODE_FUNCTIONACCESS
constexpr OUStringLiteral SCFUNCTIONACCESS_SERVICE
constexpr OUStringLiteral SCDOCSETTINGS_SERVICE
static void lcl_AddRef(ScTokenArray &rArray, sal_Int32 nStartRow, sal_Int32 nColCount, sal_Int32 nRowCount)
static bool lcl_AddFunctionToken(ScTokenArray &rArray, const OUString &rName, const ScCompiler &rCompiler)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ScFunctionAccess_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
static bool lcl_CopyData(ScDocument *pSrcDoc, const ScRange &rSrcRange, ScDocument *pDestDoc, const ScAddress &rDestPos)
merge this with ScAreaLink::Refresh copy directly without a clipboard document?
Sequence< PropertyValue > aArguments
#define SC_IMPL_DUMMY_PROPERTY_LISTENER(ClassName)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...
Complex reference (a range) into the sheet.
void InitRange(const ScRange &rRange)
Store parameters used in the ScDocument::SetString() method.
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is.
SCROW GetMaxRowCount() const