diff options
Diffstat (limited to 'Swiften/Parser')
-rw-r--r-- | Swiften/Parser/PayloadParsers/WhiteboardParser.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp index 037eae2..5d4aef1 100644 --- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp +++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp @@ -13,6 +13,7 @@ #include <Swiften/Whiteboard/Elements/WhiteboardFreehandPathElement.h> #include <Swiften/Whiteboard/Elements/Color.h> #include <Swiften/Whiteboard/Operations/WhiteboardInsertOperation.h> +#include <Swiften/Whiteboard/Operations/WhiteboardUpdateOperation.h> #include <boost/optional.hpp> #include <boost/smart_ptr/make_shared.hpp> #include <boost/lexical_cast.hpp> @@ -35,6 +36,15 @@ namespace Swift { } catch (boost::bad_lexical_cast&) { } operation = insertOp; + } else if (type == "update") { + WhiteboardUpdateOperation::ref updateOp = boost::make_shared<WhiteboardUpdateOperation>(); + try { + updateOp->setID(attributes.getAttributeValue("id").get_value_or("")); + updateOp->setParentID(attributes.getAttributeValue("parentid").get_value_or("")); + updateOp->setPos(boost::lexical_cast<int>(attributes.getAttributeValue("pos").get_value_or("0"))); + } catch (boost::bad_lexical_cast&) { + } + operation = updateOp; } } else if (level_ == 2) { if (element == "line") { @@ -42,15 +52,21 @@ namespace Swift { int y1 = 0; int x2 = 0; int y2 = 0; + int xShift = 0; + int yShift = 0; try { x1 = boost::lexical_cast<int>(attributes.getAttributeValue("x1").get_value_or("0")); y1 = boost::lexical_cast<int>(attributes.getAttributeValue("y1").get_value_or("0")); x2 = boost::lexical_cast<int>(attributes.getAttributeValue("x2").get_value_or("0")); y2 = boost::lexical_cast<int>(attributes.getAttributeValue("y2").get_value_or("0")); + xShift = boost::lexical_cast<int>(attributes.getAttributeValue("xshift").get_value_or("0")); + yShift = boost::lexical_cast<int>(attributes.getAttributeValue("yshift").get_value_or("0")); } catch (boost::bad_lexical_cast&) { } WhiteboardLineElement::ref whiteboardElement = boost::make_shared<WhiteboardLineElement>(x1, y1, x2, y2); + whiteboardElement->setShift(xShift, yShift); + Color color(attributes.getAttributeValue("stroke").get_value_or("#000000")); color.setAlpha(opacityToAlpha(attributes.getAttributeValue("opacity").get_value_or("1"))); whiteboardElement->setColor(color); @@ -253,6 +269,11 @@ namespace Swift { if (insertOp) { insertOp->setElement(wbElement); } + + WhiteboardUpdateOperation::ref updateOp = boost::dynamic_pointer_cast<WhiteboardUpdateOperation>(operation); + if (updateOp) { + updateOp->setElement(wbElement); + } getPayloadInternal()->setOperation(operation); } else if (level_ == 2) { if (element == "text") { |