LibreOffice Module sw (master)  1
txtdrop.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <vcl/svapp.hxx>
22 #include <paratr.hxx>
23 #include <txtfrm.hxx>
24 #include <charfmt.hxx>
25 #include <viewopt.hxx>
26 #include <viewsh.hxx>
27 #include "pordrop.hxx"
28 #include "itrform2.hxx"
29 #include "txtpaint.hxx"
30 #include <blink.hxx>
31 #include <breakit.hxx>
32 #include <com/sun/star/i18n/ScriptType.hpp>
33 #include <com/sun/star/i18n/WordType.hpp>
34 #include <com/sun/star/i18n/XBreakIterator.hpp>
35 #include <editeng/langitem.hxx>
36 #include <charatr.hxx>
37 #include <editeng/fhgtitem.hxx>
38 #include <calbck.hxx>
39 #include <doc.hxx>
40 
41 using namespace ::com::sun::star::i18n;
42 using namespace ::com::sun::star;
43 
49 static bool lcl_IsDropFlyInter( const SwTextFormatInfo &rInf,
50  sal_uInt16 nWidth, sal_uInt16 nHeight )
51 {
52  const SwTextFly& rTextFly = rInf.GetTextFly();
53  if( rTextFly.IsOn() )
54  {
55  SwRect aRect( rInf.GetTextFrame()->getFrameArea().Pos(), Size( nWidth, nHeight) );
56  aRect.Pos() += rInf.GetTextFrame()->getFramePrintArea().Pos();
57  aRect.Pos().AdjustX(rInf.X() );
58  aRect.Pos().setY( rInf.Y() );
59  aRect = rTextFly.GetFrame( aRect );
60  return aRect.HasArea();
61  }
62 
63  return false;
64 }
65 
66 namespace {
67 
68 class SwDropSave
69 {
70  SwTextPaintInfo* pInf;
71  sal_Int32 nIdx;
72  sal_Int32 nLen;
73  long nX;
74  long nY;
75 
76 public:
77  explicit SwDropSave( const SwTextPaintInfo &rInf );
78  ~SwDropSave();
79 };
80 
81 }
82 
83 SwDropSave::SwDropSave( const SwTextPaintInfo &rInf ) :
84  pInf( const_cast<SwTextPaintInfo*>(&rInf) ), nIdx( rInf.GetIdx() ),
85  nLen( rInf.GetLen() ), nX( rInf.X() ), nY( rInf.Y() )
86 {
87 }
88 
89 SwDropSave::~SwDropSave()
90 {
91  pInf->SetIdx(TextFrameIndex(nIdx));
92  pInf->SetLen(TextFrameIndex(nLen));
93  pInf->X( nX );
94  pInf->Y( nY );
95 }
96 
99 {
100  pFollow.reset();
101  pFnt.reset();
102 }
103 
105 SwDropPortion::SwDropPortion( const sal_uInt16 nLineCnt,
106  const sal_uInt16 nDrpHeight,
107  const sal_uInt16 nDrpDescent,
108  const sal_uInt16 nDist )
109  : nLines( nLineCnt ),
110  nDropHeight(nDrpHeight),
111  nDropDescent(nDrpDescent),
112  nDistance(nDist),
113  nFix(0),
114  nY(0)
115 {
117 }
118 
120 {
121  pPart.reset();
122  if( pBlink )
123  pBlink->Delete( this );
124 }
125 
127 sal_Int32 SwTextNode::GetDropLen( sal_Int32 nWishLen ) const
128 {
129  sal_Int32 nEnd = GetText().getLength();
130  if( nWishLen && nWishLen < nEnd )
131  nEnd = nWishLen;
132 
133  if (! nWishLen)
134  {
135  // find first word
136  const SwAttrSet& rAttrSet = GetSwAttrSet();
137  const sal_uInt16 nTextScript = g_pBreakIt->GetRealScriptOfText( GetText(), 0 );
138 
139  LanguageType eLanguage;
140 
141  switch ( nTextScript )
142  {
143  case i18n::ScriptType::ASIAN :
144  eLanguage = rAttrSet.GetCJKLanguage().GetLanguage();
145  break;
146  case i18n::ScriptType::COMPLEX :
147  eLanguage = rAttrSet.GetCTLLanguage().GetLanguage();
148  break;
149  default :
150  eLanguage = rAttrSet.GetLanguage().GetLanguage();
151  break;
152  }
153 
154  Boundary aBound =
155  g_pBreakIt->GetBreakIter()->getWordBoundary( GetText(), 0,
156  g_pBreakIt->GetLocale( eLanguage ), WordType::DICTIONARY_WORD, true );
157 
158  nEnd = aBound.endPos;
159  }
160 
161  sal_Int32 i = 0;
162  for( ; i < nEnd; ++i )
163  {
164  sal_Unicode const cChar = GetText()[i];
165  if( CH_TAB == cChar || CH_BREAK == cChar ||
166  (( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar )
167  && GetTextAttrForCharAt(i)) )
168  break;
169  }
170  return i;
171 }
172 
175 {
176  TextFrameIndex nEnd(GetText().getLength());
177  if (nWishLen && nWishLen < nEnd)
178  nEnd = nWishLen;
179 
180  if (! nWishLen)
181  {
182  // find first word
183  const SwAttrSet& rAttrSet = GetTextNodeForParaProps()->GetSwAttrSet();
184  const sal_uInt16 nTextScript = g_pBreakIt->GetRealScriptOfText(GetText(), 0);
185 
186  LanguageType eLanguage;
187 
188  switch ( nTextScript )
189  {
190  case i18n::ScriptType::ASIAN :
191  eLanguage = rAttrSet.GetCJKLanguage().GetLanguage();
192  break;
193  case i18n::ScriptType::COMPLEX :
194  eLanguage = rAttrSet.GetCTLLanguage().GetLanguage();
195  break;
196  default :
197  eLanguage = rAttrSet.GetLanguage().GetLanguage();
198  break;
199  }
200 
201  Boundary aBound = g_pBreakIt->GetBreakIter()->getWordBoundary(
202  GetText(), 0, g_pBreakIt->GetLocale(eLanguage),
203  WordType::DICTIONARY_WORD, true );
204 
205  nEnd = TextFrameIndex(aBound.endPos);
206  }
207 
208  TextFrameIndex i(0);
209  for ( ; i < nEnd; ++i)
210  {
211  sal_Unicode const cChar = GetText()[sal_Int32(i)];
212  if (CH_TAB == cChar || CH_BREAK == cChar ||
213  CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar)
214  {
215 #ifndef NDEBUG
216  if (CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar)
217  {
218  std::pair<SwTextNode const*, sal_Int32> const pos(MapViewToModel(i));
219  assert(pos.first->GetTextAttrForCharAt(pos.second) != nullptr);
220  }
221 #endif
222  break;
223  }
224  }
225  return i;
226 }
227 
233 bool SwTextNode::GetDropSize(int& rFontHeight, int& rDropHeight, int& rDropDescent) const
234 {
235  rFontHeight = 0;
236  rDropHeight = 0;
237  rDropDescent =0;
238 
239  const SwAttrSet& rSet = GetSwAttrSet();
240  const SwFormatDrop& rDrop = rSet.GetDrop();
241 
242  // Return (0,0) if there is no drop cap at this paragraph
243  if( 1 >= rDrop.GetLines() ||
244  ( !rDrop.GetChars() && !rDrop.GetWholeWord() ) )
245  {
246  return false;
247  }
248 
249  // get text frame
251  for( SwTextFrame* pLastFrame = aIter.First(); pLastFrame; pLastFrame = aIter.Next() )
252  {
253  // Only (master-) text frames can have a drop cap.
254  if (!pLastFrame->IsFollow() &&
255  pLastFrame->GetTextNodeForFirstText() == this)
256  {
257 
258  if( !pLastFrame->HasPara() )
259  pLastFrame->GetFormatted();
260 
261  if ( !pLastFrame->IsEmpty() )
262  {
263  const SwParaPortion* pPara = pLastFrame->GetPara();
264  OSL_ENSURE( pPara, "GetDropSize could not find the ParaPortion, I'll guess the drop cap size" );
265 
266  if ( pPara )
267  {
268  const SwLinePortion* pFirstPor = pPara->GetFirstPortion();
269  if (pFirstPor && pFirstPor->IsDropPortion())
270  {
271  const SwDropPortion* pDrop = static_cast<const SwDropPortion*>(pFirstPor);
272  rDropHeight = pDrop->GetDropHeight();
273  rDropDescent = pDrop->GetDropDescent();
274  if (const SwFont *pFont = pDrop->GetFnt())
275  rFontHeight = pFont->GetSize(pFont->GetActual()).Height();
276  else
277  {
278  const SvxFontHeightItem& rItem = rSet.Get(RES_CHRATR_FONTSIZE);
279  rFontHeight = rItem.GetHeight();
280  }
281  }
282  }
283  }
284  break;
285  }
286  }
287 
288  if (rFontHeight==0 && rDropHeight==0 && rDropDescent==0)
289  {
290  const sal_uInt16 nLines = rDrop.GetLines();
291 
292  const SvxFontHeightItem& rItem = rSet.Get( RES_CHRATR_FONTSIZE );
293  rFontHeight = rItem.GetHeight();
294  rDropHeight = nLines * rFontHeight;
295  rDropDescent = rFontHeight / 5;
296  return false;
297  }
298 
299  return true;
300 }
301 
303 void SwDropPortion::PaintText( const SwTextPaintInfo &rInf ) const
304 {
305  OSL_ENSURE( nDropHeight && pPart && nLines != 1, "Drop Portion painted twice" );
306 
307  const SwDropPortionPart* pCurrPart = GetPart();
308  const TextFrameIndex nOldLen = GetLen();
309  const sal_uInt16 nOldWidth = Width();
310  const sal_uInt16 nOldAscent = GetAscent();
311 
312  const SwTwips nBasePosY = rInf.Y();
313  const_cast<SwTextPaintInfo&>(rInf).Y( nBasePosY + nY );
314  const_cast<SwDropPortion*>(this)->SetAscent( nOldAscent + nY );
315  SwDropSave aSave( rInf );
316  // for text inside drop portions we let vcl handle the text directions
317  SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() );
318  aLayoutModeModifier.SetAuto();
319 
320  while ( pCurrPart )
321  {
322  const_cast<SwDropPortion*>(this)->SetLen( pCurrPart->GetLen() );
323  const_cast<SwDropPortion*>(this)->Width( pCurrPart->GetWidth() );
324  const_cast<SwTextPaintInfo&>(rInf).SetLen( pCurrPart->GetLen() );
325  SwFontSave aFontSave( rInf, &pCurrPart->GetFont() );
326  const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(pCurrPart->GetJoinBorderWithNext());
327  const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(pCurrPart->GetJoinBorderWithPrev());
328 
329  if ( rInf.OnWin() &&
331  (!pCurrPart->GetFont().GetBackColor() || *pCurrPart->GetFont().GetBackColor() == COL_TRANSPARENT) )
332  {
333  rInf.DrawBackground( *this );
334  }
335 
336  SwTextPortion::Paint( rInf );
337 
338  const_cast<SwTextPaintInfo&>(rInf).SetIdx( rInf.GetIdx() + pCurrPart->GetLen() );
339  const_cast<SwTextPaintInfo&>(rInf).X( rInf.X() + pCurrPart->GetWidth() );
340  pCurrPart = pCurrPart->GetFollow();
341  }
342 
343  const_cast<SwTextPaintInfo&>(rInf).Y( nBasePosY );
344  const_cast<SwDropPortion*>(this)->Width( nOldWidth );
345  const_cast<SwDropPortion*>(this)->SetLen( nOldLen );
346  const_cast<SwDropPortion*>(this)->SetAscent( nOldAscent );
347  const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(false);
348  const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(false);
349 }
350 
351 void SwDropPortion::PaintDrop( const SwTextPaintInfo &rInf ) const
352 {
353  // normal output is being done during the normal painting
354  if( ! nDropHeight || ! pPart || nLines == 1 )
355  return;
356 
357  // set the lying values
358  const sal_uInt16 nOldHeight = Height();
359  const sal_uInt16 nOldWidth = Width();
360  const sal_uInt16 nOldAscent = GetAscent();
361  const SwTwips nOldPosY = rInf.Y();
362  const SwTwips nOldPosX = rInf.X();
363  const SwParaPortion *pPara = rInf.GetParaPortion();
364  const Point aOutPos( nOldPosX, nOldPosY - pPara->GetAscent()
365  - pPara->GetRealHeight() + pPara->Height() );
366  // make good for retouching
367 
368  // Set baseline
369  const_cast<SwTextPaintInfo&>(rInf).Y( aOutPos.Y() + nDropHeight );
370 
371  // for background
372  const_cast<SwDropPortion*>(this)->Height( nDropHeight + nDropDescent );
373  const_cast<SwDropPortion*>(this)->SetAscent( nDropHeight );
374 
375  // Always adapt Clipregion to us, never set it off using the existing ClipRect
376  // as that could be set for the line
377  SwRect aClipRect;
378  if ( rInf.OnWin() )
379  {
380  aClipRect = SwRect( aOutPos, SvLSize() );
381  aClipRect.Intersection( rInf.GetPaintRect() );
382  }
383  SwSaveClip aClip( const_cast<OutputDevice*>(rInf.GetOut()) );
384  aClip.ChgClip( aClipRect, rInf.GetTextFrame() );
385 
386  // Just do, what we always do ...
387  PaintText( rInf );
388 
389  // save old values
390  const_cast<SwDropPortion*>(this)->Height( nOldHeight );
391  const_cast<SwDropPortion*>(this)->Width( nOldWidth );
392  const_cast<SwDropPortion*>(this)->SetAscent( nOldAscent );
393  const_cast<SwTextPaintInfo&>(rInf).Y( nOldPosY );
394 }
395 
396 void SwDropPortion::Paint( const SwTextPaintInfo &rInf ) const
397 {
398  // normal output is being done here
399  if( ! nDropHeight || ! pPart || 1 == nLines )
400  {
401  if ( rInf.OnWin() &&
403  rInf.DrawBackground( *this );
404 
405  // make sure that font is not rotated
406  std::unique_ptr<SwFont> pTmpFont;
407  if ( rInf.GetFont()->GetOrientation( rInf.GetTextFrame()->IsVertical() ) )
408  {
409  pTmpFont.reset(new SwFont( *rInf.GetFont() ));
410  pTmpFont->SetVertical( 0, rInf.GetTextFrame()->IsVertical() );
411  }
412 
413  SwFontSave aFontSave( rInf, pTmpFont.get() );
414  // for text inside drop portions we let vcl handle the text directions
415  SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() );
416  aLayoutModeModifier.SetAuto();
417 
418  SwTextPortion::Paint( rInf );
419  }
420 }
421 
423 {
424  const TextFrameIndex nOldLen = GetLen();
425  const TextFrameIndex nOldInfLen = rInf.GetLen();
426  if (!SwTextPortion::Format( rInf ))
427  return false;
428 
429  // looks like shit, but what can we do?
430  rInf.SetUnderflow( nullptr );
431  Truncate();
432  SetLen( nOldLen );
433  rInf.SetLen( nOldInfLen );
434 
435  return true;
436 }
437 
439 {
440  sal_uInt16 nMyX = 0;
441  TextFrameIndex nIdx(0);
442 
443  const SwDropPortionPart* pCurrPart = GetPart();
444 
445  // skip parts
446  while ( pCurrPart && nIdx + pCurrPart->GetLen() < rInf.GetLen() )
447  {
448  nMyX = nMyX + pCurrPart->GetWidth();
449  nIdx = nIdx + pCurrPart->GetLen();
450  pCurrPart = pCurrPart->GetFollow();
451  }
452 
453  TextFrameIndex const nOldIdx = rInf.GetIdx();
454  TextFrameIndex const nOldLen = rInf.GetLen();
455 
456  const_cast<SwTextSizeInfo&>(rInf).SetIdx( nIdx );
457  const_cast<SwTextSizeInfo&>(rInf).SetLen( rInf.GetLen() - nIdx );
458 
459  if( pCurrPart )
460  {
461  const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(pCurrPart->GetJoinBorderWithNext());
462  const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(pCurrPart->GetJoinBorderWithPrev());
463  }
464 
465  // robust
466  SwFontSave aFontSave( rInf, pCurrPart ? &pCurrPart->GetFont() : nullptr );
467  SwPosSize aPosSize( SwTextPortion::GetTextSize( rInf ) );
468  aPosSize.Width( aPosSize.Width() + nMyX );
469 
470  const_cast<SwTextSizeInfo&>(rInf).SetIdx( nOldIdx );
471  const_cast<SwTextSizeInfo&>(rInf).SetLen( nOldLen );
472  if( pCurrPart )
473  {
474  const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(false);
475  const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(false);
476  }
477 
478  return aPosSize;
479 }
480 
482 {
483  return TextFrameIndex(0);
484 }
485 
486 void SwTextFormatter::CalcDropHeight( const sal_uInt16 nLines )
487 {
488  const SwLinePortion *const pOldCurr = GetCurr();
489  sal_uInt16 nDropHght = 0;
490  sal_uInt16 nAscent = 0;
491  sal_uInt16 nHeight = 0;
492  sal_uInt16 nDropLns = 0;
493  const bool bRegisterOld = IsRegisterOn();
494  m_bRegisterOn = false;
495 
496  Top();
497 
498  while( GetCurr()->IsDummy() )
499  {
500  if ( !Next() )
501  break;
502  }
503 
504  // If we have only one line we return 0
505  if( GetNext() || GetDropLines() == 1 )
506  {
507  for( ; nDropLns < nLines; nDropLns++ )
508  {
509  if ( GetCurr()->IsDummy() )
510  break;
511  else
512  {
513  CalcAscentAndHeight( nAscent, nHeight );
514  nDropHght = nDropHght + nHeight;
515  m_bRegisterOn = bRegisterOld;
516  }
517  if ( !Next() )
518  {
519  nDropLns++;
520  break;
521  }
522  }
523 
524  // We hit the line ascent when reaching the last line!
525  nDropHght = nDropHght - nHeight;
526  nDropHght = nDropHght + nAscent;
527  Top();
528  }
529  m_bRegisterOn = bRegisterOld;
530  SetDropDescent( nHeight - nAscent );
531  SetDropHeight( nDropHght );
532  SetDropLines( nDropLns );
533  // Find old position!
534  while( pOldCurr != GetCurr() )
535  {
536  if( !Next() )
537  {
538  OSL_ENSURE( false, "SwTextFormatter::_CalcDropHeight: left Toulouse" );
539  break;
540  }
541  }
542 }
543 
548 void SwTextFormatter::GuessDropHeight( const sal_uInt16 nLines )
549 {
550  OSL_ENSURE( nLines, "GuessDropHeight: Give me more Lines!" );
551  sal_uInt16 nAscent = 0;
552  sal_uInt16 nHeight = 0;
553  SetDropLines( nLines );
554  if ( GetDropLines() > 1 )
555  {
556  CalcRealHeight();
557  CalcAscentAndHeight( nAscent, nHeight );
558  }
559  SetDropDescent( nHeight - nAscent );
560  SetDropHeight( nHeight * nLines - GetDropDescent() );
561 }
562 
564 {
565  if( !m_pDropFormat )
566  return nullptr;
567 
569  nPorLen = m_pFrame->GetDropLen( nPorLen );
570  if( !nPorLen )
571  {
572  ClearDropFormat();
573  return nullptr;
574  }
575 
576  SwDropPortion *pDropPor = nullptr;
577 
578  // first or second round?
579  if ( !( GetDropHeight() || IsOnceMore() ) )
580  {
581  if ( GetNext() )
583  else
585  }
586 
587  // the DropPortion
588  if( GetDropHeight() )
589  pDropPor = new SwDropPortion( GetDropLines(), GetDropHeight(),
591  else
592  pDropPor = new SwDropPortion( 0,0,0,m_pDropFormat->GetDistance() );
593 
594  pDropPor->SetLen( nPorLen );
595 
596  // If it was not possible to create a proper drop cap portion
597  // due to avoiding endless loops. We return a drop cap portion
598  // with an empty SwDropCapPart. For these portions the current
599  // font is used.
600  if ( GetDropLines() < 2 )
601  {
602  SetPaintDrop( true );
603  return pDropPor;
604  }
605 
606  // build DropPortionParts:
607  OSL_ENSURE( ! rInf.GetIdx(), "Drop Portion not at 0 position!" );
608  TextFrameIndex nNextChg(0);
609  const SwCharFormat* pFormat = m_pDropFormat->GetCharFormat();
610  SwDropPortionPart* pCurrPart = nullptr;
611 
612  while ( nNextChg < nPorLen )
613  {
614  // check for attribute changes and if the portion has to split:
615  Seek( nNextChg );
616 
617  // the font is deleted in the destructor of the drop portion part
618  SwFont* pTmpFnt = new SwFont( *rInf.GetFont() );
619  if ( pFormat )
620  {
621  const SwAttrSet& rSet = pFormat->GetAttrSet();
622  pTmpFnt->SetDiffFnt(&rSet, &m_pFrame->GetDoc().getIDocumentSettingAccess());
623  }
624 
625  // we do not allow a vertical font for the drop portion
626  pTmpFnt->SetVertical( 0, rInf.GetTextFrame()->IsVertical() );
627 
628  // find next attribute change / script change
629  const TextFrameIndex nTmpIdx = nNextChg;
630  TextFrameIndex nNextAttr = GetNextAttr();
631  nNextChg = m_pScriptInfo->NextScriptChg( nTmpIdx );
632  if( nNextChg > nNextAttr )
633  nNextChg = nNextAttr;
634  if ( nNextChg > nPorLen )
635  nNextChg = nPorLen;
636 
637  std::unique_ptr<SwDropPortionPart> pPart(
638  new SwDropPortionPart( *pTmpFnt, nNextChg - nTmpIdx ) );
639  auto pPartTemp = pPart.get();
640 
641  if ( ! pCurrPart )
642  pDropPor->SetPart( std::move(pPart) );
643  else
644  pCurrPart->SetFollow( std::move(pPart) );
645 
646  pCurrPart = pPartTemp;
647  }
648 
649  SetPaintDrop( true );
650  return pDropPor;
651 }
652 
654 {
655  const SwDropPortion *pDrop = GetInfo().GetParaPortion()->FindDropPortion();
656  OSL_ENSURE( pDrop, "DrapCop-Portion not available." );
657  if( !pDrop )
658  return;
659 
660  const SwTwips nOldY = GetInfo().Y();
661 
662  Top();
663 
667  GetInfo().ResetKanaIdx();
668 
669  // 8047: Drops and Dummies
670  while( !m_pCurr->GetLen() && Next() )
671  ;
672 
673  // MarginPortion and Adjustment!
674  const SwLinePortion *pPor = m_pCurr->GetFirstPortion();
675  long nX = 0;
676  while( pPor && !pPor->IsDropPortion() )
677  {
678  nX = nX + pPor->Width();
679  pPor = pPor->GetNextPortion();
680  }
681  Point aLineOrigin( GetTopLeft() );
682 
683  aLineOrigin.AdjustX(nX );
684  sal_uInt16 nTmpAscent, nTmpHeight;
685  CalcAscentAndHeight( nTmpAscent, nTmpHeight );
686  aLineOrigin.AdjustY(nTmpAscent );
687  GetInfo().SetIdx( GetStart() );
688  GetInfo().SetPos( aLineOrigin );
689  GetInfo().SetLen( pDrop->GetLen() );
690 
691  pDrop->PaintDrop( GetInfo() );
692 
693  GetInfo().Y( nOldY );
694 }
695 
696 // Since the calculation of the font size is expensive, this is being
697 // channeled through a DropCapCache
698 #define DROP_CACHE_SIZE 10
699 
701 {
702  const void* aFontCacheId[ DROP_CACHE_SIZE ] = {};
703  OUString aText[ DROP_CACHE_SIZE ];
704  sal_uInt16 aFactor[ DROP_CACHE_SIZE ];
705  sal_uInt16 aWishedHeight[ DROP_CACHE_SIZE ] = {};
707  sal_uInt16 nIndex = 0;
708 public:
709  SwDropCapCache() = default;
710  void CalcFontSize( SwDropPortion* pDrop, SwTextFormatInfo &rInf );
711 };
712 
714 {
715  delete pDropCapCache;
716 }
717 
719 {
720  const void* nFntCacheId = nullptr;
721  sal_uInt16 nTmpIdx = 0;
722 
723  OSL_ENSURE( pDrop->GetPart(),"DropPortion without part during font calculation");
724 
725  SwDropPortionPart* pCurrPart = pDrop->GetPart();
726  const bool bUseCache = ! pCurrPart->GetFollow() && !pCurrPart->GetFont().HasBorder();
727  TextFrameIndex nIdx = rInf.GetIdx();
728  OUString aStr(rInf.GetText().copy(sal_Int32(nIdx), sal_Int32(pCurrPart->GetLen())));
729 
730  long nDescent = 0;
731  long nFactor = -1;
732 
733  if ( bUseCache )
734  {
735  SwFont& rFnt = pCurrPart->GetFont();
736  rFnt.CheckFontCacheId( rInf.GetVsh(), rFnt.GetActual() );
737  rFnt.GetFontCacheId( nFntCacheId, nTmpIdx, rFnt.GetActual() );
738 
739  nTmpIdx = 0;
740 
741  while( nTmpIdx < DROP_CACHE_SIZE &&
742  ( aText[ nTmpIdx ] != aStr || aFontCacheId[ nTmpIdx ] != nFntCacheId ||
743  aWishedHeight[ nTmpIdx ] != pDrop->GetDropHeight() ) )
744  ++nTmpIdx;
745  }
746 
747  // we have to calculate a new font scaling factor if
748  // 1. we did not find a scaling factor in the cache or
749  // 2. we are not allowed to use the cache because the drop portion
750  // consists of more than one part
751  if( nTmpIdx >= DROP_CACHE_SIZE || ! bUseCache )
752  {
753  ++nIndex;
755  nTmpIdx = nIndex;
756 
757  long nWishedHeight = pDrop->GetDropHeight();
758  long nAscent = 0;
759 
760  // find out biggest font size for initial scaling factor
761  long nMaxFontHeight = 1;
762  while ( pCurrPart )
763  {
764  const SwFont& rFnt = pCurrPart->GetFont();
765  const long nCurrHeight = rFnt.GetHeight( rFnt.GetActual() );
766  if ( nCurrHeight > nMaxFontHeight )
767  nMaxFontHeight = nCurrHeight;
768 
769  pCurrPart = pCurrPart->GetFollow();
770  }
771 
772  nFactor = ( 1000 * nWishedHeight ) / nMaxFontHeight;
773 
774  if ( bUseCache )
775  {
776  // save keys for cache
777  aFontCacheId[ nTmpIdx ] = nFntCacheId;
778  aText[ nTmpIdx ] = aStr;
779  aWishedHeight[ nTmpIdx ] = sal_uInt16(nWishedHeight);
780  // save initial scaling factor
781  aFactor[ nTmpIdx ] = static_cast<sal_uInt16>(nFactor);
782  }
783 
784  bool bGrow = (pDrop->GetLen() != TextFrameIndex(0));
785 
786  // for growing control
787  long nMax = USHRT_MAX;
788  long nMin = 0;
789 #if OSL_DEBUG_LEVEL > 1
790  long nGrow = 0;
791 #endif
792 
793  bool bWinUsed = false;
794  vcl::Font aOldFnt;
795  MapMode aOldMap( MapUnit::MapTwip );
796  OutputDevice* pOut = rInf.GetOut();
797  OutputDevice* pWin;
798  if( rInf.GetVsh() && rInf.GetVsh()->GetWin() )
799  pWin = rInf.GetVsh()->GetWin();
800  else
802 
803  while( bGrow )
804  {
805  // reset pCurrPart to first part
806  pCurrPart = pDrop->GetPart();
807  bool bFirstGlyphRect = true;
808  tools::Rectangle aCommonRect, aRect;
809 
810  while ( pCurrPart )
811  {
812  // current font
813  SwFont& rFnt = pCurrPart->GetFont();
814 
815  // Get height including proportion
816  const long nCurrHeight = rFnt.GetHeight( rFnt.GetActual() );
817 
818  // Get without proportion
819  const sal_uInt8 nOldProp = rFnt.GetPropr();
820  rFnt.SetProportion( 100 );
821  Size aOldSize( 0, rFnt.GetHeight( rFnt.GetActual() ) );
822 
823  Size aNewSize( 0, ( nFactor * nCurrHeight ) / 1000 );
824  rFnt.SetSize( aNewSize, rFnt.GetActual() );
825  rFnt.ChgPhysFnt( rInf.GetVsh(), *pOut );
826 
827  nAscent = rFnt.GetAscent( rInf.GetVsh(), *pOut );
828 
829  // we get the rectangle that covers all chars
830  bool bHaveGlyphRect = pOut->GetTextBoundRect( aRect, rInf.GetText(), 0,
831  sal_Int32(nIdx), sal_Int32(pCurrPart->GetLen()))
832  && ! aRect.IsEmpty();
833 
834  if ( ! bHaveGlyphRect )
835  {
836  // getting glyph boundaries failed for some reason,
837  // we take the window for calculating sizes
838  if ( pWin )
839  {
840  if ( ! bWinUsed )
841  {
842  bWinUsed = true;
843  aOldMap = pWin->GetMapMode( );
844  pWin->SetMapMode( MapMode( MapUnit::MapTwip ) );
845  aOldFnt = pWin->GetFont();
846  }
847  pWin->SetFont( rFnt.GetActualFont() );
848 
849  bHaveGlyphRect = pWin->GetTextBoundRect( aRect, rInf.GetText(), 0,
850  sal_Int32(nIdx), sal_Int32(pCurrPart->GetLen()))
851  && ! aRect.IsEmpty();
852  }
853  if (!bHaveGlyphRect)
854  {
855  // We do not have a window or our window could not
856  // give us glyph boundaries.
857  aRect = tools::Rectangle( Point( 0, 0 ), Size( 0, nAscent ) );
858  }
859  }
860 
861  // Now we (hopefully) have a bounding rectangle for the
862  // glyphs of the current portion and the ascent of the current
863  // font
864 
865  // reset font size and proportion
866  rFnt.SetSize( aOldSize, rFnt.GetActual() );
867  rFnt.SetProportion( nOldProp );
868 
869  // Modify the bounding rectangle with the borders
870  // Robust: If the padding is so big as drop cap letter has no enough space than
871  // remove all padding.
872  if( rFnt.GetTopBorderSpace() + rFnt.GetBottomBorderSpace() >= nWishedHeight )
873  {
874  rFnt.SetTopBorderDist(0);
875  rFnt.SetBottomBorderDist(0);
876  rFnt.SetRightBorderDist(0);
877  rFnt.SetLeftBorderDist(0);
878  }
879 
880  if( rFnt.GetTopBorder() )
881  {
882  aRect.setHeight(aRect.GetHeight() + rFnt.GetTopBorderSpace());
883  aRect.setY(aRect.getY() - rFnt.GetTopBorderSpace());
884  }
885 
886  if( rFnt.GetBottomBorder() )
887  {
888  aRect.setHeight(aRect.GetHeight() + rFnt.GetBottomBorderSpace());
889  }
890 
891  if ( bFirstGlyphRect )
892  {
893  aCommonRect = aRect;
894  bFirstGlyphRect = false;
895  }
896  else
897  aCommonRect.Union( aRect );
898 
899  nIdx = nIdx + pCurrPart->GetLen();
900  pCurrPart = pCurrPart->GetFollow();
901  }
902 
903  // now we have a union ( aCommonRect ) of all glyphs with
904  // respect to a common baseline : 0
905 
906  // get descent and ascent from union
907  if ( rInf.GetTextFrame()->IsVertical() )
908  {
909  nDescent = aCommonRect.Left();
910  nAscent = aCommonRect.Right();
911 
912  if ( nDescent < 0 )
913  nDescent = -nDescent;
914  }
915  else
916  {
917  nDescent = aCommonRect.Bottom();
918  nAscent = aCommonRect.Top();
919  }
920  if ( nAscent < 0 )
921  nAscent = -nAscent;
922 
923  const long nHght = nAscent + nDescent;
924  if ( nHght )
925  {
926  if ( nHght > nWishedHeight )
927  nMax = nFactor;
928  else
929  {
930  if ( bUseCache )
931  aFactor[ nTmpIdx ] = static_cast<sal_uInt16>(nFactor);
932  nMin = nFactor;
933  }
934 
935  nFactor = ( nFactor * nWishedHeight ) / nHght;
936  bGrow = ( nFactor > nMin ) && ( nFactor < nMax );
937 #if OSL_DEBUG_LEVEL > 1
938  if ( bGrow )
939  nGrow++;
940 #endif
941  nIdx = rInf.GetIdx();
942  }
943  else
944  bGrow = false;
945  }
946 
947  if ( bWinUsed )
948  {
949  // reset window if it has been used
950  pWin->SetMapMode( aOldMap );
951  pWin->SetFont( aOldFnt );
952  }
953 
954  if ( bUseCache )
955  aDescent[ nTmpIdx ] = -short( nDescent );
956  }
957 
958  pCurrPart = pDrop->GetPart();
959 
960  // did made any new calculations or did we use the cache?
961  if ( -1 == nFactor )
962  {
963  nFactor = aFactor[ nTmpIdx ];
964  nDescent = aDescent[ nTmpIdx ];
965  }
966  else
967  nDescent = -nDescent;
968 
969  while ( pCurrPart )
970  {
971  // scale current font
972  SwFont& rFnt = pCurrPart->GetFont();
973  Size aNewSize( 0, ( nFactor * rFnt.GetHeight( rFnt.GetActual() ) ) / 1000 );
974 
975  const sal_uInt8 nOldProp = rFnt.GetPropr();
976  rFnt.SetProportion( 100 );
977  rFnt.SetSize( aNewSize, rFnt.GetActual() );
978  rFnt.SetProportion( nOldProp );
979 
980  pCurrPart = pCurrPart->GetFollow();
981  }
982  pDrop->SetY( static_cast<short>(nDescent) );
983 }
984 
986 {
987  bool bFull = false;
988  nFix = static_cast<sal_uInt16>(rInf.X());
989 
990  SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() );
991  aLayoutModeModifier.SetAuto();
992 
993  if( nDropHeight && pPart && nLines!=1 )
994  {
995  if( !pDropCapCache )
997 
998  // adjust font sizes to fit into the rectangle
999  pDropCapCache->CalcFontSize( this, rInf );
1000 
1001  const long nOldX = rInf.X();
1002  {
1003  SwDropSave aSave( rInf );
1004  SwDropPortionPart* pCurrPart = pPart.get();
1005 
1006  while ( pCurrPart )
1007  {
1008  rInf.SetLen( pCurrPart->GetLen() );
1009  SwFont& rFnt = pCurrPart->GetFont();
1010  {
1011  SwFontSave aFontSave( rInf, &rFnt );
1014  bFull = FormatText( rInf );
1015 
1016  if ( bFull )
1017  break;
1018  }
1019 
1020  const SwTwips nTmpWidth =
1021  ( InSpaceGrp() && rInf.GetSpaceAdd() ) ?
1022  Width() + CalcSpacing( rInf.GetSpaceAdd(), rInf ) :
1023  Width();
1024 
1025  // set values
1026  pCurrPart->SetWidth( static_cast<sal_uInt16>(nTmpWidth) );
1027 
1028  // Move
1029  rInf.SetIdx( rInf.GetIdx() + pCurrPart->GetLen() );
1030  rInf.X( rInf.X() + nTmpWidth );
1031  pCurrPart = pCurrPart->GetFollow();
1032  }
1033  SetJoinBorderWithNext(false);
1034  SetJoinBorderWithPrev(false);
1035  Width( static_cast<sal_uInt16>(rInf.X() - nOldX) );
1036  }
1037 
1038  // reset my length
1039  SetLen( rInf.GetLen() );
1040 
1041  // Quit when Flys are overlapping
1042  if( ! bFull )
1043  bFull = lcl_IsDropFlyInter( rInf, Width(), nDropHeight );
1044 
1045  if( bFull )
1046  {
1047  // FormatText could have caused nHeight to be 0
1048  if ( !Height() )
1049  Height( rInf.GetTextHeight() );
1050 
1051  // And now for another round
1052  nDropHeight = nLines = 0;
1053  pPart.reset();
1054 
1055  // Meanwhile use normal formatting
1056  bFull = SwTextPortion::Format( rInf );
1057  }
1058  else
1059  rInf.SetDropInit( true );
1060 
1061  Height( rInf.GetTextHeight() );
1062  SetAscent( rInf.GetAscent() );
1063  }
1064  else
1065  bFull = SwTextPortion::Format( rInf );
1066 
1067  if( bFull )
1068  nDistance = 0;
1069  else
1070  {
1071  const sal_uInt16 nWant = Width() + GetDistance();
1072  const sal_uInt16 nRest = static_cast<sal_uInt16>(rInf.Width() - rInf.X());
1073  if( ( nWant > nRest ) ||
1075  nDistance = 0;
1076 
1077  Width( Width() + nDistance );
1078  }
1079  return bFull;
1080 }
1081 
1082 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetLeftBorderDist(const sal_uInt16 nLeftDist)
Definition: swfont.hxx:856
SwScriptInfo * m_pScriptInfo
Definition: itratr.hxx:40
std::deque< sal_uInt16 > * GetpKanaComp() const
Definition: porlay.hxx:184
const sal_Unicode CH_BREAK
Definition: swfont.hxx:43
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
const SwFormatDrop * m_pDropFormat
Definition: itrform2.hxx:35
bool IsRegisterOn() const
Definition: itrtxt.hxx:94
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: txtdrop.cxx:481
const std::optional< editeng::SvxBorderLine > & GetBottomBorder() const
Definition: swfont.hxx:340
SwViewShell * GetVsh()
Definition: inftxt.hxx:228
~SwDropPortionPart()
SwDropPortionPart DTor.
Definition: txtdrop.cxx:98
void setHeight(long n)
OUString aText[DROP_CACHE_SIZE]
Definition: txtdrop.cxx:703
const SwFormatDrop & GetDrop(bool=true) const
Definition: paratr.hxx:194
long GetHeight() const
bool IsPagePreview() const
Definition: viewopt.hxx:607
sal_uInt16 GetDropDescent() const
Definition: itrtxt.hxx:207
bool GetWholeWord() const
Definition: paratr.hxx:92
TextFrameIndex NextScriptChg(TextFrameIndex nPos) const
Definition: porlay.cxx:1612
bool InSpaceGrp() const
Definition: porlin.hxx:109
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:170
sal_uInt16 Height() const
Definition: possiz.hxx:44
SwFont * GetFont()
Definition: inftxt.hxx:238
const OUString & GetText() const
Definition: ndtxt.hxx:211
void SetWidth(sal_uInt16 nNew)
Definition: pordrop.hxx:53
void SetY(short nNew)
Definition: pordrop.hxx:97
TextFrameIndex GetStart() const
Definition: itrtxt.hxx:88
void SetPos(const Point &rNew)
Definition: inftxt.hxx:436
void GuessDropHeight(const sal_uInt16 nLines)
We assume that the font height doesn't change and that at first there are at least as many lines...
Definition: txtdrop.cxx:548
sal_uInt8 GetPropr() const
Definition: swfont.hxx:280
bool m_bRegisterOn
Definition: itrtxt.hxx:45
sal_uInt8 GetLines() const
Definition: paratr.hxx:86
const SwRect & getFramePrintArea() const
Definition: frame.hxx:178
static void DeleteDropCapCache()
Definition: txtdrop.cxx:713
const SvxLanguageItem & GetLanguage(bool=true) const
Definition: charatr.hxx:92
The purpose of this class is to be the universal interface between formatting/text output and the pos...
Definition: txtfly.hxx:119
Size SvLSize() const
Definition: possiz.hxx:48
const SvxFont & GetActualFont() const
Definition: swfont.hxx:185
sal_uInt16 GetDropHeight() const
Definition: itrtxt.hxx:205
TElementType * Next()
Definition: calbck.hxx:373
const SvxLanguageItem & GetCJKLanguage(bool=true) const
Definition: charatr.hxx:94
sal_uInt16 GetTextHeight() const
Definition: inftxt.hxx:719
const void * aFontCacheId[DROP_CACHE_SIZE]
Definition: txtdrop.cxx:702
void SetLen(TextFrameIndex const nLen)
Definition: porlin.hxx:75
const MapMode & GetMapMode() const
TextFrameIndex GetNextAttr() const
Definition: itratr.cxx:728
long SwTwips
Definition: swtypes.hxx:49
bool HasBorder() const
Check whether font has any border on any side.
Definition: swfont.hxx:923
SwDropPortionPart * GetPart() const
Definition: pordrop.hxx:94
const SwLineLayout * Next()
Definition: itrtxt.cxx:106
std::unique_ptr< SwDropPortionPart > pPart
Definition: pordrop.hxx:64
void Pos(const Point &rNew)
Definition: swrect.hxx:168
static bool lcl_IsDropFlyInter(const SwTextFormatInfo &rInf, sal_uInt16 nWidth, sal_uInt16 nHeight)
Calculates if a drop caps portion intersects with a fly The width and height of the drop caps portion...
Definition: txtdrop.cxx:49
void SetKanaComp(std::deque< sal_uInt16 > *pNew)
Definition: inftxt.hxx:329
void SetJoinBorderWithPrev(const bool bJoinPrev)
Definition: porlin.hxx:170
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1280
long getY() const
sal_uInt16 GetOrientation(const bool bVertLayout=false, const bool bVertFormatLRBT=false) const
Definition: swfont.cxx:433
Collection of SwLineLayout instances, represents the paragraph text in Writer layout.
Definition: porlay.hxx:229
void SetMapMode()
void SetBottomBorderDist(const sal_uInt16 nBottomDist)
Definition: swfont.hxx:842
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: portxt.cxx:523
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
Definition: breakit.cxx:83
bool Seek(TextFrameIndex nPos)
Enables the attributes used at char pos nPos in the logical font.
Definition: itratr.cxx:301
std::vector< long > * GetpLLSpaceAdd() const
Definition: porlay.hxx:179
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, const long *pDXArray=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr) const
long GetLen(const Point &rPnt)
static OutputDevice * GetDefaultDevice()
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:3051
bool IsEmpty() const
#define CH_TXTATR_BREAKWORD
Definition: hintids.hxx:136
SwRect GetFrame(const SwRect &rPortion) const
Definition: txtfly.hxx:356
sal_uInt16 sal_Unicode
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
SwDropCapCache()=default
bool IsReadonly() const
Definition: viewopt.hxx:435
long Right() const
#define CH_TXTATR_INWORD
Definition: hintids.hxx:137
const SwRect & getFrameArea() const
Definition: frame.hxx:177
size_t pos
const vcl::Font & GetFont() const
#define X
sal_uInt16 GetAscent(SwViewShell const *pSh, const OutputDevice &rOut)
Definition: swfont.hxx:326
void PaintText(const SwTextPaintInfo &rInf) const
Manipulate the width, otherwise the chars are being stretched.
Definition: txtdrop.cxx:303
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:33
SwRect & Intersection(const SwRect &rRect)
Definition: swrect.cxx:56
void SetDropDescent(const sal_uInt16 nNew)
Definition: itrtxt.hxx:208
long GetSpaceAdd() const
Definition: inftxt.hxx:447
SwTextPaintInfo & GetInfo()
Definition: itrpaint.hxx:57
oslFileHandle & pOut
sal_uInt16 GetDistance() const
Definition: paratr.hxx:95
long Top() const
void CalcRealHeight(bool bNewLine=false)
Definition: itrform2.cxx:1743
void ChgPhysFnt(SwViewShell const *pSh, OutputDevice &rOut)
Definition: swfont.cxx:969
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: portxt.cxx:438
sal_uInt16 GetDistance() const
Definition: pordrop.hxx:89
short aDescent[DROP_CACHE_SIZE]
Definition: txtdrop.cxx:706
SwFontScript GetActual() const
Definition: swfont.hxx:183
sal_uInt16 aFactor[DROP_CACHE_SIZE]
Definition: txtdrop.cxx:704
sal_uInt16 nLines
Definition: pordrop.hxx:65
SwTwips Y() const
Definition: inftxt.hxx:387
void CalcAscentAndHeight(sal_uInt16 &rAscent, sal_uInt16 &rHeight) const
Definition: itrtxt.cxx:63
SwDropCapCache * pDropCapCache
Definition: txtinit.cxx:32
const SwViewOption & GetOpt() const
Definition: inftxt.hxx:245
void SetDropLines(const sal_uInt16 nNew)
Definition: itrtxt.hxx:203
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1290
void SetFollow(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:49
std::unique_ptr< SwDropPortionPart > pFollow
Definition: pordrop.hxx:36
sal_uInt16 GetDropDescent() const
Definition: pordrop.hxx:91
#define DROP_CACHE_SIZE
Definition: txtdrop.cxx:698
sal_uInt16 aWishedHeight[DROP_CACHE_SIZE]
Definition: txtdrop.cxx:705
int i
void SetPart(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:95
void SetRightBorderDist(const sal_uInt16 nRightDist)
Definition: swfont.hxx:849
void setY(long y)
void Top()
Definition: itrtxt.hxx:99
vcl::RenderContext * GetOut()
Definition: inftxt.hxx:231
SwTextFly & GetTextFly()
Definition: inftxt.hxx:390
const sal_Unicode CH_TAB
Definition: swfont.hxx:44
SwParaPortion * GetParaPortion()
Definition: inftxt.hxx:128
sal_uInt16 nDropHeight
Definition: pordrop.hxx:66
void SetWhichPor(const PortionType nNew)
Definition: porlin.hxx:94
void CheckFontCacheId(SwViewShell const *pSh, SwFontScript nWhich)
Definition: swfont.hxx:195
void SetUnderflow(SwLinePortion *pNew)
Definition: inftxt.hxx:607
TElementType * First()
Definition: calbck.hxx:342
const Color * GetBackColor() const
Definition: swfont.hxx:191
SwLinePortion * GetFirstPortion() const
Definition: porlay.cxx:668
long GetHeight() const
Definition: swfont.hxx:283
sal_uInt16 GetTopBorderSpace() const
Definition: swfont.hxx:863
bool HasArea() const
Definition: swrect.hxx:291
void ResetSpaceIdx()
Definition: inftxt.hxx:443
sal_uInt16 Width() const
Definition: inftxt.hxx:534
long Bottom() const
void SetJoinBorderWithNext(const bool bJoinNext)
Definition: porlin.hxx:171
const SvxLanguageItem & GetCTLLanguage(bool=true) const
Definition: charatr.hxx:96
bool FormatText(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:422
TextFrameIndex GetIdx() const
Definition: inftxt.hxx:278
bool IsDropPortion() const
Definition: porlin.hxx:121
sal_uInt8 GetChars() const
Definition: paratr.hxx:89
static bool IsFieldShadings()
Definition: viewopt.hxx:643
TextFrameIndex GetLen() const
Definition: porlin.hxx:74
SwTextFrame * GetTextFrame()
Definition: inftxt.hxx:291
Point GetTopLeft() const
Definition: itrtxt.hxx:186
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
Definition: txtfrm.cxx:1220
#define Y
const OUString & GetText() const
Definition: inftxt.hxx:246
sal_uInt16 GetWidth() const
Definition: pordrop.hxx:52
void Truncate()
Definition: porlin.hxx:196
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
Definition: breakit.hxx:62
SwTwips X() const
Definition: inftxt.hxx:385
SwTextFrame * m_pFrame
Definition: itrtxt.hxx:34
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:50
virtual long CalcSpacing(long nSpaceAdd, const SwTextSizeInfo &rInf) const override
Definition: portxt.cxx:611
sal_uInt16 nDistance
Definition: pordrop.hxx:68
void ClearDropFormat()
Definition: itrform2.hxx:197
sal_uInt16 nDropDescent
Definition: pordrop.hxx:67
const css::lang::Locale & GetLocale(const LanguageType aLang)
Definition: breakit.hxx:67
TextFrameIndex GetDropLen(TextFrameIndex nWishLen) const
nWishLen = 0 indicates that we want a whole word
Definition: txtdrop.cxx:174
LanguageType GetLanguage() const
sal_Int32 GetDropLen(sal_Int32 nWishLen) const
nWishLen = 0 indicates that we want a whole word
Definition: txtdrop.cxx:127
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: txtdrop.cxx:985
void PaintDrop(const SwTextPaintInfo &rInf) const
Definition: txtdrop.cxx:351
sal_uInt32 GetHeight() const
void CalcFontSize(SwDropPortion *pDrop, SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:718
void ChgClip(const SwRect &rRect, const SwTextFrame *pFrame=nullptr, bool bEnlargeRect=false, sal_Int32 nEnlargeTop=0, sal_Int32 nEnlargeBottom=0)
Definition: txtpaint.hxx:46
void SetLen(const TextFrameIndex nNew)
Definition: inftxt.hxx:281
TextFrameIndex GetLen() const
Definition: pordrop.hxx:51
bool GetDropSize(int &rFontHeight, int &rDropHeight, int &rDropDescent) const
Passes back info needed on the dropcap dimensions.
Definition: txtdrop.cxx:233
void CalcDropHeight(const sal_uInt16 nLines)
Definition: txtdrop.cxx:486
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
tools::Rectangle & Union(const tools::Rectangle &rRect)
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: txtdrop.cxx:438
void SetSize(const Size &rSize, const SwFontScript nWhich)
Definition: swfont.hxx:737
unsigned char sal_uInt8
vcl::Window * GetWin() const
Definition: viewsh.hxx:340
bool GetJoinBorderWithNext() const
Definition: pordrop.hxx:56
void SetFont(const vcl::Font &rNewFont)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:253
void SetDropHeight(const sal_uInt16 nNew)
Definition: itrtxt.hxx:206
friend class SwDropCapCache
Definition: pordrop.hxx:63
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:175
bool OnWin() const
Definition: inftxt.hxx:199
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: txtdrop.cxx:396
TextFrameIndex GetLen() const
Definition: inftxt.hxx:280
sal_uInt16 GetBottomBorderSpace() const
Definition: swfont.hxx:878
sal_uInt16 Width() const
Definition: possiz.hxx:46
void SetPaintDrop(const bool bNew)
Definition: itrpaint.hxx:55
double getLength(const B2DPolygon &rCandidate)
long Left() const
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:723
const SwDropPortion * FindDropPortion() const
Definition: porlay.cxx:2390
const std::optional< editeng::SvxBorderLine > & GetTopBorder() const
Definition: swfont.hxx:339
const SwLineLayout * GetNext() const
Definition: itrtxt.hxx:84
sal_uInt16 GetRealHeight() const
Definition: porlay.hxx:153
const SwLineLayout * GetCurr() const
Definition: itrtxt.hxx:83
void SetAscent(const sal_uInt16 nNewAsc)
Definition: porlin.hxx:79
sal_uInt16 nIndex
Definition: txtdrop.cxx:707
bool IsVertical() const
Definition: frame.hxx:951
SwDropPortionPart * GetFollow() const
Definition: pordrop.hxx:48
SwFont * GetFnt() const
Definition: pordrop.hxx:99
const SwCharFormat * GetCharFormat() const
Definition: paratr.hxx:98
SwDoc & GetDoc()
Definition: txtfrm.hxx:450
const SwRect & GetPaintRect() const
Definition: inftxt.hxx:438
void SetDiffFnt(const SfxItemSet *pSet, const IDocumentSettingAccess *pIDocumentSettingAccess)
Definition: swfont.cxx:493
bool IsOn() const
Definition: txtfly.hxx:313
void DrawBackground(const SwLinePortion &rPor) const
Definition: inftxt.cxx:1165
void ResetKanaIdx()
Definition: inftxt.hxx:326
SwLineLayout * m_pCurr
Definition: itrtxt.hxx:36
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:50
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: portxt.cxx:508
bool IsOnceMore() const
Definition: itrform2.hxx:201
sal_uInt16 GetDropLines() const
Definition: itrtxt.hxx:202
virtual ~SwDropPortion() override
Definition: txtdrop.cxx:119
void SetProportion(const sal_uInt8 nNewPropr)
Definition: swfont.hxx:765
std::unique_ptr< SwFont > pFnt
Definition: pordrop.hxx:37
void SetVertical(sal_uInt16 nDir, const bool bVertLayout=false, const bool bVertLayoutLRBT=false)
Definition: swfont.cxx:438
SwLinePortion * GetNextPortion() const
Definition: porlin.hxx:72
void SetIdx(const TextFrameIndex nNew)
Definition: inftxt.hxx:279
SwDropPortion(const sal_uInt16 nLineCnt, const sal_uInt16 nDropHeight, const sal_uInt16 nDropDescent, const sal_uInt16 nDistance)
SwDropPortion CTor, DTor.
Definition: txtdrop.cxx:105
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...
void SetDropInit(const bool bNew)
Definition: inftxt.hxx:592
aStr
sal_uInt16 & GetAscent()
Definition: porlin.hxx:77
void SetpSpaceAdd(std::vector< long > *pNew)
Definition: inftxt.hxx:451
void SetTopBorderDist(const sal_uInt16 nTopDist)
Definition: swfont.hxx:835
sal_uInt16 nFix
Definition: pordrop.hxx:69
void PaintDropPortion()
Definition: txtdrop.cxx:653
SwDropPortion * NewDropPortion(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:563
sal_uInt16 GetAscent() const
Definition: inftxt.hxx:713
SwFont & GetFont() const
Definition: pordrop.hxx:50
sal_uInt16 GetDropHeight() const
Definition: pordrop.hxx:90
bool GetJoinBorderWithPrev() const
Definition: pordrop.hxx:55
void GetFontCacheId(const void *&rnFontCacheId, sal_uInt16 &rIdx, SwFontScript nWhich)
Definition: swfont.hxx:197