diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-15 16:58:32 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-15 17:10:24 +0900 |
commit | fbd06b24c5cd4a560669e311a10ea37fc3834eac (patch) | |
tree | 32c35140825e6d7dfd7fcbce2ae8d8f92ddc6f92 | |
parent | 961b141d6b224d723a0193510975b6f1478e1be5 (diff) |
refactor SwDropCapsPict to use RenderContext
Change-Id: I6a68d22f9b7ded9d58a69057bf0f4197a67fd2e8
-rw-r--r-- | sw/source/ui/chrdlg/drpcps.cxx | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx index 825c7e26b394..cab734c2cd4b 100644 --- a/sw/source/ui/chrdlg/drpcps.cxx +++ b/sw/source/ui/chrdlg/drpcps.cxx @@ -130,7 +130,7 @@ public: void SetDistance( sal_uInt16 nD ); void SetValues( const OUString& rText, sal_uInt8 nLines, sal_uInt16 nDistance ); - void DrawPrev( const Point& rPt ); + void DrawPrev(vcl::RenderContext& rRenderContext, const Point& rPt); }; VCL_BUILDER_FACTORY_ARGS(SwDropCapsPict, WB_BORDER) @@ -343,71 +343,77 @@ void SwDropCapsPict::UpdatePaintSettings() Invalidate(); } -void SwDropCapsPict::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle &/*rRect*/) +void SwDropCapsPict::Paint(vcl::RenderContext& rRenderContext, const Rectangle &/*rRect*/) { if (!IsVisible()) return; - SetMapMode(MapMode(MAP_PIXEL)); - SetLineColor(); + rRenderContext.SetMapMode(MapMode(MAP_PIXEL)); + rRenderContext.SetLineColor(); - SetFillColor( maBackColor ); + rRenderContext.SetFillColor(maBackColor); - Size aOutputSizePixel( GetOutputSizePixel() ); + Size aOutputSizePixel(rRenderContext.GetOutputSizePixel()); DrawRect(Rectangle(Point(0, 0), aOutputSizePixel )); - SetClipRegion(vcl::Region(Rectangle( - Point(BORDER, BORDER), - Size (aOutputSizePixel.Width () - 2 * BORDER, - aOutputSizePixel.Height() - 2 * BORDER)))); + rRenderContext.SetClipRegion(vcl::Region(Rectangle(Point(BORDER, BORDER), + Size (aOutputSizePixel.Width () - 2 * BORDER, + aOutputSizePixel.Height() - 2 * BORDER)))); OSL_ENSURE(mnLineH > 0, "We cannot make it that small"); long nY0 = (aOutputSizePixel.Height() - (LINES * mnTotLineH)) / 2; - SetFillColor( maTextLineColor ); + + rRenderContext.SetFillColor(maTextLineColor); + for (int i = 0; i < LINES; ++i) - DrawRect(Rectangle(Point(BORDER, nY0 + i * mnTotLineH), Size(aOutputSizePixel.Width() - 2 * BORDER, mnLineH))); + { + rRenderContext.DrawRect(Rectangle(Point(BORDER, nY0 + i * mnTotLineH), + Size(aOutputSizePixel.Width() - 2 * BORDER, mnLineH))); + } // Text background with gap (240 twips ~ 1 line height) const long nDistW = (((static_cast<long>(mnDistance) * 100) / 240) * mnTotLineH) / 100; - SetFillColor( maBackColor ); + rRenderContext.SetFillColor(maBackColor); if (mpPage && mpPage->m_pDropCapsBox->IsChecked()) { - const Size aTextSize( maTextSize.Width()+nDistW, maTextSize.Height() ); - DrawRect( Rectangle( Point( BORDER, nY0 ), aTextSize ) ); + const Size aTextSize(maTextSize.Width() + nDistW, maTextSize.Height()); + rRenderContext.DrawRect(Rectangle(Point(BORDER, nY0), aTextSize)); // draw Text - DrawPrev( Point( BORDER, nY0 ) ); + DrawPrev(rRenderContext, Point(BORDER, nY0)); } - - SetClipRegion(); + rRenderContext.SetClipRegion(); } -void SwDropCapsPict::DrawPrev( const Point& rPt ) +void SwDropCapsPict::DrawPrev(vcl::RenderContext& rRenderContext, const Point& rPt) { Point aPt(rPt); InitPrinter(); - vcl::Font aOldFont = mpPrinter->GetFont(); - sal_uInt16 nScript; - size_t nIdx = 0; - sal_Int32 nStart; - sal_Int32 nEnd; + vcl::Font aOldFont = mpPrinter->GetFont(); + sal_uInt16 nScript; + size_t nIdx = 0; + sal_Int32 nStart; + sal_Int32 nEnd; + GetFirstScriptSegment(nStart, nEnd, nScript); + do { - SvxFont& rFnt = (nScript==css::i18n::ScriptType::ASIAN) ? maCJKFont : ((nScript==css::i18n::ScriptType::COMPLEX) ? maCTLFont : maFont); - mpPrinter->SetFont( rFnt ); + SvxFont& rFnt = (nScript==css::i18n::ScriptType::ASIAN) ? maCJKFont : ((nScript==css::i18n::ScriptType::COMPLEX) ? maCTLFont : maFont); + mpPrinter->SetFont(rFnt); - rFnt.DrawPrev( this, mpPrinter, aPt, maText, nStart, nEnd - nStart ); + rFnt.DrawPrev(&rRenderContext, mpPrinter, aPt, maText, nStart, nEnd - nStart); if (!maScriptChanges.empty()) - aPt.X() += maScriptChanges[ nIdx ].textWidth; + aPt.X() += maScriptChanges[nIdx].textWidth; - if ( !GetNextScriptSegment(nIdx, nStart, nEnd, nScript) ) + if (!GetNextScriptSegment(nIdx, nStart, nEnd, nScript)) break; } - while( true ); - mpPrinter->SetFont( aOldFont ); + while(true); + + mpPrinter->SetFont(aOldFont); } void SwDropCapsPict::CheckScript() |