summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.cpp34
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.h1
2 files changed, 32 insertions, 3 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
index b5cfa7b..aca3103 100644
--- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
+++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
@@ -17,7 +17,7 @@
#include <boost/lexical_cast.hpp>
namespace Swift {
- WhiteboardParser::WhiteboardParser() : level_(0) {
+ WhiteboardParser::WhiteboardParser() : actualIsText(false), level_(0) {
}
void WhiteboardParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) {
@@ -167,7 +167,28 @@ namespace Swift {
getPayloadInternal()->setElement(whiteboardElement);
} else if (element == "text") {
- WhiteboardTextElement::ref whiteboardElement = boost::make_shared<WhiteboardTextElement>(0,0);
+ int x = 0;
+ int y = 0;
+ try {
+ x = boost::lexical_cast<int>(attributes.getAttributeValue("x").get_value_or("0"));
+ y = boost::lexical_cast<int>(attributes.getAttributeValue("y").get_value_or("0"));
+ } catch (boost::bad_lexical_cast&) {
+ }
+
+ WhiteboardTextElement::ref whiteboardElement = boost::make_shared<WhiteboardTextElement>(x, y);
+
+ actualIsText = true;
+ Color color(attributes.getAttributeValue("fill").get_value_or("#000000"));
+ color.setAlpha(opacityToAlpha(attributes.getAttributeValue("opacity").get_value_or("1")));
+ whiteboardElement->setColor(color);
+
+ int fontSize = 1;
+ try {
+ fontSize = boost::lexical_cast<int>(attributes.getAttributeValue("font-size").get_value_or("12"));
+ } catch (boost::bad_lexical_cast&) {
+ }
+ whiteboardElement->setSize(fontSize);
+
getPayloadInternal()->setElement(whiteboardElement);
} else if (element == "ellipse") {
int cx = 0;
@@ -208,11 +229,18 @@ namespace Swift {
--level_;
if (level_ == 0) {
getPayloadInternal()->setData(data_);
+ } else if (level_ == 1) {
+ if (element == "text") {
+ actualIsText = false;
+ }
}
}
void WhiteboardParser::handleCharacterData(const std::string& data) {
- data_ += data;
+ if (level_ == 2 && actualIsText) {
+ WhiteboardTextElement::ref element = boost::dynamic_pointer_cast<WhiteboardTextElement>(getPayloadInternal()->getElement());
+ element->setText(data);
+ }
}
WhiteboardPayload::Type WhiteboardParser::stringToType(const std::string& type) const {
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.h b/Swiften/Parser/PayloadParsers/WhiteboardParser.h
index dfb2236..7c93de3 100644
--- a/Swiften/Parser/PayloadParsers/WhiteboardParser.h
+++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.h
@@ -24,6 +24,7 @@ namespace Swift {
int opacityToAlpha(std::string opacity) const;
private:
+ bool actualIsText;
int level_;
std::string data_;
};