sw: use SAL_RET_MAYBENULL in GetTableBox()

This could have caught tdf#162180

Change-Id: I71e86b402ae0c603d1c7ace209d55f5808b9ebe2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171054
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli
2024-07-26 16:12:33 +02:00
parent a5133fb041
commit 3a961b522a
3 changed files with 14 additions and 8 deletions
+1 -1
View File
@@ -307,7 +307,7 @@ public:
SwFrameFormat* GetFlyFormat() const;
/// If node is in a table return the respective table box.
SwTableBox* GetTableBox() const;
SAL_RET_MAYBENULL SwTableBox* GetTableBox() const;
SwNodeOffset GetIndex() const { return SwNodeOffset(GetPos()); }
+7 -4
View File
@@ -616,10 +616,13 @@ static void lcl_setRowNotTracked(SwNode& rNode)
if ( rDoc.GetIDocumentUndoRedo().DoesUndo() && rNode.GetTableBox() )
{
SvxPrintItem aSetTracking(RES_PRINT, false);
SwNodeIndex aInsPos( *(rNode.GetTableBox()->GetSttNd()), 1);
SwCursor aCursor( SwPosition(aInsPos), nullptr );
::sw::UndoGuard const undoGuard(rNode.GetDoc().GetIDocumentUndoRedo());
rDoc.SetRowNotTracked( aCursor, aSetTracking );
if (const SwTableBox* pTableBox = rNode.GetTableBox())
{
SwNodeIndex aInsPos( *(pTableBox->GetSttNd()), 1);
SwCursor aCursor( SwPosition(aInsPos), nullptr );
::sw::UndoGuard const undoGuard(rNode.GetDoc().GetIDocumentUndoRedo());
rDoc.SetRowNotTracked( aCursor, aSetTracking );
}
}
}
+6 -3
View File
@@ -243,21 +243,24 @@ void SwASCWriter::WriteTable(SwTableNode* pTableNd, SwTextNode* pNd)
Out( aASCNodeFnTab, *pNd, *this );
Point aPrevBoxPoint;
if (const SwTableBox* pPrevBox = pNd->GetTableBox())
aPrevBoxPoint = pPrevBox->GetCoordinates();
SwTableBox* pTableBox = pNd->GetTableBox();
if (pTableBox)
aPrevBoxPoint = pTableBox->GetCoordinates();
m_pCurrentPam->Move(fnMoveForward, GoInNode);
pNd = m_pCurrentPam->GetPoint()->GetNode().GetTextNode();
pTableBox = pNd->GetTableBox();
// Line break in a box
// Each line is a new SwTextNode so we
// need to parse inside the current box
while (pNd->GetTableBox() && (pNd->GetTableBox()->GetCoordinates() == aPrevBoxPoint))
while (pTableBox && pTableBox->GetCoordinates() == aPrevBoxPoint)
{
Strm().WriteUnicodeOrByteText(sPreLineEnd);
Out(aASCNodeFnTab, *pNd, *this);
m_pCurrentPam->Move(fnMoveForward, GoInNode);
pNd = m_pCurrentPam->GetPoint()->GetNode().GetTextNode();
pTableBox = pNd->GetTableBox();
}
if (pBox != pLine->GetTabBoxes().back())
Strm().WriteUChar( 0x9 );