1 /** 2 * Copyright (C) 2014 KO GmbH <copyright@kogmbh.com> 3 * 4 * @licstart 5 * This file is part of WebODF. 6 * 7 * WebODF is free software: you can redistribute it and/or modify it 8 * under the terms of the GNU Affero General Public License (GNU AGPL) 9 * as published by the Free Software Foundation, either version 3 of 10 * the License, or (at your option) any later version. 11 * 12 * WebODF is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Affero General Public License for more details. 16 * 17 * You should have received a copy of the GNU Affero General Public License 18 * along with WebODF. If not, see <http://www.gnu.org/licenses/>. 19 * @licend 20 * 21 * @source: http://www.webodf.org/ 22 * @source: https://github.com/kogmbh/WebODF/ 23 */ 24 25 /*global runtime, odf*/ 26 27 /** 28 * Convenient access to style attributes for graphic-properties. 29 * @constructor 30 * @param {!Element} element <style:graphic-properties/> element 31 * @param {!odf.StyleParseUtils} styleParseUtils 32 * @param {!odf.GraphicProperties|undefined} parent 33 */ 34 odf.GraphicProperties = function (element, styleParseUtils, parent) { 35 "use strict"; 36 var self = this, 37 stylens = odf.Namespaces.stylens, 38 svgns = odf.Namespaces.svgns, 39 getter; 40 getter = { 41 verticalPos: function () { 42 var v = element.getAttributeNS(stylens, "vertical-pos"); 43 return v === "" ? undefined : v; 44 }, 45 verticalRel: function () { 46 var v = element.getAttributeNS(stylens, "vertical-rel"); 47 return v === "" ? undefined : v; 48 }, 49 horizontalPos: function () { 50 var v = element.getAttributeNS(stylens, "horizontal-pos"); 51 return v === "" ? undefined : v; 52 }, 53 horizontalRel: function () { 54 var v = element.getAttributeNS(stylens, "horizontal-rel"); 55 return v === "" ? undefined : v; 56 }, 57 strokeWidth: function () { 58 var a = element.getAttributeNS(svgns, "stroke-width"); 59 return styleParseUtils.parseLength(a); 60 } 61 }; 62 /** 63 * @return {!string|undefined} 64 */ 65 this.verticalPos = function () { 66 return /**@type{!string|undefined}*/(self.data.value("verticalPos")); 67 }; 68 /** 69 * @return {!string|undefined} 70 */ 71 this.verticalRel = function () { 72 return /**@type{!string|undefined}*/(self.data.value("verticalRel")); 73 }; 74 /** 75 * @return {!string|undefined} 76 */ 77 this.horizontalPos = function () { 78 return /**@type{!string|undefined}*/(self.data.value("horizontalPos")); 79 }; 80 /** 81 * @return {!string|undefined} 82 */ 83 this.horizontalRel = function () { 84 return /**@type{!string|undefined}*/(self.data.value("horizontalRel")); 85 }; 86 /** 87 * @return {!number|undefined} 88 */ 89 this.strokeWidth = function () { 90 return /**@type{!number|undefined}*/(self.data.value("strokeWidth")); 91 }; 92 /** 93 * @type {!odf.LazyStyleProperties} 94 */ 95 this.data; 96 function init() { 97 var p = parent === undefined ? undefined : parent.data; 98 self.data = new odf.LazyStyleProperties(p, getter); 99 } 100 init(); 101 }; 102 /** 103 * @constructor 104 */ 105 odf.ComputedGraphicProperties = function () { 106 "use strict"; 107 var /**@type{!odf.GraphicProperties|undefined}*/ 108 g; 109 /** 110 * @param {!odf.GraphicProperties|undefined} graphicProperties 111 * @return {undefined} 112 */ 113 this.setGraphicProperties = function (graphicProperties) { 114 g = graphicProperties; 115 }; 116 /** 117 * @return {!string} 118 */ 119 this.verticalPos = function () { 120 return (g && g.verticalPos()) || "from-top"; 121 }; 122 /** 123 * @return {!string} 124 */ 125 this.verticalRel = function () { 126 return (g && g.verticalRel()) || "page"; 127 }; 128 /** 129 * @return {!string} 130 */ 131 this.horizontalPos = function () { 132 return (g && g.horizontalPos()) || "from-left"; 133 }; 134 /** 135 * @return {!string} 136 */ 137 this.horizontalRel = function () { 138 return (g && g.horizontalRel()) || "page"; 139 }; 140 }; 141