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 ************************************************************************/
61 #ifndef INCLUDED_LOTUSWORDPRO_INC_LWPOVERRIDE_HXX
62 #define INCLUDED_LOTUSWORDPRO_INC_LWPOVERRIDE_HXX
64 #include "lwpobjid.hxx"
65 #include "lwptools.hxx"
66 #include <o3tl/safeint.hxx>
69 class LwpObjectStream
;
81 LwpOverride() : m_nValues(0), m_nOverride(0), m_nApply(0) {}
83 virtual ~LwpOverride(){}
85 virtual LwpOverride
* clone() const = 0;
87 virtual void Read(LwpObjectStream
* pStrm
) = 0;
89 void ReadCommon(LwpObjectStream
* pStrm
);
93 void Override(sal_uInt16 nBits
, STATE eState
);
96 explicit LwpOverride(LwpOverride
const& rOther
);
99 LwpOverride
& operator=(LwpOverride
const& rOther
) = delete;
102 sal_uInt16 m_nValues
;
103 sal_uInt16 m_nOverride
;
107 class LwpTextLanguageOverride final
: public LwpOverride
110 LwpTextLanguageOverride() : m_nLanguage(0) {}
112 virtual LwpTextLanguageOverride
* clone() const override
;
114 void Read(LwpObjectStream
* pStrm
) override
;
117 LwpTextLanguageOverride(LwpTextLanguageOverride
const& rOther
);
118 LwpTextLanguageOverride
& operator=(LwpTextLanguageOverride
const& rOther
) = delete;
120 sal_uInt16 m_nLanguage
;
123 class LwpTextAttributeOverride final
: public LwpOverride
126 LwpTextAttributeOverride() : m_nHideLevels(0), m_nBaseLineOffset(0) {}
128 virtual LwpTextAttributeOverride
* clone() const override
;
130 void Read(LwpObjectStream
* pStrm
) override
;
132 inline sal_uInt16
GetHideLevels() const;
137 LwpTextAttributeOverride(LwpTextAttributeOverride
const& rOther
);
138 LwpTextAttributeOverride
& operator=(LwpTextAttributeOverride
const& rOther
) = delete;
141 TAO_HIGHLIGHT
= 0x08,
143 sal_uInt16 m_nHideLevels
;
144 sal_uInt32 m_nBaseLineOffset
;
147 inline sal_uInt16
LwpTextAttributeOverride::GetHideLevels() const
149 return m_nHideLevels
;
152 class LwpKinsokuOptsOverride final
: public LwpOverride
155 LwpKinsokuOptsOverride() : m_nLevels(0) {}
157 virtual LwpKinsokuOptsOverride
* clone() const override
;
159 void Read(LwpObjectStream
* pStrm
) override
;
162 LwpKinsokuOptsOverride(LwpKinsokuOptsOverride
const& rOther
);
163 LwpKinsokuOptsOverride
& operator=(LwpKinsokuOptsOverride
const& rOther
) = delete;
165 sal_uInt16 m_nLevels
;
168 class LwpBulletOverride final
: public LwpOverride
171 LwpBulletOverride() {m_bIsNull
= true;}
173 virtual LwpBulletOverride
* clone() const override
;
175 void Read(LwpObjectStream
* pStrm
) override
;
177 inline const LwpObjectID
& GetSilverBullet() const;
179 void Override(LwpBulletOverride
* pOther
);
181 inline bool IsSilverBulletOverridden();
182 inline bool IsSkipOverridden();
183 inline bool IsRightAlignedOverridden();
184 inline bool IsSkip();
185 inline bool IsRightAligned();
186 inline bool IsEditable();
188 void OverrideSilverBullet(LwpObjectID aID
);
189 void OverrideSkip(bool bOver
);
190 void OverrideRightAligned(bool bOver
);
192 inline void RevertSilverBullet();
193 inline void RevertSkip();
194 inline void RevertRightAligned();
196 bool IsInValid(){return m_bIsNull
;}
199 LwpBulletOverride(LwpBulletOverride
const& rOther
);
200 LwpBulletOverride
& operator=(LwpBulletOverride
const& rOther
) = delete;
204 BO_SILVERBULLET
= 0x01,
206 BO_RIGHTALIGN
= 0x04,
211 LwpObjectID m_SilverBullet
;
215 inline const LwpObjectID
& LwpBulletOverride::GetSilverBullet() const
217 return m_SilverBullet
;
220 inline bool LwpBulletOverride::IsSilverBulletOverridden()
222 return ((m_nOverride
& BO_SILVERBULLET
) != 0);
225 inline bool LwpBulletOverride::IsSkipOverridden()
227 return ((m_nOverride
& BO_SKIP
) != 0);
230 inline bool LwpBulletOverride::IsRightAlignedOverridden()
232 return ((m_nOverride
& BO_RIGHTALIGN
) != 0);
235 inline bool LwpBulletOverride::IsSkip()
237 return ((m_nValues
& BO_SKIP
) != 0);
240 inline bool LwpBulletOverride::IsEditable()
242 return ((m_nValues
& BO_EDITABLE
) != 0);
245 inline bool LwpBulletOverride::IsRightAligned()
247 return ((m_nValues
& BO_RIGHTALIGN
) != 0);
250 inline void LwpBulletOverride::RevertSilverBullet()
252 LwpOverride::Override(BO_SILVERBULLET
, STATE_STYLE
);
255 inline void LwpBulletOverride::RevertSkip()
257 LwpOverride::Override(BO_SKIP
, STATE_STYLE
);
260 inline void LwpBulletOverride::RevertRightAligned()
262 LwpOverride::Override(BO_RIGHTALIGN
, STATE_STYLE
);
265 class LwpAlignmentOverride final
: public LwpOverride
268 LwpAlignmentOverride() : m_nAlignType(ALIGN_LEFT
), m_nPosition(0), m_nAlignChar(0){}
270 virtual LwpAlignmentOverride
* clone() const override
;
272 void Read(LwpObjectStream
* pStrm
) override
;
280 ALIGN_JUSTIFYALL
= 4,
281 ALIGN_NUMERICLEFT
= 5,
282 ALIGN_NUMERICRIGHT
= 6,
286 AlignType
GetAlignType(){ return m_nAlignType
; }
287 void Override(LwpAlignmentOverride
* other
);
288 void OverrideAlignment(AlignType val
);
291 LwpAlignmentOverride(LwpAlignmentOverride
const& rOther
);
292 LwpAlignmentOverride
& operator=(LwpAlignmentOverride
const& rOther
) = delete;
301 AlignType m_nAlignType
;
302 sal_uInt32 m_nPosition
;
303 sal_uInt16 m_nAlignChar
;
306 class LwpSpacingCommonOverride final
: public LwpOverride
309 LwpSpacingCommonOverride() : m_nSpacingType(SPACING_NONE
), m_nAmount(0), m_nMultiple(65536){}
311 virtual LwpSpacingCommonOverride
* clone() const override
;
313 void Read(LwpObjectStream
* pStrm
) override
;
323 SpacingType
GetType() const {return m_nSpacingType
;}
324 sal_Int32
GetAmount() const {return m_nAmount
;}
325 sal_Int32
GetMultiple() const {return m_nMultiple
;}
327 void Override(LwpSpacingCommonOverride
* other
);
328 void OverrideType(SpacingType val
);
329 void OverrideAmount(sal_Int32 val
);
330 void OverrideMultiple(sal_Int32 val
);
333 LwpSpacingCommonOverride(LwpSpacingCommonOverride
const& rOther
);
334 LwpSpacingCommonOverride
& operator=(LwpSpacingCommonOverride
const& rOther
) = delete;
342 SpacingType m_nSpacingType
;//sal_uInt16
344 sal_Int32 m_nMultiple
;
347 class LwpSpacingOverride final
: public LwpOverride
350 LwpSpacingOverride();
351 virtual ~LwpSpacingOverride() override
;
353 virtual LwpSpacingOverride
* clone() const override
;
355 void Read(LwpObjectStream
* pStrm
) override
;
357 void Override(LwpSpacingOverride
* other
);
359 LwpSpacingCommonOverride
* GetSpacing(){return m_pSpacing
.get();}
360 LwpSpacingCommonOverride
* GetAboveLineSpacing(){return m_pAboveLineSpacing
.get();}
361 LwpSpacingCommonOverride
* GetAboveSpacing(){return m_pParaSpacingAbove
.get();}
362 LwpSpacingCommonOverride
* GetBelowSpacing(){return m_pParaSpacingBelow
.get();}
365 LwpSpacingOverride(LwpSpacingOverride
const& rOther
);
366 LwpSpacingOverride
& operator=(LwpSpacingOverride
const& rOther
) = delete;
368 std::unique_ptr
<LwpSpacingCommonOverride
> m_pSpacing
;
369 std::unique_ptr
<LwpSpacingCommonOverride
> m_pAboveLineSpacing
;
370 std::unique_ptr
<LwpSpacingCommonOverride
> m_pParaSpacingAbove
;
371 std::unique_ptr
<LwpSpacingCommonOverride
> m_pParaSpacingBelow
;
374 class LwpIndentOverride final
: public LwpOverride
377 LwpIndentOverride() : m_nAll(0), m_nFirst(0), m_nRest(0), m_nRight(0) {}
379 virtual LwpIndentOverride
* clone() const override
;
381 void Read(LwpObjectStream
* pStrm
) override
;
385 RELATIVE_FIRST
, RELATIVE_REST
, RELATIVE_ALL
388 inline double GetFirst() const;
389 inline double GetLeft() const;
390 inline double GetRight() const;
392 sal_uInt16
GetRelative();
393 bool IsUseRelative();
394 void Override(LwpIndentOverride
* other
);
395 void OverrideIndentAll(sal_Int32 val
);
396 void OverrideIndentFirst(sal_Int32 val
);
397 void OverrideIndentRight(sal_Int32 val
);
398 void OverrideIndentRest(sal_Int32 val
);
399 void OverrideUseRelative(bool use
);
400 void OverrideRelative(sal_uInt16 relative
);
401 sal_Int32
GetMAll() const {return m_nAll
;}
402 sal_Int32
GetMFirst() const {return m_nFirst
;}
403 sal_Int32
GetMRest() const {return m_nRest
;}
404 sal_Int32
GetMRight() const {return m_nRight
;}
405 void SetMAll(sal_Int32 val
){m_nAll
=val
;}
406 void SetMFirst(sal_Int32 val
){m_nFirst
=val
;}
407 void SetMRest(sal_Int32 val
){m_nRest
=val
;}
408 void SetMRight(sal_Int32 val
){m_nRight
=val
;}
411 LwpIndentOverride(LwpIndentOverride
const& rOther
);
412 LwpIndentOverride
& operator=(LwpIndentOverride
const& rOther
) = delete;
424 IO_REL_FIRST
= 0x0100,
425 IO_REL_REST
= 0x0200,
426 IO_REL_FLAGS
= (IO_REL_ALL
| IO_REL_FIRST
| IO_REL_REST
),
427 IO_USE_RELATIVE
= 0x0400
436 inline double LwpIndentOverride::GetFirst() const
439 if (o3tl::checked_sub(m_nFirst
, m_nRest
, nRes
))
440 throw std::range_error("bad len");
441 return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(nRes
));
443 inline double LwpIndentOverride::GetLeft() const
446 if (o3tl::checked_add(m_nAll
, m_nRest
, nRes
))
447 throw std::range_error("bad len");
448 return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(nRes
));
450 inline double LwpIndentOverride::GetRight() const
452 return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nRight
));
455 class LwpBackgroundStuff
;
456 class LwpAmikakeOverride final
: public LwpOverride
459 LwpAmikakeOverride();
461 virtual ~LwpAmikakeOverride() override
;
463 virtual LwpAmikakeOverride
* clone() const override
;
465 void Read(LwpObjectStream
* pStrm
) override
;
469 AMIKAKE_BACKGROUND
= 1,
470 AMIKAKE_CHARACTER
= 2
474 LwpAmikakeOverride(LwpAmikakeOverride
const& rOther
);
475 LwpAmikakeOverride
& operator=(LwpAmikakeOverride
const& rOther
) = delete;
477 std::unique_ptr
<LwpBackgroundStuff
> m_pBackgroundStuff
;
483 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */