summaryrefslogtreecommitdiff
path: root/sw/source/core/text/itrtxt.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/text/itrtxt.cxx')
-rw-r--r--sw/source/core/text/itrtxt.cxx58
1 files changed, 50 insertions, 8 deletions
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index 087a3dd76c7a..1d1eed3e0837 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -27,6 +27,7 @@
#include <pagefrm.hxx>
#include <tgrditem.hxx>
#include "porfld.hxx"
+#include "porrst.hxx"
#include "itrtxt.hxx"
#include <txtfrm.hxx>
@@ -60,7 +61,7 @@ void SwTextIter::Init()
m_nLineNr = 1;
}
-void SwTextIter::CalcAscentAndHeight( sal_uInt16 &rAscent, sal_uInt16 &rHeight ) const
+void SwTextIter::CalcAscentAndHeight( SwTwips &rAscent, SwTwips &rHeight ) const
{
rHeight = GetLineHeight();
rAscent = m_pCurr->GetAscent() + rHeight - m_pCurr->Height();
@@ -203,17 +204,17 @@ const SwLineLayout *SwTextCursor::CharCursorToLine(TextFrameIndex const nPositio
{
CharToLine( nPosition );
if( nPosition != m_nStart )
- bRightMargin = false;
- bool bPrevious = bRightMargin && m_pCurr->GetLen() && GetPrev() &&
+ s_bRightMargin = false;
+ bool bPrevious = s_bRightMargin && m_pCurr->GetLen() && GetPrev() &&
GetPrev()->GetLen();
if (bPrevious && nPosition && CH_BREAK == GetInfo().GetChar(nPosition - TextFrameIndex(1)))
bPrevious = false;
return bPrevious ? PrevLine() : m_pCurr;
}
-sal_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
+SwTwips SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
const SwLinePortion* pPor,
- sal_uInt16 nPorHeight, sal_uInt16 nPorAscent,
+ SwTwips nPorHeight, SwTwips nPorAscent,
const bool bAutoToCentered ) const
{
if ( pPor )
@@ -222,7 +223,7 @@ sal_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
nPorAscent = pPor->GetAscent();
}
- sal_uInt16 nOfst = rLine.GetRealHeight() - rLine.Height();
+ SwTwips nOfst = rLine.GetRealHeight() - rLine.Height();
SwTextGridItem const*const pGrid(GetGridItem(m_pFrame->FindPageFrame()));
@@ -283,13 +284,54 @@ sal_uInt16 SwTextCursor::AdjustBaseLine( const SwLineLayout& rLine,
if (GetInfo().GetTextFrame()->IsVertLR() && !GetInfo().GetTextFrame()->IsVertLRBT())
nOfst += rLine.Height() - ( rLine.Height() - nPorHeight ) / 2 - nPorAscent;
else
- nOfst += ( rLine.Height() - nPorHeight ) / 2 + nPorAscent;
+ {
+ SwTwips nLineHeight = 0;
+ bool bHadClearingBreak = false;
+ if (GetInfo().GetTextFrame()->IsVertical())
+ {
+ // Ignore the height of clearing break portions in the automatic
+ // alignment case.
+ const SwLinePortion* pLinePor = rLine.GetFirstPortion();
+ while (pLinePor)
+ {
+ bool bClearingBreak = false;
+ if (pLinePor->IsBreakPortion())
+ {
+ auto pBreakPortion = static_cast<const SwBreakPortion*>(pLinePor);
+ bClearingBreak = pBreakPortion->GetClear() != SwLineBreakClear::NONE;
+ if (bClearingBreak)
+ {
+ bHadClearingBreak = true;
+ }
+ }
+ if (!bClearingBreak && pLinePor->Height() > nLineHeight)
+ {
+ nLineHeight = pLinePor->Height();
+ }
+ pLinePor = pLinePor->GetNextPortion();
+ }
+ }
+
+ if (!bHadClearingBreak)
+ {
+ nLineHeight = rLine.Height();
+ }
+
+ nOfst += ( nLineHeight - nPorHeight ) / 2 + nPorAscent;
+ }
break;
}
[[fallthrough]];
case SvxParaVertAlignItem::Align::Baseline :
// base line
- nOfst = nOfst + rLine.GetAscent();
+ if (pPor && pPor->GetHangingBaseline())
+ {
+ nOfst += rLine.GetAscent() // Romn baseline of the line.
+ - rLine.GetHangingBaseline() // Hanging baseline of the line.
+ + pPor->GetHangingBaseline(); // Romn baseline of the portion.
+ }
+ else
+ nOfst = nOfst + rLine.GetAscent();
break;
}
}