1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: format.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <svtools/smplhint.hxx>
35 #include <svtools/brdcst.hxx>
36 #include "utility.hxx"
40 #define SM_FMT_VERSION_51 ((BYTE) 0x01)
41 #define SM_FMT_VERSION_NOW SM_FMT_VERSION_51
43 #define FNTNAME_TIMES "Times New Roman"
44 #define FNTNAME_HELV "Helvetica"
45 #define FNTNAME_COUR "Courier"
46 #define FNTNAME_MATH FONTNAME_MATH
49 // symbolic names used as array indices
53 #define SIZ_FUNCTION 2
54 #define SIZ_OPERATOR 3
58 // symbolic names used as array indices
60 #define FNT_VARIABLE 0
61 #define FNT_FUNCTION 1
70 // symbolic names used as array indices
72 #define DIS_HORIZONTAL 0
73 #define DIS_VERTICAL 1
75 #define DIS_SUPERSCRIPT 3
76 #define DIS_SUBSCRIPT 4
77 #define DIS_NUMERATOR 5
78 #define DIS_DENOMINATOR 6
79 #define DIS_FRACTION 7
80 #define DIS_STROKEWIDTH 8
81 #define DIS_UPPERLIMIT 9
82 #define DIS_LOWERLIMIT 10
83 #define DIS_BRACKETSIZE 11
84 #define DIS_BRACKETSPACE 12
85 #define DIS_MATRIXROW 13
86 #define DIS_MATRIXCOL 14
87 #define DIS_ORNAMENTSIZE 15
88 #define DIS_ORNAMENTSPACE 16
89 #define DIS_OPERATORSIZE 17
90 #define DIS_OPERATORSPACE 18
91 #define DIS_LEFTSPACE 19
92 #define DIS_RIGHTSPACE 20
93 #define DIS_TOPSPACE 21
94 #define DIS_BOTTOMSPACE 22
95 #define DIS_NORMALBRACKETSIZE 23
99 // to be broadcastet on format changes:
100 #define HINT_FORMATCHANGED 10003
102 enum SmHorAlign
{ AlignLeft
, AlignCenter
, AlignRight
};
104 String
GetDefaultFontName( LanguageType nLang
, USHORT nIdent
);
106 class SmFormat
: public SfxBroadcaster
108 SmFace vFont
[FNT_END
+ 1];
109 BOOL bDefaultFont
[FNT_END
+ 1];
112 USHORT vSize
[SIZ_END
+ 1];
113 USHORT vDist
[DIS_END
+ 1];
114 SmHorAlign eHorAlign
;
116 bScaleNormalBrackets
;
120 SmFormat(const SmFormat
&rFormat
) : SfxBroadcaster() { *this = rFormat
; }
122 const Size
& GetBaseSize() const { return aBaseSize
; }
123 void SetBaseSize(const Size
&rSize
) { aBaseSize
= rSize
; }
125 const SmFace
& GetFont(USHORT nIdent
) const { return vFont
[nIdent
]; }
126 void SetFont(USHORT nIdent
, const SmFace
&rFont
, BOOL bDefault
= FALSE
);
127 void SetFontSize(USHORT nIdent
, const Size
&rSize
) { vFont
[nIdent
].SetSize( rSize
); }
129 void SetDefaultFont(USHORT nIdent
, BOOL bVal
) { bDefaultFont
[nIdent
] = bVal
; }
130 BOOL
IsDefaultFont(USHORT nIdent
) const { return bDefaultFont
[nIdent
]; }
132 USHORT
GetRelSize(USHORT nIdent
) const { return vSize
[nIdent
]; }
133 void SetRelSize(USHORT nIdent
, USHORT nVal
) { vSize
[nIdent
] = nVal
;}
135 USHORT
GetDistance(USHORT nIdent
) const { return vDist
[nIdent
]; }
136 void SetDistance(USHORT nIdent
, USHORT nVal
) { vDist
[nIdent
] = nVal
; }
138 SmHorAlign
GetHorAlign() const { return eHorAlign
; }
139 void SetHorAlign(SmHorAlign eAlign
) { eHorAlign
= eAlign
; }
141 BOOL
IsTextmode() const { return bIsTextmode
; }
142 void SetTextmode(BOOL bVal
) { bIsTextmode
= bVal
; }
144 BOOL
IsScaleNormalBrackets() const { return bScaleNormalBrackets
; }
145 void SetScaleNormalBrackets(BOOL bVal
) { bScaleNormalBrackets
= bVal
; }
147 long GetVersion() const { return nVersion
; }
149 //! at time (5.1) use only the lower byte!!!
150 void SetVersion(long nVer
) { nVersion
= nVer
; }
152 SmFormat
& operator = (const SmFormat
&rFormat
);
154 BOOL
operator == (const SmFormat
&rFormat
) const;
155 inline BOOL
operator != (const SmFormat
&rFormat
) const;
157 void RequestApplyChanges() const
159 ((SmFormat
*) this)->Broadcast(SfxSimpleHint(HINT_FORMATCHANGED
));
164 inline BOOL
SmFormat::operator != (const SmFormat
&rFormat
) const
166 return !(*this == rFormat
);