blob: 33c01a2192422b926dc8cf4070c1d4f4a9ca1a9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* This file is part of the libsw602 project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <libsw602/Software602Document.h>
#include <librevenge-stream/librevenge-stream.h>
#include "WinText602Header.h"
#include "WinText602Parser.h"
using std::string;
namespace libsw602
{
namespace
{
RVNGInputStreamPtr getContent(librevenge::RVNGInputStream *const ip)
{
const RVNGInputStreamPtr input(ip, SW602_shared_ptr_noop_deleter<librevenge::RVNGInputStream>());
RVNGInputStreamPtr strm;
if (input->isStructured())
strm.reset(input->getSubStreamByName("CONTENTS"));
return strm;
}
}
bool Software602Document::isSupported(librevenge::RVNGInputStream *input) try
{
if (!input)
return false;
RVNGInputStreamPtr content = getContent(input);
if (bool(content))
{
content->seek(0, librevenge::RVNG_SEEK_SET);
WinText602Header header(content.get());
return header.isValid();
}
return false;
}
catch (...)
{
return false;
}
bool Software602Document::parse(librevenge::RVNGInputStream *input, librevenge::RVNGTextInterface *document) try
{
if (!input || !document)
return false;
if (!Software602Document::isSupported(input))
return false;
RVNGInputStreamPtr content = getContent(input);
if (bool(content))
{
content->seek(0, librevenge::RVNG_SEEK_SET);
WinText602Parser parser(content.get(), document);
return parser.parse();
}
return false;
}
catch (...)
{
return false;
}
} // namespace libsw602
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|