Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
12 : * GNU Lesser General Public License Version 2.1
13 : * =============================================
14 : * Copyright 2000 by Sun Microsystems, Inc.
15 : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : *
17 : * This library is free software; you can redistribute it and/or
18 : * modify it under the terms of the GNU Lesser General Public
19 : * License version 2.1, as published by the Free Software Foundation.
20 : *
21 : * This library is distributed in the hope that it will be useful,
22 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : * Lesser General Public License for more details.
25 : *
26 : * You should have received a copy of the GNU Lesser General Public
27 : * License along with this library; if not, write to the Free Software
28 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : * MA 02111-1307 USA
30 : *
31 : *
32 : * Sun Industry Standards Source License Version 1.1
33 : * =================================================
34 : * The contents of this file are subject to the Sun Industry Standards
35 : * Source License Version 1.1 (the "License"); You may not use this file
36 : * except in compliance with the License. You may obtain a copy of the
37 : * License at http://www.openoffice.org/license.html.
38 : *
39 : * Software provided under this License is provided on an "AS IS" basis,
40 : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : * See the License for the specific provisions governing your rights and
44 : * obligations concerning the Software.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /*************************************************************************
57 : * @file
58 : * Font object to serial to xml filter.
59 : ************************************************************************/
60 : #ifndef _XFFONT_HXX
61 : #define _XFFONT_HXX
62 :
63 : #include "xfglobal.hxx"
64 : #include "xfcolor.hxx"
65 :
66 : #define XFFONT_FLAG_NAME 0X00000001
67 : #define XFFONT_FLAG_NAME_ASIA 0X00000002
68 : #define XFFONT_FLAG_NAME_COMPLEX 0X00000004
69 :
70 : #define XFFONT_FLAG_SIZE 0X00000008
71 : #define XFFONT_FLAG_SIZE_ASIA 0X00000010
72 : #define XFFONT_FLAG_SIZE_COMPLEX 0X00000020
73 :
74 : #define XFFONT_FLAG_ITALIC 0X00000040
75 : #define XFFONT_FLAG_ITALIC_ASIA 0X00000080
76 : #define XFFONT_FLAG_ITALIC_COMPLEX 0X00000100
77 :
78 : #define XFFONT_FLAG_BOLD 0X00000200
79 : #define XFFONT_FLAG_BOLD_ASIA 0X00000400
80 : #define XFFONT_FLAG_BOLD_COMPLEX 0X00000800
81 :
82 : #define XFFONT_FLAG_UNDERLINE 0X00001000
83 : #define XFFONT_FLAG_UNDERLINECOLOR 0X00002000
84 :
85 : #define XFFONT_FLAG_POSITION 0X00004000
86 : #define XFFONT_FLAG_SCALE 0X00008000
87 : #define XFFONT_FLAG_CHARSPACE 0x00010000
88 :
89 : #define XFFONT_FLAG_COLOR 0x00020000
90 : #define XFFONT_FLAG_BGCOLOR 0x00040000
91 :
92 : #define XFFONT_FLAG_CROSSOUT 0x00080000
93 : #define XFFONT_FLAG_RELIEF 0x00100000
94 : #define XFFONT_FLAG_TRANSFORM 0x00200000
95 : #define XFFONT_FLAG_EMPHASIZE 0x00400000
96 : #define XFFONT_FLAG_OUTLINE 0x00800000
97 : #define XFFONT_FLAG_SHADOW 0x01000000
98 : #define XFFONT_FLAG_BLINK 0x02000000
99 : #define XFFONT_FLAG_WIDTHSCALE 0x04000000
100 :
101 : /**
102 : * @descr
103 : * The font struct of openoffice xml filter.
104 : * There should be some basic members,ie:
105 :
106 : * font name
107 : * font family
108 : * font size
109 : * font italic
110 : * font bold
111 : * font underline
112 : * font underline color
113 : */
114 248 : class XFFont
115 : {
116 : public:
117 : XFFont();
118 :
119 : public:
120 : /**
121 : * @descr Set font name.
122 : */
123 : void SetFontName(rtl::OUString name);
124 :
125 : /**
126 : * @descr Set font name for asia locale.
127 : */
128 : void SetFontNameAsia(rtl::OUString name);
129 :
130 : /**
131 : * @descr Set font name for BIDI locale.
132 : */
133 : void SetFontNameComplex(rtl::OUString name);
134 :
135 : /**
136 : * @descr Set font size.
137 : */
138 : void SetFontSize(sal_Int16 size);
139 :
140 : /**
141 : * @descr Set font size for asia locale.
142 : */
143 : void SetFontSizeAsia(sal_Int16 size);
144 :
145 : /**
146 : * @descr Set font size for BIDI locale.
147 : */
148 : void SetFontSizeComplex(sal_Int16 size);
149 :
150 : /**
151 : * @descr Set whether font is italic.
152 : */
153 : void SetItalic(sal_Bool italic = true);
154 :
155 : /**
156 : * @descr Set whether font is italic for asia locale.
157 : */
158 : void SetItalicAsia(sal_Bool italic);
159 :
160 : /**
161 : * @descr Set whether font is italic for BIDI locale.
162 : */
163 : void SetItalicComplex(sal_Bool italic);
164 :
165 : /**
166 : * @descr Set font bold.
167 : */
168 : void SetBold(sal_Bool bold = true);
169 :
170 : /**
171 : * @descr Set font bold for asia locale.
172 : */
173 : void SetBoldAsia(sal_Bool bold);
174 :
175 : /**
176 : * @descr Set font bold for complex locale.
177 : */
178 : void SetBoldComplex(sal_Bool bold);
179 :
180 : /**
181 : * @descr Set underline style.
182 : */
183 : void SetUnderline(enumXFUnderline underline,sal_Bool wordByWord=sal_False);
184 :
185 : /**
186 : * @descr Set underline color.
187 : */
188 : void SetUnderlineColor(XFColor color=XFColor(128,128,0));
189 :
190 : /**
191 : * @descr Set crossout.
192 : */
193 : void SetCrossout(enumXFCrossout cross,sal_Bool wordByWord=sal_False);
194 :
195 : /**
196 : * @descr Set font relief.
197 : */
198 : void SetRelief(enumXFRelief relief);
199 :
200 : /**
201 : * @descr Set font transform type,pls refer to enumXFTransform.
202 : */
203 : void SetTransform(enumXFTransform transform);
204 :
205 : /**
206 : * @descr Set font emphasize effect.
207 : */
208 : void SetEmphasize(enumXFEmphasize emphasize, sal_Bool top = sal_True);
209 :
210 : /**
211 : * @descr Set outline effect.
212 : */
213 : void SetOutline(sal_Bool outline);
214 :
215 : /**
216 : * @descr Set font shadow.
217 : */
218 : void SetShadow(sal_Bool shadow);
219 :
220 : /**
221 : * @descr Set font blink effect.
222 : */
223 : void SetBlink(sal_Bool blink);
224 :
225 : /**
226 : * @descr Set upper script or lower script.
227 : */
228 : void SetPosition(sal_Bool bUpperScript = sal_True, sal_Int16 pos = 33, sal_Int16 scale = 58);
229 :
230 : /**
231 : * @descr Set space between chars in percent.
232 : */
233 : void SetCharSpace(sal_Int16 space);
234 :
235 : /**
236 : * @descr Set char width scale in percent.
237 : */
238 : void SetWidthScale(sal_Int16 widthScale);
239 :
240 : /**
241 : * @descr Set font color.
242 : */
243 : void SetColor(XFColor& color);
244 :
245 : /**
246 : * @descr Set font background color.
247 : */
248 : void SetBackColor(XFColor& color);
249 : void SetBackColorTransparent();
250 :
251 : //getter:
252 : enumXFTransform GetTransform();
253 :
254 : sal_Int16 GetFontSize();
255 : XFColor GetColor();
256 :
257 : sal_uInt32 GetFlag(){ return m_nFlag; }
258 :
259 : void ToXml(IXFStream *pStrm);
260 :
261 : friend bool operator==(XFFont& f1, XFFont& f2);
262 : friend bool operator!=(XFFont& f1, XFFont& f2);
263 : friend class XFFontFactory;
264 : private:
265 : rtl::OUString m_strFontName;
266 : rtl::OUString m_strFontNameAsia;
267 : rtl::OUString m_strFontNameComplex;
268 : sal_Int16 m_nFontSize;
269 : sal_Int16 m_nFontSizeAsia;
270 : sal_Int16 m_nFontSizeComplex;
271 : sal_Bool m_bItalic;
272 : sal_Bool m_bItalicAsia;
273 : sal_Bool m_bItalicComplex;
274 : sal_Bool m_bBold;
275 : sal_Bool m_bBoldAsia;
276 : sal_Bool m_bBoldComplex;
277 : XFColor m_aUnderlineColor;
278 :
279 : enumXFUnderline m_eUnderline;
280 : enumXFCrossout m_eCrossout;
281 : enumXFRelief m_eRelief;
282 : enumXFTransform m_eTransform;
283 : enumXFEmphasize m_eEmphasize;
284 : sal_Bool m_bWordByWord;
285 : sal_Bool m_bEmphasizeTop;
286 : sal_Bool m_bOutline;
287 : sal_Bool m_bShadow;
288 : sal_Bool m_bBlink;
289 : sal_Int16 m_nPosition;
290 : sal_Int16 m_nScale;
291 : double m_fCharSpace;
292 : sal_Int16 m_nWidthScale;
293 : XFColor m_aColor;
294 : XFColor m_aBackColor;
295 : //The flag defines which variable will be funtional.
296 : sal_uInt32 m_nFlag;
297 : sal_Bool m_bTransparent;
298 : };
299 :
300 :
301 228 : inline void XFFont::SetFontName(rtl::OUString name)
302 : {
303 228 : m_strFontName = name;
304 228 : m_nFlag |= XFFONT_FLAG_NAME;
305 :
306 228 : SetFontNameAsia(name);
307 228 : SetFontNameComplex(name);
308 228 : }
309 :
310 288 : inline void XFFont::SetFontNameAsia(rtl::OUString name)
311 : {
312 288 : m_strFontNameAsia = name;
313 288 : m_nFlag |= XFFONT_FLAG_NAME_ASIA;
314 288 : }
315 :
316 228 : inline void XFFont::SetFontNameComplex(rtl::OUString name)
317 : {
318 228 : m_strFontNameComplex = name;
319 228 : m_nFlag |= XFFONT_FLAG_NAME_COMPLEX;
320 228 : }
321 :
322 : //
323 236 : inline void XFFont::SetFontSize(sal_Int16 size)
324 : {
325 236 : m_nFontSize = size;
326 236 : m_nFlag |= XFFONT_FLAG_SIZE;
327 :
328 236 : SetFontSizeAsia(size);
329 236 : SetFontSizeComplex(size);
330 236 : }
331 :
332 236 : inline void XFFont::SetFontSizeAsia(sal_Int16 size)
333 : {
334 236 : m_nFontSizeAsia = size;
335 236 : m_nFlag |= XFFONT_FLAG_SIZE_ASIA;
336 236 : }
337 :
338 236 : inline void XFFont::SetFontSizeComplex(sal_Int16 size)
339 : {
340 236 : m_nFontSizeComplex = size;
341 236 : m_nFlag |= XFFONT_FLAG_SIZE_COMPLEX;
342 236 : }
343 :
344 : //---------Italic:
345 73 : inline void XFFont::SetItalic(sal_Bool italic)
346 : {
347 73 : m_bItalic = italic;
348 73 : m_nFlag |= XFFONT_FLAG_ITALIC;
349 :
350 73 : SetItalicAsia(italic);
351 73 : SetItalicComplex(italic);
352 73 : }
353 :
354 73 : inline void XFFont::SetItalicAsia(sal_Bool italic)
355 : {
356 73 : m_bItalicAsia = italic;
357 73 : m_nFlag |= XFFONT_FLAG_ITALIC_ASIA;
358 73 : }
359 :
360 73 : inline void XFFont::SetItalicComplex(sal_Bool italic)
361 : {
362 73 : m_bItalicComplex = italic;
363 73 : m_nFlag |= XFFONT_FLAG_ITALIC_COMPLEX;
364 73 : }
365 :
366 : //--------Bold
367 89 : inline void XFFont::SetBold(sal_Bool bold)
368 : {
369 89 : m_bBold = bold;
370 89 : m_nFlag |= XFFONT_FLAG_BOLD;
371 89 : SetBoldAsia(bold);
372 89 : SetBoldComplex(bold);
373 89 : }
374 :
375 89 : inline void XFFont::SetBoldAsia(sal_Bool bold)
376 : {
377 89 : m_bBoldAsia = bold;
378 89 : m_nFlag |= XFFONT_FLAG_BOLD_ASIA;
379 89 : }
380 :
381 89 : inline void XFFont::SetBoldComplex(sal_Bool bold)
382 : {
383 89 : m_bBoldComplex = bold;
384 89 : m_nFlag |= XFFONT_FLAG_BOLD_COMPLEX;
385 89 : }
386 :
387 : //--------Underline:
388 1 : inline void XFFont::SetUnderline(enumXFUnderline underline, sal_Bool wordByWord)
389 : {
390 1 : m_eUnderline = underline;
391 1 : m_bWordByWord = wordByWord;
392 1 : m_nFlag |= XFFONT_FLAG_UNDERLINE;
393 1 : }
394 :
395 : inline void XFFont::SetUnderlineColor(XFColor color)
396 : {
397 : m_aUnderlineColor = color;
398 : m_nFlag |= XFFONT_FLAG_UNDERLINECOLOR;
399 : }
400 :
401 61 : inline void XFFont::SetCrossout(enumXFCrossout cross, sal_Bool wordByWord)
402 : {
403 61 : m_eCrossout = cross;
404 61 : m_bWordByWord = wordByWord;
405 61 : m_nFlag |= XFFONT_FLAG_CROSSOUT;
406 61 : }
407 : inline void XFFont::SetRelief(enumXFRelief relief)
408 : {
409 : m_eRelief = relief;
410 : m_nFlag |= XFFONT_FLAG_RELIEF;
411 : }
412 60 : inline void XFFont::SetTransform(enumXFTransform transform)
413 : {
414 60 : m_eTransform = transform;
415 60 : m_nFlag |= XFFONT_FLAG_TRANSFORM;
416 60 : }
417 :
418 : inline void XFFont::SetEmphasize(enumXFEmphasize emphasize, sal_Bool top)
419 : {
420 : m_eEmphasize = emphasize;
421 : m_bEmphasizeTop = top;
422 : m_nFlag |= XFFONT_FLAG_EMPHASIZE;
423 : }
424 : inline void XFFont::SetOutline(sal_Bool outline)
425 : {
426 : m_bOutline = outline;
427 : m_nFlag |= XFFONT_FLAG_OUTLINE;
428 : }
429 : inline void XFFont::SetShadow(sal_Bool shadow)
430 : {
431 : m_bShadow = shadow;
432 : m_nFlag |= XFFONT_FLAG_SHADOW;
433 : }
434 : inline void XFFont::SetBlink(sal_Bool blink)
435 : {
436 : m_bBlink = blink;
437 : m_nFlag |= XFFONT_FLAG_BLINK;
438 : }
439 :
440 2 : inline void XFFont::SetPosition(sal_Bool bUpperScript, sal_Int16 pos, sal_Int16 scale)
441 : {
442 : assert(pos>=0&&pos<=100);
443 : assert(scale>0&&scale<=100);
444 2 : m_nFlag |= XFFONT_FLAG_POSITION;
445 2 : m_nPosition = pos;
446 2 : m_nScale = scale;
447 2 : if( bUpperScript )
448 : {
449 1 : if( m_nPosition <0 )
450 0 : m_nPosition = -m_nPosition;
451 : }
452 : else
453 : {
454 1 : if( m_nPosition >0 )
455 1 : m_nPosition = -m_nPosition;
456 : }
457 2 : }
458 :
459 : inline void XFFont::SetCharSpace(sal_Int16 space)
460 : {
461 : m_nFlag |= XFFONT_FLAG_CHARSPACE;
462 : m_fCharSpace = space;
463 : }
464 :
465 : inline void XFFont::SetWidthScale(sal_Int16 widthScale)
466 : {
467 : m_nFlag |= XFFONT_FLAG_WIDTHSCALE;
468 : m_nWidthScale = widthScale;
469 : }
470 :
471 95 : inline void XFFont::SetColor(XFColor& color)
472 : {
473 95 : m_nFlag |= XFFONT_FLAG_COLOR;
474 95 : m_aColor = color;
475 95 : }
476 :
477 0 : inline void XFFont::SetBackColor(XFColor& color)
478 : {
479 0 : m_bTransparent = sal_False;
480 0 : m_nFlag |= XFFONT_FLAG_BGCOLOR;
481 0 : m_aBackColor = color;
482 0 : }
483 :
484 60 : inline void XFFont::SetBackColorTransparent()
485 : {
486 60 : m_bTransparent = sal_True;
487 60 : m_nFlag |= XFFONT_FLAG_BGCOLOR;
488 60 : }
489 :
490 60 : inline enumXFTransform XFFont::GetTransform()
491 : {
492 60 : return m_eTransform;
493 : }
494 :
495 0 : inline sal_Int16 XFFont::GetFontSize()
496 : {
497 0 : return m_nFontSize;
498 : }
499 :
500 0 : inline XFColor XFFont::GetColor()
501 : {
502 0 : return m_aColor;
503 : }
504 :
505 : #endif
506 :
507 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|