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
31class SvxBrushItem;
33
35{
36 friend class SwTextFormatter;
37protected:
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 bool m_bContentControl = false;
56
57 void SetFont( std::unique_ptr<SwFont> pNew ) { m_pFont = std::move(pNew); }
58 bool IsNoLength() const { return m_bNoLength; }
59 void SetNoLength() { m_bNoLength = true; }
60
61public:
62 SwFieldPortion( const SwFieldPortion& rField );
63 SwFieldPortion(OUString aExpand, std::unique_ptr<SwFont> pFnt = nullptr, bool bPlaceHolder = false, TextFrameIndex nLen = TextFrameIndex(1));
64 virtual ~SwFieldPortion() override;
65
66 sal_uInt16 m_nAttrFieldType;
67 void TakeNextOffset( const SwFieldPortion* pField );
68 void CheckScript( const SwTextSizeInfo &rInf );
69 bool HasFont() const { return nullptr != m_pFont; }
70 // #i89179# - made public
71 const SwFont *GetFont() const { return m_pFont.get(); }
72
73 const OUString& GetExp() const { return m_aExpand; }
74 virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
75 virtual bool Format( SwTextFormatInfo &rInf ) override;
76 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
77
78 // Empty fields are also allowed
79 virtual SwLinePortion *Compress() override;
80
81 virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
82
83 bool IsFollow() const { return m_bFollow; }
84 void SetFollow( bool bNew ) { m_bFollow = bNew; }
85
86 bool IsLeft() const { return m_bLeft; }
87 void SetLeft( bool bNew ) { m_bLeft = bNew; }
88
89 bool IsHide() const { return m_bHide; }
90 void SetHide( bool bNew ) { m_bHide = bNew; }
91
92 bool IsCenter() const { return m_bCenter; }
93 void SetCenter( bool bNew ) { m_bCenter = bNew; }
94
95 bool HasFollow() const { return m_bHasFollow; }
96 void SetHasFollow( bool bNew ) { m_bHasFollow = bNew; }
97
100
102
103 // Field cloner for SplitGlue
104 virtual SwFieldPortion *Clone( const OUString &rExpand ) const;
105
106 // Extra GetTextSize because of pFnt
107 virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override;
108
109 // Accessibility: pass information about this portion to the PortionHandler
110 virtual void HandlePortion( SwPortionHandler& rPH ) const override;
111
112 void SetContentControl(bool bContentControl) { m_bContentControl = bContentControl; }
113
114 void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
115 TextFrameIndex& nOffset) const override;
116};
117
122{
123public:
124 SwHiddenPortion( const OUString &rExpand, std::unique_ptr<SwFont> pFntL = nullptr )
125 : SwFieldPortion( rExpand, std::move(pFntL) )
127 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
128 virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const override;
129
130 // Field cloner for SplitGlue
131 virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
132};
133
135{
136protected:
137 sal_uInt16 m_nFixWidth; // See Glues
138 sal_uInt16 m_nMinDist; // Minimal distance to the text
140
141public:
142 SwNumberPortion( const OUString &rExpand,
143 std::unique_ptr<SwFont> pFnt,
144 const bool bLeft,
145 const bool bCenter,
146 const sal_uInt16 nMinDst,
147 const bool bLabelAlignmentPosAndSpaceModeActive );
148 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
149 virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
150 virtual bool Format( SwTextFormatInfo &rInf ) override;
151
152 // Field cloner for SplitGlue
153 virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
154 virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
155};
156
158{
159public:
160 SwBulletPortion( const sal_UCS4 cCh,
161 std::u16string_view rBulletFollowedBy,
162 std::unique_ptr<SwFont> pFnt,
163 const bool bLeft,
164 const bool bCenter,
165 const sal_uInt16 nMinDst,
166 const bool bLabelAlignmentPosAndSpaceModeActive );
167};
168
170{
171 std::unique_ptr<SvxBrushItem> m_pBrush;
172 tools::Long m_nId; // For StopAnimation
173 SwTwips m_nYPos; // _Always_ contains the current RelPos
175 sal_Int16 m_eOrient;
176public:
177 SwGrfNumPortion( const OUString& rGraphicFollowedBy,
178 const SvxBrushItem* pGrfBrush,
179 OUString const & referer,
180 const SwFormatVertOrient* pGrfOrient,
181 const Size& rGrfSize,
182 const bool bLeft,
183 const bool bCenter,
184 const sal_uInt16 nMinDst,
185 const bool bLabelAlignmentPosAndSpaceModeActive );
186 virtual ~SwGrfNumPortion() override;
187 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
188 virtual bool Format( SwTextFormatInfo &rInf ) override;
189
190 void SetBase( tools::Long nLnAscent, tools::Long nLnDescent,
191 tools::Long nFlyAscent, tools::Long nFlyDescent );
192
193 void StopAnimation( const OutputDevice* pOut );
194
195 bool IsAnimated() const { return m_bAnimated; }
196 void SetAnimated( bool bNew ) { m_bAnimated = bNew; }
197 void SetRelPos( SwTwips nNew ) { m_nYPos = nNew; }
198 void SetId( tools::Long nNew ) const
199 { const_cast<SwGrfNumPortion*>(this)->m_nId = nNew; }
200 SwTwips GetRelPos() const { return m_nYPos; }
202 sal_Int16 GetOrient() const { return m_eOrient; }
203};
204
214{
215 sal_uInt16 m_aPos[6]; // up to six X positions
216 o3tl::enumarray<SwFontScript,sal_uInt16> m_aWidth; // one width for every scripttype
217 SwFontScript m_aScrType[6]; // scripttype of every character
218 sal_uInt16 m_nUpPos; // the Y position of the upper baseline
219 sal_uInt16 m_nLowPos; // the Y position of the lower baseline
220 sal_uInt8 m_nProportion; // relative font height
221public:
222 explicit SwCombinedPortion( const OUString &rExpand );
223 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
224 virtual bool Format( SwTextFormatInfo &rInf ) override;
225 virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
226};
227
228namespace sw::mark { class IFieldmark; }
229
231{
232public:
233 explicit SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
234 : SwFieldPortion(rExpand)
235 , m_pFieldMark(pFieldMark)
236 {
237 }
238 // Field cloner for SplitGlue
239 virtual SwFieldPortion *Clone( const OUString &rExpand ) const override;
240
241 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
242
243private:
244 sw::mark::IFieldmark* m_pFieldMark;
245};
246
248{
249public:
250 explicit SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
251 : SwFieldPortion("")
252 , m_pFieldMark(pFieldMark)
253 , m_bStart(bStart)
254 {
255 }
256 // Field cloner for SplitGlue
257 virtual SwFieldPortion *Clone( const OUString &rExpand) const override;
258
259 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
260
261private:
262 sw::mark::IFieldmark* m_pFieldMark;
264};
265
266/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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...
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:777
Used in for asian layout specialities to display up to six characters in 2 rows and 2-3 columns.
Definition: porfld.hxx:214
SwFontScript m_aScrType[6]
Definition: porfld.hxx:217
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:1351
sal_uInt16 m_aPos[6]
Definition: porfld.hxx:215
sal_uInt16 m_nUpPos
Definition: porfld.hxx:218
sal_uInt8 m_nProportion
Definition: porfld.hxx:220
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:1188
SwCombinedPortion(const OUString &rExpand)
Initializes the script array and clears the width array.
Definition: porfld.cxx:1104
sal_uInt16 m_nLowPos
Definition: porfld.hxx:219
o3tl::enumarray< SwFontScript, sal_uInt16 > m_aWidth
Definition: porfld.hxx:216
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1134
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:262
SwFieldFormDatePortion(sw::mark::IFieldmark *pFieldMark, bool bStart)
Definition: porfld.hxx:250
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1381
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:1376
sw::mark::IFieldmark * m_pFieldMark
Definition: porfld.hxx:244
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:1358
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:1363
SwFieldFormDropDownPortion(sw::mark::IFieldmark *pFieldMark, const OUString &rExpand)
Definition: porfld.hxx:233
void SetCenter(bool bNew)
Definition: porfld.hxx:93
std::unique_ptr< SwFont > m_pFont
Definition: porfld.hxx:39
bool IsNoLength() const
Definition: porfld.hxx:58
bool IsCenter() const
Definition: porfld.hxx:92
bool IsFollow() const
Definition: porfld.hxx:83
bool HasFont() const
Definition: porfld.hxx:69
TextFrameIndex m_nNextOffset
Definition: porfld.hxx:40
void SetNoLength()
Definition: porfld.hxx:59
bool m_bContentControl
Definition: porfld.hxx:55
OUString m_aExpand
Definition: porfld.hxx:38
void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &nOffset) const override
Definition: porfld.cxx:487
bool m_bNoLength
Definition: porfld.hxx:54
sal_uInt16 m_nViewWidth
Definition: porfld.hxx:44
bool m_bFollow
Definition: porfld.hxx:45
TextFrameIndex GetNextOffset() const
Definition: porfld.hxx:98
bool m_bLeft
Definition: porfld.hxx:46
const bool m_bPlaceHolder
Definition: porfld.hxx:53
void SetNextOffset(TextFrameIndex nNew)
Definition: porfld.hxx:99
void SetLeft(bool bNew)
Definition: porfld.hxx:87
bool m_bAnimated
Definition: porfld.hxx:50
bool IsHide() const
Definition: porfld.hxx:89
virtual SwFieldPortion * Clone(const OUString &rExpand) const
Definition: porfld.cxx:53
bool IsLeft() const
Definition: porfld.hxx:86
virtual void HandlePortion(SwPortionHandler &rPH) const override
Definition: porfld.cxx:482
const SwFont * GetFont() const
Definition: porfld.hxx:71
bool m_bReplace
Definition: porfld.hxx:52
virtual SwLinePortion * Compress() override
Definition: porfld.cxx:50
bool m_bNoPaint
Definition: porfld.hxx:51
bool HasFollow() const
Definition: porfld.hxx:95
TextFrameIndex GetFieldLen() const
Definition: porfld.hxx:101
bool m_bHide
Definition: porfld.hxx:47
void SetHide(bool bNew)
Definition: porfld.hxx:90
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:458
TextFrameIndex m_nFieldLen
Definition: porfld.hxx:42
const OUString & GetExp() const
Definition: porfld.hxx:73
bool m_bCenter
Definition: porfld.hxx:48
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porfld.cxx:304
void SetFollow(bool bNew)
Definition: porfld.hxx:84
void CheckScript(const SwTextSizeInfo &rInf)
Definition: porfld.cxx:207
void SetFont(std::unique_ptr< SwFont > pNew)
Definition: porfld.hxx:57
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:471
void SetContentControl(bool bContentControl)
Definition: porfld.hxx:112
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: porfld.cxx:504
TextFrameIndex m_nNextScriptChg
Definition: porfld.hxx:41
SwFieldPortion(const SwFieldPortion &rField)
Definition: porfld.cxx:89
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porfld.cxx:119
void SetHasFollow(bool bNew)
Definition: porfld.hxx:96
sal_uInt16 m_nAttrFieldType
Definition: porfld.hxx:66
virtual ~SwFieldPortion() override
Definition: porfld.cxx:114
void TakeNextOffset(const SwFieldPortion *pField)
Definition: porfld.cxx:68
bool m_bHasFollow
Definition: porfld.hxx:49
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
Definition: swfont.hxx:135
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
SwTwips GetRelPos() const
Definition: porfld.hxx:200
void SetRelPos(SwTwips nNew)
Definition: porfld.hxx:197
void SetBase(tools::Long nLnAscent, tools::Long nLnDescent, tools::Long nFlyAscent, tools::Long nFlyDescent)
Definition: porfld.cxx:1042
tools::Long m_nId
Definition: porfld.hxx:172
sal_Int16 m_eOrient
Definition: porfld.hxx:175
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:793
void SetAnimated(bool bNew)
Definition: porfld.hxx:196
std::unique_ptr< SvxBrushItem > m_pBrush
Definition: porfld.hxx:171
SwTwips m_nGrfHeight
Definition: porfld.hxx:174
bool IsAnimated() const
Definition: porfld.hxx:195
virtual ~SwGrfNumPortion() override
Definition: porfld.cxx:832
SwTwips GetGrfHeight() const
Definition: porfld.hxx:201
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:853
sal_Int16 GetOrient() const
Definition: porfld.hxx:202
void StopAnimation(const OutputDevice *pOut)
Definition: porfld.cxx:843
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:918
SwTwips m_nYPos
Definition: porfld.hxx:173
void SetId(tools::Long nNew) const
Definition: porfld.hxx:198
Distinguish only for painting/hide.
Definition: porfld.hxx:122
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:511
SwHiddenPortion(const OUString &rExpand, std::unique_ptr< SwFont > pFntL=nullptr)
Definition: porfld.hxx:124
virtual bool GetExpText(const SwTextSizeInfo &rInf, OUString &rText) const override
Definition: porfld.cxx:529
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porfld.cxx:519
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:78
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:101
sal_uInt16 m_nMinDist
Definition: porfld.hxx:138
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:535
bool mbLabelAlignmentPosAndSpaceModeActive
Definition: porfld.hxx:139
sal_uInt16 m_nFixWidth
Definition: porfld.hxx:137
virtual void FormatEOL(SwTextFormatInfo &rInf) override
A FormatEOL indicates that the subsequent text did not fit onto the line anymore.
Definition: porfld.cxx:649
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:664
virtual SwFieldPortion * Clone(const OUString &rExpand) const override
Definition: porfld.cxx:557
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porfld.cxx:552
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:573
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
struct _xmlTextWriter * xmlTextWriterPtr
long Long
SwFontScript
Definition: swfont.hxx:124
tools::Long SwTwips
Definition: swtypes.hxx:51
unsigned char sal_uInt8
sal_uInt32 sal_UCS4