xref: /aoo42x/main/starmath/source/cfgitem.hxx (revision f6a9d5ca)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifdef _MSC_VER
25 #pragma hdrstop
26 #endif
27 
28 #ifndef _MATH_CFGITEM_HXX_
29 #define _MATH_CFGITEM_HXX_
30 
31 #include <deque>
32 #include <vector>
33 
34 #include <com/sun/star/beans/PropertyValues.hpp>
35 #include <com/sun/star/uno/Sequence.hxx>
36 #include <com/sun/star/uno/Any.h>
37 
38 #include <tools/solar.h>
39 #include <rtl/ustring.hxx>
40 #include <unotools/configitem.hxx>
41 #include <vcl/timer.hxx>
42 
43 #include <symbol.hxx>
44 #include <types.hxx>
45 
46 using namespace com::sun::star;
47 
48 class SmSym;
49 class SmFormat;
50 class Font;
51 struct SmCfgOther;
52 
53 /////////////////////////////////////////////////////////////////
54 
55 
56 struct SmFontFormat
57 {
58     String      aName;
59     sal_Int16       nCharSet;
60     sal_Int16       nFamily;
61     sal_Int16       nPitch;
62     sal_Int16       nWeight;
63     sal_Int16       nItalic;
64 
65     SmFontFormat();
66     SmFontFormat( const Font &rFont );
67 
68     const Font      GetFont() const;
69     sal_Bool            operator == ( const SmFontFormat &rFntFmt ) const;
70 };
71 
72 
73 struct SmFntFmtListEntry
74 {
75     String          aId;
76     SmFontFormat    aFntFmt;
77 
78     SmFntFmtListEntry( const String &rId, const SmFontFormat &rFntFmt );
79 };
80 
81 class SmFontFormatList
82 {
83     std::deque<SmFntFmtListEntry> aEntries;
84     sal_Bool                          bModified;
85 
86 	// disallow copy-constructor and assignment-operator for now
87     SmFontFormatList( const SmFontFormatList & );
88     SmFontFormatList & operator = ( const SmFontFormatList & );
89 
90 public:
91     SmFontFormatList();
92 
93     void    Clear();
94     void    AddFontFormat( const String &rFntFmtId, const SmFontFormat &rFntFmt );
95     void    RemoveFontFormat( const String &rFntFmtId );
96 
97     const SmFontFormat *    GetFontFormat( const String &rFntFmtId ) const;
98     const SmFontFormat *    GetFontFormat( size_t nPos ) const;
99     const String            GetFontFormatId( const SmFontFormat &rFntFmt ) const;
100     const String            GetFontFormatId( const SmFontFormat &rFntFmt, sal_Bool bAdd );
101     const String            GetFontFormatId( size_t nPos ) const;
102     const String            GetNewFontFormatId() const;
GetCount() const103     size_t                  GetCount() const    { return aEntries.size(); }
104 
IsModified() const105     sal_Bool    IsModified() const          { return bModified; }
SetModified(sal_Bool bVal)106     void    SetModified( sal_Bool bVal )    { bModified = bVal; }
107 };
108 
109 
110 /////////////////////////////////////////////////////////////////
111 
112 class SmMathConfig : public utl::ConfigItem
113 {
114     SmFormat *          pFormat;
115     SmCfgOther *        pOther;
116     SmFontFormatList *  pFontFormatList;
117     SmSymbolManager *   pSymbolMgr;
118     sal_Bool                bIsOtherModified;
119     sal_Bool                bIsFormatModified;
120 
121 	// disallow copy-constructor and assignment-operator for now
122 	SmMathConfig( const SmMathConfig & );
123 	SmMathConfig & operator = ( const SmMathConfig & );
124 
125 
126     void    StripFontFormatList( const std::vector< SmSym > &rSymbols );
127 
128 
129     void    Save();
130 
131     void    ReadSymbol( SmSym &rSymbol,
132 						const rtl::OUString &rSymbolName,
133 						const rtl::OUString &rBaseNode ) const;
134     void    ReadFontFormat( SmFontFormat &rFontFormat,
135 						const rtl::OUString &rSymbolName,
136 						const rtl::OUString &rBaseNode ) const;
137 
138     void            SetOtherIfNotEqual( sal_Bool &rbItem, sal_Bool bNewVal );
139 
140 protected:
141     void    LoadOther();
142     void    SaveOther();
143     void    LoadFormat();
144     void    SaveFormat();
145     void    LoadFontFormatList();
146     void    SaveFontFormatList();
147 
148 	void        SetOtherModified( sal_Bool bVal );
IsOtherModified() const149     inline sal_Bool IsOtherModified() const     { return bIsOtherModified; }
150     void        SetFormatModified( sal_Bool bVal );
IsFormatModified() const151     inline sal_Bool IsFormatModified() const    { return bIsFormatModified; }
152     void        SetFontFormatListModified( sal_Bool bVal );
IsFontFormatListModified() const153     inline sal_Bool IsFontFormatListModified() const    { return pFontFormatList ? pFontFormatList->IsModified(): sal_False; }
154 
155     SmFontFormatList &          GetFontFormatList();
GetFontFormatList() const156     const SmFontFormatList &    GetFontFormatList() const
157     {
158         return ((SmMathConfig *) this)->GetFontFormatList();
159     }
160 
161 public:
162 	SmMathConfig();
163     virtual ~SmMathConfig();
164 
165     // utl::ConfigItem
166     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
167     virtual void    Commit();
168 
169     // make some protected functions of utl::ConfigItem public
170     //using utl::ConfigItem::GetNodeNames;
171     //using utl::ConfigItem::GetProperties;
172     //using utl::ConfigItem::PutProperties;
173     //using utl::ConfigItem::SetSetProperties;
174     //using utl::ConfigItem::ReplaceSetProperties;
175     //using utl::ConfigItem::GetReadOnlyStates;
176 
177     SmSymbolManager &   GetSymbolManager();
178     void                GetSymbols( std::vector< SmSym > &rSymbols ) const;
179     void                SetSymbols( const std::vector< SmSym > &rNewSymbols );
180 
181     const SmFormat &    GetStandardFormat() const;
182     void                SetStandardFormat( const SmFormat &rFormat, sal_Bool bSaveFontFormatList = sal_False );
183 
184     sal_Bool            IsPrintTitle() const;
185     void            SetPrintTitle( sal_Bool bVal );
186     sal_Bool            IsPrintFormulaText() const;
187     void            SetPrintFormulaText( sal_Bool bVal );
188     sal_Bool            IsPrintFrame() const;
189     void            SetPrintFrame( sal_Bool bVal );
190     SmPrintSize     GetPrintSize() const;
191     void            SetPrintSize( SmPrintSize eSize );
192     sal_uInt16          GetPrintZoomFactor() const;
193     void            SetPrintZoomFactor( sal_uInt16 nVal );
194 
195     sal_Bool        IsSaveOnlyUsedSymbols() const;
196     void            SetSaveOnlyUsedSymbols( sal_Bool bVal );
197 
198     sal_Bool        IsIgnoreSpacesRight() const;
199     void            SetIgnoreSpacesRight( sal_Bool bVal );
200     sal_Bool        IsAutoRedraw() const;
201     void            SetAutoRedraw( sal_Bool bVal );
202     sal_Bool        IsShowFormulaCursor() const;
203     void            SetShowFormulaCursor( sal_Bool bVal );
204 };
205 
206 /////////////////////////////////////////////////////////////////
207 
208 #endif
209 
210