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 INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONT_HXX
61 : #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONT_HXX
62 :
63 : #include <sal/config.h>
64 :
65 : #include <salhelper/simplereferenceobject.hxx>
66 :
67 : #include "xfglobal.hxx"
68 : #include "xfcolor.hxx"
69 :
70 : #define XFFONT_FLAG_NAME 0X00000001
71 : #define XFFONT_FLAG_NAME_ASIA 0X00000002
72 : #define XFFONT_FLAG_NAME_COMPLEX 0X00000004
73 :
74 : #define XFFONT_FLAG_SIZE 0X00000008
75 : #define XFFONT_FLAG_SIZE_ASIA 0X00000010
76 : #define XFFONT_FLAG_SIZE_COMPLEX 0X00000020
77 :
78 : #define XFFONT_FLAG_ITALIC 0X00000040
79 : #define XFFONT_FLAG_ITALIC_ASIA 0X00000080
80 : #define XFFONT_FLAG_ITALIC_COMPLEX 0X00000100
81 :
82 : #define XFFONT_FLAG_BOLD 0X00000200
83 : #define XFFONT_FLAG_BOLD_ASIA 0X00000400
84 : #define XFFONT_FLAG_BOLD_COMPLEX 0X00000800
85 :
86 : #define XFFONT_FLAG_UNDERLINE 0X00001000
87 : #define XFFONT_FLAG_UNDERLINECOLOR 0X00002000
88 :
89 : #define XFFONT_FLAG_POSITION 0X00004000
90 : #define XFFONT_FLAG_SCALE 0X00008000
91 : #define XFFONT_FLAG_CHARSPACE 0x00010000
92 :
93 : #define XFFONT_FLAG_COLOR 0x00020000
94 : #define XFFONT_FLAG_BGCOLOR 0x00040000
95 :
96 : #define XFFONT_FLAG_CROSSOUT 0x00080000
97 : #define XFFONT_FLAG_RELIEF 0x00100000
98 : #define XFFONT_FLAG_TRANSFORM 0x00200000
99 : #define XFFONT_FLAG_EMPHASIZE 0x00400000
100 : #define XFFONT_FLAG_OUTLINE 0x00800000
101 : #define XFFONT_FLAG_SHADOW 0x01000000
102 : #define XFFONT_FLAG_BLINK 0x02000000
103 : #define XFFONT_FLAG_WIDTHSCALE 0x04000000
104 :
105 : /**
106 : * @descr
107 : * The font struct of openoffice xml filter.
108 : * There should be some basic members,ie:
109 :
110 : * font name
111 : * font family
112 : * font size
113 : * font italic
114 : * font bold
115 : * font underline
116 : * font underline color
117 : */
118 : class XFFont: public salhelper::SimpleReferenceObject
119 : {
120 : public:
121 : XFFont();
122 :
123 : public:
124 : /**
125 : * @descr Set font name.
126 : */
127 : void SetFontName(const OUString& name);
128 :
129 : /**
130 : * @descr Set font name for asia locale.
131 : */
132 : void SetFontNameAsia(const OUString& name);
133 :
134 : /**
135 : * @descr Set font name for BIDI locale.
136 : */
137 : void SetFontNameComplex(const OUString& name);
138 :
139 : /**
140 : * @descr Set font size.
141 : */
142 : void SetFontSize(sal_Int16 size);
143 :
144 : /**
145 : * @descr Set font size for asia locale.
146 : */
147 : void SetFontSizeAsia(sal_Int16 size);
148 :
149 : /**
150 : * @descr Set font size for BIDI locale.
151 : */
152 : void SetFontSizeComplex(sal_Int16 size);
153 :
154 : /**
155 : * @descr Set whether font is italic.
156 : */
157 : void SetItalic(bool italic = true);
158 :
159 : /**
160 : * @descr Set whether font is italic for asia locale.
161 : */
162 : void SetItalicAsia(bool italic);
163 :
164 : /**
165 : * @descr Set whether font is italic for BIDI locale.
166 : */
167 : void SetItalicComplex(bool italic);
168 :
169 : /**
170 : * @descr Set font bold.
171 : */
172 : void SetBold(bool bold = true);
173 :
174 : /**
175 : * @descr Set font bold for asia locale.
176 : */
177 : void SetBoldAsia(bool bold);
178 :
179 : /**
180 : * @descr Set font bold for complex locale.
181 : */
182 : void SetBoldComplex(bool bold);
183 :
184 : /**
185 : * @descr Set underline style.
186 : */
187 : void SetUnderline(enumXFUnderline underline,bool wordByWord=false);
188 :
189 : /**
190 : * @descr Set underline color.
191 : */
192 : void SetUnderlineColor(XFColor color=XFColor(128,128,0));
193 :
194 : /**
195 : * @descr Set crossout.
196 : */
197 : void SetCrossout(enumXFCrossout cross,bool wordByWord=false);
198 :
199 : /**
200 : * @descr Set font relief.
201 : */
202 : void SetRelief(enumXFRelief relief);
203 :
204 : /**
205 : * @descr Set font transform type,pls refer to enumXFTransform.
206 : */
207 : void SetTransform(enumXFTransform transform);
208 :
209 : /**
210 : * @descr Set font emphasize effect.
211 : */
212 : void SetEmphasize(enumXFEmphasize emphasize, bool top = true);
213 :
214 : /**
215 : * @descr Set outline effect.
216 : */
217 : void SetOutline(bool outline);
218 :
219 : /**
220 : * @descr Set font shadow.
221 : */
222 : void SetShadow(bool shadow);
223 :
224 : /**
225 : * @descr Set font blink effect.
226 : */
227 : void SetBlink(bool blink);
228 :
229 : /**
230 : * @descr Set upper script or lower script.
231 : */
232 : void SetPosition(bool bUpperScript = true, sal_Int16 pos = 33, sal_Int16 scale = 58);
233 :
234 : /**
235 : * @descr Set space between chars in percent.
236 : */
237 : void SetCharSpace(sal_Int16 space);
238 :
239 : /**
240 : * @descr Set char width scale in percent.
241 : */
242 : void SetWidthScale(sal_Int16 widthScale);
243 :
244 : /**
245 : * @descr Set font color.
246 : */
247 : void SetColor(XFColor& color);
248 :
249 : /**
250 : * @descr Set font background color.
251 : */
252 : void SetBackColor(XFColor& color);
253 : void SetBackColorTransparent();
254 :
255 : //getter:
256 : enumXFTransform GetTransform();
257 :
258 : sal_Int16 GetFontSize();
259 : XFColor GetColor();
260 :
261 : sal_uInt32 GetFlag(){ return m_nFlag; }
262 :
263 : void ToXml(IXFStream *pStrm);
264 :
265 : friend bool operator==(XFFont& f1, XFFont& f2);
266 : friend bool operator!=(XFFont& f1, XFFont& f2);
267 : friend class XFFontFactory;
268 : private:
269 516 : virtual ~XFFont() {}
270 :
271 : OUString m_strFontName;
272 : OUString m_strFontNameAsia;
273 : OUString m_strFontNameComplex;
274 : sal_Int16 m_nFontSize;
275 : sal_Int16 m_nFontSizeAsia;
276 : sal_Int16 m_nFontSizeComplex;
277 : bool m_bItalic;
278 : bool m_bItalicAsia;
279 : bool m_bItalicComplex;
280 : bool m_bBold;
281 : bool m_bBoldAsia;
282 : bool m_bBoldComplex;
283 : XFColor m_aUnderlineColor;
284 :
285 : enumXFUnderline m_eUnderline;
286 : enumXFCrossout m_eCrossout;
287 : enumXFRelief m_eRelief;
288 : enumXFTransform m_eTransform;
289 : enumXFEmphasize m_eEmphasize;
290 : bool m_bWordByWord;
291 : bool m_bEmphasizeTop;
292 : bool m_bOutline;
293 : bool m_bShadow;
294 : bool m_bBlink;
295 : sal_Int16 m_nPosition;
296 : sal_Int16 m_nScale;
297 : double m_fCharSpace;
298 : sal_Int16 m_nWidthScale;
299 : XFColor m_aColor;
300 : XFColor m_aBackColor;
301 : //The flag defines which variable will be funtional.
302 : sal_uInt32 m_nFlag;
303 : bool m_bTransparent;
304 : };
305 :
306 228 : inline void XFFont::SetFontName(const OUString& name)
307 : {
308 228 : m_strFontName = name;
309 228 : m_nFlag |= XFFONT_FLAG_NAME;
310 :
311 228 : SetFontNameAsia(name);
312 228 : SetFontNameComplex(name);
313 228 : }
314 :
315 288 : inline void XFFont::SetFontNameAsia(const OUString& name)
316 : {
317 288 : m_strFontNameAsia = name;
318 288 : m_nFlag |= XFFONT_FLAG_NAME_ASIA;
319 288 : }
320 :
321 228 : inline void XFFont::SetFontNameComplex(const OUString& name)
322 : {
323 228 : m_strFontNameComplex = name;
324 228 : m_nFlag |= XFFONT_FLAG_NAME_COMPLEX;
325 228 : }
326 :
327 236 : inline void XFFont::SetFontSize(sal_Int16 size)
328 : {
329 236 : m_nFontSize = size;
330 236 : m_nFlag |= XFFONT_FLAG_SIZE;
331 :
332 236 : SetFontSizeAsia(size);
333 236 : SetFontSizeComplex(size);
334 236 : }
335 :
336 236 : inline void XFFont::SetFontSizeAsia(sal_Int16 size)
337 : {
338 236 : m_nFontSizeAsia = size;
339 236 : m_nFlag |= XFFONT_FLAG_SIZE_ASIA;
340 236 : }
341 :
342 236 : inline void XFFont::SetFontSizeComplex(sal_Int16 size)
343 : {
344 236 : m_nFontSizeComplex = size;
345 236 : m_nFlag |= XFFONT_FLAG_SIZE_COMPLEX;
346 236 : }
347 :
348 : //---------Italic:
349 73 : inline void XFFont::SetItalic(bool italic)
350 : {
351 73 : m_bItalic = italic;
352 73 : m_nFlag |= XFFONT_FLAG_ITALIC;
353 :
354 73 : SetItalicAsia(italic);
355 73 : SetItalicComplex(italic);
356 73 : }
357 :
358 73 : inline void XFFont::SetItalicAsia(bool italic)
359 : {
360 73 : m_bItalicAsia = italic;
361 73 : m_nFlag |= XFFONT_FLAG_ITALIC_ASIA;
362 73 : }
363 :
364 73 : inline void XFFont::SetItalicComplex(bool italic)
365 : {
366 73 : m_bItalicComplex = italic;
367 73 : m_nFlag |= XFFONT_FLAG_ITALIC_COMPLEX;
368 73 : }
369 :
370 : //--------Bold
371 89 : inline void XFFont::SetBold(bool bold)
372 : {
373 89 : m_bBold = bold;
374 89 : m_nFlag |= XFFONT_FLAG_BOLD;
375 89 : SetBoldAsia(bold);
376 89 : SetBoldComplex(bold);
377 89 : }
378 :
379 89 : inline void XFFont::SetBoldAsia(bool bold)
380 : {
381 89 : m_bBoldAsia = bold;
382 89 : m_nFlag |= XFFONT_FLAG_BOLD_ASIA;
383 89 : }
384 :
385 89 : inline void XFFont::SetBoldComplex(bool bold)
386 : {
387 89 : m_bBoldComplex = bold;
388 89 : m_nFlag |= XFFONT_FLAG_BOLD_COMPLEX;
389 89 : }
390 :
391 : //--------Underline:
392 1 : inline void XFFont::SetUnderline(enumXFUnderline underline, bool wordByWord)
393 : {
394 1 : m_eUnderline = underline;
395 1 : m_bWordByWord = wordByWord;
396 1 : m_nFlag |= XFFONT_FLAG_UNDERLINE;
397 1 : }
398 :
399 : inline void XFFont::SetUnderlineColor(XFColor color)
400 : {
401 : m_aUnderlineColor = color;
402 : m_nFlag |= XFFONT_FLAG_UNDERLINECOLOR;
403 : }
404 :
405 61 : inline void XFFont::SetCrossout(enumXFCrossout cross, bool wordByWord)
406 : {
407 61 : m_eCrossout = cross;
408 61 : m_bWordByWord = wordByWord;
409 61 : m_nFlag |= XFFONT_FLAG_CROSSOUT;
410 61 : }
411 : inline void XFFont::SetRelief(enumXFRelief relief)
412 : {
413 : m_eRelief = relief;
414 : m_nFlag |= XFFONT_FLAG_RELIEF;
415 : }
416 60 : inline void XFFont::SetTransform(enumXFTransform transform)
417 : {
418 60 : m_eTransform = transform;
419 60 : m_nFlag |= XFFONT_FLAG_TRANSFORM;
420 60 : }
421 :
422 : inline void XFFont::SetEmphasize(enumXFEmphasize emphasize, bool top)
423 : {
424 : m_eEmphasize = emphasize;
425 : m_bEmphasizeTop = top;
426 : m_nFlag |= XFFONT_FLAG_EMPHASIZE;
427 : }
428 : inline void XFFont::SetOutline(bool outline)
429 : {
430 : m_bOutline = outline;
431 : m_nFlag |= XFFONT_FLAG_OUTLINE;
432 : }
433 : inline void XFFont::SetShadow(bool shadow)
434 : {
435 : m_bShadow = shadow;
436 : m_nFlag |= XFFONT_FLAG_SHADOW;
437 : }
438 : inline void XFFont::SetBlink(bool blink)
439 : {
440 : m_bBlink = blink;
441 : m_nFlag |= XFFONT_FLAG_BLINK;
442 : }
443 :
444 2 : inline void XFFont::SetPosition(bool bUpperScript, sal_Int16 pos, sal_Int16 scale)
445 : {
446 : assert(pos>=0&&pos<=100);
447 : assert(scale>0&&scale<=100);
448 2 : m_nFlag |= XFFONT_FLAG_POSITION;
449 2 : m_nPosition = pos;
450 2 : m_nScale = scale;
451 2 : if( bUpperScript )
452 : {
453 1 : if( m_nPosition <0 )
454 0 : m_nPosition = -m_nPosition;
455 : }
456 : else
457 : {
458 1 : if( m_nPosition >0 )
459 1 : m_nPosition = -m_nPosition;
460 : }
461 2 : }
462 :
463 : inline void XFFont::SetCharSpace(sal_Int16 space)
464 : {
465 : m_nFlag |= XFFONT_FLAG_CHARSPACE;
466 : m_fCharSpace = space;
467 : }
468 :
469 : inline void XFFont::SetWidthScale(sal_Int16 widthScale)
470 : {
471 : m_nFlag |= XFFONT_FLAG_WIDTHSCALE;
472 : m_nWidthScale = widthScale;
473 : }
474 :
475 95 : inline void XFFont::SetColor(XFColor& color)
476 : {
477 95 : m_nFlag |= XFFONT_FLAG_COLOR;
478 95 : m_aColor = color;
479 95 : }
480 :
481 0 : inline void XFFont::SetBackColor(XFColor& color)
482 : {
483 0 : m_bTransparent = false;
484 0 : m_nFlag |= XFFONT_FLAG_BGCOLOR;
485 0 : m_aBackColor = color;
486 0 : }
487 :
488 60 : inline void XFFont::SetBackColorTransparent()
489 : {
490 60 : m_bTransparent = true;
491 60 : m_nFlag |= XFFONT_FLAG_BGCOLOR;
492 60 : }
493 :
494 60 : inline enumXFTransform XFFont::GetTransform()
495 : {
496 60 : return m_eTransform;
497 : }
498 :
499 0 : inline sal_Int16 XFFont::GetFontSize()
500 : {
501 0 : return m_nFontSize;
502 : }
503 :
504 0 : inline XFColor XFFont::GetColor()
505 : {
506 0 : return m_aColor;
507 : }
508 :
509 : #endif
510 :
511 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|