symbol.hxx 3.65 KB
Newer Older
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
Júlio Hoffimann's avatar
Júlio Hoffimann committed
19

20 21
#ifndef INCLUDED_STARMATH_INC_SYMBOL_HXX
#define INCLUDED_STARMATH_INC_SYMBOL_HXX
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
22 23

#include <vcl/font.hxx>
24
#include <svl/lstner.hxx>
25 26 27 28 29

#include <map>
#include <vector>
#include <set>

30
#include "unomodel.hxx"
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
31
#include "utility.hxx"
32
#include "smmod.hxx"
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
33 34 35 36 37 38


#define SYMBOL_NONE     0xFFFF

class SmSym
{
Júlio Hoffimann's avatar
Júlio Hoffimann committed
39
private:
40
    SmFace              m_aFace;
Caolán McNamara's avatar
Caolán McNamara committed
41 42 43
    OUString            m_aName;
    OUString            m_aExportName;
    OUString            m_aSetName;
44
    sal_UCS4            m_cChar;
45
    bool                m_bPredefined;
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
46 47 48

public:
    SmSym();
Noel Grandin's avatar
Noel Grandin committed
49
    SmSym(const OUString& rName, const vcl::Font& rFont, sal_UCS4 cChar,
Caolán McNamara's avatar
Caolán McNamara committed
50
          const OUString& rSet, bool bIsPredefined = false);
51
    SmSym(const SmSym& rSymbol);
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
52 53 54

    SmSym&      operator = (const SmSym& rSymbol);

Noel Grandin's avatar
Noel Grandin committed
55
    const vcl::Font&  GetFace() const { return m_aFace; }
56
    sal_UCS4        GetCharacter() const { return m_cChar; }
Caolán McNamara's avatar
Caolán McNamara committed
57
    const OUString&   GetName() const { return m_aName; }
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
58

59
    bool            IsPredefined() const        { return m_bPredefined; }
Caolán McNamara's avatar
Caolán McNamara committed
60 61 62
    const OUString& GetSymbolSetName() const    { return m_aSetName; }
    const OUString& GetExportName() const       { return m_aExportName; }
    void            SetExportName( const OUString &rName )        { m_aExportName = rName; }
63 64 65 66

    // true if rSymbol has the same name, font and character
    bool            IsEqualInUI( const SmSym& rSymbol ) const;
};
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
67

68
// type of the actual container to hold the symbols
Caolán McNamara's avatar
Caolán McNamara committed
69
typedef std::map< OUString, SmSym >    SymbolMap_t;
70

71 72
// vector of pointers to the actual symbols in the above container
typedef std::vector< const SmSym * >            SymbolPtrVec_t;
73

74

75
class SmSymbolManager
76
{
Júlio Hoffimann's avatar
Júlio Hoffimann committed
77
private:
78 79
    SymbolMap_t         m_aSymbols;
    bool                m_bModified;
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
80

81
public:
82 83
    SmSymbolManager();
    SmSymbolManager(const SmSymbolManager& rSymbolSetManager);
84
    ~SmSymbolManager();
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
85

86
    SmSymbolManager &   operator = (const SmSymbolManager& rSymbolSetManager);
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
87

88
    // symbol sets are for UI purpose only, thus we assemble them here
Caolán McNamara's avatar
Caolán McNamara committed
89 90
    std::set< OUString >      GetSymbolSetNames() const;
    const SymbolPtrVec_t    GetSymbolSet(  const OUString& rSymbolSetName );
91

92 93
    const SymbolPtrVec_t    GetSymbols() const;
    bool                    AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false );
Caolán McNamara's avatar
Caolán McNamara committed
94
    void                    RemoveSymbol( const OUString & rSymbolName );
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
95

Caolán McNamara's avatar
Caolán McNamara committed
96 97
    SmSym       *   GetSymbolByName(const OUString& rSymbolName);
    const SmSym *   GetSymbolByName(const OUString& rSymbolName) const
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
98
    {
99
        return const_cast<SmSymbolManager *>(this)->GetSymbolByName(rSymbolName);
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
100 101
    }

102 103
    bool        IsModified() const          { return m_bModified; }
    void        SetModified(bool bModify)   { m_bModified = bModify; }
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
104

105 106
    void        Load();
    void        Save();
Jens-Heiner Rechtien's avatar
Jens-Heiner Rechtien committed
107 108 109 110
};

#endif

111
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */