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