update dev300-m57
[ooovba.git] / lotuswordpro / source / filter / lwpoverride.cxx
blobdac8289ae0a41fe2f8b7acf5f058a6bd23b30f21
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /*************************************************************************
56 * @file
57 * For LWP filter architecture prototype
58 ************************************************************************/
59 /*************************************************************************
60 * Change History
61 Jan 2005 Created
62 ************************************************************************/
64 #include "lwpoverride.hxx"
65 #include "lwpfilehdr.hxx"
66 #include "lwpatomholder.hxx"
67 #include "lwpborderstuff.hxx"
68 #include "lwpmargins.hxx"
69 #include "lwpbackgroundstuff.hxx"
71 /*class LwpOverride*/
72 void LwpOverride::ReadCommon(LwpObjectStream* pStrm)
74 pStrm->QuickRead(&m_nValues, 2);
75 pStrm->QuickRead(&m_nOverride, 2);
76 pStrm->QuickRead(&m_nApply, 2);
77 pStrm->SkipExtra();
80 void LwpOverride::Clear()
82 m_nValues = 0;
83 m_nOverride = 0;
84 m_nApply = 0;
87 void LwpOverride::operator=(const LwpOverride& rOther)
89 m_nValues = rOther.m_nValues;
90 m_nOverride = rOther.m_nOverride;
91 m_nApply = rOther.m_nApply;
94 void LwpOverride::Override(sal_uInt16 nBits, STATE eState)
96 if (eState == STATE_STYLE)
98 m_nValues &= ~nBits;
99 m_nOverride &= ~nBits;
101 else
103 m_nOverride |= nBits;
104 if (eState == STATE_ON)
106 m_nValues |= nBits;
108 else /* State == STATE_OFF */
110 m_nValues &= ~nBits;
113 m_nApply |= nBits;
116 /*class LwpTextLanguageOverride*/
117 void LwpTextLanguageOverride::Read(LwpObjectStream* pStrm)
119 if (pStrm->QuickReadBool())
121 ReadCommon(pStrm);
122 pStrm->QuickRead(&m_nLanguage, 2);
125 pStrm->SkipExtra();
129 /*class LwpTextAttributeOverride*/
130 void LwpTextAttributeOverride::Read(LwpObjectStream* pStrm)
132 if (pStrm->QuickReadBool())
134 ReadCommon(pStrm);
135 pStrm->QuickRead(&m_nHideLevels, 2);
137 if (LwpFileHeader::m_nFileRevision > 0x000A)
139 pStrm->QuickRead(&m_nBaseLineOffset, 4);
143 pStrm->SkipExtra();
146 sal_Bool LwpTextAttributeOverride::IsHighLight()
148 return (m_nValues & TAO_HIGHLIGHT);
151 /*class LwpKinsokuOptsOverride*/
152 void LwpKinsokuOptsOverride::Read(LwpObjectStream* pStrm)
154 if (pStrm->QuickReadBool())
156 ReadCommon(pStrm);
157 pStrm->QuickRead(&m_nLevels, 2);
160 pStrm->SkipExtra();
163 /*class LwpBulletOverride*/
164 void LwpBulletOverride::Read(LwpObjectStream * pStrm)
166 if (pStrm->QuickReadBool())
168 m_bIsNull= sal_False;
169 ReadCommon(pStrm);
170 m_SilverBullet.ReadIndexed(pStrm);
172 else
173 m_bIsNull = sal_True;
175 pStrm->SkipExtra();
177 void LwpBulletOverride::OverrideSkip(sal_Bool bOver)
179 if (bOver)
181 LwpOverride::Override(BO_SKIP, STATE_ON);
183 else
185 LwpOverride::Override(BO_SKIP, STATE_OFF);
189 void LwpBulletOverride::OverrideRightAligned(sal_Bool bOver)
191 if(bOver)
193 LwpOverride::Override(BO_RIGHTALIGN,STATE_ON);
195 else
197 LwpOverride::Override(BO_RIGHTALIGN,STATE_OFF);
201 void LwpBulletOverride::operator=(const LwpOverride& rOther)
203 LwpOverride::operator=(rOther);
204 const LwpBulletOverride* pBullet = static_cast<LwpBulletOverride*>((LwpOverride*)&rOther);
206 m_SilverBullet = pBullet->m_SilverBullet;
210 void LwpBulletOverride::OverrideSilverBullet(LwpObjectID aID)
212 if (!aID.IsNull())
214 m_SilverBullet = aID;
217 LwpOverride::Override(BO_SILVERBULLET,STATE_ON);
220 void LwpBulletOverride::Override(LwpBulletOverride* pOther)
222 if (m_nApply & BO_SILVERBULLET)
224 if (IsSilverBulletOverridden())
226 pOther->OverrideSilverBullet(m_SilverBullet);
228 else
230 pOther->RevertSilverBullet();
234 if (m_nApply & BO_SKIP)
236 if (IsSkipOverridden())
238 pOther->OverrideSkip(IsSkip());
240 else
242 pOther->RevertSkip();
246 if (m_nApply & BO_RIGHTALIGN)
248 if (IsRightAlignedOverridden())
250 pOther->OverrideRightAligned(IsRightAligned());
252 else
254 pOther->RevertRightAligned();
260 /*class LwpAlignmentOverride*/
261 void LwpAlignmentOverride::Read(LwpObjectStream * pStrm)
263 if (pStrm->QuickReadBool())
265 ReadCommon(pStrm);
266 pStrm->QuickRead(&m_nAlignType, 1);
267 pStrm->QuickRead(&m_nPosition, 4);
268 pStrm->QuickRead(&m_nAlignChar, 2);
271 pStrm->SkipExtra();
274 /*class LwpSpacingCommonOverride*/
275 void LwpSpacingCommonOverride::Read(LwpObjectStream* pStrm)
277 if (pStrm->QuickReadBool())
279 ReadCommon(pStrm);
280 pStrm->QuickRead(&m_nSpacingType, 2);
281 pStrm->QuickRead(&m_nAmount, 4);
282 pStrm->QuickRead(&m_nMultiple, 4);
285 pStrm->SkipExtra();
288 /*class LwpSpacingOverride*/
289 LwpSpacingOverride::LwpSpacingOverride() :
290 m_pSpacing(new LwpSpacingCommonOverride),
291 m_pAboveLineSpacing(new LwpSpacingCommonOverride),
292 m_pParaSpacingAbove(new LwpSpacingCommonOverride),
293 m_pParaSpacingBelow(new LwpSpacingCommonOverride)
297 LwpSpacingOverride& LwpSpacingOverride::operator=(LwpSpacingOverride& other)
299 LwpOverride::operator=(other);
300 *m_pSpacing = *other.m_pSpacing;
301 *m_pAboveLineSpacing = *other.m_pAboveLineSpacing;
302 *m_pParaSpacingAbove = *other.m_pParaSpacingAbove;
303 *m_pParaSpacingAbove = *other.m_pParaSpacingAbove;
304 return *this;
307 LwpSpacingOverride::~LwpSpacingOverride()
309 if (m_pSpacing)
311 delete m_pSpacing;
313 if (m_pAboveLineSpacing)
315 delete m_pAboveLineSpacing;
317 if (m_pParaSpacingAbove)
319 delete m_pParaSpacingAbove;
321 if (m_pParaSpacingBelow)
323 delete m_pParaSpacingBelow;
327 void LwpSpacingOverride::Read(LwpObjectStream* pStrm)
329 if (pStrm->QuickReadBool())
331 ReadCommon(pStrm);
332 m_pSpacing->Read(pStrm);
333 if (LwpFileHeader::m_nFileRevision >= 0x000d)
335 m_pAboveLineSpacing->Read(pStrm);
337 m_pParaSpacingAbove->Read(pStrm);
338 m_pParaSpacingBelow->Read(pStrm);
341 pStrm->SkipExtra();
344 /*class LwpIndentOverride*/
345 void LwpIndentOverride::Read(LwpObjectStream* pStrm)
347 if (pStrm->QuickReadBool())
349 ReadCommon(pStrm);
351 pStrm->QuickRead(&m_nAll, 4);
352 pStrm->QuickRead(&m_nFirst, 4);
353 pStrm->QuickRead(&m_nRest, 4);
354 pStrm->QuickRead(&m_nRight, 4);
357 pStrm->SkipExtra();
361 /*class LwpAmikakeOverride*/
362 LwpAmikakeOverride::LwpAmikakeOverride() :
363 m_pBackgroundStuff(new LwpBackgroundStuff), m_nType(AMIKAKE_NONE)
367 LwpAmikakeOverride::~LwpAmikakeOverride()
369 if (m_pBackgroundStuff)
371 delete m_pBackgroundStuff;
375 void LwpAmikakeOverride::Read(LwpObjectStream* pStrm)
377 if (pStrm->QuickReadBool())
379 ReadCommon(pStrm);
380 m_pBackgroundStuff->Read(pStrm);
382 else
384 Clear();
387 if (pStrm->CheckExtra())
389 pStrm->QuickRead(&m_nType, 2);
390 pStrm->SkipExtra();
392 else
394 m_nType = AMIKAKE_NONE;
398 void LwpAlignmentOverride::Override(LwpAlignmentOverride* other)//add by 1-24
400 if (m_nOverride & AO_TYPE)
402 other->OverrideAlignment(m_nAlignType);
404 /* if (m_nOverride & AO_POSITION)
406 Other->OverridePosition(GetPosition());
408 if (m_nOverride & AO_CHAR)
410 Other->OverrideAlignChar(GetAlignChar());
415 void LwpAlignmentOverride::OverrideAlignment(AlignType val)//add by 1-24
417 m_nAlignType = val;
418 m_nOverride |= AO_TYPE;
421 LwpIndentOverride& LwpIndentOverride::operator=(LwpIndentOverride& other)
423 LwpOverride::operator=(other);
424 m_nAll = other.m_nAll;
425 m_nFirst = other.m_nFirst;
426 m_nRest = other.m_nRest;
427 m_nRight = other.m_nRight;
428 return *this;
431 void LwpIndentOverride::Override(LwpIndentOverride* other)
433 if(m_nOverride & IO_ALL)
434 other->OverrideIndentAll(m_nAll);
435 if(m_nOverride & IO_FIRST)
436 other->OverrideIndentFirst(m_nFirst);
437 if(m_nOverride & IO_RIGHT)
438 other->OverrideIndentRight(m_nRight);
439 if(m_nOverride & IO_REST)
440 other->OverrideIndentRest(m_nRest);
441 if(m_nOverride & IO_USE_RELATIVE)
442 other->OverrideUseRelative(IsUseRelative());
443 if (m_nOverride & IO_REL_FLAGS)
444 other->OverrideRelative(GetRelative());
447 sal_uInt16 LwpIndentOverride::GetRelative()
449 if ((m_nOverride & IO_REL_FLAGS) == IO_REL_FIRST)
450 return RELATIVE_FIRST;
451 else if ((m_nOverride & IO_REL_FLAGS) == IO_REL_ALL)
452 return RELATIVE_ALL;
453 return RELATIVE_REST;
456 sal_Bool LwpIndentOverride::IsUseRelative()
458 return (m_nValues & IO_USE_RELATIVE) != 0;
461 void LwpIndentOverride::OverrideIndentAll(sal_Int32 val)
463 m_nAll = val;
464 m_nOverride |= IO_ALL;
467 void LwpIndentOverride::OverrideIndentFirst(sal_Int32 val)
469 m_nFirst = val;
470 m_nOverride |= IO_FIRST;
473 void LwpIndentOverride::OverrideIndentRight(sal_Int32 val)
475 m_nRight = val;
476 m_nOverride |= IO_RIGHT;
479 void LwpIndentOverride::OverrideIndentRest(sal_Int32 val)
481 m_nRest = val;
482 // m_nAll = val;
483 // m_nFirst = 0-val;
484 m_nOverride |= IO_REST;
487 void LwpIndentOverride::OverrideUseRelative(sal_Bool use)
489 if (use)
491 m_nOverride |= IO_USE_RELATIVE;
492 m_nValues |= IO_USE_RELATIVE;
494 else
496 m_nOverride &= ~IO_USE_RELATIVE;
497 m_nValues &= ~IO_USE_RELATIVE;
501 void LwpIndentOverride::OverrideRelative(sal_uInt16 relative)
503 sal_uInt16 Flag;
505 if (relative == RELATIVE_FIRST)
506 Flag = IO_REL_FIRST;
507 else if (relative == RELATIVE_ALL)
508 Flag = IO_REL_ALL;
509 else
510 Flag = IO_REL_REST;
512 m_nOverride &= ~IO_REL_FLAGS;
513 m_nOverride |= Flag;
516 void LwpSpacingOverride::Override(LwpSpacingOverride* other)
518 // if (IsAlwaysOverridden())
519 // other->SetAlways(IsAlways());//To be done
520 if (other)
522 m_pSpacing->Override(other->GetSpacing());
523 m_pAboveLineSpacing->Override(other->GetAboveLineSpacing());
524 m_pParaSpacingAbove->Override(other->GetAboveSpacing());
525 m_pParaSpacingBelow->Override(other->GetBelowSpacing());
529 void LwpSpacingCommonOverride::Override(LwpSpacingCommonOverride* other)
531 if (m_nOverride & SPO_TYPE)
532 other->OverrideType(m_nSpacingType);
533 if (m_nOverride & SPO_AMOUNT)
534 other->OverrideAmount(m_nAmount);
535 if (m_nOverride & SPO_MULTIPLE)
536 other->OverrideMultiple(m_nMultiple);
539 void LwpSpacingCommonOverride::OverrideType(SpacingType val)
541 m_nSpacingType = val;
542 m_nOverride |= SPO_TYPE;
545 void LwpSpacingCommonOverride::OverrideAmount(sal_Int32 val)
547 m_nAmount = val;
548 m_nOverride |= SPO_AMOUNT;
551 void LwpSpacingCommonOverride::OverrideMultiple(sal_Int32 val)
553 m_nMultiple = val;
554 m_nOverride |= SPO_MULTIPLE;