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 )
......
...@@ -45,14 +45,15 @@ class SwPagePreviewLayout; ...@@ -45,14 +45,15 @@ class SwPagePreviewLayout;
// Delete member <mnVirtPage> and its accessor // Delete member <mnVirtPage> and its accessor
class SwPagePreviewWin : public vcl::Window class SwPagePreviewWin : public vcl::Window
{ {
SwViewShell* mpViewShell; SwViewShell* mpViewShell;
sal_uInt16 mnSttPage; sal_uInt16 mnSttPage;
sal_uInt8 mnRow, mnCol; sal_uInt8 mnRow;
Size maPxWinSize; sal_uInt8 mnCol;
Fraction maScale; Size maPxWinSize;
SwPagePreview& mrView; Fraction maScale;
bool mbCalcScaleForPreviewLayout; SwPagePreview& mrView;
Rectangle maPaintedPreviewDocRect; bool mbCalcScaleForPreviewLayout;
Rectangle maPaintedPreviewDocRect;
SwPagePreviewLayout* mpPgPreviewLayout; SwPagePreviewLayout* mpPgPreviewLayout;
void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol ); void SetPagePreview( sal_uInt8 nRow, sal_uInt8 nCol );
...@@ -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; } sal_uInt8 GetRow() const
void SetRow( sal_uInt8 n ) { if( n ) mnRow = n; } {
return mnRow;
}
sal_uInt8 GetCol() const { return mnCol; } void SetRow(sal_uInt8 n)
void SetCol( sal_uInt8 n ) { if( n ) mnCol = n; } {
if(n)
mnRow = n;
}
sal_uInt16 GetSttPage() const { return mnSttPage; } sal_uInt8 GetCol() const
void SetSttPage( sal_uInt16 n ) { mnSttPage = n; } {
return mnCol;
}
void SetCol(sal_uInt8 n)
{
if(n)
mnCol = n;
}
sal_uInt16 GetSttPage() const
{
return mnSttPage;
}
void SetSttPage(sal_uInt16 n)
{
mnSttPage = n;
}
/** get selected page number of document preview /** get selected page number of document preview
...@@ -97,7 +123,7 @@ public: ...@@ -97,7 +123,7 @@ public:
void SetSelectedPage( sal_uInt16 _nSelectedPageNum ); void SetSelectedPage( sal_uInt16 _nSelectedPageNum );
// If we only have one column we do not have a oth page // If we only have one column we do not have a oth page
sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; } sal_uInt16 GetDefSttPage() const { return 1 == mnCol ? 1 : 0; }
void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol ); void CalcWish( sal_uInt8 nNewRow, sal_uInt8 nNewCol );
...@@ -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;
}; };
/** /**
...@@ -152,48 +176,47 @@ class SW_DLLPUBLIC SwPagePreview: public SfxViewShell ...@@ -152,48 +176,47 @@ class SW_DLLPUBLIC SwPagePreview: public SfxViewShell
// current dispatcher shell // current dispatcher shell
VclPtr<SwPagePreviewWin> pViewWin; VclPtr<SwPagePreviewWin> pViewWin;
//viewdata of the previous SwView and the new crsrposition //viewdata of the previous SwView and the new crsrposition
OUString sSwViewData; OUString sSwViewData;
//and the new cursor position if the user double click in the PagePreview //and the new cursor position if the user double click in the PagePreview
OUString sNewCrsrPos; OUString sNewCrsrPos;
// to support keyboard the number of the page to go to can be set too // to support keyboard the number of the page to go to can be set too
sal_uInt16 nNewPage; sal_uInt16 nNewPage;
// visible range // visible range
OUString sPageStr; OUString sPageStr;
Size aDocSz; Size aDocSz;
Rectangle aVisArea; Rectangle aVisArea;
// 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;
sal_uInt16 mnPageCount; sal_uInt16 mnPageCount;
bool bNormalPrint; bool bNormalPrint;
// New members to reset design mode at draw view for form shell on switching // New members to reset design mode at draw view for form shell on switching
// back from writer page preview to normal view. // back from writer page preview to normal view.
bool mbResetFormDesignMode:1; bool mbResetFormDesignMode:1;
bool mbFormDesignModeToReset:1; bool mbFormDesignModeToReset:1;
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,45 +248,50 @@ private: ...@@ -225,45 +248,50 @@ 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 void RepaintCoreRect( const SwRect& rRect ) inline const Rectangle& GetVisArea() const
{ pViewWin->RepaintCoreRect( rRect ); } { return aVisArea; }
inline void GrabFocusViewWin()
void DocSzChgd(const Size& rNewSize); { pViewWin->GrabFocus(); }
const Size& GetDocSz() const { return aDocSz; } inline void RepaintCoreRect( const SwRect& rRect )
{ pViewWin->RepaintCoreRect( rRect ); }
void SetVisArea( const Rectangle&, bool bUpdateScrollbar = true);
void DocSzChgd(const Size& rNewSize);
inline void AdjustEditWin(); const Size& GetDocSz() const
{ return aDocSz; }
void ScrollViewSzChg();
void ScrollDocSzChg(); void SetVisArea( const Rectangle&, bool bUpdateScrollbar = true);
void ShowHScrollbar(bool bShow);
void ShowVScrollbar(bool bShow); inline void AdjustEditWin();
void EnableHScrollbar(bool bEnable);
void EnableVScrollbar(bool bEnable); void ScrollViewSzChg();
void ScrollDocSzChg();
sal_uInt16 GetPageCount() const { return mnPageCount; } void ShowHScrollbar(bool bShow);
sal_uInt16 GetSelectedPage() const {return pViewWin->SelectedPage();} void ShowVScrollbar(bool bShow);
void EnableHScrollbar(bool bEnable);
bool HandleWheelCommands( const CommandEvent& ); void EnableVScrollbar(bool bEnable);
OUString GetPrevSwViewData() const { return sSwViewData; } sal_uInt16 GetPageCount() const { return mnPageCount; }
void SetNewCrsrPos( const OUString& rStr ) { sNewCrsrPos = rStr; } sal_uInt16 GetSelectedPage() const {return pViewWin->SelectedPage();}
bool HandleWheelCommands( const CommandEvent& );
OUString GetPrevSwViewData() const { return sSwViewData; }
void SetNewCrsrPos( const OUString& rStr ) { sNewCrsrPos = rStr; }
const OUString& GetNewCrsrPos() const { return sNewCrsrPos; } const OUString& GetNewCrsrPos() const { return sNewCrsrPos; }
sal_uInt16 GetNewPage() const {return nNewPage;} sal_uInt16 GetNewPage() const {return nNewPage;}
void SetNewPage(sal_uInt16 nSet) {nNewPage = nSet;} void SetNewPage(sal_uInt16 nSet) {nNewPage = nSet;}
// Handler // Handler
void Execute(SfxRequest&); void Execute(SfxRequest&);
void GetState(SfxItemSet&); void GetState(SfxItemSet&);
static void StateUndo(SfxItemSet&); static void StateUndo(SfxItemSet&);
SwDocShell* GetDocShell(); SwDocShell* GetDocShell();
// apply Accessiblity options // apply Accessiblity options
void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions); void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions);
......
...@@ -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