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 : * Breaks override of Wordpro.
59 : ************************************************************************/
60 : #include <memory>
61 :
62 : #include "clone.hxx"
63 : #include "lwpbreaksoverride.hxx"
64 : #include "lwpobjstrm.hxx"
65 : #include "lwpatomholder.hxx"
66 :
67 40 : LwpBreaksOverride::LwpBreaksOverride()
68 : {
69 40 : m_pNextStyle = new LwpAtomHolder();
70 40 : }
71 :
72 508 : LwpBreaksOverride::LwpBreaksOverride(LwpBreaksOverride const& rOther)
73 : : LwpOverride(rOther)
74 508 : , m_pNextStyle(0)
75 : {
76 508 : std::unique_ptr<LwpAtomHolder> pNextStyle(::clone(rOther.m_pNextStyle));
77 508 : m_pNextStyle = pNextStyle.release();
78 508 : }
79 :
80 1644 : LwpBreaksOverride::~LwpBreaksOverride()
81 : {
82 548 : if( m_pNextStyle )
83 548 : delete m_pNextStyle;
84 1096 : }
85 :
86 508 : LwpBreaksOverride* LwpBreaksOverride::clone() const
87 : {
88 508 : return new LwpBreaksOverride(*this);
89 : }
90 :
91 40 : void LwpBreaksOverride::Read(LwpObjectStream *pStrm)
92 : {
93 40 : if (pStrm->QuickReadBool())
94 : {
95 40 : ReadCommon(pStrm);
96 :
97 40 : m_pNextStyle->Read(pStrm);
98 : }
99 :
100 40 : pStrm->SkipExtra();
101 40 : }
102 :
103 : //add by , 01/28/2005
104 254 : void LwpBreaksOverride::Override(LwpBreaksOverride* pOther)
105 : {
106 254 : if (m_nApply & BO_PAGEBEFORE)
107 : {
108 0 : if (IsPageBreakBeforeOverridden())
109 : {
110 0 : pOther->OverridePageBreakBefore(IsPageBreakBefore());
111 : }
112 : else
113 : {
114 0 : pOther->RevertPageBreakBefore();
115 : }
116 : }
117 254 : if (m_nApply & BO_PAGEAFTER)
118 : {
119 0 : if (IsPageBreakAfterOverridden())
120 : {
121 0 : pOther->OverridePageBreakAfter(IsPageBreakAfter());
122 : }
123 : else
124 : {
125 0 : pOther->RevertPageBreakAfter();
126 : }
127 : }
128 254 : if (m_nApply & BO_KEEPTOGETHER)
129 : {
130 254 : if (IsPageBreakWithinOverridden())
131 : {
132 254 : pOther->OverridePageBreakWithin(IsPageBreakWithin());
133 : }
134 : else
135 : {
136 0 : pOther->RevertPageBreakWithin();
137 : }
138 : }
139 254 : if (m_nApply & BO_COLBEFORE)
140 : {
141 0 : if (IsColumnBreakBeforeOverridden())
142 : {
143 0 : pOther->OverrideColumnBreakBefore(IsColumnBreakBefore());
144 : }
145 : else
146 : {
147 0 : pOther->RevertColumnBreakBefore();
148 : }
149 : }
150 254 : if (m_nApply & BO_COLAFTER)
151 : {
152 0 : if (IsColumnBreakAfterOverridden())
153 : {
154 0 : pOther->OverrideColumnBreakAfter(IsColumnBreakAfter());
155 : }
156 : else
157 : {
158 0 : pOther->RevertColumnBreakAfter();
159 : }
160 : }
161 254 : if (m_nApply & BO_KEEPPREV)
162 : {
163 0 : if (IsKeepWithPreviousOverridden())
164 : {
165 0 : pOther->OverrideKeepWithPrevious(IsKeepWithPrevious());
166 : }
167 : else
168 : {
169 0 : pOther->RevertKeepWithPrevious();
170 : }
171 : }
172 254 : if (m_nApply & BO_KEEPNEXT)
173 : {
174 0 : if (IsKeepWithNextOverridden())
175 : {
176 0 : pOther->OverrideKeepWithNext(IsKeepWithNext());
177 : }
178 : else
179 : {
180 0 : pOther->RevertKeepWithNext();
181 : }
182 : }
183 254 : if (m_nApply & BO_USENEXTSTYLE)
184 : {
185 0 : if (IsUseNextStyleOverridden())
186 : {
187 0 : pOther->OverrideUseNextStyle(IsUseNextStyle());
188 : }
189 : else
190 : {
191 0 : pOther->RevertUseNextStyle();
192 : }
193 : }
194 254 : }
195 :
196 0 : void LwpBreaksOverride::OverridePageBreakBefore(bool bVal)
197 : {
198 0 : if(bVal)
199 : {
200 0 : LwpOverride::Override(BO_PAGEBEFORE, STATE_ON);
201 : }
202 : else
203 : {
204 0 : LwpOverride::Override(BO_PAGEBEFORE, STATE_OFF);
205 : }
206 0 : }
207 0 : void LwpBreaksOverride::OverridePageBreakAfter(bool bVal)
208 : {
209 0 : if(bVal)
210 : {
211 0 : LwpOverride::Override(BO_PAGEAFTER, STATE_ON);
212 : }
213 : else
214 : {
215 0 : LwpOverride::Override(BO_PAGEAFTER, STATE_OFF);
216 : }
217 0 : }
218 254 : void LwpBreaksOverride::OverridePageBreakWithin(bool bVal)
219 : {
220 : // Note the flipped logic
221 254 : if(!bVal)
222 : {
223 254 : LwpOverride::Override(BO_KEEPTOGETHER, STATE_ON);
224 : }
225 : else
226 : {
227 0 : LwpOverride::Override(BO_KEEPTOGETHER, STATE_OFF);
228 : }
229 254 : }
230 0 : void LwpBreaksOverride::OverrideColumnBreakBefore(bool bVal)
231 : {
232 0 : if(bVal)
233 : {
234 0 : LwpOverride::Override(BO_COLBEFORE, STATE_ON);
235 : }
236 : else
237 : {
238 0 : LwpOverride::Override(BO_COLBEFORE, STATE_OFF);
239 : }
240 0 : }
241 0 : void LwpBreaksOverride::OverrideColumnBreakAfter(bool bVal)
242 : {
243 0 : if(bVal)
244 : {
245 0 : LwpOverride::Override(BO_COLAFTER, STATE_ON);
246 : }
247 : else
248 : {
249 0 : LwpOverride::Override(BO_COLAFTER, STATE_OFF);
250 : }
251 0 : }
252 0 : void LwpBreaksOverride::OverrideKeepWithNext(bool bVal)
253 : {
254 0 : if(bVal)
255 : {
256 0 : LwpOverride::Override(BO_KEEPNEXT, STATE_ON);
257 : }
258 : else
259 : {
260 0 : LwpOverride::Override(BO_KEEPNEXT, STATE_OFF);
261 : }
262 0 : }
263 0 : void LwpBreaksOverride::OverrideKeepWithPrevious(bool bVal)
264 : {
265 0 : if(bVal)
266 : {
267 0 : LwpOverride::Override(BO_KEEPPREV, STATE_ON);
268 : }
269 : else
270 : {
271 0 : LwpOverride::Override(BO_KEEPPREV, STATE_OFF);
272 : }
273 0 : }
274 0 : void LwpBreaksOverride::OverrideUseNextStyle(bool bVal)
275 : {
276 0 : if(bVal)
277 : {
278 0 : LwpOverride::Override(BO_USENEXTSTYLE, STATE_ON);
279 : }
280 : else
281 : {
282 0 : LwpOverride::Override(BO_USENEXTSTYLE, STATE_OFF);
283 : }
284 0 : }
285 : //end add
286 :
287 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|