bump product version to 4.1.6.2
[LibreOffice.git] / include / svl / macitem.hxx
blob9d73f6a3ded3784fa959763aef98bce2559133a7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFXMACITEM_HXX
20 #define _SFXMACITEM_HXX
22 // class SvxMacroItem ----------------------------------------------------
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>
31 class SvStream;
33 #define SVX_MACRO_LANGUAGE_JAVASCRIPT "JavaScript"
34 #define SVX_MACRO_LANGUAGE_STARBASIC "StarBasic"
35 #define SVX_MACRO_LANGUAGE_SF "Script"
37 DBG_NAMEEX(SvxMacroItem)
39 // -----------------------------------------------------------------------
41 //Ein Macro
43 enum ScriptType
45 STARBASIC,
46 JAVASCRIPT,
47 EXTENDED_STYPE
50 // Basisklasse fuer SjJSbxObject mit virtuellem Destruktor
51 class SjJSbxObjectBase
53 public:
54 virtual ~SjJSbxObjectBase();
55 virtual SjJSbxObjectBase* Clone( void );
56 //virtual SjJSbxObjectBase& operator=( const SjJSbxObjectBase& rBase );
59 class SjJSbxObject;
61 class SVL_DLLPUBLIC SvxMacro
63 OUString aMacName;
64 OUString aLibName;
65 // Fuer JavaScript muss ein Function-Objekt gehalten werden
66 SjJSbxObjectBase* pFunctionObject;
67 ScriptType eType;
69 public:
71 SvxMacro( const OUString &rMacName, const OUString &rLanguage);
73 SvxMacro( const OUString &rMacName, const OUString &rLibName,
74 ScriptType eType); // = STARBASIC entfernt
76 SvxMacro( SjJSbxObjectBase* _pFunctionObject, const OUString &rSource );
77 ~SvxMacro(); // noetig fuer pFunctionObject
79 const OUString &GetLibName() const { return aLibName; }
80 const OUString &GetMacName() const { return aMacName; }
81 OUString GetLanguage()const;
83 ScriptType GetScriptType() const { return eType; }
85 bool HasMacro() const { return !aMacName.isEmpty(); }
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
93 SvxMacro& operator=( const SvxMacro& rBase );
96 inline SvxMacro::SvxMacro( const OUString &rMacName, const OUString &rLibName,
97 ScriptType eTyp )
98 : aMacName( rMacName ), aLibName( rLibName ), pFunctionObject(NULL), eType( eTyp )
101 inline SvxMacro::SvxMacro( SjJSbxObjectBase* _pFunctionObject, const OUString &rSource )
102 : aMacName( rSource ), pFunctionObject( _pFunctionObject ), eType( JAVASCRIPT )
105 //Macro Table, zerstoert die Pointer im DTor!
107 typedef std::map<sal_uInt16, SvxMacro> SvxMacroTable;
109 #define SVX_MACROTBL_VERSION31 0
110 #define SVX_MACROTBL_VERSION40 1
112 #define SVX_MACROTBL_AKTVERSION SVX_MACROTBL_VERSION40
114 class SVL_DLLPUBLIC SvxMacroTableDtor
116 private:
117 SvxMacroTable aSvxMacroTable;
118 public:
119 inline SvxMacroTableDtor() {}
120 inline SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : aSvxMacroTable(rCpy.aSvxMacroTable) { }
122 SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy );
123 int operator==( const SvxMacroTableDtor& rOther ) const;
125 // loescht alle Eintraege
126 void clear() { aSvxMacroTable.clear(); }
128 SvStream& Read( SvStream &, sal_uInt16 nVersion = SVX_MACROTBL_AKTVERSION );
129 SvStream& Write( SvStream & ) const;
131 sal_uInt16 GetVersion() const { return SVX_MACROTBL_AKTVERSION; }
133 SvxMacroTable::iterator begin() { return aSvxMacroTable.begin(); }
134 SvxMacroTable::const_iterator begin() const { return aSvxMacroTable.begin(); }
135 SvxMacroTable::iterator end() { return aSvxMacroTable.end(); }
136 SvxMacroTable::const_iterator end () const { return aSvxMacroTable.end(); }
137 SvxMacroTable::size_type size() const { return aSvxMacroTable.size(); }
138 bool empty() const { return aSvxMacroTable.empty(); }
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);
154 [Beschreibung]
155 Dieses Item beschreibt eine Makro-Tabelle.
158 class SVL_DLLPUBLIC SvxMacroItem: public SfxPoolItem
160 public:
161 TYPEINFO();
163 explicit inline SvxMacroItem ( const sal_uInt16 nId /*= ITEMID_MACRO*/ );
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 OUString &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;
177 inline const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;}
178 inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; }
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 );
185 private:
186 SvxMacroTableDtor aMacroTable;
188 inline SvxMacroItem( const SvxMacroItem& );
189 SvxMacroItem &operator=( const SvxMacroItem & );
192 inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId )
193 : SfxPoolItem( nId )
195 inline SvxMacroItem::SvxMacroItem( const SvxMacroItem &rCpy )
196 : SfxPoolItem( rCpy ),
197 aMacroTable( rCpy.GetMacroTable() )
200 inline sal_Bool SvxMacroItem::HasMacro( sal_uInt16 nEvent ) const
202 return aMacroTable.IsKeyValid( nEvent );
204 inline const SvxMacro& SvxMacroItem::GetMacro( sal_uInt16 nEvent ) const
206 return *(aMacroTable.Get(nEvent));
208 inline sal_Bool SvxMacroItem::DelMacro( sal_uInt16 nEvent )
210 return aMacroTable.Erase(nEvent);
213 #endif
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */