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 <tibbylickle@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
Context
- [Libreoffice] [GSoC] [Patch] libvisio isSupported implementation · Tibby Lickle
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.