build fix
[LibreOffice.git] / starmath / source / cfgitem.hxx
blob1bb91e340f2abacb2f90cda30cc31ebce82c9a51
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 #ifndef INCLUDED_STARMATH_SOURCE_CFGITEM_HXX
21 #define INCLUDED_STARMATH_SOURCE_CFGITEM_HXX
23 #include <deque>
24 #include <vector>
26 #include <com/sun/star/beans/PropertyValues.hpp>
27 #include <com/sun/star/uno/Sequence.hxx>
29 #include <rtl/ustring.hxx>
30 #include <unotools/configitem.hxx>
31 #include <vcl/timer.hxx>
33 #include <symbol.hxx>
34 #include <types.hxx>
35 #include <memory>
37 class SmSym;
38 class SmFormat;
39 namespace vcl { class Font; }
40 struct SmCfgOther;
41 class SfxItemSet;
43 struct SmFontFormat
45 OUString aName;
46 sal_Int16 nCharSet;
47 sal_Int16 nFamily;
48 sal_Int16 nPitch;
49 sal_Int16 nWeight;
50 sal_Int16 nItalic;
52 SmFontFormat();
53 explicit SmFontFormat( const vcl::Font &rFont );
55 const vcl::Font GetFont() const;
56 bool operator == ( const SmFontFormat &rFntFmt ) const;
59 struct SmFntFmtListEntry
61 OUString aId;
62 SmFontFormat aFntFmt;
64 SmFntFmtListEntry( const OUString &rId, const SmFontFormat &rFntFmt );
67 class SmFontFormatList
69 std::deque<SmFntFmtListEntry> aEntries;
70 bool bModified;
72 SmFontFormatList(const SmFontFormatList&) = delete;
73 SmFontFormatList& operator=(const SmFontFormatList&) = delete;
75 public:
76 SmFontFormatList();
78 void Clear();
79 void AddFontFormat( const OUString &rFntFmtId, const SmFontFormat &rFntFmt );
80 void RemoveFontFormat( const OUString &rFntFmtId );
82 const SmFontFormat * GetFontFormat( const OUString &rFntFmtId ) const;
83 const SmFontFormat * GetFontFormat( size_t nPos ) const;
84 const OUString GetFontFormatId( const SmFontFormat &rFntFmt ) const;
85 const OUString GetFontFormatId( const SmFontFormat &rFntFmt, bool bAdd );
86 const OUString GetFontFormatId( size_t nPos ) const;
87 const OUString GetNewFontFormatId() const;
88 size_t GetCount() const { return aEntries.size(); }
90 bool IsModified() const { return bModified; }
91 void SetModified( bool bVal ) { bModified = bVal; }
94 class SmMathConfig : public utl::ConfigItem, public SfxBroadcaster
96 std::unique_ptr<SmFormat> pFormat;
97 std::unique_ptr<SmCfgOther> pOther;
98 std::unique_ptr<SmFontFormatList> pFontFormatList;
99 std::unique_ptr<SmSymbolManager> pSymbolMgr;
100 bool bIsOtherModified;
101 bool bIsFormatModified;
102 SmFontPickList vFontPickList[7];
104 SmMathConfig(const SmMathConfig&) = delete;
105 SmMathConfig& operator=(const SmMathConfig&) = delete;
107 void StripFontFormatList( const std::vector< SmSym > &rSymbols );
110 void Save();
112 void ReadSymbol( SmSym &rSymbol,
113 const OUString &rSymbolName,
114 const OUString &rBaseNode ) const;
115 void ReadFontFormat( SmFontFormat &rFontFormat,
116 const OUString &rSymbolName,
117 const OUString &rBaseNode ) const;
119 void SetOtherIfNotEqual( bool &rbItem, bool bNewVal );
121 protected:
122 void LoadOther();
123 void SaveOther();
124 void LoadFormat();
125 void SaveFormat();
126 void LoadFontFormatList();
127 void SaveFontFormatList();
129 void SetOtherModified( bool bVal );
130 inline bool IsOtherModified() const { return bIsOtherModified; }
131 void SetFormatModified( bool bVal );
132 inline bool IsFormatModified() const { return bIsFormatModified; }
134 SmFontFormatList & GetFontFormatList();
135 const SmFontFormatList & GetFontFormatList() const
137 return const_cast<SmMathConfig*>(this)->GetFontFormatList();
140 virtual void ImplCommit() override;
142 public:
143 SmMathConfig();
144 virtual ~SmMathConfig() override;
146 // utl::ConfigItem
147 virtual void Notify( const css::uno::Sequence< OUString > &rPropertyNames ) override;
149 SmSymbolManager & GetSymbolManager();
150 void GetSymbols( std::vector< SmSym > &rSymbols ) const;
151 void SetSymbols( const std::vector< SmSym > &rNewSymbols );
153 const SmFormat & GetStandardFormat() const;
154 void SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFormatList = false );
156 bool IsPrintTitle() const;
157 void SetPrintTitle( bool bVal );
158 bool IsPrintFormulaText() const;
159 void SetPrintFormulaText( bool bVal );
160 bool IsPrintFrame() const;
161 void SetPrintFrame( bool bVal );
162 SmPrintSize GetPrintSize() const;
163 void SetPrintSize( SmPrintSize eSize );
164 sal_uInt16 GetPrintZoomFactor() const;
165 void SetPrintZoomFactor( sal_uInt16 nVal );
167 bool IsSaveOnlyUsedSymbols() const;
168 void SetSaveOnlyUsedSymbols( bool bVal );
169 bool IsAutoCloseBrackets() const;
170 void SetAutoCloseBrackets( bool bVal );
171 bool IsIgnoreSpacesRight() const;
172 void SetIgnoreSpacesRight( bool bVal );
173 bool IsAutoRedraw() const;
174 void SetAutoRedraw( bool bVal );
175 bool IsShowFormulaCursor() const;
176 void SetShowFormulaCursor( bool bVal );
178 SmFontPickList & GetFontPickList(sal_uInt16 nIdent) { return vFontPickList[nIdent]; }
180 void ItemSetToConfig(const SfxItemSet &rSet);
181 void ConfigToItemSet(SfxItemSet &rSet) const;
184 #endif
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */