Kaydet (Commit) ec6905bf authored tarafından Cédric Bosdonnat's avatar Cédric Bosdonnat

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.
üst cb3c09c3
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
SwBodyFrm( SwFrmFmt*, SwFrm* ); SwBodyFrm( SwFrmFmt*, SwFrm* );
virtual void Paint( const SwRect&, const SwPrintData *pPrintData = NULL ) const; virtual void Paint( const SwRect&, const SwPrintData *pPrintData = NULL ) const;
virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
DECL_FIXEDMEMPOOL_NEWDEL(SwBodyFrm) DECL_FIXEDMEMPOOL_NEWDEL(SwBodyFrm)
}; };
......
...@@ -84,6 +84,8 @@ public: ...@@ -84,6 +84,8 @@ public:
virtual void Cut(); virtual void Cut();
virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ); virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
sal_Bool operator<( const SwTxtFtn* pTxtFtn ) const; sal_Bool operator<( const SwTxtFtn* pTxtFtn ) const;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
......
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False ); sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
virtual SwTwips ShrinkFrm( SwTwips, virtual SwTwips ShrinkFrm( SwTwips,
sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False ); sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
}; };
class SwHeaderFrm: public SwHeadFootFrm class SwHeaderFrm: public SwHeadFootFrm
......
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
// --> #i28701# // --> #i28701#
TYPEINFO(); TYPEINFO();
void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const; virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
void RefreshLaySubsidiary( const SwPageFrm*, const SwRect& ) const; void RefreshLaySubsidiary( const SwPageFrm*, const SwRect& ) const;
void RefreshExtraData( const SwRect & ) const; void RefreshExtraData( const SwRect & ) const;
......
...@@ -209,7 +209,8 @@ public: ...@@ -209,7 +209,8 @@ public:
void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const; void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const;
sal_Bool HasGrid() const { return bHasGrid; } sal_Bool HasGrid() const { return bHasGrid; }
void PaintDecorators( OutputDevice* pOut ) const; void PaintDecorators( ) const;
void PaintBreak() const;
//Zeilennummern usw malen //Zeilennummern usw malen
void RefreshExtraData( const SwRect & ) const; void RefreshExtraData( const SwRect & ) const;
......
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
#include <svx/svdogrp.hxx> #include <svx/svdogrp.hxx>
#include <sortedobjs.hxx> #include <sortedobjs.hxx>
#include <EnhancedPDFExportHelper.hxx> #include <EnhancedPDFExportHelper.hxx>
#include <bodyfrm.hxx>
#include <hffrm.hxx>
// <-- // <--
// --> OD #i76669# // --> OD #i76669#
#include <svx/sdr/contact/viewobjectcontactredirector.hxx> #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
...@@ -2987,7 +2989,8 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const ...@@ -2987,7 +2989,8 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
if ( bExtraData ) if ( bExtraData )
pPage->RefreshExtraData( aPaintRect ); pPage->RefreshExtraData( aPaintRect );
pPage->PaintDecorators( pSh->GetOut() ); pPage->PaintDecorators( );
pPage->PaintBreak( );
if ( pSh->GetWin() ) if ( pSh->GetWin() )
{ {
...@@ -3310,7 +3313,48 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr ...@@ -3310,7 +3313,48 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
return aSeq; 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 ); SwWrtShell* pWrtSh = dynamic_cast< SwWrtShell* >( pGlobalShell );
if ( pWrtSh ) if ( pWrtSh )
...@@ -3331,7 +3375,7 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const ...@@ -3331,7 +3375,7 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const
drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D(); drawinglayer::processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D();
// Line thickness in px // 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 // Header
const SwFrm* pHeaderFrm = Lower(); const SwFrm* pHeaderFrm = Lower();
...@@ -3342,8 +3386,8 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const ...@@ -3342,8 +3386,8 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const
long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() ); long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() );
// FIXME there are cases where the label isn't show but should be // FIXME there are cases where the label isn't show but should be
long nHeaderYOff = pHeaderFrm->Frm().Bottom(); long nHeaderYOff = aBodyRect.Top();
if ( rVisArea.IsInside( Point( rVisArea.Left(), pHeaderFrm->Frm().Bottom() ) ) ) if ( rVisArea.IsInside( Point( rVisArea.Left(), nHeaderYOff ) ) )
{ {
Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff + nHalfThickness ) ); Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff + nHalfThickness ) );
rEditWin.AddHeaderFooterControl( pPageDesc, true, nOutputOff ); rEditWin.AddHeaderFooterControl( pPageDesc, true, nOutputOff );
...@@ -3353,15 +3397,17 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const ...@@ -3353,15 +3397,17 @@ void SwPageFrm::PaintDecorators( OutputDevice *pOut ) const
this, double( nHeaderYOff ) ) ); this, double( nHeaderYOff ) ) );
// Footer // Footer
const SwFrm* pFooterFrm = Lower(); const SwFrm* pFtnContFrm = Lower();
while ( pFooterFrm->GetNext() ) while ( pFtnContFrm->GetNext() )
pFooterFrm = pFooterFrm->GetNext(); {
if ( !pFooterFrm->IsFooterFrm() ) if ( pFtnContFrm->IsFtnContFrm() )
pFooterFrm = NULL; aBodyRect.AddBottom( pFtnContFrm->Frm().Bottom() - aBodyRect.Bottom() );
pFtnContFrm = pFtnContFrm->GetNext();
}
// FIXME there are cases where the label isn't show but should be // FIXME there are cases where the label isn't show but should be
long nFooterYOff = pFooterFrm->Frm().Top(); long nFooterYOff = aBodyRect.Bottom();
if ( rVisArea.IsInside( Point( rVisArea.Left(), pFooterFrm->Frm().Top() ) ) ) if ( rVisArea.IsInside( Point( rVisArea.Left(), nFooterYOff ) ) )
{ {
Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff - nHalfThickness ) ); Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff - nHalfThickness ) );
rEditWin.AddHeaderFooterControl( pPageDesc, false, nOutputOff ); rEditWin.AddHeaderFooterControl( pPageDesc, false, nOutputOff );
...@@ -6167,6 +6213,82 @@ void MA_FASTCALL lcl_RefreshLine( const SwLayoutFrm *pLay, ...@@ -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, void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
const SwRect &rRect ) const const SwRect &rRect ) const
{ {
...@@ -6247,8 +6369,7 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage, ...@@ -6247,8 +6369,7 @@ void SwLayoutFrm::PaintSubsidiaryLines( const SwPageFrm *pPage,
if ( pCnt ) if ( pCnt )
{ {
// OD 05.11.2002 #102406# - adjust setting of <bBreak>. // OD 05.11.2002 #102406# - adjust setting of <bBreak>.
bBreak = pCnt->IsPageBreak( sal_True ) || bBreak = ( IsColBodyFrm() && pCnt->IsColBreak( sal_True ) );
( IsColBodyFrm() && pCnt->IsColBreak( sal_True ) );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment