sw/source/core/inc/pagefrm.hxx | 2 + sw/source/core/layout/paintfrm.cxx | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
New commits: commit 4821d90a119347f12bfb754ed0cd2aad074a7045 Author: Tamás Zolnai <[email protected]> AuthorDate: Mon Nov 24 14:16:25 2025 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Mon Nov 24 15:57:37 2025 +0100 Draw some lines Change-Id: I40c4cd4beeab6b1416365e9e728bfe1a7756b5c5 diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index aa2af7e0ae4c..542885c38c1d 100644 --- a/sw/source/core/inc/pagefrm.hxx +++ b/sw/source/core/inc/pagefrm.hxx @@ -190,6 +190,8 @@ public: void PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) const; bool HasGrid() const { return m_bHasGrid; } + void PaintBaselineGrid( OutputDevice& rOututDevice, const SwRect &rDrawArea ) const; + void PaintDecorators( ) const; virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override; void AddSubsidiaryLinesBounds(const SwViewShell& rShell, RectangleVector& rRects) const; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index c4d5caf3c0e2..4f6c61cfc1f9 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6185,6 +6185,58 @@ void SwPageFrame::PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) co } } +void SwPageFrame::PaintBaselineGrid( OutputDevice& rOututDevice, const SwRect &/*rDrawArea*/ ) const +{ + SAL_WARN("PaintBaselineGrid", "PaintBaselineGrid"); + + // Not displayed for printing. + // TODO: do not render for PDF + if(rOututDevice.GetOutDevType() == OUTDEV_PRINTER) + { + return; + } + + // TODO: use custom color + const Color aGridColor( COL_BLACK ); + const Color aOriginalLineColor( rOututDevice.GetLineColor() ); + rOututDevice.SetLineColor( aGridColor ); + + //GetPageDesc().GetRegHeight() + + const SwLayoutFrame* pBody = FindBodyCont(); + if( !pBody ) + return; + + SwRect aGridArea( pBody->getFramePrintArea() ); + aGridArea += pBody->getFrameArea().Pos(); + // TODO: find proper line height + const tools::Long nLineHeight = 200; + + // TODO: find proper baseline (offset) + + //const tools::Long nStartX = aGridArea.Left(); + const tools::Long nLineWidth = aGridArea.Right() - aGridArea.Left(); + //const tools::Long nLineCount = aGridArea.Height() / nLineHeight; + //const tools::Long nLineThickness = 1; + // TODO: use drawing area + /*for(int i = 1; i <= nLineCount / 2; i++) + { + const tools::Long nPositionY = aGridArea.Top() + nLineHeight * i; + if(nPositionY >= rDrawArea.Top() + nLineThickness && + nPositionY <= rDrawArea.Bottom()) + { + const SwRect aLineRect( nStartX, nPositionY, nLineWidth, nLineThickness ); + PaintBorderLine(aLineRect, rDrawArea, this, &aGridColor); + } + + }*/ + + rOututDevice.DrawGrid( tools::Rectangle( aGridArea.Left(), aGridArea.Top() + nLineHeight, aGridArea.Right(), aGridArea.Bottom() ), + Size( nLineWidth, nLineHeight ), DrawGridFlags::HorzLines ); + + rOututDevice.SetLineColor( aOriginalLineColor ); +} + /** * Paint margin area of a page * @@ -6729,6 +6781,7 @@ void SwFrame::PaintBaBo( const SwRect& rRect, const SwPageFrame *pPage, if( IsPageFrame() ) { static_cast<const SwPageFrame*>(this)->PaintGrid( pOut, aRect ); + static_cast<const SwPageFrame*>(this)->PaintBaselineGrid( *pOut, aRect ); } PaintSwFrameShadowAndBorder(aRect, pPage, rAttrs);
