xref: /trunk/main/starmath/source/cfgitem.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifdef _MSC_VER
29*cdf0e10cSrcweir #pragma hdrstop
30*cdf0e10cSrcweir #endif
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifndef _MATH_CFGITEM_HXX_
33*cdf0e10cSrcweir #define _MATH_CFGITEM_HXX_
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <deque>
36*cdf0e10cSrcweir #include <vector>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValues.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
40*cdf0e10cSrcweir #include <com/sun/star/uno/Any.h>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <tools/solar.h>
43*cdf0e10cSrcweir #include <rtl/ustring.hxx>
44*cdf0e10cSrcweir #include <unotools/configitem.hxx>
45*cdf0e10cSrcweir #include <vcl/timer.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <symbol.hxx>
48*cdf0e10cSrcweir #include <types.hxx>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace com::sun::star;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class SmSym;
53*cdf0e10cSrcweir class SmFormat;
54*cdf0e10cSrcweir class Font;
55*cdf0e10cSrcweir struct SmCfgOther;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir struct SmFontFormat
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     String      aName;
63*cdf0e10cSrcweir     sal_Int16       nCharSet;
64*cdf0e10cSrcweir     sal_Int16       nFamily;
65*cdf0e10cSrcweir     sal_Int16       nPitch;
66*cdf0e10cSrcweir     sal_Int16       nWeight;
67*cdf0e10cSrcweir     sal_Int16       nItalic;
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     SmFontFormat();
70*cdf0e10cSrcweir     SmFontFormat( const Font &rFont );
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     const Font      GetFont() const;
73*cdf0e10cSrcweir     sal_Bool            operator == ( const SmFontFormat &rFntFmt ) const;
74*cdf0e10cSrcweir };
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir struct SmFntFmtListEntry
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir     String          aId;
80*cdf0e10cSrcweir     SmFontFormat    aFntFmt;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     SmFntFmtListEntry( const String &rId, const SmFontFormat &rFntFmt );
83*cdf0e10cSrcweir };
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir class SmFontFormatList
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     std::deque<SmFntFmtListEntry> aEntries;
88*cdf0e10cSrcweir     sal_Bool                          bModified;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     // disallow copy-constructor and assignment-operator for now
91*cdf0e10cSrcweir     SmFontFormatList( const SmFontFormatList & );
92*cdf0e10cSrcweir     SmFontFormatList & operator = ( const SmFontFormatList & );
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir public:
95*cdf0e10cSrcweir     SmFontFormatList();
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     void    Clear();
98*cdf0e10cSrcweir     void    AddFontFormat( const String &rFntFmtId, const SmFontFormat &rFntFmt );
99*cdf0e10cSrcweir     void    RemoveFontFormat( const String &rFntFmtId );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     const SmFontFormat *    GetFontFormat( const String &rFntFmtId ) const;
102*cdf0e10cSrcweir     const SmFontFormat *    GetFontFormat( size_t nPos ) const;
103*cdf0e10cSrcweir     const String            GetFontFormatId( const SmFontFormat &rFntFmt ) const;
104*cdf0e10cSrcweir     const String            GetFontFormatId( const SmFontFormat &rFntFmt, sal_Bool bAdd );
105*cdf0e10cSrcweir     const String            GetFontFormatId( size_t nPos ) const;
106*cdf0e10cSrcweir     const String            GetNewFontFormatId() const;
107*cdf0e10cSrcweir     size_t                  GetCount() const    { return aEntries.size(); }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     sal_Bool    IsModified() const          { return bModified; }
110*cdf0e10cSrcweir     void    SetModified( sal_Bool bVal )    { bModified = bVal; }
111*cdf0e10cSrcweir };
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir class SmMathConfig : public utl::ConfigItem
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir     SmFormat *          pFormat;
119*cdf0e10cSrcweir     SmCfgOther *        pOther;
120*cdf0e10cSrcweir     SmFontFormatList *  pFontFormatList;
121*cdf0e10cSrcweir     SmSymbolManager *   pSymbolMgr;
122*cdf0e10cSrcweir     sal_Bool                bIsOtherModified;
123*cdf0e10cSrcweir     sal_Bool                bIsFormatModified;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     // disallow copy-constructor and assignment-operator for now
126*cdf0e10cSrcweir     SmMathConfig( const SmMathConfig & );
127*cdf0e10cSrcweir     SmMathConfig & operator = ( const SmMathConfig & );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     void    StripFontFormatList( const std::vector< SmSym > &rSymbols );
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     void    Save();
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     void    ReadSymbol( SmSym &rSymbol,
136*cdf0e10cSrcweir                         const rtl::OUString &rSymbolName,
137*cdf0e10cSrcweir                         const rtl::OUString &rBaseNode ) const;
138*cdf0e10cSrcweir     void    ReadFontFormat( SmFontFormat &rFontFormat,
139*cdf0e10cSrcweir                         const rtl::OUString &rSymbolName,
140*cdf0e10cSrcweir                         const rtl::OUString &rBaseNode ) const;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     void            SetOtherIfNotEqual( sal_Bool &rbItem, sal_Bool bNewVal );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir protected:
145*cdf0e10cSrcweir     void    LoadOther();
146*cdf0e10cSrcweir     void    SaveOther();
147*cdf0e10cSrcweir     void    LoadFormat();
148*cdf0e10cSrcweir     void    SaveFormat();
149*cdf0e10cSrcweir     void    LoadFontFormatList();
150*cdf0e10cSrcweir     void    SaveFontFormatList();
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     void        SetOtherModified( sal_Bool bVal );
153*cdf0e10cSrcweir     inline sal_Bool IsOtherModified() const     { return bIsOtherModified; }
154*cdf0e10cSrcweir     void        SetFormatModified( sal_Bool bVal );
155*cdf0e10cSrcweir     inline sal_Bool IsFormatModified() const    { return bIsFormatModified; }
156*cdf0e10cSrcweir     void        SetFontFormatListModified( sal_Bool bVal );
157*cdf0e10cSrcweir     inline sal_Bool IsFontFormatListModified() const    { return pFontFormatList ? pFontFormatList->IsModified(): sal_False; }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     SmFontFormatList &          GetFontFormatList();
160*cdf0e10cSrcweir     const SmFontFormatList &    GetFontFormatList() const
161*cdf0e10cSrcweir     {
162*cdf0e10cSrcweir         return ((SmMathConfig *) this)->GetFontFormatList();
163*cdf0e10cSrcweir     }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir public:
166*cdf0e10cSrcweir     SmMathConfig();
167*cdf0e10cSrcweir     virtual ~SmMathConfig();
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     // utl::ConfigItem
170*cdf0e10cSrcweir     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
171*cdf0e10cSrcweir     virtual void    Commit();
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     // make some protected functions of utl::ConfigItem public
174*cdf0e10cSrcweir     //using utl::ConfigItem::GetNodeNames;
175*cdf0e10cSrcweir     //using utl::ConfigItem::GetProperties;
176*cdf0e10cSrcweir     //using utl::ConfigItem::PutProperties;
177*cdf0e10cSrcweir     //using utl::ConfigItem::SetSetProperties;
178*cdf0e10cSrcweir     //using utl::ConfigItem::ReplaceSetProperties;
179*cdf0e10cSrcweir     //using utl::ConfigItem::GetReadOnlyStates;
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     SmSymbolManager &   GetSymbolManager();
182*cdf0e10cSrcweir     void                GetSymbols( std::vector< SmSym > &rSymbols ) const;
183*cdf0e10cSrcweir     void                SetSymbols( const std::vector< SmSym > &rNewSymbols );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     const SmFormat &    GetStandardFormat() const;
186*cdf0e10cSrcweir     void                SetStandardFormat( const SmFormat &rFormat, sal_Bool bSaveFontFormatList = sal_False );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     sal_Bool            IsPrintTitle() const;
189*cdf0e10cSrcweir     void            SetPrintTitle( sal_Bool bVal );
190*cdf0e10cSrcweir     sal_Bool            IsPrintFormulaText() const;
191*cdf0e10cSrcweir     void            SetPrintFormulaText( sal_Bool bVal );
192*cdf0e10cSrcweir     sal_Bool            IsPrintFrame() const;
193*cdf0e10cSrcweir     void            SetPrintFrame( sal_Bool bVal );
194*cdf0e10cSrcweir     SmPrintSize     GetPrintSize() const;
195*cdf0e10cSrcweir     void            SetPrintSize( SmPrintSize eSize );
196*cdf0e10cSrcweir     sal_uInt16          GetPrintZoomFactor() const;
197*cdf0e10cSrcweir     void            SetPrintZoomFactor( sal_uInt16 nVal );
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     sal_Bool        IsSaveOnlyUsedSymbols() const;
200*cdf0e10cSrcweir     void            SetSaveOnlyUsedSymbols( sal_Bool bVal );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     sal_Bool        IsIgnoreSpacesRight() const;
203*cdf0e10cSrcweir     void            SetIgnoreSpacesRight( sal_Bool bVal );
204*cdf0e10cSrcweir     sal_Bool        IsAutoRedraw() const;
205*cdf0e10cSrcweir     void            SetAutoRedraw( sal_Bool bVal );
206*cdf0e10cSrcweir     sal_Bool        IsShowFormulaCursor() const;
207*cdf0e10cSrcweir     void            SetShowFormulaCursor( sal_Bool bVal );
208*cdf0e10cSrcweir };
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir #endif
213*cdf0e10cSrcweir 
214