Kaydet (Commit) 2a677e83 authored tarafından David Tardon's avatar David Tardon

fix keynote format detection

Change-Id: Iadc1fe4efe891ef33f85086cfe0b811ebeb6e767
üst 57a00083
From 28a3b93cc8b0050582c54722df5ac372530ff0a4 Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Fri, 1 Nov 2013 18:29:40 +0100
Subject: [PATCH] impl. XML format detection
---
src/lib/KEYDocument.cpp | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/lib/KEYDocument.cpp b/src/lib/KEYDocument.cpp
index 8ca33ad..a1a5477 100644
--- a/src/lib/KEYDocument.cpp
+++ b/src/lib/KEYDocument.cpp
@@ -13,10 +13,12 @@
#include <libetonyek/KEYDocument.h>
#include "libetonyek_utils.h"
+#include "libetonyek_xml.h"
#include "KEY1Defaults.h"
#include "KEY1Parser.h"
#include "KEY2Defaults.h"
#include "KEY2Parser.h"
+#include "KEY2Token.h"
#include "KEYContentCollector.h"
#include "KEYDefaults.h"
#include "KEYDictionary.h"
@@ -60,9 +62,32 @@ enum Source
Version detectVersionFromInput(const WPXInputStreamPtr_t &input)
{
- // TODO: do a real detection
- (void) input;
- return VERSION_KEYNOTE_5;
+ if (input->atEOS())
+ return VERSION_UNKNOWN;
+
+ const KEY2Tokenizer tokenizer;
+ KEYXMLReader reader(input.get(), tokenizer);
+
+ if ((KEY2Token::NS_URI_KEY | KEY2Token::presentation) == getId(reader))
+ {
+ const std::string version = readOnlyAttribute(reader, KEY2Token::version, KEY2Token::NS_URI_KEY);
+
+ switch (tokenizer(version.c_str()))
+ {
+ case KEY2Token::VERSION_STR_2 :
+ return VERSION_KEYNOTE_2;
+ case KEY2Token::VERSION_STR_3 :
+ return VERSION_KEYNOTE_3;
+ case KEY2Token::VERSION_STR_4 :
+ return VERSION_KEYNOTE_4;
+ case KEY2Token::VERSION_STR_5 :
+ return VERSION_KEYNOTE_5;
+ }
+ }
+
+ // TODO: test for v.1 and v.6
+
+ return VERSION_UNKNOWN;
}
Version detectVersion(const WPXInputStreamPtr_t &input, Source &source)
--
1.8.3.1
...@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libetonyek,1)) ...@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libetonyek,1))
$(eval $(call gb_UnpackedTarball_add_patches,libetonyek,\ $(eval $(call gb_UnpackedTarball_add_patches,libetonyek,\
external/libetonyek/0001-fix-windows-build.patch \ external/libetonyek/0001-fix-windows-build.patch \
external/libetonyek/libetonyek-doubledelete.patch.0 \ external/libetonyek/libetonyek-doubledelete.patch.0 \
external/libetonyek/0001-impl.-XML-format-detection.patch \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment