LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/svl - macitem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 29 44.8 %
Date: 2012-08-25 Functions: 10 22 45.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.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 _SFXMACITEM_HXX
      20                 :            : #define _SFXMACITEM_HXX
      21                 :            : 
      22                 :            : // class SvxMacroItem ----------------------------------------------------
      23                 :            : 
      24                 :            : #include "svl/svldllapi.h"
      25                 :            : #include <svl/poolitem.hxx>
      26                 :            : #include <tools/rtti.hxx>
      27                 :            : #include <tools/debug.hxx>
      28                 :            : #include <tools/string.hxx>
      29                 :            : #include <map>
      30                 :            : 
      31                 :            : class SvStream;
      32                 :            : 
      33                 :            : #define SVX_MACRO_LANGUAGE_JAVASCRIPT "JavaScript"
      34                 :            : #define SVX_MACRO_LANGUAGE_STARBASIC "StarBasic"
      35                 :            : #define SVX_MACRO_LANGUAGE_SF "Script"
      36                 :            : 
      37                 :            : DBG_NAMEEX(SvxMacroItem)
      38                 :            : 
      39                 :            : // -----------------------------------------------------------------------
      40                 :            : 
      41                 :            : //Ein Macro
      42                 :            : 
      43                 :            : enum ScriptType
      44                 :            : {
      45                 :            :     STARBASIC,
      46                 :            :     JAVASCRIPT,
      47                 :            :     EXTENDED_STYPE
      48                 :            : };
      49                 :            : 
      50                 :            : // Basisklasse fuer SjJSbxObject mit virtuellem Destruktor
      51                 :            : class SjJSbxObjectBase
      52                 :            : {
      53                 :            : public:
      54                 :            :     virtual ~SjJSbxObjectBase();
      55                 :            :     virtual SjJSbxObjectBase* Clone( void );
      56                 :            :     //virtual SjJSbxObjectBase& operator=( const SjJSbxObjectBase& rBase );
      57                 :            : };
      58                 :            : 
      59                 :            : class SjJSbxObject;
      60                 :            : 
      61                 :          0 : class SVL_DLLPUBLIC SvxMacro
      62                 :            : {
      63                 :            :     ::rtl::OUString aMacName;
      64                 :            :     ::rtl::OUString aLibName;
      65                 :            :     // Fuer JavaScript muss ein Function-Objekt gehalten werden
      66                 :            :     SjJSbxObjectBase* pFunctionObject;
      67                 :            :     ScriptType eType;
      68                 :            : 
      69                 :            : public:
      70                 :            : 
      71                 :            :     SvxMacro( const ::rtl::OUString &rMacName, const ::rtl::OUString &rLanguage);
      72                 :            : 
      73                 :            :     SvxMacro( const ::rtl::OUString &rMacName, const ::rtl::OUString &rLibName,
      74                 :            :                 ScriptType eType); //  = STARBASIC entfernt
      75                 :            : 
      76                 :            :     SvxMacro( SjJSbxObjectBase* _pFunctionObject, const ::rtl::OUString &rSource );
      77                 :            :     ~SvxMacro();    // noetig fuer pFunctionObject
      78                 :            : 
      79                 :          0 :     const ::rtl::OUString &GetLibName() const        { return aLibName; }
      80                 :          0 :     const ::rtl::OUString &GetMacName() const        { return aMacName; }
      81                 :            :     ::rtl::OUString GetLanguage()const;
      82                 :            : 
      83                 :          0 :     ScriptType GetScriptType() const        { return eType; }
      84                 :            : 
      85                 :          8 :     bool HasMacro() const { return !aMacName.isEmpty(); }
      86                 :            : 
      87                 :            : #ifdef SOLAR_JAVA
      88                 :            :     // JavaScript-Function-Objekt holen
      89                 :            :     // ACHTUNG: Implementation in SJ, Source/JScript/sjimpl.cxx
      90                 :            :     SjJSbxObjectBase* GetFunctionObject( SjJSbxObject* pParent );
      91                 :            : #endif
      92                 :            : 
      93                 :            :     SvxMacro& operator=( const SvxMacro& rBase );
      94                 :            : };
      95                 :            : 
      96                 :          0 : inline SvxMacro::SvxMacro( const ::rtl::OUString &rMacName, const ::rtl::OUString &rLibName,
      97                 :            :                             ScriptType eTyp )
      98                 :          0 :     : aMacName( rMacName ), aLibName( rLibName ), pFunctionObject(NULL), eType( eTyp )
      99                 :          0 : {}
     100                 :            : 
     101                 :            : inline SvxMacro::SvxMacro( SjJSbxObjectBase* _pFunctionObject, const ::rtl::OUString &rSource )
     102                 :            :     : aMacName( rSource ), pFunctionObject( _pFunctionObject ), eType( JAVASCRIPT )
     103                 :            : {}
     104                 :            : 
     105                 :            : //Macro Table, zerstoert die Pointer im DTor!
     106                 :            : 
     107                 :            : typedef std::map<sal_uInt16, SvxMacro> SvxMacroTable;
     108                 :            : 
     109                 :            : #define SVX_MACROTBL_VERSION31  0
     110                 :            : #define SVX_MACROTBL_VERSION40  1
     111                 :            : 
     112                 :            : #define SVX_MACROTBL_AKTVERSION SVX_MACROTBL_VERSION40
     113                 :            : 
     114                 :       1640 : class SVL_DLLPUBLIC SvxMacroTableDtor
     115                 :            : {
     116                 :            : private:
     117                 :            :     SvxMacroTable aSvxMacroTable;
     118                 :            : public:
     119                 :       1703 :     inline SvxMacroTableDtor() {}
     120                 :          8 :     inline SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : aSvxMacroTable(rCpy.aSvxMacroTable) { }
     121                 :            : 
     122                 :            :     SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy );
     123                 :            :     int operator==( const SvxMacroTableDtor& rOther ) const;
     124                 :            : 
     125                 :            :     // loescht alle Eintraege
     126                 :            :     void clear() { aSvxMacroTable.clear(); }
     127                 :            : 
     128                 :            :     SvStream&   Read( SvStream &, sal_uInt16 nVersion = SVX_MACROTBL_AKTVERSION );
     129                 :            :     SvStream&   Write( SvStream & ) const;
     130                 :            : 
     131                 :          0 :     sal_uInt16 GetVersion() const       { return SVX_MACROTBL_AKTVERSION; }
     132                 :            : 
     133                 :          0 :     SvxMacroTable::iterator begin() { return aSvxMacroTable.begin(); }
     134                 :            :     SvxMacroTable::const_iterator begin() const { return aSvxMacroTable.begin(); }
     135                 :          0 :     SvxMacroTable::iterator end() { return aSvxMacroTable.end(); }
     136                 :            :     SvxMacroTable::const_iterator end () const { return aSvxMacroTable.end(); }
     137                 :          0 :     SvxMacroTable::size_type size() const { return aSvxMacroTable.size(); }
     138                 :          2 :     bool empty() const { return aSvxMacroTable.empty(); }
     139                 :            : 
     140                 :            :     // returns NULL if no entry exists, or a pointer to the internal value
     141                 :            :     const SvxMacro* Get(sal_uInt16 nEvent) const;
     142                 :            :     // returns NULL if no entry exists, or a pointer to the internal value
     143                 :            :     SvxMacro* Get(sal_uInt16 nEvent);
     144                 :            :     // return true if the key exists
     145                 :            :     bool IsKeyValid(sal_uInt16 nEvent) const;
     146                 :            :     // This stores a copy of the rMacro parameter
     147                 :            :     SvxMacro& Insert(sal_uInt16 nEvent, const SvxMacro& rMacro);
     148                 :            :     // If the entry exists, remove it from the map and release it's storage
     149                 :            :     sal_Bool Erase(sal_uInt16 nEvent);
     150                 :            : };
     151                 :            : 
     152                 :            : 
     153                 :            : /*
     154                 :            : [Beschreibung]
     155                 :            : Dieses Item beschreibt eine Makro-Tabelle.
     156                 :            : */
     157                 :            : 
     158         [ -  + ]:        267 : class SVL_DLLPUBLIC SvxMacroItem: public SfxPoolItem
     159                 :            : {
     160                 :            : public:
     161                 :            :     TYPEINFO();
     162                 :            : 
     163                 :            :     inline SvxMacroItem ( const sal_uInt16 nId /*= ITEMID_MACRO*/ );
     164                 :            : 
     165                 :            :     // "pure virtual Methoden" vom SfxPoolItem
     166                 :            :     virtual int             operator==( const SfxPoolItem& ) const;
     167                 :            :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
     168                 :            :                                     SfxMapUnit eCoreMetric,
     169                 :            :                                     SfxMapUnit ePresMetric,
     170                 :            :                                     XubString &rText,
     171                 :            :                                     const IntlWrapper * = 0 ) const;
     172                 :            :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
     173                 :            :     virtual SfxPoolItem*    Create(SvStream &, sal_uInt16) const;
     174                 :            :     virtual SvStream&       Store(SvStream &, sal_uInt16 nItemVersion ) const;
     175                 :            :     virtual sal_uInt16          GetVersion( sal_uInt16 nFileFormatVersion ) const;
     176                 :            : 
     177                 :         14 :     inline const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;}
     178                 :          0 :     inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; }
     179                 :            : 
     180                 :            :     inline const SvxMacro& GetMacro( sal_uInt16 nEvent ) const;
     181                 :            :     inline sal_Bool HasMacro( sal_uInt16 nEvent ) const;
     182                 :            :            void SetMacro( sal_uInt16 nEvent, const SvxMacro& );
     183                 :            :     inline sal_Bool DelMacro( sal_uInt16 nEvent );
     184                 :            : 
     185                 :            : private:
     186                 :            :     SvxMacroTableDtor aMacroTable;
     187                 :            : 
     188                 :            :     inline SvxMacroItem( const SvxMacroItem& );
     189                 :            :     SvxMacroItem &operator=( const SvxMacroItem & );
     190                 :            : };
     191                 :            : 
     192                 :        146 : inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId )
     193         [ +  - ]:        146 :     : SfxPoolItem( nId )
     194                 :        146 : {}
     195                 :          2 : inline SvxMacroItem::SvxMacroItem( const SvxMacroItem &rCpy )
     196                 :            :     : SfxPoolItem( rCpy ),
     197         [ +  - ]:          2 :     aMacroTable( rCpy.GetMacroTable() )
     198                 :          2 : {}
     199                 :            : 
     200                 :          0 : inline sal_Bool SvxMacroItem::HasMacro( sal_uInt16 nEvent ) const
     201                 :            : {
     202                 :          0 :     return aMacroTable.IsKeyValid( nEvent );
     203                 :            : }
     204                 :          0 : inline const SvxMacro& SvxMacroItem::GetMacro( sal_uInt16 nEvent ) const
     205                 :            : {
     206                 :          0 :     return *(aMacroTable.Get(nEvent));
     207                 :            : }
     208                 :            : inline sal_Bool SvxMacroItem::DelMacro( sal_uInt16 nEvent )
     209                 :            : {
     210                 :            :     return aMacroTable.Erase(nEvent);
     211                 :            : }
     212                 :            : 
     213                 :            : #endif
     214                 :            : 
     215                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10