Bump version to 4.3-4
[LibreOffice.git] / lotuswordpro / source / filter / lwpoverride.cxx
blob814689a6bda6306b6843d1f493bdd3b38f545bd9
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,
29 * MA 02111-1307 USA
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 /*************************************************************************
57 * @file
58 * For LWP filter architecture prototype
59 ************************************************************************/
60 /*************************************************************************
61 * Change History
62 Jan 2005 Created
63 ************************************************************************/
65 #include <memory>
67 #include "clone.hxx"
68 #include "lwpoverride.hxx"
69 #include "lwpfilehdr.hxx"
70 #include "lwpatomholder.hxx"
71 #include "lwpborderstuff.hxx"
72 #include "lwpmargins.hxx"
73 #include "lwpbackgroundstuff.hxx"
75 /*class LwpOverride*/
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();
88 pStrm->SkipExtra();
91 void LwpOverride::Clear()
93 m_nValues = 0;
94 m_nOverride = 0;
95 m_nApply = 0;
98 void LwpOverride::Override(sal_uInt16 nBits, STATE eState)
100 if (eState == STATE_STYLE)
102 m_nValues &= ~nBits;
103 m_nOverride &= ~nBits;
105 else
107 m_nOverride |= nBits;
108 if (eState == STATE_ON)
110 m_nValues |= nBits;
112 else /* State == STATE_OFF */
114 m_nValues &= ~nBits;
117 m_nApply |= nBits;
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())
136 ReadCommon(pStrm);
137 m_nLanguage = pStrm->QuickReaduInt16();
140 pStrm->SkipExtra();
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())
161 ReadCommon(pStrm);
162 m_nHideLevels = pStrm->QuickReaduInt16();
164 if (LwpFileHeader::m_nFileRevision > 0x000A)
165 m_nBaseLineOffset = pStrm->QuickReaduInt32();
168 pStrm->SkipExtra();
171 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())
192 ReadCommon(pStrm);
193 m_nLevels = pStrm->QuickReaduInt16();
196 pStrm->SkipExtra();
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= false;
217 ReadCommon(pStrm);
218 m_SilverBullet.ReadIndexed(pStrm);
220 else
221 m_bIsNull = true;
223 pStrm->SkipExtra();
225 void LwpBulletOverride::OverrideSkip(bool bOver)
227 if (bOver)
229 LwpOverride::Override(BO_SKIP, STATE_ON);
231 else
233 LwpOverride::Override(BO_SKIP, STATE_OFF);
237 void LwpBulletOverride::OverrideRightAligned(bool bOver)
239 if(bOver)
241 LwpOverride::Override(BO_RIGHTALIGN,STATE_ON);
243 else
245 LwpOverride::Override(BO_RIGHTALIGN,STATE_OFF);
249 void LwpBulletOverride::OverrideSilverBullet(LwpObjectID aID)
251 if (!aID.IsNull())
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);
267 else
269 pOther->RevertSilverBullet();
273 if (m_nApply & BO_SKIP)
275 if (IsSkipOverridden())
277 pOther->OverrideSkip(IsSkip());
279 else
281 pOther->RevertSkip();
285 if (m_nApply & BO_RIGHTALIGN)
287 if (IsRightAlignedOverridden())
289 pOther->OverrideRightAligned(IsRightAligned());
291 else
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())
317 ReadCommon(pStrm);
318 m_nAlignType = static_cast<AlignType>(pStrm->QuickReaduInt8());
319 m_nPosition = pStrm->QuickReaduInt32();
320 m_nAlignChar = pStrm->QuickReaduInt16();
323 pStrm->SkipExtra();
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())
344 ReadCommon(pStrm);
345 m_nSpacingType = static_cast<SpacingType>(pStrm->QuickReaduInt16());
346 m_nAmount = pStrm->QuickReadInt32();
347 m_nMultiple = pStrm->QuickReadInt32();
350 pStrm->SkipExtra();
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()
364 if (m_pSpacing)
366 delete m_pSpacing;
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)
384 , m_pSpacing(0)
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())
410 ReadCommon(pStrm);
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);
420 pStrm->SkipExtra();
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())
442 ReadCommon(pStrm);
444 m_nAll = pStrm->QuickReadInt32();
445 m_nFirst = pStrm->QuickReadInt32();
446 m_nRest = pStrm->QuickReadInt32();
447 m_nRight = pStrm->QuickReadInt32();
450 pStrm->SkipExtra();
453 /*class LwpAmikakeOverride*/
454 LwpAmikakeOverride::LwpAmikakeOverride() :
455 m_pBackgroundStuff(new LwpBackgroundStuff), m_nType(AMIKAKE_NONE)
459 LwpAmikakeOverride::~LwpAmikakeOverride()
461 if (m_pBackgroundStuff)
463 delete m_pBackgroundStuff;
467 LwpAmikakeOverride::LwpAmikakeOverride(LwpAmikakeOverride const& rOther)
468 : LwpOverride(rOther)
469 , m_pBackgroundStuff(0)
470 , m_nType(rOther.m_nType)
472 SAL_WNODEPRECATED_DECLARATIONS_PUSH
473 std::auto_ptr<LwpBackgroundStuff> pBackgroundStuff(::clone(rOther.m_pBackgroundStuff));
474 SAL_WNODEPRECATED_DECLARATIONS_POP
475 m_pBackgroundStuff = pBackgroundStuff.release();
478 LwpAmikakeOverride* LwpAmikakeOverride::clone() const
480 return new LwpAmikakeOverride(*this);
483 void LwpAmikakeOverride::Read(LwpObjectStream* pStrm)
485 if (pStrm->QuickReadBool())
487 ReadCommon(pStrm);
488 m_pBackgroundStuff->Read(pStrm);
490 else
492 Clear();
495 if (pStrm->CheckExtra())
497 m_nType = pStrm->QuickReaduInt16();
498 pStrm->SkipExtra();
500 else
502 m_nType = AMIKAKE_NONE;
506 void LwpAlignmentOverride::Override(LwpAlignmentOverride* other)//add by 1-24
508 if (m_nOverride & AO_TYPE)
510 other->OverrideAlignment(m_nAlignType);
512 /* if (m_nOverride & AO_POSITION)
514 Other->OverridePosition(GetPosition());
516 if (m_nOverride & AO_CHAR)
518 Other->OverrideAlignChar(GetAlignChar());
523 void LwpAlignmentOverride::OverrideAlignment(AlignType val)//add by 1-24
525 m_nAlignType = val;
526 m_nOverride |= AO_TYPE;
529 void LwpIndentOverride::Override(LwpIndentOverride* other)
531 if(m_nOverride & IO_ALL)
532 other->OverrideIndentAll(m_nAll);
533 if(m_nOverride & IO_FIRST)
534 other->OverrideIndentFirst(m_nFirst);
535 if(m_nOverride & IO_RIGHT)
536 other->OverrideIndentRight(m_nRight);
537 if(m_nOverride & IO_REST)
538 other->OverrideIndentRest(m_nRest);
539 if(m_nOverride & IO_USE_RELATIVE)
540 other->OverrideUseRelative(IsUseRelative());
541 if (m_nOverride & IO_REL_FLAGS)
542 other->OverrideRelative(GetRelative());
545 sal_uInt16 LwpIndentOverride::GetRelative()
547 if ((m_nOverride & IO_REL_FLAGS) == IO_REL_FIRST)
548 return RELATIVE_FIRST;
549 else if ((m_nOverride & IO_REL_FLAGS) == IO_REL_ALL)
550 return RELATIVE_ALL;
551 return RELATIVE_REST;
554 bool LwpIndentOverride::IsUseRelative()
556 return (m_nValues & IO_USE_RELATIVE) != 0;
559 void LwpIndentOverride::OverrideIndentAll(sal_Int32 val)
561 m_nAll = val;
562 m_nOverride |= IO_ALL;
565 void LwpIndentOverride::OverrideIndentFirst(sal_Int32 val)
567 m_nFirst = val;
568 m_nOverride |= IO_FIRST;
571 void LwpIndentOverride::OverrideIndentRight(sal_Int32 val)
573 m_nRight = val;
574 m_nOverride |= IO_RIGHT;
577 void LwpIndentOverride::OverrideIndentRest(sal_Int32 val)
579 m_nRest = val;
580 // m_nAll = val;
581 // m_nFirst = 0-val;
582 m_nOverride |= IO_REST;
585 void LwpIndentOverride::OverrideUseRelative(bool use)
587 if (use)
589 m_nOverride |= IO_USE_RELATIVE;
590 m_nValues |= IO_USE_RELATIVE;
592 else
594 m_nOverride &= ~IO_USE_RELATIVE;
595 m_nValues &= ~IO_USE_RELATIVE;
599 void LwpIndentOverride::OverrideRelative(sal_uInt16 relative)
601 sal_uInt16 Flag;
603 if (relative == RELATIVE_FIRST)
604 Flag = IO_REL_FIRST;
605 else if (relative == RELATIVE_ALL)
606 Flag = IO_REL_ALL;
607 else
608 Flag = IO_REL_REST;
610 m_nOverride &= ~IO_REL_FLAGS;
611 m_nOverride |= Flag;
614 void LwpSpacingOverride::Override(LwpSpacingOverride* other)
616 if (other)
618 m_pSpacing->Override(other->GetSpacing());
619 m_pAboveLineSpacing->Override(other->GetAboveLineSpacing());
620 m_pParaSpacingAbove->Override(other->GetAboveSpacing());
621 m_pParaSpacingBelow->Override(other->GetBelowSpacing());
625 void LwpSpacingCommonOverride::Override(LwpSpacingCommonOverride* other)
627 if (m_nOverride & SPO_TYPE)
628 other->OverrideType(m_nSpacingType);
629 if (m_nOverride & SPO_AMOUNT)
630 other->OverrideAmount(m_nAmount);
631 if (m_nOverride & SPO_MULTIPLE)
632 other->OverrideMultiple(m_nMultiple);
635 void LwpSpacingCommonOverride::OverrideType(SpacingType val)
637 m_nSpacingType = val;
638 m_nOverride |= SPO_TYPE;
641 void LwpSpacingCommonOverride::OverrideAmount(sal_Int32 val)
643 m_nAmount = val;
644 m_nOverride |= SPO_AMOUNT;
647 void LwpSpacingCommonOverride::OverrideMultiple(sal_Int32 val)
649 m_nMultiple = val;
650 m_nOverride |= SPO_MULTIPLE;
653 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */