diff options
author | Sébastien Le Ray <sebastien-libreoffice@orniz.org> | 2011-02-27 18:02:06 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-03-03 10:41:27 +0000 |
commit | 14edd8786ab51a2eeeba7d346e6e4bed29afc36f (patch) | |
tree | 1f2ad05cce8ab03b077c1861028c44c316261194 /sw/source/core | |
parent | 91aec198c0664c8cddc81289713fb86da9403772 (diff) |
Draw smooth shadows around page and remove borders
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/inc/pagefrm.hxx | 29 | ||||
-rw-r--r-- | sw/source/core/layout/layact.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 110 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 11 |
4 files changed, 49 insertions, 113 deletions
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index e6b86b58da..3c0c1cb726 100644 --- a/sw/source/core/inc/pagefrm.hxx +++ b/sw/source/core/inc/pagefrm.hxx @@ -87,8 +87,6 @@ class SwPageFrm: public SwFtnBossFrm // is in progress. bool mbLayoutInProgress; - // #i9719# - static const sal_Int8 mnBorderPxWidth; static const sal_Int8 mnShadowPxWidth; void _UpdateAttr( SfxPoolItem*, SfxPoolItem*, BYTE &, @@ -97,28 +95,6 @@ class SwPageFrm: public SwFtnBossFrm // Anpassen der max. Fussnotenhoehen in den einzelnen Spalten void SetColMaxFtnHeight(); - /** determine rectangle for page border - - #i9719# - - @param _rPageRect - input parameter - constant instance reference of the page rectangle. - Generally, it's the frame area of the page, but for empty pages in print - preview, this parameter is useful. - - @param _pViewShell - input parameter - instance of the view shell, for which the rectangle - has to be generated. - - @param _orBorderRect - output parameter - instance reference of the border rectangle for - the given page rectangle - */ - static void GetBorderRect( const SwRect& _rPageRect, - ViewShell* _pViewShell, - SwRect& _orBorderRect, - bool bRightSidebar ); - /** determine rectangle for right page shadow #i9719# @@ -376,11 +352,6 @@ public: virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const; - // #i9719# - inline sal_Int8 BorderPxWidth() const - { - return mnBorderPxWidth; - } inline sal_Int8 ShadowPxWidth() const { return mnShadowPxWidth; diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 57af311a4e..4479c93bca 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -1427,8 +1427,6 @@ BOOL SwLayAction::FormatLayout( SwLayoutFrm *pLay, BOOL bAddRect ) if ( pLay->IsPageFrm() ) { SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(pLay); - const int nBorderWidth = - pImp->GetShell()->GetOut()->PixelToLogic( Size( pPageFrm->BorderPxWidth(), 0 ) ).Width(); const int nShadowWidth = pImp->GetShell()->GetOut()->PixelToLogic( Size( pPageFrm->ShadowPxWidth(), 0 ) ).Width(); @@ -1439,22 +1437,20 @@ BOOL SwLayAction::FormatLayout( SwLayoutFrm *pLay, BOOL bAddRect ) { case sw::sidebarwindows::SIDEBAR_LEFT: { - aPaint.Left( aPaint.Left() - nBorderWidth - nSidebarWidth); - aPaint.Right( aPaint.Right() + nBorderWidth + nShadowWidth); + aPaint.Left( aPaint.Left() - nSidebarWidth); + aPaint.Right( aPaint.Right() + nShadowWidth); } break; case sw::sidebarwindows::SIDEBAR_RIGHT: { - aPaint.Left( aPaint.Left() - nBorderWidth ); - aPaint.Right( aPaint.Right() + nBorderWidth + nShadowWidth + nSidebarWidth); + aPaint.Right( aPaint.Right() + nShadowWidth + nSidebarWidth); } break; case sw::sidebarwindows::SIDEBAR_NONE: // nothing to do break; } - aPaint.Top( aPaint.Top() - nBorderWidth ); - aPaint.Bottom( aPaint.Bottom() + nBorderWidth + nShadowWidth); + aPaint.Bottom( aPaint.Bottom() + nShadowWidth); } if ( pLay->IsPageFrm() && diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 0b8fa8b59c..2fa6b54649 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -111,6 +111,7 @@ #include <svtools/borderhelper.hxx> +#include "pagefrm.hrc" using namespace ::com::sun::star; @@ -5207,35 +5208,7 @@ void SwPageFrm::PaintMarginArea( const SwRect& _rOutputRect, } } -const sal_Int8 SwPageFrm::mnBorderPxWidth = 1; -const sal_Int8 SwPageFrm::mnShadowPxWidth = 2; - -/** determine rectangle for page border - - OD 12.02.2003 for #i9719# and #105645# - - @author OD -*/ -/*static*/ void SwPageFrm::GetBorderRect( const SwRect& _rPageRect, - ViewShell* _pViewShell, - SwRect& _orBorderRect, - bool bRightSidebar ) -{ - SwRect aAlignedPageRect( _rPageRect ); - ::SwAlignRect( aAlignedPageRect, _pViewShell ); - Rectangle aBorderPxRect = - _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() ); - - aBorderPxRect.Left() = aBorderPxRect.Left() - mnBorderPxWidth; - aBorderPxRect.Top() = aBorderPxRect.Top() - mnBorderPxWidth; - aBorderPxRect.Right() = aBorderPxRect.Right() + mnBorderPxWidth; - aBorderPxRect.Bottom() = aBorderPxRect.Bottom() + mnBorderPxWidth; - - AddSidebarBorders(aBorderPxRect,_pViewShell, bRightSidebar, true); - - _orBorderRect = - SwRect( _pViewShell->GetOut()->PixelToLogic( aBorderPxRect ) ); -} +const sal_Int8 SwPageFrm::mnShadowPxWidth = 10; /** determine rectangle for right page shadow @@ -5250,20 +5223,20 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 2; { SwRect aAlignedPageRect( _rPageRect ); ::SwAlignRect( aAlignedPageRect, _pViewShell ); - Rectangle aPagePxRect = + SwRect aPagePxRect = _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() ); + const SwPostItMgr *pMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0; - Rectangle aRightShadowPxRect( - aPagePxRect.Right() + mnShadowPxWidth, - aPagePxRect.Top() + 1, - aPagePxRect.Right() + mnBorderPxWidth + mnShadowPxWidth, - aPagePxRect.Bottom() + mnBorderPxWidth + mnShadowPxWidth ); + _orRightShadowRect.Chg( + Point( aPagePxRect.Right() + 1, aPagePxRect.Top() + mnShadowPxWidth + 1 ), + Size( mnShadowPxWidth, aPagePxRect.Height() - mnShadowPxWidth - 1 ) ); - if ( bRightSidebar ) - AddSidebarBorders(aRightShadowPxRect,_pViewShell, bRightSidebar, true); + if (bRightSidebar && pMgr && pMgr->ShowNotes() && pMgr->HasNotes()) + { + _orRightShadowRect.Pos(_orRightShadowRect.Left() + pMgr->GetSidebarWidth(true) + + pMgr->GetSidebarBorderWidth(true), _orRightShadowRect.Top()); + } - _orRightShadowRect = - SwRect( _pViewShell->GetOut()->PixelToLogic( aRightShadowPxRect ) ); } /** determine rectangle for bottom page shadow @@ -5279,19 +5252,15 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 2; { SwRect aAlignedPageRect( _rPageRect ); ::SwAlignRect( aAlignedPageRect, _pViewShell ); - Rectangle aPagePxRect = + SwRect aPagePxRect = _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() ); - Rectangle aBottomShadowPxRect( - aPagePxRect.Left() + 1, - aPagePxRect.Bottom() + mnShadowPxWidth, - aPagePxRect.Right() + mnBorderPxWidth + mnShadowPxWidth, - aPagePxRect.Bottom() + mnBorderPxWidth + mnShadowPxWidth ); + _orBottomShadowRect.Chg( + Point( aPagePxRect.Left() + 1 + mnShadowPxWidth, aPagePxRect.Bottom() + 1 ), + Size( aPagePxRect.Width() - 1 - mnShadowPxWidth, mnShadowPxWidth ) ); - AddSidebarBorders(aBottomShadowPxRect,_pViewShell, bRightSidebar, true); + AddSidebarBorders( _orBottomShadowRect, _pViewShell, bRightSidebar, true); - _orBottomShadowRect = - SwRect( _pViewShell->GetOut()->PixelToLogic( aBottomShadowPxRect ) ); } /** paint page border and shadow @@ -5310,34 +5279,30 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 2; SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *_pViewShell->GetOut() ); // <-- - // get color for page border and shadow paint - const Color& rColor = SwViewOption::GetFontColor(); - - // save current fill and line color of output device - Color aFill( _pViewShell->GetOut()->GetFillColor() ); - Color aLine( _pViewShell->GetOut()->GetLineColor() ); + BitmapEx aPageBottomShadow( SW_RES( BMP_PAGE_BOTTOM_SHADOW ) ); + BitmapEx aPageRightShadow( SW_RES( BMP_PAGE_RIGHT_SHADOW ) ); + BitmapEx aPageTopRightShadow( SW_RES( BMP_PAGE_TOP_RIGHT_SHADOW ) ); + BitmapEx aPageBottomRightShadow( SW_RES( BMP_PAGE_BOTTOM_RIGHT_SHADOW ) ); + BitmapEx aPageBottomLeftShadow( SW_RES( BMP_PAGE_BOTTOM_LEFT_SHADOW ) ); - // paint page border - _pViewShell->GetOut()->SetFillColor(); // OD 20.02.2003 #107369# - no fill color - _pViewShell->GetOut()->SetLineColor( rColor ); SwRect aPaintRect; - SwPageFrm::GetBorderRect( _rPageRect, _pViewShell, aPaintRect, bRightSidebar ); - _pViewShell->GetOut()->DrawRect( aPaintRect.SVRect() ); + OutputDevice *pOut = _pViewShell->GetOut(); // paint right shadow if ( bPaintRightShadow ) { - _pViewShell->GetOut()->SetFillColor( rColor ); SwPageFrm::GetRightShadowRect( _rPageRect, _pViewShell, aPaintRect, bRightSidebar ); - _pViewShell->GetOut()->DrawRect( aPaintRect.SVRect() ); + aPageRightShadow.Scale( 1, aPaintRect.Height() ); + pOut->DrawBitmapEx( pOut->PixelToLogic( aPaintRect.Pos() ), aPageRightShadow ); + pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left(), aPaintRect.Top() - mnShadowPxWidth ) ), aPageTopRightShadow ); + pOut->DrawBitmapEx( pOut->PixelToLogic( aPaintRect.BottomLeft() ), aPageBottomRightShadow ); } // paint bottom shadow SwPageFrm::GetBottomShadowRect( _rPageRect, _pViewShell, aPaintRect, bRightSidebar ); - _pViewShell->GetOut()->DrawRect( aPaintRect.SVRect() ); - - _pViewShell->GetOut()->SetFillColor( aFill ); - _pViewShell->GetOut()->SetLineColor( aLine ); + pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left() - mnShadowPxWidth, aPaintRect.Top() ) ), aPageBottomLeftShadow ); + aPageBottomShadow.Scale( aPaintRect.Width(), 1 ); + pOut->DrawBitmapEx( pOut->PixelToLogic( aPaintRect.Pos() ), aPageBottomShadow); } //mod #i6193# paint sidebar for notes @@ -5468,14 +5433,21 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 2; SwRect& _orBorderAndShadowBoundRect, bool bRightSidebar ) { + SwRect aAlignedPageRect( _rPageRect ); + ::SwAlignRect( aAlignedPageRect, _pViewShell ); + SwRect aPagePxRect = + _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() ); + SwRect aTmpRect; - SwPageFrm::GetBorderRect( _rPageRect, _pViewShell, _orBorderAndShadowBoundRect, bRightSidebar ); SwPageFrm::GetRightShadowRect( _rPageRect, _pViewShell, aTmpRect, bRightSidebar ); - _orBorderAndShadowBoundRect.Union( aTmpRect ); + + aPagePxRect.Right( aTmpRect.Right() ); + SwPageFrm::GetBottomShadowRect( _rPageRect, _pViewShell, aTmpRect, bRightSidebar ); - _orBorderAndShadowBoundRect.Union( aTmpRect ); + aPagePxRect.Bottom( aTmpRect.Bottom() ); + aPagePxRect.Left( aTmpRect.Left() - mnShadowPxWidth - 1); - AddSidebarBorders(_orBorderAndShadowBoundRect, _pViewShell, bRightSidebar, false); + _orBorderAndShadowBoundRect = _pViewShell->GetOut()->PixelToLogic( aPagePxRect.SVRect() ); } /*static*/ void SwPageFrm::AddSidebarBorders(SwRect &aRect, ViewShell* _pViewShell, bool bRightSidebar, bool bPx) diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 498877077e..60bfcc7cf4 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1005,9 +1005,6 @@ void ViewShell::VisPortChgd( const SwRect &rRect) if ( aPageRect.IsOver( aBoth ) ) { - // #i9719#, - consider new border and shadow width - const SwTwips nBorderWidth = - GetOut()->PixelToLogic( Size( pPage->BorderPxWidth(), 0 ) ).Width(); const SwTwips nShadowWidth = GetOut()->PixelToLogic( Size( pPage->ShadowPxWidth(), 0 ) ).Width(); @@ -1017,14 +1014,14 @@ void ViewShell::VisPortChgd( const SwRect &rRect) { case sw::sidebarwindows::SIDEBAR_LEFT: { - nPageLeft = aPageRect.Left() - nBorderWidth - nSidebarWidth; - nPageRight = aPageRect.Right() + nBorderWidth + nShadowWidth; + nPageLeft = aPageRect.Left() - nSidebarWidth; + nPageRight = aPageRect.Right() + nShadowWidth; } break; case sw::sidebarwindows::SIDEBAR_RIGHT: { - nPageLeft = aPageRect.Left() - nBorderWidth; - nPageRight = aPageRect.Right() + nBorderWidth + nShadowWidth + nSidebarWidth; + nPageLeft = aPageRect.Left(); + nPageRight = aPageRect.Right() + nShadowWidth + nSidebarWidth; } break; case sw::sidebarwindows::SIDEBAR_NONE: |