summaryrefslogtreecommitdiff
path: root/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
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')
-rw-r--r--editeng/source/editeng/editeng.cxx2
-rw-r--r--editeng/source/editeng/impedit3.cxx15
-rw-r--r--editeng/source/items/svxfont.cxx6
-rw-r--r--editeng/source/outliner/outleeng.cxx2
-rw-r--r--editeng/source/outliner/outleeng.hxx2
-rw-r--r--editeng/source/outliner/outliner.cxx6
6 files changed, 17 insertions, 16 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,
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index 691ef6cb037a..e5b6a6df4fbf 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -500,7 +500,7 @@ Size SvxFont::GetTextSize(const OutputDevice& rOut, const OUString &rTxt,
void SvxFont::QuickDrawText( OutputDevice *pOut,
const Point &rPos, const OUString &rTxt,
- const sal_Int32 nIdx, const sal_Int32 nLen, const tools::Long* pDXArray ) const
+ const sal_Int32 nIdx, const sal_Int32 nLen, o3tl::span<const tools::Long> pDXArray ) const
{
// Font has to be selected in OutputDevice...
@@ -526,12 +526,12 @@ void SvxFont::QuickDrawText( OutputDevice *pOut,
if( IsCapital() )
{
- DBG_ASSERT( !pDXArray, "DrawCapital not for TextArray!" );
+ DBG_ASSERT( pDXArray.empty(), "DrawCapital not for TextArray!" );
DrawCapital( pOut, aPos, rTxt, nIdx, nLen );
}
else
{
- if ( IsKern() && !pDXArray )
+ if ( IsKern() && pDXArray.empty() )
{
Size aSize = GetPhysTxtSize( pOut, rTxt, nIdx, nLen );
diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx
index d9e1d0595a11..ed0099d2ac1a 100644
--- a/editeng/source/outliner/outleeng.cxx
+++ b/editeng/source/outliner/outleeng.cxx
@@ -141,7 +141,7 @@ OUString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
}
void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen,
- const tools::Long* pDXArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
+ o3tl::span<const tools::Long> pDXArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft,
const EEngineData::WrongSpellVector* pWrongSpellVector,
const SvxFieldData* pFieldData,
bool bEndOfLine,
diff --git a/editeng/source/outliner/outleeng.hxx b/editeng/source/outliner/outleeng.hxx
index dcff4b9f8be0..ecc14d61a75c 100644
--- a/editeng/source/outliner/outleeng.hxx
+++ b/editeng/source/outliner/outleeng.hxx
@@ -44,7 +44,7 @@ public:
virtual void ParagraphConnected( sal_Int32 nLeftParagraph, sal_Int32 nRightParagraph ) override;
virtual void DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart,
- sal_Int32 nTextLen, const tools::Long* pDXArray, const SvxFont& rFont,
+ sal_Int32 nTextLen, o3tl::span<const tools::Long> pDXArray, const SvxFont& rFont,
sal_Int32 nPara, sal_uInt8 nRightToLeft,
const EEngineData::WrongSpellVector* pWrongSpellVector,
const SvxFieldData* pFieldData,
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index c827b13a5937..48d02130135a 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -977,7 +977,7 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& rStartPos, const Point&
aTextPos.AdjustY( -(aMetric.GetDescent()) );
}
- DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), aBuf.data(),
+ DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), o3tl::span(aBuf.data(), aBuf.size()),
aSvxFont, nPara, bRightToLeftPara ? 1 : 0, nullptr, nullptr, false, false, true, nullptr, Color(), Color());
}
else
@@ -1653,7 +1653,7 @@ void Outliner::StripPortions()
}
void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart,
- sal_Int32 nTextLen, const tools::Long* pDXArray,const SvxFont& rFont,
+ sal_Int32 nTextLen, o3tl::span<const tools::Long> pDXArray,const SvxFont& rFont,
sal_Int32 nPara, sal_uInt8 nRightToLeft,
const EEngineData::WrongSpellVector* pWrongSpellVector,
const SvxFieldData* pFieldData,
@@ -1679,7 +1679,7 @@ void Outliner::DrawingTab( const Point& rStartPos, tools::Long nWidth, const OUS
{
if(aDrawPortionHdl.IsSet())
{
- DrawPortionInfo aInfo( rStartPos, rChar, 0, rChar.getLength(), rFont, nPara, nullptr, nullptr,
+ DrawPortionInfo aInfo( rStartPos, rChar, 0, rChar.getLength(), rFont, nPara, {}, nullptr,
nullptr, nullptr, rOverlineColor, rTextLineColor, nRightToLeft, true, nWidth, bEndOfLine, bEndOfParagraph, false);
aDrawPortionHdl.Call( &aInfo );