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

Generated by: LCOV version 1.11