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 #ifndef INCLUDED_SW_SOURCE_CORE_TEXT_PORRST_HXX
20 #define INCLUDED_SW_SOURCE_CORE_TEXT_PORRST_HXX
21 
22 #include <tools/gen.hxx>
23 
24 #include <TextFrameIndex.hxx>
25 #include <txttypes.hxx>
26 #include <txtfrm.hxx>
27 #include <svx/ctredlin.hxx>
28 
29 #include "porlin.hxx"
30 #include "portxt.hxx"
31 #include "possiz.hxx"
32 
33 class SwPortionHandler;
34 class SwTextPaintInfo;
35 class SwTextSizeInfo;
36 class SwFont;
37 
38 #define LINE_BREAK_WIDTH 150
39 #define SPECIAL_FONT_HEIGHT 200
40 
41 class SwTextFormatInfo;
42 
44 {
48 
49 public:
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 
58 {
60 
61 public:
62  explicit SwBreakPortion( const SwLinePortion &rPortion );
63  // Returns 0 if we have no usable data
64  virtual SwLinePortion *Compress() override;
65  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
66  virtual bool Format( SwTextFormatInfo &rInf ) override;
67  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
68  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
69 
70  // Accessibility: pass information about this portion to the PortionHandler
71  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
72 
73  static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0";
74  void SetRedline( const RedlineType eRedline ) { m_eRedline = eRedline; }
75 };
76 
78 {
79  short nKern;
81  bool bGridKern;
82 
83 public:
84 
85  // This constructor automatically appends the portion to rPortion
86  // bBG indicates, that the background of the kerning portion has to
87  // be painted, e.g., if the portion if positioned between to fields.
88  // bGridKern indicates, that the kerning portion is used to provide
89  // additional space in grid mode.
90  SwKernPortion( SwLinePortion &rPortion, short nKrn,
91  bool bBG = false, bool bGridKern = false );
92 
93  // This constructor only sets the height and ascent to the values
94  // of rPortion. It is only used for kerning portions for grid mode
95  explicit SwKernPortion( const SwLinePortion &rPortion );
96 
97  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
98  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
99 };
100 
102 {
104  bool bLeft;
105 public:
106  explicit SwArrowPortion( const SwLinePortion &rPortion );
107  explicit SwArrowPortion( const SwTextPaintInfo &rInf );
108  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
109  virtual SwLinePortion *Compress() override;
110  bool IsLeft() const { return bLeft; }
111  const Point& GetPos() const { return aPos; }
112 };
113 
114 // The characters which are forbidden at the start of a line like the dot and
115 // other punctuation marks are allowed to display in the margin of the page
116 // by a user option.
117 // The SwHangingPortion is the corresponding textportion to do that.
119 {
120  sal_uInt16 nInnerWidth;
121 public:
122  explicit SwHangingPortion( SwPosSize aSize ) : nInnerWidth( aSize.Width() )
123  {
126  Height( aSize.Height() );
127  }
128 
129  sal_uInt16 GetInnerWidth() const { return nInnerWidth; }
130 };
131 
132 // Used to hide text
134 {
135 public:
136  explicit SwHiddenTextPortion(TextFrameIndex const nLen)
137  {
139  }
140 
141  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
142  virtual bool Format( SwTextFormatInfo &rInf ) override;
143 };
144 
146 {
147 
148 private:
149  mutable sal_uInt16 mnViewWidth; // used to cache a calculated value
150  mutable sal_uInt16 mnHalfCharWidth; // used to cache a calculated value
151 protected:
153 
154 public:
155 
157  : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar )
158  {
160  }
161 
162  virtual bool DoPaint(SwTextPaintInfo const& rInf,
163  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const;
164  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
165  virtual bool Format( SwTextFormatInfo &rInf ) override;
166  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo& rInf ) const override;
167 };
168 
172 {
173 public:
174  explicit SwBookmarkPortion(sal_Unicode const cChar)
175  : SwControlCharPortion(cChar)
176  {
179  }
180 
181  virtual bool DoPaint(SwTextPaintInfo const& rInf,
182  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override;
183  virtual SwLinePortion * Compress() override { return this; }
184 };
185 
186 #endif
187 
188 /* 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
Color aColor
Definition: porrst.hxx:47
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:526
sal_uInt16 Height() const
Definition: possiz.hxx:50
sal_uInt16 mnViewWidth
Definition: porrst.hxx:149
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:111
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
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
virtual SwLinePortion * Compress() override
Definition: porrst.hxx:183
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:109
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:75
bool bGridKern
Definition: porrst.hxx:81
bool IsLeft() const
Definition: porrst.hxx:110
SwControlCharPortion(sal_Unicode cChar)
Definition: porrst.hxx:156
SwKernPortion(SwLinePortion &rPortion, short nKrn, bool bBG=false, bool bGridKern=false)
Definition: porrst.cxx:170
short nKern
Definition: porrst.hxx:79
sal_uInt16 nInnerWidth
Definition: porrst.hxx:120
sal_uInt16 sal_Unicode
sal_uInt16 mnHalfCharWidth
Definition: porrst.hxx:150
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
const FontStrikeout eStrikeout
Definition: porrst.hxx:46
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:154
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:27
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:254
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:94
float u
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:193
void SetRedline(const RedlineType eRedline)
Definition: porrst.hxx:74
static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE
Definition: porrst.hxx:73
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porrst.cxx:104
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:259
SwBookmarkPortion(sal_Unicode const cChar)
Definition: porrst.hxx:174
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:50
bool bBackground
Definition: porrst.hxx:80
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:671
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:60
const FontLineStyle eUnderline
Definition: porrst.hxx:45
SwHiddenTextPortion(TextFrameIndex const nLen)
Definition: porrst.hxx:136
sal_uInt16 Width() const
Definition: possiz.hxx:52
for showing bookmark starts and ends; note that in contrast to SwControlCharPortion these do not have...
Definition: porrst.hxx:171
RedlineType
SwHangingPortion(SwPosSize aSize)
Definition: porrst.hxx:122
FontLineStyle
sal_uInt16 GetInnerWidth() const
Definition: porrst.hxx:129
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
sal_Unicode mcChar
Definition: porrst.hxx:152
FontStrikeout
RedlineType m_eRedline
Definition: porrst.hxx:59