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 
27 #include "porlin.hxx"
28 #include "portxt.hxx"
29 #include "possiz.hxx"
30 
31 class SwPortionHandler;
32 class SwTextPaintInfo;
33 class SwTextSizeInfo;
34 class SwFont;
35 
36 #define LINE_BREAK_WIDTH 150
37 #define SPECIAL_FONT_HEIGHT 200
38 
39 class SwTextFormatInfo;
40 
42 {
43 public:
44  explicit SwTmpEndPortion( const SwLinePortion &rPortion );
45  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
46 };
47 
49 {
50 public:
51  explicit SwBreakPortion( const SwLinePortion &rPortion );
52  // Returns 0 if we have no usable data
53  virtual SwLinePortion *Compress() override;
54  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
55  virtual bool Format( SwTextFormatInfo &rInf ) override;
56  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
57  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
58 
59  // Accessibility: pass information about this portion to the PortionHandler
60  virtual void HandlePortion( SwPortionHandler& rPH ) const override;
61 };
62 
64 {
65  short nKern;
67  bool bGridKern;
68 
69 public:
70 
71  // This constructor automatically appends the portion to rPortion
72  // bBG indicates, that the background of the kerning portion has to
73  // be painted, e.g., if the portion if positioned between to fields.
74  // bGridKern indicates, that the kerning portion is used to provide
75  // additional space in grid mode.
76  SwKernPortion( SwLinePortion &rPortion, short nKrn,
77  bool bBG = false, bool bGridKern = false );
78 
79  // This constructor only sets the height and ascent to the values
80  // of rPortion. It is only used for kerning portions for grid mode
81  explicit SwKernPortion( const SwLinePortion &rPortion );
82 
83  virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
84  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
85 };
86 
88 {
90  bool bLeft;
91 public:
92  explicit SwArrowPortion( const SwLinePortion &rPortion );
93  explicit SwArrowPortion( const SwTextPaintInfo &rInf );
94  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
95  virtual SwLinePortion *Compress() override;
96  bool IsLeft() const { return bLeft; }
97  const Point& GetPos() const { return aPos; }
98 };
99 
100 // The characters which are forbidden at the start of a line like the dot and
101 // other punctuation marks are allowed to display in the margin of the page
102 // by a user option.
103 // The SwHangingPortion is the corresponding textportion to do that.
105 {
106  sal_uInt16 nInnerWidth;
107 public:
108  explicit SwHangingPortion( SwPosSize aSize ) : nInnerWidth( aSize.Width() )
109  {
112  Height( aSize.Height() );
113  }
114 
115  sal_uInt16 GetInnerWidth() const { return nInnerWidth; }
116 };
117 
118 // Used to hide text
120 {
121 public:
122  explicit SwHiddenTextPortion(TextFrameIndex const nLen)
123  {
125  }
126 
127  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
128  virtual bool Format( SwTextFormatInfo &rInf ) override;
129 };
130 
132 {
133 
134 private:
135  mutable sal_uInt16 mnViewWidth; // used to cache a calculated value
136  mutable sal_uInt16 mnHalfCharWidth; // used to cache a calculated value
137 protected:
139 
140 public:
141 
143  : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar )
144  {
146  }
147 
148  virtual bool DoPaint(SwTextPaintInfo const& rInf,
149  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const;
150  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
151  virtual bool Format( SwTextFormatInfo &rInf ) override;
152  virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo& rInf ) const override;
153 };
154 
158 {
159 public:
160  explicit SwBookmarkPortion(sal_Unicode const cChar)
161  : SwControlCharPortion(cChar)
162  {
165  }
166 
167  virtual bool DoPaint(SwTextPaintInfo const& rInf,
168  OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override;
169  virtual SwLinePortion * Compress() override { return this; }
170 };
171 
172 #endif
173 
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:88
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:487
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const override
Definition: porrst.cxx:523
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:469
sal_uInt16 Height() const
Definition: possiz.hxx:50
sal_uInt16 mnViewWidth
Definition: porrst.hxx:135
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:91
SwBreakPortion(const SwLinePortion &rPortion)
Definition: porrst.cxx:73
const Point & GetPos() const
Definition: porrst.hxx:97
Point aPos
Definition: porrst.hxx:89
SwArrowPortion(const SwLinePortion &rPortion)
Definition: porrst.cxx:177
virtual bool DoPaint(SwTextPaintInfo const &rInf, OUString &rOutString, SwFont &rTmpFont, int &rDeltaY) const
Definition: porrst.cxx:495
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
virtual SwLinePortion * Compress() override
Definition: porrst.hxx:169
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:85
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:75
bool bGridKern
Definition: porrst.hxx:67
bool IsLeft() const
Definition: porrst.hxx:96
SwControlCharPortion(sal_Unicode cChar)
Definition: porrst.hxx:142
SwKernPortion(SwLinePortion &rPortion, short nKrn, bool bBG=false, bool bGridKern=false)
Definition: porrst.cxx:113
short nKern
Definition: porrst.hxx:65
sal_uInt16 nInnerWidth
Definition: porrst.hxx:106
sal_uInt16 sal_Unicode
sal_uInt16 mnHalfCharWidth
Definition: porrst.hxx:136
virtual sal_uInt16 GetViewWidth(const SwTextSizeInfo &rInf) const override
Definition: porrst.cxx:624
virtual void FormatEOL(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:163
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:564
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:97
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:197
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:94
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:136
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: porrst.cxx:80
virtual SwLinePortion * Compress() override
Definition: porrst.cxx:202
SwBookmarkPortion(sal_Unicode const cChar)
Definition: porrst.hxx:160
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:50
bool bBackground
Definition: porrst.hxx:66
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: porrst.cxx:614
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: porrst.cxx:56
SwHiddenTextPortion(TextFrameIndex const nLen)
Definition: porrst.hxx:122
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:157
SwHangingPortion(SwPosSize aSize)
Definition: porrst.hxx:108
sal_uInt16 GetInnerWidth() const
Definition: porrst.hxx:115
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:108
sal_Unicode mcChar
Definition: porrst.hxx:138
SwTmpEndPortion(const SwLinePortion &rPortion)
Definition: porrst.cxx:49