gui
[lbook_fbreader.git] / fbreader / src / formats / rtf / RtfPlugin.cpp
blob1d66e6e4183cc690563e6d18df7e5a9838105bb4
1 /*
2 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
20 #include <ZLTime.h>
22 #include <ZLStringUtil.h>
23 #include <ZLFile.h>
24 #include <ZLInputStream.h>
26 #include "RtfPlugin.h"
27 #include "RtfDescriptionReader.h"
28 #include "RtfBookReader.h"
29 #include "../../description/BookDescription.h"
31 bool RtfPlugin::providesMetaInfo() const {
32 return false;
35 bool RtfPlugin::acceptsFile(const ZLFile &file) const {
36 const std::string &extension = file.extension();
37 return (extension == "rtf");
40 bool RtfPlugin::readDescription(const std::string &path, BookDescription &description) const {
41 ZLFile file(path);
42 shared_ptr<ZLInputStream> stream = file.inputStream();
44 if (stream.isNull()) {
45 return false;
48 detectEncodingAndLanguage(description, *stream);
50 if (!RtfDescriptionReader(description).readDocument(path)) {
51 return false;
54 return true;
57 bool RtfPlugin::readModel(const BookDescription &description, BookModel &model) const {
58 return RtfBookReader(model, description.encoding()).readDocument(description.fileName());
61 const std::string &RtfPlugin::iconName() const {
62 static const std::string ICON_NAME = "rtf";
63 return ICON_NAME;
66 FormatInfoPage *RtfPlugin::createInfoPage(ZLOptionsDialog&, const std::string&) {
67 return 0;