1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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,
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
56 /*************************************************************************
58 * For LWP filter architecture prototype
59 ************************************************************************/
60 /*************************************************************************
63 ************************************************************************/
68 #include "lwpoverride.hxx"
69 #include "lwpfilehdr.hxx"
70 #include "lwpatomholder.hxx"
71 #include "lwpborderstuff.hxx"
72 #include "lwpmargins.hxx"
73 #include "lwpbackgroundstuff.hxx"
76 LwpOverride::LwpOverride(LwpOverride
const& rOther
)
77 : m_nValues(rOther
.m_nValues
)
78 , m_nOverride(rOther
.m_nOverride
)
79 , m_nApply(rOther
.m_nApply
)
83 void LwpOverride::ReadCommon(LwpObjectStream
* pStrm
)
85 m_nValues
= pStrm
->QuickReaduInt16();
86 m_nOverride
= pStrm
->QuickReaduInt16();
87 m_nApply
= pStrm
->QuickReaduInt16();
91 void LwpOverride::Clear()
98 void LwpOverride::Override(sal_uInt16 nBits
, STATE eState
)
100 if (eState
== STATE_STYLE
)
103 m_nOverride
&= ~nBits
;
107 m_nOverride
|= nBits
;
108 if (eState
== STATE_ON
)
112 else /* State == STATE_OFF */
120 /*class LwpTextLanguageOverride*/
121 LwpTextLanguageOverride::LwpTextLanguageOverride(LwpTextLanguageOverride
const& rOther
)
122 : LwpOverride(rOther
)
123 , m_nLanguage(rOther
.m_nLanguage
)
127 LwpTextLanguageOverride
* LwpTextLanguageOverride::clone() const
129 return new LwpTextLanguageOverride(*this);
132 void LwpTextLanguageOverride::Read(LwpObjectStream
* pStrm
)
134 if (pStrm
->QuickReadBool())
137 m_nLanguage
= pStrm
->QuickReaduInt16();
144 /*class LwpTextAttributeOverride*/
145 LwpTextAttributeOverride::LwpTextAttributeOverride(LwpTextAttributeOverride
const& rOther
)
146 : LwpOverride(rOther
)
147 , m_nHideLevels(rOther
.m_nHideLevels
)
148 , m_nBaseLineOffset(rOther
.m_nBaseLineOffset
)
152 LwpTextAttributeOverride
* LwpTextAttributeOverride::clone() const
154 return new LwpTextAttributeOverride(*this);
157 void LwpTextAttributeOverride::Read(LwpObjectStream
* pStrm
)
159 if (pStrm
->QuickReadBool())
162 m_nHideLevels
= pStrm
->QuickReaduInt16();
164 if (LwpFileHeader::m_nFileRevision
> 0x000A)
165 m_nBaseLineOffset
= pStrm
->QuickReaduInt32();
171 bool LwpTextAttributeOverride::IsHighlight()
173 return (m_nValues
& TAO_HIGHLIGHT
) != 0;
176 /*class LwpKinsokuOptsOverride*/
177 LwpKinsokuOptsOverride::LwpKinsokuOptsOverride(LwpKinsokuOptsOverride
const& rOther
)
178 : LwpOverride(rOther
)
179 , m_nLevels(rOther
.m_nLevels
)
183 LwpKinsokuOptsOverride
* LwpKinsokuOptsOverride::clone() const
185 return new LwpKinsokuOptsOverride(*this);
188 void LwpKinsokuOptsOverride::Read(LwpObjectStream
* pStrm
)
190 if (pStrm
->QuickReadBool())
193 m_nLevels
= pStrm
->QuickReaduInt16();
199 /*class LwpBulletOverride*/
200 LwpBulletOverride::LwpBulletOverride(LwpBulletOverride
const& rOther
)
201 : LwpOverride(rOther
)
202 , m_SilverBullet(rOther
.m_SilverBullet
)
203 , m_bIsNull(rOther
.m_bIsNull
)
207 LwpBulletOverride
* LwpBulletOverride::clone() const
209 return new LwpBulletOverride(*this);
212 void LwpBulletOverride::Read(LwpObjectStream
* pStrm
)
214 if (pStrm
->QuickReadBool())
218 m_SilverBullet
.ReadIndexed(pStrm
);
225 void LwpBulletOverride::OverrideSkip(bool bOver
)
229 LwpOverride::Override(BO_SKIP
, STATE_ON
);
233 LwpOverride::Override(BO_SKIP
, STATE_OFF
);
237 void LwpBulletOverride::OverrideRightAligned(bool bOver
)
241 LwpOverride::Override(BO_RIGHTALIGN
,STATE_ON
);
245 LwpOverride::Override(BO_RIGHTALIGN
,STATE_OFF
);
249 void LwpBulletOverride::OverrideSilverBullet(LwpObjectID aID
)
253 m_SilverBullet
= aID
;
256 LwpOverride::Override(BO_SILVERBULLET
,STATE_ON
);
259 void LwpBulletOverride::Override(LwpBulletOverride
* pOther
)
261 if (m_nApply
& BO_SILVERBULLET
)
263 if (IsSilverBulletOverridden())
265 pOther
->OverrideSilverBullet(m_SilverBullet
);
269 pOther
->RevertSilverBullet();
273 if (m_nApply
& BO_SKIP
)
275 if (IsSkipOverridden())
277 pOther
->OverrideSkip(IsSkip());
281 pOther
->RevertSkip();
285 if (m_nApply
& BO_RIGHTALIGN
)
287 if (IsRightAlignedOverridden())
289 pOther
->OverrideRightAligned(IsRightAligned());
293 pOther
->RevertRightAligned();
299 /*class LwpAlignmentOverride*/
300 LwpAlignmentOverride::LwpAlignmentOverride(LwpAlignmentOverride
const& rOther
)
301 : LwpOverride(rOther
)
302 , m_nAlignType(rOther
.m_nAlignType
)
303 , m_nPosition(rOther
.m_nPosition
)
304 , m_nAlignChar(rOther
.m_nAlignChar
)
308 LwpAlignmentOverride
* LwpAlignmentOverride::clone() const
310 return new LwpAlignmentOverride(*this);
313 void LwpAlignmentOverride::Read(LwpObjectStream
* pStrm
)
315 if (pStrm
->QuickReadBool())
318 m_nAlignType
= static_cast<AlignType
>(pStrm
->QuickReaduInt8());
319 m_nPosition
= pStrm
->QuickReaduInt32();
320 m_nAlignChar
= pStrm
->QuickReaduInt16();
326 /*class LwpSpacingCommonOverride*/
327 LwpSpacingCommonOverride::LwpSpacingCommonOverride(LwpSpacingCommonOverride
const& rOther
)
328 : LwpOverride(rOther
)
329 , m_nSpacingType(rOther
.m_nSpacingType
)
330 , m_nAmount(rOther
.m_nAmount
)
331 , m_nMultiple(rOther
.m_nMultiple
)
335 LwpSpacingCommonOverride
* LwpSpacingCommonOverride::clone() const
337 return new LwpSpacingCommonOverride(*this);
340 void LwpSpacingCommonOverride::Read(LwpObjectStream
* pStrm
)
342 if (pStrm
->QuickReadBool())
345 m_nSpacingType
= static_cast<SpacingType
>(pStrm
->QuickReaduInt16());
346 m_nAmount
= pStrm
->QuickReadInt32();
347 m_nMultiple
= pStrm
->QuickReadInt32();
353 /*class LwpSpacingOverride*/
354 LwpSpacingOverride::LwpSpacingOverride() :
355 m_pSpacing(new LwpSpacingCommonOverride
),
356 m_pAboveLineSpacing(new LwpSpacingCommonOverride
),
357 m_pParaSpacingAbove(new LwpSpacingCommonOverride
),
358 m_pParaSpacingBelow(new LwpSpacingCommonOverride
)
362 LwpSpacingOverride::~LwpSpacingOverride()
368 if (m_pAboveLineSpacing
)
370 delete m_pAboveLineSpacing
;
372 if (m_pParaSpacingAbove
)
374 delete m_pParaSpacingAbove
;
376 if (m_pParaSpacingBelow
)
378 delete m_pParaSpacingBelow
;
382 LwpSpacingOverride::LwpSpacingOverride(LwpSpacingOverride
const& rOther
)
383 : LwpOverride(rOther
)
385 , m_pAboveLineSpacing(0)
386 , m_pParaSpacingAbove(0)
387 , m_pParaSpacingBelow(0)
389 std::unique_ptr
<LwpSpacingCommonOverride
> pSpacing(::clone(rOther
.m_pSpacing
));
390 std::unique_ptr
<LwpSpacingCommonOverride
> pAboveLineSpacing(::clone(rOther
.m_pAboveLineSpacing
));
391 std::unique_ptr
<LwpSpacingCommonOverride
> pParaSpacingAbove(::clone(rOther
.m_pParaSpacingAbove
));
392 std::unique_ptr
<LwpSpacingCommonOverride
> pParaSpacingBelow(::clone(rOther
.m_pParaSpacingBelow
));
393 m_pSpacing
= pSpacing
.release();
394 m_pAboveLineSpacing
= pAboveLineSpacing
.release();
395 m_pParaSpacingAbove
= pParaSpacingAbove
.release();
396 m_pParaSpacingBelow
= pParaSpacingBelow
.release();
399 LwpSpacingOverride
* LwpSpacingOverride::clone() const
401 return new LwpSpacingOverride(*this);
404 void LwpSpacingOverride::Read(LwpObjectStream
* pStrm
)
406 if (pStrm
->QuickReadBool())
409 m_pSpacing
->Read(pStrm
);
410 if (LwpFileHeader::m_nFileRevision
>= 0x000d)
412 m_pAboveLineSpacing
->Read(pStrm
);
414 m_pParaSpacingAbove
->Read(pStrm
);
415 m_pParaSpacingBelow
->Read(pStrm
);
421 /*class LwpIndentOverride*/
422 LwpIndentOverride::LwpIndentOverride(LwpIndentOverride
const& rOther
)
423 : LwpOverride(rOther
)
424 , m_nAll(rOther
.m_nAll
)
425 , m_nFirst(rOther
.m_nFirst
)
426 , m_nRest(rOther
.m_nRest
)
427 , m_nRight(rOther
.m_nRight
)
431 LwpIndentOverride
* LwpIndentOverride::clone() const
433 return new LwpIndentOverride(*this);
436 void LwpIndentOverride::Read(LwpObjectStream
* pStrm
)
438 if (pStrm
->QuickReadBool())
442 m_nAll
= pStrm
->QuickReadInt32();
443 m_nFirst
= pStrm
->QuickReadInt32();
444 m_nRest
= pStrm
->QuickReadInt32();
445 m_nRight
= pStrm
->QuickReadInt32();
451 /*class LwpAmikakeOverride*/
452 LwpAmikakeOverride::LwpAmikakeOverride() :
453 m_pBackgroundStuff(new LwpBackgroundStuff
), m_nType(AMIKAKE_NONE
)
457 LwpAmikakeOverride::~LwpAmikakeOverride()
459 if (m_pBackgroundStuff
)
461 delete m_pBackgroundStuff
;
465 LwpAmikakeOverride::LwpAmikakeOverride(LwpAmikakeOverride
const& rOther
)
466 : LwpOverride(rOther
)
467 , m_pBackgroundStuff(0)
468 , m_nType(rOther
.m_nType
)
470 std::unique_ptr
<LwpBackgroundStuff
> pBackgroundStuff(::clone(rOther
.m_pBackgroundStuff
));
471 m_pBackgroundStuff
= pBackgroundStuff
.release();
474 LwpAmikakeOverride
* LwpAmikakeOverride::clone() const
476 return new LwpAmikakeOverride(*this);
479 void LwpAmikakeOverride::Read(LwpObjectStream
* pStrm
)
481 if (pStrm
->QuickReadBool())
484 m_pBackgroundStuff
->Read(pStrm
);
491 if (pStrm
->CheckExtra())
493 m_nType
= pStrm
->QuickReaduInt16();
498 m_nType
= AMIKAKE_NONE
;
502 void LwpAlignmentOverride::Override(LwpAlignmentOverride
* other
)//add by 1-24
504 if (m_nOverride
& AO_TYPE
)
506 other
->OverrideAlignment(m_nAlignType
);
508 /* if (m_nOverride & AO_POSITION)
510 Other->OverridePosition(GetPosition());
512 if (m_nOverride & AO_CHAR)
514 Other->OverrideAlignChar(GetAlignChar());
519 void LwpAlignmentOverride::OverrideAlignment(AlignType val
)//add by 1-24
522 m_nOverride
|= AO_TYPE
;
525 void LwpIndentOverride::Override(LwpIndentOverride
* other
)
527 if(m_nOverride
& IO_ALL
)
528 other
->OverrideIndentAll(m_nAll
);
529 if(m_nOverride
& IO_FIRST
)
530 other
->OverrideIndentFirst(m_nFirst
);
531 if(m_nOverride
& IO_RIGHT
)
532 other
->OverrideIndentRight(m_nRight
);
533 if(m_nOverride
& IO_REST
)
534 other
->OverrideIndentRest(m_nRest
);
535 if(m_nOverride
& IO_USE_RELATIVE
)
536 other
->OverrideUseRelative(IsUseRelative());
537 if (m_nOverride
& IO_REL_FLAGS
)
538 other
->OverrideRelative(GetRelative());
541 sal_uInt16
LwpIndentOverride::GetRelative()
543 if ((m_nOverride
& IO_REL_FLAGS
) == IO_REL_FIRST
)
544 return RELATIVE_FIRST
;
545 else if ((m_nOverride
& IO_REL_FLAGS
) == IO_REL_ALL
)
547 return RELATIVE_REST
;
550 bool LwpIndentOverride::IsUseRelative()
552 return (m_nValues
& IO_USE_RELATIVE
) != 0;
555 void LwpIndentOverride::OverrideIndentAll(sal_Int32 val
)
558 m_nOverride
|= IO_ALL
;
561 void LwpIndentOverride::OverrideIndentFirst(sal_Int32 val
)
564 m_nOverride
|= IO_FIRST
;
567 void LwpIndentOverride::OverrideIndentRight(sal_Int32 val
)
570 m_nOverride
|= IO_RIGHT
;
573 void LwpIndentOverride::OverrideIndentRest(sal_Int32 val
)
578 m_nOverride
|= IO_REST
;
581 void LwpIndentOverride::OverrideUseRelative(bool use
)
585 m_nOverride
|= IO_USE_RELATIVE
;
586 m_nValues
|= IO_USE_RELATIVE
;
590 m_nOverride
&= ~IO_USE_RELATIVE
;
591 m_nValues
&= ~IO_USE_RELATIVE
;
595 void LwpIndentOverride::OverrideRelative(sal_uInt16 relative
)
599 if (relative
== RELATIVE_FIRST
)
601 else if (relative
== RELATIVE_ALL
)
606 m_nOverride
&= ~IO_REL_FLAGS
;
610 void LwpSpacingOverride::Override(LwpSpacingOverride
* other
)
614 m_pSpacing
->Override(other
->GetSpacing());
615 m_pAboveLineSpacing
->Override(other
->GetAboveLineSpacing());
616 m_pParaSpacingAbove
->Override(other
->GetAboveSpacing());
617 m_pParaSpacingBelow
->Override(other
->GetBelowSpacing());
621 void LwpSpacingCommonOverride::Override(LwpSpacingCommonOverride
* other
)
623 if (m_nOverride
& SPO_TYPE
)
624 other
->OverrideType(m_nSpacingType
);
625 if (m_nOverride
& SPO_AMOUNT
)
626 other
->OverrideAmount(m_nAmount
);
627 if (m_nOverride
& SPO_MULTIPLE
)
628 other
->OverrideMultiple(m_nMultiple
);
631 void LwpSpacingCommonOverride::OverrideType(SpacingType val
)
633 m_nSpacingType
= val
;
634 m_nOverride
|= SPO_TYPE
;
637 void LwpSpacingCommonOverride::OverrideAmount(sal_Int32 val
)
640 m_nOverride
|= SPO_AMOUNT
;
643 void LwpSpacingCommonOverride::OverrideMultiple(sal_Int32 val
)
646 m_nOverride
|= SPO_MULTIPLE
;
649 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */