diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-03-22 10:16:39 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-03-26 01:30:31 +0100 |
commit | d3922a93a096e07ab54e91fd0dd7c86302f33b78 (patch) | |
tree | 7469ce6ac7ad379d39b9c38bb0b9bd590b7b54b2 /vcl/source | |
parent | 068880d65081ec2db1af7643fcb9a3680b3119c0 (diff) |
Rename DrawCommand* to WidgetDrawAction*, remove unused circ draw
Change-Id: Icef900e75255d477812a198fdb29e0cdebba35b8
Reviewed-on: https://gerrit.libreoffice.org/69654
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 99 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinition.cxx | 31 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinitionReader.cxx | 25 |
3 files changed, 48 insertions, 107 deletions
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 1263c1a12aee..0cfe446f53a3 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -253,97 +253,76 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics } } -void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCommands, +void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDrawActions, SalGraphics& rGraphics, long nX, long nY, long nWidth, long nHeight) { - for (std::shared_ptr<DrawCommand> const& pDrawCommand : rDrawCommands) + for (std::shared_ptr<WidgetDrawAction> const& pDrawAction : rDrawActions) { - switch (pDrawCommand->maType) + switch (pDrawAction->maType) { - case DrawCommandType::RECTANGLE: + case WidgetDrawActionType::RECTANGLE: { - auto const& rRectDrawCommand - = static_cast<RectangleDrawCommand const&>(*pDrawCommand); + auto const& rWidgetDraw + = static_cast<WidgetDrawActionRectangle const&>(*pDrawAction); basegfx::B2DRectangle rRect( - nX + (nWidth * rRectDrawCommand.mfX1), nY + (nHeight * rRectDrawCommand.mfY1), - nX + (nWidth * rRectDrawCommand.mfX2), nY + (nHeight * rRectDrawCommand.mfY2)); + nX + (nWidth * rWidgetDraw.mfX1), nY + (nHeight * rWidgetDraw.mfY1), + nX + (nWidth * rWidgetDraw.mfX2), nY + (nHeight * rWidgetDraw.mfY2)); basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect( - rRect, rRectDrawCommand.mnRx / rRect.getWidth() * 2.0, - rRectDrawCommand.mnRy / rRect.getHeight() * 2.0); + rRect, rWidgetDraw.mnRx / rRect.getWidth() * 2.0, + rWidgetDraw.mnRy / rRect.getHeight() * 2.0); rGraphics.SetLineColor(); - rGraphics.SetFillColor(rRectDrawCommand.maFillColor); + rGraphics.SetFillColor(rWidgetDraw.maFillColor); rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f, nullptr); - rGraphics.SetLineColor(rRectDrawCommand.maStrokeColor); + rGraphics.SetLineColor(rWidgetDraw.maStrokeColor); rGraphics.SetFillColor(); - rGraphics.DrawPolyLine(basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, - basegfx::B2DVector(rRectDrawCommand.mnStrokeWidth, - rRectDrawCommand.mnStrokeWidth), - basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, - 0.0f, false, nullptr); + rGraphics.DrawPolyLine( + basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, + basegfx::B2DVector(rWidgetDraw.mnStrokeWidth, rWidgetDraw.mnStrokeWidth), + basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, nullptr); } break; - case DrawCommandType::CIRCLE: + case WidgetDrawActionType::LINE: { - auto const& rCircleDrawCommand - = static_cast<CircleDrawCommand const&>(*pDrawCommand); - - basegfx::B2DRectangle rRect(nX + (nWidth * rCircleDrawCommand.mfX1), - nY + (nHeight * rCircleDrawCommand.mfY1), - nX + (nWidth * rCircleDrawCommand.mfX2), - nY + (nHeight * rCircleDrawCommand.mfY2)); - - basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromEllipse( - rRect.getCenter(), rRect.getWidth() / 2.0, rRect.getHeight() / 2.0); - - rGraphics.SetLineColor(rCircleDrawCommand.maStrokeColor); - rGraphics.SetFillColor(rCircleDrawCommand.maFillColor); - rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), - basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f, nullptr); - } - break; - case DrawCommandType::LINE: - { - auto const& rLineDrawCommand = static_cast<LineDrawCommand const&>(*pDrawCommand); + auto const& rWidgetDraw = static_cast<WidgetDrawActionLine const&>(*pDrawAction); Point aRectPoint(nX + 1, nY + 1); Size aRectSize(nWidth - 1, nHeight - 1); rGraphics.SetFillColor(); - rGraphics.SetLineColor(rLineDrawCommand.maStrokeColor); + rGraphics.SetLineColor(rWidgetDraw.maStrokeColor); basegfx::B2DPolygon aB2DPolygon{ - { aRectPoint.X() + (aRectSize.Width() * rLineDrawCommand.mfX1), - aRectPoint.Y() + (aRectSize.Height() * rLineDrawCommand.mfY1) }, - { aRectPoint.X() + (aRectSize.Width() * rLineDrawCommand.mfX2), - aRectPoint.Y() + (aRectSize.Height() * rLineDrawCommand.mfY2) }, + { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX1), + aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY1) }, + { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX2), + aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY2) }, }; - rGraphics.DrawPolyLine(basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, - basegfx::B2DVector(rLineDrawCommand.mnStrokeWidth, - rLineDrawCommand.mnStrokeWidth), - basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, - 0.0f, false, nullptr); + rGraphics.DrawPolyLine( + basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, + basegfx::B2DVector(rWidgetDraw.mnStrokeWidth, rWidgetDraw.mnStrokeWidth), + basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, nullptr); } break; - case DrawCommandType::IMAGE: + case WidgetDrawActionType::IMAGE: { - double nScaleFactor = 1.0; + double nScaleFactor = 2.0; if (comphelper::LibreOfficeKit::isActive()) nScaleFactor = comphelper::LibreOfficeKit::getDPIScale(); - auto const& rDrawCommand = static_cast<ImageDrawCommand const&>(*pDrawCommand); + auto const& rWidgetDraw = static_cast<WidgetDrawActionImage const&>(*pDrawAction); auto& rCacheImages = ImplGetSVData()->maGDIData.maThemeImageCache; - OUString rCacheKey = rDrawCommand.msSource + "@" + OUString::number(nScaleFactor); + OUString rCacheKey = rWidgetDraw.msSource + "@" + OUString::number(nScaleFactor); auto& aIterator = rCacheImages.find(rCacheKey); BitmapEx aBitmap; if (aIterator == rCacheImages.end()) { - SvFileStream aFileStream(rDrawCommand.msSource, StreamMode::READ); + SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ); vcl::bitmap::loadFromSvg(aFileStream, "", aBitmap, nScaleFactor); if (!!aBitmap) @@ -377,19 +356,20 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom } } break; - case DrawCommandType::EXTERNAL: + case WidgetDrawActionType::EXTERNAL: { - auto const& rDrawCommand = static_cast<ImageDrawCommand const&>(*pDrawCommand); + auto const& rWidgetDraw + = static_cast<WidgetDrawActionExternal const&>(*pDrawAction); auto& rCacheDrawCommands = ImplGetSVData()->maGDIData.maThemeDrawCommandsCache; - auto& aIterator = rCacheDrawCommands.find(rDrawCommand.msSource); + auto& aIterator = rCacheDrawCommands.find(rWidgetDraw.msSource); gfx::DrawRoot aDrawRoot; if (aIterator == rCacheDrawCommands.end()) { - SvFileStream aFileStream(rDrawCommand.msSource, StreamMode::READ); + SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ); uno::Reference<uno::XComponentContext> xContext( comphelper::getProcessComponentContext()); @@ -412,7 +392,7 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom if (pDrawRoot) { rCacheDrawCommands.insert( - std::make_pair(rDrawCommand.msSource, *pDrawRoot)); + std::make_pair(rWidgetDraw.msSource, *pDrawRoot)); drawFromDrawCommands(*pDrawRoot, rGraphics, nX, nY, nWidth, nHeight); } } @@ -444,7 +424,8 @@ bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart // use last defined state auto const& pState = aStates.back(); { - munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight); + munchDrawCommands(pState->mpWidgetDrawActions, m_rGraphics, nX, nY, nWidth, + nHeight); bOK = true; } } diff --git a/vcl/source/gdi/WidgetDefinition.cxx b/vcl/source/gdi/WidgetDefinition.cxx index 668fe74bf403..6eb6ae7fa3ac 100644 --- a/vcl/source/gdi/WidgetDefinition.cxx +++ b/vcl/source/gdi/WidgetDefinition.cxx @@ -134,7 +134,7 @@ void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStro Color aFillColor, float fX1, float fY1, float fX2, float fY2, sal_Int32 nRx, sal_Int32 nRy) { - auto pCommand(std::make_shared<RectangleDrawCommand>()); + auto pCommand(std::make_shared<WidgetDrawActionRectangle>()); pCommand->maStrokeColor = aStrokeColor; pCommand->maFillColor = aFillColor; pCommand->mnStrokeWidth = nStrokeWidth; @@ -144,49 +144,34 @@ void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStro pCommand->mfY1 = fY1; pCommand->mfX2 = fX2; pCommand->mfY2 = fY2; - mpDrawCommands.push_back(std::move(pCommand)); -} - -void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, - Color aFillColor, float fX1, float fY1, float fX2, - float fY2) -{ - auto pCommand(std::make_shared<CircleDrawCommand>()); - pCommand->maStrokeColor = aStrokeColor; - pCommand->maFillColor = aFillColor; - pCommand->mnStrokeWidth = nStrokeWidth; - pCommand->mfX1 = fX1; - pCommand->mfY1 = fY1; - pCommand->mfX2 = fX2; - pCommand->mfY2 = fY2; - mpDrawCommands.push_back(std::move(pCommand)); + mpWidgetDrawActions.push_back(std::move(pCommand)); } void WidgetDefinitionState::addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2, float fY2) { - auto pCommand(std::make_shared<LineDrawCommand>()); + auto pCommand(std::make_shared<WidgetDrawActionLine>()); pCommand->maStrokeColor = aStrokeColor; pCommand->mnStrokeWidth = nStrokeWidth; pCommand->mfX1 = fX1; pCommand->mfY1 = fY1; pCommand->mfX2 = fX2; pCommand->mfY2 = fY2; - mpDrawCommands.push_back(std::move(pCommand)); + mpWidgetDrawActions.push_back(std::move(pCommand)); } void WidgetDefinitionState::addDrawImage(OUString const& sSource) { - auto pCommand(std::make_shared<ImageDrawCommand>()); + auto pCommand(std::make_shared<WidgetDrawActionImage>()); pCommand->msSource = sSource; - mpDrawCommands.push_back(std::move(pCommand)); + mpWidgetDrawActions.push_back(std::move(pCommand)); } void WidgetDefinitionState::addDrawExternal(OUString const& sSource) { - auto pCommand(std::make_unique<ExternalSourceDrawCommand>()); + auto pCommand(std::make_unique<WidgetDrawActionExternal>()); pCommand->msSource = sSource; - mpDrawCommands.push_back(std::move(pCommand)); + mpWidgetDrawActions.push_back(std::move(pCommand)); } } // end vcl namespace diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx index c183cb717e9c..f825addd0042 100644 --- a/vcl/source/gdi/WidgetDefinitionReader.cxx +++ b/vcl/source/gdi/WidgetDefinitionReader.cxx @@ -226,31 +226,6 @@ void WidgetDefinitionReader::readDrawingDefinition(tools::XmlWalker& rWalker, rpState->addDrawRectangle(aStrokeColor, nStrokeWidth, aFillColor, fX1, fY1, fX2, fY2, nRx, nRy); } - else if (rWalker.name() == "circ") - { - Color aStrokeColor; - readColor(rWalker.attribute("stroke"), aStrokeColor); - Color aFillColor; - readColor(rWalker.attribute("fill"), aFillColor); - OString sStrokeWidth = rWalker.attribute("stroke-width"); - sal_Int32 nStrokeWidth = -1; - if (!sStrokeWidth.isEmpty()) - nStrokeWidth = sStrokeWidth.toInt32(); - - OString sX1 = rWalker.attribute("x1"); - float fX1 = sX1.isEmpty() ? 0.0 : sX1.toFloat(); - - OString sY1 = rWalker.attribute("y1"); - float fY1 = sY1.isEmpty() ? 0.0 : sY1.toFloat(); - - OString sX2 = rWalker.attribute("x2"); - float fX2 = sX2.isEmpty() ? 1.0 : sX2.toFloat(); - - OString sY2 = rWalker.attribute("y2"); - float fY2 = sY2.isEmpty() ? 1.0 : sY2.toFloat(); - - rpState->addDrawCircle(aStrokeColor, nStrokeWidth, aFillColor, fX1, fY1, fX2, fY2); - } else if (rWalker.name() == "line") { Color aStrokeColor; |