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 
20 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <string_view>
25 
26 #include <swtypes.hxx>
27 #include <swfont.hxx>
28 #include "porexp.hxx"
29 #include <o3tl/enumarray.hxx>
30 
31 class SvxBrushItem;
32 class SwFormatVertOrient;
33 
35 {
36  friend class SwTextFormatter;
37 protected:
38  OUString m_aExpand; // The expanded field
39  std::unique_ptr<SwFont> m_pFont; // For multi-line fields
40  TextFrameIndex m_nNextOffset; // Offset of the follow in the original string
42  TextFrameIndex m_nFieldLen; //< Length of field text, 1 for normal fields, any number for input fields
43  // TODO ^ do we need this as member or is base class len enough?
44  sal_uInt16 m_nViewWidth; // Screen width for empty fields
45  bool m_bFollow : 1; // 2nd or later part of a field
46  bool m_bLeft : 1; // Used by SwNumberPortion
47  bool m_bHide : 1; // Used by SwNumberPortion
48  bool m_bCenter : 1; // Used by SwNumberPortion
49  bool m_bHasFollow : 1; // Continues on the next line
50  bool m_bAnimated : 1; // Used by SwGrfNumPortion
51  bool m_bNoPaint : 1; // Used by SwGrfNumPortion
52  bool m_bReplace : 1; // Used by SwGrfNumPortion
53  const bool m_bPlaceHolder : 1;
54  bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR)
55 
56  void SetFont( std::unique_ptr<SwFont> pNew ) { m_pFont = std::move(pNew); }
57  bool IsNoLength() const { return m_bNoLength; }
58  void SetNoLength() { m_bNoLength = true; }
59 
60 public:
61  SwFieldPortion( const SwFieldPortion& rField );
62  SwFieldPortion(const OUString &rExpand, std::unique_ptr<SwFont> pFnt = nullptr, bool bPlaceHolder = false, TextFrameIndex nLen = TextFrameIndex(1));
63  virtual ~SwFieldPortion() override;
64 
65  sal_uInt16 m_nAttrFieldType;
66  void TakeNextOffset( const SwFieldPortion* pField );
67  void CheckScript( const SwTextSizeInfo &rInf );
68  bool HasFont() const { return nullptr != m_pFont; }
69  // #i89179# - made public
70  const SwFont *GetFont() const { return m_pFont.get(); }
71 
72  const OUString& GetExp() const { return m_aExpand; }
73  virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
74  virtual bool Format( SwTextFormatInfo &rInf ) override;
75  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
76 
77  // Empty fields are also allowed
78  virtual SwLinePortion *Compress() override;
79 
80  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
81 
82  bool IsFollow() const { return m_bFollow; }
83  void SetFollow( bool bNew ) { m_bFollow = bNew; }
84 
85  bool IsLeft() const { return m_bLeft; }
86  void SetLeft( bool bNew ) { m_bLeft = bNew; }
87 
88  bool IsHide() const { return m_bHide; }
89  void SetHide( bool bNew ) { m_bHide = bNew; }
90 
91  bool IsCenter() const { return m_bCenter; }
92  void SetCenter( bool bNew ) { m_bCenter = bNew; }
93 
94  bool HasFollow() const { return m_bHasFollow; }
95  void SetHasFollow( bool bNew ) { m_bHasFollow = bNew; }
96 
98  void SetNextOffset(TextFrameIndex nNew) { m_nNextOffset = nNew; }
99 
101 
102  // Field cloner for SplitGlue
103  virtual SwFieldPortion *Clone( const OUString &rExpand ) const;
104 
105  // Extra GetTextSize because of pFnt
106  virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override;
107 
108  // Accessibility: pass information about this portion to the PortionHandler
109  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
110 };
111 
116 {
117 public:
118  SwHiddenPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFntL = nullptr )
119  : SwFieldPortion( rExpand, std::move(pFntL) )
121  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
122  virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
123 
124  // Field cloner for SplitGlue
125  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
126 };
127 
129 {
130 protected:
131  sal_uInt16 m_nFixWidth; // See Glues
132  sal_uInt16 m_nMinDist; // Minimal distance to the text
134 
135 public:
136  SwNumberPortion( const OUString &rExpand,
137  std::unique_ptr<SwFont> pFnt,
138  const bool bLeft,
139  const bool bCenter,
140  const sal_uInt16 nMinDst,
141  const bool bLabelAlignmentPosAndSpaceModeActive );
142  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
143  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
144  virtual bool Format( SwTextFormatInfo &rInf ) override;
145 
146  // Field cloner for SplitGlue
147  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
148  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
149 };
150 
152 {
153 public:
154  SwBulletPortion( const sal_UCS4 cCh,
155  std::u16string_view rBulletFollowedBy,
156  std::unique_ptr<SwFont> pFnt,
157  const bool bLeft,
158  const bool bCenter,
159  const sal_uInt16 nMinDst,
160  const bool bLabelAlignmentPosAndSpaceModeActive );
161 };
162 
164 {
165  std::unique_ptr<SvxBrushItem> m_pBrush;
166  tools::Long m_nId; // For StopAnimation
167  SwTwips m_nYPos; // _Always_ contains the current RelPos
169  sal_Int16 m_eOrient;
170 public:
171  SwGrfNumPortion( const OUString& rGraphicFollowedBy,
172  const SvxBrushItem* pGrfBrush,
173  OUString const & referer,
174  const SwFormatVertOrient* pGrfOrient,
175  const Size& rGrfSize,
176  const bool bLeft,
177  const bool bCenter,
178  const sal_uInt16 nMinDst,
179  const bool bLabelAlignmentPosAndSpaceModeActive );
180  virtual ~SwGrfNumPortion() override;
181  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
182  virtual bool Format( SwTextFormatInfo &rInf ) override;
183 
184  void SetBase( tools::Long nLnAscent, tools::Long nLnDescent,
185  tools::Long nFlyAscent, tools::Long nFlyDescent );
186 
187  void StopAnimation( const OutputDevice* pOut );
188 
189  bool IsAnimated() const { return m_bAnimated; }
190  void SetAnimated( bool bNew ) { m_bAnimated = bNew; }
191  void SetRelPos( SwTwips nNew ) { m_nYPos = nNew; }
192  void SetId( tools::Long nNew ) const
193  { const_cast<SwGrfNumPortion*>(this)->m_nId = nNew; }
194  SwTwips GetRelPos() const { return m_nYPos; }
195  SwTwips GetGrfHeight() const { return m_nGrfHeight; }
196  sal_Int16 GetOrient() const { return m_eOrient; }
197 };
198 
208 {
209  sal_uInt16 m_aPos[6]; // up to six X positions
210  o3tl::enumarray<SwFontScript,sal_uInt16> m_aWidth = {}; // one width for every scripttype
211  SwFontScript m_aScrType[6]; // scripttype of every character
212  sal_uInt16 m_nUpPos; // the Y position of the upper baseline
213  sal_uInt16 m_nLowPos; // the Y position of the lower baseline
214  sal_uInt8 m_nProportion; // relative font height
215 public:
216  explicit SwCombinedPortion( const OUString &rExpand );
217  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
218  virtual bool Format( SwTextFormatInfo &rInf ) override;
219  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
220 };
221 
222 namespace sw::mark { class IFieldmark; }
223 
225 {
226 public:
227  explicit SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
228  : SwFieldPortion(rExpand)
229  , m_pFieldMark(pFieldMark)
230  {
231  }
232  // Field cloner for SplitGlue
233  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
234 
235  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
236 
237 private:
239 };
240 
242 {
243 public:
244  explicit SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
245  : SwFieldPortion("")
246  , m_pFieldMark(pFieldMark)
247  , m_bStart(bStart)
248  {
249  }
250  // Field cloner for SplitGlue
251  virtual SwFieldPortion *Clone( const OUString &rExpand) const override;
252 
253  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
254 
255 private:
257  bool m_bStart;
258 };
259 
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bHide
Definition: porfld.hxx:47
SwFieldPortion(const SwFieldPortion &rField)
Definition: porfld.cxx:88
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:498
bool m_bFollow
Definition: porfld.hxx:45
bool IsNoLength() const
Definition: porfld.hxx:57
bool m_bNoPaint
Definition: porfld.hxx:51
bool m_bLeft
Definition: porfld.hxx:46
void StopAnimation(const OutputDevice *pOut)
Definition: porfld.cxx:806
sal_uInt32 sal_UCS4
sal_uInt16 m_nLowPos
Definition: porfld.hxx:213
bool IsAnimated() const
Definition: porfld.hxx:189
sal_uInt8 m_nProportion
Definition: porfld.hxx:214
SwTwips GetRelPos() const
Definition: porfld.hxx:194
void SetCenter(bool bNew)
Definition: porfld.hxx:92
bool HasFont() const
Definition: porfld.hxx:68
sal_Int16 m_eOrient
Definition: porfld.hxx:169
long Long
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
bool IsCenter() const
Definition: porfld.hxx:91
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:536
sal_uInt16 m_nViewWidth
Definition: porfld.hxx:44
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:75
Distinguish only for painting/hide.
Definition: porfld.hxx:115
tools::Long m_nId
Definition: porfld.hxx:166
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:256
std::unique_ptr< SwFont > m_pFont
Definition: porfld.hxx:39
bool m_bCenter
Definition: porfld.hxx:48
bool m_bAnimated
Definition: porfld.hxx:50
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:1332
virtual ~SwFieldPortion() override
Definition: porfld.cxx:113
SwTwips GetGrfHeight() const
Definition: porfld.hxx:195
virtual ~SwGrfNumPortion() override
Definition: porfld.cxx:795
void SetFollow(bool bNew)
Definition: porfld.hxx:83
void SetHasFollow(bool bNew)
Definition: porfld.hxx:95
o3tl::enumarray< SwFontScript, sal_uInt16 > m_aWidth
Definition: porfld.hxx:210
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:444
SwFontScript m_aScrType[6]
Definition: porfld.hxx:211
bool m_bHasFollow
Definition: porfld.hxx:49
bool m_bNoLength
Definition: porfld.hxx:54
sal_Int16 GetOrient() const
Definition: porfld.hxx:196
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:816
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:1314
SwCombinedPortion(const OUString &rExpand)
Initializes the script array and clears the width array.
Definition: porfld.cxx:1063
SwGrfNumPortion(const OUString &rGraphicFollowedBy, const SvxBrushItem *pGrfBrush, OUString const &referer, const SwFormatVertOrient *pGrfOrient, const Size &rGrfSize, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
Definition: porfld.cxx:756
void CheckScript(const SwTextSizeInfo &rInf)
Definition: porfld.cxx:198
const OUString & GetExp() const
Definition: porfld.hxx:72
Used in for asian layout specialities to display up to six characters in 2 rows and 2-3 columns...
Definition: porfld.hxx:207
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1090
void SetAnimated(bool bNew)
Definition: porfld.hxx:190
void SetLeft(bool bNew)
Definition: porfld.hxx:86
void SetRelPos(SwTwips nNew)
Definition: porfld.hxx:191
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:492
sal_uInt16 m_nAttrFieldType
Definition: porfld.hxx:65
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1319
void TakeNextOffset(const SwFieldPortion *pField)
Definition: porfld.cxx:67
bool IsHide() const
Definition: porfld.hxx:88
TextFrameIndex m_nNextOffset
Definition: porfld.hxx:40
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:94
TextFrameIndex GetFieldLen() const
Definition: porfld.hxx:100
SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
Definition: porfld.hxx:244
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1337
SwBulletPortion(const sal_UCS4 cCh, std::u16string_view rBulletFollowedBy, std::unique_ptr< SwFont > pFnt, const bool bLeft, const bool bCenter, const sal_uInt16 nMinDst, const bool bLabelAlignmentPosAndSpaceModeActive)
Definition: porfld.cxx:740
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:474
std::unique_ptr< SvxBrushItem > m_pBrush
Definition: porfld.hxx:165
TextFrameIndex m_nNextScriptChg
Definition: porfld.hxx:41
bool IsLeft() const
Definition: porfld.hxx:85
virtual SwLinePortion * Compress() override
Definition: porfld.cxx:49
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:1144
OUString m_aExpand
Definition: porfld.hxx:38
virtual void HandlePortion(SwPortionHandler &rPH) const override
Definition: porfld.cxx:455
bool mbLabelAlignmentPosAndSpaceModeActive
Definition: porfld.hxx:133
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porfld.cxx:515
sal_uInt16 m_nMinDist
Definition: porfld.hxx:132
SwHiddenPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFntL=nullptr)
Definition: porfld.hxx:118
tools::Long SwTwips
Definition: swtypes.hxx:49
TextFrameIndex m_nFieldLen
Definition: porfld.hxx:42
void SetHide(bool bNew)
Definition: porfld.hxx:89
void SetNoLength()
Definition: porfld.hxx:58
void SetId(tools::Long nNew) const
Definition: porfld.hxx:192
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:50
virtual void FormatEOL(SwTextFormatInfo &rInf) override
A FormatEOL indicates that the subsequent text did not fit onto the line anymore. ...
Definition: porfld.cxx:612
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:295
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:118
unsigned char sal_uInt8
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:238
sal_uInt16 m_nFixWidth
Definition: porfld.hxx:131
bool IsFollow() const
Definition: porfld.hxx:82
const SwFont * GetFont() const
Definition: porfld.hxx:70
bool HasFollow() const
Definition: porfld.hxx:94
void SetFont(std::unique_ptr< SwFont > pNew)
Definition: porfld.hxx:56
void SetBase(tools::Long nLnAscent, tools::Long nLnDescent, tools::Long nFlyAscent, tools::Long nFlyDescent)
Definition: porfld.cxx:1001
SwTwips m_nGrfHeight
Definition: porfld.hxx:168
SwFontScript
Definition: swfont.hxx:122
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:482
SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
Definition: porfld.hxx:227
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:431
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: porfld.cxx:467
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:881
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:1307
void SetNextOffset(TextFrameIndex nNew)
Definition: porfld.hxx:98
bool m_bReplace
Definition: porfld.hxx:52
virtual SwFieldPortion * Clone(const OUString &rExpand) const
Definition: porfld.cxx:52
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:520
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:627
const bool m_bPlaceHolder
Definition: porfld.hxx:53
sal_uInt16 m_aPos[6]
Definition: porfld.hxx:209
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:97
sal_uInt16 m_nUpPos
Definition: porfld.hxx:212
SwTwips m_nYPos
Definition: porfld.hxx:167