LibreOffice Module sw (master) 1
porrst.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#pragma once
20
21#include <tools/gen.hxx>
22
23#include <TextFrameIndex.hxx>
24#include <txttypes.hxx>
25#include <txtfrm.hxx>
26#include <svx/ctredlin.hxx>
27#include <scriptinfo.hxx>
28
29#include "porlin.hxx"
30#include "portxt.hxx"
31#include "possiz.hxx"
32
34class SwTextPaintInfo;
35class SwTextSizeInfo;
36class SwFont;
37
38#define LINE_BREAK_WIDTH 150
39#define SPECIAL_FONT_HEIGHT 200
40
42
44{
48
49public:
50 explicit SwTmpEndPortion( const SwLinePortion &rPortion,
51 const FontLineStyle eUnderline,
52 const FontStrikeout eStrikeout,
53 const Color& rColor );
54 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
55};
56
57enum class SwLineBreakClear;
58
60{
62
65
68
69public:
70 explicit SwBreakPortion(const SwLinePortion& rPortion, const SwTextAttr* pAttr);
71 // Returns 0 if we have no usable data
72 virtual SwLinePortion *Compress() override;
73 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
74 virtual bool Format( SwTextFormatInfo &rInf ) override;
75 virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
76 virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
77
78 // Accessibility: pass information about this portion to the PortionHandler
79 virtual void HandlePortion( SwPortionHandler& rPH ) const override;
80
81 void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
82 TextFrameIndex& nOffset) const override;
83
84 static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0";
85 void SetRedline( const RedlineType eRedline ) { m_eRedline = eRedline; }
86
88};
89
91{
92 short m_nKern;
95
96public:
97
98 // This constructor automatically appends the portion to rPortion
99 // bBG indicates, that the background of the kerning portion has to
100 // be painted, e.g., if the portion if positioned between to fields.
101 // bGridKern indicates, that the kerning portion is used to provide
102 // additional space in grid mode.
103 SwKernPortion( SwLinePortion &rPortion, short nKrn,
104 bool bBG = false, bool bGridKern = false );
105
106 // This constructor only sets the height and ascent to the values
107 // of rPortion. It is only used for kerning portions for grid mode
108 explicit SwKernPortion( const SwLinePortion &rPortion );
109
110 virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
111 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
112};
113
116{
119public:
120 explicit SwArrowPortion( const SwLinePortion &rPortion );
121 explicit SwArrowPortion( const SwTextPaintInfo &rInf );
122 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
123 virtual SwLinePortion *Compress() override;
124 bool IsLeft() const { return m_bLeft; }
125 const Point& GetPos() const { return m_aPos; }
126};
127
128// The characters which are forbidden at the start of a line like the dot and
129// other punctuation marks are allowed to display in the margin of the page
130// by a user option.
131// The SwHangingPortion is the corresponding textportion to do that.
133{
134 sal_uInt16 m_nInnerWidth;
135public:
136 explicit SwHangingPortion( SwPosSize aSize ) : m_nInnerWidth( aSize.Width() )
137 {
140 Height( aSize.Height() );
141 }
142
143 sal_uInt16 GetInnerWidth() const { return m_nInnerWidth; }
144};
145
146// Used to hide text
148{
149public:
151 {
153 }
154
155 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
156 virtual bool Format( SwTextFormatInfo &rInf ) override;
157};
158
160{
161
162private:
163 mutable sal_uInt16 mnViewWidth; // used to cache a calculated value
164protected:
165 mutable sal_uInt16 mnHalfCharWidth; // used to cache a calculated value
167
168public:
169
171 : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar )
172 {
174 }
175
176 virtual bool DoPaint(SwTextPaintInfo const& rInf,
177 OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const;
178 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
179 virtual bool Format( SwTextFormatInfo &rInf ) override;
180 virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo& rInf ) const override;
181};
182
186{
187 // custom colors defined by metadata
188 std::vector<std::tuple<SwScriptInfo::MarkKind, Color, OUString>> m_oColors;
189 // number of MarkKind marks
192
193public:
194 explicit SwBookmarkPortion(sal_Unicode const cChar, std::vector<std::tuple<SwScriptInfo::MarkKind, Color, OUString>>rColors)
195 : SwControlCharPortion(cChar), m_oColors(rColors), m_nStart(0), m_nEnd(0), m_nPoint(0), m_bHasCustomColor(false)
196 {
199 for (const auto& it : m_oColors)
200 {
201 if (std::get<0>(it) == SwScriptInfo::MarkKind::Start)
202 m_nStart++;
203 else if (std::get<0>(it) == SwScriptInfo::MarkKind::End)
204 m_nEnd++;
205 else
206 m_nPoint++;
207
208 if (!m_bHasCustomColor && COL_TRANSPARENT != std::get<1>(it))
209 m_bHasCustomColor = true;
210 }
211 }
212
213 virtual bool DoPaint(SwTextPaintInfo const& rInf,
214 OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override;
215 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
216 virtual SwLinePortion * Compress() override { return this; }
217 virtual void HandlePortion(SwPortionHandler& rPH) const override;
218 void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
219 TextFrameIndex& rOffset) const override;
220};
221
222/* 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...
Indicator that the content does not fit into a fixed height frame (red triangle on the UI).
Definition: porrst.hxx:116
SwArrowPortion(const SwLinePortion &rPortion)
Definition: porrst.cxx:306
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:331
Point m_aPos
Definition: porrst.hxx:117
bool IsLeft() const
Definition: porrst.hxx:124
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:326
const Point & GetPos() const
Definition: porrst.hxx:125
for showing bookmark starts and ends; note that in contrast to SwControlCharPortion these do not have...
Definition: porrst.hxx:186
sal_Int16 m_nEnd
Definition: porrst.hxx:190
sal_Int16 m_nStart
Definition: porrst.hxx:190
bool m_bHasCustomColor
Definition: porrst.hxx:191
virtual SwLinePortion * Compress() override
Definition: porrst.hxx:216
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const override
Definition: porrst.cxx:664
void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &rOffset) const override
Definition: porrst.cxx:871
virtual void HandlePortion(SwPortionHandler &rPH) const override
Definition: porrst.cxx:849
SwBookmarkPortion(sal_Unicode const cChar, std::vector< std::tuple< SwScriptInfo::MarkKind, Color, OUString > >rColors)
Definition: porrst.hxx:194
std::vector< std::tuple< SwScriptInfo::MarkKind, Color, OUString > > m_oColors
Definition: porrst.hxx:188
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:757
sal_Int16 m_nPoint
Definition: porrst.hxx:190
RedlineType m_eRedline
Definition: porrst.hxx:61
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:128
static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE
Definition: porrst.hxx:84
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:125
SwBreakPortion(const SwLinePortion &rPortion, const SwTextAttr *pAttr)
Definition: porrst.cxx:102
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:188
SwLineBreakClear m_eClear
Tracks the type of the breaking clear from SwTextLineBreak, if there is one.
Definition: porrst.hxx:64
SwTwips m_nTextHeight
Height of the line-break character itself, without spacing added for clearing.
Definition: porrst.hxx:67
void SetRedline(const RedlineType eRedline)
Definition: porrst.hxx:85
void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &nOffset) const override
Definition: porrst.cxx:227
SwLineBreakClear GetClear() const
Definition: porrst.cxx:240
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:122
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porrst.cxx:117
virtual void HandlePortion(SwPortionHandler &rPH) const override
Definition: porrst.cxx:222
sal_uInt16 mnHalfCharWidth
Definition: porrst.hxx:165
sal_uInt16 mnViewWidth
Definition: porrst.hxx:163
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:707
SwControlCharPortion(sal_Unicode cChar)
Definition: porrst.hxx:170
sal_Unicode mcChar
Definition: porrst.hxx:166
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:902
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const
Definition: porrst.cxx:636
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:912
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
Definition: swfont.hxx:135
SwHangingPortion(SwPosSize aSize)
Definition: porrst.hxx:136
sal_uInt16 GetInnerWidth() const
Definition: porrst.hxx:143
sal_uInt16 m_nInnerWidth
Definition: porrst.hxx:134
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:610
SwHiddenTextPortion(TextFrameIndex const nLen)
Definition: porrst.hxx:150
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:628
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:265
bool m_bGridKern
Definition: porrst.hxx:94
SwKernPortion(SwLinePortion &rPortion, short nKrn, bool bBG=false, bool bGridKern=false)
Definition: porrst.cxx:242
short m_nKern
Definition: porrst.hxx:92
bool m_bBackground
Definition: porrst.hxx:93
virtual void FormatEOL(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:292
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
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
SwTwips Width() const
Definition: possiz.hxx:51
SwTwips Height() const
Definition: possiz.hxx:49
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
const FontStrikeout m_eStrikeout
Definition: porrst.hxx:46
Color m_aColor
Definition: porrst.hxx:47
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:66
SwTmpEndPortion(const SwLinePortion &rPortion, const FontLineStyle eUnderline, const FontStrikeout eStrikeout, const Color &rColor)
Definition: porrst.cxx:55
const FontLineStyle m_eUnderline
Definition: porrst.hxx:45
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
RedlineType
struct _xmlTextWriter * xmlTextWriterPtr
float u
FontLineStyle
FontStrikeout
SwLineBreakClear
Defines the location of a line break text wrapping restart.
tools::Long SwTwips
Definition: swtypes.hxx:51
sal_uInt16 sal_Unicode