xref: /aoo41x/main/starmath/inc/format.hxx (revision 67e470da)
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 #ifndef FORMAT_HXX
24 #define FORMAT_HXX
25 
26 
27 #include <svl/smplhint.hxx>
28 #include <svl/brdcst.hxx>
29 #include "utility.hxx"
30 #include <types.hxx>
31 
32 
33 #define SM_FMT_VERSION_51	((sal_uInt8) 0x01)
34 #define SM_FMT_VERSION_NOW	SM_FMT_VERSION_51
35 
36 #define FNTNAME_TIMES	"Times New Roman"
37 #define FNTNAME_HELV	"Helvetica"
38 #define FNTNAME_COUR	"Courier"
39 #define FNTNAME_MATH    FONTNAME_MATH
40 
41 
42 // symbolic names used as array indices
43 #define SIZ_BEGIN		0
44 #define SIZ_TEXT		0
45 #define SIZ_INDEX		1
46 #define SIZ_FUNCTION	2
47 #define SIZ_OPERATOR	3
48 #define SIZ_LIMITS		4
49 #define SIZ_END			4
50 
51 // symbolic names used as array indices
52 #define FNT_BEGIN		0
53 #define FNT_VARIABLE	0
54 #define FNT_FUNCTION	1
55 #define FNT_NUMBER		2
56 #define FNT_TEXT		3
57 #define FNT_SERIF		4
58 #define FNT_SANS		5
59 #define FNT_FIXED		6
60 #define FNT_MATH		7
61 #define FNT_END			7
62 
63 // symbolic names used as array indices
64 #define DIS_BEGIN				 0
65 #define DIS_HORIZONTAL			 0
66 #define DIS_VERTICAL			 1
67 #define DIS_ROOT				 2
68 #define DIS_SUPERSCRIPT 		 3
69 #define DIS_SUBSCRIPT			 4
70 #define DIS_NUMERATOR			 5
71 #define DIS_DENOMINATOR 		 6
72 #define DIS_FRACTION			 7
73 #define DIS_STROKEWIDTH 		 8
74 #define DIS_UPPERLIMIT			 9
75 #define DIS_LOWERLIMIT			10
76 #define DIS_BRACKETSIZE 		11
77 #define DIS_BRACKETSPACE		12
78 #define DIS_MATRIXROW			13
79 #define DIS_MATRIXCOL			14
80 #define DIS_ORNAMENTSIZE		15
81 #define DIS_ORNAMENTSPACE		16
82 #define DIS_OPERATORSIZE		17
83 #define DIS_OPERATORSPACE		18
84 #define DIS_LEFTSPACE			19
85 #define DIS_RIGHTSPACE			20
86 #define DIS_TOPSPACE			21
87 #define DIS_BOTTOMSPACE			22
88 #define DIS_NORMALBRACKETSIZE	23
89 #define DIS_END					23
90 
91 
92 // to be broadcastet on format changes:
93 #define HINT_FORMATCHANGED	10003
94 
95 enum SmHorAlign	{ AlignLeft, AlignCenter, AlignRight };
96 
97 String GetDefaultFontName( LanguageType nLang, sal_uInt16 nIdent );
98 
99 class SmFormat : public SfxBroadcaster
100 {
101 	SmFace		vFont[FNT_END + 1];
102     sal_Bool        bDefaultFont[FNT_END + 1];
103 	Size		aBaseSize;
104 	long		nVersion;
105 	sal_uInt16		vSize[SIZ_END + 1];
106 	sal_uInt16		vDist[DIS_END + 1];
107 	SmHorAlign	eHorAlign;
108     sal_Int16       nGreekCharStyle;
109 	sal_Bool		bIsTextmode,
110 				bScaleNormalBrackets;
111 
112 public:
113 	SmFormat();
SmFormat(const SmFormat & rFormat)114     SmFormat(const SmFormat &rFormat) : SfxBroadcaster() { *this = rFormat; }
115 
GetBaseSize() const116 	const Size & 	GetBaseSize() const 			{ return aBaseSize; }
SetBaseSize(const Size & rSize)117 	void			SetBaseSize(const Size &rSize)	{ aBaseSize = rSize; }
118 
GetFont(sal_uInt16 nIdent) const119 	const SmFace &  GetFont(sal_uInt16 nIdent) const { return vFont[nIdent]; }
120     void            SetFont(sal_uInt16 nIdent, const SmFace &rFont, sal_Bool bDefault = sal_False);
SetFontSize(sal_uInt16 nIdent,const Size & rSize)121     void            SetFontSize(sal_uInt16 nIdent, const Size &rSize)   { vFont[nIdent].SetSize( rSize ); }
122 
SetDefaultFont(sal_uInt16 nIdent,sal_Bool bVal)123     void            SetDefaultFont(sal_uInt16 nIdent, sal_Bool bVal)    { bDefaultFont[nIdent] = bVal; }
IsDefaultFont(sal_uInt16 nIdent) const124     sal_Bool            IsDefaultFont(sal_uInt16 nIdent) const   { return bDefaultFont[nIdent]; }
125 
GetRelSize(sal_uInt16 nIdent) const126 	sal_uInt16			GetRelSize(sal_uInt16 nIdent) const			{ return vSize[nIdent]; }
SetRelSize(sal_uInt16 nIdent,sal_uInt16 nVal)127 	void			SetRelSize(sal_uInt16 nIdent, sal_uInt16 nVal)	{ vSize[nIdent] = nVal;}
128 
GetDistance(sal_uInt16 nIdent) const129 	sal_uInt16			GetDistance(sal_uInt16 nIdent) const			{ return vDist[nIdent]; }
SetDistance(sal_uInt16 nIdent,sal_uInt16 nVal)130 	void			SetDistance(sal_uInt16 nIdent, sal_uInt16 nVal)	{ vDist[nIdent] = nVal; }
131 
GetHorAlign() const132 	SmHorAlign		GetHorAlign() const				{ return eHorAlign; }
SetHorAlign(SmHorAlign eAlign)133 	void			SetHorAlign(SmHorAlign eAlign)	{ eHorAlign = eAlign; }
134 
IsTextmode() const135 	sal_Bool			IsTextmode() const     { return bIsTextmode; }
SetTextmode(sal_Bool bVal)136 	void			SetTextmode(sal_Bool bVal) { bIsTextmode = bVal; }
137 
GetGreekCharStyle() const138     sal_Int16           GetGreekCharStyle() const     { return nGreekCharStyle; }
SetGreekCharStyle(sal_Int16 nVal)139     void            SetGreekCharStyle(sal_Int16 nVal) { nGreekCharStyle = nVal; }
140 
IsScaleNormalBrackets() const141 	sal_Bool			IsScaleNormalBrackets() const     { return bScaleNormalBrackets; }
SetScaleNormalBrackets(sal_Bool bVal)142 	void			SetScaleNormalBrackets(sal_Bool bVal) { bScaleNormalBrackets = bVal; }
143 
GetVersion() const144 	long			GetVersion() const { return nVersion; }
145 
146 	//! at time (5.1) use only the lower byte!!!
SetVersion(long nVer)147 	void			SetVersion(long nVer) { nVersion = nVer; }
148 
149 	SmFormat & 		operator = (const SmFormat &rFormat);
150 
151     sal_Bool            operator == (const SmFormat &rFormat) const;
152     inline sal_Bool     operator != (const SmFormat &rFormat) const;
153 
RequestApplyChanges() const154 	void RequestApplyChanges() const
155 	{
156 		((SmFormat *) this)->Broadcast(SfxSimpleHint(HINT_FORMATCHANGED));
157 	}
158 
159 };
160 
operator !=(const SmFormat & rFormat) const161 inline sal_Bool    SmFormat::operator != (const SmFormat &rFormat) const
162 {
163     return !(*this == rFormat);
164 }
165 
166 #endif
167 
168