LibreOffice Module starmath (master) 1
symbol.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
25#pragma once
26
27#include <map>
28#include <vector>
29#include <set>
30
31#include "utility.hxx"
32
33
34#define SYMBOL_NONE 0xFFFF
35
36class SmSym
37{
38private:
40 OUString m_aName;
41 OUString m_aExportName;
42 OUString m_aSetName;
45
46public:
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);
51
52 SmSym& operator = (const SmSym& rSymbol);
53
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; }
57
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; }
62
63 // true if rSymbol has the same name, font and character
64 bool IsEqualInUI( const SmSym& rSymbol ) const;
65};
66
67// type of the actual container to hold the symbols
68typedef std::map< OUString, SmSym > SymbolMap_t;
69
70// vector of pointers to the actual symbols in the above container
71typedef std::vector< const SmSym * > SymbolPtrVec_t;
72
73
75{
76private:
79
80public:
82 SmSymbolManager(const SmSymbolManager& rSymbolSetManager);
84
85 SmSymbolManager & operator = (const SmSymbolManager& rSymbolSetManager);
86
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 );
90
92 bool AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false );
93 void RemoveSymbol( const OUString & rSymbolName );
94
95 SmSym * GetSymbolByName(const OUString& rSymbolName);
96 const SmSym * GetSymbolByName(const OUString& rSymbolName) const
97 {
98 return const_cast<SmSymbolManager *>(this)->GetSymbolByName(rSymbolName);
99 }
100
101 bool IsModified() const { return m_bModified; }
102 void SetModified(bool bModify) { m_bModified = bModify; }
103
104 void Load();
105 void Save();
106};
107
108/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: symbol.hxx:37
SmSym & operator=(const SmSym &rSymbol)
Definition: symbol.cxx:61
OUString m_aExportName
Definition: symbol.hxx:41
OUString m_aSetName
Definition: symbol.hxx:42
const OUString & GetSymbolSetName() const
Definition: symbol.hxx:59
bool IsPredefined() const
Definition: symbol.hxx:58
const OUString & GetName() const
Definition: symbol.hxx:56
const OUString & GetExportName() const
Definition: symbol.hxx:60
sal_UCS4 m_cChar
Definition: symbol.hxx:43
void SetExportName(const OUString &rName)
Definition: symbol.hxx:61
SmFace m_aFace
Definition: symbol.hxx:39
OUString m_aName
Definition: symbol.hxx:40
sal_UCS4 GetCharacter() const
Definition: symbol.hxx:55
const vcl::Font & GetFace() const
Definition: symbol.hxx:54
SmSym()
Definition: symbol.cxx:28
bool IsEqualInUI(const SmSym &rSymbol) const
Definition: symbol.cxx:76
bool m_bPredefined
Definition: symbol.hxx:44
SymbolPtrVec_t GetSymbolSet(std::u16string_view rSymbolSetName)
Definition: symbol.cxx:189
bool AddOrReplaceSymbol(const SmSym &rSymbol, bool bForceChange=false)
Definition: symbol.cxx:133
bool IsModified() const
Definition: symbol.hxx:101
SymbolMap_t m_aSymbols
Definition: symbol.hxx:77
void RemoveSymbol(const OUString &rSymbolName)
Definition: symbol.cxx:169
SmSym * GetSymbolByName(const OUString &rSymbolName)
Definition: symbol.cxx:112
std::set< OUString > GetSymbolSetNames() const
Definition: symbol.cxx:180
bool m_bModified
Definition: symbol.hxx:78
SymbolPtrVec_t GetSymbols() const
Definition: symbol.cxx:122
const SmSym * GetSymbolByName(const OUString &rSymbolName) const
Definition: symbol.hxx:96
void SetModified(bool bModify)
Definition: symbol.hxx:102
SmSymbolManager & operator=(const SmSymbolManager &rSymbolSetManager)
Definition: symbol.cxx:104
std::map< OUString, SmSym > SymbolMap_t
Definition: symbol.hxx:68
std::vector< const SmSym * > SymbolPtrVec_t
Definition: symbol.hxx:71
sal_uInt32 sal_UCS4