summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorBogdan B <buzea.bogdan@libreoffice.org>2022-11-25 00:16:27 +0100
committerHossein <hossein@libreoffice.org>2023-06-05 13:53:16 +0200
commit2f5bffafe4f653aa4ce86f7a27305587680cba58 (patch)
tree20d6ca4396e421a9f347004d9b97ecdba8f1535e /sw/source
parente86a0236e69d76769b91f96d71fe852b91c5db6e (diff)
tdf#152431 Fix line count resets to zero after 65535
GetLineCount was a sal_uInt16 value, that allows only 65535 lines to be counted. This is changed to sal_Int32 and also the underlying data type for the lines number is changed from sal_uLong to sal_Int32, but not for pages number. With this change, the maximum possible line number is now increased to 2^31-1 = 2,147,483,647. Change-Id: Ibee2d24e638204133f0ef085564016543f73d351 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143173 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/access/accdoc.cxx2
-rw-r--r--sw/source/core/access/accportions.cxx2
-rw-r--r--sw/source/core/doc/doc.cxx11
-rw-r--r--sw/source/core/edit/editsh.cxx4
-rw-r--r--sw/source/core/inc/txtfrm.hxx10
-rw-r--r--sw/source/core/layout/atrfrm.cxx2
-rw-r--r--sw/source/core/layout/layact.cxx8
-rw-r--r--sw/source/core/text/frmpaint.cxx4
-rw-r--r--sw/source/core/text/itradj.cxx6
-rw-r--r--sw/source/core/text/itrcrsr.cxx2
-rw-r--r--sw/source/core/text/itrtxt.hxx4
-rw-r--r--sw/source/core/text/txtfrm.cxx10
-rw-r--r--sw/source/core/text/widorp.cxx8
-rw-r--r--sw/source/ui/misc/pggrid.cxx2
14 files changed, 38 insertions, 37 deletions
diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx
index 5785b50261f4..deedc3b510a1 100644
--- a/sw/source/core/access/accdoc.cxx
+++ b/sw/source/core/access/accdoc.cxx
@@ -542,7 +542,7 @@ uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes()
SwContentFrame* pCurrFrame = pCursorShell->GetCurrFrame();
SwPageFrame* pCurrPage=static_cast<SwFrame*>(pCurrFrame)->FindPageFrame();
- sal_uLong nLineNum = 0;
+ sal_Int32 nLineNum = 0;
SwTextFrame* pTextFrame = nullptr;
SwTextFrame* pCurrTextFrame = nullptr;
pTextFrame = static_cast< SwTextFrame* >(pCurrPage->ContainsContent());
diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx
index 152d4f956aee..1cc1b73d6a6a 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -606,7 +606,7 @@ TextFrameIndex SwAccessiblePortionData::FillSpecialPos(
// (if necessary)
size_t nRefLine = FindBreak( m_aLineBreaks, nRefPos );
size_t nMyLine = FindBreak( m_aLineBreaks, nPos );
- sal_uInt16 nLineOffset = o3tl::narrowing<sal_uInt16>( nMyLine - nRefLine );
+ sal_Int32 nLineOffset = o3tl::narrowing<sal_Int32>( nMyLine - nRefLine );
if( nLineOffset != 0 )
nRefPos = m_aLineBreaks[ nMyLine ];
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 7d7d1e250bff..18d9fa2018ab 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -485,7 +485,7 @@ struct PostItField_ : public SetGetExpField
sal_uInt16 GetPageNo( const StringRangeEnumerator &rRangeEnum,
const o3tl::sorted_vector< sal_Int32 > &rPossiblePages,
- sal_uInt16& rVirtPgNo, sal_uInt16& rLineNo );
+ sal_uInt16& rVirtPgNo, sal_Int32& rLineNo );
const SwPostItField* GetPostIt() const
{
@@ -498,7 +498,7 @@ struct PostItField_ : public SetGetExpField
sal_uInt16 PostItField_::GetPageNo(
const StringRangeEnumerator &rRangeEnum,
const o3tl::sorted_vector< sal_Int32 > &rPossiblePages,
- /* out */ sal_uInt16& rVirtPgNo, /* out */ sal_uInt16& rLineNo )
+ /* out */ sal_uInt16& rVirtPgNo, /* out */ sal_Int32& rLineNo )
{
//Problem: If a PostItField is contained in a Node that is represented
//by more than one layout instance,
@@ -517,7 +517,7 @@ sal_uInt16 PostItField_::GetPageNo(
sal_uInt16 nPgNo = pFrame->GetPhyPageNum();
if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ))
{
- rLineNo = o3tl::narrowing<sal_uInt16>(pFrame->GetLineCount( nPos ) +
+ rLineNo = o3tl::narrowing<sal_Int32>(pFrame->GetLineCount( nPos ) +
pFrame->GetAllLines() - pFrame->GetThisLines());
rVirtPgNo = pFrame->GetVirtPageNum();
return nPgNo;
@@ -549,7 +549,7 @@ static void lcl_FormatPostIt(
SwPaM& aPam,
const SwPostItField* pField,
bool bNewPage, bool bIsFirstPostIt,
- sal_uInt16 nPageNo, sal_uInt16 nLineNo )
+ sal_uInt16 nPageNo, sal_Int32 nLineNo )
{
static char const sTmp[] = " : ";
@@ -805,7 +805,8 @@ void SwDoc::UpdatePagesForPrintingWithPostItData(
// temporary post-it document.
// Since the array of post-it fields is sorted by page and line number we will
// already get them in the correct order
- sal_uInt16 nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
+ sal_uInt16 nVirtPg = 0, nLastPageNum = 0, nPhyPageNum = 0;
+ sal_Int32 nLineNo = 0;
bool bIsFirstPostIt = true;
for (SetGetExpFields::size_type i = 0; i < nPostItCount; ++i)
{
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 6803f31bc13f..0dcec2742c66 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -852,9 +852,9 @@ void SwEditShell::SetNumberingRestart()
EndAllAction();
}
-sal_uInt16 SwEditShell::GetLineCount()
+sal_Int32 SwEditShell::GetLineCount()
{
- sal_uInt16 nRet = 0;
+ sal_Int32 nRet = 0;
CalcLayout();
SwPaM* pPam = GetCursor();
SwNodeIndex aStart( pPam->GetPoint()->GetNode() );
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index c4c51503ec98..d58b97e9d3e4 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -181,8 +181,8 @@ class SW_DLLPUBLIC SwTextFrame final : public SwContentFrame
static constexpr tools::Long nMinPrtLine = 0; // This Line must not be underrun when printing
// Hack for table cells stretching multiple pages
- sal_uInt32 mnAllLines :24; // Line count for the Paint (including nThisLines)
- sal_uInt32 mnThisLines :8; // Count of Lines of the Frame
+ sal_Int32 mnAllLines :24; // Line count for the Paint (including nThisLines)
+ sal_Int32 mnThisLines :8; // Count of Lines of the Frame
// The x position for flys anchored at this paragraph.
// These values are calculated in SwTextFrame::CalcBaseOfstForFly()
@@ -676,11 +676,11 @@ public:
bool FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff );
/// Determines the line count
- sal_uInt16 GetLineCount(TextFrameIndex nPos);
+ sal_Int32 GetLineCount(TextFrameIndex nPos);
/// For displaying the line numbers
- sal_uLong GetAllLines() const { return mnAllLines; }
- sal_uLong GetThisLines() const { return mnThisLines;}
+ sal_Int32 GetAllLines() const { return mnAllLines; }
+ sal_Int32 GetThisLines() const { return mnThisLines;}
void RecalcAllLines();
/// Stops the animations within numberings
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index f6934822b74f..b61a466e08eb 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2399,7 +2399,7 @@ bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
sal_Int16 nTmp = 0;
bRet = (rVal >>= nTmp);
if( bRet && (nTmp >= 0) )
- SetLines( o3tl::narrowing<sal_uInt16>(nTmp) );
+ SetLines( nTmp );
else
bRet = false;
}
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 1996f8e319e6..21496e2237e1 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -832,7 +832,7 @@ bool SwLayAction::TurboAction_( const SwContentFrame *pCnt )
if ( !pCnt->GetValidLineNumFlag() && pCnt->IsTextFrame() )
{
- const sal_uLong nAllLines = static_cast<const SwTextFrame*>(pCnt)->GetAllLines();
+ const sal_Int32 nAllLines = static_cast<const SwTextFrame*>(pCnt)->GetAllLines();
const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pCnt))->RecalcAllLines();
if ( nAllLines != static_cast<const SwTextFrame*>(pCnt)->GetAllLines() )
{
@@ -1745,7 +1745,7 @@ bool SwLayAction::FormatContent(SwPageFrame *const pPage)
if ( !pContent->GetValidLineNumFlag() && pContent->IsTextFrame() )
{
- const sal_uLong nAllLines = static_cast<const SwTextFrame*>(pContent)->GetAllLines();
+ const sal_Int32 nAllLines = static_cast<const SwTextFrame*>(pContent)->GetAllLines();
const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pContent))->RecalcAllLines();
if ( IsPaintExtraData() && IsPaint() &&
nAllLines != static_cast<const SwTextFrame*>(pContent)->GetAllLines() )
@@ -1848,7 +1848,7 @@ bool SwLayAction::FormatContent(SwPageFrame *const pPage)
{
if ( !pContent->GetValidLineNumFlag() && pContent->IsTextFrame() )
{
- const sal_uLong nAllLines = static_cast<const SwTextFrame*>(pContent)->GetAllLines();
+ const sal_Int32 nAllLines = static_cast<const SwTextFrame*>(pContent)->GetAllLines();
const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pContent))->RecalcAllLines();
if ( IsPaintExtraData() && IsPaint() &&
nAllLines != static_cast<const SwTextFrame*>(pContent)->GetAllLines() )
@@ -1944,7 +1944,7 @@ void SwLayAction::FormatFlyContent( const SwFlyFrame *pFly )
if ( !pContent->GetValidLineNumFlag() && pContent->IsTextFrame() )
{
- const sal_uLong nAllLines = static_cast<const SwTextFrame*>(pContent)->GetAllLines();
+ const sal_Int32 nAllLines = static_cast<const SwTextFrame*>(pContent)->GetAllLines();
const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pContent))->RecalcAllLines();
if ( IsPaintExtraData() && IsPaint() &&
nAllLines != static_cast<const SwTextFrame*>(pContent)->GetAllLines() )
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index b187db7ac0b1..a701470a1c61 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -68,7 +68,7 @@ class SwExtraPainter
const SwLineNumberInfo &m_rLineInf;
SwTwips m_nX;
SwTwips m_nRedX;
- sal_uLong m_nLineNr;
+ sal_Int32 m_nLineNr;
sal_uInt16 m_nDivider;
bool m_bGoLeft;
bool IsClipChg() const { return m_aClip.IsChg(); }
@@ -86,7 +86,7 @@ public:
assert( m_rLineInf.GetCountBy() != 0 );
if( m_rLineInf.GetCountBy() == 0 )
return false;
- return !( m_nLineNr % m_rLineInf.GetCountBy() );
+ return !( m_nLineNr % static_cast<sal_Int32>(m_rLineInf.GetCountBy()) );
}
bool HasDivider() const {
assert( m_rLineInf.GetDividerCountBy() != 0 );
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index b248f20f4785..b72a8d59f5f7 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -747,7 +747,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 +780,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 +831,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 )
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index ba6641e7cdab..80900061b66f 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1243,7 +1243,7 @@ void SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst,
++nFindOfst;
// skip lines for fields which cover more than one line
- for ( sal_uInt16 i = 0; i < pCMS->m_pSpecialPos->nLineOfst; i++ )
+ for ( sal_Int32 i = 0; i < pCMS->m_pSpecialPos->nLineOfst; i++ )
Next();
}
diff --git a/sw/source/core/text/itrtxt.hxx b/sw/source/core/text/itrtxt.hxx
index 0b48e3b874fe..8db063d616e8 100644
--- a/sw/source/core/text/itrtxt.hxx
+++ b/sw/source/core/text/itrtxt.hxx
@@ -40,7 +40,7 @@ protected:
SwTwips m_nRegStart; // The register's start position (Y)
TextFrameIndex m_nStart; // Start in the text string, end = pCurr->GetLen()
sal_uInt16 m_nRegDiff; // Register's line distance
- sal_uInt16 m_nLineNr; // Line number
+ sal_Int32 m_nLineNr; // Line number
bool m_bPrev : 1;
bool m_bRegisterOn : 1; // Keep in register
bool m_bOneBlock : 1; // Justified text: Dispose single words
@@ -84,7 +84,7 @@ public:
const SwLineLayout *GetNext() const { return m_pCurr->GetNext(); }
const SwLineLayout *GetPrev();
TextFrameIndex GetLength() const { return m_pCurr->GetLen(); }
- sal_uInt16 GetLineNr() const { return m_nLineNr; }
+ sal_Int32 GetLineNr() const { return m_nLineNr; }
TextFrameIndex GetStart() const { return m_nStart; }
TextFrameIndex GetEnd() const { return GetStart() + GetLength(); }
SwTwips Y() const { return m_nY; }
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 6ae786f8b435..41124ce96a1c 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3833,9 +3833,9 @@ sal_uInt16 SwTextFrame::FirstLineHeight() const
return nHeight;
}
-sal_uInt16 SwTextFrame::GetLineCount(TextFrameIndex const nPos)
+sal_Int32 SwTextFrame::GetLineCount(TextFrameIndex const nPos)
{
- sal_uInt16 nRet = 0;
+ sal_Int32 nRet = 0;
SwTextFrame *pFrame = this;
do
{
@@ -3857,7 +3857,7 @@ sal_uInt16 SwTextFrame::GetLineCount(TextFrameIndex const nPos)
void SwTextFrame::ChgThisLines()
{
// not necessary to format here (GetFormatted etc.), because we have to come from there!
- sal_uInt32 nNew = 0;
+ sal_Int32 nNew = 0;
const SwLineNumberInfo &rInf = GetDoc().GetLineNumberInfo();
if ( !GetText().isEmpty() && HasPara() )
{
@@ -3917,9 +3917,9 @@ void SwTextFrame::RecalcAllLines()
if ( IsInTab() )
return;
- const sal_uLong nOld = GetAllLines();
+ const sal_Int32 nOld = GetAllLines();
const SwFormatLineNumber &rLineNum = GetTextNodeForParaProps()->GetSwAttrSet().GetLineNumber();
- sal_uLong nNewNum;
+ sal_Int32 nNewNum;
const bool bRestart = GetDoc().GetLineNumberInfo().IsRestartEachPage();
if ( !IsFollow() && rLineNum.GetStartValue() && rLineNum.IsCount() )
diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx
index 0ba37379d6ce..553cc2fa2de9 100644
--- a/sw/source/core/text/widorp.cxx
+++ b/sw/source/core/text/widorp.cxx
@@ -514,14 +514,14 @@ bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, SwTextMargin &rLine )
// could result in multiple lines for us.
// Therefore, the CalcFollow() remains in control until the Follow got all
// necessary lines.
- sal_uInt16 nNeed = 1; // was: nWidLines - rLine.GetLineNr();
+ sal_Int32 nNeed = 1; // was: nWidLines - rLine.GetLineNr();
// Special case: Master cannot give lines to follow
// i#91421
if ( !pMaster->GetIndPrev() )
{
pMaster->ChgThisLines();
- sal_uLong nLines = pMaster->GetThisLines();
+ sal_Int32 nLines = pMaster->GetThisLines();
if(nLines == 0 && pMaster->HasPara())
{
const SwParaPortion *pMasterPara = pMaster->GetPara();
@@ -544,7 +544,7 @@ bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, SwTextMargin &rLine )
// This is a follow frame and our side is fixed.
const SwAttrSet& rSet = pFrame->GetTextNodeForParaProps()->GetSwAttrSet();
const SvxOrphansItem& rOrph = rSet.GetOrphans();
- if (nLines <= rOrph.GetValue())
+ if (nLines <= static_cast<sal_Int32>(rOrph.GetValue()))
{
// If the master gives us a line as part of widow control, then its orphan
// control will move everything to the follow, which is worse than having no
@@ -567,7 +567,7 @@ bool WidowsAndOrphans::WouldFit( SwTextMargin &rLine, SwTwips &rMaxHeight, bool
// We expect that rLine is set to the last line
OSL_ENSURE( !rLine.GetNext(), "WouldFit: aLine::Bottom missed!" );
- sal_uInt16 nLineCnt = rLine.GetLineNr();
+ sal_Int32 nLineCnt = rLine.GetLineNr();
// First satisfy the Orphans-rule and the wish for initials ...
const sal_uInt16 nMinLines = std::max( GetOrphansLines(), rLine.GetDropLines() );
diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index a3de6219f96d..3eef17523c51 100644
--- a/sw/source/ui/misc/pggrid.cxx
+++ b/sw/source/ui/misc/pggrid.cxx
@@ -228,7 +228,7 @@ void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
aGridItem.SetGridType(m_xNoGridRB->get_active() ? GRID_NONE :
m_xLinesGridRB->get_active() ? GRID_LINES_ONLY : GRID_LINES_CHARS );
aGridItem.SetSnapToChars(m_xSnapToCharsCB->get_active());
- aGridItem.SetLines( static_cast< sal_uInt16 >(m_xLinesPerPageNF->get_value()) );
+ aGridItem.SetLines( static_cast< sal_Int32 >(m_xLinesPerPageNF->get_value()) );
aGridItem.SetBaseHeight( static_cast< sal_uInt16 >(
m_bRubyUserValue ? m_nRubyUserValue :
m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP))) );