Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lintest/fb2edit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKandrashin Denis <mail@lintest.ru>2012-10-22 13:53:08 +0400
committerKandrashin Denis <mail@lintest.ru>2012-10-22 13:53:19 +0400
commitcb4e49037c0175aae21986c68fff95849ee26b16 (patch)
tree7a9402b002a0b392790e3a0e537c886fe81bacb9
parentb08d59484a4a32657d8c5d6264b3bc4a53a6c8f4 (diff)
Fix "l:href" attributes
-rw-r--r--source/fb2save.cpp40
-rw-r--r--source/fb2save.hpp6
2 files changed, 34 insertions, 12 deletions
diff --git a/source/fb2save.cpp b/source/fb2save.cpp
index 5e5f870..1c918e2 100644
--- a/source/fb2save.cpp
+++ b/source/fb2save.cpp
@@ -300,7 +300,8 @@ FbSaveHandler::TextHandler::TextHandler(FbSaveWriter &writer, const QString &nam
, m_level(1)
, m_hasChild(false)
{
- Init(atts);
+ m_writer.writeStartElement(m_tag, m_level);
+ writeAtts(atts);
}
FbSaveHandler::TextHandler::TextHandler(TextHandler *parent, const QString &name, const QXmlAttributes &atts, const QString &tag)
@@ -310,10 +311,11 @@ FbSaveHandler::TextHandler::TextHandler(TextHandler *parent, const QString &name
, m_level(parent->nextLevel())
, m_hasChild(false)
{
- Init(atts);
+ m_writer.writeStartElement(m_tag, m_level);
+ writeAtts(atts);
}
-void FbSaveHandler::TextHandler::Init(const QXmlAttributes &atts)
+void FbSaveHandler::TextHandler::writeAtts(const QXmlAttributes &atts)
{
if (m_tag.isEmpty()) return;
m_writer.writeStartElement(m_tag, m_level);
@@ -410,8 +412,16 @@ FbSaveHandler::SpanHandler::SpanHandler(TextHandler *parent, const QString &name
FbSaveHandler::AnchorHandler::AnchorHandler(TextHandler *parent, const QString &name, const QXmlAttributes &atts)
: TextHandler(parent, name, atts, "a")
{
- QString href = Value(atts, "href");
- m_writer.writeAttribute("l:href", href);
+}
+
+void FbSaveHandler::AnchorHandler::writeAtts(const QXmlAttributes &atts)
+{
+ int count = atts.count();
+ for (int i = 0; i < count; i++) {
+ QString name = atts.qName(i);
+ if (name == "href") name == "l:href";
+ m_writer.writeAttribute(name, atts.value(i));
+ }
}
//---------------------------------------------------------------------------
@@ -421,11 +431,21 @@ FbSaveHandler::AnchorHandler::AnchorHandler(TextHandler *parent, const QString &
FbSaveHandler::ImageHandler::ImageHandler(TextHandler *parent, const QString &name, const QXmlAttributes &atts)
: TextHandler(parent, name, atts, "image")
{
- QString src = Value(atts, "src");
- QString file = m_writer.getFileName(src);
- file.prepend('#');
- m_writer.writeAttribute("l:href", file);
- m_writer.writeEndElement(0);
+}
+
+void FbSaveHandler::ImageHandler::writeAtts(const QXmlAttributes &atts)
+{
+ int count = atts.count();
+ for (int i = 0; i < count; i++) {
+ QString name = atts.qName(i);
+ QString value = atts.value(i);
+ if (name == "src") {
+ name == "l:href";
+ value = m_writer.getFileName(value);
+ value.prepend('#');
+ }
+ m_writer.writeAttribute(name, value);
+ }
}
//---------------------------------------------------------------------------
diff --git a/source/fb2save.hpp b/source/fb2save.hpp
index eafa763..ff72c6e 100644
--- a/source/fb2save.hpp
+++ b/source/fb2save.hpp
@@ -119,7 +119,7 @@ private:
virtual void TxtTag(const QString &text);
virtual void EndTag(const QString &name);
protected:
- void Init(const QXmlAttributes &atts);
+ virtual void writeAtts(const QXmlAttributes &atts);
virtual int nextLevel() const;
protected:
FbSaveWriter &m_writer;
@@ -157,6 +157,8 @@ private:
{
public:
explicit AnchorHandler(TextHandler *parent, const QString &name, const QXmlAttributes &atts);
+ protected:
+ virtual void writeAtts(const QXmlAttributes &atts);
};
class ImageHandler : public TextHandler
@@ -164,7 +166,7 @@ private:
public:
explicit ImageHandler(TextHandler *parent, const QString &name, const QXmlAttributes &atts);
protected:
- virtual void EndTag(const QString &name) { Q_UNUSED(name); }
+ virtual void writeAtts(const QXmlAttributes &atts);
};
class ParagHandler : public TextHandler