1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: macitem.hxx,v $
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"
39 #ifndef _SFXPOOLITEM_HXX
40 #include <bf_svtools/poolitem.hxx>
44 #include <tools/rtti.hxx>
48 #include <tools/debug.hxx>
52 #include <tools/string.hxx>
56 #include <tools/table.hxx>
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 // -----------------------------------------------------------------------
81 // Basisklasse fuer SjJSbxObject mit virtuellem Destruktor
82 class SjJSbxObjectBase
85 virtual ~SjJSbxObjectBase();
86 virtual SjJSbxObjectBase
* Clone( void );
87 //virtual SjJSbxObjectBase& operator=( const SjJSbxObjectBase& rBase );
96 // Fuer JavaScript muss ein Function-Objekt gehalten werden
97 SjJSbxObjectBase
* pFunctionObject
;
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
; }
118 // JavaScript-Function-Objekt holen
119 // ACHTUNG: Implementation in SJ, Source/JScript/sjimpl.cxx
120 SjJSbxObjectBase
* GetFunctionObject( SjJSbxObject
* pParent
);
123 SvxMacro
& operator=( const SvxMacro
& rBase
);
126 inline SvxMacro::SvxMacro( const String
&rMacName
, const String
&rLibName
,
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
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
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
,
163 : _SvxMacroTableDtor( nInitSz
, nReSz
)
168 Dieses Item beschreibt eine Makro-Tabelle.
171 class SvxMacroItem
: public SfxPoolItem
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
,
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
);
199 SvxMacroTableDtor aMacroTable
;
201 inline SvxMacroItem( const SvxMacroItem
& );
202 SvxMacroItem
&operator=( const SvxMacroItem
& );
205 inline SvxMacroItem::SvxMacroItem( const USHORT 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
);
225 return ( pMacro
!= 0 );