xref: /aoo41x/main/starmath/inc/format.hxx (revision 67e470da)
1*f6a9d5caSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6a9d5caSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6a9d5caSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6a9d5caSAndrew Rist  * distributed with this work for additional information
6*f6a9d5caSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6a9d5caSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6a9d5caSAndrew Rist  * "License"); you may not use this file except in compliance
9*f6a9d5caSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6a9d5caSAndrew Rist  *
11*f6a9d5caSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6a9d5caSAndrew Rist  *
13*f6a9d5caSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6a9d5caSAndrew Rist  * software distributed under the License is distributed on an
15*f6a9d5caSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6a9d5caSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6a9d5caSAndrew Rist  * specific language governing permissions and limitations
18*f6a9d5caSAndrew Rist  * under the License.
19*f6a9d5caSAndrew Rist  *
20*f6a9d5caSAndrew Rist  *************************************************************/
21*f6a9d5caSAndrew Rist 
22*f6a9d5caSAndrew Rist 
23cdf0e10cSrcweir #ifndef FORMAT_HXX
24cdf0e10cSrcweir #define FORMAT_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svl/smplhint.hxx>
28cdf0e10cSrcweir #include <svl/brdcst.hxx>
29cdf0e10cSrcweir #include "utility.hxx"
30cdf0e10cSrcweir #include <types.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #define SM_FMT_VERSION_51	((sal_uInt8) 0x01)
34cdf0e10cSrcweir #define SM_FMT_VERSION_NOW	SM_FMT_VERSION_51
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #define FNTNAME_TIMES	"Times New Roman"
37cdf0e10cSrcweir #define FNTNAME_HELV	"Helvetica"
38cdf0e10cSrcweir #define FNTNAME_COUR	"Courier"
39cdf0e10cSrcweir #define FNTNAME_MATH    FONTNAME_MATH
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // symbolic names used as array indices
43cdf0e10cSrcweir #define SIZ_BEGIN		0
44cdf0e10cSrcweir #define SIZ_TEXT		0
45cdf0e10cSrcweir #define SIZ_INDEX		1
46cdf0e10cSrcweir #define SIZ_FUNCTION	2
47cdf0e10cSrcweir #define SIZ_OPERATOR	3
48cdf0e10cSrcweir #define SIZ_LIMITS		4
49cdf0e10cSrcweir #define SIZ_END			4
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // symbolic names used as array indices
52cdf0e10cSrcweir #define FNT_BEGIN		0
53cdf0e10cSrcweir #define FNT_VARIABLE	0
54cdf0e10cSrcweir #define FNT_FUNCTION	1
55cdf0e10cSrcweir #define FNT_NUMBER		2
56cdf0e10cSrcweir #define FNT_TEXT		3
57cdf0e10cSrcweir #define FNT_SERIF		4
58cdf0e10cSrcweir #define FNT_SANS		5
59cdf0e10cSrcweir #define FNT_FIXED		6
60cdf0e10cSrcweir #define FNT_MATH		7
61cdf0e10cSrcweir #define FNT_END			7
62cdf0e10cSrcweir 
63cdf0e10cSrcweir // symbolic names used as array indices
64cdf0e10cSrcweir #define DIS_BEGIN				 0
65cdf0e10cSrcweir #define DIS_HORIZONTAL			 0
66cdf0e10cSrcweir #define DIS_VERTICAL			 1
67cdf0e10cSrcweir #define DIS_ROOT				 2
68cdf0e10cSrcweir #define DIS_SUPERSCRIPT 		 3
69cdf0e10cSrcweir #define DIS_SUBSCRIPT			 4
70cdf0e10cSrcweir #define DIS_NUMERATOR			 5
71cdf0e10cSrcweir #define DIS_DENOMINATOR 		 6
72cdf0e10cSrcweir #define DIS_FRACTION			 7
73cdf0e10cSrcweir #define DIS_STROKEWIDTH 		 8
74cdf0e10cSrcweir #define DIS_UPPERLIMIT			 9
75cdf0e10cSrcweir #define DIS_LOWERLIMIT			10
76cdf0e10cSrcweir #define DIS_BRACKETSIZE 		11
77cdf0e10cSrcweir #define DIS_BRACKETSPACE		12
78cdf0e10cSrcweir #define DIS_MATRIXROW			13
79cdf0e10cSrcweir #define DIS_MATRIXCOL			14
80cdf0e10cSrcweir #define DIS_ORNAMENTSIZE		15
81cdf0e10cSrcweir #define DIS_ORNAMENTSPACE		16
82cdf0e10cSrcweir #define DIS_OPERATORSIZE		17
83cdf0e10cSrcweir #define DIS_OPERATORSPACE		18
84cdf0e10cSrcweir #define DIS_LEFTSPACE			19
85cdf0e10cSrcweir #define DIS_RIGHTSPACE			20
86cdf0e10cSrcweir #define DIS_TOPSPACE			21
87cdf0e10cSrcweir #define DIS_BOTTOMSPACE			22
88cdf0e10cSrcweir #define DIS_NORMALBRACKETSIZE	23
89cdf0e10cSrcweir #define DIS_END					23
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // to be broadcastet on format changes:
93cdf0e10cSrcweir #define HINT_FORMATCHANGED	10003
94cdf0e10cSrcweir 
95cdf0e10cSrcweir enum SmHorAlign	{ AlignLeft, AlignCenter, AlignRight };
96cdf0e10cSrcweir 
97cdf0e10cSrcweir String GetDefaultFontName( LanguageType nLang, sal_uInt16 nIdent );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir class SmFormat : public SfxBroadcaster
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	SmFace		vFont[FNT_END + 1];
102cdf0e10cSrcweir     sal_Bool        bDefaultFont[FNT_END + 1];
103cdf0e10cSrcweir 	Size		aBaseSize;
104cdf0e10cSrcweir 	long		nVersion;
105cdf0e10cSrcweir 	sal_uInt16		vSize[SIZ_END + 1];
106cdf0e10cSrcweir 	sal_uInt16		vDist[DIS_END + 1];
107cdf0e10cSrcweir 	SmHorAlign	eHorAlign;
108cdf0e10cSrcweir     sal_Int16       nGreekCharStyle;
109cdf0e10cSrcweir 	sal_Bool		bIsTextmode,
110cdf0e10cSrcweir 				bScaleNormalBrackets;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir public:
113cdf0e10cSrcweir 	SmFormat();
SmFormat(const SmFormat & rFormat)114cdf0e10cSrcweir     SmFormat(const SmFormat &rFormat) : SfxBroadcaster() { *this = rFormat; }
115cdf0e10cSrcweir 
GetBaseSize() const116cdf0e10cSrcweir 	const Size & 	GetBaseSize() const 			{ return aBaseSize; }
SetBaseSize(const Size & rSize)117cdf0e10cSrcweir 	void			SetBaseSize(const Size &rSize)	{ aBaseSize = rSize; }
118cdf0e10cSrcweir 
GetFont(sal_uInt16 nIdent) const119cdf0e10cSrcweir 	const SmFace &  GetFont(sal_uInt16 nIdent) const { return vFont[nIdent]; }
120cdf0e10cSrcweir     void            SetFont(sal_uInt16 nIdent, const SmFace &rFont, sal_Bool bDefault = sal_False);
SetFontSize(sal_uInt16 nIdent,const Size & rSize)121cdf0e10cSrcweir     void            SetFontSize(sal_uInt16 nIdent, const Size &rSize)   { vFont[nIdent].SetSize( rSize ); }
122cdf0e10cSrcweir 
SetDefaultFont(sal_uInt16 nIdent,sal_Bool bVal)123cdf0e10cSrcweir     void            SetDefaultFont(sal_uInt16 nIdent, sal_Bool bVal)    { bDefaultFont[nIdent] = bVal; }
IsDefaultFont(sal_uInt16 nIdent) const124cdf0e10cSrcweir     sal_Bool            IsDefaultFont(sal_uInt16 nIdent) const   { return bDefaultFont[nIdent]; }
125cdf0e10cSrcweir 
GetRelSize(sal_uInt16 nIdent) const126cdf0e10cSrcweir 	sal_uInt16			GetRelSize(sal_uInt16 nIdent) const			{ return vSize[nIdent]; }
SetRelSize(sal_uInt16 nIdent,sal_uInt16 nVal)127cdf0e10cSrcweir 	void			SetRelSize(sal_uInt16 nIdent, sal_uInt16 nVal)	{ vSize[nIdent] = nVal;}
128cdf0e10cSrcweir 
GetDistance(sal_uInt16 nIdent) const129cdf0e10cSrcweir 	sal_uInt16			GetDistance(sal_uInt16 nIdent) const			{ return vDist[nIdent]; }
SetDistance(sal_uInt16 nIdent,sal_uInt16 nVal)130cdf0e10cSrcweir 	void			SetDistance(sal_uInt16 nIdent, sal_uInt16 nVal)	{ vDist[nIdent] = nVal; }
131cdf0e10cSrcweir 
GetHorAlign() const132cdf0e10cSrcweir 	SmHorAlign		GetHorAlign() const				{ return eHorAlign; }
SetHorAlign(SmHorAlign eAlign)133cdf0e10cSrcweir 	void			SetHorAlign(SmHorAlign eAlign)	{ eHorAlign = eAlign; }
134cdf0e10cSrcweir 
IsTextmode() const135cdf0e10cSrcweir 	sal_Bool			IsTextmode() const     { return bIsTextmode; }
SetTextmode(sal_Bool bVal)136cdf0e10cSrcweir 	void			SetTextmode(sal_Bool bVal) { bIsTextmode = bVal; }
137cdf0e10cSrcweir 
GetGreekCharStyle() const138cdf0e10cSrcweir     sal_Int16           GetGreekCharStyle() const     { return nGreekCharStyle; }
SetGreekCharStyle(sal_Int16 nVal)139cdf0e10cSrcweir     void            SetGreekCharStyle(sal_Int16 nVal) { nGreekCharStyle = nVal; }
140cdf0e10cSrcweir 
IsScaleNormalBrackets() const141cdf0e10cSrcweir 	sal_Bool			IsScaleNormalBrackets() const     { return bScaleNormalBrackets; }
SetScaleNormalBrackets(sal_Bool bVal)142cdf0e10cSrcweir 	void			SetScaleNormalBrackets(sal_Bool bVal) { bScaleNormalBrackets = bVal; }
143cdf0e10cSrcweir 
GetVersion() const144cdf0e10cSrcweir 	long			GetVersion() const { return nVersion; }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	//! at time (5.1) use only the lower byte!!!
SetVersion(long nVer)147cdf0e10cSrcweir 	void			SetVersion(long nVer) { nVersion = nVer; }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	SmFormat & 		operator = (const SmFormat &rFormat);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     sal_Bool            operator == (const SmFormat &rFormat) const;
152cdf0e10cSrcweir     inline sal_Bool     operator != (const SmFormat &rFormat) const;
153cdf0e10cSrcweir 
RequestApplyChanges() const154cdf0e10cSrcweir 	void RequestApplyChanges() const
155cdf0e10cSrcweir 	{
156cdf0e10cSrcweir 		((SmFormat *) this)->Broadcast(SfxSimpleHint(HINT_FORMATCHANGED));
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir 
159cdf0e10cSrcweir };
160cdf0e10cSrcweir 
operator !=(const SmFormat & rFormat) const161cdf0e10cSrcweir inline sal_Bool    SmFormat::operator != (const SmFormat &rFormat) const
162cdf0e10cSrcweir {
163cdf0e10cSrcweir     return !(*this == rFormat);
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir #endif
167cdf0e10cSrcweir 
168