Merge pull request #2744 from tsiegleauq/issue2576-parsing-does-not-end

add precise text decoration (fixes #2576)
This commit is contained in:
Norman Jäckel 2016-12-07 22:14:49 +01:00 committed by GitHub
commit 787805efa6

View File

@ -619,42 +619,47 @@ angular.module('OpenSlidesApp.core.pdf', [])
alreadyConverted.push(st); alreadyConverted.push(st);
break; break;
case "span": case "span":
if (lineNumberMode == "inline") { if (element.getAttribute("data-line-number")) {
if (diff_mode != DIFF_MODE_INSERT) { if (lineNumberMode == "inline") {
var lineNumberInline = element.getAttribute("data-line-number"), if (diff_mode != DIFF_MODE_INSERT) {
lineNumberObjInline = { var lineNumberInline = element.getAttribute("data-line-number"),
text: lineNumberInline, lineNumberObjInline = {
text: lineNumberInline,
color: "gray",
fontSize: 5
};
currentParagraph.text.push(lineNumberObjInline);
}
parseChildren(alreadyConverted, element, currentParagraph, styles, diff_mode);
} else if (lineNumberMode == "outside") {
var lineNumberOutline;
if (diff_mode == DIFF_MODE_INSERT) {
lineNumberOutline = "";
} else {
lineNumberOutline = element.getAttribute("data-line-number");
}
var lineNumberObject = {
width: 20,
text: lineNumberOutline,
color: "gray", color: "gray",
fontSize: 5 fontSize: 8,
}; margin: [0, 2, 0, 0]
currentParagraph.text.push(lineNumberObjInline); },
col = {
columns: [
lineNumberObject,
]
};
currentParagraph = create("text");
col.columns.push(currentParagraph);
parseChildren(col.columns[0], element, currentParagraph, styles, diff_mode);
alreadyConverted.push(col);
} }
parseChildren(alreadyConverted, element, currentParagraph, styles, diff_mode); }
} else if (lineNumberMode == "outside") { else {
var lineNumberOutline; var spanText = create("text", element.textContent.replace(/\n/g, ""));
if (diff_mode == DIFF_MODE_INSERT) { ComputeStyle(spanText, styles);
lineNumberOutline = ""; currentParagraph.text.push(spanText);
} else {
lineNumberOutline = element.getAttribute("data-line-number");
}
var lineNumberObject = {
width: 20,
text: lineNumberOutline,
color: "gray",
fontSize: 8,
margin: [0, 2, 0, 0]
},
col = {
columns: [
lineNumberObject,
]
};
currentParagraph = create("text");
col.columns.push(currentParagraph);
parseChildren(col.columns[0], element, currentParagraph, styles, diff_mode);
alreadyConverted.push(col);
} else {
parseChildren(alreadyConverted, element, currentParagraph, styles, diff_mode);
} }
break; break;
case "br": case "br":
@ -704,7 +709,6 @@ angular.module('OpenSlidesApp.core.pdf', [])
width *= scaleByHeight; width *= scaleByHeight;
height *= scaleByHeight; height *= scaleByHeight;
} }
alreadyConverted.push({ alreadyConverted.push({
image: BaseMap[element.getAttribute("src")], image: BaseMap[element.getAttribute("src")],
width: width, width: width,
@ -745,17 +749,12 @@ angular.module('OpenSlidesApp.core.pdf', [])
} }
break; break;
default: default:
var temporary = create("text", element.textContent.replace(/\n/g, "")); var defaultText = create("text", element.textContent.replace(/\n/g, ""));
if (styles) {
ComputeStyle(temporary, styles);
}
// TODO: This if-clause is a hotfix for issue #2442.
// Do this right! Why is currentParagraph undefined?
if (!currentParagraph) { if (!currentParagraph) {
currentParagraph = {}; currentParagraph = {};
currentParagraph.text = []; currentParagraph.text = [];
} }
currentParagraph.text.push(temporary); currentParagraph.text.push(defaultText);
break; break;
} }
return currentParagraph; return currentParagraph;