[Libreoffice-commits] .: Branch 'libreoffice-3-4' - 9 commits - sw/inc sw/source

Jan Holesovsky kendy at kemper.freedesktop.org
Tue May 3 05:46:57 PDT 2011


 sw/inc/rcid.hrc                           |    2 
 sw/source/core/inc/frmtool.hxx            |    2 
 sw/source/core/inc/pagefrm.hrc            |    6 
 sw/source/core/inc/pagefrm.hxx            |   46 ++----
 sw/source/core/layout/layact.cxx          |   83 +++++------
 sw/source/core/layout/pagechg.cxx         |    5 
 sw/source/core/layout/pagefrm.src         |   14 -
 sw/source/core/layout/paintfrm.cxx        |  219 ++++++++++++++++++------------
 sw/source/core/view/pagepreviewlayout.cxx |    3 
 sw/source/core/view/viewimp.cxx           |    6 
 sw/source/core/view/viewsh.cxx            |   32 +---
 11 files changed, 213 insertions(+), 205 deletions(-)

New commits:
commit 7b8c5bf878c29ece5f3bcfe877ad0f1141bb70f3
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Fri Apr 29 18:37:41 2011 +0200

    Use GetBoundRect() instead of Frm() in layout.

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index a00165a..e462b72 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1399,9 +1399,15 @@ sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
         if ( pLay->GetPrev() && !pLay->GetPrev()->IsValid() )
             pLay->GetPrev()->SetCompletePaint();
 
-        SwRect aOldRect( pLay->Frm() );
+        SwRect aOldFrame( pLay->Frm() );
+        SwRect aOldRect( aOldFrame );
+        if( pLay->IsPageFrm() )
+        {
+            aOldRect = static_cast<SwPageFrm*>(pLay)->GetBoundRect();
+        }
+
         pLay->Calc();
-        if ( aOldRect != pLay->Frm() )
+        if ( aOldFrame != pLay->Frm() )
             bChanged = sal_True;
 
         sal_Bool bNoPaint = sal_False;
@@ -1424,15 +1430,7 @@ sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
             if ( pLay->IsPageFrm() )
             {
                 SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(pLay);
-                const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
-
-                if(pSh)
-                {
-                    SwPageFrm::GetBorderAndShadowBoundRect(aPaint, pSh, aPaint,
-                        pPageFrm->IsLeftShadowNeeded(), pPageFrm->IsRightShadowNeeded(),
-                        pPageFrm->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
-                }
-
+                aPaint = pPageFrm->GetBoundRect();
             }
 
             sal_Bool bPageInBrowseMode = pLay->IsPageFrm();
@@ -1499,12 +1497,16 @@ sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
                 {
                     // top
                     SwRect aSpaceToPrevPage( aPageRect );
+                    aSpaceToPrevPage.Top( aSpaceToPrevPage.Top() - nHalfDocBorder );
                     aSpaceToPrevPage.Bottom( pLay->Frm().Top() );
                     if(aSpaceToPrevPage.Height() > 0 && aSpaceToPrevPage.Width() > 0)
                         pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
 
+                    pSh->GetOut()->DrawRect( aSpaceToPrevPage.SVRect() );
+
                     // left
                     aSpaceToPrevPage = aPageRect;
+                    aSpaceToPrevPage.Left( aSpaceToPrevPage.Left() - nHalfDocBorder );
                     aSpaceToPrevPage.Right( pLay->Frm().Left() );
                     if(aSpaceToPrevPage.Height() > 0 && aSpaceToPrevPage.Width() > 0)
                         pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
@@ -1578,12 +1580,14 @@ sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
     // OD 11.11.2002 #104414# - add complete frame area as paint area, if frame
     // area has been already added and after formating its lowers the frame area
     // is enlarged.
+    SwRect aBoundRect(pLay->IsPageFrm() ? static_cast<SwPageFrm*>(pLay)->GetBoundRect() : pLay->Frm() );
+
     if ( bAlreadyPainted &&
-         ( pLay->Frm().Width() > aFrmAtCompletePaint.Width() ||
-           pLay->Frm().Height() > aFrmAtCompletePaint.Height() )
+         ( aBoundRect.Width() > aFrmAtCompletePaint.Width() ||
+           aBoundRect.Height() > aFrmAtCompletePaint.Height() )
        )
     {
-        pImp->GetShell()->AddPaintRect( pLay->Frm() );
+        pImp->GetShell()->AddPaintRect( aBoundRect );
     }
     return bChanged || bTabChanged;
 }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index bbb846e..9903f97 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -995,11 +995,11 @@ void ViewShell::VisPortChgd( const SwRect &rRect)
 
             while ( pPage && pPage->Frm().Top() <= nBottom )
             {
-                SwRect aPageRect( pPage->Frm() );
+                SwRect aPageRect( pPage->GetBoundRect() );
                 if ( bBookMode )
                 {
                     const SwPageFrm& rFormatPage = static_cast<const SwPageFrm*>(pPage)->GetFormatPage();
-                    aPageRect.SSize() = rFormatPage.Frm().SSize();
+                    aPageRect.SSize() = rFormatPage.GetBoundRect().SSize();
                 }
 
                 if ( aPageRect.IsOver( aBoth ) )
@@ -1010,11 +1010,8 @@ void ViewShell::VisPortChgd( const SwRect &rRect)
 
                     if( aSidebarPos != sw::sidebarwindows::SIDEBAR_NONE )
                     {
-                        SwRect aShadowRect;
-                        SwPageFrm::GetBorderAndShadowBoundRect(aPageRect, this,
-                            aShadowRect, pPage->IsLeftShadowNeeded(), pPage->IsRightShadowNeeded(), aSidebarPos == sw::sidebarwindows::SIDEBAR_RIGHT);
-                        nPageLeft = aShadowRect.Left();
-                        nPageRight = aShadowRect.Right();
+                        nPageLeft = aPageRect.Left();
+                        nPageRight = aPageRect.Right();
                     }
 
                     if( nPageLeft < nMinLeft )
commit 2666ac6bf1a7850ef0c10cdd202557b1b2d25b19
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Wed Apr 27 09:15:18 2011 +0200

    Use GetBoundRect in SetFirstVisPage
    
    SetFirstVis page was using SwPage::Frm() to compute first visible page.
    This was causing glitches when the scroll area boundary was in the
    middle of a shadow border.

diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index 57f5ab6..87eeb4c 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -190,17 +190,17 @@ void SwViewImp::SetFirstVisPage()
         const bool bBookMode = pSwViewOption->IsViewLayoutBookMode();
 
         SwPageFrm *pPage = (SwPageFrm*)pSh->GetLayout()->Lower();
-        SwRect aPageRect = pPage->Frm();
+        SwRect aPageRect = pPage->GetBoundRect();
         while ( pPage && !aPageRect.IsOver( pSh->VisArea() ) )
         {
             pPage = (SwPageFrm*)pPage->GetNext();
             if ( pPage )
             {
-                aPageRect = pPage->Frm();
+                aPageRect = pPage->GetBoundRect();
                 if ( bBookMode && pPage->IsEmptyPage() )
                 {
                     const SwPageFrm& rFormatPage = pPage->GetFormatPage();
-                    aPageRect.SSize() = rFormatPage.Frm().SSize();
+                    aPageRect.SSize() = rFormatPage.GetBoundRect().SSize();
                 }
             }
         }
commit 5c971e9ace1f540d3ed5e729ab0c0fe0f55cdf3a
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Wed Apr 27 09:12:52 2011 +0200

    Added instance method SwPageFrm::GetBoundRect
    
    Using the static method SwPageFrm::GetBordersAndShadowBoundRect involves
    a lot of duplicate code on the callers side. The instance method
    provides a shortcut and shoudl be used instead of Frm() in every layout
    method.

diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 15dfed5..e7c973c 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -172,6 +172,8 @@ public:
     inline const SwCntntFrm  *FindFirstBodyCntnt() const;
     inline const SwCntntFrm  *FindLastBodyCntnt() const;
 
+    SwRect GetBoundRect() const;
+
     //Spezialisiertes GetCntntPos() fuer Felder in Rahmen.
     void GetCntntPosition( const Point &rPt, SwPosition &rPos ) const;
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index e9637be..904c2c9 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -5538,6 +5538,21 @@ sal_Bool SwPageFrm::IsLeftShadowNeeded() const
     _orBorderAndShadowBoundRect = _pViewShell->GetOut()->PixelToLogic( aPagePxRect.SVRect() );
 }
 
+SwRect SwPageFrm::GetBoundRect() const
+{
+    const ViewShell *pSh = getRootFrm()->GetCurrShell();
+    SwRect aPageRect( Frm() );
+    SwRect aResult;
+
+    if(!pSh) {
+        return SwRect( Point(0, 0), Size(0, 0) );
+    }
+
+    SwPageFrm::GetBorderAndShadowBoundRect( aPageRect, pSh, aResult,
+        IsLeftShadowNeeded(), IsRightShadowNeeded(), SidebarPosition() ==  sw::sidebarwindows::SIDEBAR_RIGHT );
+    return aResult;
+}
+
 /*static*/ void SwPageFrm::AddSidebarBorders(SwRect &aRect, ViewShell* _pViewShell, bool bRightSidebar, bool bPx)
 {
     const SwPostItMgr *pMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0;
commit 01fc4319e9668d0d5feeda2de71fdb5444c21c67
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Tue May 3 11:02:12 2011 +0200

    Use page bounding box for layout computations.
    
    A lot of layout methods were using duplicate code to invalidate areas.
    This led to graphical glitches with 4 borders large shadow.

diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index b2577b4..98cbb54 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -72,7 +72,7 @@ void MA_FASTCALL DrawGraphic( const SvxBrushItem *, OutputDevice *,
 
 // - method to align rectangle
 // Created declaration here to avoid <extern> declarations
-void MA_FASTCALL SwAlignRect( SwRect &rRect, ViewShell *pSh );
+void MA_FASTCALL SwAlignRect( SwRect &rRect, const ViewShell *pSh );
 
 // - method to align graphic rectangle
 // Created declaration here to avoid <extern> declarations
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index c940f26..15dfed5 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -114,7 +114,7 @@ class SwPageFrm: public SwFtnBossFrm
     */
 
     static void GetHorizontalShadowRect( const SwRect& _rPageRect,
-                                     ViewShell*    _pViewShell,
+                                     const ViewShell*    _pViewShell,
                                      SwRect&       _orBottomShadowRect,
                                      bool bPaintLeftShadow,
                                      bool bPaintRightShadow,
@@ -246,6 +246,8 @@ public:
     inline void ValidateWordCount() const;
     inline sal_Bool IsInvalid() const;
     inline sal_Bool IsInvalidFly() const;
+    sal_Bool IsRightShadowNeeded() const;
+    sal_Bool IsLeftShadowNeeded() const;
     sal_Bool IsInvalidFlyLayout() const { return bInvalidFlyLayout; }
     sal_Bool IsInvalidFlyCntnt() const { return bInvalidFlyCntnt; }
     sal_Bool IsInvalidFlyInCnt() const { return bInvalidFlyInCnt; }
@@ -307,7 +309,7 @@ public:
         shadow with & position).
     */
     static void PaintBorderAndShadow( const SwRect& _rPageRect,
-                                      ViewShell*    _pViewShell,
+                                      const ViewShell*    _pViewShell,
                                       bool bPaintLeftShadow,
                                       bool bPaintRightShadow,
                                       bool bRightSidebar );
@@ -330,9 +332,12 @@ public:
         rectangle for the given page rectangle
     */
     static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
-                                             ViewShell*    _pViewShell,
+                                             const ViewShell*    _pViewShell,
                                              SwRect& _orBorderAndShadowBoundRect,
-                                             const bool bRightSidebar );
+                                             const bool bLeftShadow,
+                                             const bool bRightShadow,
+                                             const bool bRightSidebar
+                                            );
 
     static void PaintNotesSidebar(const SwRect& _rPageRect, ViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
     static void PaintNotesSidebarArrows(const Point &aMiddleFirst, const Point &aMiddleSecond, ViewShell* _pViewShell, const Color aColorUp, const Color aColorDown);
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 2275076..a00165a 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1424,30 +1424,15 @@ sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
             if ( pLay->IsPageFrm() )
             {
                 SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(pLay);
-                const int nShadowWidth =
-                        pImp->GetShell()->GetOut()->PixelToLogic( Size( pPageFrm->ShadowPxWidth(), 0 ) ).Width();
+                const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
 
-                //mod #i6193# added sidebar width
-                const SwPostItMgr* pPostItMgr = pImp->GetShell()->GetPostItMgr();
-                const int nSidebarWidth = pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ? pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() : 0;
-                switch ( pPageFrm->SidebarPosition() )
+                if(pSh)
                 {
-                    case sw::sidebarwindows::SIDEBAR_LEFT:
-                    {
-                        aPaint.Left( aPaint.Left()  - nSidebarWidth);
-                        aPaint.Right( aPaint.Right() + nShadowWidth);
-                    }
-                    break;
-                    case sw::sidebarwindows::SIDEBAR_RIGHT:
-                    {
-                        aPaint.Right( aPaint.Right() + nShadowWidth + nSidebarWidth);
-                    }
-                    break;
-                    case sw::sidebarwindows::SIDEBAR_NONE:
-                        // nothing to do
-                    break;
+                    SwPageFrm::GetBorderAndShadowBoundRect(aPaint, pSh, aPaint,
+                        pPageFrm->IsLeftShadowNeeded(), pPageFrm->IsRightShadowNeeded(),
+                        pPageFrm->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
                 }
-                aPaint.Bottom( aPaint.Bottom() + nShadowWidth );
+
             }
 
             sal_Bool bPageInBrowseMode = pLay->IsPageFrm();
@@ -1499,38 +1484,46 @@ sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
                 const bool bLeftToRightViewLayout = pRoot->IsLeftToRightViewLayout();
                 const bool bPrev = bLeftToRightViewLayout ? pLay->GetPrev() : pLay->GetNext();
                 const bool bNext = bLeftToRightViewLayout ? pLay->GetNext() : pLay->GetPrev();
+                SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(pLay);
+                const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
+                SwRect aPageRect( pLay->Frm() );
+
+                if(pSh)
+                {
+                    SwPageFrm::GetBorderAndShadowBoundRect(aPageRect, pSh,
+                        aPageRect, pPageFrm->IsLeftShadowNeeded(), pPageFrm->IsRightShadowNeeded(),
+                        pPageFrm->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
+                }
 
                 if ( bPrev )
                 {
                     // top
-                    SwRect aSpaceToPrevPage( pLay->Frm() );
-                    const SwTwips nTop = aSpaceToPrevPage.Top() - nHalfDocBorder;
-                    if ( nTop >= 0 )
-                        aSpaceToPrevPage.Top( nTop );
+                    SwRect aSpaceToPrevPage( aPageRect );
                     aSpaceToPrevPage.Bottom( pLay->Frm().Top() );
-                    pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
+                    if(aSpaceToPrevPage.Height() > 0 && aSpaceToPrevPage.Width() > 0)
+                        pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
 
                     // left
-                    aSpaceToPrevPage = pLay->Frm();
-                    const SwTwips nLeft = aSpaceToPrevPage.Left() - nHalfDocBorder;
-                    if ( nLeft >= 0 )
-                        aSpaceToPrevPage.Left( nLeft );
+                    aSpaceToPrevPage = aPageRect;
                     aSpaceToPrevPage.Right( pLay->Frm().Left() );
-                    pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
+                    if(aSpaceToPrevPage.Height() > 0 && aSpaceToPrevPage.Width() > 0)
+                        pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
                 }
                 if ( bNext )
                 {
                     // bottom
-                    SwRect aSpaceToNextPage( pLay->Frm() );
+                    SwRect aSpaceToNextPage( aPageRect );
                     aSpaceToNextPage.Bottom( aSpaceToNextPage.Bottom() + nHalfDocBorder );
                     aSpaceToNextPage.Top( pLay->Frm().Bottom() );
-                    pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
+                    if(aSpaceToNextPage.Height() > 0 && aSpaceToNextPage.Width() > 0)
+                        pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
 
                     // right
-                    aSpaceToNextPage = pLay->Frm();
+                    aSpaceToNextPage = aPageRect;
                     aSpaceToNextPage.Right( aSpaceToNextPage.Right() + nHalfDocBorder );
                     aSpaceToNextPage.Left( pLay->Frm().Right() );
-                    pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
+                    if(aSpaceToNextPage.Height() > 0 && aSpaceToNextPage.Width() > 0)
+                        pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
                 }
             }
         }
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index d0e13eb..f810f2f 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -310,7 +310,7 @@ SwPageFrm::~SwPageFrm()
                 // including border and shadow area.
                 const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
                 SwRect aRetoucheRect;
-                SwPageFrm::GetBorderAndShadowBoundRect( Frm(), pSh, aRetoucheRect, bRightSidebar );
+                SwPageFrm::GetBorderAndShadowBoundRect( Frm(), pSh, aRetoucheRect, IsLeftShadowNeeded(), IsRightShadowNeeded(), bRightSidebar );
                 pSh->AddPaintRect( aRetoucheRect );
             }
         }
@@ -674,7 +674,8 @@ void SwPageFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
                 // page frame for determine 'old' rectangle - it's used for invalidating.
                 const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
                 SwRect aOldRectWithBorderAndShadow;
-                SwPageFrm::GetBorderAndShadowBoundRect( aOldPageFrmRect, pSh, aOldRectWithBorderAndShadow, bRightSidebar );
+                SwPageFrm::GetBorderAndShadowBoundRect( aOldPageFrmRect, pSh, aOldRectWithBorderAndShadow,
+                    IsLeftShadowNeeded(), IsRightShadowNeeded(), bRightSidebar );
                 pSh->InvalidateWindows( aOldRectWithBorderAndShadow );
             }
             rInvFlags |= 0x03;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 7bc434b..e9637be 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1038,7 +1038,7 @@ void SwSubsRects::PaintSubsidiary( OutputDevice *pOut,
 // OD 29.04.2003 #107169# - correction: adjust rectangle on pixel level in order
 //          to assure, that the border 'leaves its original pixel', if it has to.
 //          No prior adjustments for odd relation between pixel and twip.
-void MA_FASTCALL SwAlignRect( SwRect &rRect, ViewShell *pSh )
+void MA_FASTCALL SwAlignRect( SwRect &rRect, const ViewShell *pSh )
 {
     if( !rRect.HasArea() )
         return;
@@ -2839,8 +2839,6 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
     if ( bBookMode && pPage->GetPrev() && static_cast<const SwPageFrm*>(pPage->GetPrev())->IsEmptyPage() )
         pPage = static_cast<const SwPageFrm*>(pPage->GetPrev());
 
-    const bool bLTR = IsLeftToRightViewLayout();
-
     // #i68597#
     const bool bGridPainting(pSh->GetWin() && pSh->Imp()->HasDrawView() && pSh->Imp()->GetDrawView()->IsGridVisible());
 
@@ -2849,22 +2847,15 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
     while ( pPage )
     // <--
     {
-        // Paint right shadow in single page mode, or if we're on last page of
-        // the doc, or if ???Lower()??? or if we're on a page with no right
-        // sibling (OnRightPage should be renamed as OnEvenPage since it does
-        // not take reading direction into account)
-        const bool bPaintRightShadow =  !bBookMode || (!pPage->GetNext()) || (pPage == Lower()) || (!bLTR && !pPage->OnRightPage()) || (bLTR && pPage->OnRightPage());
-        // Have a full bottom shadow on side by side pages.
-        // TODO Do not draw full shadow if our sibling hasn't the
-        // same orientation
-        const bool bPaintLeftShadow = !(bBookMode && pPage->GetPrev() &&
-            ((!bLTR && !pPage->OnRightPage()) || (bLTR && pPage->OnRightPage())));
+        const bool bPaintRightShadow =  pPage->IsRightShadowNeeded();
+        const bool bPaintLeftShadow = pPage->IsLeftShadowNeeded();
         const bool bRightSidebar = pPage->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT;
 
         if ( !pPage->IsEmptyPage() )
         {
             SwRect aPaintRect;
-            SwPageFrm::GetBorderAndShadowBoundRect( pPage->Frm(), pSh, aPaintRect, bRightSidebar );
+            SwPageFrm::GetBorderAndShadowBoundRect( pPage->Frm(), pSh, aPaintRect,
+                bPaintLeftShadow, bPaintRightShadow, bRightSidebar );
 
             if ( aRect.IsOver( aPaintRect ) )
             // <--
@@ -3017,7 +3008,8 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
             const SwPageFrm& rFormatPage = pPage->GetFormatPage();
             aEmptyPageRect.SSize() = rFormatPage.Frm().SSize();
 
-            SwPageFrm::GetBorderAndShadowBoundRect( aEmptyPageRect, pSh, aPaintRect, bRightSidebar );
+            SwPageFrm::GetBorderAndShadowBoundRect( aEmptyPageRect, pSh, aPaintRect,
+                bPaintLeftShadow, bPaintRightShadow, bRightSidebar );
             aPaintRect._Intersection( aRect );
 
             if ( aRect.IsOver( aEmptyPageRect ) )
@@ -5216,6 +5208,31 @@ void SwPageFrm::PaintMarginArea( const SwRect& _rOutputRect,
 
 const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
 
+sal_Bool SwPageFrm::IsRightShadowNeeded() const
+{
+    const ViewShell *pSh = getRootFrm()->GetCurrShell();
+    const bool bIsLTR = getRootFrm()->IsLeftToRightViewLayout();
+
+    // We paint the right shadow if we're not in book mode
+    // or if we've no sibling or are the last page of the "row"
+    return !pSh || (!pSh->GetViewOptions()->IsViewLayoutBookMode()) || !GetNext()
+        || (this == Lower())  || (bIsLTR && OnRightPage())
+        || (!bIsLTR && !OnRightPage());
+
+}
+
+sal_Bool SwPageFrm::IsLeftShadowNeeded() const
+{
+    const ViewShell *pSh = getRootFrm()->GetCurrShell();
+    const bool bIsLTR = getRootFrm()->IsLeftToRightViewLayout();
+
+    // We paint the left shadow if we're not in book mode
+    // or if we've no sibling or are the last page of the "row"
+    return !pSh || (!pSh->GetViewOptions()->IsViewLayoutBookMode()) || !GetPrev()
+        || (bIsLTR && !OnRightPage())
+        || (!bIsLTR && OnRightPage());
+}
+
 /** determine rectangle for bottom page shadow
 
     OD 12.02.2003 for #i9719# and #105645#
@@ -5223,7 +5240,7 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
     @author OD
 */
 /*static*/ void SwPageFrm::GetHorizontalShadowRect( const SwRect& _rPageRect,
-                                                ViewShell*    _pViewShell,
+                                                const ViewShell*    _pViewShell,
                                                 SwRect&       _orHorizontalShadowRect,
                                                 bool bPaintLeftShadow,
                                                 bool bPaintRightShadow,
@@ -5261,7 +5278,7 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
     @author OD
 */
 /*static*/ void SwPageFrm::PaintBorderAndShadow( const SwRect& _rPageRect,
-                                                 ViewShell*    _pViewShell,
+                                                 const ViewShell*    _pViewShell,
                                                  bool bPaintLeftShadow,
                                                  bool bPaintRightShadow,
                                                  bool bRightSidebar )
@@ -5339,7 +5356,7 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
 
     SwPageFrm::GetHorizontalShadowRect( _rPageRect, _pViewShell, aPaintRect, bPaintLeftShadow, bPaintRightShadow, bRightSidebar );
 
-    // paint right shadow
+    // Right shadow & corners
     if ( bPaintRightShadow )
     {
         pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Right() + 1, aPagePxRect.Bottom() + 1 - (aPageBottomRightShadow.GetSizePixel().Height() - mnShadowPxWidth) ) ),
@@ -5351,7 +5368,7 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
         pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Right() + mnShadowPxWidth, aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageRightShadow );
     }
 
-    // paint top & bottom shadow
+    // Left shadows and corners
     if(bPaintLeftShadow)
     {
         const long lLeft = aPaintRect.Left() - aPageBottomLeftShadow.GetSizePixel().Width();
@@ -5362,6 +5379,7 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
         aPageLeftShadow.Scale( 1, aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1) );
         pOut->DrawBitmapEx( pOut->PixelToLogic( Point( lLeft, aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageLeftShadow );
     }
+
     BitmapEx aPageBottomShadow = aPageBottomShadowBase;
     aPageBottomShadow.Scale( aPaintRect.Width(), 1 );
     pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left(), aPagePxRect.Bottom() + 1 ) ), aPageBottomShadow);
@@ -5494,24 +5512,28 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
     author OD
 */
 /*static*/ void SwPageFrm::GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
-                                                        ViewShell*    _pViewShell,
+                                                        const ViewShell*    _pViewShell,
                                                         SwRect& _orBorderAndShadowBoundRect,
-                                                        bool bRightSidebar )
+                                                        bool bLeftShadow,
+                                                        bool bRightShadow,
+                                                        bool bRightSidebar
+                                                      )
 {
     SwRect aAlignedPageRect( _rPageRect );
     ::SwAlignRect( aAlignedPageRect, _pViewShell );
     SwRect aPagePxRect =
             _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
     aPagePxRect.Bottom( aPagePxRect.Bottom() + mnShadowPxWidth + 1 );
-    aPagePxRect.Top( aPagePxRect.Top() - mnShadowPxWidth );
+    aPagePxRect.Top( aPagePxRect.Top() - mnShadowPxWidth - 1 );
 
     SwRect aTmpRect;
 
-    // Always ask for full shadow
+    // Always ask for full shadow since we want a bounding rect
+    // including at least the page frame
     SwPageFrm::GetHorizontalShadowRect( _rPageRect, _pViewShell, aTmpRect, false, false, bRightSidebar );
 
-    aPagePxRect.Left( aTmpRect.Left() - mnShadowPxWidth);
-    aPagePxRect.Right( aTmpRect.Right() + mnShadowPxWidth + 1);
+    if(bLeftShadow) aPagePxRect.Left( aTmpRect.Left() - mnShadowPxWidth - 1);
+    if(bRightShadow) aPagePxRect.Right( aTmpRect.Right() + mnShadowPxWidth + 1);
 
     _orBorderAndShadowBoundRect = _pViewShell->GetOut()->PixelToLogic( aPagePxRect.SVRect() );
 }
diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx
index 64828eb..ade1164 100644
--- a/sw/source/core/view/pagepreviewlayout.cxx
+++ b/sw/source/core/view/pagepreviewlayout.cxx
@@ -1073,7 +1073,8 @@ bool SwPagePreviewLayout::Paint( const Rectangle  _aOutRect ) const
                 // #i80691# paint page border and shadow
                 {
                     SwRect aPageBorderRect;
-                    SwPageFrm::GetBorderAndShadowBoundRect( SwRect( aPageRect ), &mrParentViewShell, aPageBorderRect, true );
+                    SwPageFrm::GetBorderAndShadowBoundRect( SwRect( aPageRect ), &mrParentViewShell, aPageBorderRect,
+                        (*aPageIter)->pPage->IsLeftShadowNeeded(), (*aPageIter)->pPage->IsRightShadowNeeded(), true );
                     const Region aDLRegion(aPageBorderRect.SVRect());
                     mrParentViewShell.DLPrePaint2(aDLRegion);
                     SwPageFrm::PaintBorderAndShadow( aPageRect, &mrParentViewShell, true, false, true );
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 9ee2eb6..bbb846e 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1012,7 +1012,7 @@ void ViewShell::VisPortChgd( const SwRect &rRect)
                     {
                         SwRect aShadowRect;
                         SwPageFrm::GetBorderAndShadowBoundRect(aPageRect, this,
-                            aShadowRect, aSidebarPos == sw::sidebarwindows::SIDEBAR_RIGHT);
+                            aShadowRect, pPage->IsLeftShadowNeeded(), pPage->IsRightShadowNeeded(), aSidebarPos == sw::sidebarwindows::SIDEBAR_RIGHT);
                         nPageLeft = aShadowRect.Left();
                         nPageRight = aShadowRect.Right();
                     }
commit 12a958aa15dbc408932ba6d14da5a8021aeea754
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Tue Apr 26 18:04:12 2011 +0200

    Typo in param name

diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 01dab51..c940f26 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -116,7 +116,7 @@ class SwPageFrm: public SwFtnBossFrm
     static void GetHorizontalShadowRect( const SwRect& _rPageRect,
                                      ViewShell*    _pViewShell,
                                      SwRect&       _orBottomShadowRect,
-                                     bool bPaintLeftShado,
+                                     bool bPaintLeftShadow,
                                      bool bPaintRightShadow,
                                      bool bRightSidebar );
 
commit 3a4a2bfb1de01ed9788981fffa824ba68f558e6e
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Sat Apr 23 14:19:18 2011 +0200

    Bad shadow alignment when sidebar present.

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 3114139..7bc434b 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -5348,20 +5348,19 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
             aPageTopRightShadow );
         BitmapEx aPageRightShadow = aPageRightShadowBase;
         aPageRightShadow.Scale( 1, aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1) );
-        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPagePxRect.Right() + 1, aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageRightShadow );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Right() + mnShadowPxWidth, aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageRightShadow );
     }
 
     // paint top & bottom shadow
     if(bPaintLeftShadow)
     {
-        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left() - aPageBottomLeftShadow.GetSizePixel().Width(),
+        const long lLeft = aPaintRect.Left() - aPageBottomLeftShadow.GetSizePixel().Width();
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( lLeft,
             aPagePxRect.Bottom() + 1 + mnShadowPxWidth - aPageBottomLeftShadow.GetSizePixel().Height() ) ), aPageBottomLeftShadow );
-        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left() - aPageBottomLeftShadow.GetSizePixel().Width(),
-            aPagePxRect.Top() - mnShadowPxWidth ) ), aPageTopLeftShadow );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( lLeft, aPagePxRect.Top() - mnShadowPxWidth ) ), aPageTopLeftShadow );
         BitmapEx aPageLeftShadow = aPageLeftShadowBase;
         aPageLeftShadow.Scale( 1, aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1) );
-        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPagePxRect.Left() - aPageLeftShadow.GetSizePixel().Width(),
-             aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageLeftShadow );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( lLeft, aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageLeftShadow );
     }
     BitmapEx aPageBottomShadow = aPageBottomShadowBase;
     aPageBottomShadow.Scale( aPaintRect.Width(), 1 );
commit db16d55c2d52a59494d2bbb315bdcb55cabe4122
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Tue May 3 10:47:40 2011 +0200

    Added Impress-like 4 borders shadow.
    
    Writer and impress now have the same kind of 4 borders shadow. Impress
    do not currently honnor shadows settings (presence and color) so code
    still slightly differs but both should be easy to merge.

diff --git a/sw/source/core/inc/pagefrm.hrc b/sw/source/core/inc/pagefrm.hrc
index 302ba9a..b8f89e0 100644
--- a/sw/source/core/inc/pagefrm.hrc
+++ b/sw/source/core/inc/pagefrm.hrc
@@ -31,13 +31,11 @@
 #include "rcid.hrc"
 
 //  Bitmaps for page shadow
-#define BMP_PAGE_RIGHT_SHADOW_MASK          RC_PAGEFRM_BEGIN + 0
-#define BMP_PAGE_BOTTOM_RIGHT_SHADOW_MASK   RC_PAGEFRM_BEGIN + 1
-#define BMP_PAGE_BOTTOM_SHADOW_MASK         RC_PAGEFRM_BEGIN + 2
+#define BMP_PAGE_SHADOW_MASK                RC_PAGEFRM_BEGIN + 0
 
 
 // If you add resources, don't forget to update this
-#define PAGEFRM_ACT_END           BMP_PAGE_BOTTOMLEFT_SHADOW
+#define PAGEFRM_ACT_END           BMP_PAGE_SHADOW_MASK
 
 // Sanity check
 #if PAGEFRM_ACT_END > RC_PAGEFRM_END
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index c94574c..01dab51 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -95,29 +95,7 @@ class SwPageFrm: public SwFtnBossFrm
     // Anpassen der max. Fussnotenhoehen in den einzelnen Spalten
     void SetColMaxFtnHeight();
 
-    /** determine rectangle for right page shadow
-
-        #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 _orRightShadowRect
-        output parameter - instance reference of the right shadow rectangle for
-        the given page rectangle
-    */
-    static void GetRightShadowRect( const SwRect& _rPageRect,
-                                    ViewShell*    _pViewShell,
-                                    SwRect&       _orRightShadowRect,
-                                    bool bRightSidebar );
-
-    /** determine rectangle for bottom page shadow
+    /** determine rectangle for horizontal page shadow
 
         #i9719#
 
@@ -135,10 +113,11 @@ class SwPageFrm: public SwFtnBossFrm
         the given page rectangle
     */
 
-    static void GetBottomShadowRect( const SwRect& _rPageRect,
+    static void GetHorizontalShadowRect( const SwRect& _rPageRect,
                                      ViewShell*    _pViewShell,
                                      SwRect&       _orBottomShadowRect,
-                                     bool bFullBottomShadow,
+                                     bool bPaintLeftShado,
+                                     bool bPaintRightShadow,
                                      bool bRightSidebar );
 
     /** adds the sidebar used for notes to right and left border
@@ -329,8 +308,8 @@ public:
     */
     static void PaintBorderAndShadow( const SwRect& _rPageRect,
                                       ViewShell*    _pViewShell,
+                                      bool bPaintLeftShadow,
                                       bool bPaintRightShadow,
-                                      bool bFullBottomShadow,
                                       bool bRightSidebar );
 
     /** get bound rectangle of border and shadow for repaints
diff --git a/sw/source/core/layout/pagefrm.src b/sw/source/core/layout/pagefrm.src
index 83b80e4..1c5cafc 100644
--- a/sw/source/core/layout/pagefrm.src
+++ b/sw/source/core/layout/pagefrm.src
@@ -1,17 +1,7 @@
 #include "pagefrm.hrc"
 
-Bitmap BMP_PAGE_RIGHT_SHADOW_MASK
+Bitmap BMP_PAGE_SHADOW_MASK
 {
-    File = "page-right-shadow-mask.png";
-};
-
-Bitmap BMP_PAGE_BOTTOM_RIGHT_SHADOW_MASK
-{
-    File = "page-bottomright-shadow-mask.png";
-};
-
-Bitmap BMP_PAGE_BOTTOM_SHADOW_MASK
-{
-    File = "page-bottom-shadow-mask.png";
+    File = "page-shadow-mask.png";
 };
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index f1b175b..3114139 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -102,6 +102,7 @@
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
+#include <drawinglayer/primitive2d/discreteshadowprimitive2d.hxx>
 #include <svx/sdr/contact/objectcontacttools.hxx>
 #include <svx/unoapi.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
@@ -2856,8 +2857,8 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
         // Have a full bottom shadow on side by side pages.
         // TODO Do not draw full shadow if our sibling hasn't the
         // same orientation
-        const bool bFullBottomShadow = bBookMode && pPage->GetPrev() &&
-            ((!bLTR && !pPage->OnRightPage()) || (bLTR && pPage->OnRightPage()));
+        const bool bPaintLeftShadow = !(bBookMode && pPage->GetPrev() &&
+            ((!bLTR && !pPage->OnRightPage()) || (bLTR && pPage->OnRightPage())));
         const bool bRightSidebar = pPage->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT;
 
         if ( !pPage->IsEmptyPage() )
@@ -2963,7 +2964,7 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
                 {
                     // OD 12.02.2003 #i9719#, #105645# - use new method
                     // <SwPageFrm::PaintBorderAndShadow(..)>.
-                    SwPageFrm::PaintBorderAndShadow( pPage->Frm(), pSh, bPaintRightShadow, bFullBottomShadow, bRightSidebar );
+                    SwPageFrm::PaintBorderAndShadow( pPage->Frm(), pSh, bPaintLeftShadow, bPaintRightShadow, bRightSidebar );
                     SwPageFrm::PaintNotesSidebar( pPage->Frm(), pSh, pPage->GetPhyPageNum(), bRightSidebar);
                 }
 
@@ -3055,7 +3056,7 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
                 // paint shadow and border for empty page
                 // OD 19.02.2003 #107369# - use new method to paint page border and
                 // shadow
-                SwPageFrm::PaintBorderAndShadow( aEmptyPageRect, pSh, bPaintRightShadow, bFullBottomShadow, bRightSidebar );
+                SwPageFrm::PaintBorderAndShadow( aEmptyPageRect, pSh, bPaintLeftShadow, bPaintRightShadow, bRightSidebar );
                 SwPageFrm::PaintNotesSidebar( aEmptyPageRect, pSh, pPage->GetPhyPageNum(), bRightSidebar);
 
                 {
@@ -5213,36 +5214,7 @@ void SwPageFrm::PaintMarginArea( const SwRect& _rOutputRect,
     }
 }
 
-const sal_Int8 SwPageFrm::mnShadowPxWidth = 10;
-
-/** determine rectangle for right page shadow
-
-    OD 12.02.2003 for #i9719# and #105645#
-
-    @author OD
-*/
-/*static*/ void SwPageFrm::GetRightShadowRect( const SwRect& _rPageRect,
-                                               ViewShell*    _pViewShell,
-                                               SwRect&       _orRightShadowRect,
-                                               bool bRightSidebar )
-{
-    SwRect aAlignedPageRect( _rPageRect );
-    ::SwAlignRect( aAlignedPageRect, _pViewShell );
-    SwRect aPagePxRect =
-            _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
-    const SwPostItMgr *pMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0;
-
-    _orRightShadowRect.Chg(
-                    Point( aPagePxRect.Right() + 1, aPagePxRect.Top() + mnShadowPxWidth + 1 ),
-                    Size( mnShadowPxWidth, aPagePxRect.Height() - mnShadowPxWidth - 1 ) );
-
-    if (bRightSidebar && pMgr && pMgr->ShowNotes() && pMgr->HasNotes())
-    {
-        _orRightShadowRect.Pos(_orRightShadowRect.Left() + pMgr->GetSidebarWidth(true)
-            + pMgr->GetSidebarBorderWidth(true), _orRightShadowRect.Top());
-    }
-
-}
+const sal_Int8 SwPageFrm::mnShadowPxWidth = 9;
 
 /** determine rectangle for bottom page shadow
 
@@ -5250,10 +5222,11 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 10;
 
     @author OD
 */
-/*static*/ void SwPageFrm::GetBottomShadowRect( const SwRect& _rPageRect,
+/*static*/ void SwPageFrm::GetHorizontalShadowRect( const SwRect& _rPageRect,
                                                 ViewShell*    _pViewShell,
-                                                SwRect&       _orBottomShadowRect,
-                                                bool bFullBottomShadow,
+                                                SwRect&       _orHorizontalShadowRect,
+                                                bool bPaintLeftShadow,
+                                                bool bPaintRightShadow,
                                                 bool bRightSidebar )
 {
     const SwPostItMgr *pMgr = _pViewShell ? _pViewShell->GetPostItMgr() : 0;
@@ -5262,21 +5235,21 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 10;
     SwRect aPagePxRect =
             _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
 
-    // Shadow is shifted when not full
-    long lShadowAdjustment = (bFullBottomShadow ? 0 : 1 + mnShadowPxWidth);
+    long lShadowAdjustment = mnShadowPxWidth - 1; // TODO extract this
 
-    _orBottomShadowRect.Chg(
-                    Point( aPagePxRect.Left() + lShadowAdjustment, aPagePxRect.Bottom() + 1 ),
-                    Size( aPagePxRect.Width() - lShadowAdjustment, mnShadowPxWidth ) );
+    _orHorizontalShadowRect.Chg(
+                    Point( aPagePxRect.Left() + (bPaintLeftShadow ? lShadowAdjustment : 0), 0 ),
+                    Size( aPagePxRect.Width() - ( (bPaintLeftShadow ? lShadowAdjustment : 0) + (bPaintRightShadow ? lShadowAdjustment : 0) ),
+                        mnShadowPxWidth ) );
 
     if(pMgr && pMgr->ShowNotes() && pMgr->HasNotes())
     {
         // Notes are displayed, we've to extend borders
         SwTwips aSidebarTotalWidth = pMgr->GetSidebarWidth(true) + pMgr->GetSidebarBorderWidth(true);
         if(bRightSidebar)
-            _orBottomShadowRect.Right( _orBottomShadowRect.Right() + aSidebarTotalWidth );
+            _orHorizontalShadowRect.Right( _orHorizontalShadowRect.Right() + aSidebarTotalWidth );
         else
-            _orBottomShadowRect.Left( _orBottomShadowRect.Left() - aSidebarTotalWidth );
+            _orHorizontalShadowRect.Left( _orHorizontalShadowRect.Left() - aSidebarTotalWidth );
     }
 }
 
@@ -5289,8 +5262,8 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 10;
 */
 /*static*/ void SwPageFrm::PaintBorderAndShadow( const SwRect& _rPageRect,
                                                  ViewShell*    _pViewShell,
+                                                 bool bPaintLeftShadow,
                                                  bool bPaintRightShadow,
-                                                 bool bFullBottomShadow,
                                                  bool bRightSidebar )
 {
     // No shadow in prefs
@@ -5300,60 +5273,102 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 10;
     SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *_pViewShell->GetOut() );
     // <--
 
+    static drawinglayer::primitive2d::DiscreteShadow shadowMask( SW_RES( BMP_PAGE_SHADOW_MASK ) );
     static BitmapEx aPageTopRightShadow;
     static BitmapEx aPageBottomRightShadow;
     static BitmapEx aPageBottomLeftShadow;
     static BitmapEx aPageBottomShadowBase;
     static BitmapEx aPageRightShadowBase;
-    static Color aShadowColor;
+    static BitmapEx aPageTopShadowBase;
+    static BitmapEx aPageTopLeftShadow;
+    static BitmapEx aPageLeftShadowBase;
+    static Color aShadowColor( COL_AUTO );
+
+    SwRect aAlignedPageRect( _rPageRect );
+    ::SwAlignRect( aAlignedPageRect, _pViewShell );
+    SwRect aPagePxRect =
+        _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
 
 
     if(aShadowColor != SwViewOption::GetShadowColor() ) {
         aShadowColor = SwViewOption::GetShadowColor();
-        AlphaMask aMask( SW_RES( BMP_PAGE_BOTTOM_RIGHT_SHADOW_MASK ) );
-        Bitmap aFilledSquare( Size( mnShadowPxWidth, mnShadowPxWidth ), 24 );
-        aFilledSquare.Erase( aShadowColor );
 
+        AlphaMask aMask( shadowMask.getBottomRight().GetBitmap() );
+        Bitmap aFilledSquare( aMask.GetSizePixel(), 24 );
+        aFilledSquare.Erase( aShadowColor );
         aPageBottomRightShadow = BitmapEx( aFilledSquare, aMask );
-        aMask.Rotate( 900, 255 );
-        aPageTopRightShadow = BitmapEx( aFilledSquare, aMask );
-        aMask.Rotate( 1800, 255);
+
+        aMask = AlphaMask( shadowMask.getBottomLeft().GetBitmap() );
+        aFilledSquare = Bitmap( aMask.GetSizePixel(), 24 );
+        aFilledSquare.Erase( aShadowColor );
         aPageBottomLeftShadow = BitmapEx( aFilledSquare, aMask );
 
-        aFilledSquare = Bitmap( Size( 1, mnShadowPxWidth ), 24 );
+        aMask = AlphaMask( shadowMask.getBottom().GetBitmap() );
+        aFilledSquare = Bitmap( aMask.GetSizePixel(), 24 );
         aFilledSquare.Erase( aShadowColor );
-        aMask = Bitmap( SW_RES( BMP_PAGE_BOTTOM_SHADOW_MASK ) );
         aPageBottomShadowBase = BitmapEx( aFilledSquare, aMask );
 
-        aFilledSquare = Bitmap( Size( mnShadowPxWidth, 1 ), 24 );
+        aMask = AlphaMask( shadowMask.getTop().GetBitmap() );
+        aFilledSquare = Bitmap( aMask.GetSizePixel(), 24 );
+        aFilledSquare.Erase( aShadowColor );
+        aPageTopShadowBase = BitmapEx( aFilledSquare, aMask );
+
+        aMask = AlphaMask( shadowMask.getTopRight().GetBitmap() );
+        aFilledSquare = Bitmap( aMask.GetSizePixel(), 24 );
+        aFilledSquare.Erase( aShadowColor );
+        aPageTopRightShadow = BitmapEx( aFilledSquare, aMask );
+
+        aMask = AlphaMask( shadowMask.getRight().GetBitmap() );
+        aFilledSquare = Bitmap( aMask.GetSizePixel(), 24 );
         aFilledSquare.Erase( aShadowColor );
-        aMask = Bitmap( SW_RES( BMP_PAGE_RIGHT_SHADOW_MASK ) );
         aPageRightShadowBase = BitmapEx( aFilledSquare, aMask );
+
+        aMask = AlphaMask( shadowMask.getTopLeft().GetBitmap() );
+        aFilledSquare = Bitmap( aMask.GetSizePixel(), 24 );
+        aFilledSquare.Erase( aShadowColor );
+        aPageTopLeftShadow = BitmapEx( aFilledSquare, aMask );
+
+        aMask = AlphaMask( shadowMask.getLeft().GetBitmap() );
+        aFilledSquare = Bitmap( aMask.GetSizePixel(), 24 );
+        aFilledSquare.Erase( aShadowColor );
+        aPageLeftShadowBase = BitmapEx( aFilledSquare, aMask );
     }
 
     SwRect aPaintRect;
     OutputDevice *pOut = _pViewShell->GetOut();
 
+    SwPageFrm::GetHorizontalShadowRect( _rPageRect, _pViewShell, aPaintRect, bPaintLeftShadow, bPaintRightShadow, bRightSidebar );
+
     // paint right shadow
     if ( bPaintRightShadow )
     {
-        SwPageFrm::GetRightShadowRect( _rPageRect, _pViewShell, aPaintRect, bRightSidebar );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Right() + 1, aPagePxRect.Bottom() + 1 - (aPageBottomRightShadow.GetSizePixel().Height() - mnShadowPxWidth) ) ),
+            aPageBottomRightShadow );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Right() + 1, aPagePxRect.Top() - mnShadowPxWidth ) ),
+            aPageTopRightShadow );
         BitmapEx aPageRightShadow = aPageRightShadowBase;
-        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 );
+        aPageRightShadow.Scale( 1, aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1) );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPagePxRect.Right() + 1, aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageRightShadow );
     }
 
-    // paint bottom shadow
-    SwPageFrm::GetBottomShadowRect( _rPageRect, _pViewShell, aPaintRect, bFullBottomShadow, bRightSidebar );
-    if(!bFullBottomShadow)
+    // paint top & bottom shadow
+    if(bPaintLeftShadow)
     {
-        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left() - mnShadowPxWidth, aPaintRect.Top() ) ), aPageBottomLeftShadow );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left() - aPageBottomLeftShadow.GetSizePixel().Width(),
+            aPagePxRect.Bottom() + 1 + mnShadowPxWidth - aPageBottomLeftShadow.GetSizePixel().Height() ) ), aPageBottomLeftShadow );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left() - aPageBottomLeftShadow.GetSizePixel().Width(),
+            aPagePxRect.Top() - mnShadowPxWidth ) ), aPageTopLeftShadow );
+        BitmapEx aPageLeftShadow = aPageLeftShadowBase;
+        aPageLeftShadow.Scale( 1, aPagePxRect.Height() - 2 * (mnShadowPxWidth - 1) );
+        pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPagePxRect.Left() - aPageLeftShadow.GetSizePixel().Width(),
+             aPagePxRect.Top() + mnShadowPxWidth - 1) ), aPageLeftShadow );
     }
     BitmapEx aPageBottomShadow = aPageBottomShadowBase;
     aPageBottomShadow.Scale( aPaintRect.Width(), 1 );
-    pOut->DrawBitmapEx( pOut->PixelToLogic( aPaintRect.Pos() ), aPageBottomShadow);
+    pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left(), aPagePxRect.Bottom() + 1 ) ), aPageBottomShadow);
+    BitmapEx aPageTopShadow = aPageTopShadowBase;
+    aPageTopShadow.Scale( aPaintRect.Width(), 1 );
+    pOut->DrawBitmapEx( pOut->PixelToLogic( Point( aPaintRect.Left(), aPagePxRect.Top() - mnShadowPxWidth ) ), aPageTopShadow );
 }
 
 //mod #i6193# paint sidebar for notes
@@ -5488,16 +5503,16 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 10;
     ::SwAlignRect( aAlignedPageRect, _pViewShell );
     SwRect aPagePxRect =
             _pViewShell->GetOut()->LogicToPixel( aAlignedPageRect.SVRect() );
+    aPagePxRect.Bottom( aPagePxRect.Bottom() + mnShadowPxWidth + 1 );
+    aPagePxRect.Top( aPagePxRect.Top() - mnShadowPxWidth );
 
     SwRect aTmpRect;
-    SwPageFrm::GetRightShadowRect( _rPageRect, _pViewShell, aTmpRect, bRightSidebar );
-
-    aPagePxRect.Right( aTmpRect.Right() );
 
     // Always ask for full shadow
-    SwPageFrm::GetBottomShadowRect( _rPageRect, _pViewShell, aTmpRect, true, bRightSidebar );
-    aPagePxRect.Bottom( aTmpRect.Bottom() );
-    aPagePxRect.Left( aTmpRect.Left() );
+    SwPageFrm::GetHorizontalShadowRect( _rPageRect, _pViewShell, aTmpRect, false, false, bRightSidebar );
+
+    aPagePxRect.Left( aTmpRect.Left() - mnShadowPxWidth);
+    aPagePxRect.Right( aTmpRect.Right() + mnShadowPxWidth + 1);
 
     _orBorderAndShadowBoundRect = _pViewShell->GetOut()->PixelToLogic( aPagePxRect.SVRect() );
 }
commit 553166ac183ccb111fa8df467dc4dd13c66a23ea
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Sat Apr 23 12:46:08 2011 +0200

    Page invalidation uses information from layout.
    
    Invalidation rectangle computation was duplicating code and didn't use
    helper methods from SwPageFrm to get information about the page width.

diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 262ecaa..9ee2eb6 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -991,9 +991,6 @@ void ViewShell::VisPortChgd( const SwRect &rRect)
             SwTwips nMinLeft = LONG_MAX;
             SwTwips nMaxRight= 0;
 
-            const SwTwips nSidebarWidth = pPostItMgr && pPostItMgr->ShowNotes() && pPostItMgr->HasNotes() ?
-                                          pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth() :
-                                          0;
             const bool bBookMode = GetViewOptions()->IsViewLayoutBookMode();
 
             while ( pPage && pPage->Frm().Top() <= nBottom )
@@ -1007,29 +1004,19 @@ void ViewShell::VisPortChgd( const SwRect &rRect)
 
                 if ( aPageRect.IsOver( aBoth ) )
                 {
-                    const SwTwips nShadowWidth =
-                            GetOut()->PixelToLogic( Size( pPage->ShadowPxWidth(), 0 ) ).Width();
-
                     SwTwips nPageLeft = 0;
                     SwTwips nPageRight = 0;
-                    switch ( pPage->SidebarPosition() )
+                    const sw::sidebarwindows::SidebarPosition aSidebarPos = pPage->SidebarPosition();
+
+                    if( aSidebarPos != sw::sidebarwindows::SIDEBAR_NONE )
                     {
-                        case sw::sidebarwindows::SIDEBAR_LEFT:
-                        {
-                            nPageLeft =  aPageRect.Left() - nSidebarWidth;
-                            nPageRight = aPageRect.Right() + nShadowWidth;
-                        }
-                        break;
-                        case sw::sidebarwindows::SIDEBAR_RIGHT:
-                        {
-                            nPageLeft =  aPageRect.Left();
-                            nPageRight = aPageRect.Right() + nShadowWidth + nSidebarWidth;
-                        }
-                        break;
-                        case sw::sidebarwindows::SIDEBAR_NONE:
-                            // nothing to do
-                        break;
+                        SwRect aShadowRect;
+                        SwPageFrm::GetBorderAndShadowBoundRect(aPageRect, this,
+                            aShadowRect, aSidebarPos == sw::sidebarwindows::SIDEBAR_RIGHT);
+                        nPageLeft = aShadowRect.Left();
+                        nPageRight = aShadowRect.Right();
                     }
+
                     if( nPageLeft < nMinLeft )
                         nMinLeft = nPageLeft;
                     if( nPageRight > nMaxRight )
commit 31eef1a21ea2297cd96ea6e53dcc8df1a121c40a
Author: Sébastien Le Ray <sebastien-libreoffice at orniz.org>
Date:   Sat Apr 23 12:43:41 2011 +0200

    Typo in resource definitions.
    
    I don't know how this may have worked before…

diff --git a/sw/inc/rcid.hrc b/sw/inc/rcid.hrc
index f06180a..f3b1528 100644
--- a/sw/inc/rcid.hrc
+++ b/sw/inc/rcid.hrc
@@ -103,7 +103,7 @@
 
 // Page frame
 #define RC_PAGEFRM_BEGIN            RC_PAGEFRM
-#define RC_PAGEFRM_EN               (RC_PAGEFRM + 99)
+#define RC_PAGEFRM_END               (RC_PAGEFRM + 99)
 
 // SW/Web
 #define RC_WEB_BEGIN				RC_WEB


More information about the Libreoffice-commits mailing list