LCOV - code coverage report
Current view: top level - include/svl - macitem.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 16 29 55.2 %
Date: 2014-04-11 Functions: 12 23 52.2 %
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_SVL_MACITEM_HXX
      20             : #define INCLUDED_SVL_MACITEM_HXX
      21             : 
      22             : // class SvxMacroItem ----------------------------------------------------
      23             : 
      24             : #include <rtl/ustring.hxx>
      25             : #include <svl/svldllapi.h>
      26             : #include <svl/poolitem.hxx>
      27             : #include <tools/rtti.hxx>
      28             : #include <tools/debug.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             : enum ScriptType
      38             : {
      39             :     STARBASIC,
      40             :     JAVASCRIPT,
      41             :     EXTENDED_STYPE
      42             : };
      43             : 
      44         436 : class SVL_DLLPUBLIC SvxMacro
      45             : {
      46             :     OUString aMacName;
      47             :     OUString aLibName;
      48             :     ScriptType eType;
      49             : 
      50             : public:
      51             : 
      52             :     SvxMacro( const OUString &rMacName, const OUString &rLanguage);
      53             : 
      54             :     SvxMacro( const OUString &rMacName, const OUString &rLibName,
      55             :                 ScriptType eType); //  = STARBASIC entfernt
      56             : 
      57           0 :     const OUString &GetLibName() const        { return aLibName; }
      58           0 :     const OUString &GetMacName() const        { return aMacName; }
      59             :     OUString GetLanguage()const;
      60             : 
      61           0 :     ScriptType GetScriptType() const        { return eType; }
      62             : 
      63         220 :     bool HasMacro() const { return !aMacName.isEmpty(); }
      64             : 
      65             :     SvxMacro& operator=( const SvxMacro& rBase );
      66             : };
      67             : 
      68           0 : inline SvxMacro::SvxMacro( const OUString &rMacName, const OUString &rLibName,
      69             :                             ScriptType eTyp )
      70           0 :     : aMacName( rMacName ), aLibName( rLibName ), eType( eTyp )
      71           0 : {}
      72             : 
      73             : //Macro Table, zerstoert die Pointer im DTor!
      74             : 
      75             : typedef std::map<sal_uInt16, SvxMacro> SvxMacroTable;
      76             : 
      77             : #define SVX_MACROTBL_VERSION31  0
      78             : #define SVX_MACROTBL_VERSION40  1
      79             : 
      80             : #define SVX_MACROTBL_AKTVERSION SVX_MACROTBL_VERSION40
      81             : 
      82          95 : class SVL_DLLPUBLIC SvxMacroTableDtor
      83             : {
      84             : private:
      85             :     SvxMacroTable aSvxMacroTable;
      86             : public:
      87          91 :     inline SvxMacroTableDtor() {}
      88           4 :     inline SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : aSvxMacroTable(rCpy.aSvxMacroTable) { }
      89             : 
      90             :     SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy );
      91             :     int operator==( const SvxMacroTableDtor& rOther ) const;
      92             : 
      93             :     // loescht alle Eintraege
      94             :     void clear() { aSvxMacroTable.clear(); }
      95             : 
      96             :     SvStream&   Read( SvStream &, sal_uInt16 nVersion = SVX_MACROTBL_AKTVERSION );
      97             :     SvStream&   Write( SvStream & ) const;
      98             : 
      99           0 :     sal_uInt16 GetVersion() const       { return SVX_MACROTBL_AKTVERSION; }
     100             : 
     101           0 :     SvxMacroTable::iterator begin() { return aSvxMacroTable.begin(); }
     102             :     SvxMacroTable::const_iterator begin() const { return aSvxMacroTable.begin(); }
     103           0 :     SvxMacroTable::iterator end() { return aSvxMacroTable.end(); }
     104             :     SvxMacroTable::const_iterator end () const { return aSvxMacroTable.end(); }
     105           0 :     SvxMacroTable::size_type size() const { return aSvxMacroTable.size(); }
     106          13 :     bool empty() const { return aSvxMacroTable.empty(); }
     107             : 
     108             :     // returns NULL if no entry exists, or a pointer to the internal value
     109             :     const SvxMacro* Get(sal_uInt16 nEvent) const;
     110             :     // returns NULL if no entry exists, or a pointer to the internal value
     111             :     SvxMacro* Get(sal_uInt16 nEvent);
     112             :     // return true if the key exists
     113             :     bool IsKeyValid(sal_uInt16 nEvent) const;
     114             :     // This stores a copy of the rMacro parameter
     115             :     SvxMacro& Insert(sal_uInt16 nEvent, const SvxMacro& rMacro);
     116             :     // If the entry exists, remove it from the map and release it's storage
     117             :     bool Erase(sal_uInt16 nEvent);
     118             : };
     119             : 
     120             : 
     121             : /*
     122             : [Beschreibung]
     123             : Dieses Item beschreibt eine Makro-Tabelle.
     124             : */
     125             : 
     126         114 : class SVL_DLLPUBLIC SvxMacroItem: public SfxPoolItem
     127             : {
     128             : public:
     129             :     TYPEINFO_OVERRIDE();
     130             : 
     131             :     explicit inline SvxMacroItem ( const sal_uInt16 nId );
     132             : 
     133             :     // "pure virtual Methoden" vom SfxPoolItem
     134             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     135             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
     136             :                                     SfxMapUnit eCoreMetric,
     137             :                                     SfxMapUnit ePresMetric,
     138             :                                     OUString &rText,
     139             :                                     const IntlWrapper * = 0 ) const SAL_OVERRIDE;
     140             :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
     141             :     virtual SfxPoolItem*    Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
     142             :     virtual SvStream&       Store(SvStream &, sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
     143             :     virtual sal_uInt16          GetVersion( sal_uInt16 nFileFormatVersion ) const SAL_OVERRIDE;
     144             : 
     145           8 :     inline const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;}
     146           0 :     inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; }
     147             : 
     148             :     inline const SvxMacro& GetMacro( sal_uInt16 nEvent ) const;
     149             :     inline bool HasMacro( sal_uInt16 nEvent ) const;
     150             :            void SetMacro( sal_uInt16 nEvent, const SvxMacro& );
     151             :     inline bool DelMacro( sal_uInt16 nEvent );
     152             : 
     153             : private:
     154             :     SvxMacroTableDtor aMacroTable;
     155             : 
     156             :     inline SvxMacroItem( const SvxMacroItem& );
     157             :     SvxMacroItem &operator=( const SvxMacroItem & );
     158             : };
     159             : 
     160          75 : inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId )
     161          75 :     : SfxPoolItem( nId )
     162          75 : {}
     163           1 : inline SvxMacroItem::SvxMacroItem( const SvxMacroItem &rCpy )
     164             :     : SfxPoolItem( rCpy ),
     165           1 :     aMacroTable( rCpy.GetMacroTable() )
     166           1 : {}
     167             : 
     168         216 : inline bool SvxMacroItem::HasMacro( sal_uInt16 nEvent ) const
     169             : {
     170         216 :     return aMacroTable.IsKeyValid( nEvent );
     171             : }
     172           0 : inline const SvxMacro& SvxMacroItem::GetMacro( sal_uInt16 nEvent ) const
     173             : {
     174           0 :     return *(aMacroTable.Get(nEvent));
     175             : }
     176             : inline bool SvxMacroItem::DelMacro( sal_uInt16 nEvent )
     177             : {
     178             :     return aMacroTable.Erase(nEvent);
     179             : }
     180             : 
     181             : #endif
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10