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