diff --git a/js/pptx2html.js b/js/pptx2html.js index 057eaec..535fc45 100644 --- a/js/pptx2html.js +++ b/js/pptx2html.js @@ -168,20 +168,29 @@ function processNodesInSlide(index, node) { function processSpNode($node, $slideLayoutXML, $slideMasterXML) { var type = $node.find("ph").attr("type"); - var text = $node.find("t").text(); + var name = $node.find("cNvPr").attr("name"); var id = $node.find("cNvPr").attr("id"); - console.log(" id: " + id); + var idx = $node.find("nvPr").find("ph").attr("idx"); + console.log(" id: " + id + ", idx: " + idx); - var $slideLayoutSpNode = getSpNodeByID($slideLayoutXML, id); - var $slideMasterSpNode = getSpNodeByID($slideMasterXML, id); - - text = "
"; + "' _id='" + id + "' _idx='" + idx + "' _type='" + type + "' _name='" + name + "'>"; var nodeArr = $node.find("txBody").find("p").each(function(index, node) { var $node = $(node); @@ -268,13 +277,32 @@ function getSpNodeByID($xml, id) { return $xml.find("cNvPr[id=\"" + id + "\"]").parent().parent(); } -function getAlign($node, type) { +function getSpNodeByIDX($xml, idx) { + return $xml.find("ph[idx=\"" + idx + "\"]").parent().parent().parent(); +} + +function getAlign($node, $slideLayoutSpNode, $slideMasterSpNode, type) { // 上中下對齊: X, , var anchor = $node.find("bodyPr").attr("anchor"); + if (anchor === undefined) { + anchor = $slideLayoutSpNode.find("bodyPr").attr("anchor"); + } + if (anchor === undefined) { + anchor = $slideMasterSpNode.find("bodyPr").attr("anchor"); + } // 左中右對齊: X, , var algn = $node.find("pPr").attr("algn"); + if (algn === undefined) { + algn = $slideLayoutSpNode.find("pPr").attr("algn"); + } + if (algn === undefined) { + algn = $slideMasterSpNode.find("pPr").attr("algn"); + if (algn === undefined) { + algn = $slideMasterSpNode.find("lvl1pPr").attr("algn"); + } + } if (type == "title" || type == "subTitle" || type == "ctrTitle") { return "center-center";