LibreOffice Module lotuswordpro (master) 1
lwpparaborderoverride.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 override of Wordpro.
59************************************************************************/
60#include <memory>
61
62#include "clone.hxx"
64#include "lwpborderstuff.hxx"
65#include "lwpshadow.hxx"
66#include "lwpmargins.hxx"
67#include <sal/log.hxx>
68
70{
71 m_pBorderStuff.reset(new LwpBorderStuff());
73 m_pShadow.reset(new LwpShadow());
74 m_pMargins.reset(new LwpMargins());
75
80
81 m_nAboveWidth = 0;
82 m_nBelowWidth = 0;
84 m_nRightWidth = 0;
85
87}
88
90 : LwpOverride(rOther)
91 , m_eAboveType(rOther.m_eAboveType)
92 , m_eBelowType(rOther.m_eBelowType)
93 , m_eRightType(rOther.m_eRightType)
94 , m_eBetweenType(rOther.m_eBetweenType)
95 , m_nAboveWidth(rOther.m_nAboveWidth)
96 , m_nBelowWidth(rOther.m_nBelowWidth)
97 , m_nBetweenWidth(rOther.m_nBetweenWidth)
98 , m_nRightWidth(rOther.m_nRightWidth)
99 , m_nBetweenMargin(rOther.m_nBetweenMargin)
100{
101 m_pBorderStuff.reset(::clone(rOther.m_pBorderStuff.get()));
102 m_pBetweenStuff.reset(::clone(rOther.m_pBetweenStuff.get()));
103 m_pShadow.reset(::clone(rOther.m_pShadow.get()));
104 m_pMargins.reset(::clone(rOther.m_pMargins.get()));
105}
106
108
110{
111 return new LwpParaBorderOverride(*this);
112}
113
114namespace
115{
117{
118 sal_uInt16 n = stream->QuickReaduInt16();
120 {
121 SAL_WARN("lwp", "bad BorderWidthType " << n);
123 }
124 return static_cast<LwpParaBorderOverride::BorderWidthType>(n);
125}
126}
127
129{
130 if (pStrm->QuickReadBool())
131 {
132 ReadCommon(pStrm);
133 //start here:
134 m_pBorderStuff->Read(pStrm);
135 m_pShadow->Read(pStrm);
136 m_pMargins->Read(pStrm);
137
138 m_eAboveType = readBorderWidthType(pStrm);
139 m_eBelowType = readBorderWidthType(pStrm);
140 m_eRightType = readBorderWidthType(pStrm);
141
142 if (pStrm->CheckExtra())
143 {
144 m_pBetweenStuff->Read(pStrm);
145
146 m_eBetweenType = readBorderWidthType(pStrm);
149
150 if (pStrm->CheckExtra())
151 {
152 m_eRightType = readBorderWidthType(pStrm);
154 }
155 }
156 }
157
158 pStrm->SkipExtra();
159}
160
162{
163 if (m_nApply & PBO_STUFF)
164 {
166 {
167 pOther->OverrideBorderStuff(m_pBorderStuff.get());
168 }
169 else
170 {
171 pOther->RevertBorderStuff();
172 }
173 }
174
176 {
178 {
180 }
181 else
182 {
183 pOther->RevertBetweenStuff();
184 }
185 }
186
187 if (m_nApply & PBO_SHADOW)
188 {
189 if (IsShadowOverridden())
190 {
191 pOther->OverrideShadow(m_pShadow.get());
192 }
193 else
194 {
195 pOther->RevertShadow();
196 }
197 }
198
199 if (m_nApply & PBO_MARGINS)
200 {
202 {
203 pOther->OverrideMargins(m_pMargins.get());
204 }
205 else
206 {
207 pOther->RevertMargins();
208 }
209 }
210
212 {
214 {
216 }
217 else
218 {
219 pOther->RevertAboveType();
220 }
221 }
222
224 {
226 {
228 }
229 else
230 {
231 pOther->RevertBelowType();
232 }
233 }
234
236 {
238 {
240 }
241 else
242 {
243 pOther->RevertRightType();
244 }
245 }
246
248 {
250 {
252 }
253 else
254 {
255 pOther->RevertBetweenType();
256 }
257 }
258
259 if (m_nApply & PBO_ABOVE)
260 {
262 {
264 }
265 else
266 {
267 pOther->RevertAboveWidth();
268 }
269 }
270
271 if (m_nApply & PBO_BELOW)
272 {
274 {
276 }
277 else
278 {
279 pOther->RevertBelowWidth();
280 }
281 }
282
283 if (m_nApply & PBO_BETWEEN)
284 {
286 {
288 }
289 else
290 {
291 pOther->RevertBetweenWidth();
292 }
293 }
294
296 {
298 {
300 }
301 else
302 {
303 pOther->RevertBetweenMargin();
304 }
305 }
306
307 if (m_nApply & PBO_RIGHT)
308 {
310 {
312 }
313 else
314 {
315 pOther->RevertRightWidth();
316 }
317 }
318}
319
321{
322 *m_pBorderStuff = *pBorderStuff;
324}
326{
327 *m_pBetweenStuff = *pBorderStuff;
329}
331{
332 *m_pShadow = *pShadow;
334}
336{
337 *m_pMargins = *pMargins;
339}
341{
342 m_eAboveType = eNewType;
344}
346{
347 m_eBelowType = eNewType;
349}
351{
352 m_eRightType = eNewType;
354}
356{
357 m_eBetweenType = eNewType;
359}
361{
362 m_nAboveWidth = nNewWidth;
364}
366{
367 m_nBelowWidth = nNewWidth;
369}
371{
372 m_nBetweenWidth = nNewWidth;
374}
376{
377 m_nRightWidth = nNewWidth;
379}
381{
382 m_nBetweenMargin = nNewMargin;
384}
385
386/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
stream class for LwpObject body data provide stream like interface to read object data
Definition: lwpobjstrm.hxx:77
sal_uInt16 CheckExtra()
@descr check if extra bytes
Definition: lwpobjstrm.cxx:267
void SkipExtra()
@descr skip extra bytes
Definition: lwpobjstrm.cxx:258
sal_uInt32 QuickReaduInt32(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
Definition: lwpobjstrm.cxx:189
bool QuickReadBool()
@descr Quick read sal_Bool
Definition: lwpobjstrm.cxx:180
void Override(sal_uInt16 nBits, STATE eState)
Definition: lwpoverride.cxx:92
void ReadCommon(LwpObjectStream *pStrm)
Definition: lwpoverride.cxx:77
sal_uInt16 m_nApply
void OverrideBetweenWidth(sal_uInt32 nNewWidth)
void OverrideBorderStuff(LwpBorderStuff const *pBorderStuff)
void OverrideRightWidth(sal_uInt32 nNewWidth)
virtual ~LwpParaBorderOverride() override
void OverrideBetweenStuff(LwpBorderStuff const *pBorderStuff)
std::unique_ptr< LwpMargins > m_pMargins
void OverrideBetweenType(BorderWidthType eNewType)
void Override(LwpParaBorderOverride *pOther)
virtual LwpParaBorderOverride * clone() const override
std::unique_ptr< LwpShadow > m_pShadow
virtual void Read(LwpObjectStream *pStrm) override
void OverrideAboveType(BorderWidthType eNewType)
void OverrideAboveWidth(sal_uInt32 nNewWidth)
void OverrideBetweenMargin(sal_uInt32 nNewMargin)
void OverrideRightType(BorderWidthType eNewType)
void OverrideMargins(LwpMargins const *pMargins)
void OverrideBelowWidth(sal_uInt32 nNewWidth)
void OverrideBelowType(BorderWidthType eNewType)
std::unique_ptr< LwpBorderStuff > m_pBetweenStuff
std::unique_ptr< LwpBorderStuff > m_pBorderStuff
void OverrideShadow(LwpShadow const *pShadow)
Reference< XOutputStream > stream
sal_Int64 n
#define SAL_WARN(area, stream)
@ STATE_ON
Definition: lwpoverride.hxx:74