LibreOffice Module sw (master) 1
porlin.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 <libxml/xmlwriter.h>
22
23#include "possiz.hxx"
24#include <txttypes.hxx>
25#include <TextFrameIndex.hxx>
26#include <rtl/ustring.hxx>
27
28class SwTextSizeInfo;
29class SwTextPaintInfo;
32
35#define PORGRP_TXT 0x8000
36#define PORGRP_EXP 0x4000
37#define PORGRP_FLD 0x2000
38#define PORGRP_HYPH 0x1000
39#define PORGRP_NUMBER 0x0800
40#define PORGRP_GLUE 0x0400
41#define PORGRP_FIX 0x0200
42#define PORGRP_TAB 0x0100
43// Small special groups
44#define PORGRP_FIXMARG 0x0040
45//#define PORGRP_? 0x0020
46#define PORGRP_TABNOTLFT 0x0010
47#define PORGRP_TOXREF 0x0008
48
51class SAL_DLLPUBLIC_RTTI SwLinePortion: public SwPosSize
52{
53protected:
54 // Here we have areas with different attributes
56 // Count of chars and spaces on the line
58 SwTwips mnAscent; // Maximum ascender
60
62private:
63 PortionType mnWhichPor; // Who's who?
66 SwTwips m_nExtraBlankWidth = 0; // width of spaces after the break
67
68 void Truncate_();
69
70public:
71 explicit inline SwLinePortion(const SwLinePortion &rPortion);
72 virtual ~SwLinePortion();
73
74 // Access methods
75 SwLinePortion *GetNextPortion() const { return mpNextPortion; }
76 inline SwLinePortion &operator=(const SwLinePortion &rPortion);
77 TextFrameIndex GetLen() const { return mnLineLength; }
78 void SetLen(TextFrameIndex const nLen) { mnLineLength = nLen; }
79 void SetNextPortion( SwLinePortion *pNew ){ mpNextPortion = pNew; }
80 SwTwips &GetAscent() { return mnAscent; }
81 SwTwips GetAscent() const { return mnAscent; }
82 void SetAscent( const SwTwips nNewAsc ) { mnAscent = nNewAsc; }
83 void PrtWidth( SwTwips nNewWidth ) { Width( nNewWidth ); }
84 SwTwips PrtWidth() const { return Width(); }
85 void AddPrtWidth( const SwTwips nNew ) { Width( Width() + nNew ); }
86 void SubPrtWidth( const SwTwips nNew ) { Width( Width() - nNew ); }
87 SwTwips ExtraBlankWidth() const { return m_nExtraBlankWidth; }
88 void ExtraBlankWidth(const SwTwips nNew) { m_nExtraBlankWidth = nNew; }
89 SwTwips GetHangingBaseline() const { return mnHangingBaseline; }
90 void SetHangingBaseline( const SwTwips nNewBaseline ) { mnHangingBaseline = nNewBaseline; }
91
92 // Insert methods
93 virtual SwLinePortion *Insert( SwLinePortion *pPortion );
94 virtual SwLinePortion *Append( SwLinePortion *pPortion );
95 SwLinePortion *Cut( SwLinePortion *pVictim );
96 inline void Truncate();
97
98 // Returns 0, if there's no payload
99 virtual SwLinePortion *Compress();
100
101 void SetWhichPor( const PortionType nNew ) { mnWhichPor = nNew; }
102 PortionType GetWhichPor( ) const { return mnWhichPor; }
103
104// Group queries
105 bool InTextGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_TXT) != 0; }
106 bool InGlueGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_GLUE) != 0; }
107 bool InTabGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_TAB) != 0; }
108 bool InHyphGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_HYPH) != 0; }
109 bool InNumberGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_NUMBER) != 0; }
110 bool InFixGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_FIX) != 0; }
111 bool InFieldGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_FLD) != 0; }
112 bool InToxRefGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_TOXREF) != 0; }
113 bool InToxRefOrFieldGrp() const { return (sal_uInt16(mnWhichPor) & ( PORGRP_FLD | PORGRP_TOXREF )) != 0; }
114 bool InExpGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_EXP) != 0; }
115 bool InFixMargGrp() const { return (sal_uInt16(mnWhichPor) & PORGRP_FIXMARG) != 0; }
116 bool InSpaceGrp() const { return InTextGrp() || IsMultiPortion(); }
117// Individual queries
118 bool IsGrfNumPortion() const { return mnWhichPor == PortionType::GrfNum; }
119 bool IsFlyCntPortion() const { return mnWhichPor == PortionType::FlyCnt; }
120 bool IsBlankPortion() const { return mnWhichPor == PortionType::Blank; }
121 bool IsBreakPortion() const { return mnWhichPor == PortionType::Break; }
122 bool IsErgoSumPortion() const { return mnWhichPor == PortionType::ErgoSum; }
123 bool IsQuoVadisPortion() const { return mnWhichPor == PortionType::QuoVadis; }
124 bool IsTabLeftPortion() const { return mnWhichPor == PortionType::TabLeft; }
125 bool IsTabRightPortion() const { return mnWhichPor == PortionType::TabRight; }
126 bool IsTabCenterPortion() const { return mnWhichPor == PortionType::TabCenter; }
127 bool IsTabDecimalPortion() const { return mnWhichPor == PortionType::TabDecimal; }
128 bool IsFootnoteNumPortion() const { return mnWhichPor == PortionType::FootnoteNum; }
129 bool IsFootnotePortion() const { return mnWhichPor == PortionType::Footnote; }
130 bool IsDropPortion() const { return mnWhichPor == PortionType::Drop; }
131 bool IsLayPortion() const { return mnWhichPor == PortionType::Lay; }
132 bool IsParaPortion() const { return mnWhichPor == PortionType::Para; }
133 bool IsMarginPortion() const { return mnWhichPor == PortionType::Margin; }
134 bool IsFlyPortion() const { return mnWhichPor == PortionType::Fly; }
135 bool IsHolePortion() const { return mnWhichPor == PortionType::Hole; }
136 bool IsSoftHyphPortion() const { return mnWhichPor == PortionType::SoftHyphen; }
137 bool IsPostItsPortion() const { return mnWhichPor == PortionType::PostIts; }
138 bool IsCombinedPortion() const { return mnWhichPor == PortionType::Combined; }
139 bool IsTextPortion() const { return mnWhichPor == PortionType::Text; }
140 bool IsHangingPortion() const { return mnWhichPor == PortionType::Hanging; }
141 bool IsKernPortion() const { return mnWhichPor == PortionType::Kern; }
142 bool IsArrowPortion() const { return mnWhichPor == PortionType::Arrow; }
143 bool IsMultiPortion() const { return mnWhichPor == PortionType::Multi; }
144 bool IsNumberPortion() const { return mnWhichPor == PortionType::Number; } // #i23726#
145 bool IsControlCharPortion() const { return mnWhichPor == PortionType::ControlChar || mnWhichPor == PortionType::Bookmark; }
146
147 // Positioning
148 SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
149 SwLinePortion *FindLastPortion();
150
152 virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const;
153 virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const;
154 void CalcTextSize( const SwTextSizeInfo &rInfo );
155
156 // Output
157 virtual void Paint( const SwTextPaintInfo &rInf ) const = 0;
158 void PrePaint( const SwTextPaintInfo &rInf, const SwLinePortion *pLast ) const;
159
160 virtual bool Format( SwTextFormatInfo &rInf );
161 // Is called for the line's last portion
162 virtual void FormatEOL( SwTextFormatInfo &rInf );
163 void Move( SwTextPaintInfo &rInf );
164
165 // For SwTextSlot
166 virtual bool GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const;
167
168 // For SwFieldPortion, SwSoftHyphPortion
169 virtual sal_uInt16 GetViewWidth( const SwTextSizeInfo &rInf ) const;
170
171 // for text- and multi-portions
172 virtual tools::Long CalcSpacing( tools::Long nSpaceAdd, const SwTextSizeInfo &rInf ) const;
173
174 // Accessibility: pass information about this portion to the PortionHandler
175 virtual void HandlePortion( SwPortionHandler& rPH ) const;
176
177 bool GetJoinBorderWithPrev() const { return m_bJoinBorderWithPrev; }
178 bool GetJoinBorderWithNext() const { return m_bJoinBorderWithNext; }
179 void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; }
180 void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; }
181
182 virtual void dumpAsXml(xmlTextWriterPtr pWriter, const OUString& rText,
183 TextFrameIndex& rOffset) const;
184 void dumpAsXmlAttributes(xmlTextWriterPtr writer, std::u16string_view rText,
185 TextFrameIndex nOffset) const;
186};
187
189{
190 *static_cast<SwPosSize*>(this) = rPortion;
191 mnLineLength = rPortion.mnLineLength;
192 mnAscent = rPortion.mnAscent;
194 mnWhichPor = rPortion.mnWhichPor;
198 return *this;
199}
200
202 SwPosSize( rPortion ),
203 mpNextPortion( nullptr ),
204 mnLineLength( rPortion.mnLineLength ),
205 mnAscent( rPortion.mnAscent ),
206 mnHangingBaseline( rPortion.mnHangingBaseline ),
207 mnWhichPor( rPortion.mnWhichPor ),
208 m_bJoinBorderWithPrev( rPortion.m_bJoinBorderWithPrev ),
209 m_bJoinBorderWithNext( rPortion.m_bJoinBorderWithNext ),
210 m_nExtraBlankWidth(rPortion.m_nExtraBlankWidth)
211{
212}
213
215{
216 if ( mpNextPortion )
217 Truncate_();
218}
219
220/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
bool InToxRefOrFieldGrp() const
Definition: porlin.hxx:113
TextFrameIndex mnLineLength
Definition: porlin.hxx:57
void PrtWidth(SwTwips nNewWidth)
Definition: porlin.hxx:83
bool IsBlankPortion() const
Definition: porlin.hxx:120
bool IsTextPortion() const
Definition: porlin.hxx:139
SwLinePortion * mpNextPortion
Definition: porlin.hxx:55
void Truncate_()
Definition: porlin.cxx:152
bool IsHangingPortion() const
Definition: porlin.hxx:140
bool IsMarginPortion() const
Definition: porlin.hxx:133
bool IsSoftHyphPortion() const
Definition: porlin.hxx:136
bool IsArrowPortion() const
Definition: porlin.hxx:142
bool InTextGrp() const
Definition: porlin.hxx:105
void SetJoinBorderWithNext(const bool bJoinNext)
Definition: porlin.hxx:180
bool m_bJoinBorderWithPrev
Definition: porlin.hxx:64
SwLinePortion * GetNextPortion() const
Definition: porlin.hxx:75
void SetAscent(const SwTwips nNewAsc)
Definition: porlin.hxx:82
bool GetJoinBorderWithPrev() const
Definition: porlin.hxx:177
bool InNumberGrp() const
Definition: porlin.hxx:109
void SetHangingBaseline(const SwTwips nNewBaseline)
Definition: porlin.hxx:90
PortionType GetWhichPor() const
Definition: porlin.hxx:102
bool IsTabCenterPortion() const
Definition: porlin.hxx:126
void SetNextPortion(SwLinePortion *pNew)
Definition: porlin.hxx:79
bool IsPostItsPortion() const
Definition: porlin.hxx:137
virtual void Paint(const SwTextPaintInfo &rInf) const =0
SwTwips m_nExtraBlankWidth
Definition: porlin.hxx:66
SwTwips GetAscent() const
Definition: porlin.hxx:81
TextFrameIndex GetLen() const
Definition: porlin.hxx:77
bool IsTabRightPortion() const
Definition: porlin.hxx:125
bool InGlueGrp() const
Definition: porlin.hxx:106
bool IsParaPortion() const
Definition: porlin.hxx:132
bool m_bJoinBorderWithNext
Definition: porlin.hxx:65
bool IsKernPortion() const
Definition: porlin.hxx:141
bool GetJoinBorderWithNext() const
Definition: porlin.hxx:178
void SubPrtWidth(const SwTwips nNew)
Definition: porlin.hxx:86
void Truncate()
Definition: porlin.hxx:214
bool IsLayPortion() const
Definition: porlin.hxx:131
bool IsControlCharPortion() const
Definition: porlin.hxx:145
bool InToxRefGrp() const
Definition: porlin.hxx:112
bool InHyphGrp() const
Definition: porlin.hxx:108
SwTwips GetHangingBaseline() const
Definition: porlin.hxx:89
void ExtraBlankWidth(const SwTwips nNew)
Definition: porlin.hxx:88
bool IsFootnotePortion() const
Definition: porlin.hxx:129
void AddPrtWidth(const SwTwips nNew)
Definition: porlin.hxx:85
SwTwips & GetAscent()
Definition: porlin.hxx:80
bool InSpaceGrp() const
Definition: porlin.hxx:116
bool IsErgoSumPortion() const
Definition: porlin.hxx:122
bool IsDropPortion() const
Definition: porlin.hxx:130
bool IsTabLeftPortion() const
Definition: porlin.hxx:124
bool InTabGrp() const
Definition: porlin.hxx:107
bool IsBreakPortion() const
Definition: porlin.hxx:121
PortionType mnWhichPor
Definition: porlin.hxx:63
bool IsQuoVadisPortion() const
Definition: porlin.hxx:123
bool InFixGrp() const
Definition: porlin.hxx:110
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:78
bool IsGrfNumPortion() const
Definition: porlin.hxx:118
bool IsTabDecimalPortion() const
Definition: porlin.hxx:127
bool IsMultiPortion() const
Definition: porlin.hxx:143
bool IsCombinedPortion() const
Definition: porlin.hxx:138
SwLinePortion & operator=(const SwLinePortion &rPortion)
Definition: porlin.hxx:188
bool IsHolePortion() const
Definition: porlin.hxx:135
void SetJoinBorderWithPrev(const bool bJoinPrev)
Definition: porlin.hxx:179
bool InFieldGrp() const
Definition: porlin.hxx:111
bool IsFlyPortion() const
Definition: porlin.hxx:134
bool IsFootnoteNumPortion() const
Definition: porlin.hxx:128
SwTwips mnHangingBaseline
Definition: porlin.hxx:59
SwTwips PrtWidth() const
Definition: porlin.hxx:84
SwTwips ExtraBlankWidth() const
Definition: porlin.hxx:87
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:101
SwTwips mnAscent
Definition: porlin.hxx:58
bool InExpGrp() const
Definition: porlin.hxx:114
bool IsFlyCntPortion() const
Definition: porlin.hxx:119
bool IsNumberPortion() const
Definition: porlin.hxx:144
bool InFixMargGrp() const
Definition: porlin.hxx:115
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
SwTwips Width() const
Definition: possiz.hxx:51
SwPosSize & operator=(SwPosSize const &)=default
struct _xmlTextWriter * xmlTextWriterPtr
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
float GetTextSize(std::u16string_view sValue)
long Long
#define PORGRP_FIXMARG
Definition: porlin.hxx:44
#define PORGRP_FIX
Definition: porlin.hxx:41
#define PORGRP_TOXREF
Definition: porlin.hxx:47
#define PORGRP_EXP
Definition: porlin.hxx:36
#define PORGRP_TAB
Definition: porlin.hxx:42
#define PORGRP_TXT
Portion groups.
Definition: porlin.hxx:35
#define PORGRP_HYPH
Definition: porlin.hxx:38
#define PORGRP_FLD
Definition: porlin.hxx:37
#define PORGRP_NUMBER
Definition: porlin.hxx:39
#define PORGRP_GLUE
Definition: porlin.hxx:40
tools::Long SwTwips
Definition: swtypes.hxx:51
PortionType
Definition: txttypes.hxx:24