LibreOffice Module sw (master) 1
itrform2.cxx
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
20#include <hintids.hxx>
21
22#include <memory>
23#include <com/sun/star/i18n/ScriptType.hpp>
24#include <editeng/lspcitem.hxx>
25#include <txtflcnt.hxx>
26#include <txtftn.hxx>
27#include <flyfrms.hxx>
28#include <fmtflcnt.hxx>
29#include <fmtftn.hxx>
30#include <ftninfo.hxx>
31#include <charfmt.hxx>
33#include <layfrm.hxx>
34#include <viewsh.hxx>
35#include <viewopt.hxx>
36#include <paratr.hxx>
37#include "itrform2.hxx"
38#include "porrst.hxx"
39#include "portab.hxx"
40#include "porfly.hxx"
41#include "portox.hxx"
42#include "porref.hxx"
43#include "porfld.hxx"
44#include "porftn.hxx"
45#include "porhyph.hxx"
46#include "pordrop.hxx"
47#include "redlnitr.hxx"
48#include <sortedobjs.hxx>
49#include <fmtanchr.hxx>
50#include <pagefrm.hxx>
51#include <tgrditem.hxx>
52#include <doc.hxx>
53#include "pormulti.hxx"
55#include <xmloff/odffields.hxx>
57#include <IMark.hxx>
61#include <comphelper/string.hxx>
62#include <docsh.hxx>
63#include <unocrsrhelper.hxx>
65#include <com/sun/star/rdf/Statement.hpp>
66#include <com/sun/star/rdf/URI.hpp>
67#include <com/sun/star/rdf/URIs.hpp>
68#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
69#include <com/sun/star/rdf/XLiteral.hpp>
70#include <com/sun/star/text/XTextContent.hpp>
71
72using namespace ::com::sun::star;
73
74namespace {
76 tools::Long lcl_CalcOptRepaint( SwTextFormatter &rThis,
77 SwLineLayout const &rCurr,
78 TextFrameIndex nOldLineEnd,
79 const std::vector<tools::Long> &rFlyStarts );
81 bool lcl_BuildHiddenPortion(const SwTextSizeInfo& rInf, TextFrameIndex &rPos);
82
83 // Check whether the two font has the same border
84 bool lcl_HasSameBorder(const SwFont& rFirst, const SwFont& rSecond);
85}
86
87static void ClearFly( SwTextFormatInfo &rInf )
88{
89 delete rInf.GetFly();
90 rInf.SetFly(nullptr);
91}
92
94{
95 CtorInitTextPainter( pNewFrame, pNewInf );
96 m_pInf = pNewInf;
98 m_pMulti = nullptr;
99
100 m_bOnceMore = false;
101 m_bFlyInContentBase = false;
102 m_bTruncLines = false;
107 m_pByEndIter.reset();
108 m_pFirstOfBorderMerge = nullptr;
109
110 if (m_nStart > TextFrameIndex(GetInfo().GetText().getLength()))
111 {
112 OSL_ENSURE( false, "+SwTextFormatter::CTOR: bad offset" );
113 m_nStart = TextFrameIndex(GetInfo().GetText().getLength());
114 }
115
116}
117
119{
120 // Extremely unlikely, but still possible
121 // e.g.: field splits up, widows start to matter
122 if( GetInfo().GetRest() )
123 {
124 delete GetInfo().GetRest();
125 GetInfo().SetRest(nullptr);
126 }
127}
128
130{
131 // Insert BEHIND the current element
132 if ( m_pCurr )
133 {
134 pLay->SetNext( m_pCurr->GetNext() );
135 m_pCurr->SetNext( pLay );
136 }
137 else
138 m_pCurr = pLay;
139}
140
142{
143 // We want the rest height relative to the page.
144 // If we're in a table, then pFrame->GetUpper() is not the page.
145
146 // GetFrameRstHeight() is being called with Footnote.
147 // Wrong: const SwFrame *pUpper = pFrame->GetUpper();
148 const SwFrame *pPage = m_pFrame->FindPageFrame();
149 const SwTwips nHeight = pPage->getFrameArea().Top()
150 + pPage->getFramePrintArea().Top()
151 + pPage->getFramePrintArea().Height() - Y();
152 if( 0 > nHeight )
153 return m_pCurr->Height();
154 else
155 return sal_uInt16( nHeight );
156}
157
159{
160 if (pPortion == m_pFirstOfBorderMerge)
161 {
162 m_pFirstOfBorderMerge = nullptr;
163 return true;
164 }
165 return false;
166}
167
169{
170 // Save values and initialize rInf
171 SwLinePortion *pUnderflow = rInf.GetUnderflow();
172 if( !pUnderflow )
173 return nullptr;
174
175 // We format backwards, i.e. attribute changes can happen the next
176 // line again.
177 // Can be seen in 8081.sdw, if you enter text in the first line
178
179 TextFrameIndex const nSoftHyphPos = rInf.GetSoftHyphPos();
180 TextFrameIndex const nUnderScorePos = rInf.GetUnderScorePos();
181
182 // Save flys and set to 0, or else segmentation fault
183 // Not ClearFly(rInf) !
184 SwFlyPortion *pFly = rInf.GetFly();
185 rInf.SetFly( nullptr );
186
187 FeedInf( rInf );
188 rInf.SetLast( m_pCurr );
189 // pUnderflow does not need to be deleted, because it will drown in the following
190 // Truncate()
191 rInf.SetUnderflow(nullptr);
192 rInf.SetSoftHyphPos( nSoftHyphPos );
193 rInf.SetUnderScorePos( nUnderScorePos );
194 rInf.SetPaintOfst( GetLeftMargin() );
195
196 // We look for the portion with the under-flow position
198 if( pPor != pUnderflow )
199 {
200 // pPrev will be the last portion before pUnderflow,
201 // which still has a real width.
202 // Exception: SoftHyphPortion must not be forgotten, of course!
203 // Although they don't have a width.
204 SwLinePortion *pTmpPrev = pPor;
205 while( pPor && pPor != pUnderflow )
206 {
207 if( !pPor->IsKernPortion() &&
208 ( pPor->Width() || pPor->IsSoftHyphPortion() ) )
209 {
210 while( pTmpPrev != pPor )
211 {
212 pTmpPrev->Move( rInf );
213 rInf.SetLast( pTmpPrev );
214 pTmpPrev = pTmpPrev->GetNextPortion();
215 OSL_ENSURE( pTmpPrev, "Underflow: losing control!" );
216 };
217 }
218 pPor = pPor->GetNextPortion();
219 }
220 pPor = pTmpPrev;
221 if( pPor && // Skip flys and initials when underflow.
222 ( pPor->IsFlyPortion() || pPor->IsDropPortion() ||
223 pPor->IsFlyCntPortion() ) )
224 {
225 pPor->Move( rInf );
226 rInf.SetLast( pPor );
227 rInf.SetStopUnderflow( true );
228 pPor = pUnderflow;
229 }
230 }
231
232 // What? The under-flow portion is not in the portion chain?
233 OSL_ENSURE( pPor, "SwTextFormatter::Underflow: overflow but underflow" );
234
235 // Snapshot
236 if ( pPor==rInf.GetLast() )
237 {
238 // We end up here, if the portion triggering the under-flow
239 // spans over the whole line. E.g. if a word spans across
240 // multiple lines and flows into a fly in the second line.
241 rInf.SetFly( pFly );
242 pPor->Truncate();
243 return pPor; // Is that enough?
244 }
245 // End the snapshot
246
247 // X + Width == 0 with SoftHyph > Line?!
248 if( !pPor || !(rInf.X() + pPor->Width()) )
249 {
250 delete pFly;
251 return nullptr;
252 }
253
254 // Preparing for Format()
255 // We need to chip off the chain behind pLast, because we Insert after the Format()
256 SeekAndChg( rInf );
257
258 // line width is adjusted, so that pPor does not fit to current
259 // line anymore
260 rInf.Width( rInf.X() + (pPor->Width() ? pPor->Width() - 1 : 0) );
261 rInf.SetLen( pPor->GetLen() );
262 rInf.SetFull( false );
263 if( pFly )
264 {
265 // We need to recalculate the FlyPortion due to the following reason:
266 // If the base line is lowered by a big font in the middle of the line,
267 // causing overlapping with a fly, the FlyPortion has a wrong size/fixed
268 // size.
269 rInf.SetFly( pFly );
270 CalcFlyWidth( rInf );
271 }
272 rInf.GetLast()->SetNextPortion(nullptr);
273
274 // The SwLineLayout is an exception to this, which splits at the first
275 // portion change.
276 // Here only the other way around:
277 if( rInf.GetLast() == m_pCurr )
278 {
279 if( pPor->InTextGrp() && !pPor->InExpGrp() )
280 {
281 const PortionType nOldWhich = m_pCurr->GetWhichPor();
282 *static_cast<SwLinePortion*>(m_pCurr) = *pPor;
284 m_pCurr->SetWhichPor( nOldWhich );
285 pPor->SetNextPortion( nullptr );
286 delete pPor;
287 pPor = m_pCurr;
288 }
289 }
290
291 // Make sure that m_pFirstOfBorderMerge does not point to a portion which
292 // will be deleted by Truncate() below.
293 SwLinePortion* pNext = pPor->GetNextPortion();
294 while (pNext)
295 {
297 break;
298 pNext = pNext->GetNextPortion();
299 }
300 pPor->Truncate();
301 SwLinePortion *const pRest( rInf.GetRest() );
302 if (pRest && pRest->InFieldGrp() &&
303 static_cast<SwFieldPortion*>(pRest)->IsNoLength())
304 {
305 // HACK: decrement again, so we pick up the suffix in next line!
306 m_pByEndIter->PrevAttr();
307 }
308 delete pRest;
309 rInf.SetRest(nullptr);
310 return pPor;
311}
312
314 SwLinePortion *pPor )
315{
316 SwLinePortion *pLast = nullptr;
317 // The new portion is inserted, but everything's different for
318 // LineLayout...
319 if( pPor == m_pCurr )
320 {
321 if ( m_pCurr->GetNextPortion() )
322 {
323 pLast = pPor;
324 pPor = m_pCurr->GetNextPortion();
325 }
326
327 // i#112181 - Prevent footnote anchor being wrapped to next line
328 // without preceding word
330 }
331 else
332 {
333 pLast = rInf.GetLast();
334 if( pLast->GetNextPortion() )
335 {
336 while( pLast->GetNextPortion() )
337 pLast = pLast->GetNextPortion();
338 rInf.SetLast( pLast );
339 }
340 pLast->Insert( pPor );
341
343
344 // Adjust maxima
345 if( m_pCurr->Height() < pPor->Height() )
346 m_pCurr->Height( pPor->Height(), pPor->IsTextPortion() );
347 if( m_pCurr->GetAscent() < pPor->GetAscent() )
348 m_pCurr->SetAscent( pPor->GetAscent() );
351
352 if (GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY))
353 {
354 // For DOCX with compat=14 the only shape in line defines height of the line in spite of used font
355 if (pLast->IsFlyCntPortion() && pPor->IsTextPortion() && pPor->GetLen() == TextFrameIndex(0))
356 {
357 m_pCurr->SetAscent(pLast->GetAscent());
358 m_pCurr->Height(pLast->Height());
359 }
360 }
361 }
362
363 // Sometimes chains are constructed (e.g. by hyphenate)
364 rInf.SetLast( pPor );
365 while( pPor )
366 {
367 if (!pPor->IsDropPortion())
368 MergeCharacterBorder(*pPor, pLast, rInf);
369
370 pPor->Move( rInf );
371 rInf.SetLast( pPor );
372 pLast = pPor;
373 pPor = pPor->GetNextPortion();
374 }
375}
376
378{
379 OSL_ENSURE( rInf.GetText().getLength() < COMPLETE_STRING,
380 "SwTextFormatter::BuildPortions: bad text length in info" );
381
382 rInf.ChkNoHyph( CntEndHyph(), CntMidHyph() );
383
384 // First NewTextPortion() decides whether pCurr ends up in pPor.
385 // We need to make sure that the font is being set in any case.
386 // This is done automatically in CalcAscent.
387 rInf.SetLast( m_pCurr );
388 rInf.ForcedLeftMargin( 0 );
389
390 OSL_ENSURE( m_pCurr->FindLastPortion() == m_pCurr, "pLast supposed to equal pCurr" );
391
392 if( !m_pCurr->GetAscent() && !m_pCurr->Height() )
393 CalcAscent( rInf, m_pCurr );
394
395 SeekAndChg( rInf );
396
397 // Width() is shortened in CalcFlyWidth if we have a FlyPortion
398 OSL_ENSURE( !rInf.X() || m_pMulti, "SwTextFormatter::BuildPortion X=0?" );
399 CalcFlyWidth( rInf );
400 SwFlyPortion *pFly = rInf.GetFly();
401 if( pFly )
402 {
403 if ( 0 < pFly->GetFix() )
404 ClearFly( rInf );
405 else
406 rInf.SetFull(true);
407 }
408
409 ::std::optional<TextFrameIndex> oMovedFlyIndex;
410 if (SwTextFrame const*const pFollow = GetTextFrame()->GetFollow())
411 {
412 // flys are always on master!
413 if (GetTextFrame()->GetDrawObjs() && pFollow->GetUpper() != GetTextFrame()->GetUpper())
414 {
415 for (SwAnchoredObject const*const pAnchoredObj : *GetTextFrame()->GetDrawObjs())
416 {
417 // tdf#146500 try to stop where a fly is anchored in the follow
418 // that has recently been moved (presumably by splitting this
419 // frame); similar to check in SwFlowFrame::MoveBwd()
420 if (pAnchoredObj->RestartLayoutProcess()
421 && !pAnchoredObj->IsTmpConsiderWrapInfluence())
422 {
423 SwFormatAnchor const& rAnchor(pAnchoredObj->GetFrameFormat().GetAnchor());
424 assert(rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR || rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA);
425 TextFrameIndex const nAnchor(GetTextFrame()->MapModelToViewPos(*rAnchor.GetContentAnchor()));
426 if (pFollow->GetOffset() <= nAnchor
427 && (pFollow->GetFollow() == nullptr
428 || nAnchor < pFollow->GetFollow()->GetOffset()))
429 {
430 if (!oMovedFlyIndex || nAnchor < *oMovedFlyIndex)
431 {
432 oMovedFlyIndex.emplace(nAnchor);
433 }
434 }
435 }
436 }
437 }
438 }
439
440 SwLinePortion *pPor = NewPortion(rInf, oMovedFlyIndex);
441
442 // Asian grid stuff
443 SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame()));
444 const bool bHasGrid = pGrid && rInf.SnapToGrid() &&
445 GRID_LINES_CHARS == pGrid->GetGridType();
446
447
448 const SwDoc & rDoc = rInf.GetTextFrame()->GetDoc();
449 const sal_uInt16 nGridWidth = bHasGrid ? GetGridWidth(*pGrid, rDoc) : 0;
450
451 // used for grid mode only:
452 // the pointer is stored, because after formatting of non-asian text,
453 // the width of the kerning portion has to be adjusted
454 // Inserting a SwKernPortion before a SwTabPortion isn't necessary
455 // and will break the SwTabPortion.
456 SwKernPortion* pGridKernPortion = nullptr;
457
458 bool bFull = false;
459 SwTwips nUnderLineStart = 0;
460 rInf.Y( Y() );
461
462 while( pPor && !rInf.IsStop() )
463 {
464 OSL_ENSURE(rInf.GetLen() < TextFrameIndex(COMPLETE_STRING) &&
465 rInf.GetIdx() <= TextFrameIndex(rInf.GetText().getLength()),
466 "SwTextFormatter::BuildPortions: bad length in info" );
467
468 // We have to check the script for fields in order to set the
469 // correct nActual value for the font.
470 if( pPor->InFieldGrp() )
471 static_cast<SwFieldPortion*>(pPor)->CheckScript( rInf );
472
473 if( ! bHasGrid && rInf.HasScriptSpace() &&
474 rInf.GetLast() && rInf.GetLast()->InTextGrp() &&
475 rInf.GetLast()->Width() && !rInf.GetLast()->InNumberGrp() )
476 {
477 SwFontScript nNxtActual = rInf.GetFont()->GetActual();
478 SwFontScript nLstActual = nNxtActual;
479 sal_uInt16 nLstHeight = o3tl::narrowing<sal_uInt16>(rInf.GetFont()->GetHeight());
480 bool bAllowBehind = false;
481 const CharClass& rCC = GetAppCharClass();
482
483 // are there any punctuation characters on both sides
484 // of the kerning portion?
485 if ( pPor->InFieldGrp() )
486 {
487 OUString aAltText;
488 if ( static_cast<SwFieldPortion*>(pPor)->GetExpText( rInf, aAltText ) &&
489 !aAltText.isEmpty() )
490 {
491 bAllowBehind = rCC.isLetterNumeric( aAltText, 0 );
492
493 const SwFont* pTmpFnt = static_cast<SwFieldPortion*>(pPor)->GetFont();
494 if ( pTmpFnt )
495 nNxtActual = pTmpFnt->GetActual();
496 }
497 }
498 else
499 {
500 const OUString& rText = rInf.GetText();
501 sal_Int32 nIdx = sal_Int32(rInf.GetIdx());
502 bAllowBehind = nIdx < rText.getLength() && rCC.isLetterNumeric(rText, nIdx);
503 }
504
505 const SwLinePortion* pLast = rInf.GetLast();
506 if ( bAllowBehind && pLast )
507 {
508 bool bAllowBefore = false;
509
510 if ( pLast->InFieldGrp() )
511 {
512 OUString aAltText;
513 if ( static_cast<const SwFieldPortion*>(pLast)->GetExpText( rInf, aAltText ) &&
514 !aAltText.isEmpty() )
515 {
516 bAllowBefore = rCC.isLetterNumeric( aAltText, aAltText.getLength() - 1 );
517
518 const SwFont* pTmpFnt = static_cast<const SwFieldPortion*>(pLast)->GetFont();
519 if ( pTmpFnt )
520 {
521 nLstActual = pTmpFnt->GetActual();
522 nLstHeight = o3tl::narrowing<sal_uInt16>(pTmpFnt->GetHeight());
523 }
524 }
525 }
526 else if ( rInf.GetIdx() )
527 {
528 bAllowBefore = rCC.isLetterNumeric(rInf.GetText(), sal_Int32(rInf.GetIdx()) - 1);
529 // Note: ScriptType returns values in [1,4]
530 if ( bAllowBefore )
531 nLstActual = SwFontScript(m_pScriptInfo->ScriptType(rInf.GetIdx() - TextFrameIndex(1)) - 1);
532 }
533
534 nLstHeight /= 5;
535 // does the kerning portion still fit into the line?
536 if( bAllowBefore && ( nLstActual != nNxtActual ) &&
537 nLstHeight && rInf.X() + nLstHeight <= rInf.Width() &&
538 ! pPor->InTabGrp() )
539 {
540 SwKernPortion* pKrn =
541 new SwKernPortion( *rInf.GetLast(), nLstHeight,
542 pLast->InFieldGrp() && pPor->InFieldGrp() );
543 rInf.GetLast()->SetNextPortion( nullptr );
544 InsertPortion( rInf, pKrn );
545 }
546 }
547 }
548 else if ( bHasGrid && ! pGridKernPortion && ! m_pMulti && ! pPor->InTabGrp() )
549 {
550 // insert a grid kerning portion
551 pGridKernPortion = pPor->IsKernPortion() ?
552 static_cast<SwKernPortion*>(pPor) :
553 new SwKernPortion( *m_pCurr );
554
555 // if we have a new GridKernPortion, we initially calculate
556 // its size so that its ends on the grid
557 const SwPageFrame* pPageFrame = m_pFrame->FindPageFrame();
558 const SwLayoutFrame* pBody = pPageFrame->FindBodyCont();
559 SwRectFnSet aRectFnSet(pPageFrame);
560
561 const tools::Long nGridOrigin = pBody ?
562 aRectFnSet.GetPrtLeft(*pBody) :
563 aRectFnSet.GetPrtLeft(*pPageFrame);
564
565 SwTwips nStartX = rInf.X() + GetLeftMargin();
566 if ( aRectFnSet.IsVert() )
567 {
568 Point aPoint( nStartX, 0 );
570 nStartX = aPoint.Y();
571 }
572
573 const SwTwips nOfst = nStartX - nGridOrigin;
574 if ( nOfst )
575 {
576 const sal_uLong i = ( nOfst > 0 ) ?
577 ( ( nOfst - 1 ) / nGridWidth + 1 ) :
578 0;
579 const SwTwips nKernWidth = i * nGridWidth - nOfst;
580 const SwTwips nRestWidth = rInf.Width() - rInf.X();
581
582 if ( nKernWidth <= nRestWidth )
583 pGridKernPortion->Width( nKernWidth );
584 }
585
586 if ( pGridKernPortion != pPor )
587 InsertPortion( rInf, pGridKernPortion );
588 }
589
590 if( pPor->IsDropPortion() )
591 MergeCharacterBorder(*static_cast<SwDropPortion*>(pPor));
592
593 // the multi-portion has its own format function
594 if( pPor->IsMultiPortion() && ( !m_pMulti || m_pMulti->IsBidi() ) )
595 bFull = BuildMultiPortion( rInf, *static_cast<SwMultiPortion*>(pPor) );
596 else
597 bFull = pPor->Format( rInf );
598
599 if( rInf.IsRuby() && !rInf.GetRest() )
600 bFull = true;
601
602 // if we are underlined, we store the beginning of this underlined
603 // segment for repaint optimization
604 if ( LINESTYLE_NONE != m_pFont->GetUnderline() && ! nUnderLineStart )
605 nUnderLineStart = GetLeftMargin() + rInf.X();
606
607 if ( pPor->IsFlyPortion() )
608 m_pCurr->SetFly( true );
609 // some special cases, where we have to take care for the repaint
610 // offset:
611 // 1. Underlined portions due to special underline feature
612 // 2. Right Tab
613 // 3. BidiPortions
614 // 4. other Multiportions
615 // 5. DropCaps
616 // 6. Grid Mode
617 else if ( ( ! rInf.GetPaintOfst() || nUnderLineStart < rInf.GetPaintOfst() ) &&
618 // 1. Underlined portions
619 nUnderLineStart &&
620 // reformat is at end of an underlined portion and next portion
621 // is not underlined
622 ( ( rInf.GetReformatStart() == rInf.GetIdx() &&
624 ) ||
625 // reformat is inside portion and portion is underlined
626 ( rInf.GetReformatStart() >= rInf.GetIdx() &&
627 rInf.GetReformatStart() <= rInf.GetIdx() + pPor->GetLen() &&
629 rInf.SetPaintOfst( nUnderLineStart );
630 else if ( ! rInf.GetPaintOfst() &&
631 // 2. Right Tab
632 ( ( pPor->InTabGrp() && !pPor->IsTabLeftPortion() ) ||
633 // 3. BidiPortions
634 ( pPor->IsMultiPortion() && static_cast<SwMultiPortion*>(pPor)->IsBidi() ) ||
635 // 4. Multi Portion and 5. Drop Caps
636 ( ( pPor->IsDropPortion() || pPor->IsMultiPortion() ) &&
637 rInf.GetReformatStart() >= rInf.GetIdx() &&
638 rInf.GetReformatStart() <= rInf.GetIdx() + pPor->GetLen() )
639 // 6. Grid Mode
640 || ( bHasGrid && SwFontScript::CJK != m_pFont->GetActual() )
641 )
642 )
643 // we store the beginning of the critical portion as our
644 // paint offset
645 rInf.SetPaintOfst( GetLeftMargin() + rInf.X() );
646
647 // under one of these conditions we are allowed to delete the
648 // start of the underline portion
649 if ( IsUnderlineBreak( *pPor, *m_pFont ) )
650 nUnderLineStart = 0;
651
652 if( pPor->IsFlyCntPortion() || ( pPor->IsMultiPortion() &&
653 static_cast<SwMultiPortion*>(pPor)->HasFlyInContent() ) )
655 // bUnderflow needs to be reset or we wrap again at the next softhyphen
656 if ( !bFull )
657 {
658 rInf.ClrUnderflow();
659 if( ! bHasGrid && rInf.HasScriptSpace() && pPor->InTextGrp() &&
660 pPor->GetLen() && !pPor->InFieldGrp() )
661 {
662 // The distance between two different scripts is set
663 // to 20% of the fontheight.
664 TextFrameIndex const nTmp = rInf.GetIdx() + pPor->GetLen();
665 if (nTmp == m_pScriptInfo->NextScriptChg(nTmp - TextFrameIndex(1)) &&
666 nTmp != TextFrameIndex(rInf.GetText().getLength()) &&
667 (m_pScriptInfo->ScriptType(nTmp - TextFrameIndex(1)) == css::i18n::ScriptType::ASIAN ||
668 m_pScriptInfo->ScriptType(nTmp) == css::i18n::ScriptType::ASIAN) )
669 {
670 const SwTwips nDist = rInf.GetFont()->GetHeight()/5;
671
672 if( nDist )
673 {
674 // we do not want a kerning portion if any end
675 // would be a punctuation character
676 const CharClass& rCC = GetAppCharClass();
677 if (rCC.isLetterNumeric(rInf.GetText(), sal_Int32(nTmp) - 1)
678 && rCC.isLetterNumeric(rInf.GetText(), sal_Int32(nTmp)))
679 {
680 // does the kerning portion still fit into the line?
681 if ( rInf.X() + pPor->Width() + nDist <= rInf.Width() )
682 new SwKernPortion( *pPor, nDist );
683 else
684 bFull = true;
685 }
686 }
687 }
688 }
689 }
690
691 if ( bHasGrid && pPor != pGridKernPortion && ! m_pMulti && ! pPor->InTabGrp() )
692 {
693 TextFrameIndex const nTmp = rInf.GetIdx() + pPor->GetLen();
694 const SwTwips nRestWidth = rInf.Width() - rInf.X() - pPor->Width();
695
696 const SwFontScript nCurrScript = m_pFont->GetActual(); // pScriptInfo->ScriptType( rInf.GetIdx() );
697 const SwFontScript nNextScript =
698 nTmp >= TextFrameIndex(rInf.GetText().getLength())
700 : m_pScriptInfo->WhichFont(nTmp);
701
702 // snap non-asian text to grid if next portion is ASIAN or
703 // there are no more portions in this line
704 // be careful when handling an underflow event: the gridkernportion
705 // could have been deleted
706 if ( nRestWidth > 0 && SwFontScript::CJK != nCurrScript &&
707 ! rInf.IsUnderflow() && ( bFull || SwFontScript::CJK == nNextScript ) )
708 {
709 OSL_ENSURE( pGridKernPortion, "No GridKernPortion available" );
710
711 // calculate size
712 SwLinePortion* pTmpPor = pGridKernPortion->GetNextPortion();
713 sal_uInt16 nSumWidth = pPor->Width();
714 while ( pTmpPor )
715 {
716 nSumWidth = nSumWidth + pTmpPor->Width();
717 pTmpPor = pTmpPor->GetNextPortion();
718 }
719
720 const SwTwips i = nSumWidth ?
721 ( nSumWidth - 1 ) / nGridWidth + 1 :
722 0;
723 const SwTwips nTmpWidth = i * nGridWidth;
724 const SwTwips nKernWidth = std::min(nTmpWidth - nSumWidth, nRestWidth);
725 const SwTwips nKernWidth_1 = pGrid->IsSnapToChars() ?
726 nKernWidth / 2 : 0;
727
728 OSL_ENSURE( nKernWidth <= nRestWidth,
729 "Not enough space left for adjusting non-asian text in grid mode" );
730 if (nKernWidth_1)
731 {
732 pGridKernPortion->Width( pGridKernPortion->Width() + nKernWidth_1 );
733 rInf.X( rInf.X() + nKernWidth_1 );
734 }
735
736 if ( ! bFull && nKernWidth - nKernWidth_1 > 0 )
737 new SwKernPortion( *pPor, static_cast<short>(nKernWidth - nKernWidth_1),
738 false, true );
739
740 pGridKernPortion = nullptr;
741 }
742 else if ( pPor->IsMultiPortion() || pPor->InFixMargGrp() ||
743 pPor->IsFlyCntPortion() || pPor->InNumberGrp() ||
744 pPor->InFieldGrp() || nCurrScript != nNextScript )
745 // next portion should snap to grid
746 pGridKernPortion = nullptr;
747 }
748
749 rInf.SetFull( bFull );
750
751 // Restportions from fields with multiple lines don't yet have the right ascent
752 if ( !pPor->GetLen() && !pPor->IsFlyPortion()
753 && !pPor->IsGrfNumPortion() && ! pPor->InNumberGrp()
754 && !pPor->IsMultiPortion() )
755 CalcAscent( rInf, pPor );
756
757 InsertPortion( rInf, pPor );
758 if (pPor->IsMultiPortion() && (!m_pMulti || m_pMulti->IsBidi()))
759 {
760 (void) rInf.CheckCurrentPosBookmark(); // bookmark was already created inside MultiPortion!
761 }
762 pPor = NewPortion(rInf, oMovedFlyIndex);
763 }
764
765 if( !rInf.IsStop() )
766 {
767 // The last right centered, decimal tab
768 SwTabPortion *pLastTab = rInf.GetLastTab();
769 if( pLastTab )
770 pLastTab->FormatEOL( rInf );
771 else if( rInf.GetLast() && rInf.LastKernPortion() )
772 rInf.GetLast()->FormatEOL( rInf );
773 }
775 && static_cast<SwNumberPortion*>(m_pCurr->GetNextPortion())->IsHide() )
776 rInf.SetNumDone( false );
777
778 // Delete fly in any case
779 ClearFly( rInf );
780
781 // Reinit the tab overflow flag after the line
782 rInf.SetTabOverflow( false );
783}
784
786{
787 if( SvxAdjust::Left != GetAdjust() && !m_pMulti)
788 {
789 pCurrent->SetFormatAdj(true);
790 if( IsFlyInCntBase() )
791 {
792 CalcAdjLine( pCurrent );
793 // For e.g. centered fly we need to switch the RefPoint
794 // That's why bAlways = true
795 UpdatePos( pCurrent, GetTopLeft(), GetStart(), true );
796 }
797 }
798}
799
801{
802 bool bCalc = false;
803 if ( pPor->InFieldGrp() && static_cast<SwFieldPortion*>(pPor)->GetFont() )
804 {
805 // Numbering + InterNetFields can keep an own font, then their size is
806 // independent from hard attribute values
807 SwFont* pFieldFnt = static_cast<SwFieldPortion*>(pPor)->m_pFont.get();
808 SwFontSave aSave( rInf, pFieldFnt );
809 pPor->Height( rInf.GetTextHeight() );
810 pPor->SetAscent( rInf.GetAscent() );
811 bCalc = true;
812 }
813 // i#89179
814 // tab portion representing the list tab of a list label gets the
815 // same height and ascent as the corresponding number portion
816 else if ( pPor->InTabGrp() && pPor->GetLen() == TextFrameIndex(0) &&
817 rInf.GetLast() && rInf.GetLast()->InNumberGrp() &&
818 static_cast<const SwNumberPortion*>(rInf.GetLast())->HasFont() )
819 {
820 const SwLinePortion* pLast = rInf.GetLast();
821 pPor->Height( pLast->Height() );
822 pPor->SetAscent( pLast->GetAscent() );
823 }
824 else if (pPor->GetWhichPor() == PortionType::Bookmark
825 && rInf.GetIdx() == TextFrameIndex(rInf.GetText().getLength()))
826 {
827 // bookmark at end of paragraph: *don't* advance iterator, use the
828 // current font instead; it's possible that there's a font size on the
829 // paragraph and it's overridden on the last line of the paragraph and
830 // we don't want to apply it via SwBookmarkPortion and grow the line
831 // height (example: n758883.docx)
832 SwLinePortion const*const pLast = rInf.GetLast();
833 assert(pLast);
834 pPor->Height( pLast->Height(), false );
835 pPor->SetAscent( pLast->GetAscent() );
836 }
837 else
838 {
839 const SwLinePortion *pLast = rInf.GetLast();
840 bool bChg = false;
841
842 // In empty lines the attributes are switched on via SeekStart
843 const bool bFirstPor = rInf.GetLineStart() == rInf.GetIdx();
844 if ( pPor->IsQuoVadisPortion() )
845 bChg = SeekStartAndChg( rInf, true );
846 else
847 {
848 if( bFirstPor )
849 {
850 if( !rInf.GetText().isEmpty() )
851 {
852 if ( pPor->GetLen() || !rInf.GetIdx()
853 || ( m_pCurr != pLast && !pLast->IsFlyPortion() )
854 || !m_pCurr->IsRest() ) // instead of !rInf.GetRest()
855 bChg = SeekAndChg( rInf );
856 else
857 bChg = SeekAndChgBefore( rInf );
858 }
859 else if ( m_pMulti )
860 // do not open attributes starting at 0 in empty multi
861 // portions (rotated numbering followed by a footnote
862 // can cause trouble, because the footnote attribute
863 // starts at 0, but if we open it, the attribute handler
864 // cannot handle it.
865 bChg = false;
866 else
867 bChg = SeekStartAndChg( rInf );
868 }
869 else
870 bChg = SeekAndChg( rInf );
871 }
872 if( bChg || bFirstPor || !pPor->GetAscent()
873 || !rInf.GetLast()->InTextGrp() )
874 {
876 pPor->SetAscent( rInf.GetAscent() );
877 pPor->Height( rInf.GetTextHeight() );
878 bCalc = true;
879 }
880 else
881 {
882 pPor->Height( pLast->Height() );
883 pPor->SetAscent( pLast->GetAscent() );
884 }
885 }
886
887 if( pPor->InTextGrp() && bCalc )
888 {
889 pPor->SetAscent(pPor->GetAscent() +
890 rInf.GetFont()->GetTopBorderSpace());
891 pPor->Height(pPor->Height() +
892 rInf.GetFont()->GetTopBorderSpace() +
893 rInf.GetFont()->GetBottomBorderSpace() );
894 }
895}
896
897namespace {
898
899class SwMetaPortion : public SwTextPortion
900{
901 Color m_aShadowColor;
902public:
903 SwMetaPortion() { SetWhichPor( PortionType::Meta ); }
904 virtual void Paint( const SwTextPaintInfo &rInf ) const override;
905 void SetShadowColor(const Color& rCol ) { m_aShadowColor = rCol; }
906};
907
909class SwContentControlPortion : public SwTextPortion
910{
911 SwTextContentControl* m_pTextContentControl;
912public:
913 SwContentControlPortion(SwTextContentControl* pTextContentControl);
914 virtual void Paint(const SwTextPaintInfo& rInf) const override;
915
917 bool DescribePDFControl(const SwTextPaintInfo& rInf) const;
918};
919}
920
921void SwMetaPortion::Paint( const SwTextPaintInfo &rInf ) const
922{
923 if ( Width() )
924 {
925 rInf.DrawViewOpt( *this, PortionType::Meta,
926 // custom shading (RDF metadata)
927 COL_BLACK == m_aShadowColor
928 ? nullptr
929 : &m_aShadowColor );
930
931 SwTextPortion::Paint( rInf );
932 }
933}
934
935SwContentControlPortion::SwContentControlPortion(SwTextContentControl* pTextContentControl)
936 : m_pTextContentControl(pTextContentControl)
937{
938 SetWhichPor(PortionType::ContentControl);
939}
940
941bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) const
942{
943 auto pPDFExtOutDevData = dynamic_cast<vcl::PDFExtOutDevData*>(rInf.GetOut()->GetExtOutDevData());
944 if (!pPDFExtOutDevData)
945 {
946 return false;
947 }
948
949 if (!pPDFExtOutDevData->GetIsExportFormFields())
950 {
951 return false;
952 }
953
954 if (!m_pTextContentControl)
955 {
956 return false;
957 }
958
959 const SwFormatContentControl& rFormatContentControl = m_pTextContentControl->GetContentControl();
960 const std::shared_ptr<SwContentControl>& pContentControl = rFormatContentControl.GetContentControl();
961 if (!pContentControl)
962 {
963 return false;
964 }
965
966 // Check if this is the first content control portion of this content control.
967 SwTextNode* pTextNode = pContentControl->GetTextNode();
968 sal_Int32 nStart = m_pTextContentControl->GetStart();
969 sal_Int32 nEnd = *m_pTextContentControl->GetEnd();
970 TextFrameIndex nViewStart = rInf.GetTextFrame()->MapModelToView(pTextNode, nStart);
971 TextFrameIndex nViewEnd = rInf.GetTextFrame()->MapModelToView(pTextNode, nEnd);
972 // The content control portion starts 1 char after the starting dummy character.
973 if (rInf.GetIdx() != nViewStart + TextFrameIndex(1))
974 {
975 // Ignore: don't process and also don't emit plain text fallback.
976 return true;
977 }
978
979 std::unique_ptr<vcl::PDFWriter::AnyWidget> pDescriptor;
980 switch (pContentControl->GetType())
981 {
984 {
985 pDescriptor = std::make_unique<vcl::PDFWriter::EditWidget>();
986 break;
987 }
989 {
990 pDescriptor = std::make_unique<vcl::PDFWriter::CheckBoxWidget>();
991 auto pCheckBoxWidget = static_cast<vcl::PDFWriter::CheckBoxWidget*>(pDescriptor.get());
992 pCheckBoxWidget->Checked = pContentControl->GetChecked();
993 pCheckBoxWidget->OnValue = pContentControl->GetCheckedState();
994 pCheckBoxWidget->OffValue = pContentControl->GetUncheckedState();
995 break;
996 }
998 {
999 pDescriptor = std::make_unique<vcl::PDFWriter::ListBoxWidget>();
1000 auto pListWidget = static_cast<vcl::PDFWriter::ListBoxWidget*>(pDescriptor.get());
1001 pListWidget->DropDown = true;
1002 for (const auto& rItem : pContentControl->GetListItems())
1003 {
1004 pListWidget->Entries.push_back(rItem.m_aDisplayText);
1005 }
1006 break;
1007 }
1009 {
1010 pDescriptor = std::make_unique<vcl::PDFWriter::ComboBoxWidget>();
1011 auto pComboWidget = static_cast<vcl::PDFWriter::ComboBoxWidget*>(pDescriptor.get());
1012 for (const auto& rItem : pContentControl->GetListItems())
1013 {
1014 pComboWidget->Entries.push_back(rItem.m_aDisplayText);
1015 }
1016 break;
1017 }
1019 {
1020 pDescriptor = std::make_unique<vcl::PDFWriter::EditWidget>();
1021 auto pEditWidget = static_cast<vcl::PDFWriter::EditWidget*>(pDescriptor.get());
1022 pEditWidget->Format = vcl::PDFWriter::Date;
1023 // GetDateFormat() uses a syntax that works with SvNumberFormatter::PutEntry(), PDF's
1024 // AFDate_FormatEx() uses a similar syntax, but uses lowercase characters in case of
1025 // "Y", "M" and "D" at least.
1026 pEditWidget->DateFormat = pContentControl->GetDateFormat().toAsciiLowerCase();
1027 break;
1028 }
1029 default:
1030 break;
1031 }
1032
1033 if (!pDescriptor)
1034 {
1035 return false;
1036 }
1037
1038 const SwFont* pFont = rInf.GetFont();
1039 if (pFont)
1040 {
1041 pDescriptor->TextFont = pFont->GetActualFont();
1042 }
1043
1044 // Description for accessibility purposes.
1045 if (!pContentControl->GetAlias().isEmpty())
1046 {
1047 pDescriptor->Description = pContentControl->GetAlias();
1048 }
1049
1050 // Map the text of the content control to the descriptor's text.
1051 SwPosition aPoint(*pTextNode, nStart);
1052 SwPosition aMark(*pTextNode, nEnd);
1053 SwPaM aPam(aMark, aPoint);
1054 OUString aText = aPam.GetText();
1055 static sal_Unicode const aForbidden[] = {
1057 0
1058 };
1059 pDescriptor->Text = comphelper::string::removeAny(aText, aForbidden);
1060
1061 // Calculate the bounding rectangle of this content control, which can be one or more layout
1062 // portions in one or more lines.
1063 SwRect aLocation;
1064 auto pTextFrame = const_cast<SwTextFrame*>(rInf.GetTextFrame());
1065 SwTextSizeInfo aInf(pTextFrame);
1066 SwTextCursor aLine(pTextFrame, &aInf);
1067 SwRect aStartRect;
1068 aLine.GetCharRect(&aStartRect, nViewStart);
1069 aLocation = aStartRect;
1070 SwRect aEndRect;
1071 aLine.GetCharRect(&aEndRect, nViewEnd);
1072 aLocation.Union(aEndRect);
1073 pDescriptor->Location = aLocation.SVRect();
1074
1075 pPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::Form);
1076 pPDFExtOutDevData->CreateControl(*pDescriptor);
1077 pPDFExtOutDevData->EndStructureElement();
1078
1079 return true;
1080}
1081
1082void SwContentControlPortion::Paint(const SwTextPaintInfo& rInf) const
1083{
1084 if (Width())
1085 {
1087
1088 if (DescribePDFControl(rInf))
1089 {
1090 return;
1091 }
1092
1094 }
1095}
1096
1097namespace sw::mark {
1098 OUString ExpandFieldmark(IFieldmark* pBM)
1099 {
1100 if (pBM->GetFieldname() == ODF_FORMCHECKBOX)
1101 {
1102 ::sw::mark::ICheckboxFieldmark const*const pCheckboxFm(
1103 dynamic_cast<ICheckboxFieldmark const*>(pBM));
1104 assert(pCheckboxFm);
1105 return pCheckboxFm->IsChecked()
1106 ? OUString(u"\u2612")
1107 : OUString(u"\u2610");
1108 }
1109 assert(pBM->GetFieldname() == ODF_FORMDROPDOWN);
1110 const IFieldmark::parameter_map_t* const pParameters = pBM->GetParameters();
1111 sal_Int32 nCurrentIdx = 0;
1112 const IFieldmark::parameter_map_t::const_iterator pResult = pParameters->find(ODF_FORMDROPDOWN_RESULT);
1113 if(pResult != pParameters->end())
1114 pResult->second >>= nCurrentIdx;
1115
1116 const IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find(OUString(ODF_FORMDROPDOWN_LISTENTRY));
1117 if (pListEntries != pParameters->end())
1118 {
1119 uno::Sequence< OUString > vListEntries;
1120 pListEntries->second >>= vListEntries;
1121 if (nCurrentIdx < vListEntries.getLength())
1122 return vListEntries[nCurrentIdx];
1123 }
1124
1125 static constexpr OUStringLiteral vEnSpaces = u"\u2002\u2002\u2002\u2002\u2002";
1126 return vEnSpaces;
1127 }
1128}
1129
1131{
1132 SwTextPortion *pPor = nullptr;
1133 if( GetFnt()->IsTox() )
1134 {
1135 pPor = new SwToxPortion;
1136 }
1137 else if ( GetFnt()->IsInputField() )
1138 {
1139 if (rInf.GetOpt().IsFieldName())
1140 {
1141 OUString aFieldName = SwFieldType::GetTypeStr(SwFieldTypesEnum::Input);
1142 // assume this is only the *first* portion and follows will be created elsewhere => input field must start at Idx
1143 assert(rInf.GetText()[sal_Int32(rInf.GetIdx())] == CH_TXT_ATR_INPUTFIELDSTART);
1144 TextFrameIndex nFieldLen(-1);
1145 for (TextFrameIndex i = rInf.GetIdx() + TextFrameIndex(1); ; ++i)
1146 {
1147 assert(rInf.GetText()[sal_Int32(i)] != CH_TXT_ATR_INPUTFIELDSTART); // can't nest
1148 if (rInf.GetText()[sal_Int32(i)] == CH_TXT_ATR_INPUTFIELDEND)
1149 {
1150 nFieldLen = i + TextFrameIndex(1) - rInf.GetIdx();
1151 break;
1152 }
1153 }
1154 assert(2 <= sal_Int32(nFieldLen));
1155 pPor = new SwFieldPortion(aFieldName, nullptr, false, nFieldLen);
1156 }
1157 else
1158 {
1159 pPor = new SwTextInputFieldPortion();
1160 }
1161 }
1162 else
1163 {
1164 if( GetFnt()->IsRef() )
1165 pPor = new SwRefPortion;
1166 else if (GetFnt()->IsMeta())
1167 {
1168 auto pMetaPor = new SwMetaPortion;
1169
1170 // set custom LO_EXT_SHADING color, if it exists
1171 SwTextFrame const*const pFrame(rInf.GetTextFrame());
1172 SwPosition aPosition(pFrame->MapViewToModelPos(rInf.GetIdx()));
1173 SwPaM aPam(aPosition);
1174 uno::Reference<text::XTextContent> const xRet(
1176 *aPam.GetPointNode().GetTextNode(), aPosition.GetContentIndex(), false) );
1177 if (xRet.is())
1178 {
1179 const SwDoc & rDoc = rInf.GetTextFrame()->GetDoc();
1180 static uno::Reference< uno::XComponentContext > xContext(
1181 ::comphelper::getProcessComponentContext());
1182
1183 static uno::Reference< rdf::XURI > xODF_SHADING(
1184 rdf::URI::createKnown(xContext, rdf::URIs::LO_EXT_SHADING), uno::UNO_SET_THROW);
1185
1186 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(
1187 rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
1188
1189 const css::uno::Reference<css::rdf::XResource> xSubject(xRet, uno::UNO_QUERY);
1190 const uno::Reference<rdf::XRepository>& xRepository =
1191 xDocumentMetadataAccess->getRDFRepository();
1192 const uno::Reference<container::XEnumeration> xEnum(
1193 xRepository->getStatements(xSubject, xODF_SHADING, nullptr), uno::UNO_SET_THROW);
1194
1195 while (xEnum->hasMoreElements())
1196 {
1197 rdf::Statement stmt;
1198 if (!(xEnum->nextElement() >>= stmt)) {
1199 throw uno::RuntimeException();
1200 }
1201 const uno::Reference<rdf::XLiteral> xObject(stmt.Object, uno::UNO_QUERY);
1202 if (!xObject.is()) continue;
1203 if (xEnum->hasMoreElements()) {
1204 SAL_INFO("sw.uno", "ignoring other odf:shading statements");
1205 }
1206 Color rColor = Color::STRtoRGB(xObject->getValue());
1207 pMetaPor->SetShadowColor(rColor);
1208 break;
1209 }
1210 }
1211 pPor = pMetaPor;
1212 }
1213 else if (GetFnt()->IsContentControl())
1214 {
1215 SwTextFrame const*const pFrame(rInf.GetTextFrame());
1216 SwPosition aPosition(pFrame->MapViewToModelPos(rInf.GetIdx()));
1217 SwTextNode* pTextNode = aPosition.GetNode().GetTextNode();
1218 SwTextContentControl* pTextContentControl = nullptr;
1219 if (pTextNode)
1220 {
1221 sal_Int32 nIndex = aPosition.GetContentIndex();
1223 {
1224 pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
1225 }
1226 }
1227 pPor = new SwContentControlPortion(pTextContentControl);
1228 }
1229 else
1230 {
1231 // Only at the End!
1232 // If pCurr does not have a width, it can however already have content.
1233 // E.g. for non-displayable characters
1234
1235 auto const ch(rInf.GetText()[sal_Int32(rInf.GetIdx())]);
1236 SwTextFrame const*const pFrame(rInf.GetTextFrame());
1237 SwPosition aPosition(pFrame->MapViewToModelPos(rInf.GetIdx()));
1238 sw::mark::IFieldmark *pBM = pFrame->GetDoc().getIDocumentMarkAccess()->getFieldmarkFor(aPosition);
1239 if(pBM != nullptr && pBM->GetFieldname( ) == ODF_FORMDATE)
1240 {
1242 pPor = new SwFieldFormDatePortion(pBM, true);
1243 else if (ch == CH_TXT_ATR_FIELDSEP)
1244 pPor = new SwFieldMarkPortion(); // it's added in DateFieldmark?
1245 else if (ch == CH_TXT_ATR_FIELDEND)
1246 pPor = new SwFieldFormDatePortion(pBM, false);
1247 }
1248 else if (ch == CH_TXT_ATR_FIELDSTART)
1249 pPor = new SwFieldMarkPortion();
1250 else if (ch == CH_TXT_ATR_FIELDSEP)
1251 pPor = new SwFieldMarkPortion();
1252 else if (ch == CH_TXT_ATR_FIELDEND)
1253 pPor = new SwFieldMarkPortion();
1254 else if (ch == CH_TXT_ATR_FORMELEMENT)
1255 {
1256 OSL_ENSURE(pBM != nullptr, "Where is my form field bookmark???");
1257 if (pBM != nullptr)
1258 {
1259 if (pBM->GetFieldname( ) == ODF_FORMCHECKBOX)
1260 {
1261 pPor = new SwFieldFormCheckboxPortion();
1262 }
1263 else if (pBM->GetFieldname( ) == ODF_FORMDROPDOWN)
1264 {
1266 }
1267 /* we need to check for ODF_FORMTEXT for scenario having FormFields inside FORMTEXT.
1268 * Otherwise file will crash on open.
1269 */
1270 else if (pBM->GetFieldname( ) == ODF_FORMTEXT)
1271 {
1272 pPor = new SwFieldMarkPortion();
1273 }
1274 }
1275 }
1276 if( !pPor )
1277 {
1278 if( !rInf.X() && !m_pCurr->GetNextPortion() && !m_pCurr->GetLen() )
1279 pPor = m_pCurr;
1280 else
1281 pPor = new SwTextPortion;
1282 }
1283 }
1284 }
1285 return pPor;
1286}
1287
1288// We calculate the length, the following portion limits are defined:
1289// 1) Tabs
1290// 2) Linebreaks
1291// 3) CH_TXTATR_BREAKWORD / CH_TXTATR_INWORD
1292// 4) next attribute change
1293
1295{
1296 // If we're at the line's beginning, we take pCurr
1297 // If pCurr is not derived from SwTextPortion, we need to duplicate
1298 Seek( rInf.GetIdx() );
1299 SwTextPortion *pPor = WhichTextPor( rInf );
1300
1301 // until next attribute change:
1302 const TextFrameIndex nNextAttr = GetNextAttr();
1303 TextFrameIndex nNextChg = std::min(nNextAttr, TextFrameIndex(rInf.GetText().getLength()));
1304
1305 // end of script type:
1306 const TextFrameIndex nNextScript = m_pScriptInfo->NextScriptChg(rInf.GetIdx());
1307 nNextChg = std::min( nNextChg, nNextScript );
1308
1309 // end of direction:
1310 const TextFrameIndex nNextDir = m_pScriptInfo->NextDirChg(rInf.GetIdx());
1311 nNextChg = std::min( nNextChg, nNextDir );
1312
1313 // hidden change (potentially via bookmark):
1314 const TextFrameIndex nNextHidden = m_pScriptInfo->NextHiddenChg(rInf.GetIdx());
1315 nNextChg = std::min( nNextChg, nNextHidden );
1316
1317 // bookmarks
1318 const TextFrameIndex nNextBookmark = m_pScriptInfo->NextBookmark(rInf.GetIdx());
1319 nNextChg = std::min(nNextChg, nNextBookmark);
1320
1321 // Turbo boost:
1322 // We assume that font characters are not larger than twice
1323 // as wide as height.
1324 // Very crazy: we need to take the ascent into account.
1325
1326 // Mind the trap! GetSize() contains the wished-for height, the real height
1327 // is only known in CalcAscent!
1328
1329 // The ratio is even crazier: a blank in Times New Roman has an ascent of
1330 // 182, a height of 200 and a width of 53!
1331 // It follows that a line with a lot of blanks is processed incorrectly.
1332 // Therefore we increase from factor 2 to 8 (due to negative kerning).
1333
1334 pPor->SetLen(TextFrameIndex(1));
1335 CalcAscent( rInf, pPor );
1336
1337 const SwFont* pTmpFnt = rInf.GetFont();
1338 sal_Int32 nExpect = std::min( sal_Int32( pTmpFnt->GetHeight() ),
1339 sal_Int32( pPor->GetAscent() ) ) / 8;
1340 if ( !nExpect )
1341 nExpect = 1;
1342 nExpect = sal_Int32(rInf.GetIdx()) + (rInf.GetLineWidth() / nExpect);
1343 if (TextFrameIndex(nExpect) > rInf.GetIdx() && nNextChg > TextFrameIndex(nExpect))
1344 nNextChg = TextFrameIndex(std::min(nExpect, rInf.GetText().getLength()));
1345
1346 // we keep an invariant during method calls:
1347 // there are no portion ending characters like hard spaces
1348 // or tabs in [ nLeftScanIdx, nRightScanIdx ]
1349 if ( m_nLeftScanIdx <= rInf.GetIdx() && rInf.GetIdx() <= m_nRightScanIdx )
1350 {
1351 if ( nNextChg > m_nRightScanIdx )
1352 nNextChg = m_nRightScanIdx =
1353 rInf.ScanPortionEnd( m_nRightScanIdx, nNextChg );
1354 }
1355 else
1356 {
1357 m_nLeftScanIdx = rInf.GetIdx();
1358 nNextChg = m_nRightScanIdx =
1359 rInf.ScanPortionEnd( rInf.GetIdx(), nNextChg );
1360 }
1361
1362 pPor->SetLen( nNextChg - rInf.GetIdx() );
1363 rInf.SetLen( pPor->GetLen() );
1364 return pPor;
1365}
1366
1367// first portions have no length
1369{
1370 SwLinePortion *pPor = nullptr;
1371
1372 if( rInf.GetRest() )
1373 {
1374 // Tabs and fields
1375 if( '\0' != rInf.GetHookChar() )
1376 return nullptr;
1377
1378 pPor = rInf.GetRest();
1379 if( pPor->IsErgoSumPortion() )
1380 rInf.SetErgoDone(true);
1381 else
1382 if( pPor->IsFootnoteNumPortion() )
1383 rInf.SetFootnoteDone(true);
1384 else
1385 if( pPor->InNumberGrp() )
1386 rInf.SetNumDone(true);
1387
1388 rInf.SetRest(nullptr);
1389 m_pCurr->SetRest( true );
1390 return pPor;
1391 }
1392
1393 // We can stand in the follow, it's crucial that
1394 // pFrame->GetOffset() == 0!
1395 if( rInf.GetIdx() )
1396 {
1397 // We now too can elongate FootnotePortions and ErgoSumPortions
1398
1399 // 1. The ErgoSumTexts
1400 if( !rInf.IsErgoDone() )
1401 {
1403 pPor = NewErgoSumPortion( rInf );
1404 rInf.SetErgoDone( true );
1405 }
1406
1407 // 2. Arrow portions
1408 if( !pPor && !rInf.IsArrowDone() )
1409 {
1410 if( m_pFrame->GetOffset() && !m_pFrame->IsFollow() &&
1411 rInf.GetIdx() == m_pFrame->GetOffset() )
1412 pPor = new SwArrowPortion( *m_pCurr );
1413 rInf.SetArrowDone( true );
1414 }
1415
1416 // 3. Kerning portions at beginning of line in grid mode
1417 if ( ! pPor && ! m_pCurr->GetNextPortion() )
1418 {
1419 SwTextGridItem const*const pGrid(
1420 GetGridItem(GetTextFrame()->FindPageFrame()));
1421 if ( pGrid )
1422 pPor = new SwKernPortion( *m_pCurr );
1423 }
1424
1425 // 4. The line rests (multiline fields)
1426 if( !pPor )
1427 {
1428 pPor = rInf.GetRest();
1429 // Only for pPor of course
1430 if( pPor )
1431 {
1432 m_pCurr->SetRest( true );
1433 rInf.SetRest(nullptr);
1434 }
1435 }
1436 }
1437 else
1438 {
1439 // 5. The foot note count
1440 if( !rInf.IsFootnoteDone() )
1441 {
1442 OSL_ENSURE( ( ! rInf.IsMulti() && ! m_pMulti ) || m_pMulti->HasRotation(),
1443 "Rotated number portion trouble" );
1444
1445 const bool bFootnoteNum = m_pFrame->IsFootnoteNumFrame();
1446 rInf.GetParaPortion()->SetFootnoteNum( bFootnoteNum );
1447 if( bFootnoteNum )
1448 pPor = NewFootnoteNumPortion( rInf );
1449 rInf.SetFootnoteDone( true );
1450 }
1451
1452 // 6. The ErgoSumTexts of course also exist in the TextMaster,
1453 // it's crucial whether the SwFootnoteFrame is aFollow
1454 if( !rInf.IsErgoDone() && !pPor && ! rInf.IsMulti() )
1455 {
1457 pPor = NewErgoSumPortion( rInf );
1458 rInf.SetErgoDone( true );
1459 }
1460
1461 // 7. The numbering
1462 if( !rInf.IsNumDone() && !pPor )
1463 {
1464 OSL_ENSURE( ( ! rInf.IsMulti() && ! m_pMulti ) || m_pMulti->HasRotation(),
1465 "Rotated number portion trouble" );
1466
1467 // If we're in the follow, then of course not
1468 if (GetTextFrame()->GetTextNodeForParaProps()->GetNumRule())
1469 pPor = NewNumberPortion( rInf );
1470 rInf.SetNumDone( true );
1471 }
1472 // 8. The DropCaps
1473 if( !pPor && GetDropFormat() && ! rInf.IsMulti() )
1474 pPor = NewDropPortion( rInf );
1475
1476 // 9. Kerning portions at beginning of line in grid mode
1477 if ( !pPor && !m_pCurr->GetNextPortion() )
1478 {
1479 SwTextGridItem const*const pGrid(
1480 GetGridItem(GetTextFrame()->FindPageFrame()));
1481 if ( pGrid )
1482 pPor = new SwKernPortion( *m_pCurr );
1483 }
1484 }
1485
1486 // 10. Decimal tab portion at the beginning of each line in table cells
1487 if ( !pPor && !m_pCurr->GetNextPortion() &&
1488 GetTextFrame()->IsInTab() &&
1489 GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_COMPAT))
1490 {
1491 pPor = NewTabPortion( rInf, true );
1492 }
1493
1494 // 11. suffix of meta-field
1495 if (!pPor)
1496 {
1497 pPor = TryNewNoLengthPortion(rInf);
1498 }
1499
1500 // 12. bookmarks
1501 // check this *last* so that BuildMultiPortion() can find it!
1502 if (!pPor && rInf.CheckCurrentPosBookmark())
1503 {
1504 const auto& bookmark = m_pScriptInfo->GetBookmarks(rInf.GetIdx());
1505 if (!bookmark.empty())
1506 {
1507 // only for character width, maybe replaced with ] later
1508 sal_Unicode mark = '[';
1509
1510 pPor = new SwBookmarkPortion(mark, bookmark);
1511 }
1512 }
1513
1514 return pPor;
1515}
1516
1517static bool lcl_OldFieldRest( const SwLineLayout* pCurr )
1518{
1519 if( !pCurr->GetNext() )
1520 return false;
1521 const SwLinePortion *pPor = pCurr->GetNext()->GetNextPortion();
1522 bool bRet = false;
1523 while( pPor && !bRet )
1524 {
1525 bRet = (pPor->InFieldGrp() && static_cast<const SwFieldPortion*>(pPor)->IsFollow()) ||
1526 (pPor->IsMultiPortion() && static_cast<const SwMultiPortion*>(pPor)->IsFollowField());
1527 if( !pPor->GetLen() )
1528 break;
1529 pPor = pPor->GetNextPortion();
1530 }
1531 return bRet;
1532}
1533
1534/* NewPortion sets rInf.nLen
1535 * A SwTextPortion is limited by a tab, break, txtatr or attr change
1536 * We can have three cases:
1537 * 1) The line is full and the wrap was not emulated
1538 * -> return 0;
1539 * 2) The line is full and a wrap was emulated
1540 * -> Reset width and return new FlyPortion
1541 * 3) We need to construct a new portion
1542 * -> CalcFlyWidth emulates the width and return portion, if needed
1543 */
1544
1546 ::std::optional<TextFrameIndex> const oMovedFlyIndex)
1547{
1548 if (oMovedFlyIndex && *oMovedFlyIndex <= rInf.GetIdx())
1549 {
1550 SAL_WARN_IF(*oMovedFlyIndex != rInf.GetIdx(), "sw.core", "stopping too late, no portion break at fly anchor?");
1551 rInf.SetStop(true);
1552 return nullptr;
1553 }
1554
1555 // Underflow takes precedence
1556 rInf.SetStopUnderflow( false );
1557 if( rInf.GetUnderflow() )
1558 {
1559 OSL_ENSURE( rInf.IsFull(), "SwTextFormatter::NewPortion: underflow but not full" );
1560 return Underflow( rInf );
1561 }
1562
1563 // If the line is full, flys and Underflow portions could be waiting ...
1564 if( rInf.IsFull() )
1565 {
1566 // LineBreaks and Flys (bug05.sdw)
1567 // IsDummy()
1568 if( rInf.IsNewLine() && (!rInf.GetFly() || !m_pCurr->IsDummy()) )
1569 return nullptr;
1570
1571 // When the text bumps into the Fly, or when the Fly comes first because
1572 // it juts out over the left edge, GetFly() is returned.
1573 // When IsFull() and no GetFly() is available, naturally zero is returned.
1574 if( rInf.GetFly() )
1575 {
1576 if( rInf.GetLast()->IsBreakPortion() )
1577 {
1578 delete rInf.GetFly();
1579 rInf.SetFly( nullptr );
1580 }
1581
1582 return rInf.GetFly();
1583 }
1584
1585 // A nasty special case: A frame without wrap overlaps the Footnote area.
1586 // We must declare the Footnote portion as rest of line, so that
1587 // SwTextFrame::Format doesn't abort (the text mass already was formatted).
1588 if( rInf.GetRest() )
1589 rInf.SetNewLine( true );
1590 else
1591 {
1592 // When the next line begins with a rest of a field, but now no
1593 // rest remains, the line must definitely be formatted anew!
1594 if( lcl_OldFieldRest( GetCurr() ) )
1595 rInf.SetNewLine( true );
1596 else
1597 {
1598 SwLinePortion *pFirst = WhichFirstPortion( rInf );
1599 if( pFirst )
1600 {
1601 rInf.SetNewLine( true );
1602 if( pFirst->InNumberGrp() )
1603 rInf.SetNumDone( false) ;
1604 delete pFirst;
1605 }
1606 }
1607 }
1608
1609 return nullptr;
1610 }
1611
1612 SwLinePortion *pPor = WhichFirstPortion( rInf );
1613
1614 // Check for Hidden Portion:
1615 if ( !pPor )
1616 {
1617 TextFrameIndex nEnd = rInf.GetIdx();
1618 if ( ::lcl_BuildHiddenPortion( rInf, nEnd ) )
1619 pPor = new SwHiddenTextPortion( nEnd - rInf.GetIdx() );
1620 }
1621
1622 if( !pPor )
1623 {
1624 if( ( !m_pMulti || m_pMulti->IsBidi() ) &&
1625 // i#42734
1626 // No multi portion if there is a hook character waiting:
1627 ( !rInf.GetRest() || '\0' == rInf.GetHookChar() ) )
1628 {
1629 // We open a multiportion part, if we enter a multi-line part
1630 // of the paragraph.
1631 TextFrameIndex nEnd = rInf.GetIdx();
1632 std::optional<SwMultiCreator> pCreate = rInf.GetMultiCreator( nEnd, m_pMulti );
1633 if( pCreate )
1634 {
1635 SwMultiPortion* pTmp = nullptr;
1636
1637 if ( SwMultiCreatorId::Bidi == pCreate->nId )
1638 pTmp = new SwBidiPortion( nEnd, pCreate->nLevel );
1639 else if ( SwMultiCreatorId::Ruby == pCreate->nId )
1640 {
1641 pTmp = new SwRubyPortion( *pCreate, *rInf.GetFont(),
1642 GetTextFrame()->GetDoc().getIDocumentSettingAccess(),
1643 nEnd, TextFrameIndex(0), rInf );
1644 }
1645 else if( SwMultiCreatorId::Rotate == pCreate->nId )
1646 {
1647 pTmp = new SwRotatedPortion( *pCreate, nEnd,
1648 GetTextFrame()->IsRightToLeft() );
1650 }
1651 else
1652 pTmp = new SwDoubleLinePortion( *pCreate, nEnd );
1653
1654 pCreate.reset();
1655 CalcFlyWidth( rInf );
1656
1657 return pTmp;
1658 }
1659 }
1660 // Tabs and Fields
1661 sal_Unicode cChar = rInf.GetHookChar();
1662
1663 if( cChar )
1664 {
1665 /* We fetch cChar again to be sure that the tab is pending now and
1666 * didn't move to the next line (as happens behind frames).
1667 * However, when a FieldPortion is in the rest, we must naturally fetch
1668 * the cChar from the field content, e.g. DecimalTabs and fields (22615)
1669 */
1670 if( !rInf.GetRest() || !rInf.GetRest()->InFieldGrp() )
1671 cChar = rInf.GetChar( rInf.GetIdx() );
1672 rInf.ClearHookChar();
1673 }
1674 else
1675 {
1676 if (rInf.GetIdx() >= TextFrameIndex(rInf.GetText().getLength()))
1677 {
1678 rInf.SetFull(true);
1679 CalcFlyWidth( rInf );
1680 return pPor;
1681 }
1682 cChar = rInf.GetChar( rInf.GetIdx() );
1683 }
1684
1685 switch( cChar )
1686 {
1687 case CH_TAB:
1688 pPor = NewTabPortion( rInf, false ); break;
1689
1690 case CH_BREAK:
1691 {
1692 SwTextAttr* pHint = GetAttr(rInf.GetIdx());
1693 pPor = new SwBreakPortion(*rInf.GetLast(), pHint);
1694 break;
1695 }
1696
1697 case CHAR_SOFTHYPHEN: // soft hyphen
1698 pPor = new SwSoftHyphPortion; break;
1699
1700 case CHAR_HARDBLANK: // no-break space
1701 // Please check tdf#115067 if you want to edit the char
1702 pPor = new SwBlankPortion( cChar ); break;
1703
1704 case CHAR_HARDHYPHEN: // non-breaking hyphen
1705 pPor = new SwBlankPortion( '-' ); break;
1706
1707 case CHAR_ZWSP: // zero width space
1708 case CHAR_WJ : // word joiner
1709 pPor = new SwControlCharPortion( cChar ); break;
1710
1712 case CH_TXTATR_INWORD:
1713 if( rInf.HasHint( rInf.GetIdx() ) )
1714 {
1715 pPor = NewExtraPortion( rInf );
1716 break;
1717 }
1718 [[fallthrough]];
1719 default :
1720 {
1721 SwTabPortion* pLastTabPortion = rInf.GetLastTab();
1722 if ( pLastTabPortion && cChar == rInf.GetTabDecimal() )
1723 {
1724 // Abandon dec. tab position if line is full
1725 // We have a decimal tab portion in the line and the next character has to be
1726 // aligned at the tab stop position. We store the width from the beginning of
1727 // the tab stop portion up to the portion containing the decimal separator:
1728 if (GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_COMPAT) /*rInf.GetVsh()->IsTabCompat();*/ &&
1729 PortionType::TabDecimal == pLastTabPortion->GetWhichPor() )
1730 {
1731 OSL_ENSURE( rInf.X() >= pLastTabPortion->GetFix(), "Decimal tab stop position cannot be calculated" );
1732 const sal_uInt16 nWidthOfPortionsUpToDecimalPosition = o3tl::narrowing<sal_uInt16>(rInf.X() - pLastTabPortion->GetFix() );
1733 static_cast<SwTabDecimalPortion*>(pLastTabPortion)->SetWidthOfPortionsUpToDecimalPosition( nWidthOfPortionsUpToDecimalPosition );
1734 rInf.SetTabDecimal( 0 );
1735 }
1736 else
1737 rInf.SetFull( rInf.GetLastTab()->Format( rInf ) );
1738 }
1739
1740 if( rInf.GetRest() )
1741 {
1742 if( rInf.IsFull() )
1743 {
1744 rInf.SetNewLine(true);
1745 return nullptr;
1746 }
1747 pPor = rInf.GetRest();
1748 rInf.SetRest(nullptr);
1749 }
1750 else
1751 {
1752 if( rInf.IsFull() )
1753 return nullptr;
1754 pPor = NewTextPortion( rInf );
1755 }
1756 break;
1757 }
1758 }
1759
1760 // if a portion is created despite there being a pending RestPortion,
1761 // then it is a field which has been split (e.g. because it contains a Tab)
1762 if( pPor && rInf.GetRest() )
1763 pPor->SetLen(TextFrameIndex(0));
1764
1765 // robust:
1766 if( !pPor || rInf.IsStop() )
1767 {
1768 delete pPor;
1769 return nullptr;
1770 }
1771 }
1772
1773 assert(pPor && "can only reach here with pPor existing");
1774
1775 // Special portions containing numbers (footnote anchor, footnote number,
1776 // numbering) can be contained in a rotated portion, if the user
1777 // choose a rotated character attribute.
1778 if (!m_pMulti)
1779 {
1780 if ( pPor->IsFootnotePortion() )
1781 {
1782 const SwTextFootnote* pTextFootnote = static_cast<SwFootnotePortion*>(pPor)->GetTextFootnote();
1783
1784 if ( pTextFootnote )
1785 {
1786 SwFormatFootnote& rFootnote = const_cast<SwFormatFootnote&>(pTextFootnote->GetFootnote());
1787 const SwDoc *const pDoc = &rInf.GetTextFrame()->GetDoc();
1788 const SwEndNoteInfo* pInfo;
1789 if( rFootnote.IsEndNote() )
1790 pInfo = &pDoc->GetEndNoteInfo();
1791 else
1792 pInfo = &pDoc->GetFootnoteInfo();
1793 const SwAttrSet& rSet = pInfo->GetAnchorCharFormat(const_cast<SwDoc&>(*pDoc))->GetAttrSet();
1794
1795 Degree10 nDir(0);
1797 nDir = pItem->GetValue();
1798
1799 if ( nDir )
1800 {
1801 delete pPor;
1802 pPor = new SwRotatedPortion(rInf.GetIdx() + TextFrameIndex(1),
1803 900_deg10 == nDir
1805 : DIR_TOP2BOTTOM );
1806 }
1807 }
1808 }
1809 else if ( pPor->InNumberGrp() )
1810 {
1811 const SwFont* pNumFnt = static_cast<SwFieldPortion*>(pPor)->GetFont();
1812
1813 if ( pNumFnt )
1814 {
1815 Degree10 nDir = pNumFnt->GetOrientation( rInf.GetTextFrame()->IsVertical() );
1816 if ( nDir )
1817 {
1818 delete pPor;
1819 pPor = new SwRotatedPortion(TextFrameIndex(0), 900_deg10 == nDir
1821 : DIR_TOP2BOTTOM );
1822
1823 rInf.SetNumDone( false );
1824 rInf.SetFootnoteDone( false );
1825 }
1826 }
1827 }
1828 }
1829
1830 // The font is set in output device,
1831 // the ascent and the height will be calculated.
1832 if( !pPor->GetAscent() && !pPor->Height() )
1833 CalcAscent( rInf, pPor );
1834 rInf.SetLen( pPor->GetLen() );
1835
1836 // In CalcFlyWidth Width() will be shortened if a FlyPortion is present.
1837 CalcFlyWidth( rInf );
1838
1839 // One must not forget that pCurr as GetLast() must provide reasonable values:
1840 if( !m_pCurr->Height() )
1841 {
1842 OSL_ENSURE( m_pCurr->Height(), "SwTextFormatter::NewPortion: limbo dance" );
1843 m_pCurr->Height( pPor->Height(), false );
1844 m_pCurr->SetAscent( pPor->GetAscent() );
1845 }
1846
1847 OSL_ENSURE(pPor->Height(), "SwTextFormatter::NewPortion: something went wrong");
1848 if( pPor->IsPostItsPortion() && rInf.X() >= rInf.Width() && rInf.GetFly() )
1849 {
1850 delete pPor;
1851 pPor = rInf.GetFly();
1852 }
1853 return pPor;
1854}
1855
1857{
1858 OSL_ENSURE( ! m_pFrame->IsVertical() || m_pFrame->IsSwapped(),
1859 "SwTextFormatter::FormatLine( nStartPos ) with unswapped frame" );
1860
1861 // For the formatting routines, we set pOut to the reference device.
1862 SwHookOut aHook( GetInfo() );
1863 if (GetInfo().GetLen() < TextFrameIndex(GetInfo().GetText().getLength()))
1864 GetInfo().SetLen(TextFrameIndex(GetInfo().GetText().getLength()));
1865
1866 bool bBuild = true;
1867 SetFlyInCntBase( false );
1868 GetInfo().SetLineHeight( 0 );
1870
1871 // Recycling must be suppressed by changed line height and also
1872 // by changed ascent (lowering of baseline).
1873 const SwTwips nOldHeight = m_pCurr->Height();
1874 const SwTwips nOldAscent = m_pCurr->GetAscent();
1875
1876 m_pCurr->SetEndHyph( false );
1877 m_pCurr->SetMidHyph( false );
1878
1879 // fly positioning can make it necessary format a line several times
1880 // for this, we have to keep a copy of our rest portion
1881 SwLinePortion* pField = GetInfo().GetRest();
1882 std::unique_ptr<SwFieldPortion> xSaveField;
1883
1884 if ( pField && pField->InFieldGrp() && !pField->IsFootnotePortion() )
1885 xSaveField.reset(new SwFieldPortion( *static_cast<SwFieldPortion*>(pField) ));
1886
1887 // for an optimal repaint rectangle, we want to compare fly portions
1888 // before and after the BuildPortions call
1889 const bool bOptimizeRepaint = AllowRepaintOpt();
1890 TextFrameIndex const nOldLineEnd = nStartPos + m_pCurr->GetLen();
1891 std::vector<tools::Long> flyStarts;
1892
1893 // these are the conditions for a fly position comparison
1894 if ( bOptimizeRepaint && m_pCurr->IsFly() )
1895 {
1897 tools::Long nPOfst = 0;
1898 while ( pPor )
1899 {
1900 if ( pPor->IsFlyPortion() )
1901 // insert start value of fly portion
1902 flyStarts.push_back( nPOfst );
1903
1904 nPOfst += pPor->Width();
1905 pPor = pPor->GetNextPortion();
1906 }
1907 }
1908
1909 // Here soon the underflow check follows.
1910 while( bBuild )
1911 {
1912 GetInfo().SetFootnoteInside( false );
1914
1915 // These values must not be reset by FormatReset();
1916 const bool bOldNumDone = GetInfo().IsNumDone();
1917 const bool bOldArrowDone = GetInfo().IsArrowDone();
1918 const bool bOldErgoDone = GetInfo().IsErgoDone();
1919
1920 // besides other things, this sets the repaint offset to 0
1921 FormatReset( GetInfo() );
1922
1923 GetInfo().SetNumDone( bOldNumDone );
1924 GetInfo().SetArrowDone( bOldArrowDone );
1925 GetInfo().SetErgoDone( bOldErgoDone );
1926
1927 // build new portions for this line
1929
1930 if( GetInfo().IsStop() )
1931 {
1933 m_pCurr->Height( GetFrameRstHeight() + 1, false );
1935 m_pCurr->Width(0);
1936 m_pCurr->Truncate();
1937 return nStartPos;
1938 }
1939 else if( GetInfo().IsDropInit() )
1940 {
1941 DropInit();
1942 GetInfo().SetDropInit( false );
1943 }
1944
1945 m_pCurr->CalcLine( *this, GetInfo() );
1947
1948 //i#120864 For Special case that at the first calculation couldn't get
1949 //correct height. And need to recalculate for the right height.
1950 SwLinePortion* pPorTmp = m_pCurr->GetNextPortion();
1951 if ( IsFlyInCntBase() && (!IsQuick() || (pPorTmp && pPorTmp->IsFlyCntPortion() && !pPorTmp->GetNextPortion() &&
1952 m_pCurr->Height() > pPorTmp->Height())))
1953 {
1954 SwTwips nTmpAscent, nTmpHeight;
1955 CalcAscentAndHeight( nTmpAscent, nTmpHeight );
1956 AlignFlyInCntBase( Y() + tools::Long( nTmpAscent ) );
1957 m_pCurr->CalcLine( *this, GetInfo() );
1959 }
1960
1961 // bBuild decides if another lap of honor is done
1963 {
1965 bBuild = false;
1966 }
1967 else
1968 {
1969 bBuild = ( GetInfo().GetTextFly().IsOn() && ChkFlyUnderflow(GetInfo()) )
1971 if( bBuild )
1972 {
1973 GetInfo().SetNumDone( bOldNumDone );
1975
1976 // delete old rest
1977 if ( GetInfo().GetRest() )
1978 {
1979 delete GetInfo().GetRest();
1980 GetInfo().SetRest( nullptr );
1981 }
1982
1983 // set original rest portion
1984 if ( xSaveField )
1985 GetInfo().SetRest( new SwFieldPortion( *xSaveField ) );
1986
1988 m_pCurr->Width(0);
1989 m_pCurr->Truncate();
1990 }
1991 }
1992 }
1993
1994 // In case of compat mode, it's possible that a tab portion is wider after
1995 // formatting than before. If this is the case, we also have to make sure
1996 // the SwLineLayout is wider as well.
1997 if (GetInfo().GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_OVER_MARGIN))
1998 {
1999 sal_uInt16 nSum = 0;
2001
2002 while (pPor)
2003 {
2004 nSum += pPor->Width();
2005 pPor = pPor->GetNextPortion();
2006 }
2007
2008 if (nSum > m_pCurr->Width())
2009 m_pCurr->Width(nSum);
2010 }
2011
2012 // calculate optimal repaint rectangle
2013 if ( bOptimizeRepaint )
2014 {
2015 GetInfo().SetPaintOfst( ::lcl_CalcOptRepaint( *this, *m_pCurr, nOldLineEnd, flyStarts ) );
2016 flyStarts.clear();
2017 }
2018 else
2019 // Special case: we do not allow an optimization of the repaint
2020 // area, but during formatting the repaint offset is set to indicate
2021 // a maximum value for the offset. This value has to be reset:
2022 GetInfo().SetPaintOfst( 0 );
2023
2024 // This corrects the start of the reformat range if something has
2025 // moved to the next line. Otherwise IsFirstReformat in AllowRepaintOpt
2026 // will give us a wrong result if we have to reformat another line
2027 GetInfo().GetParaPortion()->GetReformat().LeftMove( GetInfo().GetIdx() );
2028
2029 // delete master copy of rest portion
2030 xSaveField.reset();
2031
2032 TextFrameIndex const nNewStart = nStartPos + m_pCurr->GetLen();
2033
2034 // adjust text if kana compression is enabled
2035 if ( GetInfo().CompressLine() )
2036 {
2037 SwTwips nRepaintOfst = CalcKanaAdj( m_pCurr );
2038
2039 // adjust repaint offset
2040 if ( nRepaintOfst < GetInfo().GetPaintOfst() )
2041 GetInfo().SetPaintOfst( nRepaintOfst );
2042 }
2043
2045
2046 if( nOldHeight != m_pCurr->Height() || nOldAscent != m_pCurr->GetAscent() )
2047 {
2049 GetInfo().SetPaintOfst( 0 ); // changed line height => no recycling
2050 // all following line must be painted and when Flys are around,
2051 // also formatted
2052 GetInfo().SetShift( true );
2053 }
2054
2055 if ( IsFlyInCntBase() && !IsQuick() )
2057
2058 return nNewStart;
2059}
2060
2062{
2063 do
2064 {
2066 } while (Next());
2067}
2068
2070{
2071 SwTwips nLineHeight = m_pCurr->Height();
2072 m_pCurr->SetClipping( false );
2073
2074 SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame()));
2075 if ( pGrid && GetInfo().SnapToGrid() )
2076 {
2077 const sal_uInt16 nGridWidth = pGrid->GetBaseHeight();
2078 const sal_uInt16 nRubyHeight = pGrid->GetRubyHeight();
2079 const bool bRubyTop = ! pGrid->GetRubyTextBelow();
2080
2081 nLineHeight = nGridWidth + nRubyHeight;
2082 const sal_uInt16 nAmpRatio = (m_pCurr->Height() + nLineHeight - 1)/nLineHeight;
2083 nLineHeight *= nAmpRatio;
2084
2085 const sal_uInt16 nAsc = m_pCurr->GetAscent() +
2086 ( bRubyTop ?
2087 ( nLineHeight - m_pCurr->Height() + nRubyHeight ) / 2 :
2088 ( nLineHeight - m_pCurr->Height() - nRubyHeight ) / 2 );
2089
2090 m_pCurr->Height( nLineHeight, false );
2091 m_pCurr->SetAscent( nAsc );
2093
2094 // we ignore any line spacing options except from ...
2096 if ( ! IsParaLine() && pSpace &&
2097 SvxInterLineSpaceRule::Prop == pSpace->GetInterLineSpaceRule() )
2098 {
2099 sal_uLong nTmp = pSpace->GetPropLineSpace();
2100
2101 if( nTmp < 100 )
2102 nTmp = 100;
2103
2104 nTmp *= nLineHeight;
2105 nLineHeight = nTmp / 100;
2106 }
2107
2108 m_pCurr->SetRealHeight( nLineHeight );
2109 return;
2110 }
2111
2112 // The dummy flag is set on lines that only contain flyportions, these shouldn't
2113 // consider register-true and so on. Unfortunately an empty line can be at
2114 // the end of a paragraph (empty paragraphs or behind a Shift-Return),
2115 // which should consider the register.
2116 if (!m_pCurr->IsDummy() || (!m_pCurr->GetNext()
2117 && GetStart() >= TextFrameIndex(GetTextFrame()->GetText().getLength())
2118 && !bNewLine))
2119 {
2121 if( pSpace )
2122 {
2123 switch( pSpace->GetLineSpaceRule() )
2124 {
2125 case SvxLineSpaceRule::Auto:
2126 // shrink first line of paragraph too on spacing < 100%
2127 if (IsParaLine() &&
2128 pSpace->GetInterLineSpaceRule() == SvxInterLineSpaceRule::Prop
2130 {
2131 tools::Long nTmp = pSpace->GetPropLineSpace();
2132 // Word will render < 50% too but it's just not readable
2133 if( nTmp < 50 )
2134 nTmp = nTmp ? 50 : 100;
2135 if (nTmp<100) { // code adapted from fixed line height
2136 nTmp *= nLineHeight;
2137 nTmp /= 100;
2138 if( !nTmp )
2139 ++nTmp;
2140 nLineHeight = nTmp;
2141 sal_uInt16 nAsc = ( 4 * nLineHeight ) / 5; // 80%
2142#if 0
2143 // could do clipping here (like Word does)
2144 // but at 0.5 its unreadable either way...
2145 if( nAsc < pCurr->GetAscent() ||
2146 nLineHeight - nAsc < pCurr->Height() -
2147 pCurr->GetAscent() )
2148 pCurr->SetClipping( true );
2149#endif
2150 m_pCurr->SetAscent( nAsc );
2151 m_pCurr->Height( nLineHeight, false );
2153 }
2154 }
2155 break;
2156 case SvxLineSpaceRule::Min:
2157 {
2158 if( nLineHeight < pSpace->GetLineHeight() )
2159 nLineHeight = pSpace->GetLineHeight();
2160 break;
2161 }
2162 case SvxLineSpaceRule::Fix:
2163 {
2164 nLineHeight = pSpace->GetLineHeight();
2165 const sal_uInt16 nAsc = ( 4 * nLineHeight ) / 5; // 80%
2166 if( nAsc < m_pCurr->GetAscent() ||
2167 nLineHeight - nAsc < m_pCurr->Height() - m_pCurr->GetAscent() )
2168 m_pCurr->SetClipping( true );
2169 m_pCurr->Height( nLineHeight, false );
2170 m_pCurr->SetAscent( nAsc );
2172 }
2173 break;
2174 default: OSL_FAIL( ": unknown LineSpaceRule" );
2175 }
2176 // Note: for the _first_ line the line spacing of the previous
2177 // paragraph is applied in SwFlowFrame::CalcUpperSpace()
2178 if( !IsParaLine() )
2179 switch( pSpace->GetInterLineSpaceRule() )
2180 {
2181 case SvxInterLineSpaceRule::Off:
2182 break;
2183 case SvxInterLineSpaceRule::Prop:
2184 {
2185 tools::Long nTmp = pSpace->GetPropLineSpace();
2186 // 50% is the minimum, if 0% we switch to the
2187 // default value 100% ...
2188 if( nTmp < 50 )
2189 nTmp = nTmp ? 50 : 100;
2190
2191 // extend line height by (nPropLineSpace - 100) percent of the font height
2192 nTmp -= 100;
2193 nTmp *= m_pCurr->GetTextHeight();
2194 nTmp /= 100;
2195 nTmp += nLineHeight;
2196 if (nTmp < 1)
2197 nTmp = 1;
2198 nLineHeight = nTmp;
2199 break;
2200 }
2201 case SvxInterLineSpaceRule::Fix:
2202 {
2203 nLineHeight = nLineHeight + pSpace->GetInterLineSpace();
2204 break;
2205 }
2206 default: OSL_FAIL( ": unknown InterLineSpaceRule" );
2207 }
2208 }
2209
2210 if( IsRegisterOn() )
2211 {
2212 SwTwips nTmpY = Y() + m_pCurr->GetAscent() + nLineHeight - m_pCurr->Height();
2213 SwRectFnSet aRectFnSet(m_pFrame);
2214 if ( aRectFnSet.IsVert() )
2215 nTmpY = m_pFrame->SwitchHorizontalToVertical( nTmpY );
2216 nTmpY = aRectFnSet.YDiff( nTmpY, RegStart() );
2217 const sal_uInt16 nDiff = sal_uInt16( nTmpY % RegDiff() );
2218 if( nDiff )
2219 nLineHeight += RegDiff() - nDiff;
2220 }
2221 }
2222 m_pCurr->SetRealHeight( nLineHeight );
2223}
2224
2226{
2227 // delete Fly in any case!
2228 ClearFly( rInf );
2229 rInf.Init();
2230
2231 rInf.ChkNoHyph( CntEndHyph(), CntMidHyph() );
2232 rInf.SetRoot( m_pCurr );
2233 rInf.SetLineStart( m_nStart );
2234 rInf.SetIdx( m_nStart );
2235 rInf.Left( Left() );
2236 rInf.Right( Right() );
2237 rInf.First( FirstLeft() );
2238 rInf.LeftMargin(GetLeftMargin());
2239
2240 rInf.RealWidth( sal_uInt16(rInf.Right() - GetLeftMargin()) );
2241 rInf.Width( rInf.RealWidth() );
2242 if( const_cast<SwTextFormatter*>(this)->GetRedln() )
2243 {
2244 const_cast<SwTextFormatter*>(this)->GetRedln()->Clear( const_cast<SwTextFormatter*>(this)->GetFnt() );
2245 const_cast<SwTextFormatter*>(this)->GetRedln()->Reset();
2246 }
2247}
2248
2250{
2251 m_pFirstOfBorderMerge = nullptr;
2252 m_pCurr->Truncate();
2253 m_pCurr->Init();
2254
2255 // delete pSpaceAdd and pKanaComp
2259 FeedInf( rInf );
2260}
2261
2263{
2264 if( m_pDropFormat )
2265 {
2266 const sal_uInt16 nOldDrop = GetDropHeight();
2268 m_bOnceMore = nOldDrop != GetDropHeight();
2269 }
2270 else
2271 m_bOnceMore = false;
2272 return m_bOnceMore;
2273}
2274
2276{
2277 SwTwips nRet = Y() + GetLineHeight();
2279 if( nMin && ++nMin > nRet )
2280 {
2283 if( nRet + nDist < nMin )
2284 {
2285 const bool bRepaint = HasTruncLines() &&
2286 GetInfo().GetParaPortion()->GetRepaint().Bottom() == nRet-1;
2287 nRet = nMin - nDist;
2288 if( bRepaint )
2289 {
2290 const_cast<SwRepaint&>(GetInfo().GetParaPortion()
2291 ->GetRepaint()).Bottom( nRet-1 );
2292 const_cast<SwTextFormatInfo&>(GetInfo()).SetPaintOfst( 0 );
2293 }
2294 }
2295 }
2296 return nRet;
2297}
2298
2299// FME/OD: This routine does a limited text formatting.
2301{
2302 FormatReset( GetInfo() );
2304 m_pCurr->CalcLine( *this, GetInfo() );
2305 return m_pCurr->Width();
2306}
2307
2308// determines if the calculation of a repaint offset is allowed
2309// otherwise each line is painted from 0 (this is a copy of the beginning
2310// of the former SwTextFormatter::Recycle() function
2312{
2313 // reformat position in front of current line? Only in this case
2314 // we want to set the repaint offset
2315 bool bOptimizeRepaint = m_nStart < GetInfo().GetReformatStart() &&
2316 m_pCurr->GetLen();
2317
2318 // a special case is the last line of a block adjusted paragraph:
2319 if ( bOptimizeRepaint )
2320 {
2321 switch( GetAdjust() )
2322 {
2323 case SvxAdjust::Block:
2324 {
2325 if( IsLastBlock() || IsLastCenter() )
2326 bOptimizeRepaint = false;
2327 else
2328 {
2329 // ????: blank in the last master line (blocksat.sdw)
2330 bOptimizeRepaint = nullptr == m_pCurr->GetNext() && !m_pFrame->GetFollow();
2331 if ( bOptimizeRepaint )
2332 {
2334 while ( pPos && !pPos->IsFlyPortion() )
2335 pPos = pPos->GetNextPortion();
2336 bOptimizeRepaint = !pPos;
2337 }
2338 }
2339 break;
2340 }
2341 case SvxAdjust::Center:
2342 case SvxAdjust::Right:
2343 bOptimizeRepaint = false;
2344 break;
2345 default: ;
2346 }
2347 }
2348
2349 // Again another special case: invisible SoftHyphs
2350 const TextFrameIndex nReformat = GetInfo().GetReformatStart();
2351 if (bOptimizeRepaint && TextFrameIndex(COMPLETE_STRING) != nReformat)
2352 {
2353 const sal_Unicode cCh = nReformat >= TextFrameIndex(GetInfo().GetText().getLength())
2354 ? 0
2355 : GetInfo().GetText()[ sal_Int32(nReformat) ];
2356 bOptimizeRepaint = ( CH_TXTATR_BREAKWORD != cCh && CH_TXTATR_INWORD != cCh )
2357 || ! GetInfo().HasHint( nReformat );
2358 }
2359
2360 return bOptimizeRepaint;
2361}
2362
2364{
2365 OSL_ENSURE( ! m_pFrame->IsVertical() || m_pFrame->IsSwapped(),
2366 "SwTextFormatter::CalcUnclipped with unswapped frame" );
2367
2368 SwTwips nFlyAsc, nFlyDesc;
2369 m_pCurr->MaxAscentDescent( rTop, rBottom, nFlyAsc, nFlyDesc );
2370 rTop = Y() + GetCurr()->GetAscent();
2371 rBottom = rTop + nFlyDesc;
2372 rTop -= nFlyAsc;
2373}
2374
2375void SwTextFormatter::UpdatePos( SwLineLayout *pCurrent, Point aStart,
2376 TextFrameIndex const nStartIdx, bool bAlways) const
2377{
2378 OSL_ENSURE( ! m_pFrame->IsVertical() || m_pFrame->IsSwapped(),
2379 "SwTextFormatter::UpdatePos with unswapped frame" );
2380
2381 if( GetInfo().IsTest() )
2382 return;
2383 SwLinePortion *pFirst = pCurrent->GetFirstPortion();
2384 SwLinePortion *pPos = pFirst;
2385 SwTextPaintInfo aTmpInf( GetInfo() );
2386 aTmpInf.SetpSpaceAdd( pCurrent->GetpLLSpaceAdd() );
2387 aTmpInf.ResetSpaceIdx();
2388 aTmpInf.SetKanaComp( pCurrent->GetpKanaComp() );
2389 aTmpInf.ResetKanaIdx();
2390
2391 // The frame's size
2392 aTmpInf.SetIdx( nStartIdx );
2393 aTmpInf.SetPos( aStart );
2394
2395 SwTwips nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
2396 pCurrent->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
2397
2398 const SwTwips nTmpHeight = pCurrent->GetRealHeight();
2399 SwTwips nAscent = pCurrent->GetAscent() + nTmpHeight - pCurrent->Height();
2401 if( GetMulti() )
2402 {
2403 aTmpInf.SetDirection( GetMulti()->GetDirection() );
2404 if( GetMulti()->HasRotation() )
2405 {
2406 nFlags |= AsCharFlags::Rotate;
2407 if( GetMulti()->IsRevers() )
2408 {
2409 nFlags |= AsCharFlags::Reverse;
2410 aTmpInf.X( aTmpInf.X() - nAscent );
2411 }
2412 else
2413 aTmpInf.X( aTmpInf.X() + nAscent );
2414 }
2415 else
2416 {
2417 if ( GetMulti()->IsBidi() )
2418 nFlags |= AsCharFlags::Bidi;
2419 aTmpInf.Y( aTmpInf.Y() + nAscent );
2420 }
2421 }
2422 else
2423 aTmpInf.Y( aTmpInf.Y() + nAscent );
2424
2425 while( pPos )
2426 {
2427 // We only know one case where changing the position (caused by the
2428 // adjustment) could be relevant for a portion: We need to SetRefPoint
2429 // for FlyCntPortions.
2430 if( ( pPos->IsFlyCntPortion() || pPos->IsGrfNumPortion() )
2431 && ( bAlways || !IsQuick() ) )
2432 {
2433 pCurrent->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, pPos );
2434
2435 if( pPos->IsGrfNumPortion() )
2436 {
2437 if( !nFlyAsc && !nFlyDesc )
2438 {
2439 nTmpAscent = nAscent;
2440 nFlyAsc = nAscent;
2441 nTmpDescent = nTmpHeight - nAscent;
2442 nFlyDesc = nTmpDescent;
2443 }
2444 static_cast<SwGrfNumPortion*>(pPos)->SetBase( nTmpAscent, nTmpDescent,
2445 nFlyAsc, nFlyDesc );
2446 }
2447 else
2448 {
2449 Point aBase( aTmpInf.GetPos() );
2450 if ( GetInfo().GetTextFrame()->IsVertical() )
2452
2453 static_cast<SwFlyCntPortion*>(pPos)->SetBase( *aTmpInf.GetTextFrame(),
2454 aBase, nTmpAscent, nTmpDescent, nFlyAsc,
2455 nFlyDesc, nFlags );
2456 }
2457 }
2458 if( pPos->IsMultiPortion() && static_cast<SwMultiPortion*>(pPos)->HasFlyInContent() )
2459 {
2460 OSL_ENSURE( !GetMulti(), "Too much multi" );
2461 const_cast<SwTextFormatter*>(this)->m_pMulti = static_cast<SwMultiPortion*>(pPos);
2462 SwLineLayout *pLay = &GetMulti()->GetRoot();
2463 Point aSt( aTmpInf.X(), aStart.Y() );
2464
2465 if ( GetMulti()->HasBrackets() )
2466 {
2467 OSL_ENSURE( GetMulti()->IsDouble(), "Brackets only for doubles");
2468 aSt.AdjustX(static_cast<SwDoubleLinePortion*>(GetMulti())->PreWidth() );
2469 }
2470 else if( GetMulti()->HasRotation() )
2471 {
2472 aSt.AdjustY(pCurrent->GetAscent() - GetMulti()->GetAscent() );
2473 if( GetMulti()->IsRevers() )
2474 aSt.AdjustX(GetMulti()->Width() );
2475 else
2476 aSt.AdjustY(GetMulti()->Height() );
2477 }
2478 else if ( GetMulti()->IsBidi() )
2479 // jump to end of the bidi portion
2480 aSt.AdjustX(pLay->Width() );
2481
2482 TextFrameIndex nStIdx = aTmpInf.GetIdx();
2483 do
2484 {
2485 UpdatePos( pLay, aSt, nStIdx, bAlways );
2486 nStIdx = nStIdx + pLay->GetLen();
2487 aSt.AdjustY(pLay->Height() );
2488 pLay = pLay->GetNext();
2489 } while ( pLay );
2490 const_cast<SwTextFormatter*>(this)->m_pMulti = nullptr;
2491 }
2492 pPos->Move( aTmpInf );
2493 pPos = pPos->GetNextPortion();
2494 }
2495}
2496
2498{
2499 OSL_ENSURE( ! m_pFrame->IsVertical() || m_pFrame->IsSwapped(),
2500 "SwTextFormatter::AlignFlyInCntBase with unswapped frame" );
2501
2502 if( GetInfo().IsTest() )
2503 return;
2505 SwLinePortion *pPos = pFirst;
2507 if( GetMulti() && GetMulti()->HasRotation() )
2508 {
2509 nFlags |= AsCharFlags::Rotate;
2510 if( GetMulti()->IsRevers() )
2511 nFlags |= AsCharFlags::Reverse;
2512 }
2513
2514 SwTwips nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
2515
2516 while( pPos )
2517 {
2518 if( pPos->IsFlyCntPortion() || pPos->IsGrfNumPortion() )
2519 {
2520 m_pCurr->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, pPos );
2521
2522 if( pPos->IsGrfNumPortion() )
2523 static_cast<SwGrfNumPortion*>(pPos)->SetBase( nTmpAscent, nTmpDescent,
2524 nFlyAsc, nFlyDesc );
2525 else
2526 {
2527 Point aBase;
2528 if ( GetInfo().GetTextFrame()->IsVertical() )
2529 {
2530 nBaseLine = GetInfo().GetTextFrame()->SwitchHorizontalToVertical( nBaseLine );
2531 aBase = Point( nBaseLine, static_cast<SwFlyCntPortion*>(pPos)->GetRefPoint().Y() );
2532 }
2533 else
2534 aBase = Point( static_cast<SwFlyCntPortion*>(pPos)->GetRefPoint().X(), nBaseLine );
2535
2536 static_cast<SwFlyCntPortion*>(pPos)->SetBase( *GetInfo().GetTextFrame(), aBase, nTmpAscent, nTmpDescent,
2537 nFlyAsc, nFlyDesc, nFlags );
2538 }
2539 }
2540 pPos = pPos->GetNextPortion();
2541 }
2542}
2543
2545{
2546 OSL_ENSURE( rInf.GetTextFly().IsOn(), "SwTextFormatter::ChkFlyUnderflow: why?" );
2547 if( GetCurr() )
2548 {
2549 // First we check, whether a fly overlaps with the line.
2550 // = GetLineHeight()
2551 const sal_uInt16 nHeight = GetCurr()->GetRealHeight();
2552 SwRect aLine( GetLeftMargin(), Y(), rInf.RealWidth(), nHeight );
2553
2554 SwRect aLineVert( aLine );
2555 if ( m_pFrame->IsVertical() )
2557 SwRect aInter( rInf.GetTextFly().GetFrame( aLineVert ) );
2558 if ( m_pFrame->IsVertical() )
2560
2561 if( !aInter.HasArea() )
2562 return false;
2563
2564 // We now check every portion that could have lowered for overlapping
2565 // with the fly.
2566 const SwLinePortion *pPos = GetCurr()->GetFirstPortion();
2567 aLine.Pos().setY( Y() + GetCurr()->GetRealHeight() - GetCurr()->Height() );
2568 aLine.Height( GetCurr()->Height() );
2569
2570 while( pPos )
2571 {
2572 aLine.Width( pPos->Width() );
2573
2574 aLineVert = aLine;
2575 if ( m_pFrame->IsVertical() )
2577 aInter = rInf.GetTextFly().GetFrame( aLineVert );
2578 if ( m_pFrame->IsVertical() )
2580
2581 // New flys from below?
2582 if( !pPos->IsFlyPortion() )
2583 {
2584 if( aInter.Overlaps( aLine ) )
2585 {
2586 aInter.Intersection_( aLine );
2587 if( aInter.HasArea() )
2588 {
2589 // To be evaluated during reformat of this line:
2590 // RealHeight including spacing
2591 rInf.SetLineHeight( nHeight );
2592 // Height without extra spacing
2593 rInf.SetLineNetHeight( m_pCurr->Height() );
2594 return true;
2595 }
2596 }
2597 }
2598 else
2599 {
2600 // The fly portion is not intersected by a fly anymore
2601 if ( ! aInter.Overlaps( aLine ) )
2602 {
2603 rInf.SetLineHeight( nHeight );
2604 rInf.SetLineNetHeight( m_pCurr->Height() );
2605 return true;
2606 }
2607 else
2608 {
2609 aInter.Intersection_( aLine );
2610
2611 // No area means a fly has become invalid because of
2612 // lowering the line => reformat the line
2613 // we also have to reformat the line, if the fly size
2614 // differs from the intersection interval's size.
2615 if( ! aInter.HasArea() ||
2616 static_cast<const SwFlyPortion*>(pPos)->GetFixWidth() != aInter.Width() )
2617 {
2618 rInf.SetLineHeight( nHeight );
2619 rInf.SetLineNetHeight( m_pCurr->Height() );
2620 return true;
2621 }
2622 }
2623 }
2624
2625 aLine.Left( aLine.Left() + pPos->Width() );
2626 pPos = pPos->GetNextPortion();
2627 }
2628 }
2629 return false;
2630}
2631
2633{
2634 if( GetMulti() || rInf.GetFly() )
2635 return;
2636
2637 SwTextFly& rTextFly = rInf.GetTextFly();
2638 if( !rTextFly.IsOn() || rInf.IsIgnoreFly() )
2639 return;
2640
2641 const SwLinePortion *pLast = rInf.GetLast();
2642
2643 tools::Long nAscent;
2644 tools::Long nTop = Y();
2645 tools::Long nHeight;
2646
2647 if( rInf.GetLineHeight() )
2648 {
2649 // Real line height has already been calculated, we only have to
2650 // search for intersections in the lower part of the strip
2651 nAscent = m_pCurr->GetAscent();
2652 nHeight = rInf.GetLineNetHeight();
2653 nTop += rInf.GetLineHeight() - nHeight;
2654 }
2655 else
2656 {
2657 // We make a first guess for the lines real height
2658 if ( ! m_pCurr->GetRealHeight() )
2660
2661 nAscent = pLast->GetAscent();
2662 nHeight = pLast->Height();
2663
2664 if ( m_pCurr->GetRealHeight() > nHeight )
2665 nTop += m_pCurr->GetRealHeight() - nHeight;
2666 else
2667 // Important for fixed space between lines
2668 nHeight = m_pCurr->GetRealHeight();
2669 }
2670
2671 const tools::Long nLeftMar = GetLeftMargin();
2672 const tools::Long nLeftMin = (rInf.X() || GetDropLeft()) ? nLeftMar : GetLeftMin();
2673
2674 SwRect aLine( rInf.X() + nLeftMin, nTop, rInf.RealWidth() - rInf.X()
2675 + nLeftMar - nLeftMin , nHeight );
2676
2677 // tdf#116486: consider also the upper margin from getFramePrintArea because intersections
2678 // with this additional space should lead to repositioning of paragraphs
2679 // For compatibility we grab a related compat flag:
2680 if (GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS)
2681 && IsFirstTextLine())
2682 {
2683 const tools::Long nUpper = m_pFrame->getFramePrintArea().Top();
2684 // Increase the rectangle
2685 if( nUpper > 0 && nTop >= nUpper )
2686 aLine.SubTop( nUpper );
2687 }
2688 SwRect aLineVert( aLine );
2689 if ( m_pFrame->IsRightToLeft() )
2690 m_pFrame->SwitchLTRtoRTL( aLineVert );
2691
2692 if ( m_pFrame->IsVertical() )
2694
2695 // GetFrame(...) determines and returns the intersection rectangle
2696 SwRect aInter( rTextFly.GetFrame( aLineVert ) );
2697
2698 if ( m_pFrame->IsRightToLeft() )
2699 m_pFrame->SwitchRTLtoLTR( aInter );
2700
2701 if ( m_pFrame->IsVertical() )
2703
2704 if (!aInter.IsEmpty() && aInter.Bottom() < nTop)
2705 {
2706 // Intersects with the frame area (with upper margin), but not with the print area (without
2707 // upper margin). Don't reserve space for the fly portion in this case, text is allowed to
2708 // flow there.
2709 aInter.Height(0);
2710 }
2711
2712 if( !aInter.Overlaps( aLine ) )
2713 return;
2714
2715 aLine.Left( rInf.X() + nLeftMar );
2716 bool bForced = false;
2717 if( aInter.Left() <= nLeftMin )
2718 {
2719 SwTwips nFrameLeft = GetTextFrame()->getFrameArea().Left();
2720 if( GetTextFrame()->getFramePrintArea().Left() < 0 )
2721 nFrameLeft += GetTextFrame()->getFramePrintArea().Left();
2722 if( aInter.Left() < nFrameLeft )
2723 aInter.Left( nFrameLeft );
2724
2725 tools::Long nAddMar = 0;
2726 if ( m_pFrame->IsRightToLeft() )
2727 {
2728 nAddMar = m_pFrame->getFrameArea().Right() - Right();
2729 if ( nAddMar < 0 )
2730 nAddMar = 0;
2731 }
2732 else
2733 nAddMar = nLeftMar - nFrameLeft;
2734
2735 aInter.Width( aInter.Width() + nAddMar );
2736 // For a negative first line indent, we set this flag to show
2737 // that the indentation/margin has been moved.
2738 // This needs to be respected by the DefaultTab at the zero position.
2739 if( IsFirstTextLine() && HasNegFirst() )
2740 bForced = true;
2741 }
2742 aInter.Intersection( aLine );
2743 if( !aInter.HasArea() )
2744 return;
2745
2746 const bool bFullLine = aLine.Left() == aInter.Left() &&
2747 aLine.Right() == aInter.Right();
2748
2749 // Although no text is left, we need to format another line,
2750 // because also empty lines need to avoid a Fly with no wrapping.
2751 if (bFullLine && rInf.GetIdx() == TextFrameIndex(rInf.GetText().getLength()))
2752 {
2753 rInf.SetNewLine( true );
2754 // We know that for dummies, it holds ascent == height
2755 m_pCurr->SetDummy(true);
2756 }
2757
2758 // aInter becomes frame-local
2759 aInter.Pos().AdjustX( -nLeftMar );
2760 SwFlyPortion *pFly = new SwFlyPortion( aInter );
2761 if( bForced )
2762 {
2764 rInf.ForcedLeftMargin( o3tl::narrowing<sal_uInt16>(aInter.Width()) );
2765 }
2766
2767 if( bFullLine )
2768 {
2769 // In order to properly flow around Flys with different
2770 // wrapping attributes, we need to increase by units of line height.
2771 // The last avoiding line should be adjusted in height, so that
2772 // we don't get a frame spacing effect.
2773 // It is important that ascent == height, because the FlyPortion
2774 // values are transferred to pCurr in CalcLine and IsDummy() relies
2775 // on this behaviour.
2776 // To my knowledge we only have two places where DummyLines can be
2777 // created: here and in MakeFlyDummies.
2778 // IsDummy() is evaluated in IsFirstTextLine(), when moving lines
2779 // and in relation with DropCaps.
2780 pFly->Height( aInter.Height() );
2781
2782 // nNextTop now contains the margin's bottom edge, which we avoid
2783 // or the next margin's top edge, which we need to respect.
2784 // That means we can comfortably grow up to this value; that's how
2785 // we save a few empty lines.
2786 tools::Long nNextTop = rTextFly.GetNextTop();
2787 if ( m_pFrame->IsVertical() )
2788 nNextTop = m_pFrame->SwitchVerticalToHorizontal( nNextTop );
2789 if( nNextTop > aInter.Bottom() )
2790 {
2791 SwTwips nH = nNextTop - aInter.Top();
2792 if( nH < SAL_MAX_UINT16 )
2793 pFly->Height( nH );
2794 }
2795 if( nAscent < pFly->Height() )
2796 pFly->SetAscent( nAscent );
2797 else
2798 pFly->SetAscent( pFly->Height() );
2799 }
2800 else
2801 {
2802 if (rInf.GetIdx() == TextFrameIndex(rInf.GetText().getLength()))
2803 {
2804 // Don't use nHeight, or we have a huge descent
2805 pFly->Height( pLast->Height() );
2806 pFly->SetAscent( pLast->GetAscent() );
2807 }
2808 else
2809 {
2810 pFly->Height( aInter.Height() );
2811 if( nAscent < pFly->Height() )
2812 pFly->SetAscent( nAscent );
2813 else
2814 pFly->SetAscent( pFly->Height() );
2815 }
2816 }
2817
2818 rInf.SetFly( pFly );
2819
2820 if( pFly->GetFix() < rInf.Width() )
2821 rInf.Width( pFly->GetFix() );
2822
2823 SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame()));
2824 if ( !pGrid )
2825 return;
2826
2827 const SwPageFrame* pPageFrame = m_pFrame->FindPageFrame();
2828 const SwLayoutFrame* pBody = pPageFrame->FindBodyCont();
2829
2830 SwRectFnSet aRectFnSet(pPageFrame);
2831
2832 const tools::Long nGridOrigin = pBody ?
2833 aRectFnSet.GetPrtLeft(*pBody) :
2834 aRectFnSet.GetPrtLeft(*pPageFrame);
2835
2836 const SwDoc & rDoc = rInf.GetTextFrame()->GetDoc();
2837 const sal_uInt16 nGridWidth = GetGridWidth(*pGrid, rDoc);
2838
2839 SwTwips nStartX = GetLeftMargin();
2840 if ( aRectFnSet.IsVert() )
2841 {
2842 Point aPoint( nStartX, 0 );
2844 nStartX = aPoint.Y();
2845 }
2846
2847 const SwTwips nOfst = nStartX - nGridOrigin;
2848 const SwTwips nTmpWidth = rInf.Width() + nOfst;
2849
2850 const SwTwips i = nTmpWidth / nGridWidth + 1;
2851
2852 const SwTwips nNewWidth = ( i - 1 ) * nGridWidth - nOfst;
2853 if ( nNewWidth > 0 )
2854 rInf.Width( nNewWidth );
2855 else
2856 rInf.Width( 0 );
2857
2858
2859}
2860
2862 SwTextAttr *pHint ) const
2863{
2864 const SwFrame *pFrame = m_pFrame;
2865
2866 SwFlyInContentFrame *pFly;
2867 SwFrameFormat* pFrameFormat = static_cast<SwTextFlyCnt*>(pHint)->GetFlyCnt().GetFrameFormat();
2868 if( RES_FLYFRMFMT == pFrameFormat->Which() )
2869 {
2870 // set Lock pFrame to avoid m_pCurr getting deleted
2872 pFly = static_cast<SwTextFlyCnt*>(pHint)->GetFlyFrame(pFrame);
2873 }
2874 else
2875 pFly = nullptr;
2876 // aBase is the document-global position, from which the new extra portion is placed
2877 // aBase.X() = Offset in the line after the current position
2878 // aBase.Y() = LineIter.Y() + Ascent of the current position
2879
2880 SwTwips nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
2881 // i#11859 - use new method <SwLineLayout::MaxAscentDescent(..)>
2882 // to change line spacing behaviour at paragraph - Compatibility to MS Word
2883 //SwLinePortion *pPos = pCurr->GetFirstPortion();
2884 //lcl_MaxAscDescent( pPos, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
2885 m_pCurr->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
2886
2887 // If the ascent of the frame is larger than the ascent of the current position,
2888 // we use this one when calculating the base, or the frame would be positioned
2889 // too much to the top, sliding down after all causing a repaint in an area
2890 // he actually never was in.
2891 SwTwips nAscent = 0;
2892
2893 const bool bTextFrameVertical = GetInfo().GetTextFrame()->IsVertical();
2894
2895 const bool bUseFlyAscent = pFly && pFly->isFrameAreaPositionValid() &&
2896 0 != ( bTextFrameVertical ?
2897 pFly->GetRefPoint().X() :
2898 pFly->GetRefPoint().Y() );
2899
2900 if ( bUseFlyAscent )
2901 nAscent = std::abs( int( bTextFrameVertical ?
2902 pFly->GetRelPos().X() :
2903 pFly->GetRelPos().Y() ) );
2904
2905 // Check if be prefer to use the ascent of the last portion:
2906 if ( IsQuick() ||
2907 !bUseFlyAscent ||
2908 nAscent < rInf.GetLast()->GetAscent() )
2909 {
2910 nAscent = rInf.GetLast()->GetAscent();
2911 }
2912 else if( nAscent > nFlyAsc )
2913 nFlyAsc = nAscent;
2914
2915 Point aBase( GetLeftMargin() + rInf.X(), Y() + nAscent );
2917 if( GetMulti() && GetMulti()->HasRotation() )
2918 {
2919 nMode |= AsCharFlags::Rotate;
2920 if( GetMulti()->IsRevers() )
2921 nMode |= AsCharFlags::Reverse;
2922 }
2923
2924 Point aTmpBase( aBase );
2925 if ( GetInfo().GetTextFrame()->IsVertical() )
2927
2928 SwFlyCntPortion* pRet(nullptr);
2929 if( pFly )
2930 {
2931 pRet = sw::FlyContentPortion::Create(*GetInfo().GetTextFrame(), pFly, aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode);
2932 // We need to make sure that our font is set again in the OutputDevice
2933 // It could be that the FlyInCnt was added anew and GetFlyFrame() would
2934 // in turn cause, that it'd be created anew again.
2935 // This one's frames get formatted right away, which change the font.
2936 rInf.SelectFont();
2937 if( pRet->GetAscent() > nAscent )
2938 {
2939 aBase.setY( Y() + pRet->GetAscent() );
2940 nMode |= AsCharFlags::UlSpace;
2941 if( !rInf.IsTest() )
2942 {
2943 aTmpBase = aBase;
2944 if ( GetInfo().GetTextFrame()->IsVertical() )
2946
2947 pRet->SetBase( *rInf.GetTextFrame(), aTmpBase, nTmpAscent,
2948 nTmpDescent, nFlyAsc, nFlyDesc, nMode );
2949 }
2950 }
2951 }
2952 else
2953 {
2954 pRet = sw::DrawFlyCntPortion::Create(*rInf.GetTextFrame(), *pFrameFormat, aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode);
2955 }
2956 return pRet;
2957}
2958
2959/* Drop portion is a special case, because it has parts which aren't portions
2960 but we have handle them just like portions */
2962{
2963 if( rPortion.GetLines() <= 1 )
2964 return;
2965
2966 SwDropPortionPart* pCurrPart = rPortion.GetPart();
2967 while( pCurrPart )
2968 {
2969 if( pCurrPart->GetFollow() &&
2970 ::lcl_HasSameBorder(pCurrPart->GetFont(), pCurrPart->GetFollow()->GetFont()) )
2971 {
2972 pCurrPart->SetJoinBorderWithNext(true);
2973 pCurrPart->GetFollow()->SetJoinBorderWithPrev(true);
2974 }
2975 pCurrPart = pCurrPart->GetFollow();
2976 }
2977}
2978
2980{
2981 const SwFont aCurFont = *rInf.GetFont();
2982 if( !aCurFont.HasBorder() )
2983 return;
2984
2985 if (pPrev && pPrev->GetJoinBorderWithNext() )
2986 {
2987 // In some case border merge is called twice to the portion
2988 if( !rPortion.GetJoinBorderWithPrev() )
2989 {
2990 rPortion.SetJoinBorderWithPrev(true);
2991 if( rPortion.InTextGrp() && rPortion.Width() > aCurFont.GetLeftBorderSpace() )
2992 rPortion.Width(rPortion.Width() - aCurFont.GetLeftBorderSpace());
2993 }
2994 }
2995 else
2996 {
2997 rPortion.SetJoinBorderWithPrev(false);
2998 m_pFirstOfBorderMerge = &rPortion;
2999 }
3000
3001 // Get next portion's font
3002 bool bSeek = false;
3003 if (!rInf.IsFull() && // Not the last portion of the line (in case of line break)
3004 rInf.GetIdx() + rPortion.GetLen() != TextFrameIndex(rInf.GetText().getLength())) // Not the last portion of the paragraph
3005 {
3006 bSeek = Seek(rInf.GetIdx() + rPortion.GetLen());
3007 }
3008 // Don't join the next portion if SwKernPortion sits between two different boxes.
3009 bool bDisconnect = rPortion.IsKernPortion() && !rPortion.GetJoinBorderWithPrev();
3010 // If next portion has the same border then merge
3011 if( bSeek && GetFnt()->HasBorder() && ::lcl_HasSameBorder(aCurFont, *GetFnt()) && !bDisconnect )
3012 {
3013 // In some case border merge is called twice to the portion
3014 if( !rPortion.GetJoinBorderWithNext() )
3015 {
3016 rPortion.SetJoinBorderWithNext(true);
3017 if( rPortion.InTextGrp() && rPortion.Width() > aCurFont.GetRightBorderSpace() )
3018 rPortion.Width(rPortion.Width() - aCurFont.GetRightBorderSpace());
3019 }
3020 }
3021 // If this is the last portion of the merge group then make the real height merge
3022 else
3023 {
3024 rPortion.SetJoinBorderWithNext(false);
3025 if( m_pFirstOfBorderMerge != &rPortion )
3026 {
3027 // Calculate maximum height and ascent
3029 sal_uInt16 nMaxAscent = 0;
3030 sal_uInt16 nMaxHeight = 0;
3031 bool bReachCurrent = false;
3032 while( pActPor )
3033 {
3034 if( nMaxHeight < pActPor->Height() )
3035 nMaxHeight = pActPor->Height();
3036 if( nMaxAscent < pActPor->GetAscent() )
3037 nMaxAscent = pActPor->GetAscent();
3038
3039 pActPor = pActPor->GetNextPortion();
3040 if( !pActPor && !bReachCurrent )
3041 {
3042 pActPor = &rPortion;
3043 bReachCurrent = true;
3044 }
3045 }
3046
3047 // Change all portion's height and ascent
3048 pActPor = m_pFirstOfBorderMerge;
3049 bReachCurrent = false;
3050 while( pActPor )
3051 {
3052 if( nMaxHeight > pActPor->Height() )
3053 pActPor->Height(nMaxHeight);
3054 if( nMaxAscent > pActPor->GetAscent() )
3055 pActPor->SetAscent(nMaxAscent);
3056
3057 pActPor = pActPor->GetNextPortion();
3058 if( !pActPor && !bReachCurrent )
3059 {
3060 pActPor = &rPortion;
3061 bReachCurrent = true;
3062 }
3063 }
3064 m_pFirstOfBorderMerge = nullptr;
3065 }
3066 }
3067 Seek(rInf.GetIdx());
3068}
3069
3070namespace {
3071 // calculates and sets optimal repaint offset for the current line
3072 tools::Long lcl_CalcOptRepaint( SwTextFormatter &rThis,
3073 SwLineLayout const &rCurr,
3074 TextFrameIndex const nOldLineEnd,
3075 const std::vector<tools::Long> &rFlyStarts )
3076 {
3077 SwTextFormatInfo& txtFormatInfo = rThis.GetInfo();
3078 if ( txtFormatInfo.GetIdx() < txtFormatInfo.GetReformatStart() )
3079 // the reformat position is behind our new line, that means
3080 // something of our text has moved to the next line
3081 return 0;
3082
3083 TextFrameIndex nReformat = std::min(txtFormatInfo.GetReformatStart(), nOldLineEnd);
3084
3085 // in case we do not have any fly in our line, our repaint position
3086 // is the changed position - 1
3087 if ( rFlyStarts.empty() && ! rCurr.IsFly() )
3088 {
3089 // this is the maximum repaint offset determined during formatting
3090 // for example: the beginning of the first right tab stop
3091 // if this value is 0, this means that we do not have an upper
3092 // limit for the repaint offset
3093 const tools::Long nFormatRepaint = txtFormatInfo.GetPaintOfst();
3094
3095 if (nReformat < txtFormatInfo.GetLineStart() + TextFrameIndex(3))
3096 return 0;
3097
3098 // step back two positions for smoother repaint
3099 nReformat -= TextFrameIndex(2);
3100
3101 // i#28795, i#34607, i#38388
3102 // step back more characters, this is required by complex scripts
3103 // e.g., for Khmer (thank you, Javier!)
3104 static const TextFrameIndex nMaxContext(10);
3105 if (nReformat > txtFormatInfo.GetLineStart() + nMaxContext)
3106 nReformat = nReformat - nMaxContext;
3107 else
3108 {
3109 nReformat = txtFormatInfo.GetLineStart();
3110 //reset the margin flag - prevent loops
3112 }
3113
3114 // Weird situation: Our line used to end with a hole portion
3115 // and we delete some characters at the end of our line. We have
3116 // to take care for repainting the blanks which are not anymore
3117 // covered by the hole portion
3118 while ( nReformat > txtFormatInfo.GetLineStart() &&
3119 CH_BLANK == txtFormatInfo.GetChar( nReformat ) )
3120 --nReformat;
3121
3122 OSL_ENSURE( nReformat < txtFormatInfo.GetIdx(), "Reformat too small for me!" );
3123 SwRect aRect;
3124
3125 // Note: GetChareRect is not const. It definitely changes the
3126 // bMulti flag. We have to save and restore the old value.
3127 bool bOldMulti = txtFormatInfo.IsMulti();
3128 rThis.GetCharRect( &aRect, nReformat );
3129 txtFormatInfo.SetMulti( bOldMulti );
3130
3131 return nFormatRepaint ? std::min( aRect.Left(), nFormatRepaint ) :
3132 aRect.Left();
3133 }
3134 else
3135 {
3136 // nReformat may be wrong, if something around flys has changed:
3137 // we compare the former and the new fly positions in this line
3138 // if anything has changed, we carefully have to adjust the right
3139 // repaint position
3140 tools::Long nPOfst = 0;
3141 size_t nCnt = 0;
3142 tools::Long nX = 0;
3143 TextFrameIndex nIdx = rThis.GetInfo().GetLineStart();
3144 SwLinePortion* pPor = rCurr.GetFirstPortion();
3145
3146 while ( pPor )
3147 {
3148 if ( pPor->IsFlyPortion() )
3149 {
3150 // compare start of fly with former start of fly
3151 if (nCnt < rFlyStarts.size() &&
3152 nX == rFlyStarts[ nCnt ] &&
3153 nIdx < nReformat
3154 )
3155 // found fix position, nothing has changed left from nX
3156 nPOfst = nX + pPor->Width();
3157 else
3158 break;
3159
3160 nCnt++;
3161 }
3162 nX = nX + pPor->Width();
3163 nIdx = nIdx + pPor->GetLen();
3164 pPor = pPor->GetNextPortion();
3165 }
3166
3167 return nPOfst + rThis.GetLeftMargin();
3168 }
3169 }
3170
3171 // Determine if we need to build hidden portions
3172 bool lcl_BuildHiddenPortion(const SwTextSizeInfo& rInf, TextFrameIndex & rPos)
3173 {
3174 // Only if hidden text should not be shown:
3175 // if ( rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar() )
3176 const bool bShowInDocView = rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar();
3177 const bool bShowForPrinting = rInf.GetOpt().IsShowHiddenChar( true ) && rInf.GetOpt().IsPrinting();
3178 if (bShowInDocView || bShowForPrinting)
3179 return false;
3180
3181 const SwScriptInfo& rSI = rInf.GetParaPortion()->GetScriptInfo();
3182 TextFrameIndex nHiddenStart;
3183 TextFrameIndex nHiddenEnd;
3184 rSI.GetBoundsOfHiddenRange( rPos, nHiddenStart, nHiddenEnd );
3185 if ( nHiddenEnd )
3186 {
3187 rPos = nHiddenEnd;
3188 return true;
3189 }
3190
3191 return false;
3192 }
3193
3194 bool lcl_HasSameBorder(const SwFont& rFirst, const SwFont& rSecond)
3195 {
3196 return
3197 rFirst.GetTopBorder() == rSecond.GetTopBorder() &&
3198 rFirst.GetBottomBorder() == rSecond.GetBottomBorder() &&
3199 rFirst.GetLeftBorder() == rSecond.GetLeftBorder() &&
3200 rFirst.GetRightBorder() == rSecond.GetRightBorder() &&
3201 rFirst.GetTopBorderDist() == rSecond.GetTopBorderDist() &&
3202 rFirst.GetBottomBorderDist() == rSecond.GetBottomBorderDist() &&
3203 rFirst.GetLeftBorderDist() == rSecond.GetLeftBorderDist() &&
3204 rFirst.GetRightBorderDist() == rSecond.GetRightBorderDist() &&
3205 rFirst.GetOrientation() == rSecond.GetOrientation() &&
3206 rFirst.GetShadowColor() == rSecond.GetShadowColor() &&
3207 rFirst.GetShadowWidth() == rSecond.GetShadowWidth() &&
3208 rFirst.GetShadowLocation() == rSecond.GetShadowLocation();
3209 }
3210
3211} //end unnamed namespace
3212
3213/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY
@ PROP_LINE_SPACING_SHRINKS_FIRST_LINE
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...
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
static Color STRtoRGB(std::u16string_view colorname)
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &pos) const =0
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
vcl::ExtOutDevData * GetExtOutDevData() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
sal_uInt16 GetPropLineSpace() const
SvxInterLineSpaceRule GetInterLineSpaceRule() const
SvxLineSpaceRule GetLineSpaceRule() const
sal_uInt16 GetLineHeight() const
short GetInterLineSpace() const
wrapper class for the positioning of Writer fly frames and drawing objects
Indicator that the content does not fit into a fixed height frame (red triangle on the UI).
Definition: porrst.hxx:116
SwRedlineItr * GetRedln()
Definition: itratr.hxx:81
SwFont * GetFnt()
Definition: itratr.hxx:103
SwScriptInfo * m_pScriptInfo
Definition: itratr.hxx:40
TextFrameIndex GetNextAttr() const
Definition: itratr.cxx:730
bool Seek(TextFrameIndex nPos)
Enables the attributes used at char pos nPos in the logical font.
Definition: itratr.cxx:302
SwTextAttr * GetAttr(TextFrameIndex nPos) const
Returns the attribute for a position.
Definition: itratr.cxx:143
SwFont * m_pFont
Definition: itratr.hxx:39
Non-breaking space or non-breaking hyphen.
Definition: porexp.hxx:43
for showing bookmark starts and ends; note that in contrast to SwControlCharPortion these do not have...
Definition: porrst.hxx:186
void LeftMove(TextFrameIndex const nNew)
Definition: porlay.hxx:47
Definition: doc.hxx:195
const SwFootnoteInfo & GetFootnoteInfo() const
Definition: doc.hxx:639
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:184
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1872
const SwEndNoteInfo & GetEndNoteInfo() const
Definition: doc.hxx:641
SwDocShell * GetDocShell()
Definition: doc.hxx:1362
SwFont & GetFont() const
Definition: pordrop.hxx:52
void SetJoinBorderWithPrev(const bool bJoinPrev)
Definition: pordrop.hxx:59
void SetJoinBorderWithNext(const bool bJoinNext)
Definition: pordrop.hxx:60
SwDropPortionPart * GetFollow() const
Definition: pordrop.hxx:50
Text portion for the Format -> Paragraph -> Drop Caps functionality.
Definition: pordrop.hxx:65
sal_uInt16 GetLines() const
Definition: pordrop.hxx:91
SwDropPortionPart * GetPart() const
Definition: pordrop.hxx:97
SwCharFormat * GetAnchorCharFormat(SwDoc &rDoc) const
Definition: docftn.cxx:182
bool IsNoLength() const
Definition: porfld.hxx:58
bool HasFont() const
Definition: porfld.hxx:69
bool IsHide() const
Definition: porfld.hxx:89
const SwFont * GetFont() const
Definition: porfld.hxx:71
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:122
sal_uInt16 GetFix() const
Definition: porglue.hxx:58
This portion represents an as-character anchored fly (shape, frame, etc.)
Definition: porfly.hxx:45
void SetBase(const SwTextFrame &rFrame, const Point &rBase, tools::Long nLnAscent, tools::Long nLnDescent, tools::Long nFlyAscent, tools::Long nFlyDescent, AsCharFlags nFlags)
After setting the RefPoints, the ascent needs to be recalculated because it is dependent on RelPos.
Definition: porfly.cxx:342
const Point & GetRefPoint() const
Definition: flyfrms.hxx:218
Point const & GetRelPos() const
Definition: flyincnt.cxx:200
sal_uInt16 GetBottomBorderSpace() const
Definition: swfont.hxx:877
sal_uInt16 GetTopBorderSpace() const
Definition: swfont.hxx:862
const std::optional< editeng::SvxBorderLine > & GetTopBorder() const
Definition: swfont.hxx:343
const std::optional< editeng::SvxBorderLine > & GetRightBorder() const
Definition: swfont.hxx:345
sal_uInt16 GetBottomBorderDist() const
Definition: swfont.hxx:364
FontLineStyle GetUnderline() const
Definition: swfont.hxx:272
Degree10 GetOrientation(const bool bVertLayout=false, const bool bVertFormatLRBT=false) const
Definition: swfont.cxx:412
sal_uInt16 GetRightBorderSpace() const
Definition: swfont.hxx:892
sal_uInt16 GetShadowWidth() const
Definition: swfont.hxx:382
const Color & GetShadowColor() const
Definition: swfont.hxx:381
const std::optional< editeng::SvxBorderLine > & GetBottomBorder() const
Definition: swfont.hxx:344
const SvxFont & GetActualFont() const
Definition: swfont.hxx:186
sal_uInt16 GetTopBorderDist() const
Definition: swfont.hxx:363
SwFontScript GetActual() const
Definition: swfont.hxx:184
sal_uInt16 GetRightBorderDist() const
Definition: swfont.hxx:365
const std::optional< editeng::SvxBorderLine > & GetLeftBorder() const
Definition: swfont.hxx:346
SvxShadowLocation GetShadowLocation() const
Definition: swfont.hxx:383
sal_uInt16 GetLeftBorderDist() const
Definition: swfont.hxx:366
bool HasBorder() const
Check whether font has any border on any side.
Definition: swfont.hxx:922
tools::Long GetHeight() const
Definition: swfont.hxx:284
sal_uInt16 GetLeftBorderSpace() const
Definition: swfont.hxx:907
SwLayoutFrame * FindBodyCont()
Searches the first ContentFrame in BodyText below the page.
Definition: findfrm.cxx:46
FlyAnchors.
Definition: fmtanchr.hxx:37
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:74
SfxPoolItem subclass that wraps an SwContentControl.
const std::shared_ptr< SwContentControl > & GetContentControl() const
sal_uInt8 GetLines() const
Definition: paratr.hxx:101
bool IsEndNote() const
Definition: fmtftn.hxx:73
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaPositionValid() const
Definition: frame.hxx:166
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
Style of a layout element.
Definition: frmfmt.hxx:62
Base class of the Writer layout elements.
Definition: frame.hxx:315
SwFrame * GetIndPrev() const
Definition: frame.hxx:724
bool IsInFootnote() const
Definition: frame.hxx:949
bool IsRightToLeft() const
Definition: frame.hxx:987
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
bool IsVertical() const
Definition: frame.hxx:973
SwPageFrame * FindPageFrame()
Definition: frame.hxx:680
sal_uInt16 GetFixWidth() const
Definition: porglue.hxx:37
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
const SvxLineSpacingItem * GetLineSpacing() const
Definition: inftxt.hxx:79
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:79
void Init(SwLinePortion *pNextPortion=nullptr)
Definition: porlay.cxx:2713
void SetFormatAdj(const bool bNew)
Definition: porlay.hxx:120
void SetMidHyph(const bool bNew)
Definition: porlay.hxx:124
bool IsRest() const
Definition: porlay.hxx:129
void SetForcedLeftMargin()
Definition: porlay.hxx:142
SwTwips GetTextHeight() const
Definition: porlay.hxx:171
void FinishSpaceAdd()
Definition: porlay.hxx:186
SwLineLayout * GetNext()
Definition: porlay.hxx:159
void SetClipping(const bool bNew)
Definition: porlay.hxx:153
void ResetFlags()
Definition: porlay.cxx:831
SwLinePortion * GetFirstPortion() const
Definition: porlay.cxx:849
void FinishKanaComp()
Definition: porlay.hxx:201
void CalcLine(SwTextFormatter &rLine, SwTextFormatInfo &rInf)
Definition: porlay.cxx:380
void SetFly(const bool bNew)
Definition: porlay.hxx:126
virtual void Height(const SwTwips nNew, const bool bText=true) override
Definition: porlay.cxx:239
bool IsFly() const
Definition: porlay.hxx:127
void MaxAscentDescent(SwTwips &_orAscent, SwTwips &_orDescent, SwTwips &_orObjAscent, SwTwips &_orObjDescent, const SwLinePortion *_pDontConsiderPortion=nullptr, const bool _bNoFlyCntPorAndLinePor=false) const
determine ascent and descent for positioning of as-character anchored object
Definition: porlay.cxx:771
bool IsDummy() const
Definition: porlay.hxx:151
void SetRealHeight(SwTwips nNew)
Definition: porlay.hxx:168
SwTwips GetRealHeight() const
Definition: porlay.hxx:169
void SetEndHyph(const bool bNew)
Definition: porlay.hxx:122
void SetNext(SwLineLayout *pNew)
Definition: porlay.hxx:161
void SetDummy(const bool bNew)
Definition: porlay.hxx:150
void SetRest(const bool bNew)
Definition: porlay.hxx:128
std::vector< tools::Long > * GetpLLSpaceAdd() const
Definition: porlay.hxx:197
std::deque< sal_uInt16 > * GetpKanaComp() const
Definition: porlay.hxx:202
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
bool IsTextPortion() const
Definition: porlin.hxx:139
virtual void FormatEOL(SwTextFormatInfo &rInf)
Definition: porlin.cxx:266
bool IsSoftHyphPortion() const
Definition: porlin.hxx:136
bool InTextGrp() const
Definition: porlin.hxx:105
void SetJoinBorderWithNext(const bool bJoinNext)
Definition: porlin.hxx:180
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
void SetNextPortion(SwLinePortion *pNew)
Definition: porlin.hxx:79
bool IsPostItsPortion() const
Definition: porlin.hxx:137
TextFrameIndex GetLen() const
Definition: porlin.hxx:77
void Move(SwTextPaintInfo &rInf)
Definition: porlin.cxx:269
SwLinePortion * FindLastPortion()
Definition: porlin.cxx:179
bool IsKernPortion() const
Definition: porlin.hxx:141
bool GetJoinBorderWithNext() const
Definition: porlin.hxx:178
void Truncate()
Definition: porlin.hxx:214
SwTwips GetHangingBaseline() const
Definition: porlin.hxx:89
bool IsFootnotePortion() const
Definition: porlin.hxx:129
SwTwips & GetAscent()
Definition: porlin.hxx:80
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
bool IsQuoVadisPortion() const
Definition: porlin.hxx:123
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:78
bool IsGrfNumPortion() const
Definition: porlin.hxx:118
bool IsMultiPortion() const
Definition: porlin.hxx:143
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
virtual bool Format(SwTextFormatInfo &rInf)
Definition: porlin.cxx:238
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:101
bool InExpGrp() const
Definition: porlin.hxx:114
bool IsFlyCntPortion() const
Definition: porlin.hxx:119
bool InFixMargGrp() const
Definition: porlin.hxx:115
virtual SwLinePortion * Insert(SwLinePortion *pPortion)
Definition: porlin.cxx:169
bool HasRotation() const
Definition: pormulti.hxx:146
bool IsBidi() const
Definition: pormulti.hxx:132
bool HasFlyInContent() const
Definition: pormulti.hxx:128
const SwLineLayout & GetRoot() const
Definition: pormulti.hxx:120
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:897
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
SwNode & GetPointNode() const
Definition: pam.hxx:283
A page of the document layout.
Definition: pagefrm.hxx:58
void SetFootnoteNum(const bool bNew)
Definition: porlay.hxx:318
SwCharRange & GetReformat()
Definition: porlay.hxx:287
void SetFixLineHeight()
Definition: porlay.hxx:315
SwRepaint & GetRepaint()
Definition: porlay.hxx:285
SwScriptInfo & GetScriptInfo()
Definition: porlay.hxx:291
SwTwips Width() const
Definition: possiz.hxx:51
SwTwips Height() const
Definition: possiz.hxx:49
bool IsVert() const
Definition: frame.hxx:1366
tools::Long YDiff(tools::Long n1, tools::Long n2) const
Definition: frame.hxx:1422
tools::Long GetPrtLeft(const SwFrame &rFrame) const
Definition: frame.hxx:1410
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwRect & Intersection(const SwRect &rRect)
Definition: swrect.cxx:57
void SubTop(const tools::Long nSub)
Definition: swrect.cxx:129
void Height(tools::Long nNew)
Definition: swrect.hxx:193
bool IsEmpty() const
Definition: swrect.hxx:304
bool HasArea() const
Definition: swrect.hxx:300
SwRect & Union(const SwRect &rRect)
Definition: swrect.cxx:35
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
SwRect & Intersection_(const SwRect &rRect)
Definition: swrect.cxx:81
void Pos(const Point &rNew)
Definition: swrect.hxx:171
bool Overlaps(const SwRect &rRect) const
Definition: swrect.hxx:374
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
void Reset()
Definition: redlnitr.hxx:112
void Clear(SwFont *pFnt)
Definition: redlnitr.hxx:109
sal_Int16 ScriptType(const TextFrameIndex nPos) const
Definition: porlay.cxx:1898
TextFrameIndex NextDirChg(const TextFrameIndex nPos, const sal_uInt8 *pLevel=nullptr) const
Definition: porlay.cxx:1911
static bool GetBoundsOfHiddenRange(const SwTextNode &rNode, sal_Int32 nPos, sal_Int32 &rnStartPos, sal_Int32 &rnEndPos, std::vector< sal_Int32 > *pList=nullptr)
Hidden text range information - static and non-version.
Definition: porlay.cxx:2052
SwFontScript WhichFont(TextFrameIndex nIdx) const
Definition: porlay.cxx:900
std::vector< std::tuple< MarkKind, Color, OUString > > GetBookmarks(TextFrameIndex const nPos)
Definition: porlay.cxx:1963
TextFrameIndex NextHiddenChg(TextFrameIndex nPos) const
Definition: porlay.cxx:1938
TextFrameIndex NextScriptChg(TextFrameIndex nPos) const
Definition: porlay.cxx:1885
TextFrameIndex NextBookmark(TextFrameIndex nPos) const
Definition: porlay.cxx:1950
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: txttab.cxx:338
virtual void FormatEOL(SwTextFormatInfo &rInf) override
Definition: txttab.cxx:348
void CalcAdjLine(SwLineLayout *pCurr)
Definition: itradj.cxx:670
SwTwips CalcKanaAdj(SwLineLayout *pCurr)
Definition: itradj.cxx:412
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:208
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
void GetCharRect(SwRect *, TextFrameIndex, SwCursorMoveState *=nullptr, const tools::Long nMax=0)
Definition: itrcrsr.cxx:1226
static void SetRightMargin(const bool bNew)
Definition: itrtxt.hxx:295
The purpose of this class is to be the universal interface between formatting/text output and the pos...
Definition: txtfly.hxx:122
SwTwips GetMinBottom() const
Definition: txtfly.hxx:342
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:362
bool IsOn() const
Definition: txtfly.hxx:319
tools::Long GetNextTop() const
Definition: txtfly.hxx:352
void SetArrowDone(const bool bNew)
Definition: inftxt.hxx:635
SwLinePortion * GetLast()
Definition: inftxt.hxx:564
bool IsIgnoreFly() const
Definition: inftxt.hxx:573
void SetStop(const bool bNew)
Definition: inftxt.hxx:578
SwTabPortion * GetLastTab()
Definition: inftxt.hxx:618
void SetFly(SwFlyPortion *pNew)
Definition: inftxt.hxx:613
void SetErgoDone(const bool bNew)
Definition: inftxt.hxx:631
void ChkNoHyph(const sal_uInt8 bEnd, const sal_uInt8 bMid)
Definition: inftxt.hxx:570
void SetUnderScorePos(TextFrameIndex const nNew)
Definition: inftxt.hxx:645
void ClrUnderflow()
Definition: inftxt.hxx:587
const SwFormatDrop * GetDropFormat() const
Definition: inftxt.cxx:1530
void SetRoot(SwLineLayout *pNew)
Definition: inftxt.hxx:563
void SetRest(SwLinePortion *pNewRest)
Definition: inftxt.hxx:580
sal_uInt16 ForcedLeftMargin() const
Definition: inftxt.hxx:554
bool CheckFootnotePortion(SwLineLayout const *pCurr)
Definition: inftxt.hxx:652
void SetShift(const bool bNew)
Definition: inftxt.hxx:584
void SetLineStart(TextFrameIndex const nNew)
Definition: inftxt.hxx:594
bool IsTest() const
Definition: inftxt.hxx:591
void SetDropInit(const bool bNew)
Definition: inftxt.hxx:589
sal_uInt16 RealWidth() const
Definition: inftxt.hxx:552
void SetTabOverflow(bool bOverflow)
Definition: inftxt.hxx:665
TextFrameIndex GetLineStart() const
Definition: inftxt.hxx:593
void SetLineNetHeight(const sal_uInt16 nNew)
Definition: inftxt.hxx:600
SwTwips Right() const
Definition: inftxt.hxx:547
bool IsUnderflow() const
Definition: inftxt.hxx:586
const SwLinePortion * GetUnderflow() const
Definition: inftxt.hxx:602
bool LastKernPortion()
Definition: inftxt.cxx:1745
sal_Unicode GetHookChar() const
Definition: inftxt.hxx:625
void SetLineHeight(const sal_uInt16 nNew)
Definition: inftxt.hxx:598
bool IsNumDone() const
Definition: inftxt.hxx:632
bool IsErgoDone() const
Definition: inftxt.hxx:630
TextFrameIndex ScanPortionEnd(TextFrameIndex nStart, TextFrameIndex nEnd)
Definition: inftxt.cxx:1652
sal_uInt16 GetLineNetHeight() const
Definition: inftxt.hxx:599
SwTwips Left() const
Definition: inftxt.hxx:545
sal_uInt16 GetLineHeight() const
Definition: inftxt.hxx:597
void SetLast(SwLinePortion *pNewLast)
Definition: inftxt.hxx:565
bool IsFull() const
Definition: inftxt.hxx:566
SwLinePortion * GetRest()
Definition: inftxt.hxx:579
bool IsNewLine() const
Definition: inftxt.hxx:581
bool IsFootnoteDone() const
Definition: inftxt.hxx:628
sal_uInt16 Width() const
Definition: inftxt.hxx:531
void ClearHookChar()
Definition: inftxt.hxx:623
SwFlyPortion * GetFly()
Definition: inftxt.hxx:612
TextFrameIndex GetSoftHyphPos() const
Definition: inftxt.hxx:606
sal_Unicode GetTabDecimal() const
Definition: inftxt.hxx:620
void SetNumDone(const bool bNew)
Definition: inftxt.hxx:633
void SetNewLine(const bool bNew)
Definition: inftxt.hxx:582
void SetTabDecimal(const sal_Unicode cNew)
Definition: inftxt.hxx:621
bool IsArrowDone() const
Definition: inftxt.hxx:634
bool CheckCurrentPosBookmark()
Definition: inftxt.cxx:2010
TextFrameIndex GetUnderScorePos() const
Definition: inftxt.hxx:644
void SetFootnoteDone(const bool bNew)
Definition: inftxt.hxx:629
SwTwips GetLineWidth()
Returns the distance between the current horizontal position and the end of the line.
Definition: inftxt.cxx:1773
SwTwips First() const
Definition: inftxt.hxx:549
bool IsStop() const
Definition: inftxt.hxx:577
void SetUnderflow(SwLinePortion *pNew)
Definition: inftxt.hxx:604
TextFrameIndex GetReformatStart() const
Definition: inftxt.hxx:774
void LeftMargin(const SwTwips nNew)
Definition: inftxt.hxx:551
void SetFull(const bool bNew)
Definition: inftxt.hxx:567
void SetSoftHyphPos(TextFrameIndex const nNew)
Definition: inftxt.hxx:607
SwExpandPortion * TryNewNoLengthPortion(SwTextFormatInfo const &rInfo)
Try to create a new portion with zero length, for an end of a hint (where there is no CH_TXTATR).
Definition: txtfld.cxx:321
bool IsFlyInCntBase() const
Definition: itrform2.hxx:210
std::unique_ptr< sw::MergedAttrIterByEnd > m_pByEndIter
Definition: itrform2.hxx:45
bool m_bTruncLines
Definition: itrform2.hxx:43
sal_uInt16 GetFrameRstHeight() const
Definition: itrform2.cxx:141
bool AllowRepaintOpt() const
Definition: itrform2.cxx:2311
TextFrameIndex m_nRightScanIdx
Definition: itrform2.hxx:40
bool CalcOnceMore()
Definition: itrform2.cxx:2262
SwTextPortion * NewTextPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1294
sal_uInt8 m_nContentEndHyph
Definition: itrform2.hxx:37
const sal_uInt8 & CntMidHyph() const
Definition: itrform2.hxx:220
bool ClearIfIsFirstOfBorderMerge(SwLinePortion const *pPortion)
Definition: itrform2.cxx:158
SwErgoSumPortion * NewErgoSumPortion(SwTextFormatInfo const &rInf) const
Definition: txtftn.cxx:1044
bool HasTruncLines() const
Definition: itrform2.hxx:204
SwMultiPortion * GetMulti() const
Definition: itrform2.hxx:199
void SetFlyInCntBase(bool bNew=true)
Definition: itrform2.hxx:211
bool m_bFlyInContentBase
Definition: itrform2.hxx:42
SwTabPortion * NewTabPortion(SwTextFormatInfo &rInf, bool bAuto) const
Definition: txttab.cxx:70
const sal_uInt8 & CntEndHyph() const
Definition: itrform2.hxx:219
void CalcFlyWidth(SwTextFormatInfo &rInf)
Calculation of the emulated right side.
Definition: itrform2.cxx:2632
void CalcUnclipped(SwTwips &rTop, SwTwips &rBottom)
Definition: itrform2.cxx:2363
void FormatReset(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:2249
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:484
SwTwips CalcFitToContent_()
Definition: itrform2.cxx:2300
void CtorInitTextFormatter(SwTextFrame *pFrame, SwTextFormatInfo *pInf)
Definition: itrform2.cxx:93
SwLinePortion * NewPortion(SwTextFormatInfo &rInf, ::std::optional< TextFrameIndex >)
Definition: itrform2.cxx:1545
void AlignFlyInCntBase(tools::Long nBaseLine) const
Set all anchored as character objects to the passed BaseLine (in Y direction).
Definition: itrform2.cxx:2497
SwDropPortion * NewDropPortion(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:561
bool IsStop() const
Definition: itrform2.hxx:174
bool ChkFlyUnderflow(SwTextFormatInfo &rInf) const
This is called after the real height of the line has been calculated Therefore it is possible,...
Definition: itrform2.cxx:2544
bool IsNewLine() const
Definition: itrform2.hxx:177
void CalcAscent(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:800
const SwFormatDrop * GetDropFormat() const
Definition: itrform2.hxx:196
void BuildPortions(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:377
void CalcAdjustLine(SwLineLayout *pCurr)
Definition: itrform2.cxx:785
TextFrameIndex FormatLine(TextFrameIndex nStart)
Definition: itrform2.cxx:1856
SwMultiPortion * m_pMulti
Definition: itrform2.hxx:36
SwNumberPortion * NewNumberPortion(SwTextFormatInfo &rInf) const
Definition: txtfld.cxx:620
SwLinePortion * WhichFirstPortion(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:1368
void UpdatePos(SwLineLayout *pCurr, Point aStart, TextFrameIndex nStartIdx, bool bAlways=false) const
The position of the portions changes with the adjustment.
Definition: itrform2.cxx:2375
SwLinePortion * NewExtraPortion(SwTextFormatInfo &rInf)
Definition: txtfld.cxx:360
bool BuildMultiPortion(SwTextFormatInfo &rInf, SwMultiPortion &rMulti)
Definition: pormulti.cxx:1907
TextFrameIndex m_nLeftScanIdx
Definition: itrform2.hxx:39
static void MergeCharacterBorder(SwDropPortion const &rPortion)
Merge border of the drop portion with modifying the font of the portions' part.
Definition: itrform2.cxx:2961
SwNumberPortion * NewFootnoteNumPortion(SwTextFormatInfo const &rInf) const
The portion for the Footnote Numbering in the Footnote Area.
Definition: txtftn.cxx:933
void CalcRealHeight(bool bNewLine=false)
Definition: itrform2.cxx:2069
bool IsQuick() const
Definition: itrform2.hxx:180
const SwFormatDrop * m_pDropFormat
Definition: itrform2.hxx:35
SwFlyCntPortion * NewFlyCntPortion(SwTextFormatInfo &rInf, SwTextAttr *pHt) const
Sets a new portion for an object anchored as character.
Definition: itrform2.cxx:2861
void FeedInf(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:2225
SwTextPortion * WhichTextPor(SwTextFormatInfo &rInf) const
Definition: itrform2.cxx:1130
SwLinePortion * m_pFirstOfBorderMerge
Definition: itrform2.hxx:46
void RecalcRealHeight()
Definition: itrform2.cxx:2061
SwLinePortion * Underflow(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:168
void InsertPortion(SwTextFormatInfo &rInf, SwLinePortion *pPor)
Definition: itrform2.cxx:313
SwTwips CalcBottomLine() const
Definition: itrform2.cxx:2275
SwTextFormatInfo & GetInfo()
Definition: itrform2.hxx:213
virtual ~SwTextFormatter() override
Definition: itrform2.cxx:118
void Insert(SwLineLayout *pLine)
Definition: itrform2.cxx:129
sal_uInt8 m_nContentMidHyph
Definition: itrform2.hxx:38
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
bool IsFootnoteNumFrame() const
Am I a FootnoteFrame, with a number at the start of the paragraph?
Definition: txtfrm.hxx:628
SwDoc & GetDoc()
Definition: txtfrm.hxx:466
void SwitchVerticalToHorizontal(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from vertical to horizontal layout.
Definition: txtfrm.cxx:580
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:861
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1246
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:444
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:683
bool IsSwapped() const
Definition: txtfrm.hxx:541
void SwitchRTLtoLTR(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from RTL to LTR layout.
Definition: txtfrm.hxx:741
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1252
void SetHasRotatedPortions(bool bHasRotatedPortions)
Definition: txtftn.cxx:98
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout.
Definition: txtfrm.cxx:473
sal_uInt16 GetBaseHeight() const
Definition: tgrditem.hxx:75
bool GetRubyTextBelow() const
Definition: tgrditem.hxx:85
sal_uInt16 GetRubyHeight() const
Definition: tgrditem.hxx:78
SwTextGrid GetGridType() const
Definition: tgrditem.hxx:81
bool IsSnapToChars() const
Definition: tgrditem.hxx:100
SwParaPortion * GetParaPortion()
Definition: inftxt.hxx:121
SwTwips Y() const
Definition: itrtxt.hxx:90
bool SeekAndChgBefore(SwTextSizeInfo &rInf)
Definition: itrtxt.hxx:316
TextFrameIndex GetStart() const
Definition: itrtxt.hxx:88
bool SeekStartAndChg(SwTextSizeInfo &rInf, const bool bPara=false)
Definition: itrtxt.hxx:324
void Bottom()
Definition: itrtxt.cxx:186
bool IsFirstTextLine() const
Definition: itrtxt.hxx:120
SwLineLayout * m_pCurr
Definition: itrtxt.hxx:36
SwTwips GetLineHeight() const
Definition: itrtxt.hxx:116
const SwLineLayout * Next()
Definition: itrtxt.cxx:108
SwTextFrame * m_pFrame
Definition: itrtxt.hxx:34
sal_uInt16 RegDiff() const
Definition: itrtxt.hxx:93
const SwLineLayout * GetCurr() const
Definition: itrtxt.hxx:83
SwTextFrame * GetTextFrame()
Definition: itrtxt.hxx:134
TextFrameIndex m_nStart
Definition: itrtxt.hxx:41
SwTwips RegStart() const
Definition: itrtxt.hxx:92
void CalcAscentAndHeight(SwTwips &rAscent, SwTwips &rHeight) const
Definition: itrtxt.cxx:64
SwTextInfo * m_pInf
Definition: itrtxt.hxx:35
bool IsParaLine() const
Definition: itrtxt.hxx:125
SwLineInfo m_aLineInf
Definition: itrtxt.hxx:33
bool SeekAndChg(SwTextSizeInfo &rInf)
Definition: itrtxt.hxx:311
bool IsRegisterOn() const
Definition: itrtxt.hxx:94
sal_uInt16 GetDropLeft() const
Definition: itrtxt.hxx:204
void DropInit()
Definition: itrcrsr.cxx:363
Point GetTopLeft() const
Definition: itrtxt.hxx:186
SwTwips Right() const
Definition: itrtxt.hxx:181
bool IsLastCenter() const
Definition: itrtxt.hxx:189
bool IsLastBlock() const
Definition: itrtxt.hxx:188
SwTwips GetLeftMargin() const
Definition: itrtxt.hxx:329
sal_uInt16 GetDropHeight() const
Definition: itrtxt.hxx:205
SwTwips Left() const
Definition: itrtxt.hxx:334
SwTwips FirstLeft() const
Definition: itrtxt.hxx:182
bool HasNegFirst() const
Definition: itrtxt.hxx:194
SvxAdjust GetAdjust() const
Definition: itrtxt.hxx:190
SwTwips GetLeftMin() const
Definition: itrtxt.hxx:193
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, ::sw::GetTextAttrMode const eMode=::sw::GetTextAttrMode::Default) const
get the innermost text attribute covering position nIndex.
Definition: ndtxt.cxx:1802
void SetpSpaceAdd(std::vector< tools::Long > *pNew)
Definition: inftxt.hxx:448
void SetPaintOfst(const SwTwips nNew)
Definition: inftxt.hxx:746
SwTextFly & GetTextFly()
Definition: inftxt.hxx:387
SwTwips X() const
Definition: inftxt.hxx:382
void SetPos(const Point &rNew)
Definition: inftxt.hxx:433
SwTwips GetPaintOfst() const
Definition: inftxt.hxx:741
const Point & GetPos() const
Definition: inftxt.hxx:432
void DrawViewOpt(const SwLinePortion &rPor, PortionType nWhich, const Color *pColor=nullptr) const
Definition: inftxt.cxx:1308
void ResetSpaceIdx()
Definition: inftxt.hxx:440
SwTwips Y() const
Definition: inftxt.hxx:384
void CtorInitTextPainter(SwTextFrame *pFrame, SwTextPaintInfo *pInf)
Definition: itrpaint.cxx:63
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: portxt.cxx:529
SwTextFrame * GetTextFrame()
Definition: inftxt.hxx:288
vcl::RenderContext * GetOut()
Definition: inftxt.hxx:225
sal_uInt16 GetHangingBaseline() const
Definition: inftxt.hxx:723
SwViewShell * GetVsh()
Definition: inftxt.hxx:222
const SwViewOption & GetOpt() const
Definition: inftxt.hxx:239
void SetMulti(const bool bNew)
Definition: inftxt.hxx:205
void SetLen(const TextFrameIndex nNew)
Definition: inftxt.hxx:276
void ResetKanaIdx()
Definition: inftxt.hxx:323
void ResetMaxWidthDiff()
Definition: inftxt.hxx:311
sal_uInt16 GetTextHeight() const
Definition: inftxt.hxx:717
SwFont * GetFont()
Definition: inftxt.hxx:232
void SetIdx(const TextFrameIndex nNew)
Definition: inftxt.hxx:274
bool HasScriptSpace() const
Definition: inftxt.hxx:212
void SetDirection(const sal_uInt8 nNew)
Definition: inftxt.hxx:219
sal_uInt16 GetAscent() const
Definition: inftxt.hxx:711
sal_Unicode GetChar(TextFrameIndex const nPos) const
Definition: inftxt.hxx:241
bool IsRuby() const
Definition: inftxt.hxx:208
void SetKanaComp(std::deque< sal_uInt16 > *pNew)
Definition: inftxt.hxx:326
TextFrameIndex GetLen() const
Definition: inftxt.hxx:275
bool IsOtherThanFootnoteInside() const
Definition: inftxt.hxx:202
void SelectFont()
Definition: inftxt.cxx:367
void SetFootnoteInside(const bool bNew)
Definition: inftxt.hxx:201
std::optional< SwMultiCreator > GetMultiCreator(TextFrameIndex &rPos, SwMultiPortion const *pM) const
Definition: pormulti.cxx:934
const OUString & GetText() const
Definition: inftxt.hxx:240
TextFrameIndex GetIdx() const
Definition: inftxt.hxx:273
bool SnapToGrid() const
Definition: inftxt.hxx:216
void SetOtherThanFootnoteInside(const bool bNew)
Definition: inftxt.hxx:203
bool HasHint(TextFrameIndex nPos) const
Definition: inftxt.cxx:478
bool IsMulti() const
Definition: inftxt.hxx:204
void SetStopUnderflow(const bool bNew)
Definition: inftxt.hxx:199
bool IsPrinting() const
Definition: viewopt.hxx:538
bool IsShowHiddenChar(bool bHard=false) const
Definition: viewopt.hxx:431
bool IsFieldName() const
Definition: viewopt.hxx:361
vcl::Window * GetWin() const
Definition: viewsh.hxx:346
static DrawFlyCntPortion * Create(const SwTextFrame &rFrame, SwFrameFormat const &rFormat, const Point &rBase, tools::Long nAsc, tools::Long nDescent, tools::Long nFlyAsc, tools::Long nFlyDesc, AsCharFlags nFlags)
Definition: porfly.cxx:302
static FlyContentPortion * Create(const SwTextFrame &rFrame, SwFlyInContentFrame *pFly, const Point &rBase, tools::Long nAscent, tools::Long nDescent, tools::Long nFlyAsc, tools::Long nFlyDesc, AsCharFlags nFlags)
Definition: porfly.cxx:295
virtual bool IsChecked() const =0
virtual editeng::HangulHanjaConversion::ConversionDirection GetDirection(editeng::HangulHanjaConversion::ConversionDirection _eDefaultDirection) const override
float u
LINESTYLE_NONE
#define CH_TXT_ATR_FIELDSEP
Definition: hintids.hxx:181
#define CH_TXT_ATR_INPUTFIELDSTART
Definition: hintids.hxx:175
#define CH_TXT_ATR_FORMELEMENT
Definition: hintids.hxx:178
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
constexpr TypedWhichId< SvxCharRotateItem > RES_CHRATR_ROTATE(32)
#define CH_TXTATR_INWORD
Definition: hintids.hxx:172
#define CH_TXT_ATR_INPUTFIELDEND
Definition: hintids.hxx:176
#define CH_TXT_ATR_FIELDEND
Definition: hintids.hxx:182
#define CH_TXT_ATR_FIELDSTART
Definition: hintids.hxx:180
#define CH_TXTATR_BREAKWORD
Definition: hintids.hxx:171
#define DIR_BOTTOM2TOP
Definition: inftxt.hxx:55
#define DIR_TOP2BOTTOM
Definition: inftxt.hxx:57
CharClass & GetAppCharClass()
Definition: init.cxx:706
sal_Int32 nIndex
static bool lcl_OldFieldRest(const SwLineLayout *pCurr)
Definition: itrform2.cxx:1517
static void ClearFly(SwTextFormatInfo &rInf)
Definition: itrform2.cxx:87
bool IsUnderlineBreak(const SwLinePortion &rPor, const SwFont &rFnt)
Definition: itrpaint.cxx:46
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
uno::Reference< text::XTextContent > GetNestedTextContent(SwTextNode const &rTextNode, sal_Int32 const nIndex, bool const bParent)
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:74
double getLength(const B2DPolygon &rCandidate)
OUString removeAny(std::u16string_view rIn, sal_Unicode const *const pChars)
int i
tools::Long SnapToGrid(KernArray &rKernArray, std::u16string_view aText, sal_Int32 nStt, sal_Int32 nLen, tools::Long nGridWidth, bool bForceLeft)
Snap ideographs to text grids: a) Ideographic open brackets are aligned to the rightmost edge of span...
Definition: justify.cxx:176
OUString ExpandFieldmark(IFieldmark *pBM)
Definition: itrform2.cxx:1098
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
@ Parent
EXPAND : (Start < nIndex <= End)
long Long
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
SwNodeOffset abs(const SwNodeOffset &a)
Definition: nodeoffset.hxx:34
constexpr OUStringLiteral ODF_FORMTEXT
constexpr OUStringLiteral ODF_FORMDROPDOWN_RESULT
constexpr OUStringLiteral ODF_FORMDROPDOWN_LISTENTRY
constexpr OUStringLiteral ODF_FORMCHECKBOX
constexpr OUStringLiteral ODF_FORMDATE
constexpr OUStringLiteral ODF_FORMDROPDOWN
SwTextGridItem const * GetGridItem(SwPageFrame const *const)
Definition: pagechg.cxx:2595
sal_uInt16 GetGridWidth(SwTextGridItem const &, SwDoc const &)
Definition: pagechg.cxx:2609
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
std::vector< OUString > Entries
tools::Long GetLen(const Point &rPnt)
const sal_Unicode CH_TAB
Definition: swfont.hxx:44
const sal_Unicode CH_BREAK
Definition: swfont.hxx:43
const sal_Unicode CH_BLANK
Definition: swfont.hxx:42
SwFontScript
Definition: swfont.hxx:124
#define CHAR_HARDBLANK
Definition: swtypes.hxx:173
tools::Long SwTwips
Definition: swtypes.hxx:51
#define CHAR_SOFTHYPHEN
Definition: swtypes.hxx:175
#define CHAR_WJ
Definition: swtypes.hxx:179
#define CHAR_HARDHYPHEN
Definition: swtypes.hxx:174
#define CHAR_ZWSP
Definition: swtypes.hxx:178
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:57
@ GRID_LINES_CHARS
Definition: tgrditem.hxx:30
Left
PortionType
Definition: txttypes.hxx:24
#define SAL_MAX_UINT16
sal_uInt16 sal_Unicode