LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/basic - basmgr.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 15 80.0 %
Date: 2012-08-25 Functions: 9 12 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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                 :            : #ifndef _BASMGR_HXX
      20                 :            : #define _BASMGR_HXX
      21                 :            : 
      22                 :            : #include <tools/string.hxx>
      23                 :            : #include <svl/brdcst.hxx>
      24                 :            : #include <basic/sbstar.hxx>
      25                 :            : #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
      26                 :            : #include <com/sun/star/script/XStarBasicAccess.hpp>
      27                 :            : #include "basicdllapi.h"
      28                 :            : #include <vector>
      29                 :            : 
      30                 :            : // Basic XML Import/Export
      31                 :            : BASIC_DLLPUBLIC com::sun::star::uno::Reference< com::sun::star::script::XStarBasicAccess >
      32                 :            :     getStarBasicAccess( BasicManager* pMgr );
      33                 :            : 
      34                 :            : class SotStorage;
      35                 :            : 
      36                 :            : #define BASERR_REASON_OPENSTORAGE       0x0001
      37                 :            : #define BASERR_REASON_OPENLIBSTORAGE    0x0002
      38                 :            : #define BASERR_REASON_OPENMGRSTREAM     0x0004
      39                 :            : #define BASERR_REASON_OPENLIBSTREAM     0x0008
      40                 :            : #define BASERR_REASON_LIBNOTFOUND       0x0010
      41                 :            : #define BASERR_REASON_STORAGENOTFOUND   0x0020
      42                 :            : #define BASERR_REASON_BASICLOADERROR    0x0040
      43                 :            : #define BASERR_REASON_NOSTORAGENAME     0x0080
      44                 :            : 
      45                 :            : #define BASERR_REASON_STDLIB            0x0100
      46                 :            : 
      47                 :          0 : class BASIC_DLLPUBLIC BasicError
      48                 :            : {
      49                 :            : private:
      50                 :            :     sal_uIntPtr nErrorId;
      51                 :            :     sal_uInt16  nReason;
      52                 :            :     String  aErrStr;
      53                 :            : 
      54                 :            : public:
      55                 :            :             BasicError( const BasicError& rErr );
      56                 :            :             BasicError( sal_uIntPtr nId, sal_uInt16 nR, const String& rErrStr );
      57                 :            : 
      58                 :          0 :     sal_uIntPtr     GetErrorId() const                  { return nErrorId; }
      59                 :            :     sal_uInt16  GetReason() const                   { return nReason; }
      60                 :            :     String  GetErrorStr()                       { return aErrStr; }
      61                 :            : 
      62                 :            :     void    SetErrorId( sal_uIntPtr n )             { nErrorId = n; }
      63                 :            :     void    SetReason( sal_uInt16 n )               { nReason = n; }
      64                 :            :     void    SetErrorStr( const String& rStr)    { aErrStr = rStr; }
      65                 :            : };
      66                 :            : 
      67                 :            : class BasicLibs;
      68                 :            : class ErrorManager;
      69                 :            : class BasicLibInfo;
      70                 :            : 
      71                 :            : namespace basic { class BasicManagerCleaner; }
      72                 :            : 
      73                 :            : // Library password handling for 5.0 documents
      74                 :       1412 : class BASIC_DLLPUBLIC OldBasicPassword
      75                 :            : {
      76                 :            : public:
      77                 :            :     virtual void setLibraryPassword( const String& rLibraryName, const String& rPassword ) = 0;
      78                 :            :     virtual String getLibraryPassword( const String& rLibraryName ) = 0;
      79                 :            :     virtual void clearLibraryPassword( const String& rLibraryName ) = 0;
      80                 :            :     virtual sal_Bool hasLibraryPassword( const String& rLibraryName ) = 0;
      81                 :            : 
      82                 :            : protected:
      83                 :       1334 :     ~OldBasicPassword() {}
      84                 :            : };
      85                 :            : 
      86                 :        498 : struct LibraryContainerInfo
      87                 :            : {
      88                 :            :     ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > mxScriptCont;
      89                 :            :     ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > mxDialogCont;
      90                 :            :     OldBasicPassword* mpOldBasicPassword;
      91                 :            : 
      92                 :        187 :     LibraryContainerInfo()
      93                 :        187 :         :mpOldBasicPassword( NULL )
      94                 :            :     {
      95                 :        187 :     }
      96                 :            : 
      97                 :        187 :     LibraryContainerInfo
      98                 :            :     (
      99                 :            :         com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > xScriptCont,
     100                 :            :         com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer > xDialogCont,
     101                 :            :         OldBasicPassword* pOldBasicPassword
     102                 :            :     )
     103                 :            :         : mxScriptCont( xScriptCont )
     104                 :            :         , mxDialogCont( xDialogCont )
     105                 :        187 :         , mpOldBasicPassword( pOldBasicPassword )
     106                 :        187 :     {}
     107                 :            : };
     108                 :            : 
     109                 :            : struct BasicManagerImpl;
     110                 :            : 
     111                 :            : 
     112                 :            : #define LIB_NOTFOUND    0xFFFF
     113                 :            : 
     114                 :            : class BASIC_DLLPUBLIC BasicManager : public SfxBroadcaster
     115                 :            : {
     116                 :            :     friend class LibraryContainer_Impl;
     117                 :            :     friend class StarBasicAccess_Impl;
     118                 :            :     friend class BasMgrContainerListenerImpl;
     119                 :            :     friend class ::basic::BasicManagerCleaner;
     120                 :            : 
     121                 :            : private:
     122                 :            :     BasicLibs*          pLibs;
     123                 :            :     std::vector<BasicError> aErrors;
     124                 :            : 
     125                 :            :     String              aName;
     126                 :            :     String              maStorageName;
     127                 :            :     sal_Bool                mbDocMgr;
     128                 :            : 
     129                 :            :     BasicManagerImpl*   mpImpl;
     130                 :            : 
     131                 :            :     BASIC_DLLPRIVATE void Init();
     132                 :            : 
     133                 :            : protected:
     134                 :            :     sal_Bool            ImpLoadLibary( BasicLibInfo* pLibInfo ) const;
     135                 :            :     sal_Bool            ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly = sal_False );
     136                 :            :     void            ImpCreateStdLib( StarBASIC* pParentFromStdLib );
     137                 :            :     void            ImpMgrNotLoaded(  const String& rStorageName  );
     138                 :            :     BasicLibInfo*   CreateLibInfo();
     139                 :            :     void            LoadBasicManager( SotStorage& rStorage, const String& rBaseURL, sal_Bool bLoadBasics = sal_True );
     140                 :            :     void            LoadOldBasicManager( SotStorage& rStorage );
     141                 :            :     sal_Bool            ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) const;
     142                 :            :     sal_Bool            ImplEncryptStream( SvStream& rStream ) const;
     143                 :            :     BasicLibInfo*   FindLibInfo( StarBASIC* pBasic ) const;
     144                 :            :     void            CheckModules( StarBASIC* pBasic, sal_Bool bReference ) const;
     145                 :            :     ~BasicManager();
     146                 :            : 
     147                 :            : public:
     148                 :            :                     TYPEINFO();
     149                 :            :                     BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBASIC* pParentFromStdLib = NULL, String* pLibPath = NULL, sal_Bool bDocMgr = sal_False );
     150                 :            :                     BasicManager( StarBASIC* pStdLib, String* pLibPath = NULL, sal_Bool bDocMgr = sal_False );
     151                 :            : 
     152                 :            :     /** deletes the given BasicManager instance
     153                 :            : 
     154                 :            :         This method is necessary since normally, BasicManager instances are owned by the BasicManagerRepository,
     155                 :            :         and expected to be deleted by the repository only. However, there exists quite some legacy code,
     156                 :            :         which needs to explicitly delete a BasicManager itself. This code must not use the (protected)
     157                 :            :         destructor, but LegacyDeleteBasicManager.
     158                 :            :     */
     159                 :            :     static void     LegacyDeleteBasicManager( BasicManager*& _rpManager );
     160                 :            : 
     161                 :        122 :     void            SetStorageName( const String& rName )   { maStorageName = rName; }
     162                 :          0 :     String          GetStorageName() const                  { return maStorageName; }
     163                 :         13 :     void            SetName( const String& rName )          { aName = rName; }
     164                 :        397 :     String          GetName() const                         { return aName; }
     165                 :            : 
     166                 :            : 
     167                 :            :     sal_uInt16          GetLibCount() const;
     168                 :            :     StarBASIC*      GetLib( sal_uInt16 nLib ) const;
     169                 :            :     StarBASIC*      GetLib( const String& rName ) const;
     170                 :            :     sal_uInt16          GetLibId( const String& rName ) const;
     171                 :            : 
     172                 :            :     String          GetLibName( sal_uInt16 nLib );
     173                 :            : 
     174                 :            :     /** announces the library containers which belong to this BasicManager
     175                 :            : 
     176                 :            :         The method will automatically add two global constants, BasicLibraries and DialogLibraries,
     177                 :            :         to the BasicManager.
     178                 :            :     */
     179                 :            :     void            SetLibraryContainerInfo( const LibraryContainerInfo& rInfo );
     180                 :            : 
     181                 :            :     const ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer >&
     182                 :            :                     GetDialogLibraryContainer()  const;
     183                 :            :     const ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer >&
     184                 :            :                     GetScriptLibraryContainer()  const;
     185                 :            : 
     186                 :            :     sal_Bool            LoadLib( sal_uInt16 nLib );
     187                 :            :     sal_Bool            RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage );
     188                 :            : 
     189                 :            :     // Modify-Flag will be reset only during save.
     190                 :            :     sal_Bool            IsBasicModified() const;
     191                 :            : 
     192                 :            :     std::vector<BasicError>& GetErrors();
     193                 :            : 
     194                 :            :     /** sets a global constant in the basic library, referring to some UNO object, to a new value.
     195                 :            : 
     196                 :            :         If a constant with this name already existed before, its value is changed, and the old constant is
     197                 :            :         returned. If it does not yet exist, it is newly created, and inserted into the basic library.
     198                 :            :     */
     199                 :            :     ::com::sun::star::uno::Any
     200                 :            :                     SetGlobalUNOConstant( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rValue );
     201                 :            : 
     202                 :            :     /** retrieves a global constant in the basic library, referring to some UNO object, returns true if a value is found ( value is in aOut ) false otherwise. */
     203                 :            :                     bool GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut );
     204                 :            :     /** determines whether there are password-protected modules whose size exceedes the
     205                 :            :         legacy module size
     206                 :            :         @param _out_rModuleNames
     207                 :            :             takes the names of modules whose size exceeds the legacy limit
     208                 :            :     */
     209                 :            :     bool            LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< rtl::OUString >& _out_rModuleNames );
     210                 :            :     bool HasExeCode( const String& );
     211                 :            :     /// determines whether the Basic Manager has a given macro, given by fully qualified name
     212                 :            :     bool            HasMacro( String const& i_fullyQualifiedName ) const;
     213                 :            :     /// executes a given macro
     214                 :            :     ErrCode         ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue );
     215                 :            :     /// executes a given macro
     216                 :            :     ErrCode         ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue );
     217                 :            : 
     218                 :            : private:
     219                 :            :     BASIC_DLLPRIVATE sal_Bool IsReference( sal_uInt16 nLib );
     220                 :            : 
     221                 :            :     BASIC_DLLPRIVATE sal_Bool SetLibName( sal_uInt16 nLib, const String& rName );
     222                 :            : 
     223                 :            :     BASIC_DLLPRIVATE StarBASIC* GetStdLib() const;
     224                 :            :     BASIC_DLLPRIVATE StarBASIC* AddLib( SotStorage& rStorage, const String& rLibName, sal_Bool bReference );
     225                 :            :     BASIC_DLLPRIVATE sal_Bool RemoveLib( sal_uInt16 nLib );
     226                 :            :     BASIC_DLLPRIVATE sal_Bool HasLib( const String& rName ) const;
     227                 :            : 
     228                 :            :     BASIC_DLLPRIVATE StarBASIC* CreateLibForLibContainer( const String& rLibName,
     229                 :            :                         const com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >&
     230                 :            :                             xScriptCont );
     231                 :            :     // For XML import/export:
     232                 :            :     BASIC_DLLPRIVATE StarBASIC* CreateLib( const String& rLibName );
     233                 :            :     BASIC_DLLPRIVATE StarBASIC* CreateLib( const String& rLibName, const String& Password,
     234                 :            :                                const String& LinkTargetURL );
     235                 :            : };
     236                 :            : 
     237                 :            : #endif  //_BASMGR_HXX
     238                 :            : 
     239                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10