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 : * Border stuff of Wordpro.
59 : ************************************************************************/
60 : #include "lwpborderstuff.hxx"
61 : #include "lwpstyledef.hxx"
62 : #include "lwpfilehdr.hxx"
63 : #include "lwptools.hxx"
64 :
65 98 : LwpBorderStuff::LwpBorderStuff()
66 : {
67 98 : m_nSides = 0;
68 98 : m_nValid = 0;
69 :
70 98 : m_nBoderGroupIDLeft = 0;
71 98 : m_nBoderGroupIDRight = 0;
72 98 : m_nBoderGroupIDTop = 0;
73 98 : m_nBoderGroupIDBottom = 0;
74 :
75 98 : m_nGroupIndent = 0;
76 :
77 98 : m_nWidthLeft = 0;
78 98 : m_nWidthTop = 0;
79 98 : m_nWidthRight = 0;
80 98 : m_nWidthBottom = 0;
81 98 : }
82 :
83 24 : void LwpBorderStuff::Read(LwpObjectStream *pStrm)
84 : {
85 24 : m_nSides = pStrm->QuickReaduInt16();
86 24 : if( m_nSides&LEFT )
87 : {
88 8 : m_nBoderGroupIDLeft = pStrm->QuickReaduInt16();
89 8 : m_nWidthLeft = pStrm->QuickReadInt32();
90 8 : m_aColorLeft.Read(pStrm);
91 :
92 8 : if( LwpFileHeader::m_nFileRevision < 0x000b )
93 : {
94 0 : pStrm->SeekRel(8);
95 : }
96 : }
97 :
98 24 : if( m_nSides&RIGHT )
99 : {
100 8 : m_nBoderGroupIDRight = pStrm->QuickReaduInt16();
101 8 : m_nWidthRight = pStrm->QuickReadInt32();
102 8 : m_aColorRight.Read(pStrm);
103 :
104 8 : if( LwpFileHeader::m_nFileRevision < 0x000b )
105 : {
106 0 : pStrm->SeekRel(8);
107 : }
108 : }
109 :
110 24 : if( m_nSides&TOP )
111 : {
112 16 : m_nBoderGroupIDTop = pStrm->QuickReaduInt16();
113 16 : m_nWidthTop = pStrm->QuickReadInt32();
114 16 : m_aColorTop.Read(pStrm);
115 :
116 16 : if( LwpFileHeader::m_nFileRevision < 0x000b )
117 : {
118 0 : pStrm->SeekRel(8);
119 : }
120 : }
121 :
122 24 : if( m_nSides&BOTTOM )
123 : {
124 8 : m_nBoderGroupIDBottom = pStrm->QuickReaduInt16();
125 8 : m_nWidthBottom = pStrm->QuickReadInt32();
126 8 : m_aColorBottom.Read(pStrm);
127 :
128 8 : if( LwpFileHeader::m_nFileRevision < 0x000b )
129 : {
130 0 : pStrm->SeekRel(8);
131 : }
132 : }
133 :
134 24 : m_nGroupIndent = pStrm->QuickReadInt32();
135 24 : m_nValid = pStrm->QuickReaduInt16();
136 24 : pStrm->SkipExtra();
137 :
138 24 : if( LwpFileHeader::m_nFileRevision < 0x0010 )
139 : {
140 6 : if( m_nBoderGroupIDLeft&EXTERNAL_ID )
141 : {
142 0 : m_nBoderGroupIDLeft = BGRP_SOLID;
143 : }
144 6 : if( m_nBoderGroupIDRight&EXTERNAL_ID )
145 : {
146 0 : m_nBoderGroupIDRight = BGRP_SOLID;
147 : }
148 6 : if( m_nBoderGroupIDTop&EXTERNAL_ID )
149 : {
150 0 : m_nBoderGroupIDTop = BGRP_SOLID;
151 : }
152 6 : if( m_nBoderGroupIDBottom&EXTERNAL_ID )
153 : {
154 0 : m_nBoderGroupIDBottom = BGRP_SOLID;
155 : }
156 : }
157 24 : }
158 :
159 352 : sal_Bool LwpBorderStuff::HasSide(sal_uInt16 side)
160 : {
161 352 : return m_nSides&side;
162 : }
163 :
164 352 : sal_uInt16 LwpBorderStuff::GetSideType(sal_uInt16 side)
165 : {
166 352 : switch(side)
167 : {
168 : case LEFT:
169 88 : return m_nBoderGroupIDLeft;
170 : break;
171 : case RIGHT:
172 88 : return m_nBoderGroupIDRight;
173 : break;
174 : case TOP:
175 88 : return m_nBoderGroupIDTop;
176 : break;
177 : case BOTTOM:
178 88 : return m_nBoderGroupIDBottom;
179 : break;
180 : }
181 : // FIXME: this is needed to avoid warning: control reaches end of non-void function
182 : // a better solution would be to enum value for the parameter side
183 0 : return 0;
184 : }
185 :
186 360 : LwpColor LwpBorderStuff::GetSideColor(sal_uInt16 side)
187 : {
188 360 : switch(side)
189 : {
190 : case LEFT:
191 88 : return m_aColorLeft;
192 : break;
193 : case RIGHT:
194 88 : return m_aColorRight;
195 : break;
196 : case TOP:
197 96 : return m_aColorTop;
198 : break;
199 : case BOTTOM:
200 88 : return m_aColorBottom;
201 : break;
202 : }
203 : // FIXME: this is needed to avoid warning: control reaches end of non-void function
204 : // a better solution would be to enum value for the parameter side
205 0 : return LwpColor();
206 : }
207 :
208 360 : float LwpBorderStuff::GetSideWidth(sal_uInt16 side)
209 : {
210 360 : switch(side)
211 : {
212 : case LEFT:
213 88 : return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthLeft));
214 : break;
215 : case RIGHT:
216 88 : return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthRight));
217 : break;
218 : case TOP:
219 96 : return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthTop));
220 : break;
221 : case BOTTOM:
222 88 : return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthBottom));
223 : break;
224 : }
225 : // FIXME: this is needed to avoid warning: control reaches end of non-void function
226 : // a better solution would be to enum value for the parameter side
227 0 : return 0;
228 : }
229 :
230 4 : LwpBorderStuff& LwpBorderStuff::operator = (const LwpBorderStuff& rOther)
231 : {
232 4 : m_nSides = rOther.m_nSides;
233 4 : m_nValid = rOther.m_nValid;
234 :
235 4 : m_nBoderGroupIDLeft = rOther.m_nBoderGroupIDLeft;
236 4 : m_nBoderGroupIDRight = rOther.m_nBoderGroupIDRight;
237 4 : m_nBoderGroupIDTop = rOther.m_nBoderGroupIDTop;
238 4 : m_nBoderGroupIDBottom = rOther.m_nBoderGroupIDBottom;
239 :
240 4 : m_nGroupIndent = rOther.m_nGroupIndent;
241 :
242 4 : m_nWidthLeft = rOther.m_nWidthLeft;
243 4 : m_nWidthTop = rOther.m_nWidthTop;
244 4 : m_nWidthRight = rOther.m_nWidthRight;
245 4 : m_nWidthBottom = rOther.m_nWidthBottom;
246 :
247 4 : m_aColorLeft = rOther.m_aColorLeft;
248 4 : m_aColorRight = rOther.m_aColorRight;
249 4 : m_aColorTop = rOther.m_aColorTop;
250 4 : m_aColorBottom = rOther.m_aColorBottom;
251 :
252 4 : return *this;
253 : }
254 :
255 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|