LibreOffice Module lotuswordpro (master) 1
xffont.cxx
Go to the documentation of this file.
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 ************************************************************************/
61#include <xfilter/xffont.hxx>
62#include <xfilter/xfutil.hxx>
63
65 : m_nFontSize(0)
66 , m_nFontSizeAsia(0)
67 , m_nFontSizeComplex(0)
68 , m_bItalic(false)
69 , m_bItalicAsia(false)
70 , m_bItalicComplex(false)
71 , m_bBold(false)
72 , m_bBoldAsia(false)
73 , m_bBoldComplex(false)
74 , m_eUnderline(enumXFUnderlineNone)
75 , m_eCrossout(enumXFCrossoutNone)
76 , m_eTransform(enumXFTransformNone)
77 , m_bWordByWord(false)
78 , m_nPosition(33)
79 , m_nScale(58)
80 , m_nFlag(0)
81 , m_bTransparent(false)
82{
83}
84/*
85 The Following variable are to be compared:
86 OUString m_strFontName;
87 OUString m_strFontNameAsia;
88 OUString m_strFontNameComplex;
89 sal_Int16 m_nFontSize;
90 sal_Int16 m_nFontSizeAsia;
91 sal_Int16 m_nFontSizeComplex;
92 sal_Bool m_bItalic;
93 sal_Bool m_bItalicAsia;
94 sal_Bool m_bItalicComplex;
95 sal_Bool m_bBold;
96 sal_Bool m_bBoldAsia;
97 sal_Bool m_bBoldComplex;
98 sal_Int16 m_nUnderline;
99 sal_uInt32 m_nUnderlineColor;
100
101 sal_uInt32 m_nFlag;
102*/
103bool operator==(XFFont const & f1, XFFont const & f2)
104{
105 //The most possible entry be first:
106 if( f1.m_nFlag != f2.m_nFlag )
107 return false;
108
109 if( f1.m_strFontName != f2.m_strFontName ||
112 )
113 return false;
114
115 if( f1.m_nFontSize != f2.m_nFontSize ||
118 )
119 return false;
120
121 if( f1.m_bItalic != f2.m_bItalic ||
122 f1.m_bItalicAsia != f2.m_bItalicAsia ||
124 )
125 return false;
126
127 if( f1.m_bBold != f2.m_bBold ||
128 f1.m_bBoldAsia != f2.m_bBoldAsia ||
130 )
131 return false;
132
134 {
135 if( f1.m_eUnderline != f2.m_eUnderline )
136 return false;
137 }
138
140 {
142 return false;
143 }
144
146 {
147 if( f1.m_eCrossout != f2.m_eCrossout )
148 return false;
149 }
150
152 {
153 if( f1.m_eTransform != f2.m_eTransform )
154 return false;
155 }
156
157 if( f1.m_bWordByWord != f2.m_bWordByWord )
158 return false;
159
161 {
162 if( f1.m_nPosition != f2.m_nPosition )
163 return false;
164 }
165
167 {
168 if( f1.m_nScale != f2.m_nScale )
169 return false;
170 }
171
173 {
174 if( f1.m_aColor != f2.m_aColor )
175 return false;
176 }
177
179 {
180 if( f1.m_aBackColor != f2.m_aBackColor )
181 return false;
182 }
183
184 return true;
185}
186
187bool operator!=(XFFont const & f1, XFFont const & f2)
188{
189 return !(f1==f2);
190}
191
193{
194 IXFAttrList *pAttrList = pStrm->GetAttrList();
195
197 {
198 pAttrList->AddAttribute("style:font-name",m_strFontName );
199 }
200
202 {
203 pAttrList->AddAttribute("style:font-name-asian",m_strFontNameAsia );
204 }
205
207 {
208 pAttrList->AddAttribute("style:font-name-complex", m_strFontNameComplex);
209 }
210
211 //font size:
212 if( (m_nFlag & XFFONT_FLAG_SIZE) && m_nFontSize != 0 )
213 {
214 OUString strSize = OUString::number(m_nFontSize) + "pt";
215 pAttrList->AddAttribute("fo:font-size",strSize);
216 }
218 {
219 OUString strSize = OUString::number(m_nFontSizeAsia) + "pt";
220 pAttrList->AddAttribute("style:font-size-asian",strSize);
221 }
223 {
224 OUString strSize = OUString::number(m_nFontSizeComplex) + "pt";
225 pAttrList->AddAttribute("style:font-size-complex",strSize);
226 }
227
228 //italic flag:
230 {
231 pAttrList->AddAttribute("fo:font-style", "italic");
232 }
234 {
235 pAttrList->AddAttribute("style:font-style-asian", "italic");
236 }
238 {
239 pAttrList->AddAttribute("style:font-style-complex", "italic");
240 }
241
242 //Bold flag:
243 if( (m_nFlag & XFFONT_FLAG_BOLD) && m_bBold )
244 {
245 pAttrList->AddAttribute("fo:font-weight", "bold");
246 }
248 {
249 pAttrList->AddAttribute("style:font-weight-asian", "bold");
250 }
252 {
253 pAttrList->AddAttribute("style:font-weight-complex", "bold");
254 }
255 //underline:
257 {
258 pAttrList->AddAttribute("style:text-underline", GetUnderlineName(m_eUnderline) );
260 {
261 pAttrList->AddAttribute( "style:text-underline-color", m_aUnderlineColor.ToString() );
262 }
263 else
264 pAttrList->AddAttribute( "style:text-underline-color", "font-color" );
265 }
266
267 //enumCrossoutType m_eCrossout;
269 {
270 pAttrList->AddAttribute("style:text-crossing-out", GetCrossoutName(m_eCrossout) );
271 }
272
274 {
275 if( m_bWordByWord )
276 pAttrList->AddAttribute("fo:score-spaces", "false" );
277 else
278 pAttrList->AddAttribute("fo:score-spaces", "true" );
279 }
280
282 {
283 //enumTransformSmallCap is different:
285 pAttrList->AddAttribute("fo:font-variant", GetTransformName(m_eTransform) );
286 else
287 pAttrList->AddAttribute("fo:text-transform", GetTransformName(m_eTransform) );
288 }
289
290 //position & scale:
291 if( ((m_nFlag & XFFONT_FLAG_SCALE) && m_nScale>0 ) ||
293 )
294 {
295 OUString tmp = OUString::number(m_nPosition) + "% "
296 + OUString::number(m_nScale) + "%";
297 pAttrList->AddAttribute("style:text-position", tmp );
298 }
299
300 //Color:
302 {
303 pAttrList->AddAttribute( "fo:color", m_aColor.ToString() );
304 }
305
307 {
308 if (m_bTransparent)
309 pAttrList->AddAttribute( "style:text-background-color", "transparent");
310 else
311 pAttrList->AddAttribute( "style:text-background-color", m_aBackColor.ToString() );
312 }
313}
314
315/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 m_nPosition
Attribute list interface for sax writer.
Definition: ixfattrlist.hxx:72
virtual void AddAttribute(const OUString &name, const OUString &value)=0
@descr: Add an attribute to the attribute list.
Stream wrapper for sax writer.
Definition: ixfstream.hxx:72
virtual IXFAttrList * GetAttrList()=0
@descr return the Attribute list interface.
OUString ToString() const
Definition: xfcolor.cxx:63
@descr The font struct of openoffice xml filter.
Definition: xffont.hxx:120
enumXFTransform m_eTransform
Definition: xffont.hxx:246
bool m_bWordByWord
Definition: xffont.hxx:247
XFFont()
Definition: xffont.cxx:64
bool m_bItalic
Definition: xffont.hxx:236
sal_Int16 m_nPosition
Definition: xffont.hxx:248
bool m_bItalicAsia
Definition: xffont.hxx:237
sal_Int16 m_nScale
Definition: xffont.hxx:249
XFColor m_aBackColor
Definition: xffont.hxx:251
OUString m_strFontNameComplex
Definition: xffont.hxx:232
bool m_bBoldComplex
Definition: xffont.hxx:241
OUString m_strFontName
Definition: xffont.hxx:230
sal_Int16 m_nFontSize
Definition: xffont.hxx:233
enumXFCrossout m_eCrossout
Definition: xffont.hxx:245
sal_Int16 m_nFontSizeAsia
Definition: xffont.hxx:234
XFColor m_aColor
Definition: xffont.hxx:250
bool m_bTransparent
Definition: xffont.hxx:254
OUString m_strFontNameAsia
Definition: xffont.hxx:231
sal_uInt32 m_nFlag
Definition: xffont.hxx:253
sal_Int16 m_nFontSizeComplex
Definition: xffont.hxx:235
bool m_bBoldAsia
Definition: xffont.hxx:240
bool m_bBold
Definition: xffont.hxx:239
enumXFUnderline m_eUnderline
Definition: xffont.hxx:244
bool m_bItalicComplex
Definition: xffont.hxx:238
XFColor m_aUnderlineColor
Definition: xffont.hxx:242
void ToXml(IXFStream *pStrm)
Definition: xffont.cxx:192
@ enumXFCrossoutNone
Definition: xfdefs.hxx:145
@ enumXFUnderlineNone
Definition: xfdefs.hxx:116
@ enumXFTransformSmallCaps
Definition: xfdefs.hxx:159
@ enumXFTransformNone
Definition: xfdefs.hxx:155
bool operator!=(XFFont const &f1, XFFont const &f2)
Definition: xffont.cxx:187
bool operator==(XFFont const &f1, XFFont const &f2)
Definition: xffont.cxx:103
#define XFFONT_FLAG_ITALIC
Definition: xffont.hxx:79
#define XFFONT_FLAG_SIZE_COMPLEX
Definition: xffont.hxx:77
#define XFFONT_FLAG_SIZE_ASIA
Definition: xffont.hxx:76
#define XFFONT_FLAG_UNDERLINECOLOR
Definition: xffont.hxx:88
#define XFFONT_FLAG_UNDERLINE
Definition: xffont.hxx:87
#define XFFONT_FLAG_POSITION
Definition: xffont.hxx:90
#define XFFONT_FLAG_SIZE
Definition: xffont.hxx:75
#define XFFONT_FLAG_BOLD
Definition: xffont.hxx:83
#define XFFONT_FLAG_CROSSOUT
Definition: xffont.hxx:97
#define XFFONT_FLAG_BOLD_ASIA
Definition: xffont.hxx:84
#define XFFONT_FLAG_NAME_ASIA
Definition: xffont.hxx:72
#define XFFONT_FLAG_NAME_COMPLEX
Definition: xffont.hxx:73
#define XFFONT_FLAG_BGCOLOR
Definition: xffont.hxx:95
#define XFFONT_FLAG_ITALIC_ASIA
Definition: xffont.hxx:80
#define XFFONT_FLAG_COLOR
Definition: xffont.hxx:94
#define XFFONT_FLAG_TRANSFORM
Definition: xffont.hxx:99
#define XFFONT_FLAG_SCALE
Definition: xffont.hxx:91
#define XFFONT_FLAG_NAME
Definition: xffont.hxx:71
#define XFFONT_FLAG_ITALIC_COMPLEX
Definition: xffont.hxx:81
OUString GetUnderlineName(enumXFUnderline type)
Definition: xfutil.cxx:89
OUString GetTransformName(enumXFTransform type)
Definition: xfutil.cxx:153
OUString GetCrossoutName(enumXFCrossout type)
Definition: xfutil.cxx:133