LCOV - code coverage report
Current view: top level - sc/inc - addincol.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 24 0.0 %
Date: 2014-04-14 Functions: 0 27 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 SC_ADDINCOL_HXX
      21             : #define SC_ADDINCOL_HXX
      22             : 
      23             : #include "global.hxx"
      24             : #include <com/sun/star/sheet/XVolatileResult.hpp>
      25             : #include <com/sun/star/sheet/XAddIn.hpp>
      26             : #include <com/sun/star/sheet/XResultListener.hpp>
      27             : #include <com/sun/star/sheet/ResultEvent.hpp>
      28             : #include <com/sun/star/container/XNameAccess.hpp>
      29             : #include <com/sun/star/reflection/XIdlMethod.hpp>
      30             : #include <i18nlangtag/lang.h>
      31             : #include <rtl/ustring.h>
      32             : #include "scdllapi.h"
      33             : #include <rtl/ustring.hxx>
      34             : 
      35             : #include "types.hxx"
      36             : 
      37             : #include <boost/unordered_map.hpp>
      38             : 
      39             : class SfxObjectShell;
      40             : class ScUnoAddInFuncData;
      41             : class ScFuncDesc;
      42             : 
      43             : typedef ::boost::unordered_map< OUString, const ScUnoAddInFuncData*, OUStringHash > ScAddInHashMap;
      44             : 
      45             : enum ScAddInArgumentType
      46             : {
      47             :     SC_ADDINARG_NONE,                   ///< -
      48             :     SC_ADDINARG_INTEGER,                ///< long
      49             :     SC_ADDINARG_DOUBLE,                 ///< double
      50             :     SC_ADDINARG_STRING,                 ///< string
      51             :     SC_ADDINARG_INTEGER_ARRAY,          ///< sequence<sequence<long>>
      52             :     SC_ADDINARG_DOUBLE_ARRAY,           ///< sequence<sequence<double>>
      53             :     SC_ADDINARG_STRING_ARRAY,           ///< sequence<sequence<string>>
      54             :     SC_ADDINARG_MIXED_ARRAY,            ///< sequence<sequence<any>>
      55             :     SC_ADDINARG_VALUE_OR_ARRAY,         ///< any
      56             :     SC_ADDINARG_CELLRANGE,              ///< XCellRange
      57             :     SC_ADDINARG_CALLER,                 ///< XPropertySet
      58             :     SC_ADDINARG_VARARGS                 ///< sequence<any>
      59             : };
      60             : 
      61           0 : struct ScAddInArgDesc
      62             : {
      63             :     OUString         aInternalName; ///< used to match configuration and reflection information
      64             :     OUString         aName;
      65             :     OUString         aDescription;
      66             :     ScAddInArgumentType eType;
      67             :     bool                    bOptional;
      68             : };
      69             : 
      70             : class ScUnoAddInFuncData
      71             : {
      72             : public:
      73           0 :     struct LocalizedName
      74             :     {
      75             :         OUString    maLocale;
      76             :         OUString    maName;
      77             : 
      78           0 :                     LocalizedName( const OUString& rLocale, const OUString& rName )
      79           0 :                         : maLocale( rLocale), maName( rName) { }
      80             :     };
      81             : private:
      82             :     OUString     aOriginalName;      ///< kept in formula
      83             :     OUString     aLocalName;         ///< for display
      84             :     OUString     aUpperName;         ///< for entering formulas
      85             :     OUString     aUpperLocal;        ///< for entering formulas
      86             :     OUString     aDescription;
      87             :     com::sun::star::uno::Reference< com::sun::star::reflection::XIdlMethod> xFunction;
      88             :     com::sun::star::uno::Any            aObject;
      89             :     long                nArgCount;
      90             :     ScAddInArgDesc*     pArgDescs;
      91             :     long                nCallerPos;
      92             :     sal_uInt16          nCategory;
      93             :     OString        sHelpId;
      94             :     mutable ::std::vector< LocalizedName > maCompNames;
      95             :     mutable bool        bCompInitialized;
      96             : 
      97             : public:
      98             :                 ScUnoAddInFuncData( const OUString& rNam, const OUString& rLoc,
      99             :                                     const OUString& rDesc,
     100             :                                     sal_uInt16 nCat, const OString&,
     101             :                                     const com::sun::star::uno::Reference<
     102             :                                         com::sun::star::reflection::XIdlMethod>& rFunc,
     103             :                                     const com::sun::star::uno::Any& rO,
     104             :                                     long nAC, const ScAddInArgDesc* pAD,
     105             :                                     long nCP );
     106             :                 ~ScUnoAddInFuncData();
     107             : 
     108           0 :     const OUString&  GetOriginalName() const     { return aOriginalName; }
     109           0 :     const OUString&  GetLocalName() const        { return aLocalName; }
     110           0 :     const OUString&  GetUpperName() const        { return aUpperName; }
     111           0 :     const OUString&  GetUpperLocal() const       { return aUpperLocal; }
     112           0 :     const com::sun::star::uno::Reference< com::sun::star::reflection::XIdlMethod>&   GetFunction() const
     113           0 :                                                         { return xFunction; }
     114           0 :     const com::sun::star::uno::Any& GetObject() const   { return aObject; }
     115           0 :     long                    GetArgumentCount() const    { return nArgCount; }
     116           0 :     const ScAddInArgDesc*   GetArguments() const        { return pArgDescs; }
     117           0 :     long                    GetCallerPos() const        { return nCallerPos; }
     118           0 :     const OUString&  GetDescription() const      { return aDescription; }
     119           0 :     sal_uInt16              GetCategory() const         { return nCategory; }
     120           0 :     const OString      GetHelpId() const           { return sHelpId; }
     121             : 
     122             :     const ::std::vector< LocalizedName >&  GetCompNames() const;
     123             :     bool                    GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const;
     124             : 
     125             :     void    SetFunction( const com::sun::star::uno::Reference< com::sun::star::reflection::XIdlMethod>& rNewFunc,
     126             :                          const com::sun::star::uno::Any& rNewObj );
     127             :     void    SetArguments( long nNewCount, const ScAddInArgDesc* pNewDescs );
     128             :     void    SetCallerPos( long nNewPos );
     129             :     void    SetCompNames( const ::std::vector< LocalizedName >& rNew );
     130             : };
     131             : 
     132             : class SC_DLLPUBLIC ScUnoAddInCollection
     133             : {
     134             : private:
     135             :     long                    nFuncCount;
     136             :     ScUnoAddInFuncData**    ppFuncData;
     137             :     ScAddInHashMap*         pExactHashMap;      ///< exact internal name
     138             :     ScAddInHashMap*         pNameHashMap;       ///< internal name upper
     139             :     ScAddInHashMap*         pLocalHashMap;      ///< localized name upper
     140             :     bool                    bInitialized;
     141             : 
     142             :     void        Initialize();
     143             :     void        ReadConfiguration();
     144             :     void        ReadFromAddIn( const com::sun::star::uno::Reference<
     145             :                                 com::sun::star::uno::XInterface>& xInterface );
     146             :     void        UpdateFromAddIn( const com::sun::star::uno::Reference<
     147             :                                   com::sun::star::uno::XInterface>& xInterface,
     148             :                                 const OUString& rServiceName );
     149             :     void        LoadComponent( const ScUnoAddInFuncData& rFuncData );
     150             : 
     151             : public:
     152             :                 ScUnoAddInCollection();
     153             :                 ~ScUnoAddInCollection();
     154             : 
     155             :                         /// User enetered name. rUpperName MUST already be upper case!
     156             :     OUString     FindFunction( const OUString& rUpperName, bool bLocalFirst );
     157             : 
     158             :                         /** Only if bComplete is set, the function reference and argument types
     159             :                             are initialized (component may have to be loaded).
     160             :                             @param rName is the exact Name. */
     161             :     const ScUnoAddInFuncData*   GetFuncData( const OUString& rName, bool bComplete = false );
     162             : 
     163             :                         /** For enumeration in ScCompiler::OpCodeMap::getAvailableMappings().
     164             :                             @param nIndex
     165             :                                 0 <= nIndex < GetFuncCount()
     166             :                          */
     167             :     const ScUnoAddInFuncData*   GetFuncData( long nIndex );
     168             : 
     169             :     void                Clear();
     170             : 
     171             :     void                LocalizeString( OUString& rName );    ///< modify rName - input: exact name
     172             : 
     173             :     long                GetFuncCount();
     174             :     bool                FillFunctionDesc( long nFunc, ScFuncDesc& rDesc );
     175             : 
     176             :     static bool         FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc );
     177             :                   /// leave rRetExcelName unchanged, if no matching name is found
     178             :     bool                GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName );
     179             :                   /// leave rRetCalcName unchanged, if no matching name is found
     180             :     bool                GetCalcName( const OUString& rExcelName, OUString& rRetCalcName );
     181             : };
     182             : 
     183             : class ScUnoAddInCall
     184             : {
     185             : private:
     186             :     const ScUnoAddInFuncData*   pFuncData;
     187             :     com::sun::star::uno::Sequence<com::sun::star::uno::Any>         aArgs;
     188             :     com::sun::star::uno::Sequence<com::sun::star::uno::Any>         aVarArg;
     189             :     com::sun::star::uno::Reference<com::sun::star::uno::XInterface> xCaller;
     190             :     bool                        bValidCount;
     191             :     // result:
     192             :     sal_uInt16                  nErrCode;
     193             :     bool                        bHasString;
     194             :     double                      fValue;
     195             :     OUString                    aString;
     196             :     ScMatrixRef                 xMatrix;
     197             :     com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVarRes;
     198             : 
     199             :     void            ExecuteCallWithArgs(
     200             :                         com::sun::star::uno::Sequence<com::sun::star::uno::Any>& rCallArgs);
     201             : 
     202             : public:
     203             :                     // exact name
     204             :                     ScUnoAddInCall( ScUnoAddInCollection& rColl, const OUString& rName,
     205             :                                     long nParamCount );
     206             :                     ~ScUnoAddInCall();
     207             : 
     208             :     bool                NeedsCaller() const;
     209             :     void                SetCaller( const com::sun::star::uno::Reference<
     210             :                                     com::sun::star::uno::XInterface>& rInterface );
     211             :     void                SetCallerFromObjectShell( SfxObjectShell* pSh );
     212             : 
     213             :     bool                ValidParamCount();
     214             :     ScAddInArgumentType GetArgType( long nPos );
     215             :     void                SetParam( long nPos, const com::sun::star::uno::Any& rValue );
     216             : 
     217             :     void                ExecuteCall();
     218             : 
     219             :     void                SetResult( const com::sun::star::uno::Any& rNewRes );
     220             : 
     221           0 :     sal_uInt16          GetErrCode() const      { return nErrCode; }
     222           0 :     bool                HasString() const       { return bHasString; }
     223           0 :     bool                HasMatrix() const       { return xMatrix.get(); }
     224           0 :     bool                HasVarRes() const       { return ( xVarRes.is() ); }
     225           0 :     double              GetValue() const        { return fValue; }
     226           0 :     const OUString&     GetString() const       { return aString; }
     227             :     ScMatrixRef         GetMatrix() const;
     228             :     com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult>
     229           0 :                         GetVarRes() const       { return xVarRes; }
     230             : };
     231             : 
     232             : #endif
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10