bump product version to 5.0.4.1
[LibreOffice.git] / starmath / source / cfgitem.hxx
blob98122903497ab92460a24b709bf79fade1020e1d
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>
28 #include <com/sun/star/uno/Any.h>
30 #include <rtl/ustring.hxx>
31 #include <unotools/configitem.hxx>
32 #include <vcl/timer.hxx>
34 #include <symbol.hxx>
35 #include <types.hxx>
36 #include <memory>
38 class SmSym;
39 class SmFormat;
40 namespace vcl { class Font; }
41 struct SmCfgOther;
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&) SAL_DELETED_FUNCTION;
73 SmFontFormatList& operator=(const SmFontFormatList&) SAL_DELETED_FUNCTION;
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
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;
103 SmMathConfig(const SmMathConfig&) SAL_DELETED_FUNCTION;
104 SmMathConfig& operator=(const SmMathConfig&) SAL_DELETED_FUNCTION;
106 void StripFontFormatList( const std::vector< SmSym > &rSymbols );
109 void Save();
111 void ReadSymbol( SmSym &rSymbol,
112 const OUString &rSymbolName,
113 const OUString &rBaseNode ) const;
114 void ReadFontFormat( SmFontFormat &rFontFormat,
115 const OUString &rSymbolName,
116 const OUString &rBaseNode ) const;
118 void SetOtherIfNotEqual( bool &rbItem, bool bNewVal );
120 protected:
121 void LoadOther();
122 void SaveOther();
123 void LoadFormat();
124 void SaveFormat();
125 void LoadFontFormatList();
126 void SaveFontFormatList();
128 void SetOtherModified( bool bVal );
129 inline bool IsOtherModified() const { return bIsOtherModified; }
130 void SetFormatModified( bool bVal );
131 inline bool IsFormatModified() const { return bIsFormatModified; }
132 void SetFontFormatListModified( bool bVal );
133 inline bool IsFontFormatListModified() const { return pFontFormatList && pFontFormatList->IsModified(); }
135 SmFontFormatList & GetFontFormatList();
136 const SmFontFormatList & GetFontFormatList() const
138 return const_cast<SmMathConfig*>(this)->GetFontFormatList();
141 virtual void ImplCommit() SAL_OVERRIDE;
143 public:
144 SmMathConfig();
145 virtual ~SmMathConfig();
147 // utl::ConfigItem
148 virtual void Notify( const com::sun::star::uno::Sequence< OUString > &rPropertyNames ) SAL_OVERRIDE;
150 SmSymbolManager & GetSymbolManager();
151 void GetSymbols( std::vector< SmSym > &rSymbols ) const;
152 void SetSymbols( const std::vector< SmSym > &rNewSymbols );
154 const SmFormat & GetStandardFormat() const;
155 void SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFormatList = false );
157 bool IsPrintTitle() const;
158 void SetPrintTitle( bool bVal );
159 bool IsPrintFormulaText() const;
160 void SetPrintFormulaText( bool bVal );
161 bool IsPrintFrame() const;
162 void SetPrintFrame( bool bVal );
163 SmPrintSize GetPrintSize() const;
164 void SetPrintSize( SmPrintSize eSize );
165 sal_uInt16 GetPrintZoomFactor() const;
166 void SetPrintZoomFactor( sal_uInt16 nVal );
168 bool IsSaveOnlyUsedSymbols() const;
169 void SetSaveOnlyUsedSymbols( bool bVal );
170 bool IsIgnoreSpacesRight() const;
171 void SetIgnoreSpacesRight( bool bVal );
172 bool IsAutoRedraw() const;
173 void SetAutoRedraw( bool bVal );
174 bool IsShowFormulaCursor() const;
175 void SetShowFormulaCursor( bool bVal );
178 #endif
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */