1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <vcl/font.hxx>
24 #include <svl/lstner.hxx>
32 #include "unomodel.hxx"
33 #include "utility.hxx"
37 #define SYMBOLSET_NONE 0xFFFF
38 #define SYMBOL_NONE 0xFFFF
41 ////////////////////////////////////////////////////////////////////////////////
43 inline const OUString
GetExportSymbolName( const OUString
&rUiSymbolName
)
45 return SM_MOD()->GetLocSymbolData().GetExportSymbolName( rUiSymbolName
);
49 inline const OUString
GetUiSymbolName( const OUString
&rExportSymbolName
)
51 return SM_MOD()->GetLocSymbolData().GetUiSymbolName( rExportSymbolName
);
54 inline const OUString
GetExportSymbolSetName( const OUString
&rUiSymbolSetName
)
56 return SM_MOD()->GetLocSymbolData().GetExportSymbolSetName( rUiSymbolSetName
);
60 inline const OUString
GetUiSymbolSetName( const OUString
&rExportSymbolSetName
)
62 return SM_MOD()->GetLocSymbolData().GetUiSymbolSetName( rExportSymbolSetName
);
65 ////////////////////////////////////////////////////////////////////////////////
72 OUString m_aExportName
;
80 SmSym(const OUString
& rName
, const Font
& rFont
, sal_UCS4 cChar
,
81 const OUString
& rSet
, bool bIsPredefined
= false);
82 SmSym(const SmSym
& rSymbol
);
84 SmSym
& operator = (const SmSym
& rSymbol
);
86 const Font
& GetFace() const { return m_aFace
; }
87 sal_UCS4
GetCharacter() const { return m_cChar
; }
88 const OUString
& GetName() const { return m_aName
; }
90 void SetFace( const Font
& rFont
) { m_aFace
= rFont
; }
91 void SetCharacter( sal_UCS4 cChar
) { m_cChar
= cChar
; }
93 bool IsPredefined() const { return m_bPredefined
; }
94 const OUString
& GetSymbolSetName() const { return m_aSetName
; }
95 void SetSymbolSetName( const OUString
&rName
) { m_aSetName
= rName
; }
96 const OUString
& GetExportName() const { return m_aExportName
; }
97 void SetExportName( const OUString
&rName
) { m_aExportName
= rName
; }
99 bool IsDocSymbol() const { return m_bDocSymbol
; }
100 void SetDocSymbol( bool bVal
) { m_bDocSymbol
= bVal
; }
102 // true if rSymbol has the same name, font and character
103 bool IsEqualInUI( const SmSym
& rSymbol
) const;
106 // type of the actual container to hold the symbols
107 typedef std::map
< OUString
, SmSym
> SymbolMap_t
;
109 // vector of pointers to the actual symbols in the above container
110 typedef std::vector
< const SmSym
* > SymbolPtrVec_t
;
112 struct lt_SmSymPtr
: public std::binary_function
< const SmSym
*, const SmSym
*, bool >
114 bool operator() ( const SmSym
*pSym1
, const SmSym
*pSym2
) const
116 return pSym1
->GetCharacter() < pSym2
->GetCharacter();
121 class SmSymbolManager
: public SfxListener
124 SymbolMap_t m_aSymbols
;
127 virtual void SFX_NOTIFY(SfxBroadcaster
& rBC
, const TypeId
& rBCType
,
128 const SfxHint
& rHint
, const TypeId
& rHintType
);
132 SmSymbolManager(const SmSymbolManager
& rSymbolSetManager
);
135 SmSymbolManager
& operator = (const SmSymbolManager
& rSymbolSetManager
);
137 // symbol sets are for UI purpose only, thus we assemble them here
138 std::set
< OUString
> GetSymbolSetNames() const;
139 const SymbolPtrVec_t
GetSymbolSet( const OUString
& rSymbolSetName
);
141 sal_uInt16
GetSymbolCount() const { return static_cast< sal_uInt16
>(m_aSymbols
.size()); }
142 const SymbolPtrVec_t
GetSymbols() const;
143 bool AddOrReplaceSymbol( const SmSym
& rSymbol
, bool bForceChange
= false );
144 void RemoveSymbol( const OUString
& rSymbolName
);
146 SmSym
* GetSymbolByName(const OUString
& rSymbolName
);
147 const SmSym
* GetSymbolByName(const OUString
& rSymbolName
) const
149 return ((SmSymbolManager
*) this)->GetSymbolByName(rSymbolName
);
152 bool IsModified() const { return m_bModified
; }
153 void SetModified(bool bModify
) { m_bModified
= bModify
; }
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */