diff options
Diffstat (limited to 'editeng/source/editeng/impedit2.cxx')
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 9d5658a68109..c58c76b4e8a5 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3084,52 +3084,66 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace ) if ( !IsFormatted() && !IsFormatting() ) FormatDoc(); - long nMaxWidth = 0; - long nCurWidth = 0; - + sal_uInt32 nMaxWidth = 0; // Over all the paragraphs ... sal_Int32 nParas = GetParaPortions().Count(); for ( sal_Int32 nPara = 0; nPara < nParas; nPara++ ) { - ParaPortion* pPortion = GetParaPortions()[nPara]; - if ( pPortion->IsVisible() ) - { - const SvxLRSpaceItem& rLRItem = GetLRSpaceItem( pPortion->GetNode() ); - sal_Int32 nSpaceBeforeAndMinLabelWidth = GetSpaceBeforeAndMinLabelWidth( pPortion->GetNode() ); + nMaxWidth = std::max(nMaxWidth, CalcParaWidth(nPara, bIgnoreExtraSpace)); + } + + return nMaxWidth; +} + +sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace ) +{ + // If still not formatted and not in the process. + // Will be brought in the formatting for AutoPageSize. + if ( !IsFormatted() && !IsFormatting() ) + FormatDoc(); + + long nMaxWidth = 0; + // Over all the paragraphs ... - // On the lines of the paragraph ... + ParaPortion* pPortion = GetParaPortions()[nPara]; + if ( pPortion->IsVisible() ) + { + const SvxLRSpaceItem& rLRItem = GetLRSpaceItem( pPortion->GetNode() ); + sal_Int32 nSpaceBeforeAndMinLabelWidth = GetSpaceBeforeAndMinLabelWidth( pPortion->GetNode() ); - sal_Int32 nLines = pPortion->GetLines().Count(); - for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ ) + + // On the lines of the paragraph ... + + sal_Int32 nLines = pPortion->GetLines().Count(); + for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ ) + { + EditLine& rLine = pPortion->GetLines()[nLine]; + // nCurWidth = pLine->GetStartPosX(); + // For Center- or Right- alignment it depends on the paper + // width, here not preferred. I general, it is best not leave it + // to StartPosX, also the right indents have to be taken into + // account! + long nCurWidth = GetXValue( rLRItem.GetTextLeft() + nSpaceBeforeAndMinLabelWidth ); + if ( nLine == 0 ) { - EditLine& rLine = pPortion->GetLines()[nLine]; - // nCurWidth = pLine->GetStartPosX(); - // For Center- or Right- alignment it depends on the paper - // width, here not preferred. I general, it is best not leave it - // to StartPosX, also the right indents have to be taken into - // account! - nCurWidth = GetXValue( rLRItem.GetTextLeft() + nSpaceBeforeAndMinLabelWidth ); - if ( nLine == 0 ) + long nFI = GetXValue( rLRItem.GetTextFirstLineOfst() ); + nCurWidth -= nFI; + if ( pPortion->GetBulletX() > nCurWidth ) { - long nFI = GetXValue( rLRItem.GetTextFirstLineOfst() ); - nCurWidth -= nFI; + nCurWidth += nFI; // LI? if ( pPortion->GetBulletX() > nCurWidth ) - { - nCurWidth += nFI; // LI? - if ( pPortion->GetBulletX() > nCurWidth ) - nCurWidth = pPortion->GetBulletX(); - } - } - nCurWidth += GetXValue( rLRItem.GetRight() ); - nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace ); - if ( nCurWidth > nMaxWidth ) - { - nMaxWidth = nCurWidth; + nCurWidth = pPortion->GetBulletX(); } } + nCurWidth += GetXValue( rLRItem.GetRight() ); + nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace ); + if ( nCurWidth > nMaxWidth ) + { + nMaxWidth = nCurWidth; + } } } |