1*39a19a47SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*39a19a47SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*39a19a47SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*39a19a47SAndrew Rist * distributed with this work for additional information
6*39a19a47SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*39a19a47SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*39a19a47SAndrew Rist * "License"); you may not use this file except in compliance
9*39a19a47SAndrew Rist * with the License. You may obtain a copy of the License at
10*39a19a47SAndrew Rist *
11*39a19a47SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*39a19a47SAndrew Rist *
13*39a19a47SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*39a19a47SAndrew Rist * software distributed under the License is distributed on an
15*39a19a47SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*39a19a47SAndrew Rist * KIND, either express or implied. See the License for the
17*39a19a47SAndrew Rist * specific language governing permissions and limitations
18*39a19a47SAndrew Rist * under the License.
19*39a19a47SAndrew Rist *
20*39a19a47SAndrew Rist *************************************************************/
21*39a19a47SAndrew Rist
22*39a19a47SAndrew Rist
23cdf0e10cSrcweir #ifndef _SFXMACITEM_HXX
24cdf0e10cSrcweir #define _SFXMACITEM_HXX
25cdf0e10cSrcweir
26cdf0e10cSrcweir // class SvxMacroItem ----------------------------------------------------
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "svl/svldllapi.h"
29cdf0e10cSrcweir #include <svl/poolitem.hxx>
30cdf0e10cSrcweir #include <tools/rtti.hxx>
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #include <tools/string.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #ifndef _TABLE_HXX
35cdf0e10cSrcweir #include <tools/table.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir
38cdf0e10cSrcweir class SvStream;
39cdf0e10cSrcweir
40cdf0e10cSrcweir #define SVX_MACRO_LANGUAGE_JAVASCRIPT "JavaScript"
41cdf0e10cSrcweir #define SVX_MACRO_LANGUAGE_STARBASIC "StarBasic"
42cdf0e10cSrcweir #define SVX_MACRO_LANGUAGE_SF "Script"
43cdf0e10cSrcweir
44cdf0e10cSrcweir DBG_NAMEEX(SvxMacroItem)
45cdf0e10cSrcweir
46cdf0e10cSrcweir // -----------------------------------------------------------------------
47cdf0e10cSrcweir
48cdf0e10cSrcweir //Ein Macro
49cdf0e10cSrcweir
50cdf0e10cSrcweir enum ScriptType
51cdf0e10cSrcweir {
52cdf0e10cSrcweir STARBASIC,
53cdf0e10cSrcweir JAVASCRIPT,
54cdf0e10cSrcweir EXTENDED_STYPE
55cdf0e10cSrcweir };
56cdf0e10cSrcweir
57cdf0e10cSrcweir // Basisklasse fuer SjJSbxObject mit virtuellem Destruktor
58cdf0e10cSrcweir class SjJSbxObjectBase
59cdf0e10cSrcweir {
60cdf0e10cSrcweir public:
61cdf0e10cSrcweir virtual ~SjJSbxObjectBase();
62cdf0e10cSrcweir virtual SjJSbxObjectBase* Clone( void );
63cdf0e10cSrcweir //virtual SjJSbxObjectBase& operator=( const SjJSbxObjectBase& rBase );
64cdf0e10cSrcweir };
65cdf0e10cSrcweir
66cdf0e10cSrcweir class SjJSbxObject;
67cdf0e10cSrcweir
68cdf0e10cSrcweir class SVL_DLLPUBLIC SvxMacro
69cdf0e10cSrcweir {
70cdf0e10cSrcweir String aMacName;
71cdf0e10cSrcweir String aLibName;
72cdf0e10cSrcweir // Fuer JavaScript muss ein Function-Objekt gehalten werden
73cdf0e10cSrcweir SjJSbxObjectBase* pFunctionObject;
74cdf0e10cSrcweir ScriptType eType;
75cdf0e10cSrcweir
76cdf0e10cSrcweir public:
77cdf0e10cSrcweir
78cdf0e10cSrcweir SvxMacro( const String &rMacName, const String &rLanguage);
79cdf0e10cSrcweir
80cdf0e10cSrcweir SvxMacro( const String &rMacName, const String &rLibName,
81cdf0e10cSrcweir ScriptType eType); // = STARBASIC entfernt
82cdf0e10cSrcweir
83cdf0e10cSrcweir SvxMacro( SjJSbxObjectBase* _pFunctionObject, const String &rSource );
84cdf0e10cSrcweir ~SvxMacro(); // noetig fuer pFunctionObject
85cdf0e10cSrcweir
GetLibName() const86cdf0e10cSrcweir const String &GetLibName() const { return aLibName; }
GetMacName() const87cdf0e10cSrcweir const String &GetMacName() const { return aMacName; }
88cdf0e10cSrcweir String GetLanguage()const;
89cdf0e10cSrcweir
GetScriptType() const90cdf0e10cSrcweir ScriptType GetScriptType() const { return eType; }
91cdf0e10cSrcweir
HasMacro() const92cdf0e10cSrcweir sal_Bool HasMacro() const { return aMacName.Len() ? sal_True : sal_False; }
93cdf0e10cSrcweir
94cdf0e10cSrcweir #ifdef SOLAR_JAVA
95cdf0e10cSrcweir // JavaScript-Function-Objekt holen
96cdf0e10cSrcweir // ACHTUNG: Implementation in SJ, Source/JScript/sjimpl.cxx
97cdf0e10cSrcweir SjJSbxObjectBase* GetFunctionObject( SjJSbxObject* pParent );
98cdf0e10cSrcweir #endif
99cdf0e10cSrcweir
100cdf0e10cSrcweir SvxMacro& operator=( const SvxMacro& rBase );
101cdf0e10cSrcweir };
102cdf0e10cSrcweir
SvxMacro(const String & rMacName,const String & rLibName,ScriptType eTyp)103cdf0e10cSrcweir inline SvxMacro::SvxMacro( const String &rMacName, const String &rLibName,
104cdf0e10cSrcweir ScriptType eTyp )
105cdf0e10cSrcweir : aMacName( rMacName ), aLibName( rLibName ), pFunctionObject(NULL), eType( eTyp )
106cdf0e10cSrcweir {}
107cdf0e10cSrcweir
SvxMacro(SjJSbxObjectBase * _pFunctionObject,const String & rSource)108cdf0e10cSrcweir inline SvxMacro::SvxMacro( SjJSbxObjectBase* _pFunctionObject, const String &rSource )
109cdf0e10cSrcweir : aMacName( rSource ), pFunctionObject( _pFunctionObject ), eType( JAVASCRIPT )
110cdf0e10cSrcweir {}
111cdf0e10cSrcweir
112cdf0e10cSrcweir //Macro Table, zerstoert die Pointer im DTor!
113cdf0e10cSrcweir
114cdf0e10cSrcweir DECLARE_TABLE( _SvxMacroTableDtor, SvxMacro* )
115cdf0e10cSrcweir
116cdf0e10cSrcweir #define SVX_MACROTBL_VERSION31 0
117cdf0e10cSrcweir #define SVX_MACROTBL_VERSION40 1
118cdf0e10cSrcweir
119cdf0e10cSrcweir #define SVX_MACROTBL_AKTVERSION SVX_MACROTBL_VERSION40
120cdf0e10cSrcweir
121cdf0e10cSrcweir class SVL_DLLPUBLIC SvxMacroTableDtor : public _SvxMacroTableDtor
122cdf0e10cSrcweir {
123cdf0e10cSrcweir public:
124cdf0e10cSrcweir inline SvxMacroTableDtor( const sal_uInt16 nInitSz = 0, const sal_uInt16 nReSz = 1 );
SvxMacroTableDtor(const SvxMacroTableDtor & rCpy)125cdf0e10cSrcweir inline SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : _SvxMacroTableDtor() { *this = rCpy; }
~SvxMacroTableDtor()126cdf0e10cSrcweir inline ~SvxMacroTableDtor() { DelDtor(); }
127cdf0e10cSrcweir SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy );
128cdf0e10cSrcweir
129cdf0e10cSrcweir // loescht alle Eintraege
130cdf0e10cSrcweir void DelDtor();
131cdf0e10cSrcweir
132cdf0e10cSrcweir SvStream& Read( SvStream &, sal_uInt16 nVersion = SVX_MACROTBL_AKTVERSION );
133cdf0e10cSrcweir SvStream& Write( SvStream & ) const;
134cdf0e10cSrcweir
GetVersion() const135cdf0e10cSrcweir sal_uInt16 GetVersion() const { return SVX_MACROTBL_AKTVERSION; }
136cdf0e10cSrcweir };
137cdf0e10cSrcweir
SvxMacroTableDtor(const sal_uInt16 nInitSz,const sal_uInt16 nReSz)138cdf0e10cSrcweir inline SvxMacroTableDtor::SvxMacroTableDtor( const sal_uInt16 nInitSz,
139cdf0e10cSrcweir const sal_uInt16 nReSz)
140cdf0e10cSrcweir : _SvxMacroTableDtor( nInitSz, nReSz )
141cdf0e10cSrcweir {}
142cdf0e10cSrcweir
143cdf0e10cSrcweir /*
144cdf0e10cSrcweir [Beschreibung]
145cdf0e10cSrcweir Dieses Item beschreibt eine Makro-Tabelle.
146cdf0e10cSrcweir */
147cdf0e10cSrcweir
148cdf0e10cSrcweir class SVL_DLLPUBLIC SvxMacroItem: public SfxPoolItem
149cdf0e10cSrcweir {
150cdf0e10cSrcweir public:
151cdf0e10cSrcweir TYPEINFO();
152cdf0e10cSrcweir
153cdf0e10cSrcweir inline SvxMacroItem ( const sal_uInt16 nId /*= ITEMID_MACRO*/ );
154cdf0e10cSrcweir
155cdf0e10cSrcweir // "pure virtual Methoden" vom SfxPoolItem
156cdf0e10cSrcweir virtual int operator==( const SfxPoolItem& ) const;
157cdf0e10cSrcweir virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
158cdf0e10cSrcweir SfxMapUnit eCoreMetric,
159cdf0e10cSrcweir SfxMapUnit ePresMetric,
160cdf0e10cSrcweir XubString &rText,
161cdf0e10cSrcweir const IntlWrapper * = 0 ) const;
162cdf0e10cSrcweir virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
163cdf0e10cSrcweir virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
164cdf0e10cSrcweir virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
165cdf0e10cSrcweir virtual sal_uInt16 GetVersion( sal_uInt16 nFileFormatVersion ) const;
166cdf0e10cSrcweir
GetMacroTable() const167cdf0e10cSrcweir inline const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;}
SetMacroTable(const SvxMacroTableDtor & rTbl)168cdf0e10cSrcweir inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; }
169cdf0e10cSrcweir
170cdf0e10cSrcweir inline const SvxMacro& GetMacro( sal_uInt16 nEvent ) const;
171cdf0e10cSrcweir inline sal_Bool HasMacro( sal_uInt16 nEvent ) const;
172cdf0e10cSrcweir void SetMacro( sal_uInt16 nEvent, const SvxMacro& );
173cdf0e10cSrcweir inline sal_Bool DelMacro( sal_uInt16 nEvent );
174cdf0e10cSrcweir
175cdf0e10cSrcweir private:
176cdf0e10cSrcweir SvxMacroTableDtor aMacroTable;
177cdf0e10cSrcweir
178cdf0e10cSrcweir inline SvxMacroItem( const SvxMacroItem& );
179cdf0e10cSrcweir SvxMacroItem &operator=( const SvxMacroItem & );
180cdf0e10cSrcweir };
181cdf0e10cSrcweir
SvxMacroItem(const sal_uInt16 nId)182cdf0e10cSrcweir inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId )
183cdf0e10cSrcweir : SfxPoolItem( nId )
184cdf0e10cSrcweir {}
SvxMacroItem(const SvxMacroItem & rCpy)185cdf0e10cSrcweir inline SvxMacroItem::SvxMacroItem( const SvxMacroItem &rCpy )
186cdf0e10cSrcweir : SfxPoolItem( rCpy ),
187cdf0e10cSrcweir aMacroTable( rCpy.GetMacroTable() )
188cdf0e10cSrcweir {}
189cdf0e10cSrcweir
HasMacro(sal_uInt16 nEvent) const190cdf0e10cSrcweir inline sal_Bool SvxMacroItem::HasMacro( sal_uInt16 nEvent ) const
191cdf0e10cSrcweir {
192cdf0e10cSrcweir return aMacroTable.IsKeyValid( nEvent );
193cdf0e10cSrcweir }
GetMacro(sal_uInt16 nEvent) const194cdf0e10cSrcweir inline const SvxMacro& SvxMacroItem::GetMacro( sal_uInt16 nEvent ) const
195cdf0e10cSrcweir {
196cdf0e10cSrcweir return *(aMacroTable.Get(nEvent));
197cdf0e10cSrcweir }
DelMacro(sal_uInt16 nEvent)198cdf0e10cSrcweir inline sal_Bool SvxMacroItem::DelMacro( sal_uInt16 nEvent )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir SvxMacro *pMacro = aMacroTable.Remove( nEvent );
201cdf0e10cSrcweir delete pMacro;
202cdf0e10cSrcweir return ( pMacro != 0 );
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir #endif
206