summaryrefslogtreecommitdiff
path: root/lotuswordpro/source/filter/xfilter/xffont.hxx
blob: d7ada0605cad83b5ce2fbadb238d7f7bf5bfe765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: IBM Corporation
 *
 *  Copyright: 2008 by IBM Corporation
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
/*************************************************************************
 * @file
 * Font object to serial to xml filter.
 ************************************************************************/
#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONT_HXX
#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONT_HXX

#include <sal/config.h>

#include <salhelper/simplereferenceobject.hxx>

#include "xfglobal.hxx"
#include "xfcolor.hxx"

#define     XFFONT_FLAG_NAME            0X00000001
#define     XFFONT_FLAG_NAME_ASIA       0X00000002
#define     XFFONT_FLAG_NAME_COMPLEX    0X00000004

#define     XFFONT_FLAG_SIZE            0X00000008
#define     XFFONT_FLAG_SIZE_ASIA       0X00000010
#define     XFFONT_FLAG_SIZE_COMPLEX    0X00000020

#define     XFFONT_FLAG_ITALIC          0X00000040
#define     XFFONT_FLAG_ITALIC_ASIA     0X00000080
#define     XFFONT_FLAG_ITALIC_COMPLEX  0X00000100

#define     XFFONT_FLAG_BOLD            0X00000200
#define     XFFONT_FLAG_BOLD_ASIA       0X00000400
#define     XFFONT_FLAG_BOLD_COMPLEX    0X00000800

#define     XFFONT_FLAG_UNDERLINE       0X00001000
#define     XFFONT_FLAG_UNDERLINECOLOR  0X00002000

#define     XFFONT_FLAG_POSITION        0X00004000
#define     XFFONT_FLAG_SCALE           0X00008000
#define     XFFONT_FLAG_CHARSPACE       0x00010000

#define     XFFONT_FLAG_COLOR           0x00020000
#define     XFFONT_FLAG_BGCOLOR         0x00040000

#define     XFFONT_FLAG_CROSSOUT        0x00080000
#define     XFFONT_FLAG_RELIEF          0x00100000
#define     XFFONT_FLAG_TRANSFORM       0x00200000
#define     XFFONT_FLAG_EMPHASIZE       0x00400000
#define     XFFONT_FLAG_OUTLINE         0x00800000
#define     XFFONT_FLAG_SHADOW          0x01000000
#define     XFFONT_FLAG_BLINK           0x02000000
#define     XFFONT_FLAG_WIDTHSCALE      0x04000000

/**
 * @descr
 * The font struct of openoffice xml filter.
 * There should be some basic members,ie:

 * font name
 * font family
 * font size
 * font italic
 * font bold
 * font underline
 * font underline color
 */
class XFFont: public salhelper::SimpleReferenceObject
{
public:
    XFFont();

public:
    /**
     * @descr   Set font name.
     */
    void    SetFontName(const OUString& name);

    /**
     * @descr   Set font name for asia locale.
     */
    void    SetFontNameAsia(const OUString& name);

    /**
     * @descr   Set font name for BIDI locale.
     */
    void    SetFontNameComplex(const OUString& name);

    /**
     * @descr   Set font size.
     */
    void    SetFontSize(sal_Int16 size);

    /**
     * @descr   Set font size for asia locale.
     */
    void    SetFontSizeAsia(sal_Int16 size);

    /**
     * @descr   Set font size for BIDI locale.
     */
    void    SetFontSizeComplex(sal_Int16 size);

    /**
     * @descr   Set whether font is italic.
     */
    void    SetItalic(bool italic = true);

    /**
     * @descr   Set whether font is italic for asia locale.
     */
    void    SetItalicAsia(bool italic);

    /**
     * @descr   Set whether font is italic for BIDI locale.
     */
    void    SetItalicComplex(bool italic);

    /**
     * @descr   Set font bold.
     */
    void    SetBold(bool bold = true);

    /**
     * @descr   Set font bold for asia locale.
     */
    void    SetBoldAsia(bool bold);

    /**
     * @descr   Set font bold for complex locale.
     */
    void    SetBoldComplex(bool bold);

    /**
     * @descr   Set underline style.
     */
    void    SetUnderline(enumXFUnderline underline,bool wordByWord=false);

    /**
     * @descr   Set crossout.
     */
    void    SetCrossout(enumXFCrossout cross,bool wordByWord=false);

    /**
     * @descr   Set font transform type,pls refer to enumXFTransform.
     */
    void    SetTransform(enumXFTransform transform);

    /**
     * @descr   Set upper script or lower script.
     */
    void    SetPosition(bool bUpperScript = true, sal_Int16 pos = 33, sal_Int16 scale = 58);

    /**
     * @descr   Set font color.
     */
    void    SetColor(XFColor& color);

    /**
     * @descr   Set font background color.
     */
    void    SetBackColor(XFColor& color);
    void    SetBackColorTransparent();

    //getter:
    enumXFTransform GetTransform();

    sal_Int16 GetFontSize();
    XFColor GetColor();

    void    ToXml(IXFStream *pStrm);

    friend bool operator==(XFFont& f1, XFFont& f2);
    friend bool operator!=(XFFont& f1, XFFont& f2);
    friend class    XFFontFactory;
private:
    virtual ~XFFont() {}

    OUString   m_strFontName;
    OUString   m_strFontNameAsia;
    OUString   m_strFontNameComplex;
    sal_Int16   m_nFontSize;
    sal_Int16   m_nFontSizeAsia;
    sal_Int16   m_nFontSizeComplex;
    bool    m_bItalic;
    bool    m_bItalicAsia;
    bool    m_bItalicComplex;
    bool    m_bBold;
    bool    m_bBoldAsia;
    bool    m_bBoldComplex;
    XFColor     m_aUnderlineColor;

    enumXFUnderline m_eUnderline;
    enumXFCrossout  m_eCrossout;
    enumXFRelief    m_eRelief;
    enumXFTransform m_eTransform;
    enumXFEmphasize m_eEmphasize;
    bool    m_bWordByWord;
    bool    m_bEmphasizeTop;
    bool    m_bOutline;
    bool    m_bShadow;
    bool    m_bBlink;
    sal_Int16   m_nPosition;
    sal_Int16   m_nScale;
    double      m_fCharSpace;
    sal_Int16   m_nWidthScale;
    XFColor     m_aColor;
    XFColor     m_aBackColor;
    //The flag defines which variable will be funtional.
    sal_uInt32  m_nFlag;
    bool    m_bTransparent;
};

inline void XFFont::SetFontName(const OUString& name)
{
    m_strFontName = name;
    m_nFlag |= XFFONT_FLAG_NAME;

    SetFontNameAsia(name);
    SetFontNameComplex(name);
}

inline void XFFont::SetFontNameAsia(const OUString& name)
{
    m_strFontNameAsia = name;
    m_nFlag |= XFFONT_FLAG_NAME_ASIA;
}

inline void XFFont::SetFontNameComplex(const OUString& name)
{
    m_strFontNameComplex = name;
    m_nFlag |= XFFONT_FLAG_NAME_COMPLEX;
}

inline void XFFont::SetFontSize(sal_Int16 size)
{
    m_nFontSize = size;
    m_nFlag |= XFFONT_FLAG_SIZE;

    SetFontSizeAsia(size);
    SetFontSizeComplex(size);
}

inline void XFFont::SetFontSizeAsia(sal_Int16 size)
{
    m_nFontSizeAsia = size;
    m_nFlag |= XFFONT_FLAG_SIZE_ASIA;
}

inline void XFFont::SetFontSizeComplex(sal_Int16 size)
{
    m_nFontSizeComplex = size;
    m_nFlag |= XFFONT_FLAG_SIZE_COMPLEX;
}

//---------Italic:
inline void XFFont::SetItalic(bool italic)
{
    m_bItalic = italic;
    m_nFlag |= XFFONT_FLAG_ITALIC;

    SetItalicAsia(italic);
    SetItalicComplex(italic);
}

inline void XFFont::SetItalicAsia(bool italic)
{
    m_bItalicAsia = italic;
    m_nFlag |= XFFONT_FLAG_ITALIC_ASIA;
}

inline void XFFont::SetItalicComplex(bool italic)
{
    m_bItalicComplex = italic;
    m_nFlag |= XFFONT_FLAG_ITALIC_COMPLEX;
}

//--------Bold
inline void XFFont::SetBold(bool bold)
{
    m_bBold = bold;
    m_nFlag |= XFFONT_FLAG_BOLD;
    SetBoldAsia(bold);
    SetBoldComplex(bold);
}

inline void XFFont::SetBoldAsia(bool bold)
{
    m_bBoldAsia = bold;
    m_nFlag |= XFFONT_FLAG_BOLD_ASIA;
}

inline void XFFont::SetBoldComplex(bool bold)
{
    m_bBoldComplex = bold;
    m_nFlag |= XFFONT_FLAG_BOLD_COMPLEX;
}

//--------Underline:
inline void XFFont::SetUnderline(enumXFUnderline underline, bool wordByWord)
{
    m_eUnderline = underline;
    m_bWordByWord = wordByWord;
    m_nFlag |= XFFONT_FLAG_UNDERLINE;
}

inline void XFFont::SetCrossout(enumXFCrossout cross, bool wordByWord)
{
    m_eCrossout = cross;
    m_bWordByWord = wordByWord;
    m_nFlag |= XFFONT_FLAG_CROSSOUT;
}

inline void XFFont::SetTransform(enumXFTransform transform)
{
    m_eTransform = transform;
    m_nFlag |= XFFONT_FLAG_TRANSFORM;
}

inline void XFFont::SetPosition(bool bUpperScript, sal_Int16 pos, sal_Int16 scale)
{
    assert(pos>=0&&pos<=100);
    assert(scale>0&&scale<=100);
    m_nFlag |= XFFONT_FLAG_POSITION;
    m_nPosition = pos;
    m_nScale = scale;
    if( bUpperScript )
    {
        if( m_nPosition <0 )
            m_nPosition = -m_nPosition;
    }
    else
    {
        if( m_nPosition >0 )
            m_nPosition = -m_nPosition;
    }
}

inline void XFFont::SetColor(XFColor& color)
{
    m_nFlag |= XFFONT_FLAG_COLOR;
    m_aColor = color;
}

inline void XFFont::SetBackColor(XFColor& color)
{
    m_bTransparent = false;
    m_nFlag |= XFFONT_FLAG_BGCOLOR;
    m_aBackColor = color;
}

inline void XFFont::SetBackColorTransparent()
{
    m_bTransparent = true;
    m_nFlag |= XFFONT_FLAG_BGCOLOR;
}

inline enumXFTransform XFFont::GetTransform()
{
    return m_eTransform;
}

inline sal_Int16 XFFont::GetFontSize()
{
    return m_nFontSize;
}

inline XFColor XFFont::GetColor()
{
    return m_aColor;
}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */