LibreOffice Module lotuswordpro (master) 1
xfborders.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 * Border object,now only used by paragraph object.
59 ************************************************************************/
60#include <xfilter/xfborders.hxx>
61#include <xfilter/xfglobal.hxx>
63
65{
66 m_bDouble = false;
67 m_bSameWidth = false;
68 m_fWidthInner = 0;
69 m_fWidthSpace = 0;
70 m_fWidthOuter = 0;
71}
72
74{
76}
77
78void XFBorder::SetWidth(double width)
79{
80 if( !m_bDouble )
81 {
82 m_fWidthInner = width;
83 m_bSameWidth = true;
84 }
85 else if (m_bSameWidth)
86 {
87 m_fWidthInner = width;
88 m_fWidthOuter = width;
89 m_fWidthSpace = width;
90 }
91}
92
93void XFBorder::SetDoubleLine(bool dual,bool bSameWidth)
94{
95 m_bDouble = dual;
96 m_bSameWidth = bSameWidth;
97}
98
99void XFBorder::SetWidthInner(double inner)
100{
101 assert(m_bDouble);
102 m_fWidthInner = inner;
103}
104
105void XFBorder::SetWidthSpace(double space)
106{
107 assert(m_bDouble);
108 m_fWidthSpace = space;
109}
110
111void XFBorder::SetWidthOuter(double outer)
112{
113 assert(m_bDouble);
114 m_fWidthOuter = outer;
115}
116
118{
119 OUString str;
120
121 if( m_bDouble )
122 {
123 str = OUString::number(m_fWidthInner) + "cm " +
124 OUString::number(m_fWidthSpace) + "cm " +
125 OUString::number(m_fWidthOuter) + "cm";
126 }
127 return str;
128}
129
131{
132 OUString str;
133
134 if( m_bDouble )
135 {
136 double width = m_fWidthInner + m_fWidthSpace + m_fWidthOuter;
137 if( width<FLOAT_MIN )
138 {
139 return str;
140 }
141
142 str = OUString::number(width) + "cm double " + m_aColor.ToString();
143 }
144 else
145 {
146 double width = m_fWidthInner;
147 if( width<FLOAT_MIN )
148 {
149 return str;
150 }
151 str = OUString::number(width) + "cm solid " + m_aColor.ToString();
152 }
153 return str;
154}
155
156bool operator==(XFBorder const & b1, XFBorder const & b2)
157{
158 if( b1.m_bDouble != b2.m_bDouble )
159 return false;
160 if( !b1.m_bDouble )
161 {
162 if( b1.m_fWidthInner != b2.m_fWidthInner )
163 return false;
164 }
165 else
166 {
167 if( b1.m_bSameWidth != b2.m_bSameWidth )
168 return true;
169 if( b1.m_fWidthInner != b2.m_fWidthInner ||
170 b1.m_fWidthSpace != b2.m_fWidthSpace ||
172 )
173 return false;
174 }
175 if( b1.m_aColor != b2.m_aColor )
176 return false;
177 return true;
178}
179
180bool operator!=(XFBorder const & b1, XFBorder const & b2)
181{
182 return !(b1 == b2);
183}
184
185//XFBorders:
186
188{
189 switch(side)
190 {
191 case enumXFBorderLeft:
193 break;
196 break;
197 case enumXFBorderTop:
199 break;
202 break;
203 default:
204 break;
205 }
206}
207
208void XFBorders::SetWidth(enumXFBorder side, double width)
209{
210 switch(side)
211 {
212 case enumXFBorderLeft:
213 m_aBorderLeft.SetWidth(width);
214 break;
217 break;
218 case enumXFBorderTop:
219 m_aBorderTop.SetWidth(width);
220 break;
223 break;
224 default:
225 break;
226 }
227}
228
230{
231 switch(side)
232 {
233 case enumXFBorderLeft:
234 m_aBorderLeft.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
235 break;
237 m_aBorderRight.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
238 break;
239 case enumXFBorderTop:
240 m_aBorderTop.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
241 break;
243 m_aBorderBottom.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
244 break;
245 default:
246 break;
247 }
248}
249
251{
252 switch(side)
253 {
254 case enumXFBorderLeft:
256 break;
259 break;
260 case enumXFBorderTop:
262 break;
265 break;
266 default:
267 break;
268 }
269}
270
272{
273 switch(side)
274 {
275 case enumXFBorderLeft:
277 break;
280 break;
281 case enumXFBorderTop:
283 break;
286 break;
287 default:
288 break;
289 }
290}
291
293{
294 switch(side)
295 {
296 case enumXFBorderLeft:
298 break;
301 break;
302 case enumXFBorderTop:
304 break;
307 break;
308 default:
309 break;
310 }
311}
312
313bool operator ==(XFBorders const & b1, XFBorders const & b2)
314{
315 if( b1.m_aBorderLeft != b2.m_aBorderLeft )
316 return false;
317 if( b1.m_aBorderRight != b2.m_aBorderRight )
318 return false;
319 if( b1.m_aBorderTop != b2.m_aBorderTop )
320 return false;
321 if( b1.m_aBorderBottom != b2.m_aBorderBottom )
322 return false;
323 return true;
324}
325
326bool operator!=(XFBorders const & b1, XFBorders const & b2)
327{
328 return !(b1 == b2);
329}
330
332{
333 IXFAttrList *pAttrList = pStrm->GetAttrList();
334
335 if( !m_aBorderLeft.GetLineWidth().isEmpty() )
336 pAttrList->AddAttribute( "style:border-line-width-left", m_aBorderLeft.GetLineWidth() );
337 if( !m_aBorderRight.GetLineWidth().isEmpty() )
338 pAttrList->AddAttribute( "style:border-line-width-right", m_aBorderRight.GetLineWidth() );
339 if( !m_aBorderTop.GetLineWidth().isEmpty() )
340 pAttrList->AddAttribute( "style:border-line-width-top", m_aBorderTop.GetLineWidth() );
341 if( !m_aBorderBottom.GetLineWidth().isEmpty() )
342 pAttrList->AddAttribute( "style:border-line-width-bottom", m_aBorderBottom.GetLineWidth() );
343
344 if( !m_aBorderLeft.ToString().isEmpty() )
345 pAttrList->AddAttribute( "fo:border-left", m_aBorderLeft.ToString() );
346 else
347 pAttrList->AddAttribute( "fo:border-left", "none" );
348
349 if( !m_aBorderRight.ToString().isEmpty() )
350 pAttrList->AddAttribute( "fo:border-right", m_aBorderRight.ToString() );
351 else
352 pAttrList->AddAttribute( "fo:border-right", "none" );
353
354 if( !m_aBorderTop.ToString().isEmpty() )
355 pAttrList->AddAttribute( "fo:border-top", m_aBorderTop.ToString() );
356 else
357 pAttrList->AddAttribute( "fo:border-top", "none" );
358
359 if( !m_aBorderBottom.ToString().isEmpty() )
360 pAttrList->AddAttribute( "fo:border-bottom", m_aBorderBottom.ToString() );
361 else
362 pAttrList->AddAttribute( "fo:border-bottom", "none" );
363
364}
365
366/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
Single border object for all objects with borders.
Definition: xfborders.hxx:72
void SetColor(XFColor const &color)
@descr Set border color.
Definition: xfborders.cxx:73
void SetWidth(double width)
@descr Set border width in cm.
Definition: xfborders.cxx:78
void SetWidthInner(double inner)
@descr Set inner line width for border with double line.
Definition: xfborders.cxx:99
OUString GetLineWidth()
@descr First line width to OOo border width format.
Definition: xfborders.cxx:117
void SetWidthOuter(double outer)
@descr Set outer line width for border with double line.
Definition: xfborders.cxx:111
bool m_bSameWidth
Definition: xfborders.hxx:122
OUString ToString()
Definition: xfborders.cxx:130
bool m_bDouble
Definition: xfborders.hxx:121
double m_fWidthSpace
Definition: xfborders.hxx:124
void SetDoubleLine(bool dual, bool bSameWidth)
@descr Set whether the border has double line.
Definition: xfborders.cxx:93
XFColor m_aColor
Definition: xfborders.hxx:120
double m_fWidthInner
Definition: xfborders.hxx:123
void SetWidthSpace(double space)
@descr Set space between double lines of border.
Definition: xfborders.cxx:105
double m_fWidthOuter
Definition: xfborders.hxx:125
Borders for object with borders.
Definition: xfborders.hxx:134
void SetWidthSpace(enumXFBorder side, double space)
@descr Set space between two borders of border side.
Definition: xfborders.cxx:271
void SetColor(enumXFBorder side, XFColor const &color)
@descr Set color of border side.
Definition: xfborders.cxx:187
void SetWidthOuter(enumXFBorder side, double outer)
@descr Set outer border width of border side.
Definition: xfborders.cxx:292
XFBorder m_aBorderBottom
Definition: xfborders.hxx:186
XFBorder m_aBorderTop
Definition: xfborders.hxx:185
XFBorder m_aBorderLeft
Definition: xfborders.hxx:183
void ToXml(IXFStream *pStrm)
Definition: xfborders.cxx:331
void SetDoubleLine(enumXFBorder side)
@descr Set border side as double line.
Definition: xfborders.cxx:229
void SetWidth(enumXFBorder side, double width)
@descr Set width or border side.
Definition: xfborders.cxx:208
void SetWidthInner(enumXFBorder side, double inner)
@descr Set inner border with of border side.
Definition: xfborders.cxx:250
XFBorder m_aBorderRight
Definition: xfborders.hxx:184
Color object.
Definition: xfcolor.hxx:70
OUString ToString() const
Definition: xfcolor.cxx:63
bool operator!=(XFBorder const &b1, XFBorder const &b2)
Definition: xfborders.cxx:180
bool operator==(XFBorder const &b1, XFBorder const &b2)
Definition: xfborders.cxx:156
enumXFBorder
Definition: xfdefs.hxx:194
@ enumXFBorderLeft
Definition: xfdefs.hxx:196
@ enumXFBorderRight
Definition: xfdefs.hxx:197
@ enumXFBorderBottom
Definition: xfdefs.hxx:199
@ enumXFBorderTop
Definition: xfdefs.hxx:198
#define FLOAT_MIN
Definition: xfglobal.hxx:66