tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / starmath / inc / symbol.hxx
blobf337a0dfac215863e682f324350147e26a81630c
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 "format.hxx"
32 #include "utility.hxx"
35 #define SYMBOL_NONE 0xFFFF
37 class SmSym
39 private:
40 SmFace m_aFace;
41 OUString m_aUiName;
42 OUString m_aExportName;
43 OUString m_aSetName;
44 sal_UCS4 m_cChar;
45 bool m_bPredefined;
47 public:
48 SmSym();
49 SmSym(const OUString& rName, const vcl::Font& rFont, sal_UCS4 cChar,
50 const OUString& rSet, bool bIsPredefined = false);
51 SmSym(const SmSym& rSymbol);
53 SmSym& operator = (const SmSym& rSymbol);
55 const vcl::Font& GetFace(const SmFormat* pFormat = nullptr) const;
56 sal_UCS4 GetCharacter() const { return m_cChar; }
57 const OUString& GetUiName() const { return m_aUiName; }
59 bool IsPredefined() const { return m_bPredefined; }
60 const OUString& GetSymbolSetName() const { return m_aSetName; }
61 const OUString& GetExportName() const { return m_aExportName; }
62 void SetExportName( const OUString &rName ) { m_aExportName = rName; }
64 // true if rSymbol has the same name, font and character
65 bool IsEqualInUI( const SmSym& rSymbol ) const;
68 // type of the actual container to hold the symbols
69 typedef std::map< OUString, SmSym > SymbolMap_t;
71 // vector of pointers to the actual symbols in the above container
72 typedef std::vector< const SmSym * > SymbolPtrVec_t;
75 class SmSymbolManager
77 private:
78 SymbolMap_t m_aSymbols;
79 bool m_bModified;
81 public:
82 SmSymbolManager();
83 SmSymbolManager(const SmSymbolManager& rSymbolSetManager);
84 ~SmSymbolManager();
86 SmSymbolManager & operator = (const SmSymbolManager& rSymbolSetManager);
88 // symbol sets are for UI purpose only, thus we assemble them here
89 std::set< OUString > GetSymbolSetNames() const;
90 SymbolPtrVec_t GetSymbolSet( std::u16string_view rSymbolSetName );
92 SymbolPtrVec_t GetSymbols() const;
93 bool AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false );
94 void RemoveSymbol( const OUString & rSymbolName );
96 SmSym* GetSymbolByName(std::u16string_view rSymbolName);
97 SmSym* GetSymbolByUiName(std::u16string_view rSymbolName);
98 SmSym* GetSymbolByExportName(std::u16string_view rSymbolName);
100 bool IsModified() const { return m_bModified; }
101 void SetModified(bool bModify) { m_bModified = bModify; }
103 void Load();
104 void Save();
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */