LibreOffice Module lotuswordpro (master) 1
lwpoverride.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 * For LWP filter architecture prototype
59 ************************************************************************/
60
61#include <sal/log.hxx>
62#include <memory>
63
64#include "clone.hxx"
65#include <lwpoverride.hxx>
66#include <lwpfilehdr.hxx>
68
69/*class LwpOverride*/
71 : m_nValues(rOther.m_nValues)
72 , m_nOverride(rOther.m_nOverride)
73 , m_nApply(rOther.m_nApply)
74{
75}
76
78{
79 m_nValues = pStrm->QuickReaduInt16();
81 m_nApply = pStrm->QuickReaduInt16();
82 pStrm->SkipExtra();
83}
84
86{
87 m_nValues = 0;
88 m_nOverride = 0;
89 m_nApply = 0;
90}
91
92void LwpOverride::Override(sal_uInt16 nBits, STATE eState)
93{
94 if (eState == STATE_STYLE)
95 {
96 m_nValues &= ~nBits;
97 m_nOverride &= ~nBits;
98 }
99 else
100 {
101 m_nOverride |= nBits;
102 if (eState == STATE_ON)
103 {
104 m_nValues |= nBits;
105 }
106 else /* State == STATE_OFF */
107 {
108 m_nValues &= ~nBits;
109 }
110 }
111 m_nApply |= nBits;
112}
113
114/*class LwpTextLanguageOverride*/
116 : LwpOverride(rOther)
117 , m_nLanguage(rOther.m_nLanguage)
118{
119}
120
122{
123 return new LwpTextLanguageOverride(*this);
124}
125
127{
128 if (pStrm->QuickReadBool())
129 {
130 ReadCommon(pStrm);
131 m_nLanguage = pStrm->QuickReaduInt16();
132 }
133
134 pStrm->SkipExtra();
135}
136
137/*class LwpTextAttributeOverride*/
139 : LwpOverride(rOther)
140 , m_nHideLevels(rOther.m_nHideLevels)
141 , m_nBaseLineOffset(rOther.m_nBaseLineOffset)
142{
143}
144
146{
147 return new LwpTextAttributeOverride(*this);
148}
149
151{
152 if (pStrm->QuickReadBool())
153 {
154 ReadCommon(pStrm);
156
159 }
160
161 pStrm->SkipExtra();
162}
163
165
166/*class LwpKinsokuOptsOverride*/
168 : LwpOverride(rOther)
169 , m_nLevels(rOther.m_nLevels)
170{
171}
172
174{
175 return new LwpKinsokuOptsOverride(*this);
176}
177
179{
180 if (pStrm->QuickReadBool())
181 {
182 ReadCommon(pStrm);
183 m_nLevels = pStrm->QuickReaduInt16();
184 }
185
186 pStrm->SkipExtra();
187}
188
189/*class LwpBulletOverride*/
191 : LwpOverride(rOther)
192 , m_SilverBullet(rOther.m_SilverBullet)
193 , m_bIsNull(rOther.m_bIsNull)
194{
195}
196
198
200{
201 if (pStrm->QuickReadBool())
202 {
203 m_bIsNull = false;
204 ReadCommon(pStrm);
206 }
207 else
208 m_bIsNull = true;
209
210 pStrm->SkipExtra();
211}
213{
214 if (bOver)
215 {
217 }
218 else
219 {
221 }
222}
223
225{
226 if (bOver)
227 {
229 }
230 else
231 {
233 }
234}
235
237{
238 if (!aID.IsNull())
239 {
240 m_SilverBullet = aID;
241 }
242
244}
245
247{
249 {
251 {
253 }
254 else
255 {
256 pOther->RevertSilverBullet();
257 }
258 }
259
260 if (m_nApply & BO_SKIP)
261 {
262 if (IsSkipOverridden())
263 {
264 pOther->OverrideSkip(IsSkip());
265 }
266 else
267 {
268 pOther->RevertSkip();
269 }
270 }
271
273 {
275 {
277 }
278 else
279 {
280 pOther->RevertRightAligned();
281 }
282 }
283}
284
285/*class LwpAlignmentOverride*/
287 : LwpOverride(rOther)
288 , m_nAlignType(rOther.m_nAlignType)
289 , m_nPosition(rOther.m_nPosition)
290 , m_nAlignChar(rOther.m_nAlignChar)
291{
292}
293
295{
296 return new LwpAlignmentOverride(*this);
297}
298
300{
301 if (pStrm->QuickReadBool())
302 {
303 ReadCommon(pStrm);
304 sal_uInt8 nAlignType = pStrm->QuickReaduInt8();
305 if (nAlignType <= ALIGN_SQUEEZE)
306 m_nAlignType = static_cast<AlignType>(nAlignType);
307 else
308 SAL_WARN("lwp", "unknown align type:" << nAlignType);
309 m_nPosition = pStrm->QuickReaduInt32();
310 m_nAlignChar = pStrm->QuickReaduInt16();
311 }
312
313 pStrm->SkipExtra();
314}
315
316/*class LwpSpacingCommonOverride*/
318 : LwpOverride(rOther)
319 , m_nSpacingType(rOther.m_nSpacingType)
320 , m_nAmount(rOther.m_nAmount)
321 , m_nMultiple(rOther.m_nMultiple)
322{
323}
324
326{
327 return new LwpSpacingCommonOverride(*this);
328}
329
331{
332 if (pStrm->QuickReadBool())
333 {
334 ReadCommon(pStrm);
335 const sal_uInt16 nSpacingType = pStrm->QuickReaduInt16();
336 //only the bottom pair of bits matter
337 m_nSpacingType = static_cast<SpacingType>(nSpacingType & 0x3);
338 m_nAmount = pStrm->QuickReadInt32();
339 m_nMultiple = pStrm->QuickReadInt32();
340 }
341
342 pStrm->SkipExtra();
343}
344
345/*class LwpSpacingOverride*/
347 : m_pSpacing(new LwpSpacingCommonOverride)
348 , m_pAboveLineSpacing(new LwpSpacingCommonOverride)
349 , m_pParaSpacingAbove(new LwpSpacingCommonOverride)
350 , m_pParaSpacingBelow(new LwpSpacingCommonOverride)
351{
352}
353
355
357 : LwpOverride(rOther)
358{
359 m_pSpacing.reset(::clone(rOther.m_pSpacing.get()));
363}
364
366
368{
369 if (pStrm->QuickReadBool())
370 {
371 ReadCommon(pStrm);
372 m_pSpacing->Read(pStrm);
373 if (LwpFileHeader::m_nFileRevision >= 0x000d)
374 {
375 m_pAboveLineSpacing->Read(pStrm);
376 }
377 m_pParaSpacingAbove->Read(pStrm);
378 m_pParaSpacingBelow->Read(pStrm);
379 }
380
381 pStrm->SkipExtra();
382}
383
384/*class LwpIndentOverride*/
386 : LwpOverride(rOther)
387 , m_nAll(rOther.m_nAll)
388 , m_nFirst(rOther.m_nFirst)
389 , m_nRest(rOther.m_nRest)
390 , m_nRight(rOther.m_nRight)
391{
392}
393
395
397{
398 if (pStrm->QuickReadBool())
399 {
400 ReadCommon(pStrm);
401
402 m_nAll = pStrm->QuickReadInt32();
403 m_nFirst = pStrm->QuickReadInt32();
404 m_nRest = pStrm->QuickReadInt32();
405 m_nRight = pStrm->QuickReadInt32();
406 }
407
408 pStrm->SkipExtra();
409}
410
411/*class LwpAmikakeOverride*/
413 : m_pBackgroundStuff(new LwpBackgroundStuff)
414 , m_nType(AMIKAKE_NONE)
415{
416}
417
419
421 : LwpOverride(rOther)
422 , m_pBackgroundStuff(::clone(rOther.m_pBackgroundStuff.get()))
423 , m_nType(rOther.m_nType)
424{
425}
426
428
430{
431 if (pStrm->QuickReadBool())
432 {
433 ReadCommon(pStrm);
434 m_pBackgroundStuff->Read(pStrm);
435 }
436 else
437 {
438 Clear();
439 }
440
441 if (pStrm->CheckExtra())
442 {
443 m_nType = pStrm->QuickReaduInt16();
444 pStrm->SkipExtra();
445 }
446 else
447 {
449 }
450}
451
453{
454 if (m_nOverride & AO_TYPE)
455 {
457 }
458}
459
461{
462 m_nAlignType = val;
464}
465
467{
468 if (m_nOverride & IO_ALL)
470 if (m_nOverride & IO_FIRST)
472 if (m_nOverride & IO_RIGHT)
474 if (m_nOverride & IO_REST)
480}
481
483{
485 return RELATIVE_FIRST;
486 else if ((m_nOverride & IO_REL_FLAGS) == IO_REL_ALL)
487 return RELATIVE_ALL;
488 return RELATIVE_REST;
489}
490
492
494{
495 m_nAll = val;
497}
498
500{
501 m_nFirst = val;
503}
504
506{
507 m_nRight = val;
509}
510
512{
513 m_nRest = val;
514 // m_nAll = val;
515 // m_nFirst = 0-val;
517}
518
520{
521 if (use)
522 {
525 }
526 else
527 {
528 m_nOverride &= ~IO_USE_RELATIVE;
529 m_nValues &= ~IO_USE_RELATIVE;
530 }
531}
532
533void LwpIndentOverride::OverrideRelative(sal_uInt16 relative)
534{
535 sal_uInt16 Flag;
536
537 if (relative == RELATIVE_FIRST)
538 Flag = IO_REL_FIRST;
539 else if (relative == RELATIVE_ALL)
540 Flag = IO_REL_ALL;
541 else
542 Flag = IO_REL_REST;
543
544 m_nOverride &= ~IO_REL_FLAGS;
545 m_nOverride |= Flag;
546}
547
549{
550 if (other)
551 {
552 m_pSpacing->Override(other->GetSpacing());
553 m_pAboveLineSpacing->Override(other->GetAboveLineSpacing());
554 m_pParaSpacingAbove->Override(other->GetAboveSpacing());
555 m_pParaSpacingBelow->Override(other->GetBelowSpacing());
556 }
557}
558
560{
561 if (m_nOverride & SPO_TYPE)
567}
568
570{
571 m_nSpacingType = val;
573}
574
576{
577 m_nAmount = val;
579}
580
582{
583 m_nMultiple = val;
585}
586
587/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 m_nPosition
void OverrideAlignment(AlignType val)
void Override(LwpAlignmentOverride *other)
virtual LwpAlignmentOverride * clone() const override
void Read(LwpObjectStream *pStrm) override
virtual LwpAmikakeOverride * clone() const override
virtual ~LwpAmikakeOverride() override
void Read(LwpObjectStream *pStrm) override
std::unique_ptr< LwpBackgroundStuff > m_pBackgroundStuff
virtual LwpBulletOverride * clone() const override
bool IsRightAlignedOverridden() const
LwpObjectID m_SilverBullet
void OverrideSkip(bool bOver)
bool IsSilverBulletOverridden() const
void OverrideSilverBullet(LwpObjectID aID)
bool IsSkipOverridden() const
void Read(LwpObjectStream *pStrm) override
bool IsRightAligned() const
void OverrideRightAligned(bool bOver)
void Override(LwpBulletOverride *pOther)
bool IsSkip() const
static sal_uInt16 m_nFileRevision
Definition: lwpfilehdr.hxx:77
void Override(LwpIndentOverride *other)
void OverrideUseRelative(bool use)
virtual LwpIndentOverride * clone() const override
void OverrideIndentFirst(sal_Int32 val)
void OverrideIndentRight(sal_Int32 val)
void OverrideIndentAll(sal_Int32 val)
bool IsUseRelative() const
sal_uInt16 GetRelative() const
void Read(LwpObjectStream *pStrm) override
void OverrideRelative(sal_uInt16 relative)
void OverrideIndentRest(sal_Int32 val)
virtual LwpKinsokuOptsOverride * clone() const override
void Read(LwpObjectStream *pStrm) override
object id class
Definition: lwpobjid.hxx:79
void ReadIndexed(LwpSvStream *pStrm)
@descr Read object id with indexed format from stream if index>0, lowid is get from time table per th...
Definition: lwpobjid.cxx:96
bool IsNull() const
Definition: lwpobjid.hxx:110
stream class for LwpObject body data provide stream like interface to read object data
Definition: lwpobjstrm.hxx:77
sal_uInt16 QuickReaduInt16(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
Definition: lwpobjstrm.cxx:200
sal_uInt16 CheckExtra()
@descr check if extra bytes
Definition: lwpobjstrm.cxx:267
void SkipExtra()
@descr skip extra bytes
Definition: lwpobjstrm.cxx:258
sal_uInt8 QuickReaduInt8(bool *pFailure=nullptr)
@descr Quick read sal_uInt8
Definition: lwpobjstrm.cxx:230
sal_uInt32 QuickReaduInt32(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
Definition: lwpobjstrm.cxx:189
sal_Int32 QuickReadInt32()
@descr Quick read sal_Int32
Definition: lwpobjstrm.cxx:211
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
sal_uInt16 m_nValues
void Clear()
Definition: lwpoverride.cxx:85
sal_uInt16 m_nOverride
void Override(LwpSpacingCommonOverride *other)
void OverrideAmount(sal_Int32 val)
void Read(LwpObjectStream *pStrm) override
void OverrideMultiple(sal_Int32 val)
void OverrideType(SpacingType val)
virtual LwpSpacingCommonOverride * clone() const override
void Read(LwpObjectStream *pStrm) override
virtual LwpSpacingOverride * clone() const override
void Override(LwpSpacingOverride *other)
std::unique_ptr< LwpSpacingCommonOverride > m_pAboveLineSpacing
LwpSpacingCommonOverride * GetSpacing()
virtual ~LwpSpacingOverride() override
LwpSpacingCommonOverride * GetAboveLineSpacing()
std::unique_ptr< LwpSpacingCommonOverride > m_pParaSpacingAbove
std::unique_ptr< LwpSpacingCommonOverride > m_pParaSpacingBelow
LwpSpacingCommonOverride * GetAboveSpacing()
LwpSpacingCommonOverride * GetBelowSpacing()
std::unique_ptr< LwpSpacingCommonOverride > m_pSpacing
void Read(LwpObjectStream *pStrm) override
virtual LwpTextAttributeOverride * clone() const override
virtual LwpTextLanguageOverride * clone() const override
void Read(LwpObjectStream *pStrm) override
T * clone(T *const other)
Creates a new copy of the passed object.
Definition: clone.hxx:64
#define SAL_WARN(area, stream)
STATE
Definition: lwpoverride.hxx:72
@ STATE_ON
Definition: lwpoverride.hxx:74
@ STATE_OFF
Definition: lwpoverride.hxx:73
@ STATE_STYLE
Definition: lwpoverride.hxx:75
use
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
unsigned char sal_uInt8