diff options
author | Kandrashin Denis <mail@lintest.ru> | 2012-11-08 18:07:20 +0400 |
---|---|---|
committer | Kandrashin Denis <mail@lintest.ru> | 2012-11-08 18:07:20 +0400 |
commit | 72e93d4f40d3a64cb40dc971d431aa9d25b98a0e (patch) | |
tree | bbfea23553247c2f0aa6c4aaef22ac7588c0bef6 | |
parent | 03f3b9f008231b223ad566af83ded97c376104ef (diff) |
Try to use logging class: FbMessage
-rw-r--r-- | fb2edit.pro | 178 | ||||
-rw-r--r-- | source/fb2dock.cpp | 1 | ||||
-rw-r--r-- | source/fb2head.hpp | 2 | ||||
-rw-r--r-- | source/fb2list.cpp | 1 | ||||
-rw-r--r-- | source/fb2logs.cpp | 68 | ||||
-rw-r--r-- | source/fb2logs.hpp | 37 | ||||
-rw-r--r-- | source/fb2main.cpp | 6 | ||||
-rw-r--r-- | source/fb2main.hpp | 3 | ||||
-rw-r--r-- | source/fb2page.hpp | 2 | ||||
-rw-r--r-- | source/fb2read.cpp | 1 | ||||
-rw-r--r-- | source/fb2read.hpp | 4 | ||||
-rw-r--r-- | source/fb2save.hpp | 4 | ||||
-rw-r--r-- | source/fb2xml.cpp | 24 | ||||
-rw-r--r-- | source/fb2xml.hpp (renamed from source/fb2xml.h) | 9 | ||||
-rw-r--r-- | source/fb2xml2.cpp | 363 | ||||
-rw-r--r-- | source/fb2xml2.h | 41 |
16 files changed, 232 insertions, 512 deletions
diff --git a/fb2edit.pro b/fb2edit.pro index 9f85c89..e9569b8 100644 --- a/fb2edit.pro +++ b/fb2edit.pro @@ -1,88 +1,90 @@ -HEADERS = \ - source/fb2xml.h \ - source/fb2xml2.h \ - source/fb2html.h \ - source/fb2app.hpp \ - source/fb2code.hpp \ - source/fb2dlgs.hpp \ - source/fb2dock.hpp \ - source/fb2head.hpp \ - source/fb2imgs.hpp \ - source/fb2list.hpp \ - source/fb2main.hpp \ - source/fb2note.hpp \ - source/fb2page.hpp \ - source/fb2read.hpp \ - source/fb2tree.hpp \ - source/fb2save.hpp \ - source/fb2text.hpp \ - source/fb2utils.h \ - source/fb2mode.h - -SOURCES = \ - source/fb2app.cpp \ - source/fb2code.cpp \ - source/fb2dlgs.cpp \ - source/fb2dock.cpp \ - source/fb2head.cpp \ - source/fb2html.cpp \ - source/fb2imgs.cpp \ - source/fb2list.cpp \ - source/fb2main.cpp \ - source/fb2note.cpp \ - source/fb2page.cpp \ - source/fb2read.cpp \ - source/fb2save.cpp \ - source/fb2tree.cpp \ - source/fb2xml.cpp \ - source/fb2xml2.cpp \ - source/fb2text.cpp \ - source/fb2utils.cpp \ - source/fb2mode.cpp - -RESOURCES = \ - 3rdparty/gnome/gnome.qrc \ - source/res/fb2edit.qrc \ - source/js/javascript.qrc \ - 3rdparty/fb2/fb2.qrc - -TARGET = fb2edit - -TRANSLATIONS = source/ts/ru.ts - -QT += xml -QT += webkit -QT += network -QT += xmlpatterns - -OTHER_FILES += \ - source/res/style.css \ - source/res/blank.fb2 \ - source/js/export.js \ - source/js/set_cursor.js \ - source/js/get_status.js \ - source/js/insert_title.js \ - CMakeLists.txt \ - source/js/new_section1.js \ - source/js/section_get.js \ - source/js/section_new.js \ - source/js/location.js \ - source/res/mainicon.rc \ - 3rdparty/fb2/FictionBookLinks.xsd \ - 3rdparty/fb2/FictionBookLang.xsd \ - 3rdparty/fb2/FictionBookGenres.xsd \ - 3rdparty/fb2/FictionBook2.1.xsd - -if (unix) { - - DEFINES += FB2_USE_LIBXML2 - INCLUDEPATH += /usr/include/libxml2 - LIBS += -lxml2 - -} - -FORMS += \ - source/fb2find.ui \ - source/fb2setup.ui - -win32:RC_FILE = source/res/mainicon.rc +HEADERS = \
+ source/fb2html.h \
+ source/fb2app.hpp \
+ source/fb2code.hpp \
+ source/fb2dlgs.hpp \
+ source/fb2dock.hpp \
+ source/fb2head.hpp \
+ source/fb2imgs.hpp \
+ source/fb2list.hpp \
+ source/fb2main.hpp \
+ source/fb2note.hpp \
+ source/fb2page.hpp \
+ source/fb2read.hpp \
+ source/fb2tree.hpp \
+ source/fb2save.hpp \
+ source/fb2text.hpp \
+ source/fb2utils.h \
+ source/fb2xml.hpp \
+ source/fb2mode.h \
+ source/fb2xml2.h \
+ source/fb2logs.hpp
+
+SOURCES = \
+ source/fb2app.cpp \
+ source/fb2code.cpp \
+ source/fb2dlgs.cpp \
+ source/fb2dock.cpp \
+ source/fb2head.cpp \
+ source/fb2html.cpp \
+ source/fb2imgs.cpp \
+ source/fb2list.cpp \
+ source/fb2main.cpp \
+ source/fb2note.cpp \
+ source/fb2page.cpp \
+ source/fb2read.cpp \
+ source/fb2save.cpp \
+ source/fb2tree.cpp \
+ source/fb2xml.cpp \
+ source/fb2xml2.cpp \
+ source/fb2text.cpp \
+ source/fb2utils.cpp \
+ source/fb2mode.cpp \
+ source/fb2logs.cpp
+
+RESOURCES = \
+ 3rdparty/gnome/gnome.qrc \
+ source/res/fb2edit.qrc \
+ source/js/javascript.qrc \
+ 3rdparty/fb2/fb2.qrc
+
+TARGET = fb2edit
+
+TRANSLATIONS = source/ts/ru.ts
+
+QT += xml
+QT += webkit
+QT += network
+QT += xmlpatterns
+
+OTHER_FILES += \
+ source/res/style.css \
+ source/res/blank.fb2 \
+ source/js/export.js \
+ source/js/set_cursor.js \
+ source/js/get_status.js \
+ source/js/insert_title.js \
+ CMakeLists.txt \
+ source/js/new_section1.js \
+ source/js/section_get.js \
+ source/js/section_new.js \
+ source/js/location.js \
+ source/res/mainicon.rc \
+ 3rdparty/fb2/FictionBookLinks.xsd \
+ 3rdparty/fb2/FictionBookLang.xsd \
+ 3rdparty/fb2/FictionBookGenres.xsd \
+ 3rdparty/fb2/FictionBook2.1.xsd
+
+if (unix) {
+
+ DEFINES += FB2_USE_LIBXML2
+ INCLUDEPATH += /usr/include/libxml2
+ LIBS += -lxml2
+
+}
+
+FORMS += \
+ source/fb2find.ui \
+ source/fb2setup.ui
+
+win32:RC_FILE = source/res/mainicon.rc
diff --git a/source/fb2dock.cpp b/source/fb2dock.cpp index ec07166..0a3c493 100644 --- a/source/fb2dock.cpp +++ b/source/fb2dock.cpp @@ -54,6 +54,7 @@ FbMainDock::FbMainDock(QWidget *parent) addWidget(m_head);
addWidget(m_code);
+ connect(m_text->page(), SIGNAL(log(FbMessage)), parent, SLOT(log(FbMessage)));
connect(m_text->page(), SIGNAL(status(QString)), parent, SLOT(status(QString)));
connect(m_head, SIGNAL(status(QString)), parent, SLOT(status(QString)));
connect(m_code, SIGNAL(status(QString)), parent, SLOT(status(QString)));
diff --git a/source/fb2head.hpp b/source/fb2head.hpp index eaa2977..258173f 100644 --- a/source/fb2head.hpp +++ b/source/fb2head.hpp @@ -20,7 +20,7 @@ class QLineEdit; QT_END_NAMESPACE #include "fb2mode.h" -#include "fb2xml.h" +#include "fb2xml.hpp" class FbTextEdit; diff --git a/source/fb2list.cpp b/source/fb2list.cpp index 4a88f80..a624523 100644 --- a/source/fb2list.cpp +++ b/source/fb2list.cpp @@ -8,6 +8,7 @@ FbListView::FbListView(QWidget *parent) : QTreeView(parent)
{
setAllColumnsShowFocus(true);
+ setRootIsDecorated(false);
}
void FbListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
diff --git a/source/fb2logs.cpp b/source/fb2logs.cpp new file mode 100644 index 0000000..82fcfab --- /dev/null +++ b/source/fb2logs.cpp @@ -0,0 +1,68 @@ +#include "fb2logs.hpp"
+
+//---------------------------------------------------------------------------
+// FbMessage
+//---------------------------------------------------------------------------
+
+class FbMessagePrivate
+{
+public:
+ FbMessagePrivate()
+ : level(FbMessage::Message), row(-1), col(-1)
+ {
+ }
+
+ FbMessagePrivate(const FbMessagePrivate &other)
+ : level(other.level), msg(other.msg), row(other.row), col(other.col)
+ {
+ }
+private:
+ friend class FbMessage;
+ FbMessage::Level level;
+ QString msg;
+ int row;
+ int col;
+};
+
+FbMessage::FbMessage()
+ : d(new FbMessagePrivate)
+{
+}
+
+FbMessage::FbMessage(const FbMessage &other)
+ : d(new FbMessagePrivate(*other.d))
+{
+}
+
+FbMessage::FbMessage(const QXmlParseException &error, Level level)
+ : d(new FbMessagePrivate)
+{
+ d->level = level;
+ d->msg = error.message().simplified();
+ d->row = error.lineNumber();
+ d->col = error.columnNumber();
+}
+
+FbMessage::~FbMessage()
+{
+}
+
+QString FbMessage::msg() const
+{
+ return d->msg;
+}
+
+int FbMessage::level() const
+{
+ return d->level;
+}
+
+int FbMessage::row() const
+{
+ return d->row;
+}
+
+int FbMessage::col() const
+{
+ return d->col;
+}
diff --git a/source/fb2logs.hpp b/source/fb2logs.hpp new file mode 100644 index 0000000..00a8093 --- /dev/null +++ b/source/fb2logs.hpp @@ -0,0 +1,37 @@ +#ifndef FB2LOGS_H
+#define FB2LOGS_H
+
+#include <QScopedPointer>
+#include <QXmlParseException>
+
+class FbMessagePrivate;
+
+class FbMessage : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum Level {
+ Message,
+ Warring,
+ Error,
+ Fatal
+ };
+
+public:
+ explicit FbMessage();
+ FbMessage(const FbMessage &other);
+ FbMessage(const QXmlParseException &error, Level level = Message);
+ ~FbMessage();
+
+ QString msg() const;
+ int level() const;
+ int row() const;
+ int col() const;
+
+private:
+ QScopedPointer<FbMessagePrivate> d;
+
+};
+
+#endif // FB2LOGS_H
diff --git a/source/fb2main.cpp b/source/fb2main.cpp index be0fcd6..29b4196 100644 --- a/source/fb2main.cpp +++ b/source/fb2main.cpp @@ -8,6 +8,7 @@ #include "fb2code.hpp" #include "fb2dlgs.hpp" #include "fb2dock.hpp" +#include "fb2logs.hpp" #include "fb2save.hpp" #include "fb2text.hpp" #include "fb2utils.h" @@ -45,6 +46,11 @@ FbMainWindow::FbMainWindow(const QString &filename, ViewMode mode) mainDock->load(filepath); } +void FbMainWindow::log(const FbMessage &msg) +{ + logMessage(msg.msg()); +} + void FbMainWindow::logMessage(const QString &message) { if (!messageEdit) { diff --git a/source/fb2main.hpp b/source/fb2main.hpp index 0e7bf75..68eb620 100644 --- a/source/fb2main.hpp +++ b/source/fb2main.hpp @@ -16,6 +16,8 @@ QT_END_NAMESPACE class FbMainDock; +class FbMessage; + class FbLogDock: public QDockWidget { Q_OBJECT @@ -46,6 +48,7 @@ signals: void showInspectorChecked(bool); public slots: + void log(const FbMessage &msg); void logMessage(const QString &message); void status(const QString &text); diff --git a/source/fb2page.hpp b/source/fb2page.hpp index 24db7a0..9bd478b 100644 --- a/source/fb2page.hpp +++ b/source/fb2page.hpp @@ -9,6 +9,7 @@ class FbStore; class FbTextElement; class FbNetworkAccessManager; +#include "fb2logs.hpp" #include "fb2mode.h" class FbTextLogger : public QObject @@ -47,6 +48,7 @@ public: signals: void status(const QString &text); + void log(const FbMessage &msg); public slots: void html(const QString &html, FbStore *store); diff --git a/source/fb2read.cpp b/source/fb2read.cpp index 54c6536..da361f7 100644 --- a/source/fb2read.cpp +++ b/source/fb2read.cpp @@ -46,6 +46,7 @@ bool FbReadThread::parse() FbReadHandler handler(writer); connect(&handler, SIGNAL(binary(QString,QByteArray)), m_store, SLOT(binary(QString,QByteArray))); +// connect(&handler, SIGNAL(log(FbMessage)), parent(), SIGNAL(log(FbMessage))); #ifdef FB2_USE_LIBXML2 XML2::XmlReader reader; diff --git a/source/fb2read.hpp b/source/fb2read.hpp index e1c132c..0a6880e 100644 --- a/source/fb2read.hpp +++ b/source/fb2read.hpp @@ -1,7 +1,7 @@ #ifndef FB2READ_H #define FB2READ_H -#include "fb2xml.h" +#include "fb2xml.hpp" #include <QByteArray> #include <QMutex> @@ -36,7 +36,7 @@ private: QString m_html; }; -class FbReadHandler : public QObject, public FbXmlHandler +class FbReadHandler : public FbXmlHandler { Q_OBJECT diff --git a/source/fb2save.hpp b/source/fb2save.hpp index c1e0bd6..c375ece 100644 --- a/source/fb2save.hpp +++ b/source/fb2save.hpp @@ -1,7 +1,7 @@ #ifndef FB2SAVE_H #define FB2SAVE_H -#include "fb2xml.h" +#include "fb2xml.hpp" #include "fb2imgs.hpp" #include <QByteArray> @@ -42,7 +42,7 @@ private: QLabel * label; }; -class FbHtmlHandler : public QObject, public FbXmlHandler +class FbHtmlHandler : public FbXmlHandler { Q_OBJECT diff --git a/source/fb2xml.cpp b/source/fb2xml.cpp index 7cd3d51..20cc8e2 100644 --- a/source/fb2xml.cpp +++ b/source/fb2xml.cpp @@ -1,4 +1,4 @@ -#include "fb2xml.h" +#include "fb2xml.hpp" #include <QtDebug> //--------------------------------------------------------------------------- @@ -99,30 +99,21 @@ bool FbXmlHandler::endElement(const QString & namespaceURI, const QString & loca return m_handler && m_handler->doEnd(qName.toLower(), found); } -bool FbXmlHandler::error(const QXmlParseException& exception) +bool FbXmlHandler::warning(const QXmlParseException& exception) { - qCritical() << QObject::tr("Parse error at line %1, column %2: %3") - .arg(exception.lineNumber()) - .arg(exception.columnNumber()) - .arg(exception.message().simplified()); - return false; + emit log(FbMessage(exception, FbMessage::Warring)); + return true; } -bool FbXmlHandler::warning(const QXmlParseException& exception) +bool FbXmlHandler::error(const QXmlParseException& exception) { - qWarning() << QObject::tr("Parse error at line %1, column %2: %3") - .arg(exception.lineNumber()) - .arg(exception.columnNumber()) - .arg(exception.message().simplified()); + emit log(FbMessage(exception, FbMessage::Error)); return false; } bool FbXmlHandler::fatalError(const QXmlParseException &exception) { - qCritical() << QObject::tr("Parse error at line %1, column %2: %3") - .arg(exception.lineNumber()) - .arg(exception.columnNumber()) - .arg(exception.message().simplified()); + emit log(FbMessage(exception, FbMessage::Fatal)); return false; } @@ -130,4 +121,3 @@ QString FbXmlHandler::errorString() const { return m_error; } - diff --git a/source/fb2xml.h b/source/fb2xml.hpp index 3882f7e..6c6ebf1 100644 --- a/source/fb2xml.h +++ b/source/fb2xml.hpp @@ -6,6 +6,8 @@ #include <QXmlStreamReader> #include <QXmlStreamWriter> +#include "fb2logs.hpp" + #define FB2_BEGIN_KEYLIST private: enum Keyword { #define FB2_END_KEYLIST None }; \ @@ -25,8 +27,10 @@ x::KeywordHash::KeywordHash() { #define FB2_KEY(key,str) insert(str,key); -class FbXmlHandler : public QXmlDefaultHandler +class FbXmlHandler : public QObject, public QXmlDefaultHandler { + Q_OBJECT + public: explicit FbXmlHandler(); virtual ~FbXmlHandler(); @@ -38,6 +42,9 @@ public: bool fatalError(const QXmlParseException &exception); QString errorString() const; +signals: + void log(const FbMessage &msg); + protected: class NodeHandler { diff --git a/source/fb2xml2.cpp b/source/fb2xml2.cpp index 587eef2..c53c3e1 100644 --- a/source/fb2xml2.cpp +++ b/source/fb2xml2.cpp @@ -12,368 +12,7 @@ namespace XML2 { //--------------------------------------------------------------------------- -// XML2::HtmlReader -//--------------------------------------------------------------------------- - -class HtmlReaderLocator : public QXmlLocator { -public: - HtmlReaderLocator(HtmlReader* r) : reader(r) {} - virtual int columnNumber(void) const; - virtual int lineNumber(void) const; -private: - HtmlReader* reader; -}; - -class HtmlReaderPrivate -{ -private: - class ClosedTag : public QList<QString> { public: ClosedTag(); }; -public: - ~HtmlReaderPrivate(void) {} -private: - HtmlReaderPrivate(HtmlReader* reader); - - static void startDocument(void* c); - static void endDocument(void* c); - static void startElement(void* c, const xmlChar* name, const xmlChar** attrs); - static void endElement(void* c, const xmlChar* name); - static void comment(void* c, const xmlChar* value); - static void cdataBlock(void* c, const xmlChar* value, int len); - static void processingInstruction(void* c, const xmlChar* target, const xmlChar* data); - static void characters(void* c, const xmlChar* ch, int len); - static void ignorableWhitespace(void* c, const xmlChar* ch, int len); - static void internalSubset(void* c, const xmlChar* name, const xmlChar* publicId, const xmlChar* systemId); - - static QString C2S(const xmlChar* text, int size = -1); - static QString local(const QString &name); - - void parse(const QXmlInputSource* input); - - QScopedPointer<HtmlReaderLocator> locator; - Q_DECLARE_PUBLIC(HtmlReader) - HtmlReader* q_ptr; - - QXmlEntityResolver* entityresolver; - QXmlDTDHandler* dtdhandler; - QXmlContentHandler* contenthandler; - QXmlErrorHandler* errorhandler; - QXmlLexicalHandler* lexicalhandler; - QXmlDeclHandler* declhandler; - - xmlParserCtxt* context; - QList<QString> closed; - - friend class HtmlReaderLocator; -}; - -HtmlReaderPrivate::HtmlReaderPrivate(HtmlReader* reader) - : q_ptr(reader), entityresolver(0), dtdhandler(0), contenthandler(0), errorhandler(0), lexicalhandler(0), declhandler(0), context(0) -{ - this->locator.reset(new HtmlReaderLocator(reader)); -} - -HtmlReaderPrivate::ClosedTag::ClosedTag() -{ - *this << "area"; - *this << "base"; - *this << "br"; - *this << "col"; - *this << "command"; - *this << "embed"; - *this << "hr"; - *this << "img"; - *this << "input"; - *this << "keygen"; - *this << "link"; - *this << "meta"; - *this << "param"; - *this << "source"; - *this << "track"; - *this << "wbr"; -} - -QString HtmlReaderPrivate::C2S(const xmlChar* text, int size) -{ - return QString::fromLocal8Bit(reinterpret_cast<const char*>(text), size); -} - -void HtmlReaderPrivate::parse(const QXmlInputSource* input) -{ - htmlSAXHandler handler; - QByteArray arr = input->data().toUtf8(); - - std::memset(&handler, 0, sizeof(handler)); - handler.startDocument = &HtmlReaderPrivate::startDocument; - handler.endDocument = &HtmlReaderPrivate::endDocument; - handler.startElement = &HtmlReaderPrivate::startElement; - handler.endElement = &HtmlReaderPrivate::endElement; - handler.comment = &HtmlReaderPrivate::comment; - handler.cdataBlock = &HtmlReaderPrivate::cdataBlock; - handler.processingInstruction = &HtmlReaderPrivate::processingInstruction; - handler.characters = &HtmlReaderPrivate::characters; - handler.ignorableWhitespace = &HtmlReaderPrivate::ignorableWhitespace; - handler.internalSubset = &HtmlReaderPrivate::internalSubset; - - this->context = htmlCreatePushParserCtxt(&handler, this, arr.constData(), arr.size(), "", XML_CHAR_ENCODING_UTF8); - htmlParseChunk(this->context, NULL, 0, 1); - htmlFreeParserCtxt(this->context); - xmlCleanupParser(); -} - -void HtmlReaderPrivate::startDocument(void* c) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->contenthandler) { - r->contenthandler->startDocument(); - } -} - -void HtmlReaderPrivate::endDocument(void* c) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->contenthandler) { - r->contenthandler->endDocument(); - } -} - -QString HtmlReaderPrivate::local(const QString &name) -{ - return name.mid(name.lastIndexOf(":")); -} - -void HtmlReaderPrivate::startElement(void* c, const xmlChar* name, const xmlChar** attrs) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->contenthandler) { - QXmlAttributes a; - if (attrs) { - int i = 0; - while (attrs[i]) { - QString qName = C2S(attrs[i]); - a.append(qName, "", local(qName), C2S(attrs[i+1])); - i += 2; - } - } - static ClosedTag closed; - QString qName = C2S(name); - QString localName = local(qName); - r->contenthandler->startElement("", localName, qName, a); - if (closed.indexOf(qName.toLower()) != -1) { - r->contenthandler->endElement("", localName, qName); - } - } -} - -void HtmlReaderPrivate::endElement(void* c, const xmlChar* name) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->contenthandler) { - QString qName = C2S(name); - r->contenthandler->endElement("", local(qName), qName); - } -} - -void HtmlReaderPrivate::comment(void* c, const xmlChar* value) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->lexicalhandler) { - r->lexicalhandler->comment(C2S(value)); - } -} - -void HtmlReaderPrivate::cdataBlock(void* c, const xmlChar* value, int len) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->lexicalhandler) { - r->lexicalhandler->startCDATA(); - if (r->contenthandler) { - r->contenthandler->characters(C2S(value, len)); - } - r->lexicalhandler->endCDATA(); - } -} - -void HtmlReaderPrivate::processingInstruction(void* c, const xmlChar* target, const xmlChar* data) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->contenthandler) { - r->contenthandler->processingInstruction(C2S(target), C2S(data)); - } -} - -void HtmlReaderPrivate::characters(void* c, const xmlChar* ch, int len) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->contenthandler) { - r->contenthandler->characters(C2S(ch, len)); - } -} - -void HtmlReaderPrivate::ignorableWhitespace(void* c, const xmlChar* ch, int len) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->contenthandler) { - r->contenthandler->ignorableWhitespace(C2S(ch, len)); - } -} - -void HtmlReaderPrivate::internalSubset(void* c, const xmlChar* name, const xmlChar* publicId, const xmlChar* systemId) -{ - HtmlReaderPrivate* r = reinterpret_cast<HtmlReaderPrivate*>(c); - if (r->lexicalhandler) { - r->lexicalhandler->startDTD(C2S(name), C2S(publicId), C2S(systemId)); - r->lexicalhandler->endDTD(); - } - -} - -HtmlReader::HtmlReader(void) - : d_ptr(new HtmlReaderPrivate(this)) -{ -} - -HtmlReader::~HtmlReader(void) -{ -} - -bool HtmlReader::feature(const QString&, bool* ok) const -{ - if (ok) { - *ok = false; - } - - return false; -} - -void HtmlReader::setFeature(const QString&, bool) -{ -} - -bool HtmlReader::hasFeature(const QString&) const -{ - return false; -} - -void* HtmlReader::property(const QString&, bool* ok) const -{ - if (ok) { - *ok = false; - } - - return 0; -} - -void HtmlReader::setProperty(const QString&, void*) -{ -} - -bool HtmlReader::hasProperty(const QString&) const -{ - return false; -} - -void HtmlReader::setEntityResolver(QXmlEntityResolver* handler) -{ - Q_D(HtmlReader); - d->entityresolver = handler; -} - -QXmlEntityResolver* HtmlReader::entityResolver(void) const -{ - const HtmlReaderPrivate* d = this->d_func(); - return d->entityresolver; -} - -void HtmlReader::setDTDHandler(QXmlDTDHandler* handler) -{ - Q_D(HtmlReader); - d->dtdhandler = handler; -} - -QXmlDTDHandler* HtmlReader::DTDHandler(void) const -{ - const HtmlReaderPrivate* d = this->d_func(); - return d->dtdhandler; -} - -void HtmlReader::setContentHandler(QXmlContentHandler* handler) -{ - Q_D(HtmlReader); - d->contenthandler = handler; -} - -QXmlContentHandler* HtmlReader::contentHandler(void) const -{ - const HtmlReaderPrivate* d = this->d_func(); - return d->contenthandler; -} - -void HtmlReader::setErrorHandler(QXmlErrorHandler* handler) -{ - Q_D(HtmlReader); - d->errorhandler = handler; -} - -QXmlErrorHandler* HtmlReader::errorHandler(void) const -{ - const HtmlReaderPrivate* d = this->d_func(); - return d->errorhandler; -} - -void HtmlReader::setLexicalHandler(QXmlLexicalHandler* handler) -{ - Q_D(HtmlReader); - d->lexicalhandler = handler; -} - -QXmlLexicalHandler* HtmlReader::lexicalHandler(void) const -{ - const HtmlReaderPrivate* d = this->d_func(); - return d->lexicalhandler; -} - -void HtmlReader::setDeclHandler(QXmlDeclHandler* handler) -{ - Q_D(HtmlReader); - d->declhandler = handler; -} - -QXmlDeclHandler* HtmlReader::declHandler(void) const -{ - const HtmlReaderPrivate* d = this->d_func(); - return d->declhandler; -} - -bool HtmlReader::parse(const QXmlInputSource& input) -{ - return this->parse(&input); -} - -bool HtmlReader::parse(const QXmlInputSource* input) -{ - Q_D(HtmlReader); - - if (d->contenthandler) { - d->contenthandler->setDocumentLocator(d->locator.data()); - } - - d->parse(input); - - return true; -} - -int HtmlReaderLocator::columnNumber(void) const -{ - return this->reader->d_func()->context->input->col; -} - -int HtmlReaderLocator::lineNumber(void) const -{ - return this->reader->d_func()->context->input->line; -} - -//--------------------------------------------------------------------------- -// XML2::HtmlReader +// XML2::XmlReader //--------------------------------------------------------------------------- class XmlReaderLocator : public QXmlLocator { diff --git a/source/fb2xml2.h b/source/fb2xml2.h index c049a89..881ce7c 100644 --- a/source/fb2xml2.h +++ b/source/fb2xml2.h @@ -26,47 +26,10 @@ namespace XML2 { -class HtmlReaderPrivate; - -class HtmlReader : public QXmlReader { -public: - HtmlReader(void); - virtual ~HtmlReader(void); - - virtual bool feature(const QString& name, bool* ok = 0) const; - virtual void setFeature(const QString& name, bool value); - virtual bool hasFeature(const QString& name) const; - virtual void* property(const QString& name, bool* ok = 0) const; - virtual void setProperty(const QString& name, void* value); - virtual bool hasProperty(const QString& name) const; - - virtual void setEntityResolver(QXmlEntityResolver* handler); - virtual QXmlEntityResolver* entityResolver(void) const; - virtual void setDTDHandler(QXmlDTDHandler* handler); - virtual QXmlDTDHandler* DTDHandler(void) const; - virtual void setContentHandler(QXmlContentHandler* handler); - virtual QXmlContentHandler* contentHandler(void) const; - virtual void setErrorHandler(QXmlErrorHandler* handler); - virtual QXmlErrorHandler* errorHandler(void) const; - virtual void setLexicalHandler(QXmlLexicalHandler* handler); - virtual QXmlLexicalHandler* lexicalHandler(void) const; - virtual void setDeclHandler(QXmlDeclHandler* handler); - virtual QXmlDeclHandler* declHandler(void) const; - - virtual bool parse(const QXmlInputSource& input); - virtual bool parse(const QXmlInputSource* input); - -private: - Q_DISABLE_COPY(HtmlReader) - Q_DECLARE_PRIVATE(HtmlReader) - QScopedPointer<HtmlReaderPrivate> d_ptr; - - friend class HtmlReaderLocator; -}; - class XmlReaderPrivate; -class XmlReader : public QXmlReader { +class XmlReader : public QXmlReader +{ public: XmlReader(void); virtual ~XmlReader(void); |