Hi, First patch for libvisio, I'm not used to external code review on my C++ code so be as harsh as you need to be.
E.
From b8f734c46d7bbcdfb155dba92048c7f7440986bf Mon Sep 17 00:00:00 2001 From: Tibby Lickle <tibbylic...@gmail.com> Date: Fri, 20 May 2011 13:58:44 +0100 Subject: [PATCH] implementation of isSupported for Visio 2k and 2k3 --- src/lib/VisioDocument.cpp | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/src/lib/VisioDocument.cpp b/src/lib/VisioDocument.cpp index dc89591..1279f4b 100644 --- a/src/lib/VisioDocument.cpp +++ b/src/lib/VisioDocument.cpp @@ -30,8 +30,35 @@ Analyzes the content of an input stream to see if it can be parsed \return A value that indicates whether the content from the input stream is a Visio Document that libvisio able to parse */ -bool libvisio::VisioDocument::isSupported(WPXInputStream* /*input*/) +bool libvisio::VisioDocument::isSupported(WPXInputStream* input) { + WPXInputStream* tmpDocStream = input->getDocumentOLEStream("VisioDocument"); + if (!tmpDocStream) + { + return false; + } + + tmpDocStream->seek(0x1A, WPX_SEEK_SET); + unsigned long bytesRead; + const unsigned char *data = tmpDocStream->read(1, bytesRead); + + if (bytesRead != 1) + { + delete [] data; + delete tmpDocStream; + return false; + } + + unsigned char version = data[0]; + delete [] data; + delete tmpDocStream; + + // Versions 2k (6) and 2k3 (11) + if (version == 6 || version == 11) + { + return true; + } + return false; } -- 1.7.4.4
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice