LibreOffice Module sw (master) 1
txtfrm.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 <config_wasm_strip.h>
21
22#include <hintids.hxx>
23#include <hints.hxx>
24#include <svl/ctloptions.hxx>
25#include <editeng/lspcitem.hxx>
26#include <editeng/lrspitem.hxx>
27#include <editeng/brushitem.hxx>
28#include <editeng/pgrditem.hxx>
30#include <swmodule.hxx>
31#include <SwSmartTagMgr.hxx>
32#include <doc.hxx>
36#include <rootfrm.hxx>
37#include <pagefrm.hxx>
38#include <viewsh.hxx>
39#include <pam.hxx>
40#include <ndtxt.hxx>
41#include <paratr.hxx>
42#include <viewopt.hxx>
43#include <flyfrm.hxx>
44#include <tabfrm.hxx>
45#include <frmatr.hxx>
46#include <frmtool.hxx>
47#include <tgrditem.hxx>
48#include <dbg_lay.hxx>
49#include <fmtfld.hxx>
50#include <fmtftn.hxx>
51#include <txtfld.hxx>
52#include <txtftn.hxx>
53#include <ftninfo.hxx>
54#include <fmtline.hxx>
55#include <txtfrm.hxx>
56#include <notxtfrm.hxx>
57#include <sectfrm.hxx>
58#include "itrform2.hxx"
59#include "widorp.hxx"
60#include "txtcache.hxx"
61#include <fntcache.hxx>
62#include <SwGrammarMarkUp.hxx>
63#include <lineinfo.hxx>
64#include <SwPortionHandler.hxx>
65#include <dcontact.hxx>
66#include <sortedobjs.hxx>
67#include <txtflcnt.hxx>
68#include <fmtflcnt.hxx>
69#include <fmtcntnt.hxx>
70#include <numrule.hxx>
71#include <GrammarContact.hxx>
72#include <calbck.hxx>
73#include <ftnidx.hxx>
74#include <ftnfrm.hxx>
75
76#include <wrtsh.hxx>
77#include <view.hxx>
78#include <edtwin.hxx>
80
81namespace sw {
82
84 : m_pMerged(rFrame.GetMergedPara())
85 , m_pNode(m_pMerged ? nullptr : rFrame.GetTextNodeFirst())
86 , m_CurrentExtent(0)
87 , m_CurrentHint(0)
88 {
89 }
90
92 {
93 if (m_pMerged)
94 {
95 while (m_CurrentExtent < m_pMerged->extents.size())
96 {
98 if (SwpHints const*const pHints = rExtent.pNode->GetpSwpHints())
99 {
100 while (m_CurrentHint < pHints->Count())
101 {
102 SwTextAttr *const pHint(pHints->Get(m_CurrentHint));
103 if (rExtent.nEnd < pHint->GetStart()
104 // <= if it has no end or isn't empty
105 || (rExtent.nEnd == pHint->GetStart()
106 && (!pHint->GetEnd()
107 || *pHint->GetEnd() != pHint->GetStart())))
108 {
109 break;
110 }
112 if (rExtent.nStart <= pHint->GetStart())
113 {
114 if (ppNode)
115 {
116 *ppNode = rExtent.pNode;
117 }
118 return pHint;
119 }
120 }
121 }
123 if (m_CurrentExtent < m_pMerged->extents.size() &&
124 rExtent.pNode != m_pMerged->extents[m_CurrentExtent].pNode)
125 {
126 m_CurrentHint = 0; // reset
127 }
128 }
129 return nullptr;
130 }
131 else
132 {
133 SwpHints const*const pHints(m_pNode->GetpSwpHints());
134 if (pHints)
135 {
136 if (m_CurrentHint < pHints->Count())
137 {
138 SwTextAttr const*const pHint(pHints->Get(m_CurrentHint));
140 if (ppNode)
141 {
142 *ppNode = m_pNode;
143 }
144 return pHint;
145 }
146 }
147 return nullptr;
148 }
149 }
150
152 : m_pNode(rFrame.GetMergedPara() ? nullptr : rFrame.GetTextNodeFirst())
153 , m_CurrentHint(0)
154 {
155 if (!m_pNode)
156 {
157 MergedAttrIterReverse iter(rFrame);
158 SwTextNode const* pNode(nullptr);
159 while (SwTextAttr const* pHint = iter.PrevAttr(&pNode))
160 {
161 m_Hints.emplace_back(pNode, pHint);
162 }
163 }
164 }
165
167 {
168 if (m_pNode)
169 {
170 SwpHints const*const pHints(m_pNode->GetpSwpHints());
171 if (pHints)
172 {
173 if (m_CurrentHint < pHints->Count())
174 {
175 SwTextAttr const*const pHint(
178 rpNode = m_pNode;
179 return pHint;
180 }
181 }
182 return nullptr;
183 }
184 else
185 {
186 if (m_CurrentHint < m_Hints.size())
187 {
188 auto const ret = m_Hints[m_Hints.size() - m_CurrentHint - 1];
190 rpNode = ret.first;
191 return ret.second;
192 }
193 return nullptr;
194 }
195 }
196
198 {
199 assert(0 < m_CurrentHint); // should only rewind as far as 0
201 }
202
204 : MergedAttrIterBase(rFrame)
205 {
206 if (m_pMerged)
207 {
209 SwpHints const*const pHints(0 < m_CurrentExtent
210 ? m_pMerged->extents[m_CurrentExtent-1].pNode->GetpSwpHints()
211 : nullptr);
212 if (pHints)
213 {
214 pHints->SortIfNeedBe();
215 m_CurrentHint = pHints->Count();
216 }
217 }
218 else
219 {
220 if (SwpHints const*const pHints = m_pNode->GetpSwpHints())
221 {
222 pHints->SortIfNeedBe();
223 m_CurrentHint = pHints->Count();
224 }
225 }
226 }
227
229 {
230 if (m_pMerged)
231 {
232 while (0 < m_CurrentExtent)
233 {
234 sw::Extent const& rExtent(m_pMerged->extents[m_CurrentExtent-1]);
235 if (SwpHints const*const pHints = rExtent.pNode->GetpSwpHints())
236 {
237 while (0 < m_CurrentHint)
238 {
239 SwTextAttr *const pHint(
240 pHints->GetSortedByEnd(m_CurrentHint - 1));
241 if (pHint->GetAnyEnd() < rExtent.nStart
242 // <= if it has end and isn't empty
243 || (pHint->GetEnd()
244 && *pHint->GetEnd() != pHint->GetStart()
245 && *pHint->GetEnd() == rExtent.nStart))
246 {
247 break;
248 }
250 if (pHint->GetAnyEnd() <= rExtent.nEnd)
251 {
252 if (ppNode)
253 {
254 *ppNode = rExtent.pNode;
255 }
256 return pHint;
257 }
258 }
259 }
261 if (0 < m_CurrentExtent &&
262 rExtent.pNode != m_pMerged->extents[m_CurrentExtent-1].pNode)
263 {
264 SwpHints const*const pHints(
265 m_pMerged->extents[m_CurrentExtent-1].pNode->GetpSwpHints());
266 m_CurrentHint = pHints ? pHints->Count() : 0; // reset
267 if (pHints)
268 pHints->SortIfNeedBe();
269 }
270 }
271 return nullptr;
272 }
273 else
274 {
275 SwpHints const*const pHints(m_pNode->GetpSwpHints());
276 if (pHints && 0 < m_CurrentHint)
277 {
278 SwTextAttr const*const pHint(pHints->GetSortedByEnd(m_CurrentHint - 1));
280 if (ppNode)
281 {
282 *ppNode = m_pNode;
283 }
284 return pHint;
285 }
286 return nullptr;
287 }
288 }
289
290 bool FrameContainsNode(SwContentFrame const& rFrame, SwNodeOffset const nNodeIndex)
291 {
292 if (rFrame.IsTextFrame())
293 {
294 SwTextFrame const& rTextFrame(static_cast<SwTextFrame const&>(rFrame));
295 if (sw::MergedPara const*const pMerged = rTextFrame.GetMergedPara())
296 {
297 SwNodeOffset const nFirst(pMerged->pFirstNode->GetIndex());
298 SwNodeOffset const nLast(pMerged->pLastNode->GetIndex());
299 return (nFirst <= nNodeIndex && nNodeIndex <= nLast);
300 }
301 else
302 {
303 return rTextFrame.GetTextNodeFirst()->GetIndex() == nNodeIndex;
304 }
305 }
306 else
307 {
308 assert(rFrame.IsNoTextFrame());
309 return static_cast<SwNoTextFrame const&>(rFrame).GetNode()->GetIndex() == nNodeIndex;
310 }
311 }
312
313 bool IsParaPropsNode(SwRootFrame const& rLayout, SwTextNode const& rNode)
314 {
315 if (rLayout.HasMergedParas())
316 {
317 if (SwTextFrame const*const pFrame = static_cast<SwTextFrame*>(rNode.getLayoutFrame(&rLayout)))
318 {
319 sw::MergedPara const*const pMerged(pFrame->GetMergedPara());
320 if (pMerged && pMerged->pParaPropsNode != &rNode)
321 {
322 return false;
323 }
324 }
325 }
326 return true;
327 }
328
329 SwTextNode *
330 GetParaPropsNode(SwRootFrame const& rLayout, SwNode const& rPos)
331 {
332 const SwTextNode *const pTextNode(rPos.GetTextNode());
333 if (pTextNode && !sw::IsParaPropsNode(rLayout, *pTextNode))
334 {
335 return static_cast<SwTextFrame*>(pTextNode->getLayoutFrame(&rLayout))->GetMergedPara()->pParaPropsNode;
336 }
337 else
338 {
339 return const_cast<SwTextNode*>(pTextNode);
340 }
341 }
342
344 GetParaPropsPos(SwRootFrame const& rLayout, SwPosition const& rPos)
345 {
346 SwPosition pos(rPos);
347 SwTextNode const*const pNode(pos.GetNode().GetTextNode());
348 if (pNode)
349 pos.Assign( *sw::GetParaPropsNode(rLayout, *pNode) );
350 return pos;
351 }
352
353 std::pair<SwTextNode *, SwTextNode *>
354 GetFirstAndLastNode(SwRootFrame const& rLayout, SwNode const& rPos)
355 {
356 SwTextNode *const pTextNode(const_cast<SwTextNode*>(rPos.GetTextNode()));
357 if (pTextNode && rLayout.HasMergedParas())
358 {
359 if (SwTextFrame const*const pFrame = static_cast<SwTextFrame*>(pTextNode->getLayoutFrame(&rLayout)))
360 {
361 if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
362 {
363 return std::make_pair(pMerged->pFirstNode, const_cast<SwTextNode*>(pMerged->pLastNode));
364 }
365 }
366 }
367 return std::make_pair(pTextNode, pTextNode);
368 }
369
371 SwTextNode const& rNode, SwRootFrame const*const pLayout)
372 {
373 rNode.SwContentNode::GetAttr(rFormatSet);
374 if (pLayout && pLayout->HasMergedParas())
375 {
376 auto pFrame = static_cast<SwTextFrame*>(rNode.getLayoutFrame(pLayout));
377 if (sw::MergedPara const*const pMerged = pFrame ? pFrame->GetMergedPara() : nullptr)
378 {
379 if (pMerged->pFirstNode != &rNode)
380 {
381 rFormatSet.ClearItem(RES_PAGEDESC);
382 rFormatSet.ClearItem(RES_BREAK);
383 static_assert(RES_PAGEDESC + 1 == sal_uInt16(RES_BREAK),
384 "first-node items must be adjacent");
386 pMerged->pFirstNode->SwContentNode::GetAttr(firstSet);
387 rFormatSet.Put(firstSet);
388
389 }
390 if (pMerged->pParaPropsNode != &rNode)
391 {
392 for (sal_uInt16 i = RES_PARATR_BEGIN; i != RES_FRMATR_END; ++i)
393 {
394 if (i != RES_PAGEDESC && i != RES_BREAK)
395 {
396 rFormatSet.ClearItem(i);
397 }
398 }
399 for (sal_uInt16 i = XATTR_FILL_FIRST; i <= XATTR_FILL_LAST; ++i)
400 {
401 rFormatSet.ClearItem(i);
402 }
406 propsSet(*rFormatSet.GetPool());
407 pMerged->pParaPropsNode->SwContentNode::GetAttr(propsSet);
408 rFormatSet.Put(propsSet);
409 return *pMerged->pParaPropsNode;
410 }
411 // keep all the CHRATR/UNKNOWNATR anyway...
412 }
413 }
414 return rNode;
415 }
416
417} // namespace sw
418
421{
422 {
424
425 if ( ! mbIsSwapped )
426 {
427 const tools::Long nPrtOfstX = aPrt.Pos().X();
428 aPrt.Pos().setX( aPrt.Pos().Y() );
429
430 if( IsVertLR() )
431 {
432 aPrt.Pos().setY( nPrtOfstX );
433 }
434 else
435 {
436 aPrt.Pos().setY( getFrameArea().Width() - ( nPrtOfstX + aPrt.Width() ) );
437 }
438 }
439 else
440 {
441 const tools::Long nPrtOfstY = aPrt.Pos().Y();
442 aPrt.Pos().setY( aPrt.Pos().X() );
443
444 if( IsVertLR() )
445 {
446 aPrt.Pos().setX( nPrtOfstY );
447 }
448 else
449 {
450 aPrt.Pos().setX( getFrameArea().Height() - ( nPrtOfstY + aPrt.Height() ) );
451 }
452 }
453
454 const tools::Long nPrtWidth = aPrt.Width();
455 aPrt.Width( aPrt.Height() );
456 aPrt.Height( nPrtWidth );
457 }
458
459 {
460 const tools::Long nFrameWidth = getFrameArea().Width();
462 aFrm.Width( aFrm.Height() );
463 aFrm.Height( nFrameWidth );
464 }
465
467}
468
474{
475 // calc offset inside frame
476 tools::Long nOfstX, nOfstY;
477 if ( IsVertLR() )
478 {
479 if (IsVertLRBT())
480 {
481 // X and Y offsets here mean the position of the point that will be the top left corner
482 // after the switch.
483 nOfstX = rRect.Left() + rRect.Width() - getFrameArea().Left();
484 nOfstY = rRect.Top() - getFrameArea().Top();
485 }
486 else
487 {
488 nOfstX = rRect.Left() - getFrameArea().Left();
489 nOfstY = rRect.Top() - getFrameArea().Top();
490 }
491 }
492 else
493 {
494 nOfstX = rRect.Left() - getFrameArea().Left();
495 nOfstY = rRect.Top() + rRect.Height() - getFrameArea().Top();
496 }
497
498 const tools::Long nWidth = rRect.Width();
499 const tools::Long nHeight = rRect.Height();
500
501 if ( IsVertLR() )
502 {
503 rRect.Left(getFrameArea().Left() + nOfstY);
504 }
505 else
506 {
507 if ( mbIsSwapped )
508 rRect.Left( getFrameArea().Left() + getFrameArea().Height() - nOfstY );
509 else
510 // frame is rotated
511 rRect.Left( getFrameArea().Left() + getFrameArea().Width() - nOfstY );
512 }
513
514 if (IsVertLRBT())
515 {
516 if (mbIsSwapped)
517 rRect.Top(getFrameArea().Top() + getFrameArea().Width() - nOfstX);
518 else
519 rRect.Top(getFrameArea().Top() + getFrameArea().Height() - nOfstX);
520 }
521 else
522 rRect.Top(getFrameArea().Top() + nOfstX);
523 rRect.Width( nHeight );
524 rRect.Height( nWidth );
525}
526
532{
533 if (IsVertLRBT())
534 {
535 // The horizontal origo is the top left corner, the LRBT origo is the
536 // bottom left corner. Finally x and y has to be swapped.
537 SAL_WARN_IF(!mbIsSwapped, "sw.core",
538 "SwTextFrame::SwitchHorizontalToVertical, IsVertLRBT, not swapped");
539 Point aPoint(rPoint);
540 rPoint.setX(getFrameArea().Left() + (aPoint.Y() - getFrameArea().Top()));
541 // This would be bottom - x delta, but bottom is top + height, finally
542 // width (and not height), as it's swapped.
543 rPoint.setY(getFrameArea().Top() + getFrameArea().Width()
544 - (aPoint.X() - getFrameArea().Left()));
545 return;
546 }
547
548 // calc offset inside frame
549 const tools::Long nOfstX = rPoint.X() - getFrameArea().Left();
550 const tools::Long nOfstY = rPoint.Y() - getFrameArea().Top();
551 if ( IsVertLR() )
552 rPoint.setX( getFrameArea().Left() + nOfstY );
553 else
554 {
555 if ( mbIsSwapped )
556 rPoint.setX( getFrameArea().Left() + getFrameArea().Height() - nOfstY );
557 else
558 // calc rotated coords
559 rPoint.setX( getFrameArea().Left() + getFrameArea().Width() - nOfstY );
560 }
561
562 rPoint.setY( getFrameArea().Top() + nOfstX );
563}
564
570{
571 Point aTmp( 0, nLimit );
573 return aTmp.X();
574}
575
581{
582 tools::Long nOfstX;
583
584 // calc offset inside frame
585 if ( IsVertLR() )
586 nOfstX = rRect.Left() - getFrameArea().Left();
587 else
588 {
589 if ( mbIsSwapped )
590 nOfstX = getFrameArea().Left() + getFrameArea().Height() - ( rRect.Left() + rRect.Width() );
591 else
592 nOfstX = getFrameArea().Left() + getFrameArea().Width() - ( rRect.Left() + rRect.Width() );
593 }
594
595 tools::Long nOfstY;
596 if (IsVertLRBT())
597 {
598 // Note that mbIsSwapped only affects the frame area, not rRect, so rRect.Height() is used
599 // here unconditionally.
600 if (mbIsSwapped)
601 nOfstY = getFrameArea().Top() + getFrameArea().Width() - (rRect.Top() + rRect.Height());
602 else
603 nOfstY = getFrameArea().Top() + getFrameArea().Height() - (rRect.Top() + rRect.Height());
604 }
605 else
606 nOfstY = rRect.Top() - getFrameArea().Top();
607 const tools::Long nWidth = rRect.Height();
608 const tools::Long nHeight = rRect.Width();
609
610 // calc rotated coords
611 rRect.Left( getFrameArea().Left() + nOfstY );
612 rRect.Top( getFrameArea().Top() + nOfstX );
613 rRect.Width( nWidth );
614 rRect.Height( nHeight );
615}
616
622{
623 tools::Long nOfstX;
624
625 // calc offset inside frame
626 if ( IsVertLR() )
627 // X offset is Y - left.
628 nOfstX = rPoint.X() - getFrameArea().Left();
629 else
630 {
631 // X offset is right - X.
632 if ( mbIsSwapped )
633 nOfstX = getFrameArea().Left() + getFrameArea().Height() - rPoint.X();
634 else
635 nOfstX = getFrameArea().Left() + getFrameArea().Width() - rPoint.X();
636 }
637
638 tools::Long nOfstY;
639 if (IsVertLRBT())
640 {
641 // Y offset is bottom - Y.
642 if (mbIsSwapped)
643 nOfstY = getFrameArea().Top() + getFrameArea().Width() - rPoint.Y();
644 else
645 nOfstY = getFrameArea().Top() + getFrameArea().Height() - rPoint.Y();
646 }
647 else
648 // Y offset is Y - top.
649 nOfstY = rPoint.Y() - getFrameArea().Top();
650
651 // calc rotated coords
652 rPoint.setX( getFrameArea().Left() + nOfstY );
653 rPoint.setY( getFrameArea().Top() + nOfstX );
654}
655
661{
662 Point aTmp( nLimit, 0 );
664 return aTmp.Y();
665}
666
667SwFrameSwapper::SwFrameSwapper( const SwTextFrame* pTextFrame, bool bSwapIfNotSwapped )
668 : pFrame( pTextFrame ), bUndo( false )
669{
670 if (pFrame->IsVertical() && bSwapIfNotSwapped != pFrame->IsSwapped())
671 {
672 bUndo = true;
673 const_cast<SwTextFrame*>(pFrame)->SwapWidthAndHeight();
674 }
675}
676
678{
679 if ( bUndo )
680 const_cast<SwTextFrame*>(pFrame)->SwapWidthAndHeight();
681}
682
684{
685 SwSwapIfNotSwapped swap(const_cast<SwTextFrame *>(this));
686
687 tools::Long nWidth = rRect.Width();
688 rRect.Left( 2 * ( getFrameArea().Left() + getFramePrintArea().Left() ) +
689 getFramePrintArea().Width() - rRect.Right() - 1 );
690
691 rRect.Width( nWidth );
692}
693
694void SwTextFrame::SwitchLTRtoRTL( Point& rPoint ) const
695{
696 SwSwapIfNotSwapped swap(const_cast<SwTextFrame *>(this));
697
698 rPoint.setX( 2 * ( getFrameArea().Left() + getFramePrintArea().Left() ) + getFramePrintArea().Width() - rPoint.X() - 1 );
699}
700
702 m_rOut( rOutp ), m_nOldLayoutMode( rOutp.GetLayoutMode() )
703{
704}
705
707{
708 const_cast<OutputDevice&>(m_rOut).SetLayoutMode( m_nOldLayoutMode );
709}
710
711void SwLayoutModeModifier::Modify( bool bChgToRTL )
712{
713 const_cast<OutputDevice&>(m_rOut).SetLayoutMode( bChgToRTL ?
716}
717
719{
720 const vcl::text::ComplexTextLayoutFlags nNewLayoutMode = m_nOldLayoutMode & ~vcl::text::ComplexTextLayoutFlags::BiDiStrong;
721 const_cast<OutputDevice&>(m_rOut).SetLayoutMode( nNewLayoutMode );
722}
723
725 rOut( rOutp ), nOldLanguageType( rOutp.GetDigitLanguage() )
726{
727 LanguageType eLang = eCurLang;
729 eLang = LANGUAGE_ENGLISH_US;
730 else
731 {
732 const SvtCTLOptions::TextNumerals nTextNumerals = SW_MOD()->GetCTLOptions().GetCTLTextNumerals();
733
734 if ( SvtCTLOptions::NUMERALS_HINDI == nTextNumerals )
736 else if ( SvtCTLOptions::NUMERALS_ARABIC == nTextNumerals )
737 eLang = LANGUAGE_ENGLISH;
738 else if ( SvtCTLOptions::NUMERALS_SYSTEM == nTextNumerals )
739 eLang = ::GetAppLanguage();
740 }
741
742 const_cast<OutputDevice&>(rOut).SetDigitLanguage( eLang );
743}
744
746{
747 const_cast<OutputDevice&>(rOut).SetDigitLanguage( nOldLanguageType );
748}
749
751{
752 OSL_ENSURE( !IsLocked(), "+SwTextFrame::Init: this is locked." );
753 if( !IsLocked() )
754 {
755 ClearPara();
757 // set flags directly to save a ResetPreps call,
758 // and thereby an unnecessary GetPara call
759 // don't set bOrphan, bLocked or bWait to false!
760 // bOrphan = bFlag7 = bFlag8 = false;
761 }
762}
763
765 sw::FrameMode const eMode)
766 : SwContentFrame( pNode, pSib )
767 , mnAllLines( 0 )
768 , mnThisLines( 0 )
769 , mnFlyAnchorOfst( 0 )
770 , mnFlyAnchorOfstNoWrap( 0 )
771 , mnFlyAnchorVertOfstNoWrap( 0 )
772 , mnFootnoteLine( 0 )
773 , mnHeightOfLastLine( 0 )
774 , mnAdditionalFirstLineOffset( 0 )
775 , mnOffset( 0 )
776 , mnCacheIndex( USHRT_MAX )
777 , mbLocked( false )
778 , mbWidow( false )
779 , mbJustWidow( false )
780 , mbEmpty( false )
781 , mbInFootnoteConnect( false )
782 , mbFootnote( false )
783 , mbRepaint( false )
784 , mbHasRotatedPortions( false )
785 , mbFieldFollow( false )
786 , mbHasAnimation( false )
787 , mbIsSwapped( false )
788 , mbFollowFormatAllowed( true )
789{
791 // note: this may call SwClientNotify if it's in a list so do it last
792 // note: this may change this->pRegisteredIn to m_pMergedPara->listeners
793 m_pMergedPara = CheckParaRedlineMerge(*this, *pNode, eMode);
794}
795
796namespace sw {
797
798SwTextFrame * MakeTextFrame(SwTextNode & rNode, SwFrame *const pSibling,
799 sw::FrameMode const eMode)
800{
801 return new SwTextFrame(&rNode, pSibling, eMode);
802}
803
805 SwRootFrame const& rLayout, SwTextNode const& rTextNode,
806 std::vector<std::pair<sal_Int32, sal_Int32>> const*const pExtents)
807{
808 if (pExtents && pExtents->empty())
809 {
810 return; // nothing to do
811 }
812 const SwFootnoteIdxs &rFootnoteIdxs = rTextNode.GetDoc().GetFootnoteIdxs();
813 size_t nPos = 0;
814 SwNodeOffset const nIndex = rTextNode.GetIndex();
815 rFootnoteIdxs.SeekEntry( rTextNode, &nPos );
816 if (nPos < rFootnoteIdxs.size())
817 {
818 while (nPos && rTextNode == (rFootnoteIdxs[ nPos ]->GetTextNode()))
819 --nPos;
820 if (nPos || rTextNode != (rFootnoteIdxs[ nPos ]->GetTextNode()))
821 ++nPos;
822 }
823 size_t iter(0);
824 for ( ; nPos < rFootnoteIdxs.size(); ++nPos)
825 {
826 SwTextFootnote* pTextFootnote = rFootnoteIdxs[ nPos ];
827 if (pTextFootnote->GetTextNode().GetIndex() > nIndex)
828 break;
829 if (pExtents)
830 {
831 while ((*pExtents)[iter].second <= pTextFootnote->GetStart())
832 {
833 ++iter;
834 if (iter == pExtents->size())
835 {
836 return;
837 }
838 }
839 if (pTextFootnote->GetStart() < (*pExtents)[iter].first)
840 {
841 continue;
842 }
843 }
844 pTextFootnote->DelFrames(&rLayout);
845 }
846}
847
848} // namespace sw
849
851{
852 // Remove associated SwParaPortion from s_pTextCache
853 ClearPara();
854
855 assert(!GetDoc().IsInDtor()); // this shouldn't be happening with ViewShell owning layout
856 if (!GetDoc().IsInDtor() && HasFootnote())
857 {
858 if (m_pMergedPara)
859 {
860 SwTextNode const* pNode(nullptr);
861 for (auto const& e : m_pMergedPara->extents)
862 {
863 if (e.pNode != pNode)
864 {
865 pNode = e.pNode;
866 // sw_redlinehide: not sure if it's necessary to check
867 // if the nodes are still alive here, which would require
868 // accessing WriterMultiListener::m_vDepends
869 sw::RemoveFootnotesForNode(*getRootFrame(), *pNode, nullptr);
870 }
871 }
872 }
873 else
874 {
875 SwTextNode *const pNode(static_cast<SwTextNode*>(GetDep()));
876 if (pNode)
877 {
878 sw::RemoveFootnotesForNode(*getRootFrame(), *pNode, nullptr);
879 }
880 }
881 }
882
883 if (!GetDoc().IsInDtor())
884 {
885 if (SwView* pView = GetActiveView())
886 pView->GetEditWin().GetFrameControlsManager().RemoveControls(this);
887 }
888
890}
891
893{
895}
896
897namespace sw {
898
899// 1. if real insert => correct nStart/nEnd for full nLen
900// 2. if rl un-delete => do not correct nStart/nEnd but just include un-deleted
902 bool const isRealInsert,
903 SwTextNode const& rNode, sal_Int32 const nIndex, sal_Int32 const nLen)
904{
905 assert(!isRealInsert || nLen); // can 0 happen? yes, for redline in empty node
906 assert(nIndex <= rNode.Len());
907 assert(nIndex + nLen <= rNode.Len());
908 assert(rMerged.pFirstNode->GetIndex() <= rNode.GetIndex() && rNode.GetIndex() <= rMerged.pLastNode->GetIndex());
909 if (!nLen)
910 {
911 return TextFrameIndex(0);
912 }
913 OUStringBuffer text(rMerged.mergedText);
914 sal_Int32 nTFIndex(0); // index used for insertion at the end
915 sal_Int32 nInserted(0);
916 bool bInserted(false);
917 bool bFoundNode(false);
918 auto itInsert(rMerged.extents.end());
919 for (auto it = rMerged.extents.begin(); it != rMerged.extents.end(); ++it)
920 {
921 if (it->pNode == &rNode)
922 {
923 if (isRealInsert)
924 {
925 bFoundNode = true;
926 if (it->nStart <= nIndex && nIndex <= it->nEnd)
927 { // note: this can happen only once
928 text.insert(nTFIndex + (nIndex - it->nStart),
929 rNode.GetText().subView(nIndex, nLen));
930 it->nEnd += nLen;
931 nInserted = nLen;
932 assert(!bInserted);
933 bInserted = true;
934 }
935 else if (nIndex < it->nStart)
936 {
937 if (itInsert == rMerged.extents.end())
938 {
939 itInsert = it;
940 }
941 it->nStart += nLen;
942 it->nEnd += nLen;
943 }
944 }
945 else
946 {
947 assert(it == rMerged.extents.begin() || (it-1)->pNode != &rNode || (it-1)->nEnd < nIndex);
948 if (nIndex + nLen < it->nStart)
949 {
950 itInsert = it;
951 break;
952 }
953 if (nIndex < it->nStart)
954 {
955 text.insert(nTFIndex,
956 rNode.GetText().subView(nIndex, it->nStart - nIndex));
957 nInserted += it->nStart - nIndex;
958 it->nStart = nIndex;
959 bInserted = true;
960 }
961 assert(it->nStart <= nIndex);
962 if (nIndex <= it->nEnd)
963 {
964 nTFIndex += it->nEnd - it->nStart;
965 while (it->nEnd < nIndex + nLen)
966 {
967 auto *const pNext(
968 (it+1) != rMerged.extents.end() && (it+1)->pNode == it->pNode
969 ? &*(it+1)
970 : nullptr);
971 if (pNext && pNext->nStart <= nIndex + nLen)
972 {
973 text.insert(nTFIndex,
974 rNode.GetText().subView(it->nEnd, pNext->nStart - it->nEnd));
975 nTFIndex += pNext->nStart - it->nEnd;
976 nInserted += pNext->nStart - it->nEnd;
977 pNext->nStart = it->nStart;
978 it = rMerged.extents.erase(it);
979 }
980 else
981 {
982 text.insert(nTFIndex,
983 rNode.GetText().subView(it->nEnd, nIndex + nLen - it->nEnd));
984 nTFIndex += nIndex + nLen - it->nEnd;
985 nInserted += nIndex + nLen - it->nEnd;
986 it->nEnd = nIndex + nLen;
987 }
988 }
989 bInserted = true;
990 break;
991 }
992 }
993 }
994 else if (rNode.GetIndex() < it->pNode->GetIndex() || bFoundNode)
995 {
996 if (itInsert == rMerged.extents.end())
997 {
998 itInsert = it;
999 }
1000 break;
1001 }
1002 if (itInsert == rMerged.extents.end())
1003 {
1004 nTFIndex += it->nEnd - it->nStart;
1005 }
1006 }
1007// assert((bFoundNode || rMerged.extents.empty()) && "text node not found - why is it sending hints to us");
1008 if (!bInserted)
1009 { // must be in a gap
1010 rMerged.extents.emplace(itInsert, const_cast<SwTextNode*>(&rNode), nIndex, nIndex + nLen);
1011 text.insert(nTFIndex, rNode.GetText().subView(nIndex, nLen));
1012 nInserted = nLen;
1013 if (rMerged.extents.size() == 1 // also if it was empty!
1014 || rMerged.pParaPropsNode->GetIndex() < rNode.GetIndex())
1015 { // text inserted after current para-props node
1017 rMerged.pParaPropsNode = &const_cast<SwTextNode&>(rNode);
1019 }
1020 // called from SwRangeRedline::InvalidateRange()
1022 {
1023 const_cast<SwTextNode&>(rNode).SetRedlineMergeFlag(SwNode::Merge::NonFirst);
1024 }
1025 }
1026 rMerged.mergedText = text.makeStringAndClear();
1027 return TextFrameIndex(nInserted);
1028}
1029
1030// 1. if real delete => correct nStart/nEnd for full nLen
1031// 2. if rl delete => do not correct nStart/nEnd but just exclude deleted
1033 bool const isRealDelete,
1034 SwTextNode const& rNode, sal_Int32 nIndex, sal_Int32 const nLen)
1035{
1036 assert(nIndex <= rNode.Len());
1037 assert(rMerged.pFirstNode->GetIndex() <= rNode.GetIndex() && rNode.GetIndex() <= rMerged.pLastNode->GetIndex());
1038 OUStringBuffer text(rMerged.mergedText);
1039 sal_Int32 nTFIndex(0);
1040 sal_Int32 nToDelete(nLen);
1041 sal_Int32 nDeleted(0);
1042 size_t nFoundNode(0);
1043 size_t nErased(0);
1044 auto it = rMerged.extents.begin();
1045 for (; it != rMerged.extents.end(); )
1046 {
1047 bool bErase(false);
1048 if (it->pNode == &rNode)
1049 {
1050 ++nFoundNode;
1051 if (nIndex + nToDelete < it->nStart)
1052 {
1053 nToDelete = 0;
1054 if (!isRealDelete)
1055 {
1056 break;
1057 }
1058 it->nStart -= nLen;
1059 it->nEnd -= nLen;
1060 }
1061 else
1062 {
1063 if (nIndex < it->nStart)
1064 {
1065 // do not adjust nIndex into the text frame index space!
1066 nToDelete -= it->nStart - nIndex;
1067 nIndex = it->nStart;
1068 // note: continue with the if check below, no else!
1069 }
1070 if (it->nStart <= nIndex && nIndex < it->nEnd)
1071 {
1072 sal_Int32 const nDeleteHere(nIndex + nToDelete <= it->nEnd
1073 ? nToDelete
1074 : it->nEnd - nIndex);
1075 text.remove(nTFIndex + (nIndex - it->nStart), nDeleteHere);
1076 bErase = nDeleteHere == it->nEnd - it->nStart;
1077 if (bErase)
1078 {
1079 ++nErased;
1080 assert(it->nStart == nIndex);
1081 it = rMerged.extents.erase(it);
1082 }
1083 else if (isRealDelete)
1084 { // adjust for deleted text
1085 it->nStart -= (nLen - nToDelete);
1086 it->nEnd -= (nLen - nToDelete + nDeleteHere);
1087 if (it != rMerged.extents.begin()
1088 && (it-1)->pNode == &rNode
1089 && (it-1)->nEnd == it->nStart)
1090 { // merge adjacent extents
1091 nTFIndex += it->nEnd - it->nStart;
1092 (it-1)->nEnd = it->nEnd;
1093 it = rMerged.extents.erase(it);
1094 bErase = true; // skip increment
1095 }
1096 }
1097 else
1098 { // exclude text marked as deleted
1099 if (nIndex + nDeleteHere == it->nEnd)
1100 {
1101 it->nEnd -= nDeleteHere;
1102 }
1103 else
1104 {
1105 if (nIndex == it->nStart)
1106 {
1107 it->nStart += nDeleteHere;
1108 }
1109 else
1110 {
1111 sal_Int32 const nOldEnd(it->nEnd);
1112 it->nEnd = nIndex;
1113 it = rMerged.extents.emplace(it+1,
1114 it->pNode, nIndex + nDeleteHere, nOldEnd);
1115 }
1116 assert(nDeleteHere == nToDelete);
1117 }
1118 }
1119 nDeleted += nDeleteHere;
1120 nToDelete -= nDeleteHere;
1121 nIndex += nDeleteHere;
1122 if (!isRealDelete && nToDelete == 0)
1123 {
1124 break;
1125 }
1126 }
1127 }
1128 }
1129 else if (nFoundNode != 0)
1130 {
1131 break;
1132 }
1133 if (!bErase)
1134 {
1135 nTFIndex += it->nEnd - it->nStart;
1136 ++it;
1137 }
1138 }
1139// assert(nFoundNode != 0 && "text node not found - why is it sending hints to us");
1140 assert(nIndex <= rNode.Len() + nLen);
1141 // if there's a remaining deletion, it must be in gap at the end of the node
1142// can't do: might be last one in node was erased assert(nLen == 0 || rMerged.empty() || (it-1)->nEnd <= nIndex);
1143 // note: if first node gets deleted then that must call DelFrames as
1144 // pFirstNode is never updated
1145 if (nErased && nErased == nFoundNode)
1146 { // all visible text from node was erased
1147#if 1
1148 if (rMerged.pParaPropsNode == &rNode)
1149 {
1151 rMerged.pParaPropsNode = rMerged.extents.empty()
1152 ? const_cast<SwTextNode*>(rMerged.pLastNode)
1153 : rMerged.extents.front().pNode;
1155 }
1156#endif
1157// NOPE must listen on all non-hidden nodes; particularly on pLastNode rMerged.listener.EndListening(&const_cast<SwTextNode&>(rNode));
1158 }
1159 rMerged.mergedText = text.makeStringAndClear();
1160 return TextFrameIndex(nDeleted);
1161}
1162
1163std::pair<SwTextNode*, sal_Int32>
1164MapViewToModel(MergedPara const& rMerged, TextFrameIndex const i_nIndex)
1165{
1166 sal_Int32 nIndex(i_nIndex);
1167 sw::Extent const* pExtent(nullptr);
1168 for (const auto& rExt : rMerged.extents)
1169 {
1170 pExtent = &rExt;
1171 if (nIndex < (pExtent->nEnd - pExtent->nStart))
1172 {
1173 return std::make_pair(pExtent->pNode, pExtent->nStart + nIndex);
1174 }
1175 nIndex = nIndex - (pExtent->nEnd - pExtent->nStart);
1176 }
1177 assert(nIndex == 0 && "view index out of bounds");
1178 return pExtent
1179 ? std::make_pair(pExtent->pNode, pExtent->nEnd) //1-past-the-end index
1180 : std::make_pair(const_cast<SwTextNode*>(rMerged.pLastNode), rMerged.pLastNode->Len());
1181}
1182
1183TextFrameIndex MapModelToView(MergedPara const& rMerged, SwTextNode const*const pNode, sal_Int32 const nIndex)
1184{
1185 assert(rMerged.pFirstNode->GetIndex() <= pNode->GetIndex()
1186 && pNode->GetIndex() <= rMerged.pLastNode->GetIndex());
1187 sal_Int32 nRet(0);
1188 bool bFoundNode(false);
1189 for (auto const& e : rMerged.extents)
1190 {
1191 if (pNode->GetIndex() < e.pNode->GetIndex())
1192 {
1193 return TextFrameIndex(nRet);
1194 }
1195 if (e.pNode == pNode)
1196 {
1197 if (e.nStart <= nIndex && nIndex <= e.nEnd)
1198 {
1199 return TextFrameIndex(nRet + (nIndex - e.nStart));
1200 }
1201 else if (nIndex < e.nStart)
1202 {
1203 // in gap before this extent => map to 0 here TODO???
1204 return TextFrameIndex(nRet);
1205 }
1206 bFoundNode = true;
1207 }
1208 else if (bFoundNode)
1209 {
1210 break;
1211 }
1212 nRet += e.nEnd - e.nStart;
1213 }
1214 if (bFoundNode)
1215 {
1216 // must be in a gap at the end of the node
1217 assert(nIndex <= pNode->Len());
1218 return TextFrameIndex(nRet);
1219 }
1220 else if (rMerged.extents.empty())
1221 {
1222 assert(nIndex <= pNode->Len());
1223 return TextFrameIndex(0);
1224 }
1225 return TextFrameIndex(rMerged.mergedText.getLength());
1226}
1227
1228} // namespace sw
1229
1230std::pair<SwTextNode*, sal_Int32>
1232{
1233//nope assert(GetPara());
1234 sw::MergedPara const*const pMerged(GetMergedPara());
1235 if (pMerged)
1236 {
1237 return sw::MapViewToModel(*pMerged, nIndex);
1238 }
1239 else
1240 {
1241 return std::make_pair(static_cast<SwTextNode*>(const_cast<sw::BroadcastingModify*>(
1242 SwFrame::GetDep())), sal_Int32(nIndex));
1243 }
1244}
1245
1247{
1248 std::pair<SwTextNode*, sal_Int32> const ret(MapViewToModel(nIndex));
1249 return SwPosition(*ret.first, ret.second);
1250}
1251
1252TextFrameIndex SwTextFrame::MapModelToView(SwTextNode const*const pNode, sal_Int32 const nIndex) const
1253{
1254//nope assert(GetPara());
1255 sw::MergedPara const*const pMerged(GetMergedPara());
1256 if (pMerged)
1257 {
1258 return sw::MapModelToView(*pMerged, pNode, nIndex);
1259 }
1260 else
1261 {
1262 assert(static_cast<const SwTextNode*>(SwFrame::GetDep()) == pNode);
1263 return TextFrameIndex(nIndex);
1264 }
1265}
1266
1268{
1269 SwTextNode const*const pNode(rPos.GetNode().GetTextNode());
1270 sal_Int32 const nIndex(rPos.GetContentIndex());
1271 return MapModelToView(pNode, nIndex);
1272}
1273
1274void SwTextFrame::SetMergedPara(std::unique_ptr<sw::MergedPara> p)
1275{
1276 SwTextNode *const pFirst(m_pMergedPara ? m_pMergedPara->pFirstNode : nullptr);
1277 m_pMergedPara = std::move(p);
1278 if (pFirst)
1279 {
1280 if (m_pMergedPara)
1281 {
1282 assert(pFirst == m_pMergedPara->pFirstNode);
1283 }
1284 else
1285 {
1286 pFirst->Add(this); // must register at node again
1287 }
1288 }
1289 // postcondition: frame must be listening somewhere
1290 assert(m_pMergedPara || GetDep());
1291}
1292
1293const OUString& SwTextFrame::GetText() const
1294{
1295//nope assert(GetPara());
1296 sw::MergedPara const*const pMerged(GetMergedPara());
1297 if (pMerged)
1298 return pMerged->mergedText;
1299 else
1300 return static_cast<SwTextNode const*>(SwFrame::GetDep())->GetText();
1301}
1302
1304{
1305 // FIXME can GetPara be 0 ? yes... this is needed in SwContentNotify::SwContentNotify() which is called before any formatting is started
1306//nope assert(GetPara());
1307 sw::MergedPara const*const pMerged(GetMergedPara());
1308 if (pMerged)
1309 {
1310// assert(pMerged->pFirstNode == pMerged->pParaPropsNode); // surprising news!
1311 return pMerged->pParaPropsNode;
1312 }
1313 else
1314 return static_cast<SwTextNode const*>(SwFrame::GetDep());
1315}
1316
1318{
1319 sw::MergedPara const*const pMerged(GetMergedPara());
1320 if (pMerged)
1321 return pMerged->extents.empty()
1322 ? pMerged->pFirstNode
1323 : pMerged->extents.front().pNode;
1324 else
1325 return static_cast<SwTextNode const*>(SwFrame::GetDep());
1326}
1327
1329{
1330//nope assert(GetPara());
1331 sw::MergedPara const*const pMerged(GetMergedPara());
1332 if (pMerged)
1333 return pMerged->pFirstNode;
1334 else
1335 return static_cast<SwTextNode const*>(SwFrame::GetDep());
1336}
1337
1339{
1340 return GetTextNodeFirst()->GetDoc();
1341}
1342
1344 sal_uInt16 const nScript, bool const bNoChar) const
1345{
1346 // a single character can be mapped uniquely!
1347 std::pair<SwTextNode const*, sal_Int32> const pos(MapViewToModel(nIndex));
1348 return pos.first->GetLang(pos.second, bNoChar ? 0 : 1, nScript);
1349}
1350
1352{
1353 if ( GetCacheIdx() != USHRT_MAX )
1354 {
1355 if (SwParaPortion *pPara = GetPara())
1356 pPara->ResetPreps();
1357 }
1358}
1359
1361{
1362 SwFrameSwapper aSwapper( this, true );
1363
1364 if( !getFrameArea().Width() && isFrameAreaDefinitionValid() && GetUpper()->isFrameAreaDefinitionValid() ) // invalid when stack overflows (StackHack)!
1365 {
1366// OSL_FAIL( "SwTextFrame::IsHiddenNow: thin frame" );
1367 return true;
1368 }
1369
1370 bool bHiddenCharsHidePara(false);
1371 bool bHiddenParaField(false);
1372 if (m_pMergedPara)
1373 {
1374 TextFrameIndex nHiddenStart(COMPLETE_STRING);
1375 TextFrameIndex nHiddenEnd(0);
1376 if (auto const pScriptInfo = GetScriptInfo())
1377 {
1378 pScriptInfo->GetBoundsOfHiddenRange(TextFrameIndex(0),
1379 nHiddenStart, nHiddenEnd);
1380 }
1381 else // ParaPortion is created in Format, but this is called earlier
1382 {
1383 SwScriptInfo aInfo;
1384 aInfo.InitScriptInfo(*m_pMergedPara->pFirstNode, m_pMergedPara.get(), IsRightToLeft());
1386 nHiddenStart, nHiddenEnd);
1387 }
1388 if (TextFrameIndex(0) == nHiddenStart &&
1389 TextFrameIndex(GetText().getLength()) <= nHiddenEnd)
1390 {
1391 bHiddenCharsHidePara = true;
1392 }
1393 sw::MergedAttrIter iter(*this);
1394 SwTextNode const* pNode(nullptr);
1395 int nNewResultWeight = 0;
1396 for (SwTextAttr const* pHint = iter.NextAttr(&pNode); pHint; pHint = iter.NextAttr(&pNode))
1397 {
1398 if (pHint->Which() == RES_TXTATR_FIELD)
1399 {
1400 // see also SwpHints::CalcHiddenParaField()
1401 const SwFormatField& rField = pHint->GetFormatField();
1402 int nCurWeight = pNode->GetDoc().FieldCanHideParaWeight(rField.GetField()->GetTyp()->Which());
1403 if (nCurWeight > nNewResultWeight)
1404 {
1405 nNewResultWeight = nCurWeight;
1406 bHiddenParaField = pNode->GetDoc().FieldHidesPara(*rField.GetField());
1407 }
1408 else if (nCurWeight == nNewResultWeight && bHiddenParaField)
1409 {
1410 // Currently, for both supported hiding types (HiddenPara, Database), "Don't hide"
1411 // takes precedence - i.e., if there's a "Don't hide" field of that weight, we only
1412 // care about fields of higher weight.
1413 bHiddenParaField = pNode->GetDoc().FieldHidesPara(*rField.GetField());
1414 }
1415 }
1416 }
1417 }
1418 else
1419 {
1420 bHiddenCharsHidePara = static_cast<SwTextNode const*>(SwFrame::GetDep())->HasHiddenCharAttribute( true );
1421 bHiddenParaField = static_cast<SwTextNode const*>(SwFrame::GetDep())->IsHiddenByParaField();
1422 }
1423 const SwViewShell* pVsh = getRootFrame()->GetCurrShell();
1424
1425 if ( pVsh && ( bHiddenCharsHidePara || bHiddenParaField ) )
1426 {
1427
1428 if (
1429 ( bHiddenParaField &&
1430 ( !pVsh->GetViewOptions()->IsShowHiddenPara() &&
1431 !pVsh->GetViewOptions()->IsFieldName() ) ) ||
1432 ( bHiddenCharsHidePara &&
1433 !pVsh->GetViewOptions()->IsShowHiddenChar() ) )
1434 {
1435 // in order to put the cursor in the body text, one paragraph must
1436 // be visible - check this for the 1st body paragraph
1437 if (IsInDocBody() && FindPrevCnt() == nullptr)
1438 {
1439 bool isAllHidden(true);
1440 for (SwContentFrame const* pNext = FindNextCnt(true);
1441 pNext != nullptr; pNext = pNext->FindNextCnt(true))
1442 {
1443 if (!pNext->IsTextFrame()
1444 || !static_cast<SwTextFrame const*>(pNext)->IsHiddenNow())
1445 {
1446 isAllHidden = false;
1447 break;
1448 }
1449 }
1450 if (isAllHidden)
1451 {
1452 SAL_INFO("sw.core", "unhiding one body paragraph");
1453 return false;
1454 }
1455 }
1456 return true;
1457 }
1458 }
1459
1460 return false;
1461}
1462
1465{
1466 OSL_ENSURE( !GetFollow() && IsHiddenNow(),
1467 "HideHidden on visible frame of hidden frame has follow" );
1468
1471
1472 // format information is obsolete
1473 ClearPara();
1474}
1475
1477{
1478 SwPageFrame *pPage = nullptr;
1479 sw::MergedAttrIter iter(*this);
1480 SwTextNode const* pNode(nullptr);
1481 for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
1482 {
1483 if (pHt->Which() == RES_TXTATR_FTN)
1484 {
1485 TextFrameIndex const nIdx(MapModelToView(pNode, pHt->GetStart()));
1486 if (nEnd < nIdx)
1487 break;
1488 if (nStart <= nIdx)
1489 {
1490 if (!pPage)
1491 pPage = FindPageFrame();
1492 pPage->RemoveFootnote( this, static_cast<const SwTextFootnote*>(pHt) );
1493 }
1494 }
1495 }
1496}
1497
1507bool sw_HideObj( const SwTextFrame& _rFrame,
1508 const RndStdIds _eAnchorType,
1509 SwFormatAnchor const& rFormatAnchor,
1510 SwAnchoredObject* _pAnchoredObj )
1511{
1512 bool bRet( true );
1513
1514 if (_eAnchorType == RndStdIds::FLY_AT_CHAR)
1515 {
1516 const IDocumentSettingAccess *const pIDSA = &_rFrame.GetDoc().getIDocumentSettingAccess();
1521 _rFrame.IsInDocBody() && !_rFrame.FindNextCnt() )
1522 {
1523 SwTextNode const& rNode(*rFormatAnchor.GetAnchorNode()->GetTextNode());
1524 assert(FrameContainsNode(_rFrame, rNode.GetIndex()));
1525 sal_Int32 const nObjAnchorPos(rFormatAnchor.GetAnchorContentOffset());
1526 const sal_Unicode cAnchorChar = nObjAnchorPos < rNode.Len()
1527 ? rNode.GetText()[nObjAnchorPos]
1528 : 0;
1529 if (cAnchorChar == CH_TXTATR_BREAKWORD)
1530 {
1531 const SwTextAttr* const pHint(
1532 rNode.GetTextAttrForCharAt(nObjAnchorPos, RES_TXTATR_FLYCNT));
1533 if ( pHint )
1534 {
1535 const SwFrameFormat* pFrameFormat =
1536 static_cast<const SwTextFlyCnt*>(pHint)->GetFlyCnt().GetFrameFormat();
1537 if ( pFrameFormat->Which() == RES_FLYFRMFMT )
1538 {
1539 SwNodeIndex nContentIndex = *(pFrameFormat->GetContent().GetContentIdx());
1540 ++nContentIndex;
1541 if ( nContentIndex.GetNode().IsNoTextNode() )
1542 {
1543 bRet = false;
1544 // set needed data structure values for object positioning
1545 SwRectFnSet aRectFnSet(&_rFrame);
1546 SwRect aLastCharRect( _rFrame.getFrameArea() );
1547 aRectFnSet.SetWidth( aLastCharRect, 1 );
1548 _pAnchoredObj->maLastCharRect = aLastCharRect;
1549 _pAnchoredObj->mnLastTopOfLine = aRectFnSet.GetTop(aLastCharRect);
1550 }
1551 }
1552 }
1553 }
1554 }
1555 }
1556
1557 return bRet;
1558}
1559
1571{
1572 if ( GetDrawObjs() )
1573 {
1574 if ( IsHiddenNow() )
1575 {
1576 // complete paragraph is hidden. Thus, hide all objects
1577 for (SwAnchoredObject* i : *GetDrawObjs())
1578 {
1579 SdrObject* pObj = i->DrawObj();
1580 SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
1581 // under certain conditions
1582 const RndStdIds eAnchorType( pContact->GetAnchorId() );
1583 if ((eAnchorType != RndStdIds::FLY_AT_CHAR) ||
1584 sw_HideObj(*this, eAnchorType, pContact->GetAnchorFormat(),
1585 i ))
1586 {
1587 pContact->MoveObjToInvisibleLayer( pObj );
1588 }
1589 }
1590 }
1591 else
1592 {
1593 // paragraph is visible, but can contain hidden text portion.
1594 // first we check if objects are allowed to be hidden:
1595 const SwViewShell* pVsh = getRootFrame()->GetCurrShell();
1596 const bool bShouldBeHidden = !pVsh || !pVsh->GetWin() ||
1597 !pVsh->GetViewOptions()->IsShowHiddenChar();
1598
1599 // Thus, show all objects, which are anchored at paragraph and
1600 // hide/show objects, which are anchored at/as character, according
1601 // to the visibility of the anchor character.
1602 for (SwAnchoredObject* i : *GetDrawObjs())
1603 {
1604 SdrObject* pObj = i->DrawObj();
1605 SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
1606 // Determine anchor type only once
1607 const RndStdIds eAnchorType( pContact->GetAnchorId() );
1608
1609 if (eAnchorType == RndStdIds::FLY_AT_PARA)
1610 {
1611 pContact->MoveObjToVisibleLayer( pObj );
1612 }
1613 else if ((eAnchorType == RndStdIds::FLY_AT_CHAR) ||
1614 (eAnchorType == RndStdIds::FLY_AS_CHAR))
1615 {
1616 sal_Int32 nHiddenStart;
1617 sal_Int32 nHiddenEnd;
1618 const SwFormatAnchor& rAnchorFormat = pContact->GetAnchorFormat();
1620 *rAnchorFormat.GetAnchorNode()->GetTextNode(),
1621 rAnchorFormat.GetAnchorContentOffset(), nHiddenStart, nHiddenEnd);
1622 // Under certain conditions
1623 if ( nHiddenStart != COMPLETE_STRING && bShouldBeHidden &&
1624 sw_HideObj(*this, eAnchorType, rAnchorFormat, i))
1625 {
1626 pContact->MoveObjToInvisibleLayer( pObj );
1627 }
1628 else
1629 pContact->MoveObjToVisibleLayer( pObj );
1630 }
1631 else
1632 {
1633 OSL_FAIL( "<SwTextFrame::HideAndShowObjects()> - object not anchored at/inside paragraph!?" );
1634 }
1635 }
1636 }
1637 }
1638
1639 if (IsFollow())
1640 {
1641 SwTextFrame *pMaster = FindMaster();
1642 OSL_ENSURE(pMaster, "SwTextFrame without master");
1643 if (pMaster)
1644 pMaster->HideAndShowObjects();
1645 }
1646}
1647
1654TextFrameIndex SwTextFrame::FindBrk(std::u16string_view aText,
1655 const TextFrameIndex nStart,
1656 const TextFrameIndex nEnd)
1657{
1658 sal_Int32 nFound = sal_Int32(nStart);
1659 const sal_Int32 nEndLine = std::min(sal_Int32(nEnd), sal_Int32(aText.size()) - 1);
1660
1661 // Skip all leading blanks.
1662 while( nFound <= nEndLine && ' ' == aText[nFound] )
1663 {
1664 nFound++;
1665 }
1666
1667 // A tricky situation with the TextAttr-Dummy-character (in this case "$"):
1668 // "Dr.$Meyer" at the beginning of the second line. Typing a blank after that
1669 // doesn't result in the word moving into first line, even though that would work.
1670 // For this reason we don't skip the dummy char.
1671 while( nFound <= nEndLine && ' ' != aText[nFound] )
1672 {
1673 nFound++;
1674 }
1675
1676 return TextFrameIndex(nFound);
1677}
1678
1680{
1681 if (nPos == TextFrameIndex(COMPLETE_STRING)) // the "not found" range
1682 return false;
1683// Silence over-eager warning emitted at least by GCC trunk towards 6:
1684#if defined __GNUC__ && !defined __clang__
1685#pragma GCC diagnostic push
1686#pragma GCC diagnostic ignored "-Wstrict-overflow"
1687#endif
1688 if (nLen != TextFrameIndex(COMPLETE_STRING) && GetOffset() > nPos + nLen) // the range preceded us
1689#if defined __GNUC__ && !defined __clang__
1690#pragma GCC diagnostic pop
1691#endif
1692 return false;
1693
1694 if( !GetFollow() ) // the range doesn't precede us,
1695 return true; // nobody follows us.
1696
1697 TextFrameIndex const nMax = GetFollow()->GetOffset();
1698
1699 // either the range overlap or our text has been deleted
1700 // sw_redlinehide: GetText() should be okay here because it has already
1701 // been updated in the INS/DEL hint case
1702 if (nMax > nPos || nMax > TextFrameIndex(GetText().getLength()))
1703 return true;
1704
1705 // changes made in the first line of a follow can modify the master
1706 const SwParaPortion* pPara = GetFollow()->GetPara();
1707 return pPara && ( nPos <= nMax + pPara->GetLen() );
1708}
1709
1710inline void SwTextFrame::InvalidateRange(const SwCharRange &aRange, const tools::Long nD)
1711{
1712 if ( IsIdxInside( aRange.Start(), aRange.Len() ) )
1713 InvalidateRange_( aRange, nD );
1714}
1715
1717{
1718 if ( !HasPara() )
1719 { InvalidateSize();
1720 return;
1721 }
1722
1723 SetWidow( false );
1724 SwParaPortion *pPara = GetPara();
1725
1726 bool bInv = false;
1727 if( 0 != nD )
1728 {
1729 // In nDelta the differences between old and new
1730 // linelengths are being added, that's why it's negative
1731 // if chars have been added and positive, if chars have
1732 // deleted
1733 pPara->SetDelta(pPara->GetDelta() + nD);
1734 bInv = true;
1735 }
1736 SwCharRange &rReformat = pPara->GetReformat();
1737 if(aRange != rReformat) {
1738 if (TextFrameIndex(COMPLETE_STRING) == rReformat.Len())
1739 rReformat = aRange;
1740 else
1741 rReformat += aRange;
1742 bInv = true;
1743 }
1744 if(bInv)
1745 {
1747 }
1748}
1749
1751{
1752 OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
1753 "SwTextFrame::CalcLineSpace with swapped frame!" );
1754
1755 if( IsLocked() || !HasPara() )
1756 return;
1757
1758 if( GetDrawObjs() ||
1759 GetTextNodeForParaProps()->GetSwAttrSet().GetFirstLineIndent().IsAutoFirst())
1760 {
1761 Init();
1762 return;
1763 }
1764
1765 SwParaPortion *const pPara(GetPara());
1766 assert(pPara);
1767 if (pPara->IsFixLineHeight())
1768 {
1769 Init();
1770 return;
1771 }
1772
1773 Size aNewSize( getFramePrintArea().SSize() );
1774
1775 SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this );
1776 SwTextFormatter aLine( this, &aInf );
1777 if( aLine.GetDropLines() )
1778 {
1779 Init();
1780 return;
1781 }
1782
1783 aLine.Top();
1784 aLine.RecalcRealHeight();
1785
1786 aNewSize.setHeight( (aLine.Y() - getFrameArea().Top()) + aLine.GetLineHeight() );
1787
1788 SwTwips nDelta = aNewSize.Height() - getFramePrintArea().Height();
1789 // Underflow with free-flying frames
1790 if( aInf.GetTextFly().IsOn() )
1791 {
1792 SwRect aTmpFrame( getFrameArea() );
1793 if( nDelta < 0 )
1794 aTmpFrame.Height( getFramePrintArea().Height() );
1795 else
1796 aTmpFrame.Height( aNewSize.Height() );
1797 if( aInf.GetTextFly().Relax( aTmpFrame ) )
1798 {
1799 Init();
1800 return;
1801 }
1802 }
1803
1804 if( !nDelta )
1805 return;
1806
1807 SwTextFrameBreak aBreak( this );
1808 if( GetFollow() || aBreak.IsBreakNow( aLine ) )
1809 {
1810 // if there is a Follow() or if we need to break here, reformat
1811 Init();
1812 }
1813 else
1814 {
1815 // everything is business as usual...
1816 pPara->SetPrepAdjust();
1817 pPara->SetPrep();
1818 }
1819}
1820
1821static void lcl_SetWrong( SwTextFrame& rFrame, SwTextNode const& rNode,
1822 sal_Int32 const nPos, sal_Int32 const nCnt, bool const bMove)
1823{
1824 if ( !rFrame.IsFollow() )
1825 {
1826 SwTextNode& rTextNode = const_cast<SwTextNode&>(rNode);
1827 sw::GrammarContact* pGrammarContact = sw::getGrammarContactFor(rTextNode);
1828 SwGrammarMarkUp* pWrongGrammar = pGrammarContact ?
1829 pGrammarContact->getGrammarCheck( rTextNode, false ) :
1830 rTextNode.GetGrammarCheck();
1831 bool bGrammarProxy = pWrongGrammar != rTextNode.GetGrammarCheck();
1832 if( bMove )
1833 {
1834 if( rTextNode.GetWrong() )
1835 rTextNode.GetWrong()->Move( nPos, nCnt );
1836 if( pWrongGrammar )
1837 pWrongGrammar->MoveGrammar( nPos, nCnt );
1838 if( bGrammarProxy && rTextNode.GetGrammarCheck() )
1839 rTextNode.GetGrammarCheck()->MoveGrammar( nPos, nCnt );
1840 if( rTextNode.GetSmartTags() )
1841 rTextNode.GetSmartTags()->Move( nPos, nCnt );
1842 }
1843 else
1844 {
1845 if( rTextNode.GetWrong() )
1846 rTextNode.GetWrong()->Invalidate( nPos, nCnt );
1847 if( pWrongGrammar )
1848 pWrongGrammar->Invalidate( nPos, nCnt );
1849 if( rTextNode.GetSmartTags() )
1850 rTextNode.GetSmartTags()->Invalidate( nPos, nCnt );
1851 }
1852 const sal_Int32 nEnd = nPos + (nCnt > 0 ? nCnt : 1 );
1853 if ( !rTextNode.GetWrong() && !rTextNode.IsWrongDirty() )
1854 {
1855 rTextNode.SetWrong( std::make_unique<SwWrongList>( WRONGLIST_SPELL ) );
1856 rTextNode.GetWrong()->SetInvalid( nPos, nEnd );
1857 }
1858 if ( !rTextNode.GetSmartTags() && !rTextNode.IsSmartTagDirty() )
1859 {
1860 rTextNode.SetSmartTags( std::make_unique<SwWrongList>( WRONGLIST_SMARTTAG ) );
1861 rTextNode.GetSmartTags()->SetInvalid( nPos, nEnd );
1862 }
1864 rTextNode.SetGrammarCheckDirty( true );
1865 rTextNode.SetWordCountDirty( true );
1866 rTextNode.SetAutoCompleteWordDirty( true );
1867 rTextNode.SetSmartTagDirty( true );
1868 }
1869
1870 SwRootFrame *pRootFrame = rFrame.getRootFrame();
1871 if (pRootFrame)
1872 {
1873 pRootFrame->SetNeedGrammarCheck( true );
1874 }
1875
1876 SwPageFrame *pPage = rFrame.FindPageFrame();
1877 if( pPage )
1878 {
1879 pPage->InvalidateSpelling();
1881 pPage->InvalidateWordCount();
1882 pPage->InvalidateSmartTags();
1883 }
1884}
1885
1886static void lcl_SetScriptInval(SwTextFrame& rFrame, TextFrameIndex const nPos)
1887{
1888 if( rFrame.GetPara() )
1890}
1891
1892// note: SwClientNotify will be called once for every frame => just fix own Ofst
1893static void lcl_ModifyOfst(SwTextFrame & rFrame,
1894 TextFrameIndex const nPos, TextFrameIndex const nLen,
1895 TextFrameIndex (* op)(TextFrameIndex const&, TextFrameIndex const&))
1896{
1897 assert(nLen != TextFrameIndex(COMPLETE_STRING));
1898 if (rFrame.IsFollow() && nPos < rFrame.GetOffset())
1899 {
1900 rFrame.ManipOfst( std::max(nPos, op(rFrame.GetOffset(), nLen)) );
1901 assert(sal_Int32(rFrame.GetOffset()) <= rFrame.GetText().getLength());
1902 }
1903}
1904
1905namespace {
1906
1907void UpdateMergedParaForMove(sw::MergedPara & rMerged,
1908 SwTextFrame & rTextFrame,
1909 bool & o_rbRecalcFootnoteFlag,
1910 SwTextNode const& rDestNode,
1911 SwTextNode const& rNode,
1912 sal_Int32 const nDestStart,
1913 sal_Int32 const nSourceStart,
1914 sal_Int32 const nLen)
1915{
1916 std::vector<std::pair<sal_Int32, sal_Int32>> deleted;
1917 sal_Int32 const nSourceEnd(nSourceStart + nLen);
1918 sal_Int32 nLastEnd(0);
1919 for (const auto& rExt : rMerged.extents)
1920 {
1921 if (rExt.pNode == &rNode)
1922 {
1923 sal_Int32 const nStart(std::max(nLastEnd, nSourceStart));
1924 sal_Int32 const nEnd(std::min(rExt.nStart, nSourceEnd));
1925 if (nStart < nEnd)
1926 {
1927 deleted.emplace_back(nStart, nEnd);
1928 }
1929 nLastEnd = rExt.nEnd;
1930 if (nSourceEnd <= rExt.nEnd)
1931 {
1932 break;
1933 }
1934 }
1935 else if (rNode.GetIndex() < rExt.pNode->GetIndex())
1936 {
1937 break;
1938 }
1939 }
1940 if (nLastEnd != rNode.Len()) // without nLen, string yet to be removed
1941 {
1942 if (nLastEnd < nSourceEnd)
1943 {
1944 deleted.emplace_back(std::max(nLastEnd, nSourceStart), nSourceEnd);
1945 }
1946 }
1947 if (deleted.empty())
1948 return;
1949
1950 o_rbRecalcFootnoteFlag = true;
1951 for (auto const& it : deleted)
1952 {
1953 sal_Int32 const nStart(it.first - nSourceStart + nDestStart);
1954 TextFrameIndex const nDeleted = UpdateMergedParaForDelete(rMerged, false,
1955 rDestNode, nStart, it.second - it.first);
1956//FIXME asserts valid for join - but if called from split, the new node isn't there yet and it will be added later... assert(nDeleted);
1957// assert(nDeleted == it.second - it.first);
1958 if(nDeleted)
1959 {
1960 // InvalidateRange/lcl_SetScriptInval was called sufficiently for InsertText
1961 lcl_SetWrong(rTextFrame, rDestNode, nStart, it.first - it.second, false);
1962 TextFrameIndex const nIndex(sw::MapModelToView(rMerged, &rDestNode, nStart));
1963 lcl_ModifyOfst(rTextFrame, nIndex, nDeleted, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
1964 }
1965 }
1966}
1967
1968} // namespace
1969
1974#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1975static bool isA11yRelevantAttribute(sal_uInt16 nWhich)
1976{
1977 return nWhich != RES_CHRATR_RSID;
1978}
1979
1980static bool hasA11yRelevantAttribute( const std::vector<sal_uInt16>& rWhichFmtAttr )
1981{
1982 for( sal_uInt16 nWhich : rWhichFmtAttr )
1983 if ( isA11yRelevantAttribute( nWhich ) )
1984 return true;
1985
1986 return false;
1987}
1988#endif // ENABLE_WASM_STRIP_ACCESSIBILITY
1989
1990// Note: for now this overrides SwClient::SwClientNotify; the intermediary
1991// classes still override SwClient::Modify, which should continue to work
1992// as their implementation of SwClientNotify is SwClient's which calls Modify.
1993// Therefore we also don't need to call SwClient::SwClientNotify(rModify, rHint)
1994// because that's all it does, and this implementation calls
1995// SwContentFrame::SwClientNotify() when appropriate.
1996void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
1997{
1998 SfxPoolItem const* pOld(nullptr);
1999 SfxPoolItem const* pNew(nullptr);
2000 sw::MoveText const* pMoveText(nullptr);
2001 sw::InsertText const* pInsertText(nullptr);
2002 sw::DeleteText const* pDeleteText(nullptr);
2003 sw::DeleteChar const* pDeleteChar(nullptr);
2004 sw::RedlineDelText const* pRedlineDelText(nullptr);
2005 sw::RedlineUnDelText const* pRedlineUnDelText(nullptr);
2006
2007 sal_uInt16 nWhich = 0;
2008 if (rHint.GetId() == SfxHintId::SwLegacyModify)
2009 {
2010 auto pHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
2011 pOld = pHint->m_pOld;
2012 pNew = pHint->m_pNew;
2013 nWhich = pHint->GetWhich();
2014 }
2015 else if (rHint.GetId() == SfxHintId::SwInsertText)
2016 {
2017 pInsertText = static_cast<const sw::InsertText*>(&rHint);
2018 }
2019 else if (rHint.GetId() == SfxHintId::SwDeleteText)
2020 {
2021 pDeleteText = static_cast<const sw::DeleteText*>(&rHint);
2022 }
2023 else if (rHint.GetId() == SfxHintId::SwDeleteChar)
2024 {
2025 pDeleteChar = static_cast<const sw::DeleteChar*>(&rHint);
2026 }
2027 else if (rHint.GetId() == SfxHintId::SwDocPosUpdateAtIndex)
2028 {
2029 auto pDocPosAt = static_cast<const sw::DocPosUpdateAtIndex*>(&rHint);
2030 Broadcast(SfxHint()); // notify SwAccessibleParagraph
2031 if(IsLocked())
2032 return;
2033 if(pDocPosAt->m_nDocPos > getFrameArea().Top())
2034 return;
2036 &pDocPosAt->m_rNode,
2037 pDocPosAt->m_nIndex));
2039 return;
2040 }
2041 else if (auto const pHt = dynamic_cast<sw::MoveText const*>(&rHint))
2042 {
2043 pMoveText = pHt;
2044 }
2045 else if (auto const pHynt = dynamic_cast<sw::RedlineDelText const*>(&rHint))
2046 {
2047 pRedlineDelText = pHynt;
2048 }
2049 else if (auto const pHnt = dynamic_cast<sw::RedlineUnDelText const*>(&rHint))
2050 {
2051 pRedlineUnDelText = pHnt;
2052 }
2053 else
2054 {
2055 assert(!"unexpected hint");
2056 }
2057
2058 if (m_pMergedPara)
2059 {
2060 assert(m_pMergedPara->listener.IsListeningTo(&rModify));
2061 }
2062
2063 SwTextNode const& rNode(static_cast<SwTextNode const&>(rModify));
2064
2065 // modifications concerning frame attributes are processed by the base class
2066 if( IsInRange( aFrameFormatSetRange, nWhich ) || RES_FMT_CHG == nWhich )
2067 {
2068 if (m_pMergedPara)
2069 { // ignore item set changes that don't apply
2070 SwTextNode const*const pAttrNode(
2071 (nWhich == RES_PAGEDESC || nWhich == RES_BREAK)
2072 ? m_pMergedPara->pFirstNode
2073 : m_pMergedPara->pParaPropsNode);
2074 if (pAttrNode != &rModify)
2075 {
2076 return;
2077 }
2078 }
2080 if( nWhich == RES_FMT_CHG && getRootFrame()->GetCurrShell() )
2081 {
2082 // collection has changed
2083 Prepare();
2085 lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
2086 SetDerivedR2L( false );
2088 // Force complete paint due to existing indents.
2091 }
2092 return;
2093 }
2094
2095 if (m_pMergedPara && m_pMergedPara->pParaPropsNode != &rModify)
2096 {
2097 if (isPARATR(nWhich) || isPARATR_LIST(nWhich)) // FRMATR handled above
2098 {
2099 return; // ignore it
2100 }
2101 }
2102
2103 Broadcast(SfxHint()); // notify SwAccessibleParagraph
2104
2105 // while locked ignore all modifications
2106 if( IsLocked() )
2107 return;
2108
2109 // save stack
2110 // warning: one has to ensure that all variables are set
2112 TextFrameIndex nLen;
2113 bool bSetFieldsDirty = false;
2114 bool bRecalcFootnoteFlag = false;
2115
2116 if (pRedlineDelText)
2117 {
2118 if (m_pMergedPara)
2119 {
2120 sal_Int32 const nNPos = pRedlineDelText->nStart;
2121 sal_Int32 const nNLen = pRedlineDelText->nLen;
2122 nPos = MapModelToView(&rNode, nNPos);
2123 // update merged before doing anything else
2124 nLen = UpdateMergedParaForDelete(*m_pMergedPara, false, rNode, nNPos, nNLen);
2125 const sal_Int32 m = -nNLen;
2126 if (nLen && IsIdxInside(nPos, nLen))
2127 {
2129 }
2130 lcl_SetWrong( *this, rNode, nNPos, m, false );
2131 if (nLen)
2132 {
2133 lcl_SetScriptInval( *this, nPos );
2134 bSetFieldsDirty = bRecalcFootnoteFlag = true;
2135 lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
2136 }
2137 }
2138 }
2139 else if (pRedlineUnDelText)
2140 {
2141 if (m_pMergedPara)
2142 {
2143 sal_Int32 const nNPos = pRedlineUnDelText->nStart;
2144 sal_Int32 const nNLen = pRedlineUnDelText->nLen;
2145 nPos = MapModelToView(&rNode, nNPos);
2146 nLen = UpdateMergedParaForInsert(*m_pMergedPara, false, rNode, nNPos, nNLen);
2147 if (IsIdxInside(nPos, nLen))
2148 {
2149 if (!nLen)
2150 {
2151 // Refresh NumPortions even when line is empty!
2152 if (nPos)
2154 else
2155 Prepare();
2156 }
2157 else
2158 InvalidateRange_( SwCharRange( nPos, nLen ), nNLen );
2159 }
2160 lcl_SetWrong( *this, rNode, nNPos, nNLen, false );
2161 lcl_SetScriptInval( *this, nPos );
2162 bSetFieldsDirty = true;
2163 lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>);
2164 }
2165 }
2166 else if (pMoveText)
2167 {
2168 if (m_pMergedPara
2169 && m_pMergedPara->pFirstNode->GetIndex() <= pMoveText->pDestNode->GetIndex()
2170 && pMoveText->pDestNode->GetIndex() <= m_pMergedPara->pLastNode->GetIndex())
2171 { // if it's not 2 nodes in merged frame, assume the target node doesn't have frames at all
2172 assert(abs(rNode.GetIndex() - pMoveText->pDestNode->GetIndex()) == SwNodeOffset(1));
2173 UpdateMergedParaForMove(*m_pMergedPara,
2174 *this,
2175 bRecalcFootnoteFlag,
2176 *pMoveText->pDestNode, rNode,
2177 pMoveText->nDestStart,
2178 pMoveText->nSourceStart,
2179 pMoveText->nLen);
2180 }
2181 else
2182 {
2183 // there is a situation where this is okay: from JoinNext, which will then call CheckResetRedlineMergeFlag, which will then create merged from scratch for this frame
2184 // assert(!m_pMergedPara || !getRootFrame()->IsHideRedlines() || !pMoveText->pDestNode->getLayoutFrame(getRootFrame()));
2185 }
2186 }
2187 else if (pInsertText)
2188 {
2189 nPos = MapModelToView(&rNode, pInsertText->nPos);
2190 // unlike redlines, inserting into fieldmark must be explicitly handled
2191 bool isHidden(false);
2192 switch (getRootFrame()->GetFieldmarkMode())
2193 {
2195 isHidden = pInsertText->isInsideFieldmarkResult;
2196 break;
2198 isHidden = pInsertText->isInsideFieldmarkCommand;
2199 break;
2200 case sw::FieldmarkMode::ShowBoth: // just to avoid the warning
2201 break;
2202 }
2203 if (!isHidden)
2204 {
2205 nLen = TextFrameIndex(pInsertText->nLen);
2206 if (m_pMergedPara)
2207 {
2208 UpdateMergedParaForInsert(*m_pMergedPara, true, rNode, pInsertText->nPos, pInsertText->nLen);
2209 }
2210 if( IsIdxInside( nPos, nLen ) )
2211 {
2212 if( !nLen )
2213 {
2214 // Refresh NumPortions even when line is empty!
2215 if( nPos )
2217 else
2218 Prepare();
2219 }
2220 else
2221 InvalidateRange_( SwCharRange( nPos, nLen ), pInsertText->nLen );
2222 }
2223 lcl_SetScriptInval( *this, nPos );
2224 bSetFieldsDirty = true;
2225 lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>);
2226 }
2227 lcl_SetWrong( *this, rNode, pInsertText->nPos, pInsertText->nLen, true );
2228 }
2229 else if (pDeleteText)
2230 {
2231 nPos = MapModelToView(&rNode, pDeleteText->nStart);
2232 if (m_pMergedPara)
2233 { // update merged before doing anything else
2234 nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, pDeleteText->nStart, pDeleteText->nLen);
2235 }
2236 else
2237 {
2238 nLen = TextFrameIndex(pDeleteText->nLen);
2239 }
2240 const sal_Int32 m = -pDeleteText->nLen;
2241 if ((!m_pMergedPara || nLen) && IsIdxInside(nPos, nLen))
2242 {
2243 if( !nLen )
2245 else
2247 }
2248 lcl_SetWrong( *this, rNode, pDeleteText->nStart, m, true );
2249 if (nLen)
2250 {
2251 lcl_SetScriptInval( *this, nPos );
2252 bSetFieldsDirty = bRecalcFootnoteFlag = true;
2253 lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
2254 }
2255 }
2256 else if (pDeleteChar)
2257 {
2258 nPos = MapModelToView(&rNode, pDeleteChar->m_nPos);
2259 if (m_pMergedPara)
2260 {
2261 nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, pDeleteChar->m_nPos, 1);
2262 }
2263 else
2264 {
2265 nLen = TextFrameIndex(1);
2266 }
2267 lcl_SetWrong( *this, rNode, pDeleteChar->m_nPos, -1, true );
2268 if (nLen)
2269 {
2270 InvalidateRange( SwCharRange(nPos, nLen), -1 );
2271 lcl_SetScriptInval( *this, nPos );
2272 bSetFieldsDirty = bRecalcFootnoteFlag = true;
2273 lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
2274 }
2275 }
2276 else switch (nWhich)
2277 {
2278 case RES_LINENUMBER:
2279 {
2280 assert(false); // should have been forwarded to SwContentFrame
2282 }
2283 break;
2284 case RES_UPDATE_ATTR:
2285 {
2286 const SwUpdateAttr* pNewUpdate = static_cast<const SwUpdateAttr*>(pNew);
2287
2288 sal_Int32 const nNPos = pNewUpdate->getStart();
2289 sal_Int32 const nNLen = pNewUpdate->getEnd() - nNPos;
2290 nPos = MapModelToView(&rNode, nNPos);
2291 nLen = MapModelToView(&rNode, nNPos + nNLen) - nPos;
2292 if( IsIdxInside( nPos, nLen ) )
2293 {
2294 // We need to reformat anyways, even if the invalidated
2295 // range is empty.
2296 // E.g.: empty line, set 14 pt!
2297
2298 // FootnoteNumbers need to be formatted
2299 if( !nLen )
2300 nLen = TextFrameIndex(1);
2301
2303 const sal_uInt16 nTmp = pNewUpdate->getWhichAttr();
2304
2305 if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_INETFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp ||
2306 RES_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp )
2307 {
2308 lcl_SetWrong( *this, rNode, nNPos, nNPos + nNLen, false );
2309 lcl_SetScriptInval( *this, nPos );
2310 }
2311 }
2312
2313#if !ENABLE_WASM_STRIP_ACCESSIBILITY
2314 if( isA11yRelevantAttribute( pNewUpdate->getWhichAttr() ) &&
2315 hasA11yRelevantAttribute( pNewUpdate->getFmtAttrs() ) )
2316 {
2317 SwViewShell* pViewSh = getRootFrame() ? getRootFrame()->GetCurrShell() : nullptr;
2318 if ( pViewSh )
2319 {
2320 pViewSh->InvalidateAccessibleParaAttrs( *this );
2321 }
2322 }
2323#endif
2324 }
2325 break;
2326 case RES_OBJECTDYING:
2327 break;
2328
2330 {
2331 CalcLineSpace();
2334 if( IsInSct() && !GetPrev() )
2335 {
2336 SwSectionFrame *pSect = FindSctFrame();
2337 if( pSect->ContainsAny() == this )
2338 pSect->InvalidatePrt();
2339 }
2340
2341 // i#11859
2342 // (1) Also invalidate next frame on next page/column.
2343 // (2) Skip empty sections and hidden paragraphs
2344 // Thus, use method <InvalidateNextPrtArea()>
2346
2348 }
2349 break;
2350
2351 case RES_TXTATR_FIELD:
2353 {
2354 sal_Int32 const nNPos = static_cast<const SwFormatField*>(pNew)->GetTextField()->GetStart();
2355 nPos = MapModelToView(&rNode, nNPos);
2357 {
2358 if( pNew == pOld )
2359 {
2360 // only repaint
2361 // opt: invalidate window?
2364 }
2365 else
2367 }
2368 bSetFieldsDirty = true;
2369 // ST2
2370 if ( SwSmartTagMgr::Get().IsSmartTagsEnabled() )
2371 lcl_SetWrong( *this, rNode, nNPos, nNPos + 1, false );
2372 }
2373 break;
2374
2375 case RES_TXTATR_FTN :
2376 {
2377 if (!IsInFootnote())
2378 { // the hint may be sent from the anchor node, or from a
2379 // node in the footnote; the anchor index is only valid in the
2380 // anchor node!
2381 assert(rNode == static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote()->GetTextNode());
2382 nPos = MapModelToView(&rNode,
2383 static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote()->GetStart());
2384 }
2385#ifdef _MSC_VER
2386 else nPos = TextFrameIndex(42); // shut up MSVC 2017 spurious warning C4701
2387#endif
2389 Prepare( PrepareHint::FootnoteInvalidation, static_cast<const SwFormatFootnote*>(pNew)->GetTextFootnote() );
2390 break;
2391 }
2392
2393 case RES_ATTRSET_CHG:
2394 {
2396
2397 const SwAttrSet& rNewSet = *static_cast<const SwAttrSetChg*>(pNew)->GetChgSet();
2398 int nClear = 0;
2399 sal_uInt16 nCount = rNewSet.Count();
2400
2401 if( const SwFormatFootnote* pItem = rNewSet.GetItemIfSet( RES_TXTATR_FTN, false ) )
2402 {
2403 nPos = MapModelToView(&rNode, pItem->GetTextFootnote()->GetStart());
2406 nClear = 0x01;
2407 --nCount;
2408 }
2409
2410 if( const SwFormatField* pItem = rNewSet.GetItemIfSet( RES_TXTATR_FIELD, false ) )
2411 {
2412 nPos = MapModelToView(&rNode, pItem->GetTextField()->GetStart());
2414 {
2415 const SfxPoolItem* pOldItem = pOld ?
2416 &(static_cast<const SwAttrSetChg*>(pOld)->GetChgSet()->Get(RES_TXTATR_FIELD)) : nullptr;
2417 if( pItem == pOldItem )
2418 {
2421 }
2422 else
2424 }
2425 nClear |= 0x02;
2426 --nCount;
2427 }
2428 bool bLineSpace = SfxItemState::SET == rNewSet.GetItemState(
2429 RES_PARATR_LINESPACING, false ),
2430 bRegister = SfxItemState::SET == rNewSet.GetItemState(
2431 RES_PARATR_REGISTER, false );
2432 if ( bLineSpace || bRegister )
2433 {
2434 if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2435 {
2437 CalcLineSpace();
2440
2441 // i#11859
2442 // (1) Also invalidate next frame on next page/column.
2443 // (2) Skip empty sections and hidden paragraphs
2444 // Thus, use method <InvalidateNextPrtArea()>
2446
2448 }
2449 nClear |= 0x04;
2450 if ( bLineSpace )
2451 {
2452 --nCount;
2453 if ((!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2454 && IsInSct() && !GetPrev())
2455 {
2456 SwSectionFrame *pSect = FindSctFrame();
2457 if( pSect->ContainsAny() == this )
2458 pSect->InvalidatePrt();
2459 }
2460 }
2461 if ( bRegister )
2462 --nCount;
2463 }
2464 if ( SfxItemState::SET == rNewSet.GetItemState( RES_PARATR_SPLIT,
2465 false ))
2466 {
2467 if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2468 {
2469 if (GetPrev())
2470 CheckKeep();
2471 Prepare();
2473 }
2474 nClear |= 0x08;
2475 --nCount;
2476 }
2477
2478 if( SfxItemState::SET == rNewSet.GetItemState( RES_BACKGROUND, false)
2479 && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
2480 && !IsFollow() && GetDrawObjs() )
2481 {
2482 SwSortedObjs *pObjs = GetDrawObjs();
2483 for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i )
2484 {
2485 SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
2486 if ( auto pFly = pAnchoredObj->DynCastFlyFrame() )
2487 {
2488 if( !pFly->IsFlyInContentFrame() )
2489 {
2490 const SvxBrushItem &rBack =
2491 pFly->GetAttrSet()->GetBackground();
2492 // #GetTransChg#
2493 // following condition determines, if the fly frame
2494 // "inherites" the background color of text frame.
2495 // This is the case, if fly frame background
2496 // color is "no fill"/"auto fill" and if the fly frame
2497 // has no background graphic.
2498 // Thus, check complete fly frame background
2499 // color and *not* only its transparency value
2500 if ( (rBack.GetColor() == COL_TRANSPARENT) &&
2501 rBack.GetGraphicPos() == GPOS_NONE )
2502 {
2503 pFly->SetCompletePaint();
2504 pFly->InvalidatePage();
2505 }
2506 }
2507 }
2508 }
2509 }
2510
2511 if ( SfxItemState::SET ==
2512 rNewSet.GetItemState( RES_TXTATR_CHARFMT, false ) )
2513 {
2514 lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
2516 }
2517 else if ( SfxItemState::SET ==
2518 rNewSet.GetItemState( RES_CHRATR_LANGUAGE, false ) ||
2519 SfxItemState::SET ==
2520 rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, false ) ||
2521 SfxItemState::SET ==
2522 rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, false ) )
2523 lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false );
2524 else if ( SfxItemState::SET ==
2525 rNewSet.GetItemState( RES_CHRATR_FONT, false ) ||
2526 SfxItemState::SET ==
2527 rNewSet.GetItemState( RES_CHRATR_CJK_FONT, false ) ||
2528 SfxItemState::SET ==
2529 rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) )
2531 else if ( SfxItemState::SET ==
2532 rNewSet.GetItemState( RES_FRAMEDIR, false )
2533 && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify))
2534 {
2535 SetDerivedR2L( false );
2537 // Force complete paint due to existing indents.
2539 }
2540
2541 if( nCount )
2542 {
2543 if( getRootFrame()->GetCurrShell() )
2544 {
2545 Prepare();
2547 }
2548
2549 if (nClear || (m_pMergedPara &&
2550 (m_pMergedPara->pParaPropsNode != &rModify ||
2551 m_pMergedPara->pFirstNode != &rModify)))
2552 {
2553 assert(pOld);
2554 SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
2555 SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
2556
2557 if (m_pMergedPara && m_pMergedPara->pParaPropsNode != &rModify)
2558 {
2559 for (sal_uInt16 i = RES_PARATR_BEGIN; i != RES_FRMATR_END; ++i)
2560 {
2561 if (i != RES_BREAK && i != RES_PAGEDESC)
2562 {
2563 aOldSet.ClearItem(i);
2564 aNewSet.ClearItem(i);
2565 }
2566 }
2567 for (sal_uInt16 i = XATTR_FILL_FIRST; i <= XATTR_FILL_LAST; ++i)
2568 {
2569 aOldSet.ClearItem(i);
2570 aNewSet.ClearItem(i);
2571 }
2572 }
2573 if (m_pMergedPara && m_pMergedPara->pFirstNode != &rModify)
2574 {
2575 aOldSet.ClearItem(RES_BREAK);
2576 aNewSet.ClearItem(RES_BREAK);
2577 aOldSet.ClearItem(RES_PAGEDESC);
2578 aNewSet.ClearItem(RES_PAGEDESC);
2579 }
2580
2581 if( 0x01 & nClear )
2582 {
2583 aOldSet.ClearItem( RES_TXTATR_FTN );
2584 aNewSet.ClearItem( RES_TXTATR_FTN );
2585 }
2586 if( 0x02 & nClear )
2587 {
2588 aOldSet.ClearItem( RES_TXTATR_FIELD );
2589 aNewSet.ClearItem( RES_TXTATR_FIELD );
2590 }
2591 if ( 0x04 & nClear )
2592 {
2593 if ( bLineSpace )
2594 {
2597 }
2598 if ( bRegister )
2599 {
2600 aOldSet.ClearItem( RES_PARATR_REGISTER );
2601 aNewSet.ClearItem( RES_PARATR_REGISTER );
2602 }
2603 }
2604 if ( 0x08 & nClear )
2605 {
2606 aOldSet.ClearItem( RES_PARATR_SPLIT );
2607 aNewSet.ClearItem( RES_PARATR_SPLIT );
2608 }
2609 if (aOldSet.Count() || aNewSet.Count())
2610 {
2611 SwContentFrame::SwClientNotify(rModify, sw::LegacyModifyHint(&aOldSet, &aNewSet));
2612 }
2613 }
2614 else
2616 }
2617
2618#if !ENABLE_WASM_STRIP_ACCESSIBILITY
2619 if (isA11yRelevantAttribute(nWhich))
2620 {
2621 SwViewShell* pViewSh = getRootFrame() ? getRootFrame()->GetCurrShell() : nullptr;
2622 if ( pViewSh )
2623 {
2624 pViewSh->InvalidateAccessibleParaAttrs( *this );
2625 }
2626 }
2627#endif
2628 }
2629 break;
2630 case RES_PARATR_SPLIT:
2631 if ( GetPrev() )
2632 CheckKeep();
2633 Prepare();
2634 bSetFieldsDirty = true;
2635 break;
2636 case RES_FRAMEDIR :
2637 assert(false); // should have been forwarded to SwContentFrame
2638 SetDerivedR2L( false );
2640 break;
2641 default:
2642 {
2643 Prepare();
2645 if ( !nWhich )
2646 {
2647 // is called by e. g. HiddenPara with 0
2648 SwFrame *pNxt = FindNext();
2649 if ( nullptr != pNxt )
2650 pNxt->InvalidatePrt();
2651 }
2652 }
2653 } // switch
2654
2655 if( bSetFieldsDirty )
2657
2658 if ( bRecalcFootnoteFlag )
2660}
2661
2663{
2664 if ( RES_VIRTPAGENUM_INFO == rHint.Which() && IsInDocBody() && ! IsFollow() )
2665 {
2666 SwVirtPageNumInfo &rInfo = static_cast<SwVirtPageNumInfo&>(rHint);
2667 const SwPageFrame *pPage = FindPageFrame();
2668 if ( pPage )
2669 {
2670 if ( pPage == rInfo.GetOrigPage() && !GetPrev() )
2671 {
2672 // this should be the one
2673 // (could only differ temporarily; is that disturbing?)
2674 rInfo.SetInfo( pPage, this );
2675 return false;
2676 }
2677 if ( pPage->GetPhyPageNum() < rInfo.GetOrigPage()->GetPhyPageNum() &&
2678 (!rInfo.GetPage() || pPage->GetPhyPageNum() > rInfo.GetPage()->GetPhyPageNum()))
2679 {
2680 // this could be the one
2681 rInfo.SetInfo( pPage, this );
2682 }
2683 }
2684 }
2685 return true;
2686}
2687
2688void SwTextFrame::PrepWidows( const sal_uInt16 nNeed, bool bNotify )
2689{
2690 OSL_ENSURE(GetFollow() && nNeed, "+SwTextFrame::Prepare: lost all friends");
2691
2692 SwParaPortion *pPara = GetPara();
2693 if ( !pPara )
2694 return;
2695 pPara->SetPrepWidows();
2696
2697 sal_uInt16 nHave = nNeed;
2698
2699 // We yield a few lines and shrink in CalcPreps()
2700 SwSwapIfNotSwapped swap( this );
2701
2702 SwTextSizeInfo aInf( this );
2703 SwTextMargin aLine( this, &aInf );
2704 aLine.Bottom();
2705 TextFrameIndex nTmpLen = aLine.GetCurr()->GetLen();
2706 while( nHave && aLine.PrevLine() )
2707 {
2708 if( nTmpLen )
2709 --nHave;
2710 nTmpLen = aLine.GetCurr()->GetLen();
2711 }
2712
2713 // If it's certain that we can yield lines, the Master needs
2714 // to check the widow rule
2715 if( !nHave )
2716 {
2717 bool bSplit = true;
2718 if( !IsFollow() ) // only a master decides about orphans
2719 {
2720 const WidowsAndOrphans aWidOrp( this );
2721 bSplit = ( aLine.GetLineNr() >= aWidOrp.GetOrphansLines() &&
2722 aLine.GetLineNr() >= aLine.GetDropLines() );
2723 }
2724
2725 if( bSplit )
2726 {
2727 GetFollow()->SetOffset( aLine.GetEnd() );
2728 aLine.TruncLines( true );
2729 if( pPara->IsFollowField() )
2730 GetFollow()->SetFieldFollow( true );
2731 }
2732 }
2733 if ( bNotify )
2734 {
2737 }
2738}
2739
2740static bool lcl_ErgoVadis(SwTextFrame* pFrame, TextFrameIndex & rPos, const PrepareHint ePrep)
2741{
2742 const SwFootnoteInfo &rFootnoteInfo = pFrame->GetDoc().GetFootnoteInfo();
2743 if( ePrep == PrepareHint::ErgoSum )
2744 {
2745 if( rFootnoteInfo.m_aErgoSum.isEmpty() )
2746 return false;
2747 rPos = pFrame->GetOffset();
2748 }
2749 else
2750 {
2751 if( rFootnoteInfo.m_aQuoVadis.isEmpty() )
2752 return false;
2753 if( pFrame->HasFollow() )
2754 rPos = pFrame->GetFollow()->GetOffset();
2755 else
2756 rPos = TextFrameIndex(pFrame->GetText().getLength());
2757 if( rPos )
2758 --rPos; // our last character
2759 }
2760 return true;
2761}
2762
2763// Silence over-eager warning emitted at least by GCC 5.3.1
2764#if defined __GNUC__ && !defined __clang__
2765# pragma GCC diagnostic push
2766# pragma GCC diagnostic ignored "-Wstrict-overflow"
2767#endif
2768bool SwTextFrame::Prepare( const PrepareHint ePrep, const void* pVoid,
2769 bool bNotify )
2770{
2771 bool bParaPossiblyInvalid = false;
2772
2773 SwFrameSwapper aSwapper( this, false );
2774
2775 if ( IsEmpty() )
2776 {
2777 switch ( ePrep )
2778 {
2780 SetInvalidVert( true ); // Test
2781 [[fallthrough]];
2784 case PrepareHint::FootnoteInvalidationGone : return bParaPossiblyInvalid;
2785
2787 {
2788 // We also need an InvalidateSize for Areas (with and without columns),
2789 // so that we format and bUndersized is set (if needed)
2790 if( IsInFly() || IsInSct() )
2791 {
2792 SwTwips nTmpBottom = GetUpper()->getFrameArea().Top() +
2794 if( nTmpBottom < getFrameArea().Bottom() )
2795 break;
2796 }
2797 // Are there any free-flying frames on this page?
2798 SwTextFly aTextFly( this );
2799 if( aTextFly.IsOn() )
2800 {
2801 // Does any free-flying frame overlap?
2802 if ( aTextFly.Relax() || IsUndersized() )
2803 break;
2804 }
2805 if (GetTextNodeForParaProps()->GetSwAttrSet().GetRegister().GetValue())
2806 break;
2807
2808 SwTextGridItem const*const pGrid(GetGridItem(FindPageFrame()));
2809 if (pGrid && GetTextNodeForParaProps()->GetSwAttrSet().GetParaGrid().GetValue())
2810 break;
2811
2812 // i#28701 - consider anchored objects
2813 if ( GetDrawObjs() )
2814 break;
2815
2816 return bParaPossiblyInvalid;
2817 }
2818 default:
2819 break;
2820 }
2821 }
2822
2823 // Split fly anchors are technically empty (have no SwParaPortion), but otherwise behave like
2824 // other split text frames, which are non-empty.
2825 bool bSplitFlyAnchor = GetOffset() == TextFrameIndex(0) && HasFollow()
2826 && GetFollow()->GetOffset() == TextFrameIndex(0);
2827
2828 if( !HasPara() && !bSplitFlyAnchor && PrepareHint::MustFit != ePrep )
2829 {
2830 SetInvalidVert( true ); // Test
2831 OSL_ENSURE( !IsLocked(), "SwTextFrame::Prepare: three of a perfect pair" );
2832 if ( bNotify )
2834 else
2836 return bParaPossiblyInvalid;
2837 }
2838
2839 // Get object from cache while locking
2840 SwTextLineAccess aAccess( this );
2841 SwParaPortion *pPara = aAccess.GetPara();
2842
2843 switch( ePrep )
2844 {
2846 {
2848 aFrm.Height(0);
2849 }
2850
2851 {
2853 aPrt.Height(0);
2854 }
2855
2858 [[fallthrough]];
2860 pPara->SetPrepAdjust();
2861 if( IsFootnoteNumFrame() != pPara->IsFootnoteNum() ||
2862 IsUndersized() )
2863 {
2865 if( GetOffset() && !IsFollow() )
2867 }
2868 break;
2870 pPara->SetPrepMustFit(true);
2871 [[fallthrough]];
2873 pPara->SetPrepAdjust();
2874 break;
2875 case PrepareHint::Widows :
2876 // MustFit is stronger than anything else
2877 if( pPara->IsPrepMustFit() )
2878 return bParaPossiblyInvalid;
2879 // see comment in WidowsAndOrphans::FindOrphans and CalcPreps()
2880 PrepWidows( *static_cast<const sal_uInt16 *>(pVoid), bNotify );
2881 break;
2882
2884 {
2885 SwTextFootnote const *pFootnote = static_cast<SwTextFootnote const *>(pVoid);
2886 if( IsInFootnote() )
2887 {
2888 // Am I the first TextFrame of a footnote?
2889 if( !GetPrev() )
2890 // So we're a TextFrame of the footnote, which has
2891 // to display the footnote number or the ErgoSum text
2893
2894 if( !GetNext() )
2895 {
2896 // We're the last Footnote; we need to update the
2897 // QuoVadis texts now
2898 const SwFootnoteInfo &rFootnoteInfo = GetDoc().GetFootnoteInfo();
2899 if( !pPara->UpdateQuoVadis( rFootnoteInfo.m_aQuoVadis ) )
2900 {
2901 TextFrameIndex nPos = pPara->GetParLen();
2902 if( nPos )
2903 --nPos;
2905 }
2906 }
2907 }
2908 else
2909 {
2910 // We are the TextFrame _with_ the footnote
2912 &pFootnote->GetTextNode(), pFootnote->GetStart());
2914 }
2915 break;
2916 }
2918 {
2919 // Test
2920 {
2921 SetInvalidVert( false );
2922 bool bOld = IsVertical();
2923 SetInvalidVert( true );
2924 if( bOld != IsVertical() )
2926 }
2927
2928 if( HasFollow() )
2929 {
2930 TextFrameIndex nNxtOfst = GetFollow()->GetOffset();
2931 if( nNxtOfst )
2932 --nNxtOfst;
2933 InvalidateRange(SwCharRange( nNxtOfst, TextFrameIndex(1)), 1);
2934 }
2935 if( IsInFootnote() )
2936 {
2942 }
2943 // If we have a page number field, we must invalidate those spots
2944 SwTextNode const* pNode(nullptr);
2945 sw::MergedAttrIter iter(*this);
2946 TextFrameIndex const nEnd = GetFollow()
2948 for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
2949 {
2950 TextFrameIndex const nStart(MapModelToView(pNode, pHt->GetStart()));
2951 if (nStart >= GetOffset())
2952 {
2953 if (nStart >= nEnd)
2954 break;
2955
2956 // If we're flowing back and own a Footnote, the Footnote also flows
2957 // with us. So that it doesn't obstruct us, we send ourselves
2958 // an ADJUST_FRM.
2959 // pVoid != 0 means MoveBwd()
2960 const sal_uInt16 nWhich = pHt->Which();
2961 if (RES_TXTATR_FIELD == nWhich ||
2962 (HasFootnote() && pVoid && RES_TXTATR_FTN == nWhich))
2964 }
2965 }
2966 // A new boss, a new chance for growing
2967 if( IsUndersized() )
2968 {
2971 }
2972 break;
2973 }
2974
2976 {
2977 if ( isFramePrintAreaValid() )
2978 {
2979 SwTextGridItem const*const pGrid(GetGridItem(FindPageFrame()));
2980 if (pGrid && GetTextNodeForParaProps()->GetSwAttrSet().GetParaGrid().GetValue())
2981 InvalidatePrt();
2982 }
2983
2984 // If we don't overlap with anybody:
2985 // did any free-flying frame overlapped _before_ the position change?
2986 bool bFormat = pPara->HasFly();
2987 if( !bFormat )
2988 {
2989 if( IsInFly() )
2990 {
2991 SwTwips nTmpBottom = GetUpper()->getFrameArea().Top() +
2993 if( nTmpBottom < getFrameArea().Bottom() )
2994 bFormat = true;
2995 }
2996 if( !bFormat )
2997 {
2998 if ( GetDrawObjs() )
2999 {
3000 const size_t nCnt = GetDrawObjs()->size();
3001 for ( size_t i = 0; i < nCnt; ++i )
3002 {
3003 SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
3004 // i#28701 - consider all
3005 // to-character anchored objects
3006 if ( pAnchoredObj->GetFrameFormat().GetAnchor().GetAnchorId()
3007 == RndStdIds::FLY_AT_CHAR )
3008 {
3009 bFormat = true;
3010 break;
3011 }
3012 }
3013 }
3014 if( !bFormat )
3015 {
3016 // Are there any free-flying frames on this page?
3017 SwTextFly aTextFly( this );
3018 if( aTextFly.IsOn() )
3019 {
3020 // Does any free-flying frame overlap?
3021 const bool bRelaxed = aTextFly.Relax();
3022 bFormat = bRelaxed || IsUndersized();
3023 if (bRelaxed)
3024 {
3025 // It's possible that pPara was deleted above; retrieve it again
3026 pPara = aAccess.GetPara();
3027 }
3028 }
3029 }
3030 }
3031 }
3032
3033 if( bFormat )
3034 {
3035 if( !IsLocked() )
3036 {
3037 if( pPara->GetRepaint().HasArea() )
3039 Init();
3040 pPara = nullptr;
3042 }
3043 }
3044 else
3045 {
3046 if (GetTextNodeForParaProps()->GetSwAttrSet().GetRegister().GetValue())
3047 bParaPossiblyInvalid = Prepare( PrepareHint::Register, nullptr, bNotify );
3048 // The Frames need to be readjusted, which caused by changes
3049 // in position
3050 else if( HasFootnote() )
3051 {
3052 bParaPossiblyInvalid = Prepare( PrepareHint::AdjustSizeWithoutFormatting, nullptr, bNotify );
3054 }
3055 else
3056 return bParaPossiblyInvalid; // So that there's no SetPrep()
3057
3058 if (bParaPossiblyInvalid)
3059 {
3060 // It's possible that pPara was deleted above; retrieve it again
3061 pPara = aAccess.GetPara();
3062 }
3063
3064 }
3065 break;
3066 }
3068 if (GetTextNodeForParaProps()->GetSwAttrSet().GetRegister().GetValue())
3069 {
3070 pPara->SetPrepAdjust();
3071 CalcLineSpace();
3072
3073 // It's possible that pPara was deleted above; retrieve it again
3074 bParaPossiblyInvalid = true;
3075 pPara = aAccess.GetPara();
3076
3079 SwFrame* pNxt = GetIndNext();
3080 if ( nullptr != pNxt )
3081 {
3082 pNxt->InvalidatePrt_();
3083 if ( pNxt->IsLayoutFrame() )
3084 pNxt->InvalidatePage();
3085 }
3087 }
3088 break;
3090 {
3091 // If a Follow is calling us, because a footnote is being deleted, our last
3092 // line has to be formatted, so that the first line of the Follow can flow up.
3093 // Which had flowed to the next page to be together with the footnote (this is
3094 // especially true for areas with columns)
3095 OSL_ENSURE( GetFollow(), "PrepareHint::FootnoteInvalidationGone may only be called by Follow" );
3097 if( IsFollow() && GetOffset() == nPos ) // If we don't have a mass of text, we call our
3099 if( nPos )
3100 --nPos; // The char preceding our Follow
3102 return bParaPossiblyInvalid;
3103 }
3106 {
3108 if( lcl_ErgoVadis( this, nPos, ePrep ) )
3110 }
3111 break;
3113 {
3114 if( pVoid )
3115 {
3116 TextFrameIndex const nWhere = CalcFlyPos( static_cast<SwFrameFormat const *>(pVoid) );
3117 OSL_ENSURE( TextFrameIndex(COMPLETE_STRING) != nWhere, "Prepare: Why me?" );
3119 return bParaPossiblyInvalid;
3120 }
3121 [[fallthrough]]; // else: continue with default case block
3122 }
3123 case PrepareHint::Clear:
3124 default:
3125 {
3126 if( IsLocked() )
3127 {
3129 {
3130 TextFrameIndex const nLen = (GetFollow()
3131 ? GetFollow()->GetOffset()
3133 - GetOffset();
3135 }
3136 }
3137 else
3138 {
3139 if( pPara->GetRepaint().HasArea() )
3141 Init();
3142 pPara = nullptr;
3143 if( GetOffset() && !IsFollow() )
3145 if ( bNotify )
3147 else
3149 }
3150 return bParaPossiblyInvalid; // no SetPrep() happened
3151 }
3152 }
3153 if( pPara )
3154 {
3155 pPara->SetPrep();
3156 }
3157
3158 return bParaPossiblyInvalid;
3159}
3160#if defined __GNUC__ && !defined __clang__
3161# pragma GCC diagnostic pop
3162#endif
3163
3173{
3177public:
3178 SwTestFormat( SwTextFrame* pTextFrame, const SwFrame* pPrv, SwTwips nMaxHeight );
3179 ~SwTestFormat();
3180};
3181
3182SwTestFormat::SwTestFormat( SwTextFrame* pTextFrame, const SwFrame* pPre, SwTwips nMaxHeight )
3183 : pFrame( pTextFrame )
3184{
3187
3188 SwRectFnSet aRectFnSet(pFrame);
3189 SwTwips nLower = aRectFnSet.GetBottomMargin(*pFrame);
3190
3191 {
3192 // indeed, here the GetUpper()->getFramePrintArea() gets copied and manipulated
3195 aFrm += pFrame->GetUpper()->getFrameArea().Pos();
3196 aRectFnSet.SetHeight( aFrm, nMaxHeight );
3197
3198 if( pFrame->GetPrev() )
3199 {
3200 aRectFnSet.SetPosY(
3201 aFrm,
3202 aRectFnSet.GetBottom(pFrame->GetPrev()->getFrameArea()) - ( aRectFnSet.IsVert() ? nMaxHeight + 1 : 0 ) );
3203 }
3204 }
3205
3207 const SwBorderAttrs &rAttrs = *aAccess.Get();
3208
3209 {
3211 aRectFnSet.SetPosX(aPrt, rAttrs.CalcLeft( pFrame ) );
3212 }
3213
3214 if( pPre )
3215 {
3216 SwTwips nUpper = pFrame->CalcUpperSpace( &rAttrs, pPre );
3218 aRectFnSet.SetPosY(aPrt, nUpper );
3219 }
3220
3221 {
3223 aRectFnSet.SetHeight( aPrt, std::max( tools::Long(0) , aRectFnSet.GetHeight(pFrame->getFrameArea()) - aRectFnSet.GetTop(aPrt) - nLower ) );
3224 aRectFnSet.SetWidth( aPrt, aRectFnSet.GetWidth(pFrame->getFrameArea()) - ( rAttrs.CalcLeft( pFrame ) + rAttrs.CalcRight( pFrame ) ) );
3225 }
3226
3227 pOldPara = pFrame->HasPara() ? pFrame->GetPara() : nullptr;
3228 pFrame->SetPara( new SwParaPortion(), false );
3229 OSL_ENSURE( ! pFrame->IsSwapped(), "A frame is swapped before Format_" );
3230
3231 if ( pFrame->IsVertical() )
3233
3234 SwTextFormatInfo aInf( pFrame->getRootFrame()->GetCurrShell()->GetOut(), pFrame, false, true, true );
3235 SwTextFormatter aLine( pFrame, &aInf );
3236
3237 pFrame->Format_( aLine, aInf );
3238
3239 if ( pFrame->IsVertical() )
3241
3242 OSL_ENSURE( ! pFrame->IsSwapped(), "A frame is swapped after Format_" );
3243}
3244
3246{
3247 {
3249 aFrm.setSwRect(aOldFrame);
3250 }
3251
3252 {
3254 aPrt.setSwRect(aOldPrt);
3255 }
3256
3258}
3259
3260bool SwTextFrame::TestFormat( const SwFrame* pPrv, SwTwips &rMaxHeight, bool &bSplit )
3261{
3263
3264 if( IsLocked() && GetUpper()->getFramePrintArea().Width() <= 0 )
3265 return false;
3266
3267 SwTestFormat aSave( this, pPrv, rMaxHeight );
3268
3269 return SwTextFrame::WouldFit(rMaxHeight, bSplit, true, false);
3270}
3271
3284bool SwTextFrame::WouldFit(SwTwips &rMaxHeight, bool &bSplit, bool bTst, bool bMoveBwd)
3285{
3286 OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
3287 "SwTextFrame::WouldFit with swapped frame" );
3288 SwRectFnSet aRectFnSet(this);
3289
3290 if( IsLocked() )
3291 return false;
3292
3293 // it can happen that the IdleCollector removed the cached information
3294 if( !IsEmpty() )
3295 GetFormatted();
3296
3297 // i#27801 - correction: 'short cut' for empty paragraph
3298 // can *not* be applied, if test format is in progress. The test format doesn't
3299 // adjust the frame and the printing area - see method <SwTextFrame::Format_(..)>,
3300 // which is called in <SwTextFrame::TestFormat(..)>
3301 if ( IsEmpty() && !bTst )
3302 {
3303 bSplit = false;
3304 SwTwips nHeight = aRectFnSet.IsVert() ? getFramePrintArea().SSize().Width() : getFramePrintArea().SSize().Height();
3305 if( rMaxHeight < nHeight )
3306 return false;
3307 else
3308 {
3309 rMaxHeight -= nHeight;
3310 return true;
3311 }
3312 }
3313
3314 // GetPara can still be 0 in edge cases
3315 // We return true in order to be reformatted on the new Page
3316 OSL_ENSURE( HasPara() || IsHiddenNow(), "WouldFit: GetFormatted() and then !HasPara()" );
3317 if( !HasPara() || ( !aRectFnSet.GetHeight(getFrameArea()) && IsHiddenNow() ) )
3318 return true;
3319
3320 // Because the Orphan flag only exists for a short moment, we also check
3321 // whether the Framesize is set to very huge by CalcPreps, in order to
3322 // force a MoveFwd
3323 if (IsWidow() || (aRectFnSet.IsVert()
3324 ? (0 == getFrameArea().Left())
3325 : (sw::WIDOW_MAGIC - 20000 < getFrameArea().Bottom())))
3326 {
3327 SetWidow(false);
3328 if ( GetFollow() )
3329 {
3330 // If we've ended up here due to a Widow request by our Follow, we check
3331 // whether there's a Follow with a real height at all.
3332 // Else (e.g. for newly created SctFrames) we ignore the IsWidow() and
3333 // still check if we can find enough room
3334 if (((!aRectFnSet.IsVert() && getFrameArea().Bottom() <= sw::WIDOW_MAGIC - 20000) ||
3335 ( aRectFnSet.IsVert() && 0 < getFrameArea().Left() ) ) &&
3336 ( GetFollow()->IsVertical() ?
3337 !GetFollow()->getFrameArea().Width() :
3338 !GetFollow()->getFrameArea().Height() ) )
3339 {
3340 SwTextFrame* pFoll = GetFollow()->GetFollow();
3341 while( pFoll &&
3342 ( pFoll->IsVertical() ?
3343 !pFoll->getFrameArea().Width() :
3344 !pFoll->getFrameArea().Height() ) )
3345 pFoll = pFoll->GetFollow();
3346 if( pFoll )
3347 return false;
3348 }
3349 else
3350 return false;
3351 }
3352 }
3353
3354 SwSwapIfNotSwapped swap( this );
3355
3356 SwTextSizeInfo aInf( this );
3357 SwTextMargin aLine( this, &aInf );
3358
3359 WidowsAndOrphans aFrameBreak( this, rMaxHeight, bSplit );
3360
3361 bool bRet = true;
3362
3363 aLine.Bottom();
3364 // is breaking necessary?
3365 bSplit = !aFrameBreak.IsInside( aLine );
3366 if ( bSplit )
3367 bRet = !aFrameBreak.IsKeepAlways() && aFrameBreak.WouldFit(aLine, rMaxHeight, bTst, bMoveBwd);
3368 else
3369 {
3370 // we need the total height including the current line
3371 aLine.Top();
3372 do
3373 {
3374 rMaxHeight -= aLine.GetLineHeight();
3375 } while ( aLine.Next() );
3376 }
3377
3378 return bRet;
3379}
3380
3382{
3383 OSL_ENSURE( ! IsVertical() || ! IsSwapped(),
3384 "SwTextFrame::GetParHeight with swapped frame" );
3385
3386 if( !HasPara() )
3387 { // For non-empty paragraphs this is a special case
3388 // For UnderSized we can simply just ask 1 Twip more
3389 sal_uInt16 nRet = o3tl::narrowing<sal_uInt16>(getFramePrintArea().SSize().Height());
3390 if( IsUndersized() )
3391 {
3392 if( IsEmpty() || GetText().isEmpty() )
3393 nRet = o3tl::narrowing<sal_uInt16>(EmptyHeight());
3394 else
3395 ++nRet;
3396 }
3397 return nRet;
3398 }
3399
3400 // TODO: Refactor and improve code
3401 const SwLineLayout* pLineLayout = GetPara();
3402 SwTwips nHeight = pLineLayout ? pLineLayout->GetRealHeight() : 0;
3403
3404 // Is this paragraph scrolled? Our height until now is at least
3405 // one line height too low then
3406 if( GetOffset() && !IsFollow() )
3407 nHeight *= 2;
3408
3409 while ( pLineLayout && pLineLayout->GetNext() )
3410 {
3411 pLineLayout = pLineLayout->GetNext();
3412 nHeight = nHeight + pLineLayout->GetRealHeight();
3413 }
3414
3415 return nHeight;
3416}
3417
3421SwTextFrame* SwTextFrame::GetFormatted( bool bForceQuickFormat )
3422{
3423 vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
3424 SwSwapIfSwapped swap( this );
3425
3426 // In case the SwLineLayout was cleared out of the s_pTextCache, recreate it
3427 // Not for empty paragraphs
3428 if( !HasPara() && !(isFrameAreaDefinitionValid() && IsEmpty()) )
3429 {
3430 // Calc() must be called, because frame position can be wrong
3431 const bool bFormat = isFrameAreaSizeValid();
3432 Calc(pRenderContext); // calls Format() if invalid
3433
3434 // If the flags were valid (hence bFormat=true), Calc did nothing,
3435 // so Format() must be called manually in order to recreate
3436 // the SwLineLayout that has been deleted from the
3437 // SwTextFrame::s_pTextCache (hence !HasPara() above).
3438 // Optimization with FormatQuick()
3439 if( bFormat && !FormatQuick( bForceQuickFormat ) )
3440 Format(getRootFrame()->GetCurrShell()->GetOut());
3441 }
3442
3443 return this;
3444}
3445
3447{
3448 // i#31490
3449 // If we are currently locked, we better return with a
3450 // fairly reasonable value:
3451 if ( IsLocked() )
3452 return getFramePrintArea().Width();
3453
3454 SwParaPortion* pOldPara = GetPara();
3455 SwParaPortion *pDummy = new SwParaPortion();
3456 SetPara( pDummy, false );
3457 const SwPageFrame* pPage = FindPageFrame();
3458
3459 const Point aOldFramePos = getFrameArea().Pos();
3460 const SwTwips nOldFrameWidth = getFrameArea().Width();
3461 const SwTwips nOldPrtWidth = getFramePrintArea().Width();
3462 const SwTwips nPageWidth = GetUpper()->IsVertical() ?
3463 pPage->getFramePrintArea().Height() :
3464 pPage->getFramePrintArea().Width();
3465
3466 {
3468 aFrm.Width( nPageWidth );
3469 }
3470
3471 {
3473 aPrt.Width( nPageWidth );
3474 }
3475
3476 // i#25422 objects anchored as character in RTL
3477 if ( IsRightToLeft() )
3478 {
3480 aFrm.Pos().AdjustX(nOldFrameWidth - nPageWidth );
3481 }
3482
3483 TextFrameLockGuard aLock( this );
3484
3485 SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true, true );
3486 aInf.SetIgnoreFly( true );
3487 SwTextFormatter aLine( this, &aInf );
3488 SwHookOut aHook( aInf );
3489
3490 // i#54031 - assure minimum of MINLAY twips.
3491 const SwTwips nMax = std::max( SwTwips(MINLAY), aLine.CalcFitToContent_() + 1 );
3492
3493 {
3495 aFrm.Width( nOldFrameWidth );
3496
3497 // i#25422 objects anchored as character in RTL
3498 if ( IsRightToLeft() )
3499 {
3500 aFrm.Pos() = aOldFramePos;
3501 }
3502 }
3503
3504 {
3506 aPrt.Width( nOldPrtWidth );
3507 }
3508
3509 SetPara( pOldPara );
3510
3511 return nMax;
3512}
3513
3521{
3522 if ( IsLocked() )
3523 return;
3524
3525 // reset additional first line offset
3527
3528 const SwTextNode* pTextNode( GetTextNodeForParaProps() );
3529 // sw_redlinehide: check that pParaPropsNode is the correct one
3530 assert(pTextNode->IsNumbered(getRootFrame()) == pTextNode->IsNumbered(nullptr));
3531 if (!(pTextNode->IsNumbered(getRootFrame()) &&
3532 pTextNode->IsCountedInList() && pTextNode->GetNumRule()))
3533 return;
3534
3535 int nListLevel = pTextNode->GetActualListLevel();
3536
3537 if (nListLevel < 0)
3538 nListLevel = 0;
3539
3540 if (nListLevel >= MAXLEVEL)
3541 nListLevel = MAXLEVEL - 1;
3542
3543 const SwNumFormat& rNumFormat =
3544 pTextNode->GetNumRule()->Get( o3tl::narrowing<sal_uInt16>(nListLevel) );
3546 return;
3547
3548 // keep current paragraph portion and apply dummy paragraph portion
3549 SwParaPortion* pOldPara = GetPara();
3550 SwParaPortion *pDummy = new SwParaPortion();
3551 SetPara( pDummy, false );
3552
3553 // lock paragraph
3554 TextFrameLockGuard aLock( this );
3555
3556 // simulate text formatting
3557 SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true, true );
3558 aInf.SetIgnoreFly( true );
3559 SwTextFormatter aLine( this, &aInf );
3560 SwHookOut aHook( aInf );
3561 aLine.CalcFitToContent_();
3562
3563 // determine additional first line offset
3564 const SwLinePortion* pFirstPortion = aLine.GetCurr()->GetFirstPortion();
3565 if ( pFirstPortion->InNumberGrp() && !pFirstPortion->IsFootnoteNumPortion() )
3566 {
3567 SwTwips nNumberPortionWidth( pFirstPortion->Width() );
3568
3569 const SwLinePortion* pPortion = pFirstPortion->GetNextPortion();
3570 while ( pPortion &&
3571 pPortion->InNumberGrp() && !pPortion->IsFootnoteNumPortion())
3572 {
3573 nNumberPortionWidth += pPortion->Width();
3574 pPortion = pPortion->GetNextPortion();
3575 }
3576
3577 if ( ( IsRightToLeft() &&
3578 rNumFormat.GetNumAdjust() == SvxAdjust::Left ) ||
3579 ( !IsRightToLeft() &&
3580 rNumFormat.GetNumAdjust() == SvxAdjust::Right ) )
3581 {
3582 mnAdditionalFirstLineOffset = -nNumberPortionWidth;
3583 }
3584 else if ( rNumFormat.GetNumAdjust() == SvxAdjust::Center )
3585 {
3586 mnAdditionalFirstLineOffset = -(nNumberPortionWidth/2);
3587 }
3588 }
3589
3590 // restore paragraph portion
3591 SetPara( pOldPara );
3592}
3593
3606void SwTextFrame::CalcHeightOfLastLine( const bool _bUseFont )
3607{
3608 // i#71281
3609 // Invalidate printing area, if height of last line changes
3610 const SwTwips nOldHeightOfLastLine( mnHeightOfLastLine );
3611
3612 // determine output device
3614 OSL_ENSURE( pVsh, "<SwTextFrame::_GetHeightOfLastLineForPropLineSpacing()> - no SwViewShell" );
3615
3616 // i#78921
3617 // There could be no <SwViewShell> instance in the case of loading a binary
3618 // StarOffice file format containing an embedded Writer document.
3619 if ( !pVsh )
3620 {
3621 return;
3622 }
3623 OutputDevice* pOut = pVsh->GetOut();
3625 if ( !pVsh->GetViewOptions()->getBrowseMode() ||
3626 pVsh->GetViewOptions()->IsPrtFormat() )
3627 {
3629 }
3630 OSL_ENSURE( pOut, "<SwTextFrame::_GetHeightOfLastLineForPropLineSpacing()> - no OutputDevice" );
3631
3632 if ( !pOut )
3633 {
3634 return;
3635 }
3636
3637 // determine height of last line
3638 if ( _bUseFont || pIDSA->get(DocumentSettingId::OLD_LINE_SPACING ) )
3639 {
3640 // former determination of last line height for proportional line
3641 // spacing - take height of font set at the paragraph
3642 // FIXME actually... must the font match across all nodes?
3643 SwFont aFont( &GetTextNodeForParaProps()->GetSwAttrSet(), pIDSA );
3644
3645 // we must ensure that the font is restored correctly on the OutputDevice
3646 // otherwise Last!=Owner could occur
3647 if ( pLastFont )
3648 {
3649 SwFntObj *pOldFont = pLastFont;
3650 pLastFont = nullptr;
3651 aFont.SetFntChg( true );
3652 aFont.ChgPhysFnt( pVsh, *pOut );
3653 mnHeightOfLastLine = aFont.GetHeight( pVsh, *pOut );
3654 assert(pLastFont && "coverity[var_deref_model] - pLastFont should be set in SwSubFont::ChgFnt");
3655 pLastFont->Unlock();
3656 pLastFont = pOldFont;
3657 pLastFont->SetDevFont( pVsh, *pOut );
3658 }
3659 else
3660 {
3661 vcl::Font aOldFont = pOut->GetFont();
3662 aFont.SetFntChg( true );
3663 aFont.ChgPhysFnt( pVsh, *pOut );
3664 mnHeightOfLastLine = aFont.GetHeight( pVsh, *pOut );
3665 assert(pLastFont && "coverity[var_deref_model] - pLastFont should be set in SwSubFont::ChgFnt");
3666 pLastFont->Unlock();
3667 pLastFont = nullptr;
3668 pOut->SetFont( aOldFont );
3669 }
3670 }
3671 else
3672 {
3673 // new determination of last line height - take actually height of last line
3674 // i#89000
3675 // assure same results, if paragraph is undersized
3676 if ( IsUndersized() )
3677 {
3679 }
3680 else
3681 {
3682 bool bCalcHeightOfLastLine = true;
3683 if ( ( !HasPara() && IsEmpty( ) ) || GetText().isEmpty() )
3684 {
3686 bCalcHeightOfLastLine = false;
3687 }
3688
3689 if ( bCalcHeightOfLastLine )
3690 {
3691 OSL_ENSURE( HasPara(),
3692 "<SwTextFrame::CalcHeightOfLastLine()> - missing paragraph portions." );
3693 const SwLineLayout* pLineLayout = GetPara();
3694 while ( pLineLayout && pLineLayout->GetNext() )
3695 {
3696 // iteration to last line
3697 pLineLayout = pLineLayout->GetNext();
3698 }
3699 if ( pLineLayout )
3700 {
3701 SwTwips nAscent, nDescent, nDummy1, nDummy2;
3702 // i#47162 - suppress consideration of
3703 // fly content portions and the line portion.
3704 pLineLayout->MaxAscentDescent( nAscent, nDescent,
3705 nDummy1, nDummy2,
3706 nullptr, true );
3707 // i#71281
3708 // Suppress wrong invalidation of printing area, if method is
3709 // called recursive.
3710 // Thus, member <mnHeightOfLastLine> is only set directly, if
3711 // no recursive call is needed.
3712 const SwTwips nNewHeightOfLastLine = nAscent + nDescent;
3713 // i#47162 - if last line only contains
3714 // fly content portions, <mnHeightOfLastLine> is zero.
3715 // In this case determine height of last line by the font
3716 if ( nNewHeightOfLastLine == 0 )
3717 {
3718 CalcHeightOfLastLine( true );
3719 }
3720 else
3721 {
3722 mnHeightOfLastLine = nNewHeightOfLastLine;
3723 }
3724 }
3725 }
3726 }
3727 }
3728 // i#71281
3729 // invalidate printing area, if height of last line changes
3730 if ( mnHeightOfLastLine != nOldHeightOfLastLine )
3731 {
3732 InvalidatePrt();
3733 }
3734}
3735
3745tools::Long SwTextFrame::GetLineSpace( const bool _bNoPropLineSpace ) const
3746{
3747 tools::Long nRet = 0;
3748
3750
3751 switch( rSpace.GetInterLineSpaceRule() )
3752 {
3753 case SvxInterLineSpaceRule::Prop:
3754 {
3755 if ( _bNoPropLineSpace )
3756 {
3757 break;
3758 }
3759
3760 // i#11860 - adjust spacing implementation for object positioning
3761 // - compatibility to MS Word
3762 nRet = GetHeightOfLastLine();
3763
3764 tools::Long nTmp = nRet;
3765 nTmp *= rSpace.GetPropLineSpace();
3766 nTmp /= 100;
3767 nTmp -= nRet;
3768 if ( nTmp > 0 )
3769 nRet = nTmp;
3770 else
3771 nRet = 0;
3772 }
3773 break;
3774 case SvxInterLineSpaceRule::Fix:
3775 {
3776 if ( rSpace.GetInterLineSpace() > 0 )
3777 nRet = rSpace.GetInterLineSpace();
3778 }
3779 break;
3780 default:
3781 break;
3782 }
3783 return nRet;
3784}
3785
3787{
3788 if ( !HasPara() )
3789 {
3791 return IsVertical() ? o3tl::narrowing<sal_uInt16>(getFramePrintArea().Width()) : o3tl::narrowing<sal_uInt16>(getFramePrintArea().Height());
3792 return USHRT_MAX;
3793 }
3794 const SwParaPortion *pPara = GetPara();
3795 if ( !pPara )
3796 return USHRT_MAX;
3797
3798 // tdf#146500 Lines with only fly overlap cannot be "moved", so the idea
3799 // here is to continue until there's some text.
3800 // FIXME ideally we want to count a fly to the line in which it is anchored
3801 // - it may even be anchored in some other paragraph! SwFlyPortion doesn't
3802 // have a pointer sadly so no way to find out.
3803 sal_uInt16 nHeight(0);
3804 for (SwLineLayout const* pLine = pPara; pLine; pLine = pLine->GetNext())
3805 {
3806 nHeight += pLine->Height();
3807 bool hasNonFly(false);
3808 for (SwLinePortion const* pPortion = pLine->GetFirstPortion();
3809 pPortion; pPortion = pPortion->GetNextPortion())
3810 {
3811 switch (pPortion->GetWhichPor())
3812 {
3813 case PortionType::Fly:
3814 case PortionType::Glue:
3816 break;
3817 default:
3818 {
3819 hasNonFly = true;
3820 break;
3821 }
3822 }
3823 if (hasNonFly)
3824 {
3825 break;
3826 }
3827 }
3828 if (hasNonFly)
3829 {
3830 break;
3831 }
3832 }
3833 return nHeight;
3834}
3835
3837{
3838 sal_uInt16 nRet = 0;
3839 SwTextFrame *pFrame = this;
3840 do
3841 {
3842 pFrame->GetFormatted();
3843 if( !pFrame->HasPara() )
3844 break;
3845 SwTextSizeInfo aInf( pFrame );
3846 SwTextMargin aLine( pFrame, &aInf );
3848 aLine.Bottom();
3849 else
3850 aLine.CharToLine( nPos );
3851 nRet = nRet + aLine.GetLineNr();
3852 pFrame = pFrame->GetFollow();
3853 } while ( pFrame && pFrame->GetOffset() <= nPos );
3854 return nRet;
3855}
3856
3858{
3859 // not necessary to format here (GetFormatted etc.), because we have to come from there!
3860 sal_uInt32 nNew = 0;
3861 const SwLineNumberInfo &rInf = GetDoc().GetLineNumberInfo();
3862 if ( !GetText().isEmpty() && HasPara() )
3863 {
3864 SwTextSizeInfo aInf( this );
3865 SwTextMargin aLine( this, &aInf );
3866 if ( rInf.IsCountBlankLines() )
3867 {
3868 aLine.Bottom();
3869 nNew = aLine.GetLineNr();
3870 }
3871 else
3872 {
3873 do
3874 {
3875 if( aLine.GetCurr()->HasContent() )
3876 ++nNew;
3877 } while ( aLine.NextLine() );
3878 }
3879 }
3880 else if ( rInf.IsCountBlankLines() )
3881 nNew = 1;
3882
3883 if ( nNew == mnThisLines )
3884 return;
3885
3886 if (!IsInTab() && GetTextNodeForParaProps()->GetSwAttrSet().GetLineNumber().IsCount())
3887 {
3889 mnThisLines = nNew;
3891 SwFrame *pNxt = GetNextContentFrame();
3892 while( pNxt && pNxt->IsInTab() )
3893 {
3894 pNxt = pNxt->FindTabFrame();
3895 if( nullptr != pNxt )
3896 pNxt = pNxt->FindNextCnt();
3897 }
3898 if( pNxt )
3899 pNxt->InvalidateLineNum();
3900
3901 // Extend repaint to the bottom.
3902 if ( HasPara() )
3903 {
3904 SwRepaint& rRepaint = GetPara()->GetRepaint();
3905 rRepaint.Bottom( std::max( rRepaint.Bottom(),
3907 }
3908 }
3909 else // Paragraphs which are not counted should not manipulate the AllLines.
3910 mnThisLines = nNew;
3911}
3912
3914{
3916
3917 if ( IsInTab() )
3918 return;
3919
3920 const sal_uLong nOld = GetAllLines();
3922 sal_uLong nNewNum;
3923 const bool bRestart = GetDoc().GetLineNumberInfo().IsRestartEachPage();
3924
3925 if ( !IsFollow() && rLineNum.GetStartValue() && rLineNum.IsCount() )
3926 nNewNum = rLineNum.GetStartValue() - 1;
3927 // If it is a follow or not has not be considered if it is a restart at each page; the
3928 // restart should also take effect at follows.
3929 else if ( bRestart && FindPageFrame()->FindFirstBodyContent() == this )
3930 {
3931 nNewNum = 0;
3932 }
3933 else
3934 {
3936 while ( pPrv &&
3937 (pPrv->IsInTab() || pPrv->IsInDocBody() != IsInDocBody()) )
3938 pPrv = pPrv->GetPrevContentFrame();
3939
3940 // i#78254 Restart line numbering at page change
3941 // First body content may be in table!
3942 if ( bRestart && pPrv && pPrv->FindPageFrame() != FindPageFrame() )
3943 pPrv = nullptr;
3944
3945 nNewNum = pPrv ? static_cast<SwTextFrame*>(pPrv)->GetAllLines() : 0;
3946 }
3947 if ( rLineNum.IsCount() )
3948 nNewNum += GetThisLines();
3949
3950 if ( nOld == nNewNum )
3951 return;
3952
3953 mnAllLines = nNewNum;
3955 while ( pNxt &&
3956 (pNxt->IsInTab() || pNxt->IsInDocBody() != IsInDocBody()) )
3957 pNxt = pNxt->GetNextContentFrame();
3958 if ( pNxt )
3959 {
3960 if ( pNxt->GetUpper() != GetUpper() )
3961 pNxt->InvalidateLineNum();
3962 else
3963 pNxt->InvalidateLineNum_();
3964 }
3965}
3966
3968{
3969 const SwParaPortion* pPara = isFrameAreaDefinitionValid() ? GetPara() : nullptr;
3970
3971 if (pPara)
3972 {
3973 if ( IsFollow() )
3974 rPH.Skip( GetOffset() );
3975
3976 const SwLineLayout* pLine = pPara;
3977 while ( pLine )
3978 {
3979 const SwLinePortion* pPor = pLine->GetFirstPortion();
3980 while ( pPor )
3981 {
3982 pPor->HandlePortion( rPH );
3983 pPor = pPor->GetNextPortion();
3984 }
3985
3986 rPH.LineBreak();
3987 pLine = pLine->GetNext();
3988 }
3989 }
3990
3991 rPH.Finish();
3992}
3993
3995{
3996 const SwParaPortion* pPara = GetPara();
3997 return pPara ? &pPara->GetScriptInfo() : nullptr;
3998}
3999
4003static SwTwips lcl_CalcFlyBasePos( const SwTextFrame& rFrame, SwRect aFlyRect,
4004 SwTextFly const & rTextFly )
4005{
4006 SwRectFnSet aRectFnSet(&rFrame);
4007 SwTwips nRet = rFrame.IsRightToLeft() ?
4008 aRectFnSet.GetRight(rFrame.getFrameArea()) :
4009 aRectFnSet.GetLeft(rFrame.getFrameArea());
4010
4011 do
4012 {
4013 SwRect aRect = rTextFly.GetFrame( aFlyRect );
4014 if ( 0 != aRectFnSet.GetWidth(aRect) )
4015 {
4016 if ( rFrame.IsRightToLeft() )
4017 {
4018 if ( aRectFnSet.GetRight(aRect) -
4019 aRectFnSet.GetRight(aFlyRect) >= 0 )
4020 {
4021 aRectFnSet.SetRight(
4022aFlyRect, aRectFnSet.GetLeft(aRect) );
4023 nRet = aRectFnSet.GetLeft(aRect);
4024 }
4025 else
4026 break;
4027 }
4028 else
4029 {
4030 if ( aRectFnSet.GetLeft(aFlyRect) -
4031 aRectFnSet.GetLeft(aRect) >= 0 )
4032 {
4033 aRectFnSet.SetLeft(
4034aFlyRect, aRectFnSet.GetRight(aRect) + 1 );
4035 nRet = aRectFnSet.GetRight(aRect);
4036 }
4037 else
4038 break;
4039 }
4040 }
4041 else
4042 break;
4043 }
4044 while ( aRectFnSet.GetWidth(aFlyRect) > 0 );
4045
4046 return nRet;
4047}
4048
4050{
4051 OSL_ENSURE( !IsVertical() || !IsSwapped(),
4052 "SwTextFrame::CalcBasePosForFly with swapped frame!" );
4053
4054 if (!GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::ADD_FLY_OFFSETS))
4055 return;
4056
4057 SwRectFnSet aRectFnSet(this);
4058
4060
4061 // Get first 'real' line and adjust position and height of line rectangle.
4062 // Correct behaviour if no 'real' line exists
4063 // (empty paragraph with and without a dummy portion)
4064 SwTwips nFlyAnchorVertOfstNoWrap = 0;
4065 {
4066 SwTwips nTop = aRectFnSet.GetTop(aFlyRect);
4067 const SwLineLayout* pLay = GetPara();
4068 SwTwips nLineHeight = 200;
4069 while( pLay && pLay->IsDummy() && pLay->GetNext() )
4070 {
4071 nTop += pLay->Height();
4072 nFlyAnchorVertOfstNoWrap += pLay->Height();
4073 pLay = pLay->GetNext();
4074 }
4075 if ( pLay )
4076 {
4077 nLineHeight = pLay->Height();
4078 }
4079 aRectFnSet.SetTopAndHeight( aFlyRect, nTop, nLineHeight );
4080 }
4081
4082 SwTextFly aTextFly( this );
4083 aTextFly.SetIgnoreCurrentFrame( true );
4084 aTextFly.SetIgnoreContour( true );
4085 // ignore objects in page header|footer for
4086 // text frames not in page header|footer
4087 aTextFly.SetIgnoreObjsInHeaderFooter( true );
4088 SwTwips nRet1 = lcl_CalcFlyBasePos( *this, aFlyRect, aTextFly );
4089 aTextFly.SetIgnoreCurrentFrame( false );
4090 SwTwips nRet2 = lcl_CalcFlyBasePos( *this, aFlyRect, aTextFly );
4091
4092 // make values relative to frame start position
4093 SwTwips nLeft = IsRightToLeft() ?
4094 aRectFnSet.GetRight(getFrameArea()) :
4095 aRectFnSet.GetLeft(getFrameArea());
4096
4097 mnFlyAnchorOfst = nRet1 - nLeft;
4098 mnFlyAnchorOfstNoWrap = nRet2 - nLeft;
4099
4100 if (!GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS))
4101 return;
4102
4103 if (mnFlyAnchorOfstNoWrap > 0)
4104 mnFlyAnchorVertOfstNoWrap = nFlyAnchorVertOfstNoWrap;
4105}
4106
4107SwTwips SwTextFrame::GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
4108{
4109 return bIgnoreFlysAnchoredAtThisFrame ? 0 : mnFlyAnchorVertOfstNoWrap;
4110}
4111
4116{
4118 for( const SwTextFrame *pFrame = aIter.First(); pFrame; pFrame = aIter.Next() )
4119 {
4120 SwRect aRec( pFrame->GetPaintArea() );
4121 const SwRootFrame *pRootFrame = pFrame->getRootFrame();
4122 SwViewShell *pCurShell = pRootFrame ? pRootFrame->GetCurrShell() : nullptr;
4123 if( pCurShell )
4124 pCurShell->InvalidateWindows( aRec );
4125 }
4126}
4127
4129{
4130 if (pWrtSh && pWrtSh->GetViewOptions()->IsShowOutlineContentVisibilityButton() &&
4131 GetTextNodeFirst()->IsOutline())
4132 {
4133 SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
4136 }
4137}
4138
4139/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ CONSIDER_WRAP_ON_OBJECT_POSITION
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...
GPOS_NONE
virtual OutputDevice * getReferenceDevice(bool bCreate) const =0
Returns the current reference device.
virtual bool SetFieldsDirty(bool b, const SwNode *pChk, SwNodeOffset nLen)=0
Provides access to settings of a document.
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
SdrObjUserCall * GetUserCall() const
void Broadcast(const SfxHint &rHint)
SfxHintId GetId() const
SfxItemPool * GetPool() const
sal_uInt16 Count() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 Which() const
constexpr tools::Long Height() const
void setHeight(tools::Long nHeight)
const Color & GetColor() const
SvxGraphicPosition GetGraphicPos() const
sal_uInt16 GetPropLineSpace() const
SvxInterLineSpaceRule GetInterLineSpaceRule() const
short GetInterLineSpace() const
SvxAdjust GetNumAdjust() const
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
wrapper class for the positioning of Writer fly frames and drawing objects
virtual SwFrameFormat & GetFrameFormat()=0
virtual const SwFlyFrame * DynCastFlyFrame() const
sal_uInt16 Count() const
Definition: hints.hxx:353
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:122
const SwFormatLineNumber & GetLineNumber(bool=true) const
Definition: fmtline.hxx:64
const SvxLineSpacingItem & GetLineSpacing(bool=true) const
Definition: paratr.hxx:201
SwBorderAttrs * Get()
Definition: frmtool.cxx:2686
tools::Long CalcLeft(const SwFrame *pCaller) const
Definition: frmtool.cxx:2372
tools::Long CalcRight(const SwFrame *pCaller) const
Definition: frmtool.cxx:2301
void Unlock()
Definition: swcache.cxx:477
TextFrameIndex & Len()
Definition: porlay.hxx:49
TextFrameIndex & Start()
Definition: porlay.hxx:45
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:67
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:210
virtual void MoveObjToInvisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding invisible layer
Definition: dcontact.cxx:237
const SwFormatAnchor & GetAnchorFormat() const
some virtual helper methods for information about the object (Writer fly frame resp.
Definition: dcontact.hxx:138
RndStdIds GetAnchorId() const
Definition: dcontact.hxx:145
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:59
SwContentFrame * GetPrevContentFrame() const
Definition: cntfrm.hxx:128
virtual void DestroyImpl() override
Definition: ssfrm.cxx:428
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:120
SwTextFrame * FindMaster() const
Definition: flowfrm.cxx:749
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: wsfrm.cxx:2353
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:765
LanguageType nOldLanguageType
Definition: txtfrm.hxx:965
SwDigitModeModifier(const OutputDevice &rOutp, LanguageType eCurLang)
Definition: txtfrm.cxx:724
const OutputDevice & rOut
Definition: txtfrm.hxx:964
Definition: doc.hxx:197
const SwFootnoteInfo & GetFootnoteInfo() const
Definition: doc.hxx:643
bool FieldHidesPara(const SwField &rField) const
Definition: doc.cxx:1384
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:252
const SwLineNumberInfo & GetLineNumberInfo() const
Definition: lineinfo.cxx:49
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:371
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:647
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:190
int FieldCanHideParaWeight(SwFieldIds eFieldId) const
Definition: doc.cxx:1369
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
SwFrameControlsManager & GetFrameControlsManager()
Definition: edtwin.cxx:6833
SwFieldIds Which() const
Definition: fldbas.hxx:276
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
void SetDevFont(const SwViewShell *pSh, OutputDevice &rOut)
Definition: fntcache.cxx:558
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
Definition: swfont.hxx:135
void SetFntChg(const bool bNew)
Definition: swfont.hxx:212
void ChgPhysFnt(SwViewShell const *pSh, OutputDevice &rOut)
Definition: swfont.cxx:893
tools::Long GetHeight() const
Definition: swfont.hxx:287
bool RemoveFootnote(const SwContentFrame *, const SwTextFootnote *, bool bPrep=true)
Definition: ftnfrm.cxx:1736
SwTextFootnote * SeekEntry(const SwNode &rNd, size_t *pPos=nullptr) const
Definition: ftnidx.cxx:408
OUString m_aErgoSum
Definition: ftninfo.hxx:96
OUString m_aQuoVadis
Definition: ftninfo.hxx:95
FlyAnchors.
Definition: fmtanchr.hxx:37
sal_Int32 GetAnchorContentOffset() const
Definition: atrfrm.cxx:1631
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1614
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
const SwField * GetField() const
Definition: fmtfld.hxx:131
bool IsCount() const
Definition: fmtline.hxx:58
sal_uLong GetStartValue() const
Definition: fmtline.hxx:57
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
void setSwRect(const SwRect &rNew)
Definition: frame.hxx:198
const SwRect & getFrameArea() const
Definition: frame.hxx:179
bool isFrameAreaDefinitionValid() const
Definition: frame.hxx:171
const SwRect & getFramePrintArea() const
Definition: frame.hxx:180
bool isFramePrintAreaValid() const
Definition: frame.hxx:168
bool isFrameAreaSizeValid() const
Definition: frame.hxx:167
A container for the Header/Footer, PageBreak, and Outline Content Visibility controls.
void SetOutlineContentVisibilityButton(const SwContentFrame *pContentFrame)
Style of a layout element.
Definition: frmfmt.hxx:72
Helper class which can be used instead of the macros if a function has too many returns.
Definition: txtfrm.hxx:943
SwFrameSwapper(const SwTextFrame *pFrame, bool bSwapIfNotSwapped)
Definition: txtfrm.cxx:667
const SwTextFrame * pFrame
Definition: txtfrm.hxx:944
Base class of the Writer layout elements.
Definition: frame.hxx:315
void InvalidateLineNum_()
Definition: frame.hxx:801
bool IsTextFrame() const
Definition: frame.hxx:1240
void SetDerivedR2L(bool bNew)
Definition: frame.hxx:636
bool IsInDtor() const
Definition: frame.hxx:898
void InvalidateLineNum()
Definition: frame.hxx:1056
void CheckDirChange()
checks the layout direction and invalidates the lower frames recursively, if necessary.
Definition: ssfrm.cxx:195
bool IsInDocBody() const
Definition: frame.hxx:949
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1121
SwContentFrame * FindPrevCnt()
Definition: findfrm.cxx:201
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1105
SwFrame * FindNext()
Definition: frame.hxx:1147
SwFrame * GetNext()
Definition: frame.hxx:682
SwFrameType mnFrameType
Definition: frame.hxx:414
bool IsVertLRBT() const
Definition: frame.hxx:989
bool IsInFootnote() const
Definition: frame.hxx:955
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1799
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:568
bool IsInTab() const
Definition: frame.hxx:961
static SwCache & GetCache()
Definition: frame.hxx:523
bool IsRightToLeft() const
Definition: frame.hxx:993
bool IsInFly() const
Definition: frame.hxx:967
void InvalidateNextPrtArea()
method to invalidate printing area of next frame #i11859#
Definition: findfrm.cxx:1367
void InvalidatePrt()
Definition: frame.hxx:1042
void ValidateLineNum()
Definition: frame.hxx:766
SwLayoutFrame * GetUpper()
Definition: frame.hxx:684
bool IsVertical() const
Definition: frame.hxx:979
void InvalidatePage(const SwPageFrame *pPage=nullptr) const
Invalidates the page in which the Frame is currently placed.
Definition: wsfrm.cxx:618
SwRootFrame * getRootFrame()
Definition: frame.hxx:685
bool IsNoTextFrame() const
Definition: frame.hxx:1244
void SetCompletePaint() const
Definition: frame.hxx:1000
void InvalidatePrt_()
Definition: frame.hxx:785
SwFrame * GetPrev()
Definition: frame.hxx:683
void InvalidateSize_()
Definition: frame.hxx:777
bool IsVertLR() const
Definition: frame.hxx:985
void InvalidateSize()
Definition: frame.hxx:1035
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:217
void SetInvalidVert(bool bNew)
Definition: frame.hxx:634
SwPageFrame * FindPageFrame()
Definition: frame.hxx:686
sw::BroadcastingModify * GetDep()
use these so we can grep for SwFrame's GetRegisteredIn accesses beware that SwTextFrame may return sw...
Definition: frame.hxx:478
SwFrame * GetIndNext()
Definition: frame.hxx:733
bool IsLayoutFrame() const
Definition: frame.hxx:1176
bool IsInSct() const
Definition: frame.hxx:973
void MoveGrammar(sal_Int32 nPos, sal_Int32 nDiff)
TElementType * Next()
Definition: calbck.hxx:380
TElementType * First()
Definition: calbck.hxx:372
const SwFrame * ContainsAny(const bool _bInvestigateFootnoteForSections=false) const
Method <ContainsAny()> doesn't investigate content of footnotes by default.
Definition: findfrm.cxx:131
const OutputDevice & m_rOut
Definition: txtfrm.hxx:953
SwLayoutModeModifier(const OutputDevice &rOutp)
Definition: txtfrm.cxx:701
void Modify(bool bChgToRTL)
Definition: txtfrm.cxx:711
vcl::text::ComplexTextLayoutFlags m_nOldLayoutMode
Definition: txtfrm.hxx:954
Collection of SwLinePortion instances, representing one line of text.
Definition: porlay.hxx:79
SwLineLayout * GetNext()
Definition: porlay.hxx:159
SwLinePortion * GetFirstPortion() const
Definition: porlay.cxx:848
virtual void Height(const SwTwips nNew, const bool bText=true) override
Definition: porlay.cxx:238
bool HasContent() const
Definition: porlay.hxx:133
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:770
bool IsDummy() const
Definition: porlay.hxx:151
SwTwips GetRealHeight() const
Definition: porlay.hxx:169
< purpose of derivation from SwClient: character style for displaying the numbers.
Definition: lineinfo.hxx:39
bool IsRestartEachPage() const
Definition: lineinfo.hxx:89
bool IsCountBlankLines() const
Definition: lineinfo.hxx:83
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
SwLinePortion * GetNextPortion() const
Definition: porlin.hxx:75
bool InNumberGrp() const
Definition: porlin.hxx:109
TextFrameIndex GetLen() const
Definition: porlin.hxx:77
virtual void HandlePortion(SwPortionHandler &rPH) const
Definition: porlin.cxx:319
bool IsFootnoteNumPortion() const
Definition: porlin.hxx:128
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:123
Base class of the Writer document model elements.
Definition: node.hxx:98
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
SwNodeOffset GetIndex() const
Definition: node.hxx:312
bool IsNoTextNode() const
Definition: node.hxx:699
SwDoc & GetDoc()
Definition: node.hxx:233
Merge GetRedlineMergeFlag() const
Definition: node.hxx:116
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:87
A page of the document layout.
Definition: pagefrm.hxx:59
void InvalidateWordCount() const
Definition: pagefrm.hxx:400
void InvalidateAutoCompleteWords() const
Definition: pagefrm.hxx:396
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:205
void InvalidateSmartTags() const
Definition: pagefrm.hxx:392
void InvalidateSpelling() const
Definition: pagefrm.hxx:387
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Definition: porlay.hxx:251
bool IsPrepMustFit() const
Definition: porlay.hxx:310
TextFrameIndex GetParLen() const
Definition: porlay.cxx:2650
SwCharRange & GetReformat()
Definition: porlay.hxx:287
void SetDelta(tools::Long nDelta)
Definition: porlay.hxx:289
void SetPrepAdjust()
Definition: porlay.hxx:311
void SetPrep()
Definition: porlay.hxx:305
bool IsFollowField() const
Definition: porlay.hxx:314
void SetPrepMustFit(const bool bNew)
Definition: porlay.hxx:309
bool HasFly() const
Definition: porlay.hxx:302
void SetPrepWidows()
Definition: porlay.hxx:307
bool IsFootnoteNum() const
Definition: porlay.hxx:319
bool IsFixLineHeight() const
Definition: porlay.hxx:316
bool UpdateQuoVadis(std::u16string_view rQuo)
Is called in SwTextFrame::Prepare()
Definition: txtftn.cxx:1569
SwRepaint & GetRepaint()
Definition: porlay.hxx:285
tools::Long GetDelta() const
Definition: porlay.hxx:290
SwScriptInfo & GetScriptInfo()
Definition: porlay.hxx:291
The SwPortionHandler interface implements a visitor for the layout engine's text portions.
virtual void LineBreak()=0
line break.
virtual void Skip(TextFrameIndex nLength)=0
skip characters.
virtual void Finish()=0
end of paragraph.
SwTwips Width() const
Definition: possiz.hxx:51
bool IsVert() const
Definition: frame.hxx:1372
tools::Long GetHeight(const SwRect &rRect) const
Definition: frame.hxx:1387
void SetWidth(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1395
void SetPosX(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1405
void SetRight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1394
tools::Long GetWidth(const SwRect &rRect) const
Definition: frame.hxx:1386
void SetHeight(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1396
tools::Long GetTop(const SwRect &rRect) const
Definition: frame.hxx:1382
void SetPosY(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1406
void SetTopAndHeight(SwRect &rRect, tools::Long nTop, tools::Long nHeight) const
Definition: frame.hxx:1433
tools::Long GetBottomMargin(const SwFrame &rFrame) const
Definition: frame.hxx:1409
tools::Long GetLeft(const SwRect &rRect) const
Definition: frame.hxx:1384
tools::Long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1383
tools::Long GetRight(const SwRect &rRect) const
Definition: frame.hxx:1385
void SetLeft(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1393
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
bool HasArea() const
Definition: swrect.hxx:300
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
void Pos(const Point &rNew)
Definition: swrect.hxx:171
void SSize(const Size &rNew)
Definition: swrect.hxx:180
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
SwViewShell * GetCurrShell() const
Definition: rootfrm.hxx:215
bool HasMergedParas() const
Definition: wsfrm.cxx:4758
void SetNeedGrammarCheck(bool bVal)
Definition: rootfrm.hxx:271
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:2028
void InitScriptInfo(const SwTextNode &rNode, sw::MergedPara const *pMerged, bool bRTL)
Definition: porlay.cxx:1134
void SetInvalidityA(const TextFrameIndex nPos)
Definition: scriptinfo.hxx:114
static SwSmartTagMgr & Get()
class for collecting anchored objects
Definition: sortedobjs.hxx:49
size_t size() const
Definition: sortedobjs.cxx:43
Small Helper class: Prepares a test format.
Definition: txtfrm.cxx:3173
SwTestFormat(SwTextFrame *pTextFrame, const SwFrame *pPrv, SwTwips nMaxHeight)
Definition: txtfrm.cxx:3182
SwParaPortion * pOldPara
Definition: txtfrm.cxx:3175
SwRect aOldPrt
Definition: txtfrm.cxx:3176
SwTextFrame * pFrame
Definition: txtfrm.cxx:3174
SwRect aOldFrame
Definition: txtfrm.cxx:3176
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
sal_Int32 GetAnyEnd() const
end (if available), else start
Definition: txatbase.hxx:161
virtual const sal_Int32 * GetEnd() const
end position
Definition: txatbase.cxx:48
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
The purpose of this class is to be the universal interface between formatting/text output and the pos...
Definition: txtfly.hxx:122
void SetIgnoreObjsInHeaderFooter(const bool bNew)
Definition: txtfly.hxx:381
void SetIgnoreContour(bool bNew)
Definition: txtfly.hxx:376
void SetIgnoreCurrentFrame(bool bNew)
Definition: txtfly.hxx:371
bool Relax(const SwRect &rRect)
If there is no flying object frame standing in rRect (usually the current row), then we are turning o...
Definition: txtfly.hxx:328
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:366
bool IsOn() const
Definition: txtfly.hxx:323
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
void DelFrames(const SwRootFrame *)
Definition: atrftn.cxx:475
const SwTextNode & GetTextNode() const
Definition: txtftn.hxx:72
void SetIgnoreFly(const bool bNew)
Definition: inftxt.hxx:576
SwTwips CalcFitToContent_()
Definition: itrform2.cxx:2340
void RecalcRealHeight()
Definition: itrform2.cxx:2101
bool IsBreakNow(SwTextMargin &rLine)
Definition: widorp.cxx:219
bool IsKeepAlways() const
Definition: widorp.hxx:38
bool IsInside(SwTextMargin const &rLine) const
BP 18.6.93: Widows.
Definition: widorp.cxx:103
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
void Init()
This is public, as it needs to be called by some methods in order to save the Prepare USE WITH CAUTIO...
Definition: txtfrm.cxx:750
TextFrameIndex CalcFlyPos(SwFrameFormat const *pSearch)
Calculates the position of FlyInContentFrames.
Definition: porfly.cxx:184
SwTextFrame * GetFormatted(bool bForceQuickFormat=false)
In case the SwLineLayout was cleared out of the s_pTextCache, recreate it.
Definition: txtfrm.cxx:3421
bool IsFootnoteNumFrame() const
Am I a FootnoteFrame, with a number at the start of the paragraph?
Definition: txtfrm.hxx:637
sal_uLong GetThisLines() const
Definition: txtfrm.hxx:683
SwDoc & GetDoc()
Definition: txtfrm.hxx:475
void SwitchVerticalToHorizontal(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from vertical to horizontal layout.
Definition: txtfrm.cxx:580
bool TestFormat(const SwFrame *pPrv, SwTwips &nMaxHeight, bool &bSplit)
The WouldFit equivalent for temporarily rewired TextFrames nMaxHeight returns the required size here ...
Definition: txtfrm.cxx:3260
void SetOffset(TextFrameIndex nNewOfst)
Definition: txtfrm.hxx:886
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:876
void CalcFootnoteFlag(TextFrameIndex nStop=TextFrameIndex(COMPLETE_STRING))
Does the Frame have a local footnote (in this Frame or Follow)?
Definition: txtftn.cxx:104
void HideAndShowObjects()
Hides respectively shows objects, which are anchored at paragraph, at/as a character of the paragraph...
Definition: txtfrm.cxx:1570
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1246
LanguageType GetLangOfChar(TextFrameIndex nIndex, sal_uInt16 nScript, bool bNoChar=false) const
Definition: txtfrm.cxx:1343
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:453
bool HasPara() const
Definition: txtfrm.hxx:840
void UpdateOutlineContentVisibilityButton(SwWrtShell *pWrtSh) const
Definition: txtfrm.cxx:4128
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
Definition: txtfrm.cxx:1231
void InvalidateRange(const SwCharRange &, const tools::Long=0)
Definition: txtfrm.cxx:1710
void SwitchLTRtoRTL(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from LTR to RTL layout.
Definition: txtfrm.cxx:683
void SetMergedPara(std::unique_ptr< sw::MergedPara > p)
Definition: txtfrm.cxx:1274
bool FormatQuick(bool bForceQuickFormat)
Definition: frmform.cxx:2151
SwTwips GetBaseVertOffsetForFly(bool bIgnoreFlysAnchoredAtThisFrame) const
Definition: txtfrm.cxx:4107
bool IsWidow() const
Definition: txtfrm.hxx:534
bool IsSwapped() const
Definition: txtfrm.hxx:550
SwTwips mnFlyAnchorOfst
Definition: txtfrm.hxx:189
void HideHidden()
Removes Textfrm's attachments, when it's hidden.
Definition: txtfrm.cxx:1464
void CalcBaseOfstForFly()
Definition: txtfrm.cxx:4049
SwTextNode const * GetTextNodeForFirstText() const
Definition: txtfrm.cxx:1317
SwTwips mnHeightOfLastLine
Definition: txtfrm.hxx:197
virtual bool WouldFit(SwTwips &nMaxHeight, bool &bSplit, bool bTst, bool bMoveBwd) override
nMaxHeight is the required height bSplit indicates, that the paragraph has to be split bTst indicates...
Definition: txtfrm.cxx:3284
bool IsIdxInside(TextFrameIndex nPos, TextFrameIndex nLen) const
Definition: txtfrm.cxx:1679
sal_uLong GetAllLines() const
For displaying the line numbers.
Definition: txtfrm.hxx:682
void ClearPara()
Removes the Line information from the Cache but retains the entry itself.
Definition: txtcache.cxx:104
virtual void Format(vcl::RenderContext *pRenderContext, const SwBorderAttrs *pAttrs=nullptr) override
Calculates the frame area size and the print area, in case they are invalid.
Definition: frmform.cxx:1852
void CalcLineSpace()
Definition: txtfrm.cxx:1750
void PrepWidows(const sal_uInt16 nNeed, bool bNotify)
Definition: txtfrm.cxx:2688
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:465
bool HasFootnote() const
Definition: txtfrm.hxx:537
void SetWidow(const bool bNew)
Definition: txtfrm.hxx:254
void ResetPreps()
Definition: txtfrm.cxx:1351
void SetPara(SwParaPortion *pNew, bool bDelete=true)
Definition: txtcache.cxx:129
void CalcHeightOfLastLine(const bool _bUseFont=false)
method to determine height of last line, needed for proportional line spacing
Definition: txtfrm.cxx:3606
static void repaintTextFrames(const SwTextNode &rNode)
Repaint all text frames of the given text node.
Definition: txtfrm.cxx:4115
SwTwips EmptyHeight() const
Definition: porrst.cxx:333
void CalcAdditionalFirstLineOffset()
Simulate format for a list item paragraph, whose list level attributes are in LABEL_ALIGNMENT mode,...
Definition: txtfrm.cxx:3520
SwTwips GetParHeight() const
Returns the sum of line height in pLine.
Definition: txtfrm.cxx:3381
SwParaPortion * GetPara()
Definition: txtcache.cxx:90
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1252
virtual bool GetInfo(SfxPoolItem &) const override
Definition: txtfrm.cxx:2662
void SetHasRotatedPortions(bool bHasRotatedPortions)
Definition: txtftn.cxx:98
sal_uInt32 mnAllLines
Definition: txtfrm.hxx:184
bool IsLocked() const
Definition: txtfrm.hxx:532
SwTwips mnFlyAnchorOfstNoWrap
Definition: txtfrm.hxx:191
SwTwips CalcFitToContent()
Simulates a formatting as if there were not right margin or Flys or other obstacles and returns the w...
Definition: txtfrm.cxx:3446
void InvalidateRange_(const SwCharRange &, const tools::Long=0)
Definition: txtfrm.cxx:1716
void SwitchHorizontalToVertical(SwRect &rRect) const
Calculates the coordinates of a rectangle when switching from horizontal to vertical layout.
Definition: txtfrm.cxx:473
void VisitPortions(SwPortionHandler &rPH) const
Visit all portions for Accessibility.
Definition: txtfrm.cxx:3967
std::unique_ptr< sw::MergedPara > m_pMergedPara
redline merge data
Definition: txtfrm.hxx:205
tools::Long GetLineSpace(const bool _bNoPropLineSpacing=false) const
Returns the additional line spacing for the next paragraph.
Definition: txtfrm.cxx:3745
void SetFieldFollow(const bool bNew)
Definition: txtfrm.hxx:257
void HideFootnotes(TextFrameIndex nStart, TextFrameIndex nEnd)
Definition: txtfrm.cxx:1476
SwTextFrame(SwTextNode *const, SwFrame *, sw::FrameMode eMode)
Definition: txtfrm.cxx:764
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1267
SwTwips mnFlyAnchorVertOfstNoWrap
The y position for wrap-through flys anchored at this paragraph.
Definition: txtfrm.hxx:193
static TextFrameIndex FindBrk(std::u16string_view aText, TextFrameIndex nStart, TextFrameIndex nEnd)
Returns the first possible break point in the current line.
Definition: txtfrm.cxx:1654
bool IsHiddenNow() const
Hidden.
Definition: txtfrm.cxx:1360
void Format_(SwTextFormatter &rLine, SwTextFormatInfo &rInf, const bool bAdjust=false)
Definition: frmform.cxx:1379
void ChgThisLines()
Definition: txtfrm.cxx:3857
sal_uInt32 mnThisLines
Definition: txtfrm.hxx:185
sal_uInt16 GetLineCount(TextFrameIndex nPos)
Determines the line count.
Definition: txtfrm.cxx:3836
const SwScriptInfo * GetScriptInfo() const
Returns the script info stored at the paraportion.
Definition: txtfrm.cxx:3994
sal_uInt16 GetCacheIdx() const
Definition: txtfrm.hxx:628
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:472
void RemoveFromCache()
Removes this frame completely from the Cache.
Definition: txtcache.cxx:120
void SetOffset_(TextFrameIndex nNewOfst)
Definition: frmform.cxx:810
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true) override
SwContentFrame: the shortcut for the Frames If the void* casts wrongly, it's its own fault!...
Definition: txtfrm.cxx:2768
virtual ~SwTextFrame() override
Definition: txtfrm.cxx:892
SwTwips GetHeightOfLastLine() const
Definition: txtfrm.hxx:782
void ManipOfst(TextFrameIndex const nNewOfst)
Definition: txtfrm.hxx:456
void SwapWidthAndHeight()
Swaps width and height of the text frame.
Definition: txtfrm.cxx:420
void RecalcAllLines()
Definition: txtfrm.cxx:3913
sal_uInt16 FirstLineHeight() const
Returns the first line height.
Definition: txtfrm.cxx:3786
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1293
SwTwips mnAdditionalFirstLineOffset
Definition: txtfrm.hxx:202
bool mbIsSwapped
Definition: txtfrm.hxx:243
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1303
virtual void SwClientNotify(SwModify const &rModify, SfxHint const &rHint) override
Definition: txtfrm.cxx:1996
bool IsEmpty() const
Definition: txtfrm.hxx:536
virtual void DestroyImpl() override
Definition: txtfrm.cxx:850
const SwLineLayout * NextLine()
Definition: itrtxt.cxx:125
TextFrameIndex GetEnd() const
Definition: itrtxt.hxx:89
SwTwips Y() const
Definition: itrtxt.hxx:90
void TruncLines(bool bNoteFollow=false)
Definition: itrtxt.cxx:365
void Bottom()
Definition: itrtxt.cxx:186
const SwLineLayout * PrevLine()
Definition: itrtxt.cxx:171
void Top()
Definition: itrtxt.hxx:99
SwTwips GetLineHeight() const
Definition: itrtxt.hxx:116
const SwLineLayout * Next()
Definition: itrtxt.cxx:108
void CharToLine(TextFrameIndex)
Definition: itrtxt.cxx:194
const SwLineLayout * GetCurr() const
Definition: itrtxt.hxx:83
sal_uInt16 GetLineNr() const
Definition: itrtxt.hxx:87
SwParaPortion * GetPara()
Definition: txtcache.cxx:50
sal_uInt16 GetDropLines() const
Definition: itrtxt.hxx:202
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
void SetWrongDirty(sw::WrongState eNew) const
Definition: txtedt.cxx:2345
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:291
bool IsSmartTagDirty() const
Definition: txtedt.cxx:2375
SwWrongList * GetSmartTags()
Definition: txtedt.cxx:2325
SwWrongList * GetWrong()
Definition: txtedt.cxx:2271
void SetWordCountDirty(bool bNew) const
Definition: txtedt.cxx:2335
void SetGrammarCheckDirty(bool bNew) const
Definition: txtedt.cxx:2360
void SetSmartTags(std::unique_ptr< SwWrongList > pNew)
Definition: txtedt.cxx:2307
void SetSmartTagDirty(bool bNew) const
Definition: txtedt.cxx:2370
void SetAutoCompleteWordDirty(bool bNew) const
Definition: txtedt.cxx:2380
bool IsCountedInList() const
Definition: ndtxt.cxx:4391
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2919
int GetActualListLevel(SwListRedlineType eRedline=SwListRedlineType::SHOW) const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4246
bool IsNumbered(SwRootFrame const *pLayout=nullptr) const
Returns is this text node is numbered.
Definition: ndtxt.cxx:2987
SwGrammarMarkUp * GetGrammarCheck()
Definition: txtedt.cxx:2297
bool IsWrongDirty() const
Definition: txtedt.cxx:2355
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:252
void SetWrong(std::unique_ptr< SwWrongList > pNew)
Definition: txtedt.cxx:2256
const OUString & GetText() const
Definition: ndtxt.hxx:244
void AddToListRLHidden()
Definition: ndtxt.cxx:4478
void RemoveFromListRLHidden()
Definition: ndtxt.cxx:4520
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
Definition: ndtxt.cxx:3153
SwTextFly & GetTextFly()
Definition: inftxt.hxx:387
const std::vector< sal_uInt16 > & getFmtAttrs() const
Definition: hints.hxx:293
sal_uInt16 getWhichAttr() const
Definition: hints.hxx:288
sal_Int32 getStart() const
Definition: hints.hxx:278
sal_Int32 getEnd() const
Definition: hints.hxx:283
bool IsShowOutlineContentVisibilityButton() const
Definition: viewopt.cxx:180
bool IsShowHiddenPara() const
Definition: viewopt.hxx:570
bool IsPrtFormat() const
Definition: viewopt.hxx:707
bool getBrowseMode() const
Definition: viewopt.hxx:638
bool IsShowHiddenChar(bool bHard=false) const
Definition: viewopt.hxx:489
bool IsFieldName() const
Definition: viewopt.hxx:419
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:364
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:451
void InvalidateAccessibleParaAttrs(const SwTextFrame &rTextFrame)
invalidate attributes for paragraphs and paragraph's characters
Definition: viewsh.cxx:2609
vcl::Window * GetWin() const
Definition: viewsh.hxx:363
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:554
Definition: view.hxx:146
SwEditWin & GetEditWin()
Definition: view.hxx:426
void SetInfo(const SwPageFrame *pPg, const SwFrame *pF)
Definition: hints.hxx:375
const SwPageFrame * GetOrigPage() const
Definition: hints.hxx:373
const SwPageFrame * GetPage() const
Definition: hints.hxx:372
void Invalidate(sal_Int32 nBegin, sal_Int32 nEnd)
Definition: wrong.cxx:426
void SetInvalid(sal_Int32 nBegin, sal_Int32 nEnd)
Definition: wrong.cxx:254
void Move(sal_Int32 nPos, sal_Int32 nDiff)
Change all values after the given position.
Definition: wrong.cxx:267
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
const SwView & GetView() const
Definition: wrtsh.hxx:443
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:68
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
void SortIfNeedBe() const
Trigger the sorting if necessary.
Definition: ndhints.hxx:176
size_t Count() const
Definition: ndhints.hxx:142
SwTextAttr * GetSortedByEnd(size_t nPos) const
Definition: ndhints.hxx:158
sal_uInt16 GetOrphansLines() const
Definition: widorp.hxx:61
bool WouldFit(SwTextMargin &rLine, SwTwips &rMaxHeight, bool bTest, bool bMoveBwd)
Definition: widorp.cxx:563
size_type size() const
const sal_Int32 m_nPos
Definition: hints.hxx:118
const sal_Int32 nStart
Definition: hints.hxx:109
const sal_Int32 nLen
Definition: hints.hxx:110
This class is responsible for the delayed display of grammar checks when a paragraph is edited It's a...
SwGrammarMarkUp * getGrammarCheck(SwTextNode &rTextNode, bool bCreate)
getGrammarCheck checks if the given text node is blocked by the current cursor if not,...
const bool isInsideFieldmarkResult
Definition: hints.hxx:101
const sal_Int32 nLen
Definition: hints.hxx:99
const bool isInsideFieldmarkCommand
Definition: hints.hxx:100
const sal_Int32 nPos
Definition: hints.hxx:98
iterate SwTextAttr in potentially merged text frame
Definition: txtfrm.hxx:1005
sw::MergedPara const *const m_pMerged
Definition: txtfrm.hxx:1007
MergedAttrIterBase(SwTextFrame const &rFrame)
Definition: txtfrm.cxx:83
SwTextNode const *const m_pNode
Definition: txtfrm.hxx:1008
SwTextAttr const * NextAttr(SwTextNode const *&rpNode)
Definition: txtfrm.cxx:166
SwTextNode const *const m_pNode
Definition: txtfrm.hxx:1026
MergedAttrIterByEnd(SwTextFrame const &rFrame)
Definition: txtfrm.cxx:151
std::vector< std::pair< SwTextNode const *, SwTextAttr const * > > m_Hints
Definition: txtfrm.hxx:1025
SwTextAttr const * PrevAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:228
MergedAttrIterReverse(SwTextFrame const &rFrame)
Definition: txtfrm.cxx:203
SwTextAttr const * NextAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:91
text is moved into pDestNode
Definition: hints.hxx:85
sal_Int32 nDestStart
Definition: hints.hxx:88
SwTextNode * pDestNode