/src/libreoffice/starmath/inc/symbol.hxx
Line | Count | Source |
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 | | |
20 | | /** This stuff is used to work with %charname. |
21 | | * |
22 | | * Will remember the char name, char code and font. |
23 | | */ |
24 | | |
25 | | #pragma once |
26 | | |
27 | | #include <map> |
28 | | #include <vector> |
29 | | #include <set> |
30 | | |
31 | | #include "format.hxx" |
32 | | #include "utility.hxx" |
33 | | |
34 | | #include <vcl/vclenum.hxx> |
35 | | |
36 | | |
37 | 0 | #define SYMBOL_NONE 0xFFFF |
38 | | |
39 | | class SmSym |
40 | | { |
41 | | private: |
42 | | SmFace m_aFace; |
43 | | OUString m_aUiName; |
44 | | OUString m_aExportName; |
45 | | OUString m_aSetName; |
46 | | sal_UCS4 m_cChar; |
47 | | bool m_bPredefined; |
48 | | |
49 | | public: |
50 | | SmSym(); |
51 | | SmSym(const OUString& rName, const vcl::Font& rFont, sal_UCS4 cChar, |
52 | | const OUString& rSet, bool bIsPredefined = false); |
53 | | SmSym(const SmSym& rSymbol); |
54 | | |
55 | | SmSym& operator = (const SmSym& rSymbol); |
56 | | |
57 | | const vcl::Font& GetFace(const SmFormat* pFormat = nullptr) const; |
58 | 0 | sal_UCS4 GetCharacter() const { return m_cChar; } |
59 | 0 | const OUString& GetUiName() const { return m_aUiName; } |
60 | | |
61 | 0 | bool IsPredefined() const { return m_bPredefined; } |
62 | 0 | const OUString& GetSymbolSetName() const { return m_aSetName; } |
63 | 0 | const OUString& GetExportName() const { return m_aExportName; } |
64 | 0 | void SetExportName( const OUString &rName ) { m_aExportName = rName; } |
65 | | |
66 | | // true if rSymbol has the same name, font and character |
67 | | bool IsEqualInUI( const SmSym& rSymbol ) const; |
68 | | }; |
69 | | |
70 | | // type of the actual container to hold the symbols |
71 | | typedef std::map< OUString, SmSym > SymbolMap_t; |
72 | | |
73 | | // vector of pointers to the actual symbols in the above container |
74 | | typedef std::vector< const SmSym * > SymbolPtrVec_t; |
75 | | |
76 | | |
77 | | class SmSymbolManager |
78 | | { |
79 | | private: |
80 | | SymbolMap_t m_aSymbols; |
81 | | bool m_bModified; |
82 | | |
83 | | public: |
84 | | SmSymbolManager(); |
85 | | SmSymbolManager(const SmSymbolManager& rSymbolSetManager); |
86 | | ~SmSymbolManager(); |
87 | | |
88 | | SmSymbolManager & operator = (const SmSymbolManager& rSymbolSetManager); |
89 | | |
90 | | // symbol sets are for UI purpose only, thus we assemble them here |
91 | | std::set< OUString > GetSymbolSetNames() const; |
92 | | SymbolPtrVec_t GetSymbolSet( std::u16string_view rSymbolSetName ); |
93 | | |
94 | | SymbolPtrVec_t GetSymbols() const; |
95 | | bool AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false ); |
96 | | void RemoveSymbol( const OUString & rSymbolName ); |
97 | | |
98 | | SmSym* GetSymbolByName(std::u16string_view rSymbolName); |
99 | | SmSym* GetSymbolByUiName(std::u16string_view rSymbolName); |
100 | | SmSym* GetSymbolByExportName(std::u16string_view rSymbolName); |
101 | | |
102 | 0 | bool IsModified() const { return m_bModified; } |
103 | 0 | void SetModified(bool bModify) { m_bModified = bModify; } |
104 | | |
105 | | void Load(); |
106 | | void Save(); |
107 | | }; |
108 | | |
109 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |