summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-10-30 09:51:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-10-31 12:10:52 +0100
commit11b15571475414ef853e21a6c96afa2ac81f848f (patch)
treee32da625489c121001e8436fb693b2a25a1e1b6e /sw
parentef085d09e0c019f78a3d35f759c8fe567856b615 (diff)
convert KernArray from sal_Int32 to double
which allows us to eliminate a bunch of rounding at various layers, and consequently maintain a lot more precision Change-Id: I911dedd7c041c1d67396c082e5695346ea689acb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175814 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/text/text.cxx4
-rw-r--r--sw/qa/core/txtnode/justify.cxx4
-rw-r--r--sw/qa/extras/layout/layout3.cxx6
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx2
-rw-r--r--sw/source/core/text/porlay.cxx12
-rw-r--r--sw/source/core/txtnode/fntcache.cxx16
-rw-r--r--sw/source/core/txtnode/justify.cxx20
7 files changed, 32 insertions, 32 deletions
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 40bdcca07b5f..6dc3e933a2dc 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -1623,9 +1623,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf129810)
CPPUNIT_ASSERT_EQUAL(size_t(14), pDXArray.size());
// Assert we are using the expected width for uncompressed chars
- CPPUNIT_ASSERT_EQUAL(sal_Int32(720), pDXArray[0]);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(720), sal_Int32(pDXArray[0]));
// Assert we are using the expected width for compressed chars
- CPPUNIT_ASSERT_EQUAL(sal_Int32(500), pDXArray[6] - pDXArray[5]);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(500), sal_Int32(pDXArray[6] - pDXArray[5]));
break;
}
}
diff --git a/sw/qa/core/txtnode/justify.cxx b/sw/qa/core/txtnode/justify.cxx
index 98b81babd8ff..495c3037a062 100644
--- a/sw/qa/core/txtnode/justify.cxx
+++ b/sw/qa/core/txtnode/justify.cxx
@@ -56,13 +56,13 @@ std::ostream& operator<<(std::ostream& rStrm, const CharWidthArray& rCharWidthAr
void CharWidthArray::ConvertToKernArray()
{
for (std::size_t i = 1; i < maArray.size(); ++i)
- maArray.adjust(i, maArray[i - 1]);
+ maArray[i] += maArray[i - 1];
}
void CharWidthArray::ConvertToCharWidths()
{
for (sal_Int32 i = maArray.size() - 1; i > 0; --i)
- maArray.adjust(i, -maArray[i - 1]);
+ maArray[i] -= maArray[i - 1];
}
/// Convert maArray to kern array values, then invoke the function, and convert it back.
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 7fd080b043e2..ebec9da48e4f 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -446,7 +446,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf161810)
// Assert we are using the expected position for the last char
// This was 9369, now 9165, according to the fixed space shrinking
- CPPUNIT_ASSERT_LESS(sal_Int32(9300), pDXArray[72]);
+ CPPUNIT_ASSERT_LESS(sal_Int32(9300), sal_Int32(pDXArray[72]));
break;
}
}
@@ -491,7 +491,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf163149)
// Assert we are using the expected position for the last char
// This was 4673, now 4163, according to the fixed space shrinking
- CPPUNIT_ASSERT_LESS(sal_Int32(4200), pDXArray[45]);
+ CPPUNIT_ASSERT_LESS(sal_Int32(4200), sal_Int32(pDXArray[45]));
break;
}
}
@@ -920,7 +920,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122607)
assertXPath(pXmlDoc,
"/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/"
"fly/txt/SwParaPortion/SwLineLayout/child::*[1]",
- "width", u"428");
+ "width", u"427");
assertXPath(pXmlDoc,
"/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/"
"fly/txt/SwParaPortion/SwLineLayout/child::*[1]",
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index eb7502025b15..fec4a17c269e 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3389,7 +3389,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testDropDownFormFieldButton)
CPPUNIT_ASSERT_EQUAL("drop-down"_ostr, sType);
OString sTextArea( aTree.get_child("textArea").get_value<std::string>() );
- CPPUNIT_ASSERT_EQUAL("1538, 1418, 1026, 275"_ostr, sTextArea);
+ CPPUNIT_ASSERT_EQUAL("1538, 1418, 1025, 275"_ostr, sTextArea);
boost::property_tree::ptree aItems = aTree.get_child("params").get_child("items");
CPPUNIT_ASSERT_EQUAL(size_t(6), aItems.size());
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 9f0fd502114f..99e00aa071df 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -2141,8 +2141,8 @@ tools::Long SwScriptInfo::Compress(KernArray& rKernArray, TextFrameIndex nIdx, T
nSub -= nLast;
nLast = rKernArray[ nI ];
if( nI && nMove )
- rKernArray.adjust(nI - 1, nMove);
- rKernArray.adjust(nI, -nSub);
+ rKernArray[nI - 1] += nMove;
+ rKernArray[nI] += -nSub;
++nI;
++nIdx;
}
@@ -2163,7 +2163,7 @@ tools::Long SwScriptInfo::Compress(KernArray& rKernArray, TextFrameIndex nIdx, T
while( nIdx < nTmpChg )
{
nLast = rKernArray[ nI ];
- rKernArray.adjust(nI, -nSub);
+ rKernArray[nI] += -nSub;
++nI;
++nIdx;
}
@@ -2251,7 +2251,7 @@ sal_Int32 SwScriptInfo::KashidaJustify( KernArray* pKernArray,
while ( nArrayPos < nArrayEnd )
{
- pKernArray->adjust(sal_Int32(nArrayPos), nKashAdd);
+ (*pKernArray)[sal_Int32(nArrayPos)] += nKashAdd;
++nArrayPos;
}
nKashAdd += nSpaceAdd;
@@ -2496,7 +2496,7 @@ TextFrameIndex SwScriptInfo::ThaiJustify( std::u16string_view aText, KernArray*
}
if (pKernArray)
- pKernArray->adjust(nI, nSpaceSum);
+ (*pKernArray)[nI] += nSpaceSum;
}
return nCnt;
@@ -2877,7 +2877,7 @@ void SwScriptInfo::CJKJustify( const OUString& rText, KernArray& rKernArray,
if (nNext < sal_Int32(nStt + nLen) || !bIsSpaceStop)
nSpaceSum += nSpaceAdd;
}
- rKernArray.adjust(nI, nSpaceSum);
+ rKernArray[nI] += nSpaceSum;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 3ae9456e62d8..9d8b678b9681 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1108,7 +1108,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
tools::Long nSum = nDiff;
for( sal_Int32 i = 0; i < nZwi; )
{
- aKernArray.adjust(i, nSum);
+ aKernArray[i] += nSum;
if( ++i == nRest )
nDiff += nAdd;
nSum += nDiff;
@@ -1202,7 +1202,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
{
if (CH_BLANK == rInf.GetText()[sal_Int32(rInf.GetIdx()) + i])
nKernSum += nSpaceAdd;
- aKernArray.adjust(i, nKernSum);
+ aKernArray[i] += nKernSum;
}
// In case of underlined/strike-through justified text
@@ -1213,14 +1213,14 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
// If it is a single underlined space, output 2 spaces:
if (TextFrameIndex(1) == rInf.GetLen())
{
- aKernArray.set(0, rInf.GetWidth() + nSpaceAdd);
+ aKernArray[0] = rInf.GetWidth() + nSpaceAdd;
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
aKernArray, aKashidaArray, sal_Int32(rInf.GetIdx()), 1 );
}
else
{
sal_Int32 nIndex(sal_Int32(rInf.GetLen()) - 2);
- aKernArray.adjust(nIndex, nSpaceAdd);
+ aKernArray[nIndex] += nSpaceAdd;
DrawTextArray(rInf.GetOut(), aTextOriginPos, rInf.GetText(), aKernArray,
aKashidaArray, sal_Int32{ rInf.GetIdx() },
sal_Int32{ rInf.GetLen() }, rInf.GetLayoutContext());
@@ -1455,9 +1455,9 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
// have to output 2 spaces:
if ((nCnt == TextFrameIndex(1)) && rInf.GetSpace() && (cChPrev == CH_BLANK))
{
- aKernArray.set(0, rInf.GetWidth() +
+ aKernArray[0] = rInf.GetWidth() +
rInf.GetKern() +
- (rInf.GetSpace() / SPACING_PRECISION_FACTOR));
+ (rInf.GetSpace() / SPACING_PRECISION_FACTOR);
if ( bSwitchL2R )
rInf.GetFrame()->SwitchLTRtoRTL( aTextOriginPos );
@@ -1615,9 +1615,9 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
for( sal_Int32 i = 1 ; i < nLen ; ++i )
{
if ( aBulletOverlay[ i ] == CH_BULLET )
- aKernArray.adjust(i - 1, nShift);
+ aKernArray[i - 1] += nShift;
if ( nAdd )
- aKernArray.adjust(i - 1, -nAdd);
+ aKernArray[i - 1] += -nAdd;
}
}
rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, aKernArray,
diff --git a/sw/source/core/txtnode/justify.cxx b/sw/source/core/txtnode/justify.cxx
index 16a141a5b284..e1ea949b5613 100644
--- a/sw/source/core/txtnode/justify.cxx
+++ b/sw/source/core/txtnode/justify.cxx
@@ -152,23 +152,23 @@ void SpaceDistribution(KernArray& rKernArray, std::u16string_view aText, sal_Int
}
cChPrev = nCh;
- rKernArray.adjust(nPrevIdx, nKernSum + nSpaceSum);
+ rKernArray[nPrevIdx] += nKernSum + nSpaceSum;
// In word line mode and for Arabic, we disabled the half space trick. If a portion
// ends with a blank, the full nSpaceAdd value has been added to the character in
// front of the blank. This leads to painting artifacts, therefore we remove the
// nSpaceAdd value again:
if (bNoHalfSpace && i + 1 == nLen && nCh == CH_BLANK)
- rKernArray.adjust(nPrevIdx, -nSpaceAdd);
+ rKernArray[nPrevIdx] += -nSpaceAdd;
// Advance nPrevIdx and assign kern values to previous cluster.
for (tools::Long nValue = rKernArray[nPrevIdx++]; nPrevIdx < i; ++nPrevIdx)
- rKernArray.set(nPrevIdx, nValue);
+ rKernArray[nPrevIdx] = nValue;
}
// the layout engine requires the total width of the output
while (nPrevIdx < nLen)
{
- rKernArray.adjust(nPrevIdx, nKernSum + nSpaceSum);
+ rKernArray[nPrevIdx] += nKernSum + nSpaceSum;
++nPrevIdx;
}
}
@@ -199,14 +199,14 @@ tools::Long SnapToGrid(KernArray& rKernArray, std::u16string_view aText, sal_Int
while (nLast < i)
{
- rKernArray.set(nLast, nX);
+ rKernArray[nLast] = nX;
++nLast;
}
}
while (nLast < nLen)
{
- rKernArray.set(nLast, nEdge);
+ rKernArray[nLast] = nEdge;
++nLast;
}
@@ -238,7 +238,7 @@ void lcl_MsoCompatSnapToGridEdge(KernArray& rKernArray, sal_Int32 nLen, tools::L
tools::Long nMinWidth = lcl_MsoGridWidth(nGridWidth, nBaseFontSize, nCharWidth + nKern);
while (nLast < i)
{
- rKernArray.set(nLast, nEdge);
+ rKernArray[nLast] = nEdge;
++nLast;
}
@@ -247,7 +247,7 @@ void lcl_MsoCompatSnapToGridEdge(KernArray& rKernArray, sal_Int32 nLen, tools::L
while (nLast < nLen)
{
- rKernArray.set(nLast, nEdge);
+ rKernArray[nLast] = nEdge;
++nLast;
}
}
@@ -279,7 +279,7 @@ void SnapToGridEdge(KernArray& rKernArray, sal_Int32 nLen, tools::Long nGridWidt
tools::Long nMinWidth = lcl_MinGridWidth(nGridWidth, nCharWidth + nKern);
while (nLast < i)
{
- rKernArray.set(nLast, nEdge);
+ rKernArray[nLast] = nEdge;
++nLast;
}
@@ -288,7 +288,7 @@ void SnapToGridEdge(KernArray& rKernArray, sal_Int32 nLen, tools::Long nGridWidt
while (nLast < nLen)
{
- rKernArray.set(nLast, nEdge);
+ rKernArray[nLast] = nEdge;
++nLast;
}
}