tdf#119856: thread-proof creating frames and setting menus
[LibreOffice.git] / lotuswordpro / inc / lwpoverride.hxx
blob19d059616b87ce760e6fbb3d6562e208e0df3191
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 ************************************************************************/
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>
67 #include <memory>
69 class LwpObjectStream;
71 enum STATE
73 STATE_OFF = 0,
74 STATE_ON = 1,
75 STATE_STYLE = 2
78 class LwpOverride
80 public:
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);
91 void Clear();
93 void Override(sal_uInt16 nBits, STATE eState);
95 protected:
96 explicit LwpOverride(LwpOverride const& rOther);
98 private:
99 LwpOverride& operator=(LwpOverride const& rOther) = delete;
101 protected:
102 sal_uInt16 m_nValues;
103 sal_uInt16 m_nOverride;
104 sal_uInt16 m_nApply;
107 class LwpTextLanguageOverride final : public LwpOverride
109 public:
110 LwpTextLanguageOverride() : m_nLanguage(0) {}
112 virtual LwpTextLanguageOverride* clone() const override;
114 void Read(LwpObjectStream* pStrm) override;
116 private:
117 LwpTextLanguageOverride(LwpTextLanguageOverride const& rOther);
118 LwpTextLanguageOverride& operator=(LwpTextLanguageOverride const& rOther) = delete;
120 sal_uInt16 m_nLanguage;
123 class LwpTextAttributeOverride final : public LwpOverride
125 public:
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;
134 bool IsHighlight();
136 private:
137 LwpTextAttributeOverride(LwpTextAttributeOverride const& rOther);
138 LwpTextAttributeOverride& operator=(LwpTextAttributeOverride const& rOther) = delete;
140 enum{
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
154 public:
155 LwpKinsokuOptsOverride() : m_nLevels(0) {}
157 virtual LwpKinsokuOptsOverride* clone() const override;
159 void Read(LwpObjectStream* pStrm) override;
161 private:
162 LwpKinsokuOptsOverride(LwpKinsokuOptsOverride const& rOther);
163 LwpKinsokuOptsOverride& operator=(LwpKinsokuOptsOverride const& rOther) = delete;
165 sal_uInt16 m_nLevels;
168 class LwpBulletOverride final : public LwpOverride
170 public:
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;}
198 private:
199 LwpBulletOverride(LwpBulletOverride const& rOther);
200 LwpBulletOverride& operator=(LwpBulletOverride const& rOther) = delete;
202 enum
204 BO_SILVERBULLET = 0x01,
205 // 0x02 is free
206 BO_RIGHTALIGN = 0x04,
207 BO_EDITABLE = 0x08,
208 BO_SKIP = 0x10
211 LwpObjectID m_SilverBullet;
212 bool m_bIsNull;
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
267 public:
268 LwpAlignmentOverride() : m_nAlignType(ALIGN_LEFT), m_nPosition(0), m_nAlignChar(0){}
270 virtual LwpAlignmentOverride* clone() const override;
272 void Read(LwpObjectStream* pStrm) override;
274 enum AlignType
276 ALIGN_LEFT = 0,
277 ALIGN_RIGHT = 1,
278 ALIGN_CENTER = 2,
279 ALIGN_JUSTIFY = 3,
280 ALIGN_JUSTIFYALL = 4,
281 ALIGN_NUMERICLEFT = 5,
282 ALIGN_NUMERICRIGHT = 6,
283 ALIGN_SQUEEZE = 7
286 AlignType GetAlignType(){ return m_nAlignType; }
287 void Override(LwpAlignmentOverride* other);
288 void OverrideAlignment(AlignType val);
290 private:
291 LwpAlignmentOverride(LwpAlignmentOverride const& rOther);
292 LwpAlignmentOverride& operator=(LwpAlignmentOverride const& rOther) = delete;
294 enum
296 AO_TYPE = 0x01,
297 AO_POSITION = 0x02,
298 AO_CHAR = 0x04
301 AlignType m_nAlignType;
302 sal_uInt32 m_nPosition;
303 sal_uInt16 m_nAlignChar;
306 class LwpSpacingCommonOverride final : public LwpOverride
308 public:
309 LwpSpacingCommonOverride() : m_nSpacingType(SPACING_NONE), m_nAmount(0), m_nMultiple(65536){}
311 virtual LwpSpacingCommonOverride* clone() const override;
313 void Read(LwpObjectStream* pStrm) override;
315 enum SpacingType
317 SPACING_DYNAMIC = 0,
318 SPACING_LEADING = 1,
319 SPACING_CUSTOM = 2,
320 SPACING_NONE = 3
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);
332 private:
333 LwpSpacingCommonOverride(LwpSpacingCommonOverride const& rOther);
334 LwpSpacingCommonOverride& operator=(LwpSpacingCommonOverride const& rOther) = delete;
336 enum
338 SPO_TYPE = 0x01,
339 SPO_AMOUNT = 0x02,
340 SPO_MULTIPLE= 0x04
342 SpacingType m_nSpacingType;//sal_uInt16
343 sal_Int32 m_nAmount;
344 sal_Int32 m_nMultiple;
347 class LwpSpacingOverride final : public LwpOverride
349 public:
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();}
364 private:
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
376 public:
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;
383 enum
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;}
410 private:
411 LwpIndentOverride(LwpIndentOverride const& rOther);
412 LwpIndentOverride& operator=(LwpIndentOverride const& rOther) = delete;
414 enum
416 IO_ALL = 0x0001,
417 IO_FIRST = 0x0002,
418 IO_REST = 0x0004,
419 IO_RIGHT = 0x0008,
420 IO_HANGING = 0x0010,
421 IO_EQUAL = 0x0020,
422 IO_BODY = 0x0040,
423 IO_REL_ALL = 0x0080,
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
430 sal_Int32 m_nAll;
431 sal_Int32 m_nFirst;
432 sal_Int32 m_nRest;
433 sal_Int32 m_nRight;
436 inline double LwpIndentOverride::GetFirst() const
438 sal_Int32 nRes;
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
445 sal_Int32 nRes;
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
458 public:
459 LwpAmikakeOverride();
461 virtual ~LwpAmikakeOverride() override;
463 virtual LwpAmikakeOverride* clone() const override;
465 void Read(LwpObjectStream* pStrm) override;
466 enum
468 AMIKAKE_NONE = 0,
469 AMIKAKE_BACKGROUND = 1,
470 AMIKAKE_CHARACTER = 2
473 private:
474 LwpAmikakeOverride(LwpAmikakeOverride const& rOther);
475 LwpAmikakeOverride& operator=(LwpAmikakeOverride const& rOther) = delete;
477 std::unique_ptr<LwpBackgroundStuff> m_pBackgroundStuff;
478 sal_uInt16 m_nType;
481 #endif
483 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */