Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_svtools / macitem.hxx
bloba930513b9d2bdf5fa612d3e9623bbfeafd6ef257
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: macitem.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFXMACITEM_HXX
31 #define _SFXMACITEM_HXX
33 // class SvxMacroItem ----------------------------------------------------
35 #ifndef INCLUDED_SVTDLLAPI_H
36 #include "bf_svtools/svtdllapi.h"
37 #endif
39 #ifndef _SFXPOOLITEM_HXX
40 #include <bf_svtools/poolitem.hxx>
41 #endif
43 #ifndef _RTTI_HXX
44 #include <tools/rtti.hxx>
45 #endif
47 #ifndef _DEBUG_HXX
48 #include <tools/debug.hxx>
49 #endif
51 #ifndef _STRING_HXX
52 #include <tools/string.hxx>
53 #endif
55 #ifndef _TABLE_HXX
56 #include <tools/table.hxx>
57 #endif
59 class SvStream;
61 namespace binfilter
64 #define SVX_MACRO_LANGUAGE_JAVASCRIPT "JavaScript"
65 #define SVX_MACRO_LANGUAGE_STARBASIC "StarBasic"
66 #define SVX_MACRO_LANGUAGE_SF "Script"
68 DBG_NAMEEX(SvxMacroItem)
70 // -----------------------------------------------------------------------
72 //Ein Macro
74 enum ScriptType
76 STARBASIC,
77 JAVASCRIPT,
78 EXTENDED_STYPE
81 // Basisklasse fuer SjJSbxObject mit virtuellem Destruktor
82 class SjJSbxObjectBase
84 public:
85 virtual ~SjJSbxObjectBase();
86 virtual SjJSbxObjectBase* Clone( void );
87 //virtual SjJSbxObjectBase& operator=( const SjJSbxObjectBase& rBase );
90 class SjJSbxObject;
92 class SvxMacro
94 String aMacName;
95 String aLibName;
96 // Fuer JavaScript muss ein Function-Objekt gehalten werden
97 SjJSbxObjectBase* pFunctionObject;
98 ScriptType eType;
100 public:
102 SvxMacro( const String &rMacName, const String &rLanguage);
104 SvxMacro( const String &rMacName, const String &rLibName,
105 ScriptType eType); // = STARBASIC entfernt
107 SvxMacro( SjJSbxObjectBase* _pFunctionObject, const String &rSource );
108 ~SvxMacro(); // noetig fuer pFunctionObject
110 const String &GetLibName() const { return aLibName; }
111 const String &GetMacName() const { return aMacName; }
113 ScriptType GetScriptType() const { return eType; }
115 BOOL HasMacro() const { return aMacName.Len() ? TRUE : FALSE; }
117 #ifdef SOLAR_JAVA
118 // JavaScript-Function-Objekt holen
119 // ACHTUNG: Implementation in SJ, Source/JScript/sjimpl.cxx
120 SjJSbxObjectBase* GetFunctionObject( SjJSbxObject* pParent );
121 #endif
123 SvxMacro& operator=( const SvxMacro& rBase );
126 inline SvxMacro::SvxMacro( const String &rMacName, const String &rLibName,
127 ScriptType eTyp )
128 : aMacName( rMacName ), aLibName( rLibName ), pFunctionObject(NULL), eType( eTyp )
131 inline SvxMacro::SvxMacro( SjJSbxObjectBase* _pFunctionObject, const String &rSource )
132 : aMacName( rSource ), pFunctionObject( _pFunctionObject ), eType( JAVASCRIPT )
135 //Macro Table, zerstoert die Pointer im DTor!
137 DECLARE_TABLE( _SvxMacroTableDtor, SvxMacro* )
139 #define SVX_MACROTBL_VERSION31 0
140 #define SVX_MACROTBL_VERSION40 1
142 #define SVX_MACROTBL_AKTVERSION SVX_MACROTBL_VERSION40
144 class SvxMacroTableDtor : public _SvxMacroTableDtor
146 public:
147 inline SvxMacroTableDtor( const USHORT nInitSz = 0, const USHORT nReSz = 1 );
148 inline SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : _SvxMacroTableDtor() { *this = rCpy; }
149 inline ~SvxMacroTableDtor() { DelDtor(); }
150 SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy );
152 // loescht alle Eintraege
153 void DelDtor();
155 SvStream& Read( SvStream &, USHORT nVersion = SVX_MACROTBL_AKTVERSION );
156 SvStream& Write( SvStream & ) const;
158 USHORT GetVersion() const { return SVX_MACROTBL_AKTVERSION; }
161 inline SvxMacroTableDtor::SvxMacroTableDtor( const USHORT nInitSz,
162 const USHORT nReSz)
163 : _SvxMacroTableDtor( nInitSz, nReSz )
167 [Beschreibung]
168 Dieses Item beschreibt eine Makro-Tabelle.
171 class SvxMacroItem: public SfxPoolItem
173 public:
174 TYPEINFO();
176 inline SvxMacroItem ( const USHORT nId /*= ITEMID_MACRO*/ );
178 // "pure virtual Methoden" vom SfxPoolItem
179 virtual int operator==( const SfxPoolItem& ) const;
180 virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
181 SfxMapUnit eCoreMetric,
182 SfxMapUnit ePresMetric,
183 XubString &rText,
184 const ::IntlWrapper * = 0 ) const;
185 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
186 virtual SfxPoolItem* Create(SvStream &, USHORT) const;
187 virtual SvStream& Store(SvStream &, USHORT nItemVersion ) const;
188 virtual USHORT GetVersion( USHORT nFileFormatVersion ) const;
190 inline const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;}
191 inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; }
193 inline const SvxMacro& GetMacro( USHORT nEvent ) const;
194 inline BOOL HasMacro( USHORT nEvent ) const;
195 void SetMacro( USHORT nEvent, const SvxMacro& );
196 inline BOOL DelMacro( USHORT nEvent );
198 private:
199 SvxMacroTableDtor aMacroTable;
201 inline SvxMacroItem( const SvxMacroItem& );
202 SvxMacroItem &operator=( const SvxMacroItem & );
205 inline SvxMacroItem::SvxMacroItem( const USHORT nId )
206 : SfxPoolItem( nId )
208 inline SvxMacroItem::SvxMacroItem( const SvxMacroItem &rCpy )
209 : SfxPoolItem( rCpy ),
210 aMacroTable( rCpy.GetMacroTable() )
213 inline BOOL SvxMacroItem::HasMacro( USHORT nEvent ) const
215 return aMacroTable.IsKeyValid( nEvent );
217 inline const SvxMacro& SvxMacroItem::GetMacro( USHORT nEvent ) const
219 return *(aMacroTable.Get(nEvent));
221 inline BOOL SvxMacroItem::DelMacro( USHORT nEvent )
223 SvxMacro *pMacro = aMacroTable.Remove( nEvent );
224 delete pMacro;
225 return ( pMacro != 0 );
230 #endif