Kaydet (Commit) 24b78414 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor SwPagePreview to use RenderContext

Change-Id: I7e19aca13ebde8d18ecf4783e59d71f4ecabeed4
üst e36b5415
...@@ -362,7 +362,7 @@ public: ...@@ -362,7 +362,7 @@ public:
@return boolean, indicating, if paint of preview was performed @return boolean, indicating, if paint of preview was performed
*/ */
bool Paint( const Rectangle& rOutRect ) const; bool Paint(vcl::RenderContext& rRenderContext, const Rectangle& rOutRect) const;
/** repaint pages on page preview /** repaint pages on page preview
......
...@@ -986,22 +986,22 @@ SwTwips SwPagePreviewLayout::GetWinPagesScrollAmount( ...@@ -986,22 +986,22 @@ SwTwips SwPagePreviewLayout::GetWinPagesScrollAmount(
OD 12.12.2002 #103492# OD 12.12.2002 #103492#
*/ */
bool SwPagePreviewLayout::Paint(const Rectangle& rOutRect) const bool SwPagePreviewLayout::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rOutRect) const
{ {
// check environment and parameters // check environment and parameters
{ {
if ( !mrParentViewShell.GetWin() && if (!mrParentViewShell.GetWin() && !mrParentViewShell.GetOut()->GetConnectMetaFile())
!mrParentViewShell.GetOut()->GetConnectMetaFile() ) {
return false; return false;
}
OSL_ENSURE( mbPaintInfoValid, OSL_ENSURE(mbPaintInfoValid, "invalid preview settings - no paint of preview");
"invalid preview settings - no paint of preview" ); if (!mbPaintInfoValid)
if ( !mbPaintInfoValid )
return false; return false;
} }
// OD 17.11.2003 #i22014# - no paint, if <superfluous> flag is set at layout // OD 17.11.2003 #i22014# - no paint, if <superfluous> flag is set at layout
if ( mrLayoutRootFrm.IsSuperfluous() ) if (mrLayoutRootFrm.IsSuperfluous())
{ {
return true; return true;
} }
...@@ -1009,13 +1009,13 @@ bool SwPagePreviewLayout::Paint(const Rectangle& rOutRect) const ...@@ -1009,13 +1009,13 @@ bool SwPagePreviewLayout::Paint(const Rectangle& rOutRect) const
// environment and parameter ok // environment and parameter ok
// OD 07.11.2003 #i22014# // OD 07.11.2003 #i22014#
if ( mbInPaint ) if (mbInPaint)
{ {
return false; return false;
} }
mbInPaint = true; mbInPaint = true;
OutputDevice* pOutputDev = mrParentViewShell.GetOut(); OutputDevice* pOutputDev = &rRenderContext; //mrParentViewShell.GetOut();
// prepare paint // prepare paint
if ( maPreviewPages.size() > 0 ) if ( maPreviewPages.size() > 0 )
......
...@@ -47,7 +47,8 @@ class SwPagePreviewWin : public vcl::Window ...@@ -47,7 +47,8 @@ class SwPagePreviewWin : public vcl::Window
{ {
SwViewShell* mpViewShell; SwViewShell* mpViewShell;
sal_uInt16 mnSttPage; sal_uInt16 mnSttPage;
sal_uInt8 mnRow, mnCol; sal_uInt8 mnRow;
sal_uInt8 mnCol;
Size maPxWinSize; Size maPxWinSize;
Fraction maScale; Fraction maScale;
SwPagePreview& mrView; SwPagePreview& mrView;
...@@ -72,16 +73,41 @@ public: ...@@ -72,16 +73,41 @@ public:
void SetViewShell( SwViewShell* pShell ); void SetViewShell( SwViewShell* pShell );
SwViewShell* GetViewShell() const { return mpViewShell; } SwViewShell* GetViewShell() const
{
return mpViewShell;
}
sal_uInt8 GetRow() const
{
return mnRow;
}
void SetRow(sal_uInt8 n)
{
if(n)
mnRow = n;
}
sal_uInt8 GetRow() const { return mnRow; } sal_uInt8 GetCol() const
void SetRow( sal_uInt8 n ) { if( n ) mnRow = n; } {
return mnCol;
}
void SetCol(sal_uInt8 n)
{
if(n)
mnCol = n;
}
sal_uInt8 GetCol() const { return mnCol; } sal_uInt16 GetSttPage() const
void SetCol( sal_uInt8 n ) { if( n ) mnCol = n; } {
return mnSttPage;
}
sal_uInt16 GetSttPage() const { return mnSttPage; } void SetSttPage(sal_uInt16 n)
void SetSttPage( sal_uInt16 n ) { mnSttPage = n; } {
mnSttPage = n;
}
/** get selected page number of document preview /** get selected page number of document preview
...@@ -138,9 +164,7 @@ public: ...@@ -138,9 +164,7 @@ public:
*/ */
bool SetBookPreviewMode( const bool _bBookPreview ); bool SetBookPreviewMode( const bool _bBookPreview );
virtual ::com::sun::star::uno::Reference< virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
::com::sun::star::accessibility::XAccessible>
CreateAccessible() SAL_OVERRIDE;
}; };
/** /**
...@@ -165,10 +189,10 @@ class SW_DLLPUBLIC SwPagePreview: public SfxViewShell ...@@ -165,10 +189,10 @@ class SW_DLLPUBLIC SwPagePreview: public SfxViewShell
// MDI control elements // MDI control elements
VclPtr<SwScrollbar> pHScrollbar; VclPtr<SwScrollbar> pHScrollbar;
VclPtr<SwScrollbar> pVScrollbar; VclPtr<SwScrollbar> pVScrollbar;
bool mbHScrollbarEnabled; bool mbHScrollbarEnabled : 1;
bool mbVScrollbarEnabled; bool mbVScrollbarEnabled : 1;
VclPtr<ImageButton> pPageUpBtn, VclPtr<ImageButton> pPageUpBtn;
pPageDownBtn; VclPtr<ImageButton> pPageDownBtn;
// dummy window for filling the lower right edge when both scrollbars are active // dummy window for filling the lower right edge when both scrollbars are active
VclPtr<vcl::Window> pScrollFill; VclPtr<vcl::Window> pScrollFill;
...@@ -183,17 +207,16 @@ class SW_DLLPUBLIC SwPagePreview: public SfxViewShell ...@@ -183,17 +207,16 @@ class SW_DLLPUBLIC SwPagePreview: public SfxViewShell
SAL_DLLPRIVATE void Init(const SwViewOption* = 0); SAL_DLLPRIVATE void Init(const SwViewOption* = 0);
SAL_DLLPRIVATE Point AlignToPixel(const Point& rPt) const; SAL_DLLPRIVATE Point AlignToPixel(const Point& rPt) const;
SAL_DLLPRIVATE int _CreateScrollbar( bool bHori ); SAL_DLLPRIVATE int _CreateScrollbar( bool bHori);
DECL_DLLPRIVATE_LINK( ScrollHdl, SwScrollbar * ); DECL_DLLPRIVATE_LINK(ScrollHdl, SwScrollbar*);
DECL_DLLPRIVATE_LINK( EndScrollHdl, SwScrollbar * ); DECL_DLLPRIVATE_LINK(EndScrollHdl, SwScrollbar*);
DECL_DLLPRIVATE_LINK( BtnPage, Button * ); DECL_DLLPRIVATE_LINK(BtnPage, Button*);
SAL_DLLPRIVATE bool ChgPage( int eMvMode, bool bUpdateScrollbar = true ); SAL_DLLPRIVATE bool ChgPage( int eMvMode, bool bUpdateScrollbar = true );
SAL_DLLPRIVATE virtual SfxPrinter* GetPrinter( bool bCreate = false ) SAL_OVERRIDE; SAL_DLLPRIVATE virtual SfxPrinter* GetPrinter( bool bCreate = false ) SAL_OVERRIDE;
SAL_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ) SAL_OVERRIDE; SAL_DLLPRIVATE virtual sal_uInt16 SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ) SAL_OVERRIDE;
SAL_DLLPRIVATE virtual bool HasPrintOptionsPage() const SAL_OVERRIDE; SAL_DLLPRIVATE virtual bool HasPrintOptionsPage() const SAL_OVERRIDE;
SAL_DLLPRIVATE virtual VclPtr<SfxTabPage> CreatePrintOptionsPage( vcl::Window *pParent, SAL_DLLPRIVATE virtual VclPtr<SfxTabPage> CreatePrintOptionsPage(vcl::Window *pParent, const SfxItemSet &rOptions ) SAL_OVERRIDE;
const SfxItemSet &rOptions ) SAL_OVERRIDE;
SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, bool bInner ); SAL_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, bool bInner );
...@@ -225,15 +248,20 @@ private: ...@@ -225,15 +248,20 @@ private:
static void InitInterface_Impl(); static void InitInterface_Impl();
public: public:
inline vcl::Window& GetFrameWindow() const { return GetViewFrame()->GetWindow(); } inline vcl::Window& GetFrameWindow() const
inline SwViewShell* GetViewShell() const { return pViewWin->GetViewShell(); } { return GetViewFrame()->GetWindow(); }
inline const Rectangle& GetVisArea() const { return aVisArea; } inline SwViewShell* GetViewShell() const
inline void GrabFocusViewWin() { pViewWin->GrabFocus(); } { return pViewWin->GetViewShell(); }
inline const Rectangle& GetVisArea() const
{ return aVisArea; }
inline void GrabFocusViewWin()
{ pViewWin->GrabFocus(); }
inline void RepaintCoreRect( const SwRect& rRect ) inline void RepaintCoreRect( const SwRect& rRect )
{ pViewWin->RepaintCoreRect( rRect ); } { pViewWin->RepaintCoreRect( rRect ); }
void DocSzChgd(const Size& rNewSize); void DocSzChgd(const Size& rNewSize);
const Size& GetDocSz() const { return aDocSz; } const Size& GetDocSz() const
{ return aDocSz; }
void SetVisArea( const Rectangle&, bool bUpdateScrollbar = true); void SetVisArea( const Rectangle&, bool bUpdateScrollbar = true);
......
...@@ -210,31 +210,31 @@ SwPagePreviewWin::~SwPagePreviewWin() ...@@ -210,31 +210,31 @@ SwPagePreviewWin::~SwPagePreviewWin()
{ {
} }
void SwPagePreviewWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) void SwPagePreviewWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
{ {
if( !mpViewShell || !mpViewShell->GetLayout() ) if (!mpViewShell || !mpViewShell->GetLayout())
return; return;
if( USHRT_MAX == mnSttPage ) // was never calculated ? (Init-Phase!) if (USHRT_MAX == mnSttPage) // was never calculated ? (Init-Phase!)
{ {
// This is the size to which I always relate. // This is the size to which I always relate.
if( !maPxWinSize.Height() || !maPxWinSize.Width() ) if (!maPxWinSize.Height() || !maPxWinSize.Width())
maPxWinSize = GetOutputSizePixel(); maPxWinSize = rRenderContext.GetOutputSizePixel();
Rectangle aRect( LogicToPixel( rRect )); Rectangle aRect(rRenderContext.LogicToPixel(rRect));
mpPgPreviewLayout->Prepare( 1, Point(0,0), maPxWinSize, mpPgPreviewLayout->Prepare(1, Point(0,0), maPxWinSize,
mnSttPage, maPaintedPreviewDocRect ); mnSttPage, maPaintedPreviewDocRect);
SetSelectedPage( 1 ); SetSelectedPage(1);
mpPgPreviewLayout->Paint( PixelToLogic( aRect ) ); mpPgPreviewLayout->Paint(rRenderContext, rRenderContext.PixelToLogic(aRect));
SetPagePreview(mnRow, mnCol); SetPagePreview(mnRow, mnCol);
} }
else else
{ {
MapMode aMM( GetMapMode() ); MapMode aMM(rRenderContext.GetMapMode());
aMM.SetScaleX( maScale ); aMM.SetScaleX(maScale);
aMM.SetScaleY( maScale ); aMM.SetScaleY(maScale);
SetMapMode( aMM ); rRenderContext.SetMapMode(aMM);
mpPgPreviewLayout->Paint( rRect ); mpPgPreviewLayout->Paint(rRenderContext, rRect);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment