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 
28 #include "porlin.hxx"
29 #include "portxt.hxx"
30 #include "possiz.hxx"
31 
32 class SwPortionHandler;
33 class SwTextPaintInfo;
34 class SwTextSizeInfo;
35 class SwFont;
36 
37 #define LINE_BREAK_WIDTH 150
38 #define SPECIAL_FONT_HEIGHT 200
39 
40 class SwTextFormatInfo;
41 
43 {
47 
48 public:
49  explicit SwTmpEndPortion( const SwLinePortion &rPortion,
50  const FontLineStyle eUnderline,
51  const FontStrikeout eStrikeout,
52  const Color& rColor );
53  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
54 };
55 
56 enum class SwLineBreakClear;
57 
59 {
61 
64 
67 
68 public:
69  explicit SwBreakPortion(const SwLinePortion& rPortion, const SwTextAttr* pAttr);
70  // Returns 0 if we have no usable data
71  virtual SwLinePortion *Compress() override;
72  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
73  virtual bool Format( SwTextFormatInfo &rInf ) override;
74  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
75  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
76 
77  // Accessibility: pass information about this portion to the PortionHandler
78  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
79 
80  void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
81  TextFrameIndex& nOffset) const override;
82 
83  static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0";
84  void SetRedline( const RedlineType eRedline ) { m_eRedline = eRedline; }
85 
86  SwLineBreakClear GetClear() const;
87 };
88 
90 {
91  short m_nKern;
94 
95 public:
96 
97  // This constructor automatically appends the portion to rPortion
98  // bBG indicates, that the background of the kerning portion has to
99  // be painted, e.g., if the portion if positioned between to fields.
100  // bGridKern indicates, that the kerning portion is used to provide
101  // additional space in grid mode.
102  SwKernPortion( SwLinePortion &rPortion, short nKrn,
103  bool bBG = false, bool bGridKern = false );
104 
105  // This constructor only sets the height and ascent to the values
106  // of rPortion. It is only used for kerning portions for grid mode
107  explicit SwKernPortion( const SwLinePortion &rPortion );
108 
109  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
110  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
111 };
112 
115 {
117  bool m_bLeft;
118 public:
119  explicit SwArrowPortion( const SwLinePortion &rPortion );
120  explicit SwArrowPortion( const SwTextPaintInfo &rInf );
121  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
122  virtual SwLinePortion *Compress() override;
123  bool IsLeft() const { return m_bLeft; }
124  const Point& GetPos() const { return m_aPos; }
125 };
126 
127 // The characters which are forbidden at the start of a line like the dot and
128 // other punctuation marks are allowed to display in the margin of the page
129 // by a user option.
130 // The SwHangingPortion is the corresponding textportion to do that.
132 {
133  sal_uInt16 m_nInnerWidth;
134 public:
135  explicit SwHangingPortion( SwPosSize aSize ) : m_nInnerWidth( aSize.Width() )
136  {
139  Height( aSize.Height() );
140  }
141 
142  sal_uInt16 GetInnerWidth() const { return m_nInnerWidth; }
143 };
144 
145 // Used to hide text
147 {
148 public:
149  explicit SwHiddenTextPortion(TextFrameIndex const nLen)
150  {
152  }
153 
154  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
155  virtual bool Format( SwTextFormatInfo &rInf ) override;
156 };
157 
159 {
160 
161 private:
162  mutable sal_uInt16 mnViewWidth; // used to cache a calculated value
163  mutable sal_uInt16 mnHalfCharWidth; // used to cache a calculated value
164 protected:
166 
167 public:
168 
170  : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar )
171  {
173  }
174 
175  virtual bool DoPaint(SwTextPaintInfo const& rInf,
176  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const;
177  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
178  virtual bool Format( SwTextFormatInfo &rInf ) override;
179  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo& rInf ) const override;
180 };
181 
185 {
186 public:
187  explicit SwBookmarkPortion(sal_Unicode const cChar)
188  : SwControlCharPortion(cChar)
189  {
192  }
193 
194  virtual bool DoPaint(SwTextPaintInfo const& rInf,
195  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override;
196  virtual SwLinePortion * Compress() override { return this; }
197 };
198 
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:123
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:594
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const override
Definition: porrst.cxx:630
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:576
const FontStrikeout m_eStrikeout
Definition: porrst.hxx:45
sal_uInt16 mnViewWidth
Definition: porrst.hxx:162
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:126
const Point & GetPos() const
Definition: porrst.hxx:124
sal_uInt16 m_nInnerWidth
Definition: porrst.hxx:133
SwArrowPortion(const SwLinePortion &rPortion)
Definition: porrst.cxx:284
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const
Definition: porrst.cxx:602
short m_nKern
Definition: porrst.hxx:91
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
SwLineBreakClear
Defines the location of a line break text wrapping restart.
virtual SwLinePortion * Compress() override
Definition: porrst.hxx:196
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:120
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:77
Point m_aPos
Definition: porrst.hxx:116
bool IsLeft() const
Definition: porrst.hxx:123
SwControlCharPortion(sal_Unicode cChar)
Definition: porrst.hxx:169
SwKernPortion(SwLinePortion &rPortion, short nKrn, bool bBG=false, bool bGridKern=false)
Definition: porrst.cxx:220
sal_uInt16 sal_Unicode
sal_uInt16 mnHalfCharWidth
Definition: porrst.hxx:163
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:731
virtual void FormatEOL(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:270
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:671
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:43
SwTwips m_nTextHeight
Height of the line-break character itself, without spacing added for clearing.
Definition: porrst.hxx:66
bool m_bGridKern
Definition: porrst.hxx:93
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:172
Color m_aColor
Definition: porrst.hxx:46
SwTmpEndPortion(const SwLinePortion &rPortion, const FontLineStyle eUnderline, const FontStrikeout eStrikeout, const Color &rColor)
Definition: porrst.cxx:53
This portion represents a part of the paragraph string.
Definition: portxt.hxx:26
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:304
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:98
float u
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:243
SwLineBreakClear m_eClear
Tracks the type of the breaking clear from SwTextLineBreak, if there is one.
Definition: porrst.hxx:63
SwLineBreakClear GetClear() const
Definition: porrst.cxx:218
void SetRedline(const RedlineType eRedline)
Definition: porrst.hxx:84
SwTwips Height() const
Definition: possiz.hxx:49
Indicator that the content does not fit into a fixed height frame (red triangle on the UI)...
Definition: porrst.hxx:114
static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE
Definition: porrst.hxx:83
tools::Long SwTwips
Definition: swtypes.hxx:51
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porrst.cxx:115
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:309
SwBookmarkPortion(sal_Unicode const cChar)
Definition: porrst.hxx:187
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:51
void dumpAsXml(xmlTextWriterPtr pWriter, const OUString &rText, TextFrameIndex &nOffset) const override
Definition: porrst.cxx:205
SwTwips Width() const
Definition: possiz.hxx:51
const FontLineStyle m_eUnderline
Definition: porrst.hxx:44
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:721
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:64
SwHiddenTextPortion(TextFrameIndex const nLen)
Definition: porrst.hxx:149
SwBreakPortion(const SwLinePortion &rPortion, const SwTextAttr *pAttr)
Definition: porrst.cxx:100
for showing bookmark starts and ends; note that in contrast to SwControlCharPortion these do not have...
Definition: porrst.hxx:184
struct _xmlTextWriter * xmlTextWriterPtr
RedlineType
SwHangingPortion(SwPosSize aSize)
Definition: porrst.hxx:135
FontLineStyle
sal_uInt16 GetInnerWidth() const
Definition: porrst.hxx:142
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...
virtual void HandlePortion(SwPortionHandler &rPH) const override
Definition: porrst.cxx:200
bool m_bBackground
Definition: porrst.hxx:92
sal_Unicode mcChar
Definition: porrst.hxx:165
FontStrikeout
RedlineType m_eRedline
Definition: porrst.hxx:60