sw/qa/core/layout/data/redline-table.docx |binary sw/qa/core/layout/paintfrm.cxx | 48 ++++++++++++++++++++++++++++++ sw/source/core/layout/paintfrm.cxx | 14 ++++++-- 3 files changed, 58 insertions(+), 4 deletions(-)
New commits: commit 2fda9973e6ea93835f0e9f37fb0e443aba77b5f9 Author: Miklos Vajna <[email protected]> AuthorDate: Tue Feb 3 16:23:59 2026 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Feb 4 12:39:21 2026 +0100 cool#13988 sw redline render mode: table row redlines The bugdoc has some table row-level insert and delete redlines. Switching to omit insert/delete redline render mode is expected to just color existing text as gray/red/green, and we get an unexpected table background here. The table background was added in commit f348440e17debacbcba9153e238e010e8c020bdc (tdf#146120 sw: show tracked table changes with different color, 2021-12-08), and is wanted with standard redline render mode, where you already underline/strikethrough modified text. Fix the problem by rendering table background similar to "hide changes" when we're in a non-standard redline render mode. In the future, we may want to draw some red/green border around these table row or cell frames, similar to what we do for images. But for now, just make sure the unwanted background is not painted. Change-Id: I42f8ec3acacb697fb59ad9ee4d5d9a62efade76a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198656 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/qa/core/layout/data/redline-table.docx b/sw/qa/core/layout/data/redline-table.docx new file mode 100644 index 000000000000..2af033fa151e Binary files /dev/null and b/sw/qa/core/layout/data/redline-table.docx differ diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx index cddb43f4b80d..b3d48ed1e808 100644 --- a/sw/qa/core/layout/paintfrm.cxx +++ b/sw/qa/core/layout/paintfrm.cxx @@ -11,9 +11,12 @@ #include <o3tl/string_view.hxx> #include <svtools/DocumentToGraphicRenderer.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/metaact.hxx> #include <docsh.hxx> #include <unotxdoc.hxx> +#include <wrtsh.hxx> namespace { @@ -212,6 +215,51 @@ CPPUNIT_TEST_FIXTURE(Test, testEndnoteContSeparator) // i.e. the separator was too short vs Word. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9360), nEndnoteSeparatorLength); } + +int CountPolyPolygons(const GDIMetaFile& rMetaFile) +{ + int nCount = 0; + for (size_t nAction = 0; nAction < rMetaFile.GetActionSize(); ++nAction) + { + MetaAction* pAction = rMetaFile.GetAction(nAction); + if (pAction->GetType() != MetaActionType::POLYPOLYGON) + { + continue; + } + + ++nCount; + } + return nCount; +} + +CPPUNIT_TEST_FIXTURE(Test, testTableRedlineRenderMode) +{ + // Given a document with table redlines, standard redline render mode: + createSwDoc("redline-table.docx"); + + // When painting those redlines: + SwDocShell* pDocShell = getSwDocShell(); + std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile(); + + // Make sure we have the filled polygons for the rows: + CPPUNIT_ASSERT_EQUAL(2, CountPolyPolygons(*xMetaFile)); + + // And given a document with 'omit inserts' redline render mode: + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + SwViewOption aOpt(*pWrtShell->GetViewOptions()); + aOpt.SetRedlineRenderMode(SwRedlineRenderMode::OmitInserts); + pWrtShell->ApplyViewOptions(aOpt); + + // When painting those redlines: + xMetaFile = pDocShell->GetPreviewMetaFile(); + + // Make sure we have no filled polygons for the rows: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 2 + // i.e. we had unexpected filled polygons where just colored text was wanted. + CPPUNIT_ASSERT_EQUAL(0, CountPolyPolygons(*xMetaFile)); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 7b58db9f155d..d89437ee530f 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6814,7 +6814,13 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP bool bBack = GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigBackRect, bLowerMode, /*bConsiderTextBox=*/false ); // show track changes of table row - if( IsRowFrame() && !getRootFrame()->IsHideRedlines() ) + const SwViewOption* pViewOptions = pSh->GetViewOptions(); + SwRedlineRenderMode eRedlineRenderMode = pViewOptions->GetRedlineRenderMode(); + // Non-standard redline render mode means we don't paint a custom background color for table + // redlines. + bool bHideTableRedlines + = getRootFrame()->IsHideRedlines() || eRedlineRenderMode != SwRedlineRenderMode::Standard; + if( IsRowFrame() && !bHideTableRedlines ) { RedlineType eType = static_cast<const SwRowFrame*>(this)->GetTabLine()->GetRedlineType(); if ( RedlineType::Delete == eType || RedlineType::Insert == eType ) @@ -6823,7 +6829,7 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP bBack = true; } } - else if ( IsCellFrame() && !getRootFrame()->IsHideRedlines() ) + else if ( IsCellFrame() && !bHideTableRedlines ) { RedlineType eType = static_cast<const SwCellFrame*>(this)->GetTabBox()->GetRedlineType(); if ( RedlineType::Delete == eType || RedlineType::Insert == eType ) @@ -6833,7 +6839,7 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP } } - if ( bBack && IsCellFrame() && !getRootFrame()->IsHideRedlines() && + if ( bBack && IsCellFrame() && !bHideTableRedlines && // skip cell background to show the row colored according to its tracked change RedlineType::None != static_cast<const SwRowFrame*>(GetUpper())->GetTabLine()->GetRedlineType() ) { @@ -6859,7 +6865,7 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP // #i6467# - on print output, pdf output and in embedded mode not editing color COL_WHITE is used // instead of the global retouche color. if ( pSh->GetOut()->GetOutDevType() == OUTDEV_PRINTER || - pSh->GetViewOptions()->IsPDFExport() || + pViewOptions->IsPDFExport() || ( pSh->GetDoc()->GetDocShell()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && !pSh->GetDoc()->GetDocShell()->IsInPlaceActive() )
