android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / text / txttab.cxx
blob389e4efb2e469157f7e8f7e7bd3739a4eab7d1e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <hintids.hxx>
21 #include <comphelper/string.hxx>
22 #include <editeng/tstpitem.hxx>
23 #include <rtl/ustrbuf.hxx>
24 #include <IDocumentSettingAccess.hxx>
25 #include <doc.hxx>
26 #include <SwPortionHandler.hxx>
28 #include <viewopt.hxx>
29 #include "portab.hxx"
30 #include "inftxt.hxx"
31 #include "itrform2.hxx"
32 #include <txtfrm.hxx>
33 #include "porfld.hxx"
34 #include <memory>
36 /**
37 * #i24363# tab stops relative to indent
39 * Return the first tab stop that is > nSearchPos.
40 * If the tab stop is outside the print area, we
41 * return 0 if it is not the first tab stop.
43 const SvxTabStop* SwLineInfo::GetTabStop(const SwTwips nSearchPos, SwTwips& nRight) const
45 for( sal_uInt16 i = 0; i < m_oRuler->Count(); ++i )
47 const SvxTabStop &rTabStop = m_oRuler->operator[](i);
48 if (nRight && rTabStop.GetTabPos() > nRight)
50 // Consider the first tabstop to always be in-bounds.
51 if (!i)
52 nRight = rTabStop.GetTabPos();
53 return i ? nullptr : &rTabStop;
55 if( rTabStop.GetTabPos() > nSearchPos )
57 if (!i && !nRight)
58 nRight = rTabStop.GetTabPos();
59 return &rTabStop;
62 return nullptr;
65 sal_uInt16 SwLineInfo::NumberOfTabStops() const
67 return m_oRuler->Count();
70 SwTabPortion *SwTextFormatter::NewTabPortion( SwTextFormatInfo &rInf, bool bAuto ) const
72 IDocumentSettingAccess const& rIDSA(rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess());
73 const bool bTabOverSpacing = rIDSA.get(DocumentSettingId::TAB_OVER_SPACING);
74 const bool bTabsRelativeToIndent = rIDSA.get(DocumentSettingId::TABS_RELATIVE_TO_INDENT);
76 // Update search location - since Center/Decimal tabstops' width is dependent on the following text.
77 SwTabPortion* pTmpLastTab = rInf.GetLastTab();
78 if (pTmpLastTab && (pTmpLastTab->IsTabCenterPortion() || pTmpLastTab->IsTabDecimalPortion()))
79 pTmpLastTab->PostFormat(rInf);
81 sal_Unicode cFill = 0;
82 sal_Unicode cDec = 0;
83 SvxTabAdjust eAdj;
85 sal_uInt16 nNewTabPos;
86 bool bAutoTabStop = true;
88 const bool bRTL = m_pFrame->IsRightToLeft();
89 // #i24363# tab stops relative to indent
90 // nTabLeft: The absolute value, the tab stops are relative to: Tabs origin.
92 // #i91133#
93 const SwTwips nTabLeft = bRTL
94 ? m_pFrame->getFrameArea().Right() -
95 ( bTabsRelativeToIndent ? GetTabLeft() : 0 )
96 : m_pFrame->getFrameArea().Left() +
97 ( bTabsRelativeToIndent ? GetTabLeft() : 0 );
99 // The absolute position, where we started the line formatting
100 SwTwips nLinePos = GetLeftMargin();
101 if ( bRTL )
103 Point aPoint( nLinePos, 0 );
104 m_pFrame->SwitchLTRtoRTL( aPoint );
105 nLinePos = aPoint.X();
108 // The current position, relative to the line start
109 SwTwips nTabPos = rInf.GetLastTab() ? rInf.GetLastTab()->GetTabPos() : 0;
110 if( nTabPos < rInf.X() )
112 nTabPos = rInf.X();
115 // The current position in absolute coordinates
116 const SwTwips nCurrentAbsPos = bRTL ?
117 nLinePos - nTabPos :
118 nLinePos + nTabPos;
120 SwTwips nMyRight;
121 if ( m_pFrame->IsVertLR() )
122 nMyRight = Left();
123 else
124 nMyRight = Right();
126 if ( m_pFrame->IsVertical() )
128 Point aRightTop( nMyRight, m_pFrame->getFrameArea().Top() );
129 m_pFrame->SwitchHorizontalToVertical( aRightTop );
130 nMyRight = aRightTop.Y();
133 SwTwips nNextPos = 0;
134 bool bAbsoluteNextPos = false;
136 // #i24363# tab stops relative to indent
137 // nSearchPos: The current position relative to the tabs origin
138 const SwTwips nSearchPos = bRTL ?
139 nTabLeft - nCurrentAbsPos :
140 nCurrentAbsPos - nTabLeft;
142 // First, we examine the tab stops set at the paragraph style or
143 // any hard set tab stops:
144 // Note: If there are no user defined tab stops, there is always a
145 // default tab stop.
146 const SwTwips nOldRight = nMyRight;
147 // Accept left-tabstops beyond the paragraph margin for bTabOverSpacing
148 if (bTabOverSpacing)
149 nMyRight = 0;
150 const SvxTabStop* pTabStop = m_aLineInf.GetTabStop( nSearchPos, nMyRight );
151 if (!nMyRight)
152 nMyRight = nOldRight;
153 if (pTabStop)
155 cFill = ' ' != pTabStop->GetFill() ? pTabStop->GetFill() : 0;
156 cDec = pTabStop->GetDecimal();
157 eAdj = pTabStop->GetAdjustment();
158 nNextPos = pTabStop->GetTabPos();
159 if(!bTabsRelativeToIndent && eAdj == SvxTabAdjust::Default && nSearchPos < 0)
161 //calculate default tab position of default tabs in negative indent
162 nNextPos = ( nSearchPos / nNextPos ) * nNextPos;
164 else if (pTabStop->GetTabPos() > nMyRight
165 && pTabStop->GetAdjustment() != SvxTabAdjust::Left)
167 // A rather special situation. The tabstop found is:
168 // 1.) in a document compatible with MS formats
169 // 2.) not a left tabstop.
170 // 3.) not the first tabstop (in that case nMyRight was adjusted to match tabPos).
171 // 4.) beyond the end of the text area
172 // Therefore, they act like right-tabstops at the edge of the para area.
173 // This benefits DOCX 2013+, and doesn't hurt the earlier formats,
174 // since up till now these were just treated as automatic tabstops.
175 eAdj = SvxTabAdjust::Right;
176 bAbsoluteNextPos = true;
177 nNextPos = rInf.Width();
179 bAutoTabStop = false;
181 else
183 sal_uInt16 nDefTabDist = m_aLineInf.GetDefTabStop();
184 if( USHRT_MAX == nDefTabDist )
186 const SvxTabStopItem& rTab =
187 m_pFrame->GetAttrSet()->GetPool()->GetDefaultItem( RES_PARATR_TABSTOP );
188 if( rTab.Count() )
189 nDefTabDist = o3tl::narrowing<sal_uInt16>(rTab[0].GetTabPos());
190 else
191 nDefTabDist = SVX_TAB_DEFDIST;
192 m_aLineInf.SetDefTabStop( nDefTabDist );
194 SwTwips nCount = nSearchPos;
196 // Minimum tab stop width is 1
197 if (nDefTabDist <= 0)
198 nDefTabDist = 1;
200 nCount /= nDefTabDist;
201 nNextPos = ( nCount < 0 || ( !nCount && nSearchPos <= 0 ) )
202 ? ( nCount * nDefTabDist )
203 : ( ( nCount + 1 ) * nDefTabDist );
205 // --> FME 2004-09-21 #117919 Minimum tab stop width is 1 or 51 twips:
206 const SwTwips nMinimumTabWidth = m_pFrame->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_COMPAT) ? 0 : 50;
207 if( ( bRTL && nTabLeft - nNextPos >= nCurrentAbsPos - nMinimumTabWidth ) ||
208 ( !bRTL && nNextPos + nTabLeft <= nCurrentAbsPos + nMinimumTabWidth ) )
210 nNextPos += nDefTabDist;
212 cFill = 0;
213 eAdj = SvxTabAdjust::Left;
216 // #i115705# - correction and refactoring:
217 // overrule determined next tab stop position in order to apply
218 // a tab stop at the left margin under the following conditions:
219 // - the new tab portion is inside the hanging indent
220 // - a tab stop at the left margin is allowed
221 // - the determined next tab stop is a default tab stop position OR
222 // the determined next tab stop is beyond the left margin
224 tools::Long nLeftMarginTabPos = 0;
226 if ( !bTabsRelativeToIndent )
228 if ( bRTL )
230 Point aPoint( Left(), 0 );
231 m_pFrame->SwitchLTRtoRTL( aPoint );
232 nLeftMarginTabPos = m_pFrame->getFrameArea().Right() - aPoint.X();
234 else
236 nLeftMarginTabPos = Left() - m_pFrame->getFrameArea().Left();
239 if( m_pCurr->HasForcedLeftMargin() )
241 SwLinePortion* pPor = m_pCurr->GetNextPortion();
242 while( pPor && !pPor->IsFlyPortion() )
244 pPor = pPor->GetNextPortion();
246 if ( pPor )
248 nLeftMarginTabPos += pPor->Width();
252 const bool bNewTabPortionInsideHangingIndent =
253 bRTL ? nCurrentAbsPos > nTabLeft - nLeftMarginTabPos
254 : nCurrentAbsPos < nTabLeft + nLeftMarginTabPos;
255 if ( bNewTabPortionInsideHangingIndent )
257 // If the paragraph is not inside a list having a list tab stop following
258 // the list label or no further tab stop found in such a paragraph or
259 // the next tab stop position does not equal the list tab stop,
260 // a tab stop at the left margin can be applied. If this condition is
261 // not hold, it is overruled by compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST.
262 const bool bTabAtLeftMarginAllowed =
263 ( !m_aLineInf.IsListTabStopIncluded() ||
264 !pTabStop ||
265 nNextPos != m_aLineInf.GetListTabStopPosition() ) ||
266 // compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
267 m_pFrame->GetDoc().getIDocumentSettingAccess().
268 get(DocumentSettingId::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST);
269 if ( bTabAtLeftMarginAllowed )
271 if ( !pTabStop || eAdj == SvxTabAdjust::Default ||
272 ( nNextPos > nLeftMarginTabPos ) )
274 eAdj = SvxTabAdjust::Default;
275 cFill = 0;
276 nNextPos = nLeftMarginTabPos;
282 if (!bAbsoluteNextPos)
283 nNextPos += bRTL ? nLinePos - nTabLeft : nTabLeft - nLinePos;
284 OSL_ENSURE( nNextPos >= 0, "GetTabStop: Don't go back!" );
285 nNewTabPos = sal_uInt16(nNextPos);
288 SwTabPortion *pTabPor = nullptr;
289 if ( bAuto )
291 if ( SvxTabAdjust::Decimal == eAdj &&
292 1 == m_aLineInf.NumberOfTabStops() )
293 pTabPor = new SwAutoTabDecimalPortion( nNewTabPos, cDec, cFill );
295 else
297 switch( eAdj )
299 case SvxTabAdjust::Right :
301 pTabPor = new SwTabRightPortion( nNewTabPos, cFill );
302 break;
304 case SvxTabAdjust::Center :
306 pTabPor = new SwTabCenterPortion( nNewTabPos, cFill );
307 break;
309 case SvxTabAdjust::Decimal :
311 pTabPor = new SwTabDecimalPortion( nNewTabPos, cDec, cFill );
312 break;
314 default:
316 OSL_ENSURE( SvxTabAdjust::Left == eAdj || SvxTabAdjust::Default == eAdj,
317 "+SwTextFormatter::NewTabPortion: unknown adjustment" );
318 pTabPor = new SwTabLeftPortion( nNewTabPos, cFill, bAutoTabStop );
319 break;
324 return pTabPor;
328 * The base class is initialized without setting anything
330 SwTabPortion::SwTabPortion( const sal_uInt16 nTabPosition, const sal_Unicode cFillChar, const bool bAutoTab )
331 : m_nTabPos(nTabPosition), m_cFill(cFillChar), m_bAutoTabStop( bAutoTab )
333 mnLineLength = TextFrameIndex(1);
334 OSL_ENSURE(!IsFilled() || ' ' != m_cFill, "SwTabPortion::CTOR: blanks ?!");
335 SetWhichPor( PortionType::Tab );
338 bool SwTabPortion::Format( SwTextFormatInfo &rInf )
340 SwTabPortion *pLastTab = rInf.GetLastTab();
341 if( pLastTab == this )
342 return PostFormat( rInf );
343 if( pLastTab )
344 pLastTab->PostFormat( rInf );
345 return PreFormat( rInf );
348 void SwTabPortion::FormatEOL( SwTextFormatInfo &rInf )
350 if( rInf.GetLastTab() == this )
351 PostFormat( rInf );
354 bool SwTabPortion::PreFormat( SwTextFormatInfo &rInf )
356 OSL_ENSURE( rInf.X() <= GetTabPos(), "SwTabPortion::PreFormat: rush hour" );
358 // Here we settle down ...
359 SetFix( o3tl::narrowing<sal_uInt16>(rInf.X()) );
361 IDocumentSettingAccess const& rIDSA(rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess());
362 const bool bTabCompat = rIDSA.get(DocumentSettingId::TAB_COMPAT);
363 const bool bTabOverflow = rIDSA.get(DocumentSettingId::TAB_OVERFLOW);
364 const bool bTabOverMargin = rIDSA.get(DocumentSettingId::TAB_OVER_MARGIN);
365 const bool bTabOverSpacing = rIDSA.get(DocumentSettingId::TAB_OVER_SPACING);
366 const sal_Int32 nTextFrameWidth = rInf.GetTextFrame()->getFrameArea().Width();
368 // The minimal width of a tab is one blank at least.
369 // #i37686# In compatibility mode, the minimum width
370 // should be 1, even for non-left tab stops.
371 sal_uInt16 nMinimumTabWidth = 1;
372 if ( !bTabCompat )
374 // #i89179#
375 // tab portion representing the list tab of a list label gets the
376 // same font as the corresponding number portion
377 std::optional< SwFontSave > oSave;
378 if ( GetLen() == TextFrameIndex(0) &&
379 rInf.GetLast() && rInf.GetLast()->InNumberGrp() &&
380 static_cast<SwNumberPortion*>(rInf.GetLast())->HasFont() )
382 const SwFont* pNumberPortionFont =
383 static_cast<SwNumberPortion*>(rInf.GetLast())->GetFont();
384 oSave.emplace( rInf, const_cast<SwFont*>(pNumberPortionFont) );
386 OUString aTmp( ' ' );
387 SwTextSizeInfo aInf( rInf, &aTmp );
388 nMinimumTabWidth = aInf.GetTextSize().Width();
390 PrtWidth( nMinimumTabWidth );
392 // Break tab stop to next line if:
393 // 1. Minimal width does not fit to line anymore.
394 // 2. An underflow event was called for the tab portion.
395 bool bFull = ( bTabCompat && rInf.IsUnderflow() ) ||
396 ( rInf.Width() <= rInf.X() + PrtWidth() && rInf.X() <= rInf.Width() ) ;
398 // #95477# Rotated tab stops get the width of one blank
399 const Degree10 nDir = rInf.GetFont()->GetOrientation( rInf.GetTextFrame()->IsVertical() );
401 if( ! bFull && 0_deg10 == nDir )
403 const PortionType nWhich = GetWhichPor();
404 switch( nWhich )
406 case PortionType::TabRight:
407 case PortionType::TabDecimal:
408 case PortionType::TabCenter:
410 if( PortionType::TabDecimal == nWhich )
411 rInf.SetTabDecimal(
412 static_cast<SwTabDecimalPortion*>(this)->GetTabDecimal());
413 rInf.SetLastTab( this );
414 break;
416 case PortionType::TabLeft:
418 // handle this case in PostFormat
419 if ((bTabOverMargin || bTabOverSpacing) && GetTabPos() > rInf.Width()
420 && (!m_bAutoTabStop || (!bTabOverMargin && rInf.X() > rInf.Width())))
422 if (bTabOverMargin || GetTabPos() < nTextFrameWidth)
424 rInf.SetLastTab(this);
425 break;
427 else
429 assert(!bTabOverMargin && bTabOverSpacing && GetTabPos() >= nTextFrameWidth);
430 bFull = true;
431 break;
435 PrtWidth( o3tl::narrowing<sal_uInt16>(GetTabPos() - rInf.X()) );
436 bFull = rInf.Width() <= rInf.X() + PrtWidth();
438 // In tabulator compatibility mode, we reset the bFull flag
439 // if the tabulator is at the end of the paragraph and the
440 // tab stop position is outside the frame:
441 bool bAtParaEnd = rInf.GetIdx() + GetLen() == TextFrameIndex(rInf.GetText().getLength());
442 if ( bFull && bTabCompat &&
443 ( ( bTabOverflow && ( rInf.IsTabOverflow() || !m_bAutoTabStop ) ) || bAtParaEnd ) &&
444 GetTabPos() >= nTextFrameWidth)
446 bFull = false;
447 if ( bTabOverflow && !m_bAutoTabStop )
448 rInf.SetTabOverflow( true );
451 break;
453 default: OSL_ENSURE( false, "SwTabPortion::PreFormat: unknown adjustment" );
457 if( bFull )
459 // We have to look for endless loops, if the width is smaller than one blank
460 if( rInf.GetIdx() == rInf.GetLineStart() &&
461 // #119175# TabStop should be forced to current
462 // line if there is a fly reducing the line width:
463 !rInf.GetFly() )
465 PrtWidth( o3tl::narrowing<sal_uInt16>(rInf.Width() - rInf.X()) );
466 SetFixWidth( PrtWidth() );
468 else
470 Height( 0 );
471 Width( 0 );
472 SetLen( TextFrameIndex(0) );
473 SetAscent( 0 );
474 SetNextPortion( nullptr ); //?????
476 return true;
478 else
480 // A trick with impact: The new Tabportions now behave like
481 // FlyFrames, located in the line - including adjustment !
482 SetFixWidth( PrtWidth() );
483 return false;
487 bool SwTabPortion::PostFormat( SwTextFormatInfo &rInf )
489 bool bTabOverMargin = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(
490 DocumentSettingId::TAB_OVER_MARGIN);
491 bool bTabOverSpacing = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(
492 DocumentSettingId::TAB_OVER_SPACING);
493 if (rInf.GetTextFrame()->IsInSct())
494 bTabOverMargin = false;
496 // If the tab position is larger than the right margin, it gets scaled down by default.
497 // However, if compat mode enabled, we allow tabs to go over the margin: the rest of the paragraph is not broken into lines.
498 const sal_uInt16 nRight
499 = bTabOverMargin
500 ? GetTabPos()
501 : bTabOverSpacing
502 ? std::min<long>(GetTabPos(), rInf.GetTextFrame()->getFrameArea().Right())
503 : std::min(GetTabPos(), rInf.Width());
504 const SwLinePortion *pPor = GetNextPortion();
506 sal_uInt16 nPorWidth = 0;
507 while( pPor )
509 nPorWidth = nPorWidth + pPor->Width();
510 pPor = pPor->GetNextPortion();
513 const PortionType nWhich = GetWhichPor();
514 const bool bTabCompat = rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::TAB_COMPAT);
516 if ((bTabOverMargin || bTabOverSpacing) && PortionType::TabLeft == nWhich)
518 nPorWidth = 0;
521 // #127428# Abandon dec. tab position if line is full
522 if ( bTabCompat && PortionType::TabDecimal == nWhich )
524 sal_uInt16 nPrePorWidth = static_cast<const SwTabDecimalPortion*>(this)->GetWidthOfPortionsUpToDecimalPosition();
526 // no value was set => no decimal character was found
527 if ( USHRT_MAX != nPrePorWidth )
529 if ( !bTabOverMargin && nPrePorWidth && nPorWidth - nPrePorWidth > rInf.Width() - nRight )
531 nPrePorWidth += nPorWidth - nPrePorWidth - ( rInf.Width() - nRight );
534 nPorWidth = nPrePorWidth - 1;
538 if( PortionType::TabCenter == nWhich )
540 // centered tabs are problematic:
541 // We have to detect how much fits into the line.
542 sal_uInt16 nNewWidth = nPorWidth /2;
543 if (!bTabOverMargin && !bTabOverSpacing && nNewWidth > rInf.Width() - nRight)
544 nNewWidth = nPorWidth - (rInf.Width() - nRight);
545 nPorWidth = nNewWidth;
548 const sal_uInt16 nDiffWidth = nRight - GetFix();
550 if( nDiffWidth > nPorWidth )
552 const sal_uInt16 nOldWidth = GetFixWidth();
553 const sal_uInt16 nAdjDiff = nDiffWidth - nPorWidth;
554 if( nAdjDiff > GetFixWidth() )
555 PrtWidth( nAdjDiff );
556 // Don't be afraid: we have to move rInf further.
557 // The right-tab till now only had the width of one blank.
558 // Now that we stretched, the difference had to be added to rInf.X() !
559 rInf.X( rInf.X() + PrtWidth() - nOldWidth );
561 SetFixWidth( PrtWidth() );
562 // reset last values
563 rInf.SetLastTab(nullptr);
564 if( PortionType::TabDecimal == nWhich )
565 rInf.SetTabDecimal(0);
567 return rInf.Width() <= rInf.X();
571 * Ex: LineIter::DrawTab()
573 void SwTabPortion::Paint( const SwTextPaintInfo &rInf ) const
575 // #i89179#
576 // tab portion representing the list tab of a list label gets the
577 // same font as the corresponding number portion
578 std::optional< SwFontSave > oSave;
579 bool bAfterNumbering = false;
580 if (GetLen() == TextFrameIndex(0))
582 const SwLinePortion* pPrevPortion =
583 const_cast<SwTabPortion*>(this)->FindPrevPortion( rInf.GetParaPortion() );
584 if ( pPrevPortion &&
585 pPrevPortion->InNumberGrp() &&
586 static_cast<const SwNumberPortion*>(pPrevPortion)->HasFont() )
588 const SwFont* pNumberPortionFont =
589 static_cast<const SwNumberPortion*>(pPrevPortion)->GetFont();
590 oSave.emplace( rInf, const_cast<SwFont*>(pNumberPortionFont) );
591 bAfterNumbering = true;
594 rInf.DrawBackBrush( *this );
595 if( !bAfterNumbering )
596 rInf.DrawBorder( *this );
598 // do we have to repaint a post it portion?
599 if( rInf.OnWin() && mpNextPortion && !mpNextPortion->Width() )
600 mpNextPortion->PrePaint( rInf, this );
602 // display special characters
603 if( rInf.OnWin() && rInf.GetOpt().IsTab() )
605 // filled tabs are shaded in gray
606 if( IsFilled() )
607 rInf.DrawViewOpt( *this, PortionType::Tab );
608 else
609 rInf.DrawTab( *this );
612 // Tabs should be underlined at once
613 if( rInf.GetFont()->IsPaintBlank() )
615 // Tabs with filling/filled tabs
616 const sal_uInt16 nCharWidth = rInf.GetTextSize(OUString(' ')).Width();
618 // Robust:
619 if( nCharWidth )
621 // Always with kerning, also on printer!
622 sal_uInt16 nChar = Width() / nCharWidth;
623 OUStringBuffer aBuf(nChar);
624 comphelper::string::padToLength(aBuf, nChar, ' ');
625 rInf.DrawText(aBuf.makeStringAndClear(), *this, TextFrameIndex(0),
626 TextFrameIndex(nChar), true);
630 // Display fill characters
631 if( !IsFilled() )
632 return;
634 // Tabs with filling/filled tabs
635 const sal_uInt16 nCharWidth = rInf.GetTextSize(OUString(m_cFill)).Width();
636 OSL_ENSURE( nCharWidth, "!SwTabPortion::Paint: sophisticated tabchar" );
638 // Robust:
639 if( nCharWidth )
641 // Always with kerning, also on printer!
642 sal_uInt16 nChar = Width() / nCharWidth;
643 if ( m_cFill == '_' )
644 ++nChar; // to avoid gaps
645 OUStringBuffer aBuf(nChar);
646 comphelper::string::padToLength(aBuf, nChar, m_cFill);
647 rInf.DrawText(aBuf.makeStringAndClear(), *this, TextFrameIndex(0),
648 TextFrameIndex(nChar), true);
652 void SwAutoTabDecimalPortion::Paint( const SwTextPaintInfo & ) const
656 void SwTabPortion::HandlePortion( SwPortionHandler& rPH ) const
658 rPH.Text( GetLen(), GetWhichPor() );
661 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */