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