~ubuntu-branches/ubuntu/vivid/libe-book/vivid-proposed

« back to all changes in this revision

Viewing changes to src/conv/html/ebook2html.cpp

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2014-08-07 23:08:06 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20140807230806-o06a0n2dspjavqfm
Tags: 0.1.1-2
* upload to unstable

* fix debian/copyright; this is MPL-2.0 only 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
 
/* libe-book
3
 
 * Version: MPL 2.0 / LGPLv2.1+
 
2
/*
 
3
 * This file is part of the libe-book project.
4
4
 *
5
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 
 *
9
 
 * Alternatively, the contents of this file may be used under the terms
10
 
 * of the GNU Lesser General Public License Version 2.1 or later
11
 
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
12
 
 * applicable instead of those above.
13
 
 *
14
 
 * For further information visit http://libebook.sourceforge.net
15
8
 */
16
9
 
17
10
#include <stdio.h>
18
11
#include <string.h>
19
12
 
20
 
#include <libwpd-stream/libwpd-stream.h>
 
13
#include <boost/shared_ptr.hpp>
 
14
 
 
15
#include <librevenge-generators/librevenge-generators.h>
 
16
#include <librevenge-stream/librevenge-stream.h>
21
17
 
22
18
#include <libe-book/libe-book.h>
23
19
 
24
 
#include "HtmlDocumentGenerator.h"
25
20
 
26
21
#ifdef HAVE_CONFIG_H
27
22
#include "config.h"
36
31
 
37
32
int printUsage()
38
33
{
39
 
  printf("Usage: ebook2html [OPTION] <e-book>\n");
 
34
  printf("Usage: ebook2html [OPTION] <e-book file> | <e-book directory>\n");
40
35
  printf("\n");
41
36
  printf("Options:\n");
42
37
  printf("--help                Shows this help message\n");
74
69
  if (!file)
75
70
    return printUsage();
76
71
 
77
 
  WPXFileStream input(file);
78
 
 
79
 
  if (!EBOOKDocument::isSupported(&input))
 
72
  boost::shared_ptr<librevenge::RVNGInputStream> input;
 
73
 
 
74
  if (librevenge::RVNGDirectoryStream::isDirectory(file))
 
75
    input.reset(new librevenge::RVNGDirectoryStream(file));
 
76
  else
 
77
    input.reset(new librevenge::RVNGFileStream(file));
 
78
 
 
79
  EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN;
 
80
  EBOOKDocument::Confidence confidence = EBOOKDocument::isSupported(input.get(), &type);
 
81
 
 
82
  if (EBOOKDocument::CONFIDENCE_SUPPORTED_PART == confidence)
 
83
  {
 
84
    input.reset(librevenge::RVNGDirectoryStream::createForParent(file));
 
85
    confidence = EBOOKDocument::isSupported(input.get(), &type);
 
86
  }
 
87
 
 
88
  librevenge::RVNGString document;
 
89
  librevenge::RVNGHTMLTextGenerator documentGenerator(document);
 
90
 
 
91
  if (EBOOKDocument::RESULT_OK != EBOOKDocument::parse(input.get(), &documentGenerator, type))
80
92
    return 1;
81
93
 
82
 
  HtmlDocumentGenerator documentGenerator;
 
94
  printf("%s", document.cstr());
83
95
 
84
 
  return EBOOKDocument::parse(&input, &documentGenerator) ? 0 : 1;
 
96
  return 0;
85
97
}
86
98
 
87
99
/* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */