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