From 02111da55639dc6a15f7ad1c2bfde1c9d8700880 Mon Sep 17 00:00:00 2001 From: Aron Budea Date: Mon, 4 Oct 2021 19:23:51 +0200 Subject: Revert "sw: allow the width of a line portion to be larger... ...than 65536 twips" The originating 301278b656e76b6f42af5cf8a6f5c6c02acfffeb will be reverted in libreoffice-7-2. This reverts commit 6fdd0a3f8b3448a9a246496191908c92156cc38b. Change-Id: Ia4f231af90d17eeaa0db4272c8a80e48181647dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122945 Reviewed-by: Mike Kaganski Reviewed-by: Andras Timar Tested-by: Christian Lohmaier --- sw/qa/core/text/data/line-width.fodt | 32 -------------------------------- sw/qa/core/text/text.cxx | 19 ------------------- sw/source/core/edit/edattr.cxx | 4 ++-- sw/source/core/text/itrcrsr.cxx | 12 ++++++------ sw/source/core/text/porglue.cxx | 2 +- sw/source/core/text/porlin.cxx | 2 +- sw/source/core/text/porlin.hxx | 4 ++-- sw/source/core/text/pormulti.cxx | 2 +- sw/source/core/text/pormulti.hxx | 2 +- 9 files changed, 14 insertions(+), 65 deletions(-) delete mode 100644 sw/qa/core/text/data/line-width.fodt diff --git a/sw/qa/core/text/data/line-width.fodt b/sw/qa/core/text/data/line-width.fodt deleted file mode 100644 index a6b2b2f5c62b..000000000000 --- a/sw/qa/core/text/data/line-width.fodt +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz - UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA - AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4 - AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+ - BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49 - cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn - /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF - QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo - YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo - 2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A - cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA - AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A - hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6 - 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA - AABJRU5ErkJggg== - - - - diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index be6406f6b654..d38b6a3e62cc 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -151,25 +151,6 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLineHeight) assertXPath(pXmlDoc, "//fly/infos/bounds", "top", OUString::number(DOCUMENTBORDER)); } -CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLineWidth) -{ - // Given a document with an as-char image, width in twips not fitting into sal_uInt16: - SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "line-width.fodt"); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - sal_Int32 nOldLeft = pWrtShell->GetCharRect().Left(); - - // When moving the cursor to the right: - pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); - - // Then make sure we move to the right by the image width: - sal_Int32 nNewLeft = pWrtShell->GetCharRect().Left(); - // Without the accompanying fix in place, this test would have failed with: - // - Expected greater than: 65536 - // - Actual : 1872 - // i.e. the width (around 67408 twips) was truncated. - CPPUNIT_ASSERT_GREATER(static_cast(65536), nNewLeft - nOldLeft); -} - CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 6ab5a3ae9ad8..4992cc965715 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -531,10 +531,10 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const SwFrame* pFrame = pCNd->getLayoutFrame( GetLayout() ); if ( pFrame ) { - const sal_uInt32 nFrameWidth = o3tl::narrowing( pFrame->IsVertical() ? + const sal_uInt16 nFrameWidth = o3tl::narrowing( pFrame->IsVertical() ? pFrame->getFrameArea().Height() : pFrame->getFrameArea().Width() ); - bRet = o3tl::narrowing(nFrameWidth) > ( nNext + MM50 ); + bRet = nFrameWidth > ( nNext + MM50 ); } else bRet = false; diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 2974826154bb..138359e68c41 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -1266,7 +1266,7 @@ void SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst, * Determines if SwTextCursor::GetModelPositionForViewPoint() should consider the next portion when calculating the * doc model position from a Point. */ -static bool ConsiderNextPortionForCursorOffset(const SwLinePortion* pPor, sal_uInt32 nWidth30, sal_uInt16 nX) +static bool ConsiderNextPortionForCursorOffset(const SwLinePortion* pPor, sal_uInt16 nWidth30, sal_uInt16 nX) { if (!pPor->GetNextPortion() || pPor->IsBreakPortion()) { @@ -1323,7 +1323,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con // Until here everything in document coordinates. x -= nLeftMargin; - sal_uInt32 nX = sal_uInt16( x ); + sal_uInt16 nX = sal_uInt16( x ); // If there are attribute changes in the line, search for the paragraph, // in which nX is situated. @@ -1342,7 +1342,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con // nWidth is the width of the line, or the width of // the paragraph with the font change, in which nX is situated. - sal_uInt32 nWidth = pPor->Width(); + sal_uInt16 nWidth = pPor->Width(); if ( m_pCurr->IsSpaceAdd() || pKanaComp ) { if ( pPor->InSpaceGrp() && nSpaceAdd ) @@ -1372,7 +1372,7 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con } } - sal_uInt32 nWidth30; + sal_uInt16 nWidth30; if ( pPor->IsPostItsPortion() ) nWidth30 = 0; else @@ -1691,12 +1691,12 @@ TextFrameIndex SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con } pCurrPart = pCurrPart->GetFollow(); } - nX = std::max(o3tl::narrowing(0), nX - nSumBorderWidth); + nX = std::max(0, nX - nSumBorderWidth); } // Shift the offset with the left border width else if( GetInfo().GetFont()->GetLeftBorder() && !pPor->GetJoinBorderWithPrev() ) { - nX = std::max(o3tl::narrowing(0), nX - GetInfo().GetFont()->GetLeftBorderSpace()); + nX = std::max(0, nX - GetInfo().GetFont()->GetLeftBorderSpace()); } aDrawInf.SetOffset( nX ); diff --git a/sw/source/core/text/porglue.cxx b/sw/source/core/text/porglue.cxx index 4ccfbbb62172..7c09ded23a2f 100644 --- a/sw/source/core/text/porglue.cxx +++ b/sw/source/core/text/porglue.cxx @@ -215,7 +215,7 @@ void SwMarginPortion::AdjustRight( const SwLineLayout *pCurr ) } while( pPrev != pLeft ) { - if( bNoMove || o3tl::narrowing(pPrev->PrtWidth()) >= nRightGlue || + if( bNoMove || pPrev->PrtWidth() >= nRightGlue || pPrev->InHyphGrp() || pPrev->IsKernPortion() ) { // The portion before the pRight cannot be moved diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index c5dc41ff3db5..e0a157d9d579 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -290,7 +290,7 @@ void SwLinePortion::Move( SwTextPaintInfo &rInf ) rInf.IncKanaIdx(); } if( rInf.IsRotated() ) - rInf.Y( rInf.Y() + ( bB2T ? -o3tl::narrowing(PrtWidth()) : o3tl::narrowing(PrtWidth()) ) ); + rInf.Y( rInf.Y() + ( bB2T ? -PrtWidth() : PrtWidth() ) ); else if ( bCounterDir ) rInf.X( rInf.X() - PrtWidth() ); else diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx index 3dc7ff9e287d..bca2025a2c6b 100644 --- a/sw/source/core/text/porlin.hxx +++ b/sw/source/core/text/porlin.hxx @@ -77,8 +77,8 @@ public: sal_uInt32 GetAscent() const { return mnAscent; } void SetAscent( const sal_uInt32 nNewAsc ) { mnAscent = nNewAsc; } void PrtWidth( sal_uInt16 nNewWidth ) { Width( nNewWidth ); } - sal_uInt32 PrtWidth() const { return Width(); } - void AddPrtWidth( const sal_uInt32 nNew ) { Width( Width() + nNew ); } + sal_uInt16 PrtWidth() const { return Width(); } + void AddPrtWidth( const sal_uInt16 nNew ) { Width( Width() + nNew ); } void SubPrtWidth( const sal_uInt16 nNew ) { Width( Width() - nNew ); } // Insert methods diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index b94302bd8ed7..55cb637e34ea 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -2511,7 +2511,7 @@ SwLinePortion* SwTextFormatter::MakeRestPortion( const SwLineLayout* pLine, SwTextCursorSave::SwTextCursorSave( SwTextCursor* pCursor, SwMultiPortion* pMulti, SwTwips nY, - sal_uInt32& nX, + sal_uInt16& nX, TextFrameIndex const nCurrStart, tools::Long nSpaceAdd ) : pTextCursor(pCursor), diff --git a/sw/source/core/text/pormulti.hxx b/sw/source/core/text/pormulti.hxx index c1df8b0400f2..8cd9e78f928f 100644 --- a/sw/source/core/text/pormulti.hxx +++ b/sw/source/core/text/pormulti.hxx @@ -241,7 +241,7 @@ class SwTextCursorSave bool bSpaceChg; public: SwTextCursorSave( SwTextCursor* pTextCursor, SwMultiPortion* pMulti, - SwTwips nY, sal_uInt32& nX, TextFrameIndex nCurrStart, tools::Long nSpaceAdd); + SwTwips nY, sal_uInt16& nX, TextFrameIndex nCurrStart, tools::Long nSpaceAdd); ~SwTextCursorSave(); }; -- cgit v1.2.3