Hi list, Since OOo UX team implemented a new shadow on impress which seem to please more people than the writer shadow I provided before, here is a patchset that add the same shadow to writer. Currently, impress one does not honnor shadow settings (color and shadow presence), once those patches are integrated, I'll unify the code to have both shadow using the same configuration options). I've seen occasional graphical glitches in book mode, I've been unable to track them down (they're not worse than what I occasionaly see in current stable writer version), if some writer experienced guy could take a look (Cédric Bosdonnat maybe), I guess it's related to some piece of code making bad assumption on shadow, I fixed a lot of them but haven't found this one… Regards Sébastien
From a5f6cc0bbbf42d94ad8883a4c82601bcd1305f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Sat, 23 Apr 2011 12:43:41 +0200 Subject: [PATCH 1/9] Typo in resource definitions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I don't know how this may have worked before⦠--- sw/inc/rcid.hrc | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/sw/inc/rcid.hrc b/sw/inc/rcid.hrc index 319037a..4a4abe9 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 -- 1.7.4.1
From 0d2ba1e45e476f7355cb94ecf275219adfdb0477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Sat, 23 Apr 2011 12:41:39 +0200 Subject: [PATCH] Updated page shadow masks. --- default_images/sw/res/page-bottom-shadow-mask.png | Bin 181 -> 0 bytes .../sw/res/page-bottomright-shadow-mask.png | Bin 208 -> 0 bytes default_images/sw/res/page-right-shadow-mask.png | Bin 180 -> 0 bytes default_images/sw/res/page-shadow-mask.png | Bin 0 -> 446 bytes 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 default_images/sw/res/page-bottom-shadow-mask.png delete mode 100644 default_images/sw/res/page-bottomright-shadow-mask.png delete mode 100644 default_images/sw/res/page-right-shadow-mask.png create mode 100644 default_images/sw/res/page-shadow-mask.png diff --git a/default_images/sw/res/page-bottom-shadow-mask.png b/default_images/sw/res/page-bottom-shadow-mask.png deleted file mode 100644 index fd19f034bb0fc80350c240eab1c0e33d7864f1e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 181 zcmeAS@N?(olHy`uVBq!ia0vp^j6lrA0VEg#c4kil2^0spJ29*~C-V}>VM_9LcVYP7 z-hXC4kjGiz5n0T@z%2~Ij105pNB{-dOFVsD*>5wm@hOVhTJ3iN3Q3l@MwB?`=jNv7 zl`uFLr6!i7rYMwWmSiZnd-?{1H}Z)C6^VGdIEHXsPfkdfkTNL=2veFaGjMEW`1bT_ R>3X0%gQu&X%Q~loCID+EFY5pR diff --git a/default_images/sw/res/page-bottomright-shadow-mask.png b/default_images/sw/res/page-bottomright-shadow-mask.png deleted file mode 100644 index 94f32290092a528df8eeb76fadec1f5b9b77987b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2VkYHF5IUx~9F%}28J29*~C-V}>VM_9LcVYP7 z-hXC4kjGiz5n0T@z%2~Ij105pNB{-dOFVsD*>5wmaY>70%>7vi6bkWlaSY+O&U)}9 z;{gQ@mIJQgoby!dU+lkdhC@l&*l5#{H*1!5aBRMxx@zsj$m#Plou>xo?tZ_qC$Kbj zfBMA8E8lAWHfa8xdECAs@JCNAgTa!Of(&&cUMv~auUtxi<}-M@`njxgN@xNAtSm## diff --git a/default_images/sw/res/page-right-shadow-mask.png b/default_images/sw/res/page-right-shadow-mask.png deleted file mode 100644 index 784e00f37afcaf952f6a82c40f390b0f5fbda432..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^AT}chkYG48FJTdgQyk>(#IWw1%u67LDaqU2h2ejD z|C#+j9%q3^WHAE+w=f7ZGR&GI0Tg5}@$_|Nzs=0Xr=T^-eX$)-NV3E=qQp5rH#aq} zgu%HeHL)Z$MWH;iBtya7(>EZzkxv|`NZ8ZGF@)oKa>|4$lO|08VHO6Ki44z+_5^JN PN;7!6`njxgN@xNAgB34b diff --git a/default_images/sw/res/page-shadow-mask.png b/default_images/sw/res/page-shadow-mask.png new file mode 100644 index 0000000000000000000000000000000000000000..5ffb7d934f09b300c554ffd9125557e6897ccf20 GIT binary patch literal 446 zcmV;v0YUzWP)<h;3K|Lk000e1NJLTq001KZ001Kh00000JF@JB00001b5ch_0Itp) z=>Px#0%A)?L;(MXkIcUS000SaNLh0L01EB^01EB_uQ6z>00007bV*G`2ipV`1|KYC z**=Q^00BZtL_t(I%e|CcZo@DPgGtG8e>Uv?=h{(<VQbS!+=HF0K;89am;fV)^MR2i z$`qc4;s2P@pXzH1_O&tslt^tD0UE4h1%RMbMk>`Hf<|-ED6TpgEmDo4xx2f=Rvl!- z@^+u=34k|7QY`b}JTqVdQ2=Dd^)g^Cq|^JqBIfgeIh%*~8a~vyMrLCk=d*;Q-iwS_ z2FwzXTfdYKnAFM$$`~-w>)v#v955;A#v2;haozl5ACiM_>!!6Aj`WO;vTi9KFm41l z9rH5sy4$7$^9PJuXGnUf1Ev-yyPwT`+P$AXKELMcB7kM8hvVzp%j9OOpWSN;(|(>K z1kk<K!{NBE?(2M+d=gl8OY1bvOR2m4?nj591GH)B!$X>Tnd)?tPb-qw`}u0;Dy=>+ ozn@cMs}J?dyt7{odVX(w1KTI3x?Bk1L;wH)07*qoM6N<$f+?WHwg3PC literal 0 HcmV?d00001 -- 1.7.4.1
From 9169d9c7be414b7b2ee50f0d17f26f9140b5fa50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Sat, 23 Apr 2011 12:46:08 +0200 Subject: [PATCH 2/9] 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. --- sw/source/core/view/viewsh.cxx | 31 +++++++++---------------------- 1 files changed, 9 insertions(+), 22 deletions(-) diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index fae44c9..757e5ef 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 ) -- 1.7.4.1
From 0c6ab2dd842289573a588a50bd5a7832e6571e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Sat, 23 Apr 2011 12:47:23 +0200 Subject: [PATCH 3/9] 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. --- sw/source/core/inc/pagefrm.hrc | 6 +- sw/source/core/inc/pagefrm.hxx | 31 +------ sw/source/core/layout/pagefrm.src | 14 +--- sw/source/core/layout/paintfrm.cxx | 159 ++++++++++++++++++++---------------- 4 files changed, 96 insertions(+), 114 deletions(-) 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 0c50e28..d63320d 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> @@ -2843,8 +2844,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() ) @@ -2947,7 +2948,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); } @@ -3039,7 +3040,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); { @@ -5192,36 +5193,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 @@ -5229,10 +5201,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; @@ -5241,21 +5214,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 ); } } @@ -5268,8 +5241,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 @@ -5278,60 +5251,102 @@ const sal_Int8 SwPageFrm::mnShadowPxWidth = 10; // #i16816# tagged pdf support 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 @@ -5466,16 +5481,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() ); } -- 1.7.4.1
From d3dfc63648f01fb4f7d95d6cf4823b2168681e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Sat, 23 Apr 2011 14:19:18 +0200 Subject: [PATCH 4/9] Bad shadow alignment when sidebar present. --- sw/source/core/layout/paintfrm.cxx | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index d63320d..6608e8e 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -5326,20 +5326,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 ); -- 1.7.4.1
From a079699982d93106f3e9cdee5ad530ddd9d51246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Tue, 26 Apr 2011 18:04:12 +0200 Subject: [PATCH 5/9] Typo in param name --- sw/source/core/inc/pagefrm.hxx | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 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 ); -- 1.7.4.1
From 5a7e103cad3f7c0e2a40e28a4c47832ad9583107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Tue, 26 Apr 2011 22:14:40 +0200 Subject: [PATCH 6/9] 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. --- sw/source/core/inc/frmtool.hxx | 2 +- sw/source/core/inc/pagefrm.hxx | 13 ++++-- sw/source/core/layout/layact.cxx | 63 +++++++++++-------------- sw/source/core/layout/pagechg.cxx | 5 +- sw/source/core/layout/paintfrm.cxx | 72 +++++++++++++++++++---------- sw/source/core/view/pagepreviewlayout.cxx | 3 +- sw/source/core/view/viewsh.cxx | 2 +- 7 files changed, 91 insertions(+), 69 deletions(-) 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 445effd..0c3d612 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -1410,30 +1410,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(); @@ -1485,38 +1470,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 04edc6c..a1bae57 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 ); } } @@ -673,7 +673,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 6608e8e..a99a295 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1032,7 +1032,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; @@ -2827,8 +2827,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()); @@ -2836,22 +2834,15 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const // while ( pPage && !::IsShortCut( aRect, pPage->Frm() ) ) 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 ) ) { @@ -3001,7 +2992,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 ) ) @@ -5195,6 +5187,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# @@ -5202,7 +5219,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, @@ -5240,7 +5257,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 ) @@ -5317,7 +5334,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) ) ), @@ -5329,7 +5346,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(); @@ -5340,6 +5357,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); @@ -5472,24 +5490,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 757e5ef..1085943 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(); } -- 1.7.4.1
From 46fa57a718d77242bedc49ae61f00e56cc054027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Wed, 27 Apr 2011 09:12:52 +0200 Subject: [PATCH 7/9] 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. --- sw/source/core/inc/pagefrm.hxx | 2 ++ sw/source/core/layout/paintfrm.cxx | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-) 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 a99a295..ad98b1a 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -5516,6 +5516,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; -- 1.7.4.1
From 660687d27b57cc82df5b544cabe7d34bb2f389bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Wed, 27 Apr 2011 09:15:18 +0200 Subject: [PATCH 8/9] 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. --- sw/source/core/view/viewimp.cxx | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) 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(); } } } -- 1.7.4.1
From b450454d3a3992fd79c2a18654871635da62e4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org> Date: Fri, 29 Apr 2011 18:37:41 +0200 Subject: [PATCH 9/9] Use GetBoundRect() instead of Frm() in layout. --- sw/source/core/layout/layact.cxx | 32 ++++++++++++++++++-------------- sw/source/core/view/viewsh.cxx | 11 ++++------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 0c3d612..efe64b1 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -1385,9 +1385,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; @@ -1410,15 +1416,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(); @@ -1485,12 +1483,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 ); @@ -1564,12 +1566,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 1085943..f786f37 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 ) -- 1.7.4.1
Attachment:
signature.asc
Description: PGP signature