Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / starmath / inc / symbol.hxx
blob39ce0be6e38c02191c0c1088cc7645ded33661a1
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 /** This stuff is used to work with %charname.
22 * Will remember the char name, char code and font.
25 #pragma once
27 #include <map>
28 #include <vector>
29 #include <set>
31 #include "utility.hxx"
34 #define SYMBOL_NONE 0xFFFF
36 class SmSym
38 private:
39 SmFace m_aFace;
40 OUString m_aName;
41 OUString m_aExportName;
42 OUString m_aSetName;
43 sal_UCS4 m_cChar;
44 bool m_bPredefined;
46 public:
47 SmSym();
48 SmSym(const OUString& rName, const vcl::Font& rFont, sal_UCS4 cChar,
49 const OUString& rSet, bool bIsPredefined = false);
50 SmSym(const SmSym& rSymbol);
52 SmSym& operator = (const SmSym& rSymbol);
54 const vcl::Font& GetFace() const { return m_aFace; }
55 sal_UCS4 GetCharacter() const { return m_cChar; }
56 const OUString& GetName() const { return m_aName; }
58 bool IsPredefined() const { return m_bPredefined; }
59 const OUString& GetSymbolSetName() const { return m_aSetName; }
60 const OUString& GetExportName() const { return m_aExportName; }
61 void SetExportName( const OUString &rName ) { m_aExportName = rName; }
63 // true if rSymbol has the same name, font and character
64 bool IsEqualInUI( const SmSym& rSymbol ) const;
67 // type of the actual container to hold the symbols
68 typedef std::map< OUString, SmSym > SymbolMap_t;
70 // vector of pointers to the actual symbols in the above container
71 typedef std::vector< const SmSym * > SymbolPtrVec_t;
74 class SmSymbolManager
76 private:
77 SymbolMap_t m_aSymbols;
78 bool m_bModified;
80 public:
81 SmSymbolManager();
82 SmSymbolManager(const SmSymbolManager& rSymbolSetManager);
83 ~SmSymbolManager();
85 SmSymbolManager & operator = (const SmSymbolManager& rSymbolSetManager);
87 // symbol sets are for UI purpose only, thus we assemble them here
88 std::set< OUString > GetSymbolSetNames() const;
89 SymbolPtrVec_t GetSymbolSet( std::u16string_view rSymbolSetName );
91 SymbolPtrVec_t GetSymbols() const;
92 bool AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false );
93 void RemoveSymbol( const OUString & rSymbolName );
95 SmSym * GetSymbolByName(const OUString& rSymbolName);
96 const SmSym * GetSymbolByName(const OUString& rSymbolName) const
98 return const_cast<SmSymbolManager *>(this)->GetSymbolByName(rSymbolName);
101 bool IsModified() const { return m_bModified; }
102 void SetModified(bool bModify) { m_bModified = bModify; }
104 void Load();
105 void Save();
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */