bump product version to 5.0.4.1
[LibreOffice.git] / starmath / inc / symbol.hxx
blobc05ea47f1f1627283c9af5c06f42a21efa34b26f
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 .
20 #ifndef INCLUDED_STARMATH_INC_SYMBOL_HXX
21 #define INCLUDED_STARMATH_INC_SYMBOL_HXX
23 #include <vcl/font.hxx>
24 #include <svl/lstner.hxx>
26 #include <map>
27 #include <vector>
28 #include <set>
29 #include <functional>
30 #include <algorithm>
32 #include "unomodel.hxx"
33 #include "utility.hxx"
34 #include "smmod.hxx"
37 #define SYMBOL_NONE 0xFFFF
42 inline const OUString GetExportSymbolName( const OUString &rUiSymbolName )
44 return SmLocalizedSymbolData::GetExportSymbolName( rUiSymbolName );
48 inline const OUString GetUiSymbolName( const OUString &rExportSymbolName )
50 return SmLocalizedSymbolData::GetUiSymbolName( rExportSymbolName );
53 inline const OUString GetExportSymbolSetName( const OUString &rUiSymbolSetName )
55 return SmLocalizedSymbolData::GetExportSymbolSetName( rUiSymbolSetName );
59 inline const OUString GetUiSymbolSetName( const OUString &rExportSymbolSetName )
61 return SmLocalizedSymbolData::GetUiSymbolSetName( rExportSymbolSetName );
66 class SmSym
68 private:
69 SmFace m_aFace;
70 OUString m_aName;
71 OUString m_aExportName;
72 OUString m_aSetName;
73 sal_UCS4 m_cChar;
74 bool m_bPredefined;
75 bool m_bDocSymbol;
77 public:
78 SmSym();
79 SmSym(const OUString& rName, const vcl::Font& rFont, sal_UCS4 cChar,
80 const OUString& rSet, bool bIsPredefined = false);
81 SmSym(const SmSym& rSymbol);
83 SmSym& operator = (const SmSym& rSymbol);
85 const vcl::Font& GetFace() const { return m_aFace; }
86 sal_UCS4 GetCharacter() const { return m_cChar; }
87 const OUString& GetName() const { return m_aName; }
89 void SetFace( const vcl::Font& rFont ) { m_aFace = rFont; }
90 void SetCharacter( sal_UCS4 cChar ) { m_cChar = cChar; }
92 bool IsPredefined() const { return m_bPredefined; }
93 const OUString& GetSymbolSetName() const { return m_aSetName; }
94 void SetSymbolSetName( const OUString &rName ) { m_aSetName = rName; }
95 const OUString& GetExportName() const { return m_aExportName; }
96 void SetExportName( const OUString &rName ) { m_aExportName = rName; }
98 bool IsDocSymbol() const { return m_bDocSymbol; }
99 void SetDocSymbol( bool bVal ) { m_bDocSymbol = bVal; }
101 // true if rSymbol has the same name, font and character
102 bool IsEqualInUI( const SmSym& rSymbol ) const;
105 // type of the actual container to hold the symbols
106 typedef std::map< OUString, SmSym > SymbolMap_t;
108 // vector of pointers to the actual symbols in the above container
109 typedef std::vector< const SmSym * > SymbolPtrVec_t;
111 struct lt_SmSymPtr : public std::binary_function< const SmSym *, const SmSym *, bool >
113 bool operator() ( const SmSym *pSym1, const SmSym *pSym2 ) const
115 return pSym1->GetCharacter() < pSym2->GetCharacter();
120 class SmSymbolManager : public SfxListener
122 private:
123 SymbolMap_t m_aSymbols;
124 bool m_bModified;
126 virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
127 const SfxHint& rHint, const TypeId& rHintType) SAL_OVERRIDE;
129 public:
130 SmSymbolManager();
131 SmSymbolManager(const SmSymbolManager& rSymbolSetManager);
132 virtual ~SmSymbolManager();
134 SmSymbolManager & operator = (const SmSymbolManager& rSymbolSetManager);
136 // symbol sets are for UI purpose only, thus we assemble them here
137 std::set< OUString > GetSymbolSetNames() const;
138 const SymbolPtrVec_t GetSymbolSet( const OUString& rSymbolSetName );
140 const SymbolPtrVec_t GetSymbols() const;
141 bool AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false );
142 void RemoveSymbol( const OUString & rSymbolName );
144 SmSym * GetSymbolByName(const OUString& rSymbolName);
145 const SmSym * GetSymbolByName(const OUString& rSymbolName) const
147 return const_cast<SmSymbolManager *>(this)->GetSymbolByName(rSymbolName);
150 bool IsModified() const { return m_bModified; }
151 void SetModified(bool bModify) { m_bModified = bModify; }
153 void Load();
154 void Save();
157 #endif
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */