From 3cecd5ac1183ed8ed9ee92bae33ff231a84bb781 Mon Sep 17 00:00:00 2001 From: ALONSO Laurent Date: Tue, 9 Apr 2019 13:26:17 +0200 Subject: iwa[shape]: when size is empty, use path's size... Change-Id: I19dcdcd78dbbe98dce157a9296337a28d4232e90 --- src/lib/IWAParser.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib/IWAParser.cpp b/src/lib/IWAParser.cpp index e7be74c..6c41b7f 100644 --- a/src/lib/IWAParser.cpp +++ b/src/lib/IWAParser.cpp @@ -1167,8 +1167,26 @@ bool IWAParser::parseDrawableShape(const IWAMessage &msg, bool isConnectionLine) if (shape) { const optional &placement = get(shape).message(1).optional(); + const optional &path = get(shape).message(3).optional(); if (placement) - parseShapePlacement(get(placement)); + { + IWORKGeometryPtr_t geometry; + parseShapePlacement(get(placement), geometry); + if (geometry && (geometry->m_naturalSize.m_width<=0 || geometry->m_naturalSize.m_height<=0) && path) + { + // try to retrieve the shape's size in the path + std::map const cIdToSizeId= { { 3, 3}, { 4, 3}, {5, 2}, { 6, 1}, { 8, 2} }; + for (auto const it : cIdToSizeId) + { + if (!get(path).message(it.first)) continue; + auto const &pathSize=readSize(get(get(path).message(it.first)), it.second); + if (!pathSize || pathSize->m_width<=0 || pathSize->m_height<=0) continue; + geometry->m_naturalSize=geometry->m_size=get(pathSize); + break; + } + } + m_collector.collectGeometry(geometry); + } IWORKStylePtr_t style; const optional styleRef = readRef(get(shape), 2); @@ -1188,7 +1206,6 @@ bool IWAParser::parseDrawableShape(const IWAMessage &msg, bool isConnectionLine) if (style) m_collector.setGraphicStyle(style); - const optional &path = get(shape).message(3).optional(); if (path) { if (get(path).message(3)) // point path -- cgit v1.2.3