mirror of
https://github.com/webodf/WebODF.git
synced 2026-11-30 16:47:58 +01:00
* Rename parseFontSize to parseLength
* Use that for the line height
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 + ';';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user