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