summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2011-09-06 13:29:32 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2011-09-06 13:29:32 +0200
commit851dee1cecbc7be8cb43b787a2d5aea11b4b533c (patch)
tree6048912a41cf00c0d503a4ae19513ad873208ceb
parent226511a59bfff28deaaf0207abdc87b6caafbd3d (diff)
TxtXform can but must not be present, so make it easy to detect whether it is
-rw-r--r--src/lib/VSDXContentCollector.cpp27
-rw-r--r--src/lib/VSDXContentCollector.h4
2 files changed, 19 insertions, 12 deletions
diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp
index 830ac16..000debb 100644
--- a/src/lib/VSDXContentCollector.cpp
+++ b/src/lib/VSDXContentCollector.cpp
@@ -52,7 +52,7 @@ libvisio::VSDXContentCollector::VSDXContentCollector(
m_painter(painter), m_isPageStarted(false), m_pageWidth(0.0), m_pageHeight(0.0),
m_shadowOffsetX(0.0), m_shadowOffsetY(0.0),
m_scale(1.0), m_x(0.0), m_y(0.0), m_originalX(0.0), m_originalY(0.0), m_xform(),
- m_txtxform(), m_currentGeometry(), m_groupXForms(groupXFormsSequence[0]),
+ m_txtxform(0), m_currentGeometry(), m_groupXForms(groupXFormsSequence[0]),
m_currentForeignData(), m_currentForeignProps(),
m_currentShapeId(0), m_foreignType(0), m_foreignFormat(0), m_styleProps(),
m_lineColour("black"), m_fillType("none"), m_linePattern(1),
@@ -129,15 +129,16 @@ void libvisio::VSDXContentCollector::_flushText()
double angle = 0.0;
transformAngle(angle);
- double x = m_txtxform.x; double y = m_txtxform.y + m_txtxform.height;
+ double x = m_txtxform ? m_txtxform->x : 0.0;
+ double y = m_txtxform ? m_txtxform->y : 0.0;
transformPoint(x,y);
WPXPropertyList textCoords;
textCoords.insert("svg:x", m_scale * x);
- textCoords.insert("svg:y", m_scale * y);
- textCoords.insert("svg:height", m_scale * (m_txtxform.height != 0.0 ? m_txtxform.height : m_xform.height));
- textCoords.insert("svg:width", m_scale * (m_xform.width - m_txtxform.x));
+ textCoords.insert("svg:y", m_scale * y - (m_txtxform ? m_txtxform->height : m_xform.height));
+ textCoords.insert("svg:height", m_scale * (m_txtxform ? m_txtxform->height : m_xform.height));
+ textCoords.insert("svg:width", m_scale * (m_xform.width - (m_txtxform ? m_txtxform->x : 0.0)));
textCoords.insert("libwpg:rotate", -angle*180/M_PI, WPX_GENERIC);
m_shapeOutput->addStartTextObject(textCoords, WPXPropertyListVector());
@@ -1033,9 +1034,11 @@ void libvisio::VSDXContentCollector::collectXFormData(unsigned /* id */, unsigne
void libvisio::VSDXContentCollector::collectTxtXForm(unsigned /* id */, unsigned level, const XForm &txtxform)
{
_handleLevelChange(level);
- m_txtxform = txtxform;
- m_txtxform.x = m_txtxform.pinX - m_txtxform.pinLocX;
- m_txtxform.y = m_txtxform.pinY - m_txtxform.pinLocY;
+ if (m_txtxform)
+ delete(m_txtxform);
+ m_txtxform = new XForm(txtxform);
+ m_txtxform->x = m_txtxform->pinX - m_txtxform->pinLocX;
+ m_txtxform->y = m_txtxform->pinY - m_txtxform->pinLocY;
}
void libvisio::VSDXContentCollector::transformPoint(double &x, double &y)
@@ -1621,7 +1624,9 @@ void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level)
}
m_originalX = 0.0; m_originalY = 0.0;
m_x = 0; m_y = 0;
- m_txtxform = XForm();
+ if (m_txtxform)
+ delete(m_txtxform);
+ m_txtxform = 0;
m_xform = XForm();
m_NURBSData.clear();
m_polylineData.clear();
@@ -1640,7 +1645,9 @@ void libvisio::VSDXContentCollector::startPage()
m_isShapeStarted = false;
}
m_originalX = 0.0; m_originalY = 0.0;
- m_txtxform = XForm();
+ if (m_txtxform)
+ delete(m_txtxform);
+ m_txtxform = 0;
m_xform = XForm();
m_x = 0; m_y = 0;
m_currentPageNumber++;
diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h
index 52c39eb..e5f065f 100644
--- a/src/lib/VSDXContentCollector.h
+++ b/src/lib/VSDXContentCollector.h
@@ -57,7 +57,7 @@ public:
std::vector<std::list<unsigned> > &documentPageShapeOrders,
VSDXStyles &styles, VSDXStencils &stencils
);
- virtual ~VSDXContentCollector() {};
+ virtual ~VSDXContentCollector() { if (m_txtxform) delete(m_txtxform); };
void collectEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc);
void collectForeignData(unsigned id, unsigned level, const WPXBinaryData &binaryData);
@@ -147,7 +147,7 @@ private:
double m_originalX;
double m_originalY;
XForm m_xform;
- XForm m_txtxform;
+ XForm *m_txtxform;
std::vector<WPXPropertyList> m_currentGeometry;
std::map<unsigned, XForm> &m_groupXForms;
WPXBinaryData m_currentForeignData;