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