xref: /trunk/main/starmath/inc/format.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef FORMAT_HXX
28 #define FORMAT_HXX
29 
30 
31 #include <svl/smplhint.hxx>
32 #include <svl/brdcst.hxx>
33 #include "utility.hxx"
34 #include <types.hxx>
35 
36 
37 #define SM_FMT_VERSION_51   ((sal_uInt8) 0x01)
38 #define SM_FMT_VERSION_NOW  SM_FMT_VERSION_51
39 
40 #define FNTNAME_TIMES   "Times New Roman"
41 #define FNTNAME_HELV    "Helvetica"
42 #define FNTNAME_COUR    "Courier"
43 #define FNTNAME_MATH    FONTNAME_MATH
44 
45 
46 // symbolic names used as array indices
47 #define SIZ_BEGIN       0
48 #define SIZ_TEXT        0
49 #define SIZ_INDEX       1
50 #define SIZ_FUNCTION    2
51 #define SIZ_OPERATOR    3
52 #define SIZ_LIMITS      4
53 #define SIZ_END         4
54 
55 // symbolic names used as array indices
56 #define FNT_BEGIN       0
57 #define FNT_VARIABLE    0
58 #define FNT_FUNCTION    1
59 #define FNT_NUMBER      2
60 #define FNT_TEXT        3
61 #define FNT_SERIF       4
62 #define FNT_SANS        5
63 #define FNT_FIXED       6
64 #define FNT_MATH        7
65 #define FNT_END         7
66 
67 // symbolic names used as array indices
68 #define DIS_BEGIN                0
69 #define DIS_HORIZONTAL           0
70 #define DIS_VERTICAL             1
71 #define DIS_ROOT                 2
72 #define DIS_SUPERSCRIPT          3
73 #define DIS_SUBSCRIPT            4
74 #define DIS_NUMERATOR            5
75 #define DIS_DENOMINATOR          6
76 #define DIS_FRACTION             7
77 #define DIS_STROKEWIDTH          8
78 #define DIS_UPPERLIMIT           9
79 #define DIS_LOWERLIMIT          10
80 #define DIS_BRACKETSIZE         11
81 #define DIS_BRACKETSPACE        12
82 #define DIS_MATRIXROW           13
83 #define DIS_MATRIXCOL           14
84 #define DIS_ORNAMENTSIZE        15
85 #define DIS_ORNAMENTSPACE       16
86 #define DIS_OPERATORSIZE        17
87 #define DIS_OPERATORSPACE       18
88 #define DIS_LEFTSPACE           19
89 #define DIS_RIGHTSPACE          20
90 #define DIS_TOPSPACE            21
91 #define DIS_BOTTOMSPACE         22
92 #define DIS_NORMALBRACKETSIZE   23
93 #define DIS_END                 23
94 
95 
96 // to be broadcastet on format changes:
97 #define HINT_FORMATCHANGED  10003
98 
99 enum SmHorAlign { AlignLeft, AlignCenter, AlignRight };
100 
101 String GetDefaultFontName( LanguageType nLang, sal_uInt16 nIdent );
102 
103 class SmFormat : public SfxBroadcaster
104 {
105     SmFace      vFont[FNT_END + 1];
106     sal_Bool        bDefaultFont[FNT_END + 1];
107     Size        aBaseSize;
108     long        nVersion;
109     sal_uInt16      vSize[SIZ_END + 1];
110     sal_uInt16      vDist[DIS_END + 1];
111     SmHorAlign  eHorAlign;
112     sal_Int16       nGreekCharStyle;
113     sal_Bool        bIsTextmode,
114                 bScaleNormalBrackets;
115 
116 public:
117     SmFormat();
118     SmFormat(const SmFormat &rFormat) : SfxBroadcaster() { *this = rFormat; }
119 
120     const Size &    GetBaseSize() const             { return aBaseSize; }
121     void            SetBaseSize(const Size &rSize)  { aBaseSize = rSize; }
122 
123     const SmFace &  GetFont(sal_uInt16 nIdent) const { return vFont[nIdent]; }
124     void            SetFont(sal_uInt16 nIdent, const SmFace &rFont, sal_Bool bDefault = sal_False);
125     void            SetFontSize(sal_uInt16 nIdent, const Size &rSize)   { vFont[nIdent].SetSize( rSize ); }
126 
127     void            SetDefaultFont(sal_uInt16 nIdent, sal_Bool bVal)    { bDefaultFont[nIdent] = bVal; }
128     sal_Bool            IsDefaultFont(sal_uInt16 nIdent) const   { return bDefaultFont[nIdent]; }
129 
130     sal_uInt16          GetRelSize(sal_uInt16 nIdent) const         { return vSize[nIdent]; }
131     void            SetRelSize(sal_uInt16 nIdent, sal_uInt16 nVal)  { vSize[nIdent] = nVal;}
132 
133     sal_uInt16          GetDistance(sal_uInt16 nIdent) const            { return vDist[nIdent]; }
134     void            SetDistance(sal_uInt16 nIdent, sal_uInt16 nVal) { vDist[nIdent] = nVal; }
135 
136     SmHorAlign      GetHorAlign() const             { return eHorAlign; }
137     void            SetHorAlign(SmHorAlign eAlign)  { eHorAlign = eAlign; }
138 
139     sal_Bool            IsTextmode() const     { return bIsTextmode; }
140     void            SetTextmode(sal_Bool bVal) { bIsTextmode = bVal; }
141 
142     sal_Int16           GetGreekCharStyle() const     { return nGreekCharStyle; }
143     void            SetGreekCharStyle(sal_Int16 nVal) { nGreekCharStyle = nVal; }
144 
145     sal_Bool            IsScaleNormalBrackets() const     { return bScaleNormalBrackets; }
146     void            SetScaleNormalBrackets(sal_Bool bVal) { bScaleNormalBrackets = bVal; }
147 
148     long            GetVersion() const { return nVersion; }
149 
150     //! at time (5.1) use only the lower byte!!!
151     void            SetVersion(long nVer) { nVersion = nVer; }
152 
153     SmFormat &      operator = (const SmFormat &rFormat);
154 
155     sal_Bool            operator == (const SmFormat &rFormat) const;
156     inline sal_Bool     operator != (const SmFormat &rFormat) const;
157 
158     void RequestApplyChanges() const
159     {
160         ((SmFormat *) this)->Broadcast(SfxSimpleHint(HINT_FORMATCHANGED));
161     }
162 
163 };
164 
165 inline sal_Bool    SmFormat::operator != (const SmFormat &rFormat) const
166 {
167     return !(*this == rFormat);
168 }
169 
170 #endif
171 
172