diff options
Diffstat (limited to 'svx/source/dialog/pagectrl.cxx')
-rw-r--r-- | svx/source/dialog/pagectrl.cxx | 174 |
1 files changed, 83 insertions, 91 deletions
diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx index 574e32ff0473..6f8a35612540 100644 --- a/svx/source/dialog/pagectrl.cxx +++ b/svx/source/dialog/pagectrl.cxx @@ -102,11 +102,11 @@ void SvxPageWindow::dispose() VCL_BUILDER_FACTORY(SvxPageWindow) -void SvxPageWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle&) +void SvxPageWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) { - Fraction aXScale(aWinSize.Width(),std::max((long)(aSize.Width() * 2 + aSize.Width() / 8),1L)); - Fraction aYScale(aWinSize.Height(),std::max(aSize.Height(),1L)); - MapMode aMapMode(GetMapMode()); + Fraction aXScale(aWinSize.Width(), std::max(long(aSize.Width() * 2 + aSize.Width() / 8), 1L)); + Fraction aYScale(aWinSize.Height(), std::max(aSize.Height(), 1L)); + MapMode aMapMode(rRenderContext.GetMapMode()); if(aYScale < aXScale) { @@ -118,11 +118,11 @@ void SvxPageWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangl aMapMode.SetScaleX(aXScale); aMapMode.SetScaleY(aXScale); } - SetMapMode(aMapMode); - Size aSz(PixelToLogic(GetSizePixel())); + rRenderContext.SetMapMode(aMapMode); + Size aSz(rRenderContext.PixelToLogic(GetSizePixel())); long nYPos = (aSz.Height() - aSize.Height()) / 2; - if(eUsage == SVX_PAGE_ALL) + if (eUsage == SVX_PAGE_ALL) { // all pages are equal -> draw one page if (aSize.Width() > aSize.Height()) @@ -135,61 +135,62 @@ void SvxPageWindow::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangl aY *= a2; aMapMode.SetScaleX(aX); aMapMode.SetScaleY(aY); - SetMapMode(aMapMode); - aSz = PixelToLogic(GetSizePixel()); + rRenderContext.SetMapMode(aMapMode); + aSz = rRenderContext.PixelToLogic(GetSizePixel()); nYPos = (aSz.Height() - aSize.Height()) / 2; long nXPos = (aSz.Width() - aSize.Width()) / 2; - DrawPage(Point(nXPos,nYPos),true,true); + DrawPage(rRenderContext, Point(nXPos,nYPos),true,true); } else // Portrait - DrawPage(Point((aSz.Width() - aSize.Width()) / 2,nYPos),true,true); + DrawPage(rRenderContext, Point((aSz.Width() - aSize.Width()) / 2,nYPos),true,true); } else { // Left and right page are different -> draw two pages if possible - DrawPage(Point(0,nYPos),false,(eUsage & SVX_PAGE_LEFT) != 0); - DrawPage(Point(aSize.Width() + aSize.Width() / 8,nYPos),true, - (eUsage & SVX_PAGE_RIGHT) != 0); + DrawPage(rRenderContext, Point(0, nYPos), false, (eUsage & SVX_PAGE_LEFT) != 0); + DrawPage(rRenderContext, Point(aSize.Width() + aSize.Width() / 8, nYPos), true, (eUsage & SVX_PAGE_RIGHT) != 0); } } -void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool bEnabled) +void SvxPageWindow::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOrg, const bool bSecond, const bool bEnabled) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); const Color& rFieldColor = rStyleSettings.GetFieldColor(); const Color& rFieldTextColor = rStyleSettings.GetFieldTextColor(); const Color& rDisableColor = rStyleSettings.GetDisableColor(); const Color& rDlgColor = rStyleSettings.GetDialogColor(); // background - if(!bSecond || bResetBackground) + if (!bSecond || bResetBackground) { - SetLineColor(Color(COL_TRANSPARENT)); - SetFillColor(rDlgColor); - Size winSize(GetOutputSize()); - DrawRect(Rectangle(Point(0,0),winSize)); + rRenderContext.SetLineColor(Color(COL_TRANSPARENT)); + rRenderContext.SetFillColor(rDlgColor); + Size winSize(rRenderContext.GetOutputSize()); + rRenderContext.DrawRect(Rectangle(Point(0,0), winSize)); - if(bResetBackground) + if (bResetBackground) bResetBackground = false; } - SetLineColor(rFieldTextColor); + rRenderContext.SetLineColor(rFieldTextColor); + // Shadow Size aTempSize = aSize; + // Page - if(!bEnabled) + if (!bEnabled) { - SetFillColor(rDisableColor); - DrawRect(Rectangle(rOrg,aTempSize)); + rRenderContext.SetFillColor(rDisableColor); + rRenderContext.DrawRect(Rectangle(rOrg, aTempSize)); return; } - SetFillColor(rFieldColor); - DrawRect(Rectangle(rOrg,aTempSize)); + rRenderContext.SetFillColor(rFieldColor); + rRenderContext.DrawRect(Rectangle(rOrg, aTempSize)); long nL = nLeft; long nR = nRight; - if(eUsage == SVX_PAGE_MIRROR && !bSecond) + if (eUsage == SVX_PAGE_MIRROR && !bSecond) { // turn for mirrored nL = nRight; @@ -206,17 +207,17 @@ void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool b Rectangle aHdRect(aRect); Rectangle aFtRect(aRect); - if(bHeader || bFooter) + if (bHeader || bFooter) { //UUUU Header and/or footer used - const Color aLineColor(GetLineColor()); + const Color aLineColor(rRenderContext.GetLineColor()); //UUUU draw PageFill first and on the whole page, no outline - SetLineColor(); - drawFillAttributes(maPageFillAttributes, aRect, aRect); - SetLineColor(aLineColor); + rRenderContext.SetLineColor(); + drawFillAttributes(rRenderContext, maPageFillAttributes, aRect, aRect); + rRenderContext.SetLineColor(aLineColor); - if(bHeader) + if (bHeader) { // show headers if possible aHdRect.Left() += nHdLeft; @@ -225,10 +226,10 @@ void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool b aRect.Top() += nHdHeight + nHdDist; // draw header over PageFill, plus outline - drawFillAttributes(maHeaderFillAttributes, aHdRect, aHdRect); + drawFillAttributes(rRenderContext, maHeaderFillAttributes, aHdRect, aHdRect); } - if(bFooter) + if (bFooter) { // show footer if possible aFtRect.Left() += nFtLeft; @@ -237,31 +238,31 @@ void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool b aRect.Bottom() -= nFtHeight + nFtDist; // draw footer over PageFill, plus outline - drawFillAttributes(maFooterFillAttributes, aFtRect, aFtRect); + drawFillAttributes(rRenderContext, maFooterFillAttributes, aFtRect, aFtRect); } // draw page's reduced outline, only outline - drawFillAttributes(drawinglayer::attribute::SdrAllFillAttributesHelperPtr(), aRect, aRect); + drawFillAttributes(rRenderContext, drawinglayer::attribute::SdrAllFillAttributesHelperPtr(), aRect, aRect); } else { //UUUU draw PageFill and outline - drawFillAttributes(maPageFillAttributes, aRect, aRect); + drawFillAttributes(rRenderContext, maPageFillAttributes, aRect, aRect); } - if(bFrameDirection && !bTable) + if (bFrameDirection && !bTable) { Point aPos; - vcl::Font aFont(GetFont()); + vcl::Font aFont(rRenderContext.GetFont()); const Size aSaveSize = aFont.GetSize(); Size aDrawSize(0,aRect.GetHeight() / 6); aFont.SetSize(aDrawSize); - SetFont(aFont); + rRenderContext.SetFont(aFont); OUString sText("ABC"); - Point aMove(1, GetTextHeight()); + Point aMove(1, rRenderContext.GetTextHeight()); sal_Unicode cArrow = 0x2193; - long nAWidth = GetTextWidth(sText.copy(0,1)); - switch(nFrameDirection) + long nAWidth = rRenderContext.GetTextWidth(sText.copy(0,1)); + switch (nFrameDirection) { case FRMDIR_HORI_LEFT_TOP: aPos = aRect.TopLeft(); @@ -278,7 +279,7 @@ void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool b break; case FRMDIR_VERT_TOP_LEFT: aPos = aRect.TopLeft(); - aPos.X() += PixelToLogic(Point(1,1)).X(); + aPos.X() += rRenderContext.PixelToLogic(Point(1,1)).X(); aMove.X() = 0; break; case FRMDIR_VERT_TOP_RIGHT: @@ -288,19 +289,19 @@ void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool b break; } sText += OUString(cArrow); - for(sal_uInt16 i = 0; i < sText.getLength(); i++) + for (sal_uInt16 i = 0; i < sText.getLength(); i++) { OUString sDraw(sText.copy(i,1)); long nHDiff = 0; long nCharWidth = GetTextWidth(sDraw); bool bHorizontal = 0 == aMove.Y(); - if(!bHorizontal) + if (!bHorizontal) { nHDiff = (nAWidth - nCharWidth) / 2; aPos.X() += nHDiff; } - DrawText(aPos,sDraw); - if(bHorizontal) + rRenderContext.DrawText(aPos,sDraw); + if (bHorizontal) { aPos.X() += aMove.X() < 0 ? -nCharWidth : nCharWidth; } @@ -311,42 +312,44 @@ void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool b } } aFont.SetSize(aSaveSize); - SetFont(aFont); + rRenderContext.SetFont(aFont); } - if(bTable) + if (bTable) { // Paint Table, if necessary center it - SetLineColor(Color(COL_LIGHTGRAY)); + rRenderContext.SetLineColor(Color(COL_LIGHTGRAY)); - long nW = aRect.GetWidth(),nH = aRect.GetHeight(); - long nTW = CELL_WIDTH * 3,nTH = CELL_HEIGHT * 3; + long nW = aRect.GetWidth(); + long nH = aRect.GetHeight(); + long nTW = CELL_WIDTH * 3; + long nTH = CELL_HEIGHT * 3; long _nLeft = bHorz ? aRect.Left() + ((nW - nTW) / 2) : aRect.Left(); long _nTop = bVert ? aRect.Top() + ((nH - nTH) / 2) : aRect.Top(); - Rectangle aCellRect(Point(_nLeft,_nTop),Size(CELL_WIDTH,CELL_HEIGHT)); + Rectangle aCellRect(Point(_nLeft, _nTop),Size(CELL_WIDTH, CELL_HEIGHT)); - for(sal_uInt16 i = 0; i < 3; ++i) + for (sal_uInt16 i = 0; i < 3; ++i) { aCellRect.Left() = _nLeft; aCellRect.Right() = _nLeft + CELL_WIDTH; if(i > 0) aCellRect.Move(0,CELL_HEIGHT); - for(sal_uInt16 j = 0; j < 3; ++j) + for (sal_uInt16 j = 0; j < 3; ++j) { - if(j > 0) + if (j > 0) aCellRect.Move(CELL_WIDTH,0); - DrawRect(aCellRect); + rRenderContext.DrawRect(aCellRect); } } } } //UUUU -void SvxPageWindow::drawFillAttributes( - const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes, - const Rectangle& rPaintRange, - const Rectangle& rDefineRange) +void SvxPageWindow::drawFillAttributes(vcl::RenderContext& rRenderContext, + const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes, + const Rectangle& rPaintRange, + const Rectangle& rDefineRange) { const basegfx::B2DRange aPaintRange( rPaintRange.Left(), @@ -355,8 +358,8 @@ void SvxPageWindow::drawFillAttributes( rPaintRange.Bottom()); if(!aPaintRange.isEmpty() && - !basegfx::fTools::equalZero(aPaintRange.getWidth()) && - !basegfx::fTools::equalZero(aPaintRange.getHeight())) + !basegfx::fTools::equalZero(aPaintRange.getWidth()) && + !basegfx::fTools::equalZero(aPaintRange.getHeight())) { const basegfx::B2DRange aDefineRange( rDefineRange.Left(), @@ -368,45 +371,34 @@ void SvxPageWindow::drawFillAttributes( drawinglayer::primitive2d::Primitive2DSequence aSequence; // create fill geometry if there is something to fill - if(rFillAttributes.get() && rFillAttributes->isUsed()) + if (rFillAttributes.get() && rFillAttributes->isUsed()) { - aSequence = rFillAttributes->getPrimitive2DSequence( - aPaintRange, - aDefineRange); + aSequence = rFillAttributes->getPrimitive2DSequence(aPaintRange, aDefineRange); } // create line geometry if a LineColor is set at the target device - if(IsLineColor()) + if (rRenderContext.IsLineColor()) { const drawinglayer::primitive2d::Primitive2DReference xOutline( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( - basegfx::tools::createPolygonFromRect(aPaintRange), - GetLineColor().getBColor())); + basegfx::tools::createPolygonFromRect(aPaintRange), GetLineColor().getBColor())); - drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence( - aSequence, - xOutline); + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aSequence, xOutline); } // draw that if we have something to draw - if(aSequence.getLength()) + if (aSequence.getLength()) { const drawinglayer::geometry::ViewInformation2D aViewInformation2D( - basegfx::B2DHomMatrix(), - GetViewTransformation(), - aPaintRange, - 0, - 0.0, - com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >()); - drawinglayer::processor2d::BaseProcessor2D* pProcessor = drawinglayer::processor2d::createProcessor2DFromOutputDevice( - *this, - aViewInformation2D); - - if(pProcessor) + basegfx::B2DHomMatrix(), GetViewTransformation(), aPaintRange, 0, + 0.0, css::uno::Sequence<css::beans::PropertyValue >()); + + std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor; + pProcessor.reset(drawinglayer::processor2d::createProcessor2DFromOutputDevice(rRenderContext, aViewInformation2D)); + + if (pProcessor) { pProcessor->process(aSequence); - - delete pProcessor; } } } |