merge the formfield patch from ooo-build
[ooovba.git] / starmath / inc / symbol.hxx
blob2be59e453c7977ba264a938a6d73d87c4ed31898
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: symbol.hxx,v $
10 * $Revision: 1.17 $
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 SYMBOL_HXX
31 #define SYMBOL_HXX
33 #include <vos/refernce.hxx>
34 #ifndef _FONT_HXX //autogen
35 #include <vcl/font.hxx>
36 #endif
37 #include <tools/list.hxx>
38 #include <tools/debug.hxx>
39 #include <tools/dynary.hxx>
40 #include <svtools/lstner.hxx>
41 #include <svtools/svarray.hxx>
42 #include "utility.hxx"
43 #include <smmod.hxx>
45 #define SS_ATTR_ACCESS 0x80
47 #define SYMBOLSET_NONE 0xFFFF
48 #define SYMBOL_NONE 0xFFFF
50 class SmSymSetManager;
52 ////////////////////////////////////////////////////////////////////////////////
54 inline const String GetExportSymbolName( const String &rUiSymbolName )
56 return SM_MOD1()->GetLocSymbolData().GetExportSymbolName( rUiSymbolName );
60 inline const String GetUiSymbolName( const String &rExportSymbolName )
62 return SM_MOD1()->GetLocSymbolData().GetUiSymbolName( rExportSymbolName );
65 inline const String GetExportSymbolSetName( const String &rUiSymbolSetName )
67 return SM_MOD1()->GetLocSymbolData().GetExportSymbolSetName( rUiSymbolSetName );
71 inline const String GetUiSymbolSetName( const String &rExportSymbolSetName )
73 return SM_MOD1()->GetLocSymbolData().GetUiSymbolSetName( rExportSymbolSetName );
76 ////////////////////////////////////////////////////////////////////////////////
78 class SmSym
80 friend class SmSymSetManager;
82 SmFace Face;
83 String Name;
84 String aExportName;
85 String aSetName;
86 SmSym *pHashNext;
87 SmSymSetManager *pSymSetManager;
88 sal_Unicode Character;
89 BYTE Attribut;
90 BOOL bPredefined;
91 BOOL bDocSymbol;
93 public:
94 SmSym();
95 SmSym(const SmSym& rSymbol);
96 SmSym(const String& rName, const Font& rFont, sal_Unicode cChar,
97 const String& rSet, BOOL bIsPredefined = FALSE);
99 SmSym& operator = (const SmSym& rSymbol);
101 const Font& GetFace() const { return Face; }
102 sal_Unicode GetCharacter() const { return Character; }
103 const String& GetName() const { return Name; }
105 void SetFace( const Font& rFont ) { Face = rFont; }
106 void SetCharacter( sal_Unicode cChar ) { Character = cChar; }
107 void SetName( const String &rTxt ) { Name = rTxt; }
109 BOOL IsPredefined() const { return bPredefined; }
110 const String & GetSetName() const { return aSetName; }
111 void SetSetName( const String &rName ) { aSetName = rName; }
112 const String & GetExportName() const { return aExportName; }
113 void SetExportName( const String &rName ) { aExportName = rName; }
115 BOOL IsDocSymbol() const { return bDocSymbol; }
116 void SetDocSymbol( BOOL bVal ) { bDocSymbol = bVal; }
119 DECLARE_LIST(SmListSym, SmSym *)
120 SV_DECL_PTRARR( SymbolArray, SmSym *, 32, 32 )
122 /**************************************************************************/
124 class SmSymSet
126 friend class SmSymSetManager;
128 SmListSym SymbolList;
129 String Name;
130 SmSymSetManager *pSymSetManager;
132 public:
133 SmSymSet();
134 SmSymSet(const SmSymSet& rSymbolSet);
135 SmSymSet(const String& rName);
136 ~SmSymSet();
138 SmSymSet& operator = (const SmSymSet& rSymbolSet);
140 const String& GetName() const { return Name; }
141 USHORT GetCount() const { return (USHORT) SymbolList.Count(); }
143 const SmSym& GetSymbol(USHORT SymbolNo) const
145 DBG_ASSERT(SymbolList.GetObject(SymbolNo), "Symbol nicht vorhanden");
146 return *SymbolList.GetObject(SymbolNo);
149 USHORT AddSymbol(SmSym* pSymbol);
150 void DeleteSymbol(USHORT SymbolNo);
151 SmSym * RemoveSymbol(USHORT SymbolNo);
152 USHORT GetSymbolPos(const String& rName);
155 DECLARE_DYNARRAY(SmArraySymSet, SmSymSet *)
157 /**************************************************************************/
159 class SmSymbolDialog;
162 struct SmSymSetManager_Impl
164 SmArraySymSet SymbolSets;
165 SmSymSetManager & rSymSetMgr;
166 SmSym** HashEntries;
167 USHORT NoSymbolSets;
168 USHORT NoHashEntries;
169 BOOL Modified;
171 SmSymSetManager_Impl( SmSymSetManager &rMgr, USHORT HashTableSize );
172 ~SmSymSetManager_Impl();
174 SmSymSetManager_Impl & operator = ( const SmSymSetManager_Impl &rImpl );
178 class SmSymSetManager : public SfxListener
180 friend struct SmSymSetManager_Impl;
182 SmSymSetManager_Impl *pImpl;
184 virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
185 const SfxHint& rHint, const TypeId& rHintType);
187 UINT32 GetHashIndex(const String& rSymbolName);
188 void EnterHashTable(SmSym& rSymbol);
189 void EnterHashTable(SmSymSet& rSymbolSet);
190 void FillHashTable();
191 void Init();
192 void Exit();
194 public:
195 SmSymSetManager(USHORT HashTableSize = 137);
196 SmSymSetManager(const SmSymSetManager& rSymbolSetManager);
197 ~SmSymSetManager();
199 SmSymSetManager& operator = (const SmSymSetManager& rSymbolSetManager);
201 void GetSymbols( std::vector< SmSym > &rSymbols ) const;
204 USHORT AddSymbolSet(SmSymSet* pSymbolSet);
205 void ChangeSymbolSet(SmSymSet* pSymbolSet);
206 void DeleteSymbolSet(USHORT SymbolSetNo);
207 USHORT GetSymbolSetPos(const String& rSymbolSetName) const;
208 USHORT GetSymbolSetCount() const { return pImpl->NoSymbolSets; }
209 SmSymSet *GetSymbolSet(USHORT SymbolSetNo) const
211 return pImpl->SymbolSets.Get(SymbolSetNo);
214 SmSym * GetSymbolByName(const String& rSymbolName);
215 const SmSym * GetSymbolByName(const String& rSymbolName) const
217 return ((SmSymSetManager *) this)->GetSymbolByName(rSymbolName);
220 void AddReplaceSymbol( const SmSym & rSymbol );
221 USHORT GetSymbolCount() const;
222 const SmSym * GetSymbolByPos( USHORT nPos ) const;
224 BOOL IsModified() const { return pImpl->Modified; }
225 void SetModified(BOOL Modify) { pImpl->Modified = Modify; }
227 void Load();
228 void Save();
231 #endif