diff options
-rw-r--r-- | src/lib/VSD11Parser.cpp | 74 | ||||
-rw-r--r-- | src/lib/VSD6Parser.cpp | 6 | ||||
-rw-r--r-- | src/lib/VSD6Parser.h | 2 | ||||
-rw-r--r-- | src/lib/VSDInternalStream.cpp | 210 | ||||
-rw-r--r-- | src/lib/VSDInternalStream.h | 32 | ||||
-rw-r--r-- | src/lib/VSDSVGGenerator.cpp | 394 | ||||
-rw-r--r-- | src/lib/VSDSVGGenerator.h | 58 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.cpp | 10 | ||||
-rw-r--r-- | src/lib/VSDXContentCollector.h | 2 | ||||
-rw-r--r-- | src/lib/VSDXDocumentStructure.h | 2 | ||||
-rw-r--r-- | src/lib/VSDXOutputElement.cpp | 16 | ||||
-rw-r--r-- | src/lib/VSDXParser.cpp | 2 | ||||
-rw-r--r-- | src/lib/VSDXParser.h | 4 | ||||
-rw-r--r-- | src/lib/VSDXStylesCollector.h | 2 | ||||
-rw-r--r-- | src/lib/VisioDocument.cpp | 24 | ||||
-rw-r--r-- | src/lib/VisioDocument.h | 14 | ||||
-rw-r--r-- | src/lib/libvisio.h | 2 | ||||
-rw-r--r-- | src/lib/libvisio_utils.cpp | 64 | ||||
-rw-r--r-- | src/lib/libvisio_utils.h | 24 |
19 files changed, 470 insertions, 472 deletions
diff --git a/src/lib/VSD11Parser.cpp b/src/lib/VSD11Parser.cpp index 22150c8..5af4320 100644 --- a/src/lib/VSD11Parser.cpp +++ b/src/lib/VSD11Parser.cpp @@ -74,7 +74,7 @@ bool libvisio::VSD11Parser::parse() delete trailerStream; return false; } - + delete trailerStream; return true; } @@ -106,20 +106,20 @@ bool libvisio::VSD11Parser::parseDocument(WPXInputStream *input) m_input->seek(ptrOffset, WPX_SEEK_SET); WPXInputStream *tmpInput = new VSDInternalStream(m_input, ptrLength, compressed); - switch (ptrType) - { + switch (ptrType) + { case VSD_PAGE: - handlePage(tmpInput); - break; - case VSD_PAGES: - handlePages(tmpInput); - break; - case VSD_COLORS: - readColours(tmpInput); - break; - default: - break; - } + handlePage(tmpInput); + break; + case VSD_PAGES: + handlePages(tmpInput); + break; + case VSD_COLORS: + readColours(tmpInput); + break; + default: + break; + } delete tmpInput; } @@ -197,20 +197,20 @@ void libvisio::VSD11Parser::handlePages(WPXInputStream *input) m_input->seek(ptrOffset, WPX_SEEK_SET); WPXInputStream *tmpInput = new VSDInternalStream(m_input, ptrLength, compressed); - switch (ptrType) - { + switch (ptrType) + { case VSD_PAGE: - handlePage(tmpInput); - break; - case VSD_PAGES: - handlePages(tmpInput); - break; - case VSD_COLORS: - readColours(tmpInput); - break; - default: - break; - } + handlePage(tmpInput); + break; + case VSD_PAGES: + handlePages(tmpInput); + break; + case VSD_COLORS: + readColours(tmpInput); + break; + default: + break; + } delete tmpInput; } @@ -219,7 +219,7 @@ void libvisio::VSD11Parser::handlePages(WPXInputStream *input) void libvisio::VSD11Parser::handlePage(WPXInputStream *input) { long endPos = 0; - + m_collector->startPage(); while (!input->atEOS()) @@ -231,11 +231,11 @@ void libvisio::VSD11Parser::handlePage(WPXInputStream *input) VSD_DEBUG_MSG(("Shape: parsing chunk type %x\n", m_header.chunkType)); switch (m_header.chunkType) { - case VSD_SHAPE_GROUP: - case VSD_SHAPE_SHAPE: - case VSD_SHAPE_FOREIGN: - readShape(input); - break; + case VSD_SHAPE_GROUP: + case VSD_SHAPE_SHAPE: + case VSD_SHAPE_FOREIGN: + readShape(input); + break; case VSD_XFORM_DATA: readXFormData(input); break; @@ -275,10 +275,10 @@ void libvisio::VSD11Parser::handlePage(WPXInputStream *input) case VSD_FOREIGN_DATA: readForeignData(input); break; - case VSD_PAGE_PROPS: - readPageProps(input); - default: - m_collector->collectUnhandledChunk(m_header.id, m_header.level); + case VSD_PAGE_PROPS: + readPageProps(input); + default: + m_collector->collectUnhandledChunk(m_header.id, m_header.level); } input->seek(endPos, WPX_SEEK_SET); diff --git a/src/lib/VSD6Parser.cpp b/src/lib/VSD6Parser.cpp index 257325e..3fd04b8 100644 --- a/src/lib/VSD6Parser.cpp +++ b/src/lib/VSD6Parser.cpp @@ -195,7 +195,7 @@ void libvisio::VSD6Parser::handlePage(WPXInputStream *input) unsigned int list = readU32(input); unsigned int trailer = 0; if (list != 0 || chunkType == 0x71 || chunkType == 0x70 || - chunkType == 0x6b || chunkType == 0x6a || chunkType == 0x69 || + chunkType == 0x6b || chunkType == 0x6a || chunkType == 0x69 || chunkType == 0x66 || chunkType == 0x65 || chunkType == 0x2c) trailer += 8; // 8 byte trailer @@ -235,7 +235,7 @@ void libvisio::VSD6Parser::handlePage(WPXInputStream *input) WPXBinaryData binaryData; if (foreignType == 1) - { + { // v6 always uses bmp for images which needs header reconstruction binaryData.append(0x42); binaryData.append(0x4d); @@ -263,7 +263,7 @@ void libvisio::VSD6Parser::handlePage(WPXInputStream *input) foreignProps.insert("svg:height", m_scale*xform.height); foreignProps.insert("svg:x", m_scale*(xform.pinX - xform.pinLocX)); // Y axis starts at the bottom not top - foreignProps.insert("svg:y", m_scale*(pageProps["svg:height"]->getDouble() + foreignProps.insert("svg:y", m_scale*(pageProps["svg:height"]->getDouble() - xform.pinY + xform.pinLocY - xform.height)); if (foreignType == 1) diff --git a/src/lib/VSD6Parser.h b/src/lib/VSD6Parser.h index 4000acf..e7d0007 100644 --- a/src/lib/VSD6Parser.h +++ b/src/lib/VSD6Parser.h @@ -44,7 +44,7 @@ private: static const StreamHandler handlers[]; void handlePages(WPXInputStream *input); void handlePage(WPXInputStream *input); - + bool getChunkHeader(WPXInputStream *input) { return false; } bool m_isPageStarted; diff --git a/src/lib/VSDInternalStream.cpp b/src/lib/VSDInternalStream.cpp index 26813b2..5a8909d 100644 --- a/src/lib/VSDInternalStream.cpp +++ b/src/lib/VSDInternalStream.cpp @@ -1,6 +1,6 @@ /* libvisio * Copyright (C) 2011 Fridrich Strba (fridrich.strba@bluewin.ch) - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -21,127 +21,125 @@ VSDInternalStream::VSDInternalStream(WPXInputStream *input, unsigned long size, bool compressed) : - WPXInputStream(), - m_offset(0), - m_buffer() + WPXInputStream(), + m_offset(0), + m_buffer() { - unsigned long tmpNumBytesRead = 0; - - const unsigned char *tmpBuffer = input->read(size, tmpNumBytesRead); - - if (size != tmpNumBytesRead) - return; - - if (!compressed) - { - for (unsigned long i=0; i<size; i++) - m_buffer.push_back(tmpBuffer[i]); - } - else - { - unsigned char buffer[4096] = { 0 }; - unsigned pos = 0; - unsigned offset = 0; - - while (offset < size) - { - unsigned flag = tmpBuffer[offset++]; - if (offset > size-1) - break; - - unsigned mask = 1; - for (unsigned bit = 0; bit < 8 && offset < size; ++bit) - { - if (flag & mask) - { - buffer[pos&4095] = tmpBuffer[offset++]; - m_buffer.push_back(buffer[pos&4095]); - pos++; - } - else - { - if (offset > size-2) - break; - unsigned char addr1 = tmpBuffer[offset++]; - unsigned char addr2 = tmpBuffer[offset++]; - - unsigned length = (addr2&15) + 3; - unsigned pointer = (((unsigned)addr2 & 0xF0) << 4) | addr1; - if (pointer > 4078) - pointer -= 4078; - else - pointer += 18; - - for (unsigned j = 0; j < length; ++j) - { - buffer[(pos+j) & 4095] = buffer[(pointer+j) & 4095]; - m_buffer.push_back(buffer[(pointer+j) & 4095]); - } - pos += length; - - } - - mask = mask << 1; - } - } - } + unsigned long tmpNumBytesRead = 0; + + const unsigned char *tmpBuffer = input->read(size, tmpNumBytesRead); + + if (size != tmpNumBytesRead) + return; + + if (!compressed) + { + for (unsigned long i=0; i<size; i++) + m_buffer.push_back(tmpBuffer[i]); + } + else + { + unsigned char buffer[4096] = { 0 }; + unsigned pos = 0; + unsigned offset = 0; + + while (offset < size) + { + unsigned flag = tmpBuffer[offset++]; + if (offset > size-1) + break; + + unsigned mask = 1; + for (unsigned bit = 0; bit < 8 && offset < size; ++bit) + { + if (flag & mask) + { + buffer[pos&4095] = tmpBuffer[offset++]; + m_buffer.push_back(buffer[pos&4095]); + pos++; + } + else + { + if (offset > size-2) + break; + unsigned char addr1 = tmpBuffer[offset++]; + unsigned char addr2 = tmpBuffer[offset++]; + + unsigned length = (addr2&15) + 3; + unsigned pointer = (((unsigned)addr2 & 0xF0) << 4) | addr1; + if (pointer > 4078) + pointer -= 4078; + else + pointer += 18; + + for (unsigned j = 0; j < length; ++j) + { + buffer[(pos+j) & 4095] = buffer[(pointer+j) & 4095]; + m_buffer.push_back(buffer[(pointer+j) & 4095]); + } + pos += length; + } + mask = mask << 1; + } + } + } } const unsigned char * VSDInternalStream::read(unsigned long numBytes, unsigned long &numBytesRead) { - numBytesRead = 0; - - if (numBytes == 0) - return 0; - - int numBytesToRead; - - if ((m_offset+numBytes) < m_buffer.size()) - numBytesToRead = numBytes; - else - numBytesToRead = m_buffer.size() - m_offset; - - numBytesRead = numBytesToRead; // about as paranoid as we can be.. - - if (numBytesToRead == 0) - return 0; - - long oldOffset = m_offset; - m_offset += numBytesToRead; - - return &m_buffer[oldOffset]; + numBytesRead = 0; + + if (numBytes == 0) + return 0; + + int numBytesToRead; + + if ((m_offset+numBytes) < m_buffer.size()) + numBytesToRead = numBytes; + else + numBytesToRead = m_buffer.size() - m_offset; + + numBytesRead = numBytesToRead; // about as paranoid as we can be.. + + if (numBytesToRead == 0) + return 0; + + long oldOffset = m_offset; + m_offset += numBytesToRead; + + return &m_buffer[oldOffset]; } int VSDInternalStream::seek(long offset, WPX_SEEK_TYPE seekType) { - if (seekType == WPX_SEEK_CUR) - m_offset += offset; - else if (seekType == WPX_SEEK_SET) - m_offset = offset; - - if (m_offset < 0) - { - m_offset = 0; - return 1; - } - if ((long)m_offset > (long)m_buffer.size()) - { - m_offset = m_buffer.size(); - return 1; - } - - return 0; + if (seekType == WPX_SEEK_CUR) + m_offset += offset; + else if (seekType == WPX_SEEK_SET) + m_offset = offset; + + if (m_offset < 0) + { + m_offset = 0; + return 1; + } + if ((long)m_offset > (long)m_buffer.size()) + { + m_offset = m_buffer.size(); + return 1; + } + + return 0; } long VSDInternalStream::tell() { - return m_offset; + return m_offset; } bool VSDInternalStream::atEOS() { - if ((long)m_offset == (long)m_buffer.size()) - return true; + if ((long)m_offset == (long)m_buffer.size()) + return true; - return false; + return false; } diff --git a/src/lib/VSDInternalStream.h b/src/lib/VSDInternalStream.h index 7464e04..bf140d1 100644 --- a/src/lib/VSDInternalStream.h +++ b/src/lib/VSDInternalStream.h @@ -1,6 +1,6 @@ /* libvisio * Copyright (C) 2011 Fridrich Strba (fridrich.strba@bluewin.ch) - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -27,23 +27,23 @@ class VSDInternalStream : public WPXInputStream { public: - VSDInternalStream(WPXInputStream *input, unsigned long size, bool compressed); - virtual ~VSDInternalStream() {} - - bool isOLEStream() { return false; } - WPXInputStream * getDocumentOLEStream(const char*) { return 0; } - - const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead); - int seek(long offset, WPX_SEEK_TYPE seekType); - long tell(); - bool atEOS(); - unsigned long getSize() const { return m_buffer.size(); }; + VSDInternalStream(WPXInputStream *input, unsigned long size, bool compressed); + virtual ~VSDInternalStream() {} + + bool isOLEStream() { return false; } + WPXInputStream * getDocumentOLEStream(const char*) { return 0; } + + const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead); + int seek(long offset, WPX_SEEK_TYPE seekType); + long tell(); + bool atEOS(); + unsigned long getSize() const { return m_buffer.size(); }; private: - long m_offset; - std::vector<unsigned char> m_buffer; - VSDInternalStream(const VSDInternalStream&); - VSDInternalStream& operator=(const VSDInternalStream&); + long m_offset; + std::vector<unsigned char> m_buffer; + VSDInternalStream(const VSDInternalStream&); + VSDInternalStream& operator=(const VSDInternalStream&); }; #endif diff --git a/src/lib/VSDSVGGenerator.cpp b/src/lib/VSDSVGGenerator.cpp index 95e1e3f..a5a7887 100644 --- a/src/lib/VSDSVGGenerator.cpp +++ b/src/lib/VSDSVGGenerator.cpp @@ -54,284 +54,284 @@ libvisio::VSDSVGGenerator::~VSDSVGGenerator() void libvisio::VSDSVGGenerator::startGraphics(const WPXPropertyList &propList) { - if (m_isFirstPage) - m_isFirstPage = false; - else - m_outputSink << "<hr/>\n"; - - m_outputSink << "<!-- \n"; - m_outputSink << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; - m_outputSink << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\""; - m_outputSink << " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"; - m_outputSink << " -->\n"; - - m_outputSink << "<svg:svg version=\"1.1\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" "; - if (propList["svg:width"]) - m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" "; - if (propList["svg:height"]) - m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\""; - m_outputSink << " >\n"; - - m_gradientIndex = 1; + if (m_isFirstPage) + m_isFirstPage = false; + else + m_outputSink << "<hr/>\n"; + + m_outputSink << "<!-- \n"; + m_outputSink << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; + m_outputSink << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\""; + m_outputSink << " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"; + m_outputSink << " -->\n"; + + m_outputSink << "<svg:svg version=\"1.1\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" "; + if (propList["svg:width"]) + m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" "; + if (propList["svg:height"]) + m_outputSink << "height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\""; + m_outputSink << " >\n"; + + m_gradientIndex = 1; } void libvisio::VSDSVGGenerator::endGraphics() { - m_outputSink << "</svg:svg>\n"; + m_outputSink << "</svg:svg>\n"; } void libvisio::VSDSVGGenerator::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector& gradient) { - m_style = propList; + m_style = propList; - m_gradient = gradient; + m_gradient = gradient; - if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "gradient" && m_gradient.count()) - { - double angle = (m_style["draw:angle"] ? m_style["draw:angle"]->getDouble() : 0.0); - - m_outputSink << "<svg:defs>\n"; - m_outputSink << " <svg:linearGradient id=\"grad" << m_gradientIndex++ << "\" >\n"; - for(unsigned c = 0; c < m_gradient.count(); c++) - { - m_outputSink << " <svg:stop offset=\"" << m_gradient[c]["svg:offset"]->getStr().cstr() << "\""; - - m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\""; - m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getStr().cstr() << "\" />" << std::endl; - - } - m_outputSink << " </svg:linearGradient>\n"; - - // not a simple horizontal gradient - if(angle != -90) - { - m_outputSink << " <svg:linearGradient xlink:href=\"#grad" << m_gradientIndex-1 << "\""; - m_outputSink << " id=\"grad" << m_gradientIndex++ << "\" "; - m_outputSink << "x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\" "; - m_outputSink << "gradientTransform=\"rotate(" << angle << " .5 .5)\" "; - m_outputSink << "gradientUnits=\"objectBoundingBox\" >\n"; - m_outputSink << " </svg:linearGradient>\n"; - } - - m_outputSink << "</svg:defs>\n"; - } + if(propList["draw:fill"] && propList["draw:fill"]->getStr() == "gradient" && m_gradient.count()) + { + double angle = (m_style["draw:angle"] ? m_style["draw:angle"]->getDouble() : 0.0); + + m_outputSink << "<svg:defs>\n"; + m_outputSink << " <svg:linearGradient id=\"grad" << m_gradientIndex++ << "\" >\n"; + for(unsigned c = 0; c < m_gradient.count(); c++) + { + m_outputSink << " <svg:stop offset=\"" << m_gradient[c]["svg:offset"]->getStr().cstr() << "\""; + + m_outputSink << " stop-color=\"" << m_gradient[c]["svg:stop-color"]->getStr().cstr() << "\""; + m_outputSink << " stop-opacity=\"" << m_gradient[c]["svg:stop-opacity"]->getStr().cstr() << "\" />" << std::endl; + + } + m_outputSink << " </svg:linearGradient>\n"; + + // not a simple horizontal gradient + if(angle != -90) + { + m_outputSink << " <svg:linearGradient xlink:href=\"#grad" << m_gradientIndex-1 << "\""; + m_outputSink << " id=\"grad" << m_gradientIndex++ << "\" "; + m_outputSink << "x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\" "; + m_outputSink << "gradientTransform=\"rotate(" << angle << " .5 .5)\" "; + m_outputSink << "gradientUnits=\"objectBoundingBox\" >\n"; + m_outputSink << " </svg:linearGradient>\n"; + } + + m_outputSink << "</svg:defs>\n"; + } } void libvisio::VSDSVGGenerator::startLayer(const ::WPXPropertyList& propList) { - m_outputSink << "<svg:g id=\"Layer" << propList["svg:id"]->getInt() << "\" >\n"; + m_outputSink << "<svg:g id=\"Layer" << propList["svg:id"]->getInt() << "\" >\n"; } void libvisio::VSDSVGGenerator::endLayer() { - m_outputSink << "</svg:g>\n"; + m_outputSink << "</svg:g>\n"; } void libvisio::VSDSVGGenerator::drawRectangle(const ::WPXPropertyList& propList) { - m_outputSink << "<svg:rect "; - m_outputSink << "x=\"" << doubleToString(72*propList["svg:x"]->getDouble()) << "\" y=\"" << doubleToString(72*propList["svg:y"]->getDouble()) << "\" "; - m_outputSink << "width=\"" << doubleToString(72*propList["svg:width"]->getDouble()) << "\" height=\"" << doubleToString(72*propList["svg:height"]->getDouble()) << "\" "; - if((propList["svg:rx"] && propList["svg:rx"]->getInt() !=0) || (propList["svg:ry"] && propList["svg:ry"]->getInt() !=0)) - m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; - writeStyle(); - m_outputSink << "/>\n"; + m_outputSink << "<svg:rect "; + m_outputSink << "x=\"" << doubleToString(72*propList["svg:x"]->getDouble()) << "\" y=\"" << doubleToString(72*propList["svg:y"]->getDouble()) << "\" "; + m_outputSink << "width=\"" << doubleToString(72*propList["svg:width"]->getDouble()) << "\" height=\"" << doubleToString(72*propList["svg:height"]->getDouble()) << "\" "; + if((propList["svg:rx"] && propList["svg:rx"]->getInt() !=0) || (propList["svg:ry"] && propList["svg:ry"]->getInt() !=0)) + m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; + writeStyle(); + m_outputSink << "/>\n"; } void libvisio::VSDSVGGenerator::drawEllipse(const WPXPropertyList& propList) { - m_outputSink << "<svg:ellipse "; - m_outputSink << "cx=\"" << doubleToString(72*propList["svg:cx"]->getDouble()) << "\" cy=\"" << doubleToString(72*propList["svg:cy"]->getDouble()) << "\" "; - m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; - writeStyle(); - if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0) - m_outputSink << " transform=\" translate(" << doubleToString(72*propList["svg:cx"]->getDouble()) << ", " << doubleToString(72*propList["svg:cy"]->getDouble()) - << ") rotate(" << doubleToString(-propList["libwpg:rotate"]->getDouble()) - << ") translate(" << doubleToString(-72*propList["svg:cx"]->getDouble()) - << ", " << doubleToString(-72*propList["svg:cy"]->getDouble()) - << ")\" "; - m_outputSink << "/>\n"; + m_outputSink << "<svg:ellipse "; + m_outputSink << "cx=\"" << doubleToString(72*propList["svg:cx"]->getDouble()) << "\" cy=\"" << doubleToString(72*propList["svg:cy"]->getDouble()) << "\" "; + m_outputSink << "rx=\"" << doubleToString(72*propList["svg:rx"]->getDouble()) << "\" ry=\"" << doubleToString(72*propList["svg:ry"]->getDouble()) << "\" "; + writeStyle(); + if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0) + m_outputSink << " transform=\" translate(" << doubleToString(72*propList["svg:cx"]->getDouble()) << ", " << doubleToString(72*propList["svg:cy"]->getDouble()) + << ") rotate(" << doubleToString(-propList["libwpg:rotate"]->getDouble()) + << ") translate(" << doubleToString(-72*propList["svg:cx"]->getDouble()) + << ", " << doubleToString(-72*propList["svg:cy"]->getDouble()) + << ")\" "; + m_outputSink << "/>\n"; } void libvisio::VSDSVGGenerator::drawPolyline(const ::WPXPropertyListVector& vertices) { - drawPolySomething(vertices, false); + drawPolySomething(vertices, false); } void libvisio::VSDSVGGenerator::drawPolygon(const ::WPXPropertyListVector& vertices) { - drawPolySomething(vertices, true); + drawPolySomething(vertices, true); } void libvisio::VSDSVGGenerator::drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed) { - if(vertices.count() < 2) - return; - - if(vertices.count() == 2) - { - m_outputSink << "<svg:line "; - m_outputSink << "x1=\"" << doubleToString(72*(vertices[0]["svg:x"]->getDouble())) << "\" y1=\"" << doubleToString(72*(vertices[0]["svg:y"]->getDouble())) << "\" "; - m_outputSink << "x2=\"" << doubleToString(72*(vertices[1]["svg:x"]->getDouble())) << "\" y2=\"" << doubleToString(72*(vertices[1]["svg:y"]->getDouble())) << "\"\n"; - writeStyle(); - m_outputSink << "/>\n"; - } - else - { - if (isClosed) - m_outputSink << "<svg:polygon "; - else - m_outputSink << "<svg:polyline "; - - m_outputSink << "points=\""; - for(unsigned i = 0; i < vertices.count(); i++) - { - m_outputSink << doubleToString(72*(vertices[i]["svg:x"]->getDouble())) << " " << doubleToString(72*(vertices[i]["svg:y"]->getDouble())); - if (i < vertices.count()-1) - m_outputSink << ", "; - } - m_outputSink << "\"\n"; - writeStyle(isClosed); - m_outputSink << "/>\n"; - } + if(vertices.count() < 2) + return; + + if(vertices.count() == 2) + { + m_outputSink << "<svg:line "; + m_outputSink << "x1=\"" << doubleToString(72*(vertices[0]["svg:x"]->getDouble())) << "\" y1=\"" << doubleToString(72*(vertices[0]["svg:y"]->getDouble())) << "\" "; + m_outputSink << "x2=\"" << doubleToString(72*(vertices[1]["svg:x"]->getDouble())) << "\" y2=\"" << doubleToString(72*(vertices[1]["svg:y"]->getDouble())) << "\"\n"; + writeStyle(); + m_outputSink << "/>\n"; + } + else + { + if (isClosed) + m_outputSink << "<svg:polygon "; + else + m_outputSink << "<svg:polyline "; + + m_outputSink << "points=\""; + for(unsigned i = 0; i < vertices.count(); i++) + { + m_outputSink << doubleToString(72*(vertices[i]["svg:x"]->getDouble())) << " " << doubleToString(72*(vertices[i]["svg:y"]->getDouble())); + if (i < vertices.count()-1) + m_outputSink << ", "; + } + m_outputSink << "\"\n"; + writeStyle(isClosed); + m_outputSink << "/>\n"; + } } void libvisio::VSDSVGGenerator::drawPath(const ::WPXPropertyListVector& path) { - m_outputSink << "<svg:path d=\" "; - bool isClosed = false; - unsigned i=0; - for(i=0; i < path.count(); i++) - { - WPXPropertyList propList = path[i]; - if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "M") - { - m_outputSink << "\nM"; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "L") - { - m_outputSink << "\nL"; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "C") - { - m_outputSink << "\nC"; - m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; - m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " "; - m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "A") - { - m_outputSink << "\nA"; - m_outputSink << doubleToString(72*(propList["svg:rx"]->getDouble())) << "," << doubleToString(72*(propList["svg:ry"]->getDouble())) << " "; - m_outputSink << doubleToString(propList["libwpg:rotate"] ? propList["libwpg:rotate"]->getDouble() : 0) << " "; + m_outputSink << "<svg:path d=\" "; + bool isClosed = false; + unsigned i=0; + for(i=0; i < path.count(); i++) + { + WPXPropertyList propList = path[i]; + if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "M") + { + m_outputSink << "\nM"; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "L") + { + m_outputSink << "\nL"; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "C") + { + m_outputSink << "\nC"; + m_outputSink << doubleToString(72*(propList["svg:x1"]->getDouble())) << "," << doubleToString(72*(propList["svg:y1"]->getDouble())) << " "; + m_outputSink << doubleToString(72*(propList["svg:x2"]->getDouble())) << "," << doubleToString(72*(propList["svg:y2"]->getDouble())) << " "; + m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); + } + else if (propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "A") + { + m_outputSink << "\nA"; + m_outputSink << doubleToString(72*(propList["svg:rx"]->getDouble())) << "," << doubleToString(72*(propList["svg:ry"]->getDouble())) << " "; + m_outputSink << doubleToString(propList["libwpg:rotate"] ? propList["libwpg:rotate"]->getDouble() : 0) << " "; m_outputSink << (propList["libwpg:large-arc"] ? propList["libwpg:large-arc"]->getInt() : 1) << ","; m_outputSink << (propList["libwpg:sweep"] ? propList["libwpg:sweep"]->getInt() : 1) << " "; m_outputSink << doubleToString(72*(propList["svg:x"]->getDouble())) << "," << doubleToString(72*(propList["svg:y"]->getDouble())); - } - else if ((i >= path.count()-1 && i > 2) && propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Z" ) - { - isClosed = true; - m_outputSink << "\nZ"; - } - } - - m_outputSink << "\" \n"; - writeStyle(isClosed); - m_outputSink << "/>\n"; + } + else if ((i >= path.count()-1 && i > 2) && propList["libwpg:path-action"] && propList["libwpg:path-action"]->getStr() == "Z" ) + { + isClosed = true; + m_outputSink << "\nZ"; + } + } + + m_outputSink << "\" \n"; + writeStyle(isClosed); + m_outputSink << "/>\n"; } void libvisio::VSDSVGGenerator::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData) { - if (!propList["libwpg:mime-type"] || propList["libwpg:mime-type"]->getStr().len() <= 0) - return; - WPXString base64 = binaryData.getBase64Data(); - m_outputSink << "<svg:image "; - if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"]) - m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\" "; - m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\" "; - m_outputSink << "xlink:href=\"data:" << propList["libwpg:mime-type"]->getStr().cstr() << ";base64,"; - m_outputSink << base64.cstr(); - m_outputSink << "\" />\n"; + if (!propList["libwpg:mime-type"] || propList["libwpg:mime-type"]->getStr().len() <= 0) + return; + WPXString base64 = binaryData.getBase64Data(); + m_outputSink << "<svg:image "; + if (propList["svg:x"] && propList["svg:y"] && propList["svg:width"] && propList["svg:height"]) + m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\" "; + m_outputSink << "width=\"" << doubleToString(72*(propList["svg:width"]->getDouble())) << "\" height=\"" << doubleToString(72*(propList["svg:height"]->getDouble())) << "\" "; + m_outputSink << "xlink:href=\"data:" << propList["libwpg:mime-type"]->getStr().cstr() << ";base64,"; + m_outputSink << base64.cstr(); + m_outputSink << "\" />\n"; } void libvisio::VSDSVGGenerator::startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector & /* path */) { - m_outputSink << "<svg:text "; - if (propList["svg:x"] && propList["svg:y"]) - m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\">\n"; + m_outputSink << "<svg:text "; + if (propList["svg:x"] && propList["svg:y"]) + m_outputSink << "x=\"" << doubleToString(72*(propList["svg:x"]->getDouble())) << "\" y=\"" << doubleToString(72*(propList["svg:y"]->getDouble())) << "\">\n"; } void libvisio::VSDSVGGenerator::endTextObject() { - m_outputSink << "</svg:text>\n"; + m_outputSink << "</svg:text>\n"; } void libvisio::VSDSVGGenerator::startTextSpan(const ::WPXPropertyList &propList) { - m_outputSink << "<svg:tspan "; - if (propList["style:font-name"]) - m_outputSink << "font-family=\"" << propList["style:font-name"]->getStr().cstr() << "\" "; - if (propList["fo:font-style"]) - m_outputSink << "font-style=\"" << propList["fo:font-style"]->getStr().cstr() << "\" "; - if (propList["fo:font-weight"]) - m_outputSink << "font-weight=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" "; - if (propList["fo:font-variant"]) - m_outputSink << "font-variant=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" "; - if (propList["fo:font-size"]) - m_outputSink << "font-size=\"" << propList["fo:font-size"]->getStr().cstr() << "\" "; - if (propList["fo:color"]) - m_outputSink << "fill=\"" << propList["fo:color"]->getStr().cstr() << "\" "; - m_outputSink << ">\n"; + m_outputSink << "<svg:tspan "; + if (propList["style:font-name"]) + m_outputSink << "font-family=\"" << propList["style:font-name"]->getStr().cstr() << "\" "; + if (propList["fo:font-style"]) + m_outputSink << "font-style=\"" << propList["fo:font-style"]->getStr().cstr() << "\" "; + if (propList["fo:font-weight"]) + m_outputSink << "font-weight=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" "; + if (propList["fo:font-variant"]) + m_outputSink << "font-variant=\"" << propList["fo:font-weight"]->getStr().cstr() << "\" "; + if (propList["fo:font-size"]) + m_outputSink << "font-size=\"" << propList["fo:font-size"]->getStr().cstr() << "\" "; + if (propList["fo:color"]) + m_outputSink << "fill=\"" << propList["fo:color"]->getStr().cstr() << "\" "; + m_outputSink << ">\n"; } void libvisio::VSDSVGGenerator::endTextSpan() { - m_outputSink << "</svg:tspan>\n"; + m_outputSink << "</svg:tspan>\n"; } void libvisio::VSDSVGGenerator::insertText(const ::WPXString &str) { - WPXString tempUTF8(str, true); - m_outputSink << tempUTF8.cstr() << "\n"; + WPXString tempUTF8(str, true); + m_outputSink << tempUTF8.cstr() << "\n"; } // create "style" attribute based on current pen and brush void libvisio::VSDSVGGenerator::writeStyle(bool /* isClosed */) { - m_outputSink << "style=\""; + m_outputSink << "style=\""; - if (m_style["svg:stroke-width"]) - m_outputSink << "stroke-width: " << doubleToString(72*m_style["svg:stroke-width"]->getDouble()) << "; "; + if (m_style["svg:stroke-width"]) + m_outputSink << "stroke-width: " << doubleToString(72*m_style["svg:stroke-width"]->getDouble()) << "; "; - if((m_style["svg:stroke-width"] && m_style["svg:stroke-width"]->getDouble() > 0.0) || (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "solid")) - { - if (m_style["svg:stroke-color"]) - m_outputSink << "stroke: " << m_style["svg:stroke-color"]->getStr().cstr() << "; "; - if(m_style["svg:stroke-opacity"] && m_style["svg:stroke-opacity"]->getInt()!= 1) - m_outputSink << "stroke-opacity: " << doubleToString(m_style["svg:stroke-opacity"]->getDouble()) << "; "; - } + if((m_style["svg:stroke-width"] && m_style["svg:stroke-width"]->getDouble() > 0.0) || (m_style["draw:stroke"] && m_style["draw:stroke"]->getStr() == "solid")) + { + if (m_style["svg:stroke-color"]) + m_outputSink << "stroke: " << m_style["svg:stroke-color"]->getStr().cstr() << "; "; + if(m_style["svg:stroke-opacity"] && m_style["svg:stroke-opacity"]->getInt()!= 1) + m_outputSink << "stroke-opacity: " << doubleToString(m_style["svg:stroke-opacity"]->getDouble()) << "; "; + } - if (m_style["svg:stroke-dasharray"]) - m_outputSink << "stroke-dasharray: " << m_style["svg:stroke-dasharray"]->getStr().cstr() <<"; "; + if (m_style["svg:stroke-dasharray"]) + m_outputSink << "stroke-dasharray: " << m_style["svg:stroke-dasharray"]->getStr().cstr() <<"; "; - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none") - m_outputSink << "fill: none; "; + if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none") + m_outputSink << "fill: none; "; - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap") - if(m_style["svg:fill-rule"]) - m_outputSink << "fill-rule: " << m_style["svg:fill-rule"]->getStr().cstr() << "; "; + if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "bitmap") + if(m_style["svg:fill-rule"]) + m_outputSink << "fill-rule: " << m_style["svg:fill-rule"]->getStr().cstr() << "; "; - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient") - m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); "; - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient") - m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); "; + if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient") + m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); "; + if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "gradient") + m_outputSink << "fill: url(#grad" << m_gradientIndex-1 << "); "; - if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "solid") - if (m_style["draw:fill-color"]) - m_outputSink << "fill: " << m_style["draw:fill-color"]->getStr().cstr() << "; "; + if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "solid") + if (m_style["draw:fill-color"]) + m_outputSink << "fill: " << m_style["draw:fill-color"]->getStr().cstr() << "; "; - m_outputSink << "\""; // style + m_outputSink << "\""; // style } diff --git a/src/lib/VSDSVGGenerator.h b/src/lib/VSDSVGGenerator.h index 5772a6e..2054617 100644 --- a/src/lib/VSDSVGGenerator.h +++ b/src/lib/VSDSVGGenerator.h @@ -30,41 +30,41 @@ namespace libvisio class VSDSVGGenerator : public libwpg::WPGPaintInterface { public: - VSDSVGGenerator(std::ostream & output_sink); - ~VSDSVGGenerator(); + VSDSVGGenerator(std::ostream & output_sink); + ~VSDSVGGenerator(); - void startGraphics(const ::WPXPropertyList &propList); - void endGraphics(); - void startLayer(const ::WPXPropertyList& propList); - void endLayer(); - void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {} - void endEmbeddedGraphics() {} + void startGraphics(const ::WPXPropertyList &propList); + void endGraphics(); + void startLayer(const ::WPXPropertyList& propList); + void endLayer(); + void startEmbeddedGraphics(const ::WPXPropertyList & /*propList*/) {} + void endEmbeddedGraphics() {} - void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient); + void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient); - void drawRectangle(const ::WPXPropertyList &propList); - void drawEllipse(const ::WPXPropertyList &propList); - void drawPolyline(const ::WPXPropertyListVector &vertices); - void drawPolygon(const ::WPXPropertyListVector &vertices); - void drawPath(const ::WPXPropertyListVector &path); - void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData); - void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path); - void endTextObject(); - void startTextLine(const ::WPXPropertyList & /* propList */) {} - void endTextLine() {} - void startTextSpan(const ::WPXPropertyList &propList); - void endTextSpan(); - void insertText(const ::WPXString &str); + void drawRectangle(const ::WPXPropertyList &propList); + void drawEllipse(const ::WPXPropertyList &propList); + void drawPolyline(const ::WPXPropertyListVector &vertices); + void drawPolygon(const ::WPXPropertyListVector &vertices); + void drawPath(const ::WPXPropertyListVector &path); + void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData); + void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path); + void endTextObject(); + void startTextLine(const ::WPXPropertyList & /* propList */) {} + void endTextLine() {} + void startTextSpan(const ::WPXPropertyList &propList); + void endTextSpan(); + void insertText(const ::WPXString &str); private: - ::WPXPropertyListVector m_gradient; - ::WPXPropertyList m_style; - int m_gradientIndex; - bool m_isFirstPage; - void writeStyle(bool isClosed=true); - void drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed); + ::WPXPropertyListVector m_gradient; + ::WPXPropertyList m_style; + int m_gradientIndex; + bool m_isFirstPage; + void writeStyle(bool isClosed=true); + void drawPolySomething(const ::WPXPropertyListVector& vertices, bool isClosed); - std::ostream & m_outputSink; + std::ostream & m_outputSink; }; } // namespace libvisio diff --git a/src/lib/VSDXContentCollector.cpp b/src/lib/VSDXContentCollector.cpp index 3922066..57aef6a 100644 --- a/src/lib/VSDXContentCollector.cpp +++ b/src/lib/VSDXContentCollector.cpp @@ -33,9 +33,9 @@ libvisio::VSDXContentCollector::VSDXContentCollector(libwpg::WPGPaintInterface * const ::WPXString libvisio::VSDXContentCollector::getColourString(const struct Colour &c) const { - ::WPXString sColour; - sColour.sprintf("#%.2x%.2x%.2x", c.r, c.g, c.b); - return sColour; + ::WPXString sColour; + sColour.sprintf("#%.2x%.2x%.2x", c.r, c.g, c.b); + return sColour; } void libvisio::VSDXContentCollector::rotatePoint(double &x, double &y, const XForm &xform) @@ -665,7 +665,7 @@ void libvisio::VSDXContentCollector::collectShape(unsigned id, unsigned level) m_styleProps.insert("svg:stroke-color", m_lineColour); m_styleProps.insert("draw:fill", m_fillType); m_styleProps.insert("svg:stroke-dasharray", "solid"); - + m_currentShapeId = id; } @@ -722,7 +722,7 @@ void libvisio::VSDXContentCollector::_handleLevelChange(unsigned level) m_styleProps.insert("draw:fill", m_fillType); m_styleProps.insert("svg:stroke-dasharray", "solid"); } - + m_currentLevel = level; } diff --git a/src/lib/VSDXContentCollector.h b/src/lib/VSDXContentCollector.h index 047e093..6c36c03 100644 --- a/src/lib/VSDXContentCollector.h +++ b/src/lib/VSDXContentCollector.h @@ -76,7 +76,7 @@ private: void _flushCurrentForeignData(); const ::WPXString getColourString(const Colour& c) const; - + void _handleLevelChange(unsigned level); bool m_isPageStarted; diff --git a/src/lib/VSDXDocumentStructure.h b/src/lib/VSDXDocumentStructure.h index e401ef5..b1efc61 100644 --- a/src/lib/VSDXDocumentStructure.h +++ b/src/lib/VSDXDocumentStructure.h @@ -107,6 +107,6 @@ #define VSD_NURBS_TO_ECELL 0xd1 - + #endif /* VSDXDOCUMENTSTRUCTURE_H */ diff --git a/src/lib/VSDXOutputElement.cpp b/src/lib/VSDXOutputElement.cpp index 4cb119c..535c2f1 100644 --- a/src/lib/VSDXOutputElement.cpp +++ b/src/lib/VSDXOutputElement.cpp @@ -24,8 +24,8 @@ libvisio::VSDXStyleOutputElement::VSDXStyleOutputElement(const WPXPropertyList & void libvisio::VSDXStyleOutputElement::draw(libwpg::WPGPaintInterface *painter) { - if (painter) - painter->setStyle(m_propList, m_propListVec); + if (painter) + painter->setStyle(m_propList, m_propListVec); } @@ -34,8 +34,8 @@ libvisio::VSDXEllipseOutputElement::VSDXEllipseOutputElement(const WPXPropertyLi void libvisio::VSDXEllipseOutputElement::draw(libwpg::WPGPaintInterface *painter) { - if (painter) - painter->drawEllipse(m_propList); + if (painter) + painter->drawEllipse(m_propList); } @@ -44,8 +44,8 @@ libvisio::VSDXPathOutputElement::VSDXPathOutputElement(const WPXPropertyListVect void libvisio::VSDXPathOutputElement::draw(libwpg::WPGPaintInterface *painter) { - if (painter) - painter->drawPath(m_propListVec); + if (painter) + painter->drawPath(m_propListVec); } @@ -54,7 +54,7 @@ libvisio::VSDXGraphicObjectOutputElement::VSDXGraphicObjectOutputElement(const W void libvisio::VSDXGraphicObjectOutputElement::draw(libwpg::WPGPaintInterface *painter) { - if (painter) - painter->drawGraphicObject(m_propList, m_binaryData); + if (painter) + painter->drawGraphicObject(m_propList, m_binaryData); } diff --git a/src/lib/VSDXParser.cpp b/src/lib/VSDXParser.cpp index 9a0b8f4..b513225 100644 --- a/src/lib/VSDXParser.cpp +++ b/src/lib/VSDXParser.cpp @@ -141,7 +141,7 @@ void libvisio::VSDXParser::readGeomList(WPXInputStream *input) void libvisio::VSDXParser::readGeometry(WPXInputStream *input) { unsigned geomFlags = readU8(input); - + m_collector->collectGeometry(m_header.id, m_header.level, geomFlags); } diff --git a/src/lib/VSDXParser.h b/src/lib/VSDXParser.h index 615763c..90906ac 100644 --- a/src/lib/VSDXParser.h +++ b/src/lib/VSDXParser.h @@ -57,10 +57,10 @@ protected: void readForeignDataType(WPXInputStream *input); void readPageProps(WPXInputStream *input); void readColours(WPXInputStream *input); - + // Chunk handlers void readShape(WPXInputStream *input); - + virtual bool getChunkHeader(WPXInputStream *input) = 0; WPXInputStream *m_input; diff --git a/src/lib/VSDXStylesCollector.h b/src/lib/VSDXStylesCollector.h index 8cf58bf..6f4f84e 100644 --- a/src/lib/VSDXStylesCollector.h +++ b/src/lib/VSDXStylesCollector.h @@ -49,7 +49,7 @@ public: void collectShape(unsigned id, unsigned level) {} void collectUnhandledChunk(unsigned id, unsigned level) {} - + void collectColours(const std::vector<Colour> &colours) {} // Temporary hack diff --git a/src/lib/VisioDocument.cpp b/src/lib/VisioDocument.cpp index 588055d..55d259b 100644 --- a/src/lib/VisioDocument.cpp +++ b/src/lib/VisioDocument.cpp @@ -12,8 +12,8 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111-1301 USA */ @@ -43,7 +43,7 @@ bool libvisio::VisioDocument::isSupported(WPXInputStream* input) unsigned char version = readU8(tmpDocStream); delete tmpDocStream; - + VSD_DEBUG_MSG(("VisioDocument: version %i\n", version)); // Versions 2k (6) and 2k3 (11) @@ -52,7 +52,7 @@ bool libvisio::VisioDocument::isSupported(WPXInputStream* input) return true; } - return false; + return false; } /** @@ -107,12 +107,12 @@ Provided as a convenience function for applications that support SVG internally. */ bool libvisio::VisioDocument::generateSVG(::WPXInputStream* input, WPXString& output) { - std::ostringstream tmpOutputStream; - libvisio::VSDSVGGenerator generator(tmpOutputStream); - bool result = libvisio::VisioDocument::parse(input, &generator); - if (result) - output = WPXString(tmpOutputStream.str().c_str()); - else - output = WPXString(""); - return result; + std::ostringstream tmpOutputStream; + libvisio::VSDSVGGenerator generator(tmpOutputStream); + bool result = libvisio::VisioDocument::parse(input, &generator); + if (result) + output = WPXString(tmpOutputStream.str().c_str()); + else + output = WPXString(""); + return result; } diff --git a/src/lib/VisioDocument.h b/src/lib/VisioDocument.h index 8c58ce7..8f068c1 100644 --- a/src/lib/VisioDocument.h +++ b/src/lib/VisioDocument.h @@ -12,8 +12,8 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111-1301 USA * * For further information visit http://libwpg.sourceforge.net @@ -33,12 +33,12 @@ namespace libvisio class VisioDocument { public: - - static bool isSupported(WPXInputStream* input); - - static bool parse(WPXInputStream* input, libwpg::WPGPaintInterface* painter); - static bool generateSVG(WPXInputStream* input, WPXString& output); + static bool isSupported(WPXInputStream* input); + +t static bool parse(WPXInputStream* input, libwpg::WPGPaintInterface* painter); + + static bool generateSVG(WPXInputStream* input, WPXString& output); }; } // namespace libvisio diff --git a/src/lib/libvisio.h b/src/lib/libvisio.h index 298d01a..5eeea0b 100644 --- a/src/lib/libvisio.h +++ b/src/lib/libvisio.h @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111-1301 USA */ diff --git a/src/lib/libvisio_utils.cpp b/src/lib/libvisio_utils.cpp index 3bf10de..60300a9 100644 --- a/src/lib/libvisio_utils.cpp +++ b/src/lib/libvisio_utils.cpp @@ -12,8 +12,8 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111-1301 USA */ @@ -23,50 +23,50 @@ uint8_t readU8(WPXInputStream *input) { - if (!input || input->atEOS()) - return (uint8_t)0; - unsigned long numBytesRead; - uint8_t const * p = input->read(sizeof(uint8_t), numBytesRead); - - if (p && numBytesRead == sizeof(uint8_t)) - return *(uint8_t const *)(p); - return (uint8_t)0; + if (!input || input->atEOS()) + return (uint8_t)0; + unsigned long numBytesRead; + uint8_t const * p = input->read(sizeof(uint8_t), numBytesRead); + + if (p && numBytesRead == sizeof(uint8_t)) + return *(uint8_t const *)(p); + return (uint8_t)0; } uint16_t readU16(WPXInputStream *input) { - uint16_t p0 = (uint16_t)readU8(input); - uint16_t p1 = (uint16_t)readU8(input); - return (uint16_t)(p0|(p1<<8)); + uint16_t p0 = (uint16_t)readU8(input); + uint16_t p1 = (uint16_t)readU8(input); + return (uint16_t)(p0|(p1<<8)); } uint32_t readU32(WPXInputStream *input) { - uint32_t p0 = (uint32_t)readU8(input); - uint32_t p1 = (uint32_t)readU8(input); - uint32_t p2 = (uint32_t)readU8(input); - uint32_t p3 = (uint32_t)readU8(input); - return (uint32_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)); + uint32_t p0 = (uint32_t)readU8(input); + uint32_t p1 = (uint32_t)readU8(input); + uint32_t p2 = (uint32_t)readU8(input); + uint32_t p3 = (uint32_t)readU8(input); + return (uint32_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)); } uint64_t readU64(WPXInputStream *input) { - uint64_t p0 = (uint64_t)readU8(input); - uint64_t p1 = (uint64_t)readU8(input); - uint64_t p2 = (uint64_t)readU8(input); - uint64_t p3 = (uint64_t)readU8(input); - uint64_t p4 = (uint64_t)readU8(input); - uint64_t p5 = (uint64_t)readU8(input); - uint64_t p6 = (uint64_t)readU8(input); - uint64_t p7 = (uint64_t)readU8(input); - return (uint64_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)|(p4<<32)|(p5<<40)|(p6<<48)|(p7<<56)); + uint64_t p0 = (uint64_t)readU8(input); + uint64_t p1 = (uint64_t)readU8(input); + uint64_t p2 = (uint64_t)readU8(input); + uint64_t p3 = (uint64_t)readU8(input); + uint64_t p4 = (uint64_t)readU8(input); + uint64_t p5 = (uint64_t)readU8(input); + uint64_t p6 = (uint64_t)readU8(input); + uint64_t p7 = (uint64_t)readU8(input); + return (uint64_t)(p0|(p1<<8)|(p2<<16)|(p3<<24)|(p4<<32)|(p5<<40)|(p6<<48)|(p7<<56)); } double readDouble(WPXInputStream *input) { - uint64_t value = readU64(input); - - double *doublePointer = reinterpret_cast<double *>(&value); - - return *doublePointer; + uint64_t value = readU64(input); + + double *doublePointer = reinterpret_cast<double *>(&value); + + return *doublePointer; } diff --git a/src/lib/libvisio_utils.h b/src/lib/libvisio_utils.h index 05f5b9b..31864b8 100644 --- a/src/lib/libvisio_utils.h +++ b/src/lib/libvisio_utils.h @@ -12,8 +12,8 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111-1301 USA */ @@ -52,19 +52,19 @@ typedef unsigned __int64 uint64_t; // do nothing with debug messages in a release compile #ifdef DEBUG - #ifdef VERBOSE_DEBUG - #define VSD_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M - #define VSD_DEBUG(M) M - #else - #define VSD_DEBUG_MSG(M) printf M - #define VSD_DEBUG(M) M - #endif + #ifdef VERBOSE_DEBUG + #define VSD_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M + #define VSD_DEBUG(M) M + #else + #define VSD_DEBUG_MSG(M) printf M + #define VSD_DEBUG(M) M + #endif #else - #define VSD_DEBUG_MSG(M) - #define VSD_DEBUG(M) + #define VSD_DEBUG_MSG(M) + #define VSD_DEBUG(M) #endif -uint8_t readU8(WPXInputStream *input); +uint8_t readU8(WPXInputStream *input); uint16_t readU16(WPXInputStream *input); uint32_t readU32(WPXInputStream *input); uint64_t readU64(WPXInputStream *input); |