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 <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  sal_uInt16 m_nViewWidth; // Screen width for empty fields
39  bool m_bFollow : 1; // 2nd or later part of a field
40  bool m_bLeft : 1; // Used by SwNumberPortion
41  bool m_bHide : 1; // Used by SwNumberPortion
42  bool m_bCenter : 1; // Used by SwNumberPortion
43  bool m_bHasFollow : 1; // Continues on the next line
44  bool m_bAnimated : 1; // Used by SwGrfNumPortion
45  bool m_bNoPaint : 1; // Used by SwGrfNumPortion
46  bool m_bReplace : 1; // Used by SwGrfNumPortion
47  const bool m_bPlaceHolder : 1;
48  bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR)
49 
50  void SetFont( std::unique_ptr<SwFont> pNew ) { m_pFont = std::move(pNew); }
51  bool IsNoLength() const { return m_bNoLength; }
52  void SetNoLength() { m_bNoLength = true; }
53 
54 public:
55  SwFieldPortion( const SwFieldPortion& rField );
56  SwFieldPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFnt = nullptr, bool bPlaceHolder = false );
57  virtual ~SwFieldPortion() override;
58 
59  sal_uInt16 m_nAttrFieldType;
60  void TakeNextOffset( const SwFieldPortion* pField );
61  void CheckScript( const SwTextSizeInfo &rInf );
62  bool HasFont() const { return nullptr != m_pFont; }
63  // #i89179# - made public
64  const SwFont *GetFont() const { return m_pFont.get(); }
65 
66  const OUString& GetExp() const { return m_aExpand; }
67  virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
68  virtual bool Format( SwTextFormatInfo &rInf ) override;
69  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
70 
71  // Empty fields are also allowed
72  virtual SwLinePortion *Compress() override;
73 
74  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
75 
76  bool IsFollow() const { return m_bFollow; }
77  void SetFollow( bool bNew ) { m_bFollow = bNew; }
78 
79  bool IsLeft() const { return m_bLeft; }
80  void SetLeft( bool bNew ) { m_bLeft = bNew; }
81 
82  bool IsHide() const { return m_bHide; }
83  void SetHide( bool bNew ) { m_bHide = bNew; }
84 
85  bool IsCenter() const { return m_bCenter; }
86  void SetCenter( bool bNew ) { m_bCenter = bNew; }
87 
88  bool HasFollow() const { return m_bHasFollow; }
89  void SetHasFollow( bool bNew ) { m_bHasFollow = bNew; }
90 
92  void SetNextOffset(TextFrameIndex nNew) { m_nNextOffset = nNew; }
93 
94  // Field cloner for SplitGlue
95  virtual SwFieldPortion *Clone( const OUString &rExpand ) const;
96 
97  // Extra GetTextSize because of pFnt
98  virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override;
99 
100  // Accessibility: pass information about this portion to the PortionHandler
101  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
102 };
103 
108 {
109 public:
110  SwHiddenPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFntL = nullptr )
111  : SwFieldPortion( rExpand, std::move(pFntL) )
113  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
114  virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
115 
116  // Field cloner for SplitGlue
117  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
118 };
119 
121 {
122 protected:
123  sal_uInt16 nFixWidth; // See Glues
124  sal_uInt16 const nMinDist; // Minimal distance to the text
126 
127 public:
128  SwNumberPortion( const OUString &rExpand,
129  std::unique_ptr<SwFont> pFnt,
130  const bool bLeft,
131  const bool bCenter,
132  const sal_uInt16 nMinDst,
133  const bool bLabelAlignmentPosAndSpaceModeActive );
134  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
135  virtual TextFrameIndex GetCursorOfst(sal_uInt16 nOfst) const override;
136  virtual bool Format( SwTextFormatInfo &rInf ) override;
137 
138  // Field cloner for SplitGlue
139  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
140  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
141 };
142 
144 {
145 public:
146  SwBulletPortion( const sal_Unicode cCh,
147  const OUString& rBulletFollowedBy,
148  std::unique_ptr<SwFont> pFnt,
149  const bool bLeft,
150  const bool bCenter,
151  const sal_uInt16 nMinDst,
152  const bool bLabelAlignmentPosAndSpaceModeActive );
153 };
154 
156 {
157  std::unique_ptr<SvxBrushItem> pBrush;
158  long nId; // For StopAnimation
159  SwTwips nYPos; // _Always_ contains the current RelPos
161  sal_Int16 eOrient;
162 public:
163  SwGrfNumPortion( const OUString& rGraphicFollowedBy,
164  const SvxBrushItem* pGrfBrush,
165  OUString const & referer,
166  const SwFormatVertOrient* pGrfOrient,
167  const Size& rGrfSize,
168  const bool bLeft,
169  const bool bCenter,
170  const sal_uInt16 nMinDst,
171  const bool bLabelAlignmentPosAndSpaceModeActive );
172  virtual ~SwGrfNumPortion() override;
173  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
174  virtual bool Format( SwTextFormatInfo &rInf ) override;
175 
176  void SetBase( long nLnAscent, long nLnDescent,
177  long nFlyAscent, long nFlyDescent );
178 
179  void StopAnimation( OutputDevice* pOut );
180 
181  bool IsAnimated() const { return m_bAnimated; }
182  void SetAnimated( bool bNew ) { m_bAnimated = bNew; }
183  void SetRelPos( SwTwips nNew ) { nYPos = nNew; }
184  void SetId( long nNew ) const
185  { const_cast<SwGrfNumPortion*>(this)->nId = nNew; }
186  SwTwips GetRelPos() const { return nYPos; }
187  SwTwips GetGrfHeight() const { return nGrfHeight; }
188  sal_Int16 GetOrient() const { return eOrient; }
189 };
190 
200 {
201  sal_uInt16 aPos[6]; // up to six X positions
202  o3tl::enumarray<SwFontScript,sal_uInt16> aWidth; // one width for every scripttype
203  SwFontScript aScrType[6]; // scripttype of every character
204  sal_uInt16 nUpPos; // the Y position of the upper baseline
205  sal_uInt16 nLowPos; // the Y position of the lower baseline
206  sal_uInt8 nProportion; // relative font height
207 public:
208  explicit SwCombinedPortion( const OUString &rExpand );
209  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
210  virtual bool Format( SwTextFormatInfo &rInf ) override;
211  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
212 };
213 
214 namespace sw { namespace mark {
215  class IFieldmark;
216 } }
217 
219 {
220 public:
221  explicit SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
222  : SwFieldPortion(rExpand)
223  , m_pFieldMark(pFieldMark)
224  {
225  }
226  // Field cloner for SplitGlue
227  virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
228 
229  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
230 
231 private:
233 };
234 
236 {
237 public:
238  explicit SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
239  : SwFieldPortion("")
240  , m_pFieldMark(pFieldMark)
241  , m_bStart(bStart)
242  {
243  }
244  // Field cloner for SplitGlue
245  virtual SwFieldPortion *Clone( const OUString &rExpand) const override;
246 
247  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
248 
249 private:
251  bool m_bStart;
252 };
253 
254 #endif
255 
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bHide
Definition: porfld.hxx:41
SwFieldPortion(const SwFieldPortion &rField)
Definition: porfld.cxx:90
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:496
bool m_bFollow
Definition: porfld.hxx:39
bool IsNoLength() const
Definition: porfld.hxx:51
bool m_bNoPaint
Definition: porfld.hxx:45
bool m_bLeft
Definition: porfld.hxx:40
bool IsAnimated() const
Definition: porfld.hxx:181
SwTwips GetRelPos() const
Definition: porfld.hxx:186
void SetCenter(bool bNew)
Definition: porfld.hxx:86
bool HasFont() const
Definition: porfld.hxx:62
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
bool IsCenter() const
Definition: porfld.hxx:85
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:534
sal_uInt16 m_nViewWidth
Definition: porfld.hxx:38
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:74
Distinguish only for painting/hide.
Definition: porfld.hxx:107
long SwTwips
Definition: swtypes.hxx:49
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:250
std::unique_ptr< SwFont > m_pFont
Definition: porfld.hxx:35
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:38
std::unique_ptr< SvxBrushItem > pBrush
Definition: porfld.hxx:157
sal_uInt8 nProportion
Definition: porfld.hxx:206
bool m_bCenter
Definition: porfld.hxx:42
bool m_bAnimated
Definition: porfld.hxx:44
SwFontScript aScrType[6]
Definition: porfld.hxx:203
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:1332
virtual ~SwFieldPortion() override
Definition: porfld.cxx:114
sal_uInt16 sal_Unicode
SwTwips GetGrfHeight() const
Definition: porfld.hxx:187
virtual ~SwGrfNumPortion() override
Definition: porfld.cxx:793
void SetFollow(bool bNew)
Definition: porfld.hxx:77
void SetHasFollow(bool bNew)
Definition: porfld.hxx:89
SwTwips nYPos
Definition: porfld.hxx:159
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:442
bool m_bHasFollow
Definition: porfld.hxx:43
bool m_bNoLength
Definition: porfld.hxx:48
sal_Int16 GetOrient() const
Definition: porfld.hxx:188
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:814
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:1061
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:754
void CheckScript(const SwTextSizeInfo &rInf)
Definition: porfld.cxx:196
const OUString & GetExp() const
Definition: porfld.hxx:66
Used in for asian layout specialities to display up to six characters in 2 rows and 2-3 columns...
Definition: porfld.hxx:199
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1090
void SetAnimated(bool bNew)
Definition: porfld.hxx:182
void SetLeft(bool bNew)
Definition: porfld.hxx:80
void SetRelPos(SwTwips nNew)
Definition: porfld.hxx:183
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:490
void SetBase(long nLnAscent, long nLnDescent, long nFlyAscent, long nFlyDescent)
Definition: porfld.cxx:999
sal_uInt16 m_nAttrFieldType
Definition: porfld.hxx:59
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1319
void TakeNextOffset(const SwFieldPortion *pField)
Definition: porfld.cxx:70
bool IsHide() const
Definition: porfld.hxx:82
TextFrameIndex m_nNextOffset
Definition: porfld.hxx:36
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:93
sal_uInt16 const nMinDist
Definition: porfld.hxx:124
SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
Definition: porfld.hxx:238
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1337
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:472
TextFrameIndex m_nNextScriptChg
Definition: porfld.hxx:37
bool IsLeft() const
Definition: porfld.hxx:79
virtual SwLinePortion * Compress() override
Definition: porfld.cxx:52
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:453
sal_uInt16 nFixWidth
Definition: porfld.hxx:123
SwHiddenPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFntL=nullptr)
Definition: porfld.hxx:110
void SetHide(bool bNew)
Definition: porfld.hxx:83
void SetNoLength()
Definition: porfld.hxx:52
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:49
virtual void FormatEOL(SwTextFormatInfo &rInf) override
A FormatEOL indicates that the subsequent text did not fit onto the line anymore. ...
Definition: porfld.cxx:610
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:293
bool const mbLabelAlignmentPosAndSpaceModeActive
Definition: porfld.hxx:125
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:121
unsigned char sal_uInt8
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:232
bool IsFollow() const
Definition: porfld.hxx:76
const SwFont * GetFont() const
Definition: porfld.hxx:64
SwTwips nGrfHeight
Definition: porfld.hxx:160
sal_Int16 eOrient
Definition: porfld.hxx:161
bool HasFollow() const
Definition: porfld.hxx:88
o3tl::enumarray< SwFontScript, sal_uInt16 > aWidth
Definition: porfld.hxx:202
void SetFont(std::unique_ptr< SwFont > pNew)
Definition: porfld.hxx:50
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:738
SwFontScript
Definition: swfont.hxx:122
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:480
SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
Definition: porfld.hxx:221
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:429
sal_uInt16 nUpPos
Definition: porfld.hxx:204
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: porfld.cxx:465
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:879
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:1307
void SetNextOffset(TextFrameIndex nNew)
Definition: porfld.hxx:92
sal_uInt16 nLowPos
Definition: porfld.hxx:205
bool m_bReplace
Definition: porfld.hxx:46
virtual TextFrameIndex GetCursorOfst(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porfld.cxx:513
virtual SwFieldPortion * Clone(const OUString &rExpand) const
Definition: porfld.cxx:55
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:518
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:625
const bool m_bPlaceHolder
Definition: porfld.hxx:47
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:91
void SetId(long nNew) const
Definition: porfld.hxx:184
sal_uInt16 aPos[6]
Definition: porfld.hxx:201
void StopAnimation(OutputDevice *pOut)
Definition: porfld.cxx:804