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