summaryrefslogtreecommitdiff
path: root/editeng/source/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-10-28 09:27:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-10-29 12:38:51 +0200
commit894b4911ffb96ff667fdeb3aec7922316ab7230a (patch)
tree3942ed8088c058b70bb79984b186c5156284abf4 /editeng/source/editeng
parent5b0ae3b59cd2cccfb72d991657366eb2a69bff49 (diff)
pass DX array around using o3tl::span instead of pointer
so we get bounds checking in debug mode Note that I cannot just pass around the std::vectors involved because there is a place in editeng which calls with a subset of a vector. Change-Id: I5088a139593c27bf9cbe5d843ab4b0048ac6d508 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124330 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source/editeng')
-rw-r--r--editeng/source/editeng/editeng.cxx2
-rw-r--r--editeng/source/editeng/impedit3.cxx15
2 files changed, 9 insertions, 8 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index f7c125cc2bca..5301de9513e0 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2464,7 +2464,7 @@ css::uno::Reference< css::datatransfer::XTransferable >
// ====================== Virtual Methods ========================
void EditEngine::DrawingText( const Point&, const OUString&, sal_Int32, sal_Int32,
- const tools::Long*, const SvxFont&, sal_Int32 /*nPara*/, sal_uInt8 /*nRightToLeft*/,
+ o3tl::span<const tools::Long>, const SvxFont&, sal_Int32 /*nPara*/, sal_uInt8 /*nRightToLeft*/,
const EEngineData::WrongSpellVector*, const SvxFieldData*, bool, bool,
const css::lang::Locale*, const Color&, const Color&)
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 9281f4d7dcf2..98736f11cb85 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -156,7 +156,7 @@ static void lcl_DrawRedLines( OutputDevice& rOutDev,
const Point& rPoint,
size_t nIndex,
size_t nMaxEnd,
- const tools::Long* pDXArray,
+ o3tl::span<const tools::Long> pDXArray,
WrongList const * pWrongs,
Degree10 nOrientation,
const Point& rOrigin,
@@ -3258,7 +3258,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
OUString aText;
sal_Int32 nTextStart = 0;
sal_Int32 nTextLen = 0;
- const tools::Long* pDXArray = nullptr;
+ o3tl::span<const tools::Long> pDXArray;
std::vector<tools::Long> aTmpDXArray;
if ( rTextPortion.GetKind() == PortionKind::TEXT )
@@ -3266,7 +3266,8 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
aText = rPortion.GetNode()->GetString();
nTextStart = nIndex;
nTextLen = rTextPortion.GetLen();
- pDXArray = pLine->GetCharPosArray().data() + (nIndex - pLine->GetStart());
+ pDXArray = o3tl::span(pLine->GetCharPosArray().data() + (nIndex - pLine->GetStart()),
+ pLine->GetCharPosArray().size() - (nIndex - pLine->GetStart()));
// Paint control characters (#i55716#)
/* XXX: Given that there's special handling
@@ -3391,7 +3392,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
aTmpFont.SetPhysFont(*GetRefDevice());
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, &aTmpDXArray );
- pDXArray = aTmpDXArray.data();
+ pDXArray = o3tl::span(aTmpDXArray.data(), aTmpDXArray.size());
// add a meta file comment if we record to a metafile
if( bMetafileValid )
@@ -3417,7 +3418,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
// crash when accessing 0 pointer in pDXArray
aTmpFont.SetPhysFont(*GetRefDevice());
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), &aTmpDXArray );
- pDXArray = aTmpDXArray.data();
+ pDXArray = o3tl::span(aTmpDXArray.data(), aTmpDXArray.size());
}
tools::Long nTxtWidth = rTextPortion.GetSize().Width();
@@ -3753,7 +3754,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
const Color aTextLineColor(rOutDev.GetTextLineColor());
GetEditEnginePtr()->DrawingText(
- aTmpPos, OUString(), 0, 0, nullptr,
+ aTmpPos, OUString(), 0, 0, {},
aTmpFont, n, 0,
nullptr,
nullptr,
@@ -3802,7 +3803,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
const Color aTextLineColor(rOutDev.GetTextLineColor());
GetEditEnginePtr()->DrawingText(
- aTmpPos, OUString(), 0, 0, nullptr,
+ aTmpPos, OUString(), 0, 0, {},
aTmpFont, n, 0,
nullptr,
nullptr,