tdf#130314 space counting for input field.

1. Input field should be counted like other fields,
   with its content expanded with GetExpText().

2. Use only GetLen() instead of rInf.GetLen() in
   SwTextInputFieldPortion::GetExpText() because
   when justifying the text, rInf.GetLen() isn't
   always updated corresponding to rInf.GetIdx().

   ( Check SwTextAdjuster::CalcNewBlock() for ref.)

Change-Id: I6a41275295607887c476fdd3f8e5a90c936c9d31
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103782
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
This commit is contained in:
Mark Hung
2020-10-08 14:20:49 +02:00
parent d18731f71c
commit ac76f9e8ad
+4 -4
View File
@@ -582,7 +582,7 @@ TextFrameIndex SwTextPortion::GetSpaceCnt(const SwTextSizeInfo &rInf,
return TextFrameIndex(0);
}
if ( InExpGrp() )
if ( InExpGrp() && PortionType::InputField == GetWhichPor() )
{
if( !IsBlankPortion() && !InNumberGrp() && !IsCombinedPortion() )
{
@@ -619,7 +619,7 @@ long SwTextPortion::CalcSpacing( long nSpaceAdd, const SwTextSizeInfo &rInf ) co
return 0;
}
if ( InExpGrp() )
if ( InExpGrp() || PortionType::InputField == GetWhichPor() )
{
if( !IsBlankPortion() && !InNumberGrp() && !IsCombinedPortion() )
{
@@ -716,13 +716,13 @@ void SwTextInputFieldPortion::Paint( const SwTextPaintInfo &rInf ) const
bool SwTextInputFieldPortion::GetExpText( const SwTextSizeInfo &rInf, OUString &rText ) const
{
sal_Int32 nIdx(rInf.GetIdx());
sal_Int32 nLen(rInf.GetLen());
sal_Int32 nLen(GetLen());
if ( rInf.GetChar( rInf.GetIdx() ) == CH_TXT_ATR_INPUTFIELDSTART )
{
++nIdx;
--nLen;
}
if (rInf.GetChar(rInf.GetIdx() + rInf.GetLen() - TextFrameIndex(1)) == CH_TXT_ATR_INPUTFIELDEND)
if (rInf.GetChar(rInf.GetIdx() + GetLen() - TextFrameIndex(1)) == CH_TXT_ATR_INPUTFIELDEND)
{
--nLen;
}