summaryrefslogtreecommitdiff
path: root/editeng/source/editeng/impedit2.cxx
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2018-02-17 06:35:29 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2018-02-17 07:50:00 +0100
commit1da3a3cb74a415a76fa547ef0c8f61780e260e7f (patch)
tree0367d452050d136d6612ba708038fb9d4584987b /editeng/source/editeng/impedit2.cxx
parent71545d500e4b88e960a73d499328504ce99397a8 (diff)
tdf#115639: Align right/center with trailing spaces the same as MS PowerPoint
* Add HoriAlignIgnoreTrailingWhitespace compatibility option. ** For MSO file formats it is set to true ** For ODP format it's set to false by default ** The flag is saved to ODP format as user data if the document comes from an MSO format. Change-Id: Ie22233d33a25e605de46120bfc2195038dffd63c Reviewed-on: https://gerrit.libreoffice.org/49889 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'editeng/source/editeng/impedit2.cxx')
-rw-r--r--editeng/source/editeng/impedit2.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index f89c27e21f92..651ac12d1de5 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -109,6 +109,7 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
bFirstWordCapitalization(true),
mbLastTryMerge(false),
mbReplaceLeadingSingleQuotationMark(true),
+ mbHoriAlignIgnoreTrailingWhitespace(false),
mbNbspRunNext(false)
{
pEditEngine = pEE;
@@ -3089,7 +3090,7 @@ sal_uInt32 ImpEditEngine::GetTextHeight() const
return nCurTextHeight;
}
-sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
+sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace, bool bIgnoreTrailingWhiteSpaces )
{
// If still not formatted and not in the process.
// Will be brought in the formatting for AutoPageSize.
@@ -3136,7 +3137,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
}
}
nCurWidth += GetXValue( rLRItem.GetRight() );
- nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace );
+ nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace, bIgnoreTrailingWhiteSpaces );
if ( nCurWidth > nMaxWidth )
{
nMaxWidth = nCurWidth;
@@ -3149,7 +3150,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
return static_cast<sal_uInt32>(nMaxWidth);
}
-sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, bool bIgnoreExtraSpace )
+sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, bool bIgnoreExtraSpace, bool bIgnoreTrailingWhiteSpaces )
{
sal_Int32 nPara = GetEditDoc().GetPos( pPortion->GetNode() );
@@ -3178,7 +3179,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
break;
case PortionKind::TEXT:
{
- if ( ( eJustification != SvxAdjust::Block ) || ( !bIgnoreExtraSpace ) )
+ if ( (( eJustification != SvxAdjust::Block ) || ( !bIgnoreExtraSpace )) && !bIgnoreTrailingWhiteSpaces )
{
nWidth += rTextPortion.GetSize().Width();
}
@@ -3188,7 +3189,10 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
aTmpFont.SetPhysFont( GetRefDevice() );
ImplInitDigitMode(GetRefDevice(), aTmpFont.GetLanguage());
- nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen() ).Width();
+ if (bIgnoreTrailingWhiteSpaces)
+ nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString().trim(), nPos, rTextPortion.GetLen() ).Width();
+ else
+ nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen() ).Width();
}
}
break;