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 .
22 #include "utility.hxx"
24 #include <string_view>
25 #include <rtl/ustring.hxx>
26 #include <svl/SfxBroadcaster.hxx>
27 #include <unotools/configitem.hxx>
31 namespace com::sun::star::uno
33 template <class E
> class Sequence
;
37 class SmSymbolManager
;
56 explicit SmFontFormat(const vcl::Font
& rFont
);
58 vcl::Font
GetFont() const;
59 bool operator==(const SmFontFormat
& rFntFmt
) const;
62 struct SmFntFmtListEntry
67 SmFntFmtListEntry(const OUString
& rId
, const SmFontFormat
& rFntFmt
);
70 class SmFontFormatList
72 std::vector
<SmFntFmtListEntry
> aEntries
;
75 SmFontFormatList(const SmFontFormatList
&) = delete;
76 SmFontFormatList
& operator=(const SmFontFormatList
&) = delete;
82 void AddFontFormat(const OUString
& rFntFmtId
, const SmFontFormat
& rFntFmt
);
83 void RemoveFontFormat(std::u16string_view rFntFmtId
);
85 const SmFontFormat
* GetFontFormat(std::u16string_view rFntFmtId
) const;
86 const SmFontFormat
* GetFontFormat(size_t nPos
) const;
87 OUString
GetFontFormatId(const SmFontFormat
& rFntFmt
) const;
88 OUString
GetFontFormatId(const SmFontFormat
& rFntFmt
, bool bAdd
);
89 OUString
GetFontFormatId(size_t nPos
) const;
90 OUString
GetNewFontFormatId() const;
91 size_t GetCount() const { return aEntries
.size(); }
93 bool IsModified() const { return bModified
; }
94 void SetModified(bool bVal
) { bModified
= bVal
; }
97 class SmMathConfig final
: public utl::ConfigItem
, public SfxBroadcaster
99 std::unique_ptr
<SmFormat
> pFormat
;
100 std::unique_ptr
<SmCfgOther
> pOther
;
101 std::unique_ptr
<SmFontFormatList
> pFontFormatList
;
102 std::unique_ptr
<SmSymbolManager
> pSymbolMgr
;
103 bool bIsOtherModified
;
104 bool bIsFormatModified
;
105 SmFontPickList vFontPickList
[7];
107 SmMathConfig(const SmMathConfig
&) = delete;
108 SmMathConfig
& operator=(const SmMathConfig
&) = delete;
110 void StripFontFormatList(const std::vector
<SmSym
>& rSymbols
);
114 void ReadSymbol(SmSym
& rSymbol
, const OUString
& rSymbolName
,
115 std::u16string_view rBaseNode
) const;
116 void ReadFontFormat(SmFontFormat
& rFontFormat
, std::u16string_view rSymbolName
,
117 std::u16string_view rBaseNode
) const;
119 void SetOtherIfNotEqual(bool& rbItem
, bool bNewVal
);
125 void LoadFontFormatList();
126 void SaveFontFormatList();
128 void SetOtherModified(bool bVal
);
129 bool IsOtherModified() const { return bIsOtherModified
; }
130 void SetFormatModified(bool bVal
);
131 bool IsFormatModified() const { return bIsFormatModified
; }
133 SmFontFormatList
& GetFontFormatList();
134 const SmFontFormatList
& GetFontFormatList() const
136 return const_cast<SmMathConfig
*>(this)->GetFontFormatList();
139 virtual void ImplCommit() override
;
143 virtual ~SmMathConfig() override
;
146 virtual void Notify(const css::uno::Sequence
<OUString
>& rPropertyNames
) override
;
148 SmSymbolManager
& GetSymbolManager();
149 void GetSymbols(std::vector
<SmSym
>& rSymbols
) const;
150 void SetSymbols(const std::vector
<SmSym
>& rNewSymbols
);
152 const SmFormat
& GetStandardFormat() const;
153 void SetStandardFormat(const SmFormat
& rFormat
, bool bSaveFontFormatList
= false);
155 bool IsPrintTitle() const;
156 void SetPrintTitle(bool bVal
);
157 bool IsPrintFormulaText() const;
158 void SetPrintFormulaText(bool bVal
);
159 bool IsPrintFrame() const;
160 void SetPrintFrame(bool bVal
);
161 SmPrintSize
GetPrintSize() const;
162 void SetPrintSize(SmPrintSize eSize
);
163 sal_uInt16
GetPrintZoomFactor() const;
164 void SetPrintZoomFactor(sal_uInt16 nVal
);
165 sal_uInt16
GetSmEditWindowZoomFactor() const;
166 void SetSmEditWindowZoomFactor(sal_uInt16 nVal
);
168 bool IsSaveOnlyUsedSymbols() const;
169 void SetSaveOnlyUsedSymbols(bool bVal
);
170 bool IsAutoCloseBrackets() const;
171 void SetAutoCloseBrackets(bool bVal
);
172 bool IsIgnoreSpacesRight() const;
173 void SetIgnoreSpacesRight(bool bVal
);
174 bool IsAutoRedraw() const;
175 void SetAutoRedraw(bool bVal
);
176 bool IsShowFormulaCursor() const;
177 void SetShowFormulaCursor(bool bVal
);
179 sal_uInt16
GetDefaultSmSyntaxVersion() const;
180 void SetDefaultSmSyntaxVersion(sal_uInt16 nVal
);
182 SmFontPickList
& GetFontPickList(sal_uInt16 nIdent
) { return vFontPickList
[nIdent
]; }
184 void ItemSetToConfig(const SfxItemSet
& rSet
);
185 void ConfigToItemSet(SfxItemSet
& rSet
) const;
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */