LibreOffice Module lotuswordpro (master) 1
lwpborderstuff.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 stuff of Wordpro.
59************************************************************************/
60#include "lwpborderstuff.hxx"
61#include "lwpstyledef.hxx"
62#include <lwpfilehdr.hxx>
63#include <lwptools.hxx>
64
66 : m_nSides(0), m_nValid(0),
67 m_nBorderGroupIDLeft(0),
68 m_nBorderGroupIDRight(0),
69 m_nBorderGroupIDTop(0),
70 m_nBorderGroupIDBottom(0),
71 m_nGroupIndent(0),
72 m_nWidthLeft(0),
73 m_nWidthTop(0),
74 m_nWidthRight(0),
75 m_nWidthBottom(0)
76{
77}
78
80{
81 m_nSides = pStrm->QuickReaduInt16();
82 if( m_nSides&LEFT )
83 {
86 m_aColorLeft.Read(pStrm);
87
89 {
90 pStrm->SeekRel(8);
91 }
92 }
93
94 if( m_nSides&RIGHT )
95 {
98 m_aColorRight.Read(pStrm);
99
100 if( LwpFileHeader::m_nFileRevision < 0x000b )
101 {
102 pStrm->SeekRel(8);
103 }
104 }
105
106 if( m_nSides&TOP )
107 {
109 m_nWidthTop = pStrm->QuickReadInt32();
110 m_aColorTop.Read(pStrm);
111
112 if( LwpFileHeader::m_nFileRevision < 0x000b )
113 {
114 pStrm->SeekRel(8);
115 }
116 }
117
118 if( m_nSides&BOTTOM )
119 {
122 m_aColorBottom.Read(pStrm);
123
124 if( LwpFileHeader::m_nFileRevision < 0x000b )
125 {
126 pStrm->SeekRel(8);
127 }
128 }
129
131 m_nValid = pStrm->QuickReaduInt16();
132 pStrm->SkipExtra();
133
134 if( LwpFileHeader::m_nFileRevision >= 0x0010 )
135 return;
136
138 {
140 }
142 {
144 }
146 {
148 }
150 {
152 }
153}
154
155bool LwpBorderStuff::HasSide(sal_uInt16 side)
156{
157 return (m_nSides & side) != 0;
158}
159
160sal_uInt16 LwpBorderStuff::GetSideType(sal_uInt16 side)
161{
162 switch(side)
163 {
164 case LEFT:
166 case RIGHT:
168 case TOP:
169 return m_nBorderGroupIDTop;
170 case BOTTOM:
172 }
173 // FIXME: this is needed to avoid warning: control reaches end of non-void function
174 // a better solution would be to enum value for the parameter side
175 return 0;
176}
177
179{
180 switch(side)
181 {
182 case LEFT:
183 return m_aColorLeft;
184 case RIGHT:
185 return m_aColorRight;
186 case TOP:
187 return m_aColorTop;
188 case BOTTOM:
189 return m_aColorBottom;
190 }
191 // FIXME: this is needed to avoid warning: control reaches end of non-void function
192 // a better solution would be to enum value for the parameter side
193 return LwpColor();
194}
195
196float LwpBorderStuff::GetSideWidth(sal_uInt16 side)
197{
198 switch(side)
199 {
200 case LEFT:
202 case RIGHT:
204 case TOP:
206 case BOTTOM:
208 }
209 // FIXME: this is needed to avoid warning: control reaches end of non-void function
210 // a better solution would be to enum value for the parameter side
211 return 0;
212}
213
214/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Read(LwpObjectStream *pStrm)
LwpColor m_aColorRight
sal_Int32 m_nWidthRight
sal_Int32 m_nGroupIndent
float GetSideWidth(sal_uInt16 side)
sal_uInt16 m_nBorderGroupIDLeft
sal_Int32 m_nWidthTop
sal_uInt16 m_nBorderGroupIDBottom
sal_uInt16 m_nSides
sal_Int32 m_nWidthLeft
sal_uInt16 m_nValid
sal_uInt16 GetSideType(sal_uInt16 side)
LwpColor GetSideColor(sal_uInt16 side)
LwpColor m_aColorBottom
sal_uInt16 m_nBorderGroupIDTop
bool HasSide(sal_uInt16 side)
sal_Int32 m_nWidthBottom
sal_uInt16 m_nBorderGroupIDRight
lwpcolor class (red, green, blue, extra)
Definition: lwpcolor.hxx:71
void Read(LwpObjectStream *pStrm)
@descr read color and then resolve the RGB values
Definition: lwpcolor.cxx:74
static sal_uInt16 m_nFileRevision
Definition: lwpfilehdr.hxx:77
stream class for LwpObject body data provide stream like interface to read object data
Definition: lwpobjstrm.hxx:77
sal_uInt16 QuickReaduInt16(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
Definition: lwpobjstrm.cxx:200
void SkipExtra()
@descr skip extra bytes
Definition: lwpobjstrm.cxx:258
void SeekRel(sal_uInt16 pos)
@descr SeekRel pos in object stream/buffer
Definition: lwpobjstrm.cxx:160
sal_Int32 QuickReadInt32()
@descr Quick read sal_Int32
Definition: lwpobjstrm.cxx:211
static double ConvertToMetric(double fInch)
Definition: lwptools.hxx:113
static double ConvertFromUnits(sal_Int32 nUnits)
Definition: lwptools.hxx:109
#define EXTERNAL_ID
Definition: lwpstyledef.hxx:61
#define BGRP_SOLID
Definition: lwpstyledef.hxx:92