summaryrefslogtreecommitdiff
path: root/sw/source/core/text/itradj.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/text/itradj.cxx')
-rw-r--r--sw/source/core/text/itradj.cxx37
1 files changed, 24 insertions, 13 deletions
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index a5944e49e357..4dcaf03df1f8 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -122,7 +122,7 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
// total number of kashida positions, or the number of kashida positions after some positions
// have been dropped.
// Here we want the clean total, which is OK: We have called ClearKashidaInvalid() before.
- rKashidas = rSI.KashidaJustify ( nullptr, nullptr, rItr.GetStart(), rItr.GetLength() );
+ rKashidas = rSI.KashidaJustify(nullptr, nullptr, rItr.GetStart(), rItr.GetLength());
if (rKashidas <= 0) // nothing to do
return true;
@@ -147,7 +147,7 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
if (nNext == TextFrameIndex(COMPLETE_STRING) || nNext > nEnd)
nNext = nEnd;
- sal_Int32 nKashidasInAttr = rSI.KashidaJustify ( nullptr, nullptr, nIdx, nNext - nIdx );
+ sal_Int32 nKashidasInAttr = rSI.KashidaJustify(nullptr, nullptr, nIdx, nNext - nIdx);
if (nKashidasInAttr > 0)
{
// Kashida glyph looks suspicious, skip Kashida justification
@@ -164,8 +164,8 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
}
else
{
- ComplexTextLayoutFlags nOldLayout = rInf.GetOut()->GetLayoutMode();
- rInf.GetOut()->SetLayoutMode ( nOldLayout | ComplexTextLayoutFlags::BiDiRtl );
+ vcl::text::ComplexTextLayoutFlags nOldLayout = rInf.GetOut()->GetLayoutMode();
+ rInf.GetOut()->SetLayoutMode ( nOldLayout | vcl::text::ComplexTextLayoutFlags::BiDiRtl );
nKashidasDropped = rInf.GetOut()->ValidateKashidas(
rInf.GetText(), sal_Int32(nIdx), sal_Int32(nNext - nIdx),
nKashidasInAttr,
@@ -212,7 +212,7 @@ static bool lcl_CheckKashidaWidth ( SwScriptInfo& rSI, SwTextSizeInfo& rInf, SwT
if (nNext == TextFrameIndex(COMPLETE_STRING) || nNext > nEnd)
nNext = nEnd;
- sal_Int32 nKashidasInAttr = rSI.KashidaJustify ( nullptr, nullptr, nIdx, nNext - nIdx );
+ sal_Int32 nKashidasInAttr = rSI.KashidaJustify(nullptr, nullptr, nIdx, nNext - nIdx);
tools::Long nFontMinKashida = rInf.GetOut()->GetMinKashida();
if ( nFontMinKashida && nKashidasInAttr > 0 && SwScriptInfo::IsArabicText( rInf.GetText(), nIdx, nNext - nIdx ) )
@@ -290,6 +290,8 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent,
bool bDoNotJustifyTab = false;
SwLinePortion *pPos = pCurrent->GetNextPortion();
+ // calculate real text width for shrinking
+ tools::Long nBreakWidth = 0;
while( pPos )
{
@@ -367,6 +369,11 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent,
if( nGluePortion )
{
tools::Long nSpaceAdd = nGluePortionWidth / sal_Int32(nGluePortion);
+ // shrink, if portions exceed the line width
+ tools::Long nSpaceSub = ( nBreakWidth > pCurrent->Width() )
+ ? (nBreakWidth - pCurrent->Width()) * SPACING_PRECISION_FACTOR /
+ sal_Int32(nGluePortion) + LONG_MAX/2
+ : 0;
// i60594
if( rSI.CountKashida() && !bSkipKashida )
@@ -382,7 +389,7 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent,
}
}
- pCurrent->SetLLSpaceAdd( nSpaceAdd , nSpaceIdx );
+ pCurrent->SetLLSpaceAdd( nSpaceSub ? nSpaceSub : nSpaceAdd, nSpaceIdx );
pPos->Width( static_cast<SwGluePortion*>(pPos)->GetFixWidth() );
}
else if (IsOneBlock() && nCharCnt > TextFrameIndex(1))
@@ -399,6 +406,10 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent,
else
++nGluePortion;
}
+ else
+ {
+ nBreakWidth += pPos->Width();
+ }
GetInfo().SetIdx( GetInfo().GetIdx() + pPos->GetLen() );
if ( pPos == pStopAt )
{
@@ -488,7 +499,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent )
else
nCompress = 10000 - nCompress;
- ( pCurrent->GetKanaComp() )[ nKanaIdx ] = static_cast<sal_uInt16>(nCompress);
+ ( pCurrent->GetKanaComp() )[ nKanaIdx ] = o3tl::narrowing<sal_uInt16>(nCompress);
nKanaDiffSum = 0;
}
@@ -509,11 +520,11 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent )
{
if ( pPos->InTextGrp() )
{
- const sal_uInt16 nMinWidth = pPos->Width();
+ const SwTwips nMinWidth = pPos->Width();
// get maximum portion width from info structure, calculated
// during text formatting
- sal_uInt16 nMaxWidthDiff = GetInfo().GetMaxWidthDiff( pPos );
+ SwTwips nMaxWidthDiff = GetInfo().GetMaxWidthDiff( pPos );
// check, if information is stored under other key
if ( !nMaxWidthDiff && pPos == pCurrent->GetFirstPortion() )
@@ -524,7 +535,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent )
}
else if( pPos->InGlueGrp() && pPos->InFixMargGrp() )
{
- pPos->Width( static_cast<sal_uInt16>(pPos->Width() - nDecompress) );
+ pPos->Width(pPos->Width() - nDecompress);
if ( pPos->InTabGrp() )
// set fix width to width
@@ -747,7 +758,7 @@ void SwTextAdjuster::CalcDropAdjust()
OSL_ENSURE( 1<GetDropLines() && SvxAdjust::Left!=GetAdjust() && SvxAdjust::Block!=GetAdjust(),
"CalcDropAdjust: No reason for DropAdjustment." );
- const sal_uInt16 nLineNumber = GetLineNr();
+ const sal_Int32 nLineNumber = GetLineNr();
// 1) Skip dummies
Top();
@@ -780,7 +791,7 @@ void SwTextAdjuster::CalcDropAdjust()
const auto nDropLineStart =
GetLineStart() + pLeft->Width() + pDropPor->Width();
auto nMinLeft = nDropLineStart;
- for( sal_uInt16 i = 1; i < GetDropLines(); ++i )
+ for( sal_Int32 i = 1; i < GetDropLines(); ++i )
{
if( NextLine() )
{
@@ -831,7 +842,7 @@ void SwTextAdjuster::CalcDropRepaint()
SwRepaint &rRepaint = GetInfo().GetParaPortion()->GetRepaint();
if( rRepaint.Top() > Y() )
rRepaint.Top( Y() );
- for( sal_uInt16 i = 1; i < GetDropLines(); ++i )
+ for( sal_Int32 i = 1; i < GetDropLines(); ++i )
NextLine();
const SwTwips nBottom = Y() + GetLineHeight() - 1;
if( rRepaint.Bottom() < nBottom )