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 override of Wordpro.
59 : ************************************************************************/
60 : #include <memory>
61 :
62 : #include "clone.hxx"
63 : #include "lwpparaborderoverride.hxx"
64 : #include "lwpborderstuff.hxx"
65 : #include "lwpshadow.hxx"
66 : #include "lwpmargins.hxx"
67 :
68 6 : LwpParaBorderOverride::LwpParaBorderOverride()
69 : {
70 6 : m_pBorderStuff = new LwpBorderStuff();
71 6 : m_pBetweenStuff = new LwpBorderStuff();
72 6 : m_pShadow = new LwpShadow();
73 6 : m_pMargins = new LwpMargins();
74 :
75 6 : m_eAboveType = PB_NONE;
76 6 : m_eBelowType = PB_NONE;
77 6 : m_eRightType = PB_NONE;
78 6 : m_eBetweenType = PB_NONE;
79 :
80 6 : m_nAboveWidth = 0;
81 6 : m_nBelowWidth = 0;
82 6 : m_nBetweenWidth = 0;
83 6 : m_nRightWidth = 0;
84 :
85 6 : m_nBetweenMargin = 0;
86 6 : }
87 :
88 4 : LwpParaBorderOverride::LwpParaBorderOverride(LwpParaBorderOverride const& rOther)
89 : : LwpOverride(rOther)
90 : , m_pBorderStuff(0)
91 : , m_pBetweenStuff(0)
92 : , m_pShadow(0)
93 : , m_pMargins(0)
94 : , m_eAboveType(rOther.m_eAboveType)
95 : , m_eBelowType(rOther.m_eBelowType)
96 : , m_eRightType(rOther.m_eRightType)
97 : , m_eBetweenType(rOther.m_eBetweenType)
98 : , m_nAboveWidth(rOther.m_nAboveWidth)
99 : , m_nBelowWidth(rOther.m_nBelowWidth)
100 : , m_nBetweenWidth(rOther.m_nBetweenWidth)
101 : , m_nRightWidth(rOther.m_nRightWidth)
102 4 : , m_nBetweenMargin(rOther.m_nBetweenMargin)
103 : {
104 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
105 4 : std::auto_ptr<LwpBorderStuff> pBorderStuff(::clone(rOther.m_pBorderStuff));
106 4 : std::auto_ptr<LwpBorderStuff> pBetweenStuff(::clone(rOther.m_pBetweenStuff));
107 4 : std::auto_ptr<LwpShadow> pShadow(::clone(rOther.m_pShadow));
108 4 : std::auto_ptr<LwpMargins> pMargins(::clone(rOther.m_pMargins));
109 : SAL_WNODEPRECATED_DECLARATIONS_POP
110 4 : m_pBorderStuff = pBorderStuff.release();
111 4 : m_pBetweenStuff = pBetweenStuff.release();
112 4 : m_pShadow = pShadow.release();
113 4 : m_pMargins = pMargins.release();
114 4 : }
115 :
116 30 : LwpParaBorderOverride::~LwpParaBorderOverride()
117 : {
118 10 : if( m_pBorderStuff )
119 10 : delete m_pBorderStuff;
120 10 : if( m_pBetweenStuff )
121 10 : delete m_pBetweenStuff;
122 10 : if( m_pShadow )
123 10 : delete m_pShadow;
124 10 : if( m_pMargins )
125 10 : delete m_pMargins;
126 20 : }
127 :
128 4 : LwpParaBorderOverride* LwpParaBorderOverride::clone() const
129 : {
130 4 : return new LwpParaBorderOverride(*this);
131 : }
132 :
133 6 : void LwpParaBorderOverride::Read(LwpObjectStream *pStrm)
134 : {
135 6 : if (pStrm->QuickReadBool())
136 : {
137 6 : ReadCommon(pStrm);
138 : //start here:
139 6 : m_pBorderStuff->Read(pStrm);
140 6 : m_pShadow->Read(pStrm);
141 6 : m_pMargins->Read(pStrm);
142 :
143 6 : m_eAboveType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
144 6 : m_eBelowType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
145 6 : m_eRightType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
146 :
147 6 : if( pStrm->CheckExtra() )
148 : {
149 0 : m_pBetweenStuff->Read(pStrm);
150 :
151 0 : m_eBetweenType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
152 0 : m_nBetweenWidth = pStrm->QuickReaduInt32();
153 0 : m_nBetweenMargin = pStrm->QuickReaduInt32();
154 :
155 0 : if( pStrm->CheckExtra() )
156 : {
157 0 : m_eRightType = static_cast<BorderWidthType>(pStrm->QuickReaduInt16());
158 0 : m_nRightWidth = pStrm->QuickReaduInt32();
159 : }
160 : }
161 : }
162 :
163 6 : pStrm->SkipExtra();
164 6 : }
165 :
166 2 : void LwpParaBorderOverride::Override(LwpParaBorderOverride* pOther)
167 : {
168 2 : if (m_nApply & PBO_STUFF)
169 : {
170 2 : if (IsBorderStuffOverridden())
171 : {
172 2 : pOther->OverrideBorderStuff(m_pBorderStuff);
173 : }
174 : else
175 : {
176 0 : pOther->RevertBorderStuff();
177 : }
178 : }
179 :
180 2 : if (m_nApply & PBO_BETWEENSTUFF)
181 : {
182 2 : if (IsBetweenStuffOverridden())
183 : {
184 2 : pOther->OverrideBetweenStuff(m_pBetweenStuff);
185 : }
186 : else
187 : {
188 0 : pOther->RevertBetweenStuff();
189 : }
190 : }
191 :
192 2 : if (m_nApply & PBO_SHADOW)
193 : {
194 1 : if (IsShadowOverridden())
195 : {
196 1 : pOther->OverrideShadow(m_pShadow);
197 : }
198 : else
199 : {
200 0 : pOther->RevertShadow();
201 : }
202 : }
203 :
204 2 : if (m_nApply & PBO_MARGINS)
205 : {
206 2 : if (IsMarginsOverridden())
207 : {
208 2 : pOther->OverrideMargins(m_pMargins);
209 : }
210 : else
211 : {
212 0 : pOther->RevertMargins();
213 : }
214 : }
215 :
216 2 : if (m_nApply & PBO_ABOVETYPE)
217 : {
218 2 : if (IsAboveTypeOverridden())
219 : {
220 2 : pOther->OverrideAboveType(m_eAboveType);
221 : }
222 : else
223 : {
224 0 : pOther->RevertAboveType();
225 : }
226 : }
227 :
228 2 : if (m_nApply & PBO_BELOWTYPE)
229 : {
230 2 : if (IsBelowTypeOverridden())
231 : {
232 2 : pOther->OverrideBelowType(m_eBelowType);
233 : }
234 : else
235 : {
236 0 : pOther->RevertBelowType();
237 : }
238 : }
239 :
240 2 : if (m_nApply & PBO_RIGHTTYPE)
241 : {
242 2 : if (IsRightTypeOverridden())
243 : {
244 2 : pOther->OverrideRightType(m_eRightType);
245 : }
246 : else
247 : {
248 0 : pOther->RevertRightType();
249 : }
250 : }
251 :
252 2 : if (m_nApply & PBO_BETWEENTYPE)
253 : {
254 2 : if (IsBetweenTypeOverridden())
255 : {
256 2 : pOther->OverrideBetweenType(m_eBetweenType);
257 : }
258 : else
259 : {
260 0 : pOther->RevertBetweenType();
261 : }
262 : }
263 :
264 2 : if (m_nApply & PBO_ABOVE)
265 : {
266 0 : if (IsAboveWidthOverridden())
267 : {
268 0 : pOther->OverrideAboveWidth(m_nAboveWidth);
269 : }
270 : else
271 : {
272 0 : pOther->RevertAboveWidth();
273 : }
274 : }
275 :
276 2 : if (m_nApply & PBO_BELOW)
277 : {
278 0 : if (IsBelowWidthOverridden())
279 : {
280 0 : pOther->OverrideBelowWidth(m_nBelowWidth);
281 : }
282 : else
283 : {
284 0 : pOther->RevertBelowWidth();
285 : }
286 : }
287 :
288 2 : if (m_nApply & PBO_BETWEEN)
289 : {
290 2 : if (IsBetweenWidthOverridden())
291 : {
292 2 : pOther->OverrideBetweenWidth(m_nBetweenWidth);
293 : }
294 : else
295 : {
296 0 : pOther->RevertBetweenWidth();
297 : }
298 : }
299 :
300 2 : if (m_nApply & PBO_BETWEENMARGIN)
301 : {
302 2 : if (IsBetweenMarginOverridden())
303 : {
304 2 : pOther->OverrideBetweenMargin(m_nBetweenMargin);
305 : }
306 : else
307 : {
308 0 : pOther->RevertBetweenMargin();
309 : }
310 : }
311 :
312 2 : if (m_nApply & PBO_RIGHT)
313 : {
314 0 : if (IsRightWidthOverridden())
315 : {
316 0 : pOther->OverrideRightWidth(m_nRightWidth);
317 : }
318 : else
319 : {
320 0 : pOther->RevertRightWidth();
321 : }
322 : }
323 2 : }
324 :
325 2 : void LwpParaBorderOverride::OverrideBorderStuff(LwpBorderStuff* pBorderStuff)
326 : {
327 2 : *m_pBorderStuff = *pBorderStuff;
328 2 : LwpOverride::Override(PBO_STUFF, STATE_ON);
329 2 : }
330 2 : void LwpParaBorderOverride::OverrideBetweenStuff(LwpBorderStuff* pBorderStuff)
331 : {
332 2 : *m_pBetweenStuff = *pBorderStuff;
333 2 : LwpOverride::Override(PBO_BETWEENSTUFF, STATE_ON);
334 2 : }
335 1 : void LwpParaBorderOverride::OverrideShadow(LwpShadow* pShadow)
336 : {
337 1 : *m_pShadow = *pShadow;
338 1 : LwpOverride::Override(PBO_SHADOW, STATE_ON);
339 1 : }
340 2 : void LwpParaBorderOverride::OverrideMargins(LwpMargins* pMargins)
341 : {
342 2 : *m_pMargins = *pMargins;
343 2 : LwpOverride::Override(PBO_MARGINS, STATE_ON);
344 2 : }
345 2 : void LwpParaBorderOverride::OverrideAboveType(BorderWidthType eNewType)
346 : {
347 2 : m_eAboveType = eNewType;
348 2 : LwpOverride::Override(PBO_ABOVETYPE, STATE_ON);
349 2 : }
350 2 : void LwpParaBorderOverride::OverrideBelowType(BorderWidthType eNewType)
351 : {
352 2 : m_eBelowType = eNewType;
353 2 : LwpOverride::Override(PBO_BELOWTYPE, STATE_ON);
354 2 : }
355 2 : void LwpParaBorderOverride::OverrideRightType(BorderWidthType eNewType)
356 : {
357 2 : m_eRightType = eNewType;
358 2 : LwpOverride::Override(PBO_RIGHTTYPE, STATE_ON);
359 2 : }
360 2 : void LwpParaBorderOverride::OverrideBetweenType(BorderWidthType eNewType)
361 : {
362 2 : m_eBetweenType = eNewType;
363 2 : LwpOverride::Override(PBO_BETWEENTYPE, STATE_ON);
364 2 : }
365 0 : void LwpParaBorderOverride::OverrideAboveWidth(sal_uInt32 nNewWidth)
366 : {
367 0 : m_nAboveWidth = nNewWidth;
368 0 : LwpOverride::Override(PBO_ABOVE, STATE_ON);
369 0 : }
370 0 : void LwpParaBorderOverride::OverrideBelowWidth(sal_uInt32 nNewWidth)
371 : {
372 0 : m_nBelowWidth = nNewWidth;
373 0 : LwpOverride::Override(PBO_BELOW, STATE_ON);
374 0 : }
375 2 : void LwpParaBorderOverride::OverrideBetweenWidth(sal_uInt32 nNewWidth)
376 : {
377 2 : m_nBetweenWidth = nNewWidth;
378 2 : LwpOverride::Override(PBO_BETWEEN, STATE_ON);
379 2 : }
380 0 : void LwpParaBorderOverride::OverrideRightWidth(sal_uInt32 nNewWidth)
381 : {
382 0 : m_nRightWidth = nNewWidth;
383 0 : LwpOverride::Override(PBO_RIGHT, STATE_ON);
384 0 : }
385 2 : void LwpParaBorderOverride::OverrideBetweenMargin(sal_uInt32 nNewMargin)
386 : {
387 2 : m_nBetweenMargin = nNewMargin;
388 2 : LwpOverride::Override(PBO_BETWEENMARGIN, STATE_ON);
389 2 : }
390 :
391 : //end
392 :
393 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|