LibreOffice Module sw (master)  1
porfld.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_CORE_TEXT_PORFLD_HXX
20 #define INCLUDED_SW_SOURCE_CORE_TEXT_PORFLD_HXX
21 
22 #include <swtypes.hxx>
23 #include <swfont.hxx>
24 #include "porexp.hxx"
25 #include <fmtornt.hxx>
26 #include <o3tl/enumarray.hxx>
27 
28 class SwFont;
29 class SvxBrushItem;
30 class SwFormatVertOrient;
31 
33 {
34  friend class SwTextFormatter;
35 protected:
36  OUString m_aExpand; // The expanded field
37  std::unique_ptr<SwFont> m_pFont; // For multi-line fields
38  TextFrameIndex m_nNextOffset; // Offset of the follow in the original string
40  sal_uInt16 m_nViewWidth; // Screen width for empty fields
41  bool m_bFollow : 1; // 2nd or later part of a field
42  bool m_bLeft : 1; // Used by SwNumberPortion
43  bool m_bHide : 1; // Used by SwNumberPortion
44  bool m_bCenter : 1; // Used by SwNumberPortion
45  bool m_bHasFollow : 1; // Continues on the next line
46  bool m_bAnimated : 1; // Used by SwGrfNumPortion
47  bool m_bNoPaint : 1; // Used by SwGrfNumPortion
48  bool m_bReplace : 1; // Used by SwGrfNumPortion
49  const bool m_bPlaceHolder : 1;
50  bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR)
51 
52  void SetFont( std::unique_ptr<SwFont> pNew ) { m_pFont = std::move(pNew); }
53  bool IsNoLength() const { return m_bNoLength; }
54  void SetNoLength() { m_bNoLength = true; }
55 
56 public:
57  SwFieldPortion( const SwFieldPortion& rField );
58  SwFieldPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFnt = nullptr, bool bPlaceHolder = false );
59  virtual ~SwFieldPortion() override;
60 
61  sal_uInt16 m_nAttrFieldType;
62  void TakeNextOffset( const SwFieldPortion* pField );
63  void CheckScript( const SwTextSizeInfo &rInf );
64  bool HasFont() const { return nullptr != m_pFont; }
65  // #i89179# - made public
66  const SwFont *GetFont() const { return m_pFont.get(); }
67 
68  const OUString& GetExp() const { return m_aExpand; }
69  virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
70  virtual bool Format( SwTextFormatInfo &rInf ) override;
71  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
72 
73  // Empty fields are also allowed
74  virtual SwLinePortion *Compress() override;
75 
76  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
77 
78  bool IsFollow() const { return m_bFollow; }
79  void SetFollow( bool bNew ) { m_bFollow = bNew; }
80 
81  bool IsLeft() const { return m_bLeft; }
82  void SetLeft( bool bNew ) { m_bLeft = bNew; }
83 
84  bool IsHide() const { return m_bHide; }
85  void SetHide( bool bNew ) { m_bHide = bNew; }
86 
87  bool IsCenter() const { return m_bCenter; }
88  void SetCenter( bool bNew ) { m_bCenter = bNew; }
89 
90  bool HasFollow() const { return m_bHasFollow; }
91  void SetHasFollow( bool bNew ) { m_bHasFollow = bNew; }
92 
94  void SetNextOffset(TextFrameIndex nNew) { m_nNextOffset = nNew; }
95 
96  // Field cloner for SplitGlue
97  virtual SwFieldPortion *Clone( const OUString &rExpand ) const;
98 
99  // Extra GetTextSize because of pFnt
100  virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override;
101 
102  // Accessibility: pass information about this portion to the PortionHandler
103  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
104 };
105 
110 {
111 public:
112  SwHiddenPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFntL = nullptr )
113  : SwFieldPortion( rExpand, std::move(pFntL) )
115  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
116  virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
117 
118  // Field cloner for SplitGlue
119  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
120 };
121 
123 {
124 protected:
125  sal_uInt16 nFixWidth; // See Glues
126  sal_uInt16 const nMinDist; // Minimal distance to the text
128 
129 public:
130  SwNumberPortion( const OUString &rExpand,
131  std::unique_ptr<SwFont> pFnt,
132  const bool bLeft,
133  const bool bCenter,
134  const sal_uInt16 nMinDst,
135  const bool bLabelAlignmentPosAndSpaceModeActive );
136  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
137  virtual TextFrameIndex GetCursorOfst(sal_uInt16 nOfst) const override;
138  virtual bool Format( SwTextFormatInfo &rInf ) override;
139 
140  // Field cloner for SplitGlue
141  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
142  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
143 };
144 
146 {
147 public:
148  SwBulletPortion( const sal_Unicode cCh,
149  const OUString& rBulletFollowedBy,
150  std::unique_ptr<SwFont> pFnt,
151  const bool bLeft,
152  const bool bCenter,
153  const sal_uInt16 nMinDst,
154  const bool bLabelAlignmentPosAndSpaceModeActive );
155 };
156 
158 {
159  std::unique_ptr<SvxBrushItem> pBrush;
160  long nId; // For StopAnimation
161  SwTwips nYPos; // _Always_ contains the current RelPos
163  sal_Int16 eOrient;
164 public:
165  SwGrfNumPortion( const OUString& rGraphicFollowedBy,
166  const SvxBrushItem* pGrfBrush,
167  const SwFormatVertOrient* pGrfOrient,
168  const Size& rGrfSize,
169  const bool bLeft,
170  const bool bCenter,
171  const sal_uInt16 nMinDst,
172  const bool bLabelAlignmentPosAndSpaceModeActive );
173  virtual ~SwGrfNumPortion() override;
174  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
175  virtual bool Format( SwTextFormatInfo &rInf ) override;
176 
177  void SetBase( long nLnAscent, long nLnDescent,
178  long nFlyAscent, long nFlyDescent );
179 
180  void StopAnimation( OutputDevice* pOut );
181 
182  bool IsAnimated() const { return m_bAnimated; }
183  void SetAnimated( bool bNew ) { m_bAnimated = bNew; }
184  void SetRelPos( SwTwips nNew ) { nYPos = nNew; }
185  void SetId( long nNew ) const
186  { const_cast<SwGrfNumPortion*>(this)->nId = nNew; }
187  SwTwips GetRelPos() const { return nYPos; }
188  SwTwips GetGrfHeight() const { return nGrfHeight; }
189  sal_Int16 GetOrient() const { return eOrient; }
190 };
191 
201 {
202  sal_uInt16 aPos[6]; // up to six X positions
203  o3tl::enumarray<SwFontScript,sal_uInt16> aWidth; // one width for every scripttype
204  SwFontScript aScrType[6]; // scripttype of every character
205  sal_uInt16 nUpPos; // the Y position of the upper baseline
206  sal_uInt16 nLowPos; // the Y position of the lower baseline
207  sal_uInt8 nProportion; // relative font height
208 public:
209  explicit SwCombinedPortion( const OUString &rExpand );
210  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
211  virtual bool Format( SwTextFormatInfo &rInf ) override;
212  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
213 };
214 
215 namespace sw { namespace mark {
216  class IFieldmark;
217 } }
218 
220 {
221 public:
222  explicit SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
223  : SwFieldPortion(rExpand)
224  , m_pFieldMark(pFieldMark)
225  {
226  }
227  // Field cloner for SplitGlue
228  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
229 
230  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
231 
232 private:
234 };
235 
236 #endif
237 
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bHide
Definition: porfld.hxx:43
SwFieldPortion(const SwFieldPortion &rField)
Definition: porfld.cxx:89
SwNumberPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFnt, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
Definition: porfld.cxx:495
bool m_bFollow
Definition: porfld.hxx:41
bool IsNoLength() const
Definition: porfld.hxx:53
bool m_bNoPaint
Definition: porfld.hxx:47
bool m_bLeft
Definition: porfld.hxx:42
bool IsAnimated() const
Definition: porfld.hxx:182
SwTwips GetRelPos() const
Definition: porfld.hxx:187
void SetCenter(bool bNew)
Definition: porfld.hxx:88
bool HasFont() const
Definition: porfld.hxx:64
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
bool IsCenter() const
Definition: porfld.hxx:87
virtual bool Format(SwTextFormatInfo &rInf) override
We can create multiple NumFields Tricky, if one enters enough previous-text in the dialog box to caus...
Definition: porfld.cxx:533
sal_uInt16 m_nViewWidth
Definition: porfld.hxx:40
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:77
Distinguish only for painting/hide.
Definition: porfld.hxx:109
long SwTwips
Definition: swtypes.hxx:49
std::unique_ptr< SwFont > m_pFont
Definition: porfld.hxx:37
Dialog to specify the properties of drop-down form field.
Definition: accframe.hxx:34
std::unique_ptr< SvxBrushItem > pBrush
Definition: porfld.hxx:159
sal_uInt8 nProportion
Definition: porfld.hxx:207
bool m_bCenter
Definition: porfld.hxx:44
bool m_bAnimated
Definition: porfld.hxx:46
SwFontScript aScrType[6]
Definition: porfld.hxx:204
virtual ~SwFieldPortion() override
Definition: porfld.cxx:113
sal_uInt16 sal_Unicode
SwTwips GetGrfHeight() const
Definition: porfld.hxx:188
virtual ~SwGrfNumPortion() override
Definition: porfld.cxx:792
void SetFollow(bool bNew)
Definition: porfld.hxx:79
void SetHasFollow(bool bNew)
Definition: porfld.hxx:91
SwTwips nYPos
Definition: porfld.hxx:161
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:441
bool m_bHasFollow
Definition: porfld.hxx:45
bool m_bNoLength
Definition: porfld.hxx:50
sal_Int16 GetOrient() const
Definition: porfld.hxx:189
virtual bool Format(SwTextFormatInfo &rInf) override
We can create multiple NumFields Tricky, if one enters enough previous-text in the dialog box to caus...
Definition: porfld.cxx:813
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:1313
SwCombinedPortion(const OUString &rExpand)
Initializes the script array and clears the width array.
Definition: porfld.cxx:1060
void CheckScript(const SwTextSizeInfo &rInf)
Definition: porfld.cxx:195
const OUString & GetExp() const
Definition: porfld.hxx:68
Used in for asian layout specialities to display up to six characters in 2 rows and 2-3 columns...
Definition: porfld.hxx:200
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1089
void SetAnimated(bool bNew)
Definition: porfld.hxx:183
void SetLeft(bool bNew)
Definition: porfld.hxx:82
void SetRelPos(SwTwips nNew)
Definition: porfld.hxx:184
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:489
void SetBase(long nLnAscent, long nLnDescent, long nFlyAscent, long nFlyDescent)
Definition: porfld.cxx:998
sal_uInt16 m_nAttrFieldType
Definition: porfld.hxx:61
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1318
void TakeNextOffset(const SwFieldPortion *pField)
Definition: porfld.cxx:69
bool IsHide() const
Definition: porfld.hxx:84
TextFrameIndex m_nNextOffset
Definition: porfld.hxx:38
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:96
sal_uInt16 const nMinDist
Definition: porfld.hxx:126
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:471
TextFrameIndex m_nNextScriptChg
Definition: porfld.hxx:39
bool IsLeft() const
Definition: porfld.hxx:81
virtual SwLinePortion * Compress() override
Definition: porfld.cxx:51
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:1143
OUString m_aExpand
Definition: porfld.hxx:36
virtual void HandlePortion(SwPortionHandler &rPH) const override
Definition: porfld.cxx:452
sal_uInt16 nFixWidth
Definition: porfld.hxx:125
SwHiddenPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFntL=nullptr)
Definition: porfld.hxx:112
void SetHide(bool bNew)
Definition: porfld.hxx:85
void SetNoLength()
Definition: porfld.hxx:54
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
virtual void FormatEOL(SwTextFormatInfo &rInf) override
A FormatEOL indicates that the subsequent text did not fit onto the line anymore. ...
Definition: porfld.cxx:609
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:292
bool const mbLabelAlignmentPosAndSpaceModeActive
Definition: porfld.hxx:127
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:120
unsigned char sal_uInt8
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:233
SwGrfNumPortion(const OUString &rGraphicFollowedBy, const SvxBrushItem *pGrfBrush, const SwFormatVertOrient *pGrfOrient, const Size &rGrfSize, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
Definition: porfld.cxx:753
bool IsFollow() const
Definition: porfld.hxx:78
const SwFont * GetFont() const
Definition: porfld.hxx:66
SwTwips nGrfHeight
Definition: porfld.hxx:162
sal_Int16 eOrient
Definition: porfld.hxx:163
bool HasFollow() const
Definition: porfld.hxx:90
o3tl::enumarray< SwFontScript, sal_uInt16 > aWidth
Definition: porfld.hxx:203
void SetFont(std::unique_ptr< SwFont > pNew)
Definition: porfld.hxx:52
SwBulletPortion(const sal_Unicode cCh, const OUString &rBulletFollowedBy, std::unique_ptr< SwFont > pFnt, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
Definition: porfld.cxx:737
SwFontScript
Definition: swfont.hxx:119
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:479
SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
Definition: porfld.hxx:222
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:428
sal_uInt16 nUpPos
Definition: porfld.hxx:205
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: porfld.cxx:464
virtual void Paint(const SwTextPaintInfo &rInf) const override
A hidden NumberPortion is not displayed, unless there are TextPortions in this line or there's only o...
Definition: porfld.cxx:878
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:1306
void SetNextOffset(TextFrameIndex nNew)
Definition: porfld.hxx:94
sal_uInt16 nLowPos
Definition: porfld.hxx:206
bool m_bReplace
Definition: porfld.hxx:48
virtual TextFrameIndex GetCursorOfst(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porfld.cxx:512
virtual SwFieldPortion * Clone(const OUString &rExpand) const
Definition: porfld.cxx:54
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:517
virtual void Paint(const SwTextPaintInfo &rInf) const override
A hidden NumberPortion is not displayed, unless there are TextPortions in this line or there's just o...
Definition: porfld.cxx:624
const bool m_bPlaceHolder
Definition: porfld.hxx:49
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
TextFrameIndex GetNextOffset() const
Definition: porfld.hxx:93
void SetId(long nNew) const
Definition: porfld.hxx:185
sal_uInt16 aPos[6]
Definition: porfld.hxx:202
void StopAnimation(OutputDevice *pOut)
Definition: porfld.cxx:803