diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-02-24 18:08:38 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-03-06 16:33:06 +0100 |
commit | 7894fd2b442eff45ecf14088ebd17ee9f8678752 (patch) | |
tree | cf1525a0c7118b6c84a0abd555a36277f8d8e91b /svgio/inc | |
parent | de5dc664fc923b9704860f51267c438cad28cbe4 (diff) |
svgio visitor, add draw commands and create the from svg
Adds a visitor for svgio for visiting svg nodes and create something
useful from them.
Basic draw commands - a tree of draw commands (with sub-pixel
precision support) just to store a simple definition for drawing.
Adds a svg draw visitor and create draw commands from the svg
structure and expose the commands through UNO API.
Change-Id: I073e891a2cffdd76d4e3b838590e3a19c998e9bf
Reviewed-on: https://gerrit.libreoffice.org/68770
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svgio/inc')
-rw-r--r-- | svgio/inc/svgnode.hxx | 12 | ||||
-rw-r--r-- | svgio/inc/svgvisitor.hxx | 41 |
2 files changed, 53 insertions, 0 deletions
diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx index 22df883b22b3..c10179bf236a 100644 --- a/svgio/inc/svgnode.hxx +++ b/svgio/inc/svgnode.hxx @@ -80,6 +80,8 @@ namespace svgio // which members should be initialized Display getDisplayFromContent(const OUString& aContent); + class Visitor; + class SvgNode : public InfoProvider { private: @@ -137,6 +139,8 @@ namespace svgio SvgNode(const SvgNode&) = delete; SvgNode& operator=(const SvgNode&) = delete; + void accept(Visitor& rVisitor); + /// scan helper to read and interpret a local CssStyle to mpLocalCssStyle void readLocalCssStyle(const OUString& aContent); @@ -182,6 +186,14 @@ namespace svgio /// alternative parent void setAlternativeParent(const SvgNode* pAlternativeParent = nullptr) { mpAlternativeParent = pAlternativeParent; } }; + + class Visitor + { + public: + virtual ~Visitor() = default; + virtual void visit(SvgNode const & pNode) = 0; + }; + } // end of namespace svgreader } // end of namespace svgio diff --git a/svgio/inc/svgvisitor.hxx b/svgio/inc/svgvisitor.hxx new file mode 100644 index 000000000000..ea56e4cd189a --- /dev/null +++ b/svgio/inc/svgvisitor.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef INCLUDED_SVGIO_INC_SVGVISITOR_HXX +#define INCLUDED_SVGIO_INC_SVGVISITOR_HXX + +#include <basegfx/DrawCommands.hxx> +#include <memory> +#include "svgnode.hxx" + +namespace svgio +{ +namespace svgreader +{ +class SvgDrawVisitor : public Visitor +{ +private: + std::shared_ptr<DrawRoot> mpDrawRoot; + std::shared_ptr<DrawBase> mpCurrent; + +public: + SvgDrawVisitor(); + + void visit(svgio::svgreader::SvgNode const& rNode) override; + void goToChildren(svgio::svgreader::SvgNode const& rNode); + + std::shared_ptr<DrawRoot> const& getDrawRoot() { return mpDrawRoot; } +}; +} +} + +#endif // INCLUDED_SVGIO_INC_SVGVISITOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |