diff options
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 20 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinition.cxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinitionReader.cxx | 17 |
3 files changed, 38 insertions, 6 deletions
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 6681d2190dd2..a615bd390c81 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -18,6 +18,10 @@ #include <basegfx/range/b2drectangle.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> +#include <tools/stream.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/BitmapTools.hxx> + namespace vcl { namespace @@ -34,7 +38,8 @@ OUString lcl_getThemeDefinitionPath() FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics) : m_rGraphics(rGraphics) { - WidgetDefinitionReader aReader(lcl_getThemeDefinitionPath() + "definition.xml"); + OUString sDefinitionBasePath = lcl_getThemeDefinitionPath(); + WidgetDefinitionReader aReader(sDefinitionBasePath + "definition.xml", sDefinitionBasePath); aReader.read(m_aWidgetDefinition); ImplSVData* pSVData = ImplGetSVData(); @@ -171,6 +176,19 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom 0.0f, false, nullptr); } break; + case DrawCommandType::IMAGE: + { + auto const& rDrawCommand = static_cast<ImageDrawCommand const&>(*pDrawCommand); + SvFileStream aFileStream(rDrawCommand.msSource, StreamMode::READ); + BitmapEx aBitmap; + vcl::bitmap::loadFromSvg(aFileStream, "", aBitmap, 1.0); + long nImageWidth = aBitmap.GetSizePixel().Width(); + long nImageHeight = aBitmap.GetSizePixel().Height(); + SalTwoRect aTR(0, 0, nImageWidth, nImageHeight, nX, nY, nImageWidth, nImageHeight); + rGraphics.DrawBitmap(aTR, *aBitmap.GetBitmap().ImplGetSalBitmap().get(), + *aBitmap.GetAlpha().ImplGetSalBitmap().get(), nullptr); + } + break; } } } diff --git a/vcl/source/gdi/WidgetDefinition.cxx b/vcl/source/gdi/WidgetDefinition.cxx index 2cff3aedd36e..defcf0b84cd8 100644 --- a/vcl/source/gdi/WidgetDefinition.cxx +++ b/vcl/source/gdi/WidgetDefinition.cxx @@ -132,6 +132,13 @@ void WidgetDefinitionState::addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWid mpDrawCommands.push_back(std::move(pCommand)); } +void WidgetDefinitionState::addDrawImage(OUString sSource) +{ + auto pCommand(std::make_shared<ImageDrawCommand>()); + pCommand->msSource = sSource; + mpDrawCommands.push_back(std::move(pCommand)); +} + } // end vcl namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx index f37385cc09b9..72bd5649d4db 100644 --- a/vcl/source/gdi/WidgetDefinitionReader.cxx +++ b/vcl/source/gdi/WidgetDefinitionReader.cxx @@ -164,8 +164,10 @@ bool getControlTypeForXmlString(OString const& rString, ControlType& reType) } // end anonymous namespace -WidgetDefinitionReader::WidgetDefinitionReader(OUString const& rFilePath) - : m_rFilePath(rFilePath) +WidgetDefinitionReader::WidgetDefinitionReader(OUString const& rDefinitionFile, + OUString const& rResourcePath) + : m_rDefinitionFile(rDefinitionFile) + , m_rResourcePath(rResourcePath) { } @@ -260,7 +262,12 @@ void WidgetDefinitionReader::readDrawingDefinition(tools::XmlWalker& rWalker, rpState->addDrawLine(aStrokeColor, nStrokeWidth, fX1, fY1, fX2, fY2); } - + else if (rWalker.name() == "image") + { + OString sSource = rWalker.attribute("source"); + rpState->addDrawImage(m_rResourcePath + + OStringToOUString(sSource, RTL_TEXTENCODING_UTF8)); + } rWalker.next(); } rWalker.parent(); @@ -313,10 +320,10 @@ void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker, bool WidgetDefinitionReader::read(WidgetDefinition& rWidgetDefinition) { - if (!lcl_fileExists(m_rFilePath)) + if (!lcl_fileExists(m_rDefinitionFile)) return false; - SvFileStream aFileStream(m_rFilePath, StreamMode::READ); + SvFileStream aFileStream(m_rDefinitionFile, StreamMode::READ); std::unordered_map<OString, Color*> aStyleColorMap = { { "faceColor", &rWidgetDefinition.maFaceColor }, |