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 sal_Bool
LwpTextAttributeOverride::IsHighLight()
173 return (m_nValues
& TAO_HIGHLIGHT
);
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())
216 m_bIsNull
= sal_False
;
218 m_SilverBullet
.ReadIndexed(pStrm
);
221 m_bIsNull
= sal_True
;
225 void LwpBulletOverride::OverrideSkip(sal_Bool bOver
)
229 LwpOverride::Override(BO_SKIP
, STATE_ON
);
233 LwpOverride::Override(BO_SKIP
, STATE_OFF
);
237 void LwpBulletOverride::OverrideRightAligned(sal_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 SAL_WNODEPRECATED_DECLARATIONS_PUSH
390 std::auto_ptr
<LwpSpacingCommonOverride
> pSpacing(::clone(rOther
.m_pSpacing
));
391 std::auto_ptr
<LwpSpacingCommonOverride
> pAboveLineSpacing(::clone(rOther
.m_pAboveLineSpacing
));
392 std::auto_ptr
<LwpSpacingCommonOverride
> pParaSpacingAbove(::clone(rOther
.m_pParaSpacingAbove
));
393 std::auto_ptr
<LwpSpacingCommonOverride
> pParaSpacingBelow(::clone(rOther
.m_pParaSpacingBelow
));
394 SAL_WNODEPRECATED_DECLARATIONS_POP
395 m_pSpacing
= pSpacing
.release();
396 m_pAboveLineSpacing
= pAboveLineSpacing
.release();
397 m_pParaSpacingAbove
= pParaSpacingAbove
.release();
398 m_pParaSpacingBelow
= pParaSpacingBelow
.release();
401 LwpSpacingOverride
* LwpSpacingOverride::clone() const
403 return new LwpSpacingOverride(*this);
406 void LwpSpacingOverride::Read(LwpObjectStream
* pStrm
)
408 if (pStrm
->QuickReadBool())
411 m_pSpacing
->Read(pStrm
);
412 if (LwpFileHeader::m_nFileRevision
>= 0x000d)
414 m_pAboveLineSpacing
->Read(pStrm
);
416 m_pParaSpacingAbove
->Read(pStrm
);
417 m_pParaSpacingBelow
->Read(pStrm
);
423 /*class LwpIndentOverride*/
424 LwpIndentOverride::LwpIndentOverride(LwpIndentOverride
const& rOther
)
425 : LwpOverride(rOther
)
426 , m_nAll(rOther
.m_nAll
)
427 , m_nFirst(rOther
.m_nFirst
)
428 , m_nRest(rOther
.m_nRest
)
429 , m_nRight(rOther
.m_nRight
)
433 LwpIndentOverride
* LwpIndentOverride::clone() const
435 return new LwpIndentOverride(*this);
438 void LwpIndentOverride::Read(LwpObjectStream
* pStrm
)
440 if (pStrm
->QuickReadBool())
444 m_nAll
= pStrm
->QuickReadInt32();
445 m_nFirst
= pStrm
->QuickReadInt32();
446 m_nRest
= pStrm
->QuickReadInt32();
447 m_nRight
= pStrm
->QuickReadInt32();
454 /*class LwpAmikakeOverride*/
455 LwpAmikakeOverride::LwpAmikakeOverride() :
456 m_pBackgroundStuff(new LwpBackgroundStuff
), m_nType(AMIKAKE_NONE
)
460 LwpAmikakeOverride::~LwpAmikakeOverride()
462 if (m_pBackgroundStuff
)
464 delete m_pBackgroundStuff
;
468 LwpAmikakeOverride::LwpAmikakeOverride(LwpAmikakeOverride
const& rOther
)
469 : LwpOverride(rOther
)
470 , m_pBackgroundStuff(0)
471 , m_nType(rOther
.m_nType
)
473 SAL_WNODEPRECATED_DECLARATIONS_PUSH
474 std::auto_ptr
<LwpBackgroundStuff
> pBackgroundStuff(::clone(rOther
.m_pBackgroundStuff
));
475 SAL_WNODEPRECATED_DECLARATIONS_POP
476 m_pBackgroundStuff
= pBackgroundStuff
.release();
479 LwpAmikakeOverride
* LwpAmikakeOverride::clone() const
481 return new LwpAmikakeOverride(*this);
484 void LwpAmikakeOverride::Read(LwpObjectStream
* pStrm
)
486 if (pStrm
->QuickReadBool())
489 m_pBackgroundStuff
->Read(pStrm
);
496 if (pStrm
->CheckExtra())
498 m_nType
= pStrm
->QuickReaduInt16();
503 m_nType
= AMIKAKE_NONE
;
507 void LwpAlignmentOverride::Override(LwpAlignmentOverride
* other
)//add by 1-24
509 if (m_nOverride
& AO_TYPE
)
511 other
->OverrideAlignment(m_nAlignType
);
513 /* if (m_nOverride & AO_POSITION)
515 Other->OverridePosition(GetPosition());
517 if (m_nOverride & AO_CHAR)
519 Other->OverrideAlignChar(GetAlignChar());
524 void LwpAlignmentOverride::OverrideAlignment(AlignType val
)//add by 1-24
527 m_nOverride
|= AO_TYPE
;
530 void LwpIndentOverride::Override(LwpIndentOverride
* other
)
532 if(m_nOverride
& IO_ALL
)
533 other
->OverrideIndentAll(m_nAll
);
534 if(m_nOverride
& IO_FIRST
)
535 other
->OverrideIndentFirst(m_nFirst
);
536 if(m_nOverride
& IO_RIGHT
)
537 other
->OverrideIndentRight(m_nRight
);
538 if(m_nOverride
& IO_REST
)
539 other
->OverrideIndentRest(m_nRest
);
540 if(m_nOverride
& IO_USE_RELATIVE
)
541 other
->OverrideUseRelative(IsUseRelative());
542 if (m_nOverride
& IO_REL_FLAGS
)
543 other
->OverrideRelative(GetRelative());
546 sal_uInt16
LwpIndentOverride::GetRelative()
548 if ((m_nOverride
& IO_REL_FLAGS
) == IO_REL_FIRST
)
549 return RELATIVE_FIRST
;
550 else if ((m_nOverride
& IO_REL_FLAGS
) == IO_REL_ALL
)
552 return RELATIVE_REST
;
555 sal_Bool
LwpIndentOverride::IsUseRelative()
557 return (m_nValues
& IO_USE_RELATIVE
) != 0;
560 void LwpIndentOverride::OverrideIndentAll(sal_Int32 val
)
563 m_nOverride
|= IO_ALL
;
566 void LwpIndentOverride::OverrideIndentFirst(sal_Int32 val
)
569 m_nOverride
|= IO_FIRST
;
572 void LwpIndentOverride::OverrideIndentRight(sal_Int32 val
)
575 m_nOverride
|= IO_RIGHT
;
578 void LwpIndentOverride::OverrideIndentRest(sal_Int32 val
)
583 m_nOverride
|= IO_REST
;
586 void LwpIndentOverride::OverrideUseRelative(sal_Bool use
)
590 m_nOverride
|= IO_USE_RELATIVE
;
591 m_nValues
|= IO_USE_RELATIVE
;
595 m_nOverride
&= ~IO_USE_RELATIVE
;
596 m_nValues
&= ~IO_USE_RELATIVE
;
600 void LwpIndentOverride::OverrideRelative(sal_uInt16 relative
)
604 if (relative
== RELATIVE_FIRST
)
606 else if (relative
== RELATIVE_ALL
)
611 m_nOverride
&= ~IO_REL_FLAGS
;
615 void LwpSpacingOverride::Override(LwpSpacingOverride
* other
)
619 m_pSpacing
->Override(other
->GetSpacing());
620 m_pAboveLineSpacing
->Override(other
->GetAboveLineSpacing());
621 m_pParaSpacingAbove
->Override(other
->GetAboveSpacing());
622 m_pParaSpacingBelow
->Override(other
->GetBelowSpacing());
626 void LwpSpacingCommonOverride::Override(LwpSpacingCommonOverride
* other
)
628 if (m_nOverride
& SPO_TYPE
)
629 other
->OverrideType(m_nSpacingType
);
630 if (m_nOverride
& SPO_AMOUNT
)
631 other
->OverrideAmount(m_nAmount
);
632 if (m_nOverride
& SPO_MULTIPLE
)
633 other
->OverrideMultiple(m_nMultiple
);
636 void LwpSpacingCommonOverride::OverrideType(SpacingType val
)
638 m_nSpacingType
= val
;
639 m_nOverride
|= SPO_TYPE
;
642 void LwpSpacingCommonOverride::OverrideAmount(sal_Int32 val
)
645 m_nOverride
|= SPO_AMOUNT
;
648 void LwpSpacingCommonOverride::OverrideMultiple(sal_Int32 val
)
651 m_nOverride
|= SPO_MULTIPLE
;
654 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */