diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-26 10:18:33 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-26 10:20:55 (GMT) |
commit | 99bc38e1d21b0081618485e49b0ab1bcd5bef22f (patch) | |
tree | 36a15ffaaa09832234d4296d926b3244a5952bfd /Swiften/Parser | |
parent | 06bbc72598ece3e62b82471e474b0753d5439f00 (diff) | |
download | swift-contrib-99bc38e1d21b0081618485e49b0ab1bcd5bef22f.zip swift-contrib-99bc38e1d21b0081618485e49b0ab1bcd5bef22f.tar.bz2 |
Added handling of circles(ellipses)
Diffstat (limited to 'Swiften/Parser')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index d1d57a0..b5cfa7b 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -9,6 +9,7 @@ #include <Swiften/Whiteboard/Elements/WhiteboardRectElement.h> #include <Swiften/Whiteboard/Elements/WhiteboardTextElement.h> #include <Swiften/Whiteboard/Elements/WhiteboardPolygonElement.h> +#include <Swiften/Whiteboard/Elements/WhiteboardEllipseElement.h> #include <Swiften/Whiteboard/Elements/WhiteboardFreehandPathElement.h> #include <Swiften/Whiteboard/Elements/Color.h> #include <boost/optional.hpp> @@ -168,6 +169,36 @@ namespace Swift { } else if (element == "text") { WhiteboardTextElement::ref whiteboardElement = boost::make_shared<WhiteboardTextElement>(0,0); getPayloadInternal()->setElement(whiteboardElement); + } else if (element == "ellipse") { + int cx = 0; + int cy = 0; + int rx = 0; + int ry = 0; + try { + cx = boost::lexical_cast<int>(attributes.getAttributeValue("cx").get_value_or("0")); + cy = boost::lexical_cast<int>(attributes.getAttributeValue("cy").get_value_or("0")); + rx = boost::lexical_cast<int>(attributes.getAttributeValue("rx").get_value_or("0")); + ry = boost::lexical_cast<int>(attributes.getAttributeValue("ry").get_value_or("0")); + } catch (boost::bad_lexical_cast&) { + } + + WhiteboardEllipseElement::ref whiteboardElement = boost::make_shared<WhiteboardEllipseElement>(cx, cy, rx, ry); + + int penWidth = 1; + try { + penWidth = boost::lexical_cast<int>(attributes.getAttributeValue("stroke-width").get_value_or("1")); + } catch (boost::bad_lexical_cast&) { + } + whiteboardElement->setPenWidth(penWidth); + + Color penColor(attributes.getAttributeValue("stroke").get_value_or("#000000")); + Color brushColor(attributes.getAttributeValue("fill").get_value_or("#000000")); + penColor.setAlpha(opacityToAlpha(attributes.getAttributeValue("opacity").get_value_or("1"))); + brushColor.setAlpha(opacityToAlpha(attributes.getAttributeValue("fill-opacity").get_value_or("1"))); + whiteboardElement->setPenColor(penColor); + whiteboardElement->setBrushColor(brushColor); + + getPayloadInternal()->setElement(whiteboardElement); } } ++level_; |