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 
57 {
59 
60 public:
61  explicit SwBreakPortion( const SwLinePortion &rPortion );
62  // Returns 0 if we have no usable data
63  virtual SwLinePortion *Compress() override;
64  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
65  virtual bool Format( SwTextFormatInfo &rInf ) override;
66  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
67  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
68 
69  // Accessibility: pass information about this portion to the PortionHandler
70  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
71 
72  static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0";
73  void SetRedline( const RedlineType eRedline ) { m_eRedline = eRedline; }
74 };
75 
77 {
78  short m_nKern;
81 
82 public:
83 
84  // This constructor automatically appends the portion to rPortion
85  // bBG indicates, that the background of the kerning portion has to
86  // be painted, e.g., if the portion if positioned between to fields.
87  // bGridKern indicates, that the kerning portion is used to provide
88  // additional space in grid mode.
89  SwKernPortion( SwLinePortion &rPortion, short nKrn,
90  bool bBG = false, bool bGridKern = false );
91 
92  // This constructor only sets the height and ascent to the values
93  // of rPortion. It is only used for kerning portions for grid mode
94  explicit SwKernPortion( const SwLinePortion &rPortion );
95 
96  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
97  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
98 };
99 
101 {
103  bool m_bLeft;
104 public:
105  explicit SwArrowPortion( const SwLinePortion &rPortion );
106  explicit SwArrowPortion( const SwTextPaintInfo &rInf );
107  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
108  virtual SwLinePortion *Compress() override;
109  bool IsLeft() const { return m_bLeft; }
110  const Point& GetPos() const { return m_aPos; }
111 };
112 
113 // The characters which are forbidden at the start of a line like the dot and
114 // other punctuation marks are allowed to display in the margin of the page
115 // by a user option.
116 // The SwHangingPortion is the corresponding textportion to do that.
118 {
119  sal_uInt16 m_nInnerWidth;
120 public:
121  explicit SwHangingPortion( SwPosSize aSize ) : m_nInnerWidth( aSize.Width() )
122  {
125  Height( aSize.Height() );
126  }
127 
128  sal_uInt16 GetInnerWidth() const { return m_nInnerWidth; }
129 };
130 
131 // Used to hide text
133 {
134 public:
135  explicit SwHiddenTextPortion(TextFrameIndex const nLen)
136  {
138  }
139 
140  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
141  virtual bool Format( SwTextFormatInfo &rInf ) override;
142 };
143 
145 {
146 
147 private:
148  mutable sal_uInt16 mnViewWidth; // used to cache a calculated value
149  mutable sal_uInt16 mnHalfCharWidth; // used to cache a calculated value
150 protected:
152 
153 public:
154 
156  : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar )
157  {
159  }
160 
161  virtual bool DoPaint(SwTextPaintInfo const& rInf,
162  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const;
163  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
164  virtual bool Format( SwTextFormatInfo &rInf ) override;
165  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo& rInf ) const override;
166 };
167 
171 {
172 public:
173  explicit SwBookmarkPortion(sal_Unicode const cChar)
174  : SwControlCharPortion(cChar)
175  {
178  }
179 
180  virtual bool DoPaint(SwTextPaintInfo const& rInf,
181  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override;
182  virtual SwLinePortion * Compress() override { return this; }
183 };
184 
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:112
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:544
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const override
Definition: porrst.cxx:580
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:526
const FontStrikeout m_eStrikeout
Definition: porrst.hxx:45
sal_uInt16 mnViewWidth
Definition: porrst.hxx:148
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:115
SwBreakPortion(const SwLinePortion &rPortion)
Definition: porrst.cxx:96
const Point & GetPos() const
Definition: porrst.hxx:110
sal_uInt16 m_nInnerWidth
Definition: porrst.hxx:119
SwArrowPortion(const SwLinePortion &rPortion)
Definition: porrst.cxx:234
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const
Definition: porrst.cxx:552
short m_nKern
Definition: porrst.hxx:78
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
virtual SwLinePortion * Compress() override
Definition: porrst.hxx:182
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:109
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:74
Point m_aPos
Definition: porrst.hxx:102
bool IsLeft() const
Definition: porrst.hxx:109
SwControlCharPortion(sal_Unicode cChar)
Definition: porrst.hxx:155
SwKernPortion(SwLinePortion &rPortion, short nKrn, bool bBG=false, bool bGridKern=false)
Definition: porrst.cxx:170
sal_uInt16 sal_Unicode
sal_uInt16 mnHalfCharWidth
Definition: porrst.hxx:149
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:681
virtual void FormatEOL(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:220
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:621
bool m_bGridKern
Definition: porrst.hxx:80
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:154
Color m_aColor
Definition: porrst.hxx:46
SwTmpEndPortion(const SwLinePortion &rPortion, const FontLineStyle eUnderline, const FontStrikeout eStrikeout, const Color &rColor)
Definition: porrst.cxx:49
This portion represents a part of the paragraph string.
Definition: portxt.hxx:26
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:254
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:93
float u
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:193
void SetRedline(const RedlineType eRedline)
Definition: porrst.hxx:73
static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE
Definition: porrst.hxx:72
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porrst.cxx:104
sal_uInt32 Height() const
Definition: possiz.hxx:49
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:259
SwBookmarkPortion(sal_Unicode const cChar)
Definition: porrst.hxx:173
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:49
const FontLineStyle m_eUnderline
Definition: porrst.hxx:44
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:671
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:60
SwHiddenTextPortion(TextFrameIndex const nLen)
Definition: porrst.hxx:135
for showing bookmark starts and ends; note that in contrast to SwControlCharPortion these do not have...
Definition: porrst.hxx:170
RedlineType
SwHangingPortion(SwPosSize aSize)
Definition: porrst.hxx:121
sal_uInt32 Width() const
Definition: possiz.hxx:51
FontLineStyle
sal_uInt16 GetInnerWidth() const
Definition: porrst.hxx:128
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:165
bool m_bBackground
Definition: porrst.hxx:79
sal_Unicode mcChar
Definition: porrst.hxx:151
FontStrikeout
RedlineType m_eRedline
Definition: porrst.hxx:58