diff options
author | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2011-09-06 11:16:01 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2011-09-06 11:28:10 +0200 |
commit | ec6905bf855a9226aa0e3143fdbf15bff306cb69 (patch) | |
tree | 9bd3ff8c59c846fa80a98651045a53561a8bbbf0 /sw | |
parent | cb3c09c32367a5b0c4c765ba0da75291c9367aa9 (diff) |
Header/Footer: enhanced the document subsidiary lines
+ Implemented http://wiki.services.openoffice.org/wiki/DocumentBorder#Option_3
+ Show the text boundaries for the currently edited area, e.g. don't
show the header and footer boundaries when editing the main body
+ Included the footnote boundaries into the main body ones as it's the
same editing area
+ Reimplemented the painting of the manual page breaks. These are
hidden when editing headers/footers and are be toggled with the
non-printing characters instead of the document boundaries.
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/bodyfrm.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/inc/ftnfrm.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/hffrm.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/inc/layfrm.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/pagefrm.hxx | 3 | ||||
-rwxr-xr-x | sw/source/core/layout/paintfrm.cxx | 149 |
6 files changed, 142 insertions, 16 deletions
diff --git a/sw/source/core/inc/bodyfrm.hxx b/sw/source/core/inc/bodyfrm.hxx index 42b77f36cec8..1513cc12b3d3 100644 --- a/sw/source/core/inc/bodyfrm.hxx +++ b/sw/source/core/inc/bodyfrm.hxx @@ -45,6 +45,7 @@ public: SwBodyFrm( SwFrmFmt*, SwFrm* ); virtual void Paint( const SwRect&, const SwPrintData *pPrintData = NULL ) const; + virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const; DECL_FIXEDMEMPOOL_NEWDEL(SwBodyFrm) }; diff --git a/sw/source/core/inc/ftnfrm.hxx b/sw/source/core/inc/ftnfrm.hxx index 7a79725b144f..4c9d7559dc24 100644 --- a/sw/source/core/inc/ftnfrm.hxx +++ b/sw/source/core/inc/ftnfrm.hxx @@ -84,6 +84,8 @@ public: virtual void Cut(); virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ); + virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const; + sal_Bool operator<( const SwTxtFtn* pTxtFtn ) const; #if OSL_DEBUG_LEVEL > 1 diff --git a/sw/source/core/inc/hffrm.hxx b/sw/source/core/inc/hffrm.hxx index 39f09e9bd45a..dcf9a2bdd561 100644 --- a/sw/source/core/inc/hffrm.hxx +++ b/sw/source/core/inc/hffrm.hxx @@ -46,6 +46,7 @@ public: sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False ); virtual SwTwips ShrinkFrm( SwTwips, sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False ); + virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const; }; class SwHeaderFrm: public SwHeadFootFrm diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx index 600c72bdd506..a93903364833 100644 --- a/sw/source/core/inc/layfrm.hxx +++ b/sw/source/core/inc/layfrm.hxx @@ -70,7 +70,7 @@ public: // --> #i28701# TYPEINFO(); - void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const; + virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const; void RefreshLaySubsidiary( const SwPageFrm*, const SwRect& ) const; void RefreshExtraData( const SwRect & ) const; diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index dfb0cefa1911..d45d4beeb518 100644 --- a/sw/source/core/inc/pagefrm.hxx +++ b/sw/source/core/inc/pagefrm.hxx @@ -209,7 +209,8 @@ public: void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const; sal_Bool HasGrid() const { return bHasGrid; } - void PaintDecorators( OutputDevice* pOut ) const; + void PaintDecorators( ) const; + void PaintBreak() const; //Zeilennummern usw malen void RefreshExtraData( const SwRect & ) const; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 62825b489c66..6d65e8466a8f 100755 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -87,6 +87,8 @@ #include <svx/svdogrp.hxx> #include <sortedobjs.hxx> #include <EnhancedPDFExportHelper.hxx> +#include <bodyfrm.hxx> +#include <hffrm.hxx> // <-- // --> OD #i76669# #include <svx/sdr/contact/viewobjectcontactredirector.hxx> @@ -2987,7 +2989,8 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const if ( bExtraData ) pPage->RefreshExtraData( aPaintRect ); - pPage->PaintDecorators( pSh->GetOut() ); + pPage->PaintDecorators( ); + pPage->PaintBreak( ); if ( pSh->GetWin() ) { @@ -3310,7 +3313,48 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr return aSeq; } -void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const +void SwPageFrm::PaintBreak( ) const +{ + const SwFrm* pBodyFrm = Lower(); + while ( pBodyFrm && !pBodyFrm->IsBodyFrm() ) + pBodyFrm = pBodyFrm->GetNext(); + + if ( pBodyFrm ) + { + const SwCntntFrm *pCnt = static_cast< const SwLayoutFrm* >( pBodyFrm )->ContainsCntnt(); + if ( pCnt && pCnt->IsPageBreak( sal_True )) + { + // Paint the break only if: + // * Not in header footer edition, to avoid conflicts with the + // header/footer marker + // * Non-printing characters are shown, as this is more consistent + // with other formatting marks + if ( !pGlobalShell->IsHeaderFooterEdit() && + pGlobalShell->GetViewOptions()->IsShowHiddenChar( ) ) + { + SwRect aRect( pCnt->Prt() ); + aRect.Pos() += pCnt->Frm().Pos(); + + basegfx::B2DPolygon aLine; + aLine.append( basegfx::B2DPoint( double( aRect.Left() ), double( aRect.Top() ) ) ); + aLine.append( basegfx::B2DPoint( double( aRect.Right() ), double( aRect.Top() ) ) ); + + basegfx::BColor aLineColor = SwViewOption::GetPageBreakColor().getBColor(); + + drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine = + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( + aLine, aLineColor ); + + drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 ); + aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine ); + + ProcessPrimitives( aSeq ); + } + } + } +} + +void SwPageFrm::PaintDecorators( ) const { SwWrtShell* pWrtSh = dynamic_cast< SwWrtShell* >( pGlobalShell ); if ( pWrtSh ) @@ -3331,7 +3375,7 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D(); // Line thickness in px - long nHalfThickness = pOut->LogicToPixel( Point( 0, LINE_HALF_THICKNESS ) ).Y(); + long nHalfThickness = pGlobalShell->GetOut()->LogicToPixel( Point( 0, LINE_HALF_THICKNESS ) ).Y(); // Header const SwFrm* pHeaderFrm = Lower(); @@ -3342,8 +3386,8 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() ); // FIXME there are cases where the label isn't show but should be - long nHeaderYOff = pHeaderFrm->Frm().Bottom(); - if ( rVisArea.IsInside( Point( rVisArea.Left(), pHeaderFrm->Frm().Bottom() ) ) ) + long nHeaderYOff = aBodyRect.Top(); + if ( rVisArea.IsInside( Point( rVisArea.Left(), nHeaderYOff ) ) ) { Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff + nHalfThickness ) ); rEditWin.AddHeaderFooterControl( pPageDesc, true, nOutputOff ); @@ -3353,15 +3397,17 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const this, double( nHeaderYOff ) ) ); // Footer - const SwFrm* pFooterFrm = Lower(); - while ( pFooterFrm->GetNext() ) - pFooterFrm = pFooterFrm->GetNext(); - if ( !pFooterFrm->IsFooterFrm() ) - pFooterFrm = NULL; + const SwFrm* pFtnContFrm = Lower(); + while ( pFtnContFrm->GetNext() ) + { + if ( pFtnContFrm->IsFtnContFrm() ) + aBodyRect.AddBottom( pFtnContFrm->Frm().Bottom() - aBodyRect.Bottom() ); + pFtnContFrm = pFtnContFrm->GetNext(); + } // FIXME there are cases where the label isn't show but should be - long nFooterYOff = pFooterFrm->Frm().Top(); - if ( rVisArea.IsInside( Point( rVisArea.Left(), pFooterFrm->Frm().Top() ) ) ) + long nFooterYOff = aBodyRect.Bottom(); + if ( rVisArea.IsInside( Point( rVisArea.Left(), nFooterYOff ) ) ) { Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff - nHalfThickness ) ); rEditWin.AddHeaderFooterControl( pPageDesc, false, nOutputOff ); @@ -6167,6 +6213,82 @@ void MA_FASTCALL lcl_RefreshLine( const SwLayoutFrm *pLay, } } +drawinglayer::primitive2d::Primitive2DSequence lcl_CreatePageAreaDelimiterPrimitives( + const SwRect& rRect ) +{ + drawinglayer::primitive2d::Primitive2DSequence aSeq( 4 ); + + basegfx::BColor aLineColor = SwViewOption::GetDocBoundariesColor().getBColor(); + double nLineLength = 200.0; // in Twips + + Point aPoints[] = { rRect.TopLeft(), rRect.TopRight(), rRect.BottomRight(), rRect.BottomLeft() }; + int aXOffDirs[] = { -1, 1, 1, -1 }; + int aYOffDirs[] = { -1, -1, 1, 1 }; + + // Actually loop over the corners to create the two lines + for ( int i = 0; i < 4; i++ ) + { + basegfx::B2DVector aHorizVector( double( aXOffDirs[i] ), 0.0 ); + basegfx::B2DVector aVertVector( 0.0, double( aYOffDirs[i] ) ); + + basegfx::B2DPoint aBPoint( aPoints[i].X(), aPoints[i].Y() ); + + basegfx::B2DPolygon aPolygon; + aPolygon.append( aBPoint + aHorizVector * nLineLength ); + aPolygon.append( aBPoint ); + aPolygon.append( aBPoint + aVertVector * nLineLength ); + + drawinglayer::primitive2d::PolygonHairlinePrimitive2D* pLine = + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( + aPolygon, aLineColor ); + aSeq[i] = drawinglayer::primitive2d::Primitive2DReference( pLine ); + } + + return aSeq; +} + +void SwBodyFrm::PaintSubsidiaryLines( const SwPageFrm *pPage, + const SwRect &/*rRect*/ ) const +{ + if ( !pGlobalShell->IsHeaderFooterEdit() ) + { + SwRect aArea( Frm() ); + + // TODO include the footnote area if any + const SwFrm* pLay = pPage->Lower(); + const SwFrm* pFtnCont = NULL; + while ( pLay->GetNext() && !pFtnCont ) + { + if ( pLay->IsFtnContFrm( ) ) + pFtnCont = pLay; + pLay = pLay->GetNext(); + } + + if ( pFtnCont ) + aArea.AddBottom( pFtnCont->Frm().Bottom() - aArea.Bottom() ); + + ProcessPrimitives( lcl_CreatePageAreaDelimiterPrimitives( aArea ) ); + } +} + +void SwHeadFootFrm::PaintSubsidiaryLines( const SwPageFrm *, const SwRect & ) const +{ + if ( pGlobalShell->IsHeaderFooterEdit() ) + { + SwRect aArea( Prt() ); + aArea.Pos() += Frm().Pos(); + ProcessPrimitives( lcl_CreatePageAreaDelimiterPrimitives( aArea ) ); + } +} + +/** This method is overridden in order to have no subsidiary lines + around the footnotes. + */ +void SwFtnFrm::PaintSubsidiaryLines( const SwPageFrm *, + const SwRect & ) const +{ +} + void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage, const SwRect &rRect ) const { @@ -6247,8 +6369,7 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage, if ( pCnt ) { // OD 05.11.2002 #102406# - adjust setting of <bBreak>. - bBreak = pCnt->IsPageBreak( sal_True ) || - ( IsColBodyFrm() && pCnt->IsColBreak( sal_True ) ); + bBreak = ( IsColBodyFrm() && pCnt->IsColBreak( sal_True ) ); } } |