Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #ifdef _MSC_VER
21 : : #pragma hdrstop
22 : : #endif
23 : :
24 : : #ifndef _MATH_CFGITEM_HXX_
25 : : #define _MATH_CFGITEM_HXX_
26 : :
27 : : #include <deque>
28 : : #include <vector>
29 : :
30 : : #include <com/sun/star/beans/PropertyValues.hpp>
31 : : #include <com/sun/star/uno/Sequence.hxx>
32 : : #include <com/sun/star/uno/Any.h>
33 : :
34 : : #include <tools/solar.h>
35 : : #include <rtl/ustring.hxx>
36 : : #include <unotools/configitem.hxx>
37 : : #include <vcl/timer.hxx>
38 : :
39 : : #include <symbol.hxx>
40 : : #include <types.hxx>
41 : :
42 : : using namespace com::sun::star;
43 : :
44 : : class SmSym;
45 : : class SmFormat;
46 : : class Font;
47 : : struct SmCfgOther;
48 : :
49 : : /////////////////////////////////////////////////////////////////
50 : :
51 : :
52 : 88 : struct SmFontFormat
53 : : {
54 : : String aName;
55 : : sal_Int16 nCharSet;
56 : : sal_Int16 nFamily;
57 : : sal_Int16 nPitch;
58 : : sal_Int16 nWeight;
59 : : sal_Int16 nItalic;
60 : :
61 : : SmFontFormat();
62 : : SmFontFormat( const Font &rFont );
63 : :
64 : : const Font GetFont() const;
65 : : bool operator == ( const SmFontFormat &rFntFmt ) const;
66 : : };
67 : :
68 : :
69 [ + - ][ + - ]: 48 : struct SmFntFmtListEntry
70 : : {
71 : : String aId;
72 : : SmFontFormat aFntFmt;
73 : :
74 : : SmFntFmtListEntry( const String &rId, const SmFontFormat &rFntFmt );
75 : : };
76 : :
77 : 4 : class SmFontFormatList
78 : : {
79 : : std::deque<SmFntFmtListEntry> aEntries;
80 : : bool bModified;
81 : :
82 : : // disallow copy-constructor and assignment-operator for now
83 : : SmFontFormatList( const SmFontFormatList & );
84 : : SmFontFormatList & operator = ( const SmFontFormatList & );
85 : :
86 : : public:
87 : : SmFontFormatList();
88 : :
89 : : void Clear();
90 : : void AddFontFormat( const String &rFntFmtId, const SmFontFormat &rFntFmt );
91 : : void RemoveFontFormat( const String &rFntFmtId );
92 : :
93 : : const SmFontFormat * GetFontFormat( const String &rFntFmtId ) const;
94 : : const SmFontFormat * GetFontFormat( size_t nPos ) const;
95 : : const String GetFontFormatId( const SmFontFormat &rFntFmt ) const;
96 : : const String GetFontFormatId( const SmFontFormat &rFntFmt, bool bAdd );
97 : : const String GetFontFormatId( size_t nPos ) const;
98 : : const rtl::OUString GetNewFontFormatId() const;
99 : 0 : size_t GetCount() const { return aEntries.size(); }
100 : :
101 : 4 : bool IsModified() const { return bModified; }
102 : 30 : void SetModified( bool bVal ) { bModified = bVal; }
103 : : };
104 : :
105 : :
106 : : /////////////////////////////////////////////////////////////////
107 : :
108 : : class SmMathConfig : public utl::ConfigItem
109 : : {
110 : : SmFormat * pFormat;
111 : : SmCfgOther * pOther;
112 : : SmFontFormatList * pFontFormatList;
113 : : SmSymbolManager * pSymbolMgr;
114 : : bool bIsOtherModified;
115 : : bool bIsFormatModified;
116 : :
117 : : // disallow copy-constructor and assignment-operator for now
118 : : SmMathConfig( const SmMathConfig & );
119 : : SmMathConfig & operator = ( const SmMathConfig & );
120 : :
121 : :
122 : : void StripFontFormatList( const std::vector< SmSym > &rSymbols );
123 : :
124 : :
125 : : void Save();
126 : :
127 : : void ReadSymbol( SmSym &rSymbol,
128 : : const rtl::OUString &rSymbolName,
129 : : const rtl::OUString &rBaseNode ) const;
130 : : void ReadFontFormat( SmFontFormat &rFontFormat,
131 : : const rtl::OUString &rSymbolName,
132 : : const rtl::OUString &rBaseNode ) const;
133 : :
134 : : void SetOtherIfNotEqual( bool &rbItem, bool bNewVal );
135 : :
136 : : protected:
137 : : void LoadOther();
138 : : void SaveOther();
139 : : void LoadFormat();
140 : : void SaveFormat();
141 : : void LoadFontFormatList();
142 : : void SaveFontFormatList();
143 : :
144 : : void SetOtherModified( bool bVal );
145 : 4 : inline bool IsOtherModified() const { return bIsOtherModified; }
146 : : void SetFormatModified( bool bVal );
147 : 4 : inline bool IsFormatModified() const { return bIsFormatModified; }
148 : : void SetFontFormatListModified( bool bVal );
149 : : inline bool IsFontFormatListModified() const { return pFontFormatList ? pFontFormatList->IsModified(): false; }
150 : :
151 : : SmFontFormatList & GetFontFormatList();
152 : 396 : const SmFontFormatList & GetFontFormatList() const
153 : : {
154 : 396 : return ((SmMathConfig *) this)->GetFontFormatList();
155 : : }
156 : :
157 : : public:
158 : : SmMathConfig();
159 : : virtual ~SmMathConfig();
160 : :
161 : : // utl::ConfigItem
162 : : virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
163 : : virtual void Commit();
164 : :
165 : : SmSymbolManager & GetSymbolManager();
166 : : void GetSymbols( std::vector< SmSym > &rSymbols ) const;
167 : : void SetSymbols( const std::vector< SmSym > &rNewSymbols );
168 : :
169 : : const SmFormat & GetStandardFormat() const;
170 : : void SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFormatList = false );
171 : :
172 : : bool IsPrintTitle() const;
173 : : void SetPrintTitle( bool bVal );
174 : : bool IsPrintFormulaText() const;
175 : : void SetPrintFormulaText( bool bVal );
176 : : bool IsPrintFrame() const;
177 : : void SetPrintFrame( bool bVal );
178 : : SmPrintSize GetPrintSize() const;
179 : : void SetPrintSize( SmPrintSize eSize );
180 : : sal_uInt16 GetPrintZoomFactor() const;
181 : : void SetPrintZoomFactor( sal_uInt16 nVal );
182 : :
183 : : bool IsSaveOnlyUsedSymbols() const;
184 : : void SetSaveOnlyUsedSymbols( bool bVal );
185 : : bool IsIgnoreSpacesRight() const;
186 : : void SetIgnoreSpacesRight( bool bVal );
187 : : bool IsAutoRedraw() const;
188 : : void SetAutoRedraw( bool bVal );
189 : : bool IsShowFormulaCursor() const;
190 : : void SetShowFormulaCursor( bool bVal );
191 : : void SetAutoRedraw( sal_Bool bVal );
192 : : };
193 : :
194 : : /////////////////////////////////////////////////////////////////
195 : :
196 : : #endif
197 : :
198 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|