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 <swtypes.hxx>
23 #include <swfont.hxx>
24 #include "porexp.hxx"
25 #include <o3tl/enumarray.hxx>
26 
27 class SvxBrushItem;
28 class SwFormatVertOrient;
29 
31 {
32  friend class SwTextFormatter;
33 protected:
34  OUString m_aExpand; // The expanded field
35  std::unique_ptr<SwFont> m_pFont; // For multi-line fields
36  TextFrameIndex m_nNextOffset; // Offset of the follow in the original string
38  TextFrameIndex m_nFieldLen; //< Length of field text, 1 for normal fields, any number for input fields
39  // TODO ^ do we need this as member or is base class len enough?
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, TextFrameIndex nLen = TextFrameIndex(1));
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 
97 
98  // Field cloner for SplitGlue
99  virtual SwFieldPortion *Clone( const OUString &rExpand ) const;
100 
101  // Extra GetTextSize because of pFnt
102  virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override;
103 
104  // Accessibility: pass information about this portion to the PortionHandler
105  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
106 };
107 
112 {
113 public:
114  SwHiddenPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFntL = nullptr )
115  : SwFieldPortion( rExpand, std::move(pFntL) )
117  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
118  virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
119 
120  // Field cloner for SplitGlue
121  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
122 };
123 
125 {
126 protected:
127  sal_uInt16 nFixWidth; // See Glues
128  sal_uInt16 nMinDist; // Minimal distance to the text
130 
131 public:
132  SwNumberPortion( const OUString &rExpand,
133  std::unique_ptr<SwFont> pFnt,
134  const bool bLeft,
135  const bool bCenter,
136  const sal_uInt16 nMinDst,
137  const bool bLabelAlignmentPosAndSpaceModeActive );
138  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
139  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
140  virtual bool Format( SwTextFormatInfo &rInf ) override;
141 
142  // Field cloner for SplitGlue
143  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
144  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
145 };
146 
148 {
149 public:
150  SwBulletPortion( const sal_UCS4 cCh,
151  const OUString& rBulletFollowedBy,
152  std::unique_ptr<SwFont> pFnt,
153  const bool bLeft,
154  const bool bCenter,
155  const sal_uInt16 nMinDst,
156  const bool bLabelAlignmentPosAndSpaceModeActive );
157 };
158 
160 {
161  std::unique_ptr<SvxBrushItem> pBrush;
162  tools::Long nId; // For StopAnimation
163  SwTwips nYPos; // _Always_ contains the current RelPos
165  sal_Int16 eOrient;
166 public:
167  SwGrfNumPortion( const OUString& rGraphicFollowedBy,
168  const SvxBrushItem* pGrfBrush,
169  OUString const & referer,
170  const SwFormatVertOrient* pGrfOrient,
171  const Size& rGrfSize,
172  const bool bLeft,
173  const bool bCenter,
174  const sal_uInt16 nMinDst,
175  const bool bLabelAlignmentPosAndSpaceModeActive );
176  virtual ~SwGrfNumPortion() override;
177  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
178  virtual bool Format( SwTextFormatInfo &rInf ) override;
179 
180  void SetBase( tools::Long nLnAscent, tools::Long nLnDescent,
181  tools::Long nFlyAscent, tools::Long nFlyDescent );
182 
183  void StopAnimation( const OutputDevice* pOut );
184 
185  bool IsAnimated() const { return m_bAnimated; }
186  void SetAnimated( bool bNew ) { m_bAnimated = bNew; }
187  void SetRelPos( SwTwips nNew ) { nYPos = nNew; }
188  void SetId( tools::Long nNew ) const
189  { const_cast<SwGrfNumPortion*>(this)->nId = nNew; }
190  SwTwips GetRelPos() const { return nYPos; }
191  SwTwips GetGrfHeight() const { return nGrfHeight; }
192  sal_Int16 GetOrient() const { return eOrient; }
193 };
194 
204 {
205  sal_uInt16 aPos[6]; // up to six X positions
206  o3tl::enumarray<SwFontScript,sal_uInt16> aWidth = {}; // one width for every scripttype
207  SwFontScript aScrType[6]; // scripttype of every character
208  sal_uInt16 nUpPos; // the Y position of the upper baseline
209  sal_uInt16 nLowPos; // the Y position of the lower baseline
210  sal_uInt8 nProportion; // relative font height
211 public:
212  explicit SwCombinedPortion( const OUString &rExpand );
213  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
214  virtual bool Format( SwTextFormatInfo &rInf ) override;
215  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
216 };
217 
218 namespace sw::mark { class IFieldmark; }
219 
221 {
222 public:
223  explicit SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
224  : SwFieldPortion(rExpand)
225  , m_pFieldMark(pFieldMark)
226  {
227  }
228  // Field cloner for SplitGlue
229  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
230 
231  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
232 
233 private:
235 };
236 
238 {
239 public:
240  explicit SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
241  : SwFieldPortion("")
242  , m_pFieldMark(pFieldMark)
243  , m_bStart(bStart)
244  {
245  }
246  // Field cloner for SplitGlue
247  virtual SwFieldPortion *Clone( const OUString &rExpand) const override;
248 
249  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
250 
251 private:
253  bool m_bStart;
254 };
255 
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bHide
Definition: porfld.hxx:43
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:41
bool IsNoLength() const
Definition: porfld.hxx:53
bool m_bNoPaint
Definition: porfld.hxx:47
bool m_bLeft
Definition: porfld.hxx:42
void StopAnimation(const OutputDevice *pOut)
Definition: porfld.cxx:806
sal_uInt32 sal_UCS4
bool IsAnimated() const
Definition: porfld.hxx:185
SwTwips GetRelPos() const
Definition: porfld.hxx:190
void SetCenter(bool bNew)
Definition: porfld.hxx:88
bool HasFont() const
Definition: porfld.hxx:64
long Long
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:536
sal_uInt16 m_nViewWidth
Definition: porfld.hxx:40
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:75
Distinguish only for painting/hide.
Definition: porfld.hxx:111
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:252
std::unique_ptr< SwFont > m_pFont
Definition: porfld.hxx:35
std::unique_ptr< SvxBrushItem > pBrush
Definition: porfld.hxx:161
sal_uInt8 nProportion
Definition: porfld.hxx:210
bool m_bCenter
Definition: porfld.hxx:44
bool m_bAnimated
Definition: porfld.hxx:46
SwFontScript aScrType[6]
Definition: porfld.hxx:207
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:191
virtual ~SwGrfNumPortion() override
Definition: porfld.cxx:795
void SetFollow(bool bNew)
Definition: porfld.hxx:79
void SetHasFollow(bool bNew)
Definition: porfld.hxx:91
SwTwips nYPos
Definition: porfld.hxx:163
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:444
bool m_bHasFollow
Definition: porfld.hxx:45
bool m_bNoLength
Definition: porfld.hxx:50
sal_Int16 GetOrient() const
Definition: porfld.hxx:192
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:68
Used in for asian layout specialities to display up to six characters in 2 rows and 2-3 columns...
Definition: porfld.hxx:203
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1090
void SetAnimated(bool bNew)
Definition: porfld.hxx:186
void SetLeft(bool bNew)
Definition: porfld.hxx:82
tools::Long nId
Definition: porfld.hxx:162
void SetRelPos(SwTwips nNew)
Definition: porfld.hxx:187
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:492
sal_uInt16 nMinDist
Definition: porfld.hxx:128
sal_uInt16 m_nAttrFieldType
Definition: porfld.hxx:61
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:84
TextFrameIndex m_nNextOffset
Definition: porfld.hxx:36
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:94
TextFrameIndex GetFieldLen() const
Definition: porfld.hxx:96
SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
Definition: porfld.hxx:240
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1337
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:474
TextFrameIndex m_nNextScriptChg
Definition: porfld.hxx:37
bool IsLeft() const
Definition: porfld.hxx:81
virtual SwLinePortion * Compress() override
Definition: porfld.cxx:49
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:1144
OUString m_aExpand
Definition: porfld.hxx:34
virtual void HandlePortion(SwPortionHandler &rPH) const override
Definition: porfld.cxx:455
bool mbLabelAlignmentPosAndSpaceModeActive
Definition: porfld.hxx:129
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porfld.cxx:515
sal_uInt16 nFixWidth
Definition: porfld.hxx:127
SwHiddenPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFntL=nullptr)
Definition: porfld.hxx:114
SwBulletPortion(const sal_UCS4 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:740
tools::Long SwTwips
Definition: swtypes.hxx:49
TextFrameIndex m_nFieldLen
Definition: porfld.hxx:38
void SetHide(bool bNew)
Definition: porfld.hxx:85
void SetNoLength()
Definition: porfld.hxx:54
void SetId(tools::Long nNew) const
Definition: porfld.hxx:188
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:234
bool IsFollow() const
Definition: porfld.hxx:78
const SwFont * GetFont() const
Definition: porfld.hxx:66
SwTwips nGrfHeight
Definition: porfld.hxx:164
sal_Int16 eOrient
Definition: porfld.hxx:165
bool HasFollow() const
Definition: porfld.hxx:90
o3tl::enumarray< SwFontScript, sal_uInt16 > aWidth
Definition: porfld.hxx:206
void SetFont(std::unique_ptr< SwFont > pNew)
Definition: porfld.hxx:52
void SetBase(tools::Long nLnAscent, tools::Long nLnDescent, tools::Long nFlyAscent, tools::Long nFlyDescent)
Definition: porfld.cxx:1001
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:223
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:431
sal_uInt16 nUpPos
Definition: porfld.hxx:208
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:94
sal_uInt16 nLowPos
Definition: porfld.hxx:209
bool m_bReplace
Definition: porfld.hxx:48
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: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
sal_uInt16 aPos[6]
Definition: porfld.hxx:205