[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/export-epub-moji] filters/words/epub: Rename some variables to make the code clearer.
From:       Inge Wallin <inge () lysator ! liu ! se>
Date:       2012-07-31 23:58:52
Message-ID: 20120731235852.C4BA2A6094 () git ! kde ! org
[Download RAW message or body]

Git commit 51955c573447fc88251b4a96cd53737c44d6fdf7 by Inge Wallin.
Committed on 01/08/2012 at 01:16.
Pushed by ingwa into branch 'export-epub-moji'.

Rename some variables to make the code clearer.

M  +43   -40   filters/words/epub/htmlconvert.cpp

http://commits.kde.org/calligra/51955c573447fc88251b4a96cd53737c44d6fdf7

diff --git a/filters/words/epub/htmlconvert.cpp b/filters/words/epub/htmlconvert.cpp
index 225ed2b..78e3372 100644
--- a/filters/words/epub/htmlconvert.cpp
+++ b/filters/words/epub/htmlconvert.cpp
@@ -395,22 +395,25 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
         return qMakePair(KoFilter::ParsingError, false);
     }
 
-    QDomNode childNode;
-    QDomElement nodeElement;
+    QDomNode currentNode;
+    QDomElement nodeElement;    // currentNode as Element
     int sibl = 0;
-    childNode = doc.documentElement().firstChild();
-    childNode = childNode.nextSibling();
-    childNode = childNode.firstChild().firstChild().nextSibling();
 
-    // Set childNode to the node we want to operate on next. 
+    // Find the first node that has actual content.
+    // FIXME: This should be made more robust.
+    currentNode = doc.documentElement().firstChild();
+    currentNode = currentNode.nextSibling();
+    currentNode = currentNode.firstChild().firstChild().nextSibling();
+
+    // Set currentNode to the node we want to operate on next. 
     if (flagMoreHtml) {
         for (int i = 0; i <startNode; i++){
-            childNode = childNode.nextSibling();
+            currentNode = currentNode.nextSibling();
         }
 
         sibl = startNode;
     }
-    nodeElement = childNode.toElement();
+    nodeElement = currentNode.toElement();
 
     QDomNode pNode;
 
@@ -448,22 +451,22 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
                 bodyWriter->addAttribute("class", styleClass);
             }
 
-            QDomNode node = childNode.firstChild();
+            QDomNode node = currentNode.firstChild();
 
             if (node.isCharacterData()) {
                 QDomCharacterData charData = node.toCharacterData();
                 pFlag = true;
                 bodyWriter->addTextNode(charData.data());
-                pNode = childNode;
-                childNode = node.nextSibling();
-                nodeElement = childNode.toElement();
+                pNode = currentNode;
+                currentNode = node.nextSibling();
+                nodeElement = currentNode.toElement();
                 continue;
             }
             else if (node.isElement()) {
                 pFlag = true;
-                pNode = childNode;
-                childNode = childNode.firstChild();
-                nodeElement = childNode.toElement();
+                pNode = currentNode;
+                currentNode = currentNode.firstChild();
+                nodeElement = currentNode.toElement();
                 continue;
             }
             else {
@@ -487,30 +490,30 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
             bodyWriter->addTextSpan(text);
             bodyWriter->endElement(); // span
 
-            QDomNode node = childNode.nextSibling();
+            QDomNode node = currentNode.nextSibling();
 
             if (node.isCharacterData()) {
                 //kDebug(30517) <<"isCharacterData";
                 QDomCharacterData charData = node.toCharacterData();
                 pFlag = true;
                 bodyWriter->addTextNode(charData.data());
-                childNode = node.nextSibling();
-                nodeElement = childNode.toElement();
+                currentNode = node.nextSibling();
+                nodeElement = currentNode.toElement();
                 continue;
             }
             else if (node.isElement()) {
                 pFlag = true;
-                childNode = childNode.firstChild();
-                nodeElement = childNode.toElement();
+                currentNode = currentNode.firstChild();
+                nodeElement = currentNode.toElement();
                 continue;
             }
 
-            childNode = pNode;
-            nodeElement = childNode.toElement();
+            currentNode = pNode;
+            nodeElement = currentNode.toElement();
         }
         else if (nodeElement.tagName() == "s") {
-           childNode = childNode.nextSibling();
-           nodeElement = childNode.toElement();
+           currentNode = currentNode.nextSibling();
+           nodeElement = currentNode.toElement();
         }
         else if (nodeElement.tagName() == "table") {
             // Handle table
@@ -519,9 +522,9 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
 
             // FIXME: I don't understand this at all. /IW
             if (pFlag) {
-                if (childNode.nextSibling().isNull()) {
-                    childNode = pNode;
-                    nodeElement = childNode.toElement();
+                if (currentNode.nextSibling().isNull()) {
+                    currentNode = pNode;
+                    nodeElement = currentNode.toElement();
                     pFlag = false;
                 }
             }
@@ -538,7 +541,7 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
             bodyWriter->addAttribute("alt", "(No Description)");
 
             // Check image tag to find image source
-            QDomElement imgElement = childNode.firstChild().toElement();
+            QDomElement imgElement = currentNode.firstChild().toElement();
 
             QString imgSrc = imgElement.attribute("href").section('/', 1); // I like section :)
             bodyWriter->addAttribute("src", imgSrc);
@@ -546,10 +549,10 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
 
             if (pFlag) {
                 // FIXME: What's going on here?? /IW
-                if (childNode.nextSibling().isNull()) {
+                if (currentNode.nextSibling().isNull()) {
                     bodyWriter->endElement(); // Why isn't the img tag *always* ended?
-                    childNode = pNode;
-                    nodeElement = childNode.toElement();
+                    currentNode = pNode;
+                    nodeElement = currentNode.toElement();
                     pFlag = false;
                 }
             }
@@ -559,10 +562,10 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
         else if (nodeElement.tagName() == "soft-page-break") {
             bodyWriter->addTextNode(nodeElement.text().toUtf8());
             if (pFlag) {
-                if (childNode.nextSibling().isNull()) {
+                if (currentNode.nextSibling().isNull()) {
                    bodyWriter->endElement();
-                    childNode = pNode;
-                    nodeElement = childNode.toElement();
+                    currentNode = pNode;
+                    nodeElement = currentNode.toElement();
                     pFlag = false;
                 }
             }
@@ -570,15 +573,15 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
         // Ignore unknown tag
         else {
             if (!pFlag) {
-                childNode = childNode.nextSibling();
-                nodeElement = childNode.toElement();
+                currentNode = currentNode.nextSibling();
+                nodeElement = currentNode.toElement();
                 continue;
             }
         }
 
         if (pFlag) {
-            childNode = pNode;
-            nodeElement = childNode.toElement();
+            currentNode = pNode;
+            nodeElement = currentNode.toElement();
             pFlag = false;
         }
 
@@ -595,8 +598,8 @@ QPair<KoFilter::ConversionStatus, bool> convertContent(KoStore *odfStore, QHash<
         if (!pFlag)
             sibl++;
 
-        childNode = childNode.nextSibling();
-        nodeElement = childNode.toElement();
+        currentNode = currentNode.nextSibling();
+        nodeElement = currentNode.toElement();
     }
 
     bodyWriter->endElement(); // body

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic