[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/export-epub-moji] filters/words/epub: Some more cleaning.
From: Inge Wallin <inge () lysator ! liu ! se>
Date: 2012-07-31 19:56:20
Message-ID: 20120731195620.89965A60A6 () git ! kde ! org
[Download RAW message or body]
Git commit a786bd290b636de3d4d41bb646bc0d9f71357628 by Inge Wallin.
Committed on 31/07/2012 at 21:54.
Pushed by ingwa into branch 'export-epub-moji'.
Some more cleaning.
M +24 -31 filters/words/epub/htmlconvert.cpp
http://commits.kde.org/calligra/a786bd290b636de3d4d41bb646bc0d9f71357628
diff --git a/filters/words/epub/htmlconvert.cpp b/filters/words/epub/htmlconvert.cpp
index bd2e21c..e50e6f0 100644
--- a/filters/words/epub/htmlconvert.cpp
+++ b/filters/words/epub/htmlconvert.cpp
@@ -34,7 +34,7 @@
#include <KoStore.h>
#include <KoXmlWriter.h>
-// epub filter
+// EPUB filter
#include "libepub/EpubFile.h"
@@ -359,19 +359,16 @@ KoFilter::ConversionStatus stylesParse(KoStore *odfStore,
}
-QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *input, \
QHash<QString, QString> &metaData, +QPair<KoFilter::ConversionStatus, bool> \
convertContent(KoStore *odfStore, QHash<QString, QString> &metaData, EpubFile *epub,
QByteArray &result, QList<QString> \
&breakBeforeStylesList,
int &startNode, bool \
flagMoreHtml) {
- if (!input->open("content.xml")) {
+ if (!odfStore->open("content.xml")) {
kDebug(30517) << "Can not open content.html .";
- delete input;
return qMakePair(KoFilter::FileNotFound, false);
}
- //KoStoreDevice htmlStore(htmlWriter);
- //KoXmlWriter *bodyWriter = new KoXmlWriter(&htmlStore);
QBuffer outBuf(&result);
KoXmlWriter *bodyWriter = new KoXmlWriter(&outBuf);
@@ -417,7 +414,7 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore \
*input, QHash<QSt QDomDocument doc("content");
QString errorMsg;
int errorLine, errorColumn;
- if (!doc.setContent(input->device(), true, &errorMsg, &errorLine, &errorColumn)) \
{ + if (!doc.setContent(odfStore->device(), true, &errorMsg, &errorLine, \
&errorColumn)) { kDebug() << "Error occured while parsing content.xml "
<< errorMsg << " in Line: " << errorLine
<< " Column: " << errorColumn;
@@ -426,32 +423,28 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore \
*input, QHash<QSt
QDomNode childNode;
QDomElement nodeElement;
- int sibl = 0;
+ int sibl = 0;
+ childNode = doc.documentElement().firstChild();
+ childNode = childNode.nextSibling();
+ childNode = childNode.firstChild().firstChild().nextSibling();
if (!flagMoreHtml) {
- childNode = doc.documentElement().firstChild();
- childNode = childNode.nextSibling();
- childNode = childNode.firstChild().firstChild().nextSibling();
nodeElement = childNode.toElement();
}
- else{
- childNode = doc.documentElement().firstChild();
- childNode = childNode.nextSibling();
- childNode = childNode.firstChild().firstChild().nextSibling();
+ else {
for (int i = 0; i <startNode; i++){
childNode = childNode.nextSibling();
}
nodeElement = childNode.toElement();
sibl = startNode;
-
}
QDomNode pNode;
- bool pFlag = false; // FIXME: moji: document this flag
+ bool pFlag = false; // True if inside a top level <p>.
while (!nodeElement.isNull() || pFlag) {
- //kDebug(30517) << nodeElement.tagName() <<pFlag;
+ //kDebug(30517) << nodeElement.tagName() <<pFlag;
// Check for tag table
if (nodeElement.tagName() == "table") {
@@ -478,7 +471,7 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore \
*input, QHash<QSt columnsNumber++;
}
- //===== tqble-row ======
+ //===== table-row ======
while (tableElement.tagName() == "table-row") { // FIXME: we dont have a \
tag for table-column. bodyWriter->startElement("tr");
@@ -514,8 +507,7 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore \
*input, QHash<QSt bodyWriter->endElement(); // tagName()
}
}
- else
- {
+ else {
bodyWriter->addTextNode(cellTextElement.text());
}
bodyWriter->endElement(); // tagName(p)
@@ -532,31 +524,32 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore \
*input, QHash<QSt tableNode = tableNode.nextSibling();
tableElement = tableNode.toElement();
} // end while write tag row
+
if (pFlag) {
if (childNode.nextSibling().isNull()) {
bodyWriter->endElement();
- childNode = pNode;
- nodeElement = childNode.toElement();
- pFlag = false;
+ childNode = pNode;
+ nodeElement = childNode.toElement();
+ pFlag = false;
}
}
}
else if (nodeElement.tagName() == "p" || nodeElement.tagName() =="h") {
- // check for break before
- if (breakBeforeStylesList.contains(nodeElement.attribute("style-name")) \
&& startNode!=sibl) { + // A break-before in the style means create a new \
chapter here. + if \
(breakBeforeStylesList.contains(nodeElement.attribute("style-name")) + \
&& startNode != sibl) + {
// We should check that this is root paragraph
if (!pFlag) {
- // This paragraph is root so we should
- // close html file.
+ // This paragraph is at top level so we should close the html \
file and return. bodyWriter->endElement();
bodyWriter->endElement();
// Save this node for next html file.
startNode = sibl;
// Return
- input->close();
+ odfStore->close();
return qMakePair(KoFilter::OK, true);
}
-
}
if (nodeElement.tagName() == "p")
@@ -702,6 +695,6 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore \
*input, QHash<QSt
bodyWriter->endElement(); // html
- input->close();
+ odfStore->close();
return qMakePair(KoFilter::OK, false);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic