* Rename parseFontSize to parseLength

* Use that for the line height
This commit is contained in:
Aditya Bhatt
2013-06-20 11:46:45 +02:00
parent 06e29d3ff4
commit b54a00a869
2 changed files with 10 additions and 9 deletions
+2 -2
View File
@@ -356,7 +356,7 @@ odf.OdfUtils = function OdfUtils() {
* @param {!string} positiveLength
* @return {?{value:!number,unit:!string}}
*/
function parseFontSize(positiveLength) {
function parseLength(positiveLength) {
var re = /-?([0-9]*[1-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px)|(%))/,
m = re.exec(positiveLength);
if (!m) {
@@ -364,5 +364,5 @@ odf.OdfUtils = function OdfUtils() {
}
return {value: parseFloat(m[1]), unit: m[3]};
}
this.parseFontSize = parseFontSize;
this.parseLength = parseLength;
};
+8 -7
View File
@@ -438,7 +438,7 @@ odf.Style2CSS = function Style2CSS() {
function getFontSize(styleNode) {
var props = getDirectChild(/**@type{Element}*/(styleNode), stylens, 'text-properties');
if (props) {
return utils.parseFontSize(props.getAttributeNS(fons, 'font-size'));
return utils.parseLength(props.getAttributeNS(fons, 'font-size'));
}
return null;
}
@@ -539,7 +539,7 @@ odf.Style2CSS = function Style2CSS() {
* @return {!string}
*/
function getParagraphProperties(props) {
var rule = '', imageProps, url, element, value;
var rule = '', imageProps, url, element, lineHeight;
rule += applySimpleMapping(props, paragraphPropertySimpleMapping);
imageProps = props.getElementsByTagNameNS(stylens, 'background-image');
if (imageProps.length > 0) {
@@ -552,12 +552,13 @@ odf.Style2CSS = function Style2CSS() {
}
}
value = props.getAttributeNS(fons, 'line-height');
if (value && value !== 'normal') {
if (value.indexOf('%') === -1) {
rule += 'line-height: ' + value + ';';
lineHeight = props.getAttributeNS(fons, 'line-height');
if (lineHeight && lineHeight !== 'normal') {
lineHeight = utils.parseLength(lineHeight);
if (lineHeight.unit !== '%') {
rule += 'line-height: ' + lineHeight.value + ';';
} else {
rule += 'line-height: ' + parseFloat(value) / 100 + ';';
rule += 'line-height: ' + lineHeight.value / 100 + ';';
}
}