android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / text / porrst.hxx
blob5f6f3fca370a9b0108d76a1416e92cb440a10642
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <tools/gen.hxx>
23 #include <TextFrameIndex.hxx>
24 #include <txttypes.hxx>
25 #include <txtfrm.hxx>
26 #include <svx/ctredlin.hxx>
27 #include <scriptinfo.hxx>
29 #include "porlin.hxx"
30 #include "portxt.hxx"
31 #include "possiz.hxx"
33 class SwPortionHandler;
34 class SwTextPaintInfo;
35 class SwTextSizeInfo;
36 class SwFont;
38 #define LINE_BREAK_WIDTH 150
39 #define SPECIAL_FONT_HEIGHT 200
41 class SwTextFormatInfo;
43 class SwTmpEndPortion : public SwLinePortion
45 const FontLineStyle m_eUnderline;
46 const FontStrikeout m_eStrikeout;
47 Color m_aColor;
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;
57 enum class SwLineBreakClear;
59 class SwBreakPortion : public SwLinePortion
61 RedlineType m_eRedline;
63 /// Tracks the type of the breaking clear from SwTextLineBreak, if there is one.
64 SwLineBreakClear m_eClear;
66 /// Height of the line-break character itself, without spacing added for clearing.
67 SwTwips m_nTextHeight;
69 public:
70 explicit SwBreakPortion(const SwLinePortion& rPortion, const SwTextAttr* pAttr);
71 // Returns 0 if we have no usable data
72 virtual SwLinePortion *Compress() override;
73 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
74 virtual bool Format( SwTextFormatInfo &rInf ) override;
75 virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const override;
76 virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
78 // Accessibility: pass information about this portion to the PortionHandler
79 virtual void HandlePortion( SwPortionHandler& rPH ) const override;
81 void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
82 TextFrameIndex& nOffset) const override;
84 static constexpr OUStringLiteral S_NOBREAK_FOR_REDLINE = u"\u00A0";
85 void SetRedline( const RedlineType eRedline ) { m_eRedline = eRedline; }
87 SwLineBreakClear GetClear() const;
90 class SwKernPortion : public SwLinePortion
92 short m_nKern;
93 bool m_bBackground;
94 bool m_bGridKern;
96 public:
98 // This constructor automatically appends the portion to rPortion
99 // bBG indicates, that the background of the kerning portion has to
100 // be painted, e.g., if the portion if positioned between to fields.
101 // bGridKern indicates, that the kerning portion is used to provide
102 // additional space in grid mode.
103 SwKernPortion( SwLinePortion &rPortion, short nKrn,
104 bool bBG = false, bool bGridKern = false );
106 // This constructor only sets the height and ascent to the values
107 // of rPortion. It is only used for kerning portions for grid mode
108 explicit SwKernPortion( const SwLinePortion &rPortion );
110 virtual void FormatEOL( SwTextFormatInfo &rInf ) override;
111 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
114 /// Indicator that the content does not fit into a fixed height frame (red triangle on the UI).
115 class SwArrowPortion : public SwLinePortion
117 Point m_aPos;
118 bool m_bLeft;
119 public:
120 explicit SwArrowPortion( const SwLinePortion &rPortion );
121 explicit SwArrowPortion( const SwTextPaintInfo &rInf );
122 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
123 virtual SwLinePortion *Compress() override;
124 bool IsLeft() const { return m_bLeft; }
125 const Point& GetPos() const { return m_aPos; }
128 // The characters which are forbidden at the start of a line like the dot and
129 // other punctuation marks are allowed to display in the margin of the page
130 // by a user option.
131 // The SwHangingPortion is the corresponding textportion to do that.
132 class SwHangingPortion : public SwTextPortion
134 sal_uInt16 m_nInnerWidth;
135 public:
136 explicit SwHangingPortion( SwPosSize aSize ) : m_nInnerWidth( aSize.Width() )
138 SetWhichPor( PortionType::Hanging );
139 SetLen(TextFrameIndex(1));
140 Height( aSize.Height() );
143 sal_uInt16 GetInnerWidth() const { return m_nInnerWidth; }
146 // Used to hide text
147 class SwHiddenTextPortion : public SwLinePortion
149 public:
150 explicit SwHiddenTextPortion(TextFrameIndex const nLen)
152 SetWhichPor( PortionType::HiddenText ); SetLen( nLen );
155 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
156 virtual bool Format( SwTextFormatInfo &rInf ) override;
159 class SwControlCharPortion : public SwLinePortion
162 private:
163 mutable sal_uInt16 mnViewWidth; // used to cache a calculated value
164 protected:
165 mutable sal_uInt16 mnHalfCharWidth; // used to cache a calculated value
166 sal_Unicode mcChar;
168 public:
170 explicit SwControlCharPortion( sal_Unicode cChar )
171 : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar )
173 SetWhichPor( PortionType::ControlChar ); SetLen( TextFrameIndex(1) );
176 virtual bool DoPaint(SwTextPaintInfo const& rInf,
177 OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const;
178 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
179 virtual bool Format( SwTextFormatInfo &rInf ) override;
180 virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo& rInf ) const override;
183 /// for showing bookmark starts and ends; note that in contrast to
184 /// SwControlCharPortion these do not have a character in the text.
185 class SwBookmarkPortion : public SwControlCharPortion
187 // custom colors defined by metadata
188 std::vector<std::tuple<SwScriptInfo::MarkKind, Color, OUString>> m_oColors;
189 // number of MarkKind marks
190 sal_Int16 m_nStart, m_nEnd, m_nPoint;
191 bool m_bHasCustomColor;
193 public:
194 explicit SwBookmarkPortion(sal_Unicode const cChar, std::vector<std::tuple<SwScriptInfo::MarkKind, Color, OUString>>rColors)
195 : SwControlCharPortion(cChar), m_oColors(rColors), m_nStart(0), m_nEnd(0), m_nPoint(0), m_bHasCustomColor(false)
197 SetWhichPor(PortionType::Bookmark);
198 SetLen(TextFrameIndex(0));
199 for (const auto& it : m_oColors)
201 if (std::get<0>(it) == SwScriptInfo::MarkKind::Start)
202 m_nStart++;
203 else if (std::get<0>(it) == SwScriptInfo::MarkKind::End)
204 m_nEnd++;
205 else
206 m_nPoint++;
208 if (!m_bHasCustomColor && COL_TRANSPARENT != std::get<1>(it))
209 m_bHasCustomColor = true;
213 virtual bool DoPaint(SwTextPaintInfo const& rInf,
214 OUString & rOutString, SwFont & rTmpFont, int & rDeltaY) const override;
215 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
216 virtual SwLinePortion * Compress() override { return this; }
217 virtual void HandlePortion(SwPortionHandler& rPH) const override;
218 void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
219 TextFrameIndex& rOffset) const override;
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */