| 34 |
34 |
anchor = frame.getAttributeNS(textns, 'anchor-type'),
|
| 35 |
35 |
x = frame.getAttributeNS(svgns, 'x'),
|
| 36 |
36 |
y = frame.getAttributeNS(svgns, 'y'),
|
| 37 |
|
width, height, minheight, minwidth;
|
|
37 |
width = frame.getAttributeNS(svgns, 'width'),
|
|
38 |
height = frame.getAttributeNS(svgns, 'height'),
|
|
39 |
minheight = frame.getAttributeNS(fons, 'min-height'),
|
|
40 |
minwidth = frame.getAttributeNS(fons, 'min-width');
|
| 38 |
41 |
if (anchor === "as-char") {
|
| 39 |
42 |
rule = 'display: inline-block;';
|
| 40 |
43 |
} else if (anchor || x || y) {
|
| 41 |
44 |
rule = 'position: absolute;';
|
| 42 |
|
} else {
|
|
45 |
} else if (width || height || minheight || minwidth) {
|
| 43 |
46 |
rule = 'display: block;';
|
| 44 |
47 |
}
|
| 45 |
48 |
if (x) {
|
| ... | ... | |
| 48 |
51 |
if (y) {
|
| 49 |
52 |
rule += 'top: ' + y + ';';
|
| 50 |
53 |
}
|
| 51 |
|
width = frame.getAttributeNS(svgns, 'width');
|
| 52 |
54 |
if (width) {
|
| 53 |
55 |
rule += 'width: ' + width + ';';
|
| 54 |
56 |
}
|
| 55 |
|
height = frame.getAttributeNS(svgns, 'height');
|
| 56 |
57 |
if (height) {
|
| 57 |
58 |
rule += 'height: ' + height + ';';
|
| 58 |
59 |
}
|
| 59 |
|
minheight = frame.getAttributeNS(fons, 'min-height');
|
| 60 |
60 |
if (minheight) {
|
| 61 |
61 |
rule += 'min-height: ' + minheight + ';';
|
| 62 |
62 |
}
|
| 63 |
|
minwidth = frame.getAttributeNS(fons, 'min-width');
|
| 64 |
63 |
if (minwidth) {
|
| 65 |
64 |
rule += 'min-width: ' + minwidth + ';';
|
| 66 |
65 |
}
|
| 67 |
|
rule = 'draw|' + frame.localName + '[styleid="' + id + '"] {' + rule + '}';
|
| 68 |
|
stylesheet.insertRule(rule, stylesheet.cssRules.length);
|
|
66 |
if (rule) {
|
|
67 |
rule = 'draw|' + frame.localName + '[styleid="' + id + '"] {' + rule +
|
|
68 |
'}';
|
|
69 |
stylesheet.insertRule(rule, stylesheet.cssRules.length);
|
|
70 |
}
|
| 69 |
71 |
}
|
| 70 |
72 |
function setImage(id, container, image, stylesheet) {
|
| 71 |
73 |
image.setAttribute('styleid', id);
|
| ... | ... | |
| 82 |
84 |
callback(url);
|
| 83 |
85 |
} else {
|
| 84 |
86 |
part = container.getPart(url);
|
| 85 |
|
part.load();
|
| 86 |
87 |
part.onchange = function (part) {
|
| 87 |
88 |
callback(part.url);
|
| 88 |
89 |
};
|
|
90 |
part.load();
|
| 89 |
91 |
}
|
| 90 |
92 |
} catch (e) {
|
|
93 |
alert('slight problem');
|
| 91 |
94 |
}
|
| 92 |
95 |
}
|
| 93 |
96 |
function modifyImages(container, odfbody, stylesheet) {
|
| ... | ... | |
| 105 |
108 |
function namespaceResolver(prefix) {
|
| 106 |
109 |
return namespaces[prefix];
|
| 107 |
110 |
}
|
| 108 |
|
drawiter = doc.evaluate("*//draw:*" +
|
|
111 |
frames = [];
|
|
112 |
node = odfbody.firstChild;
|
|
113 |
while (node && node !== odfbody) {
|
|
114 |
if (node.namespaceURI === drawns) {
|
|
115 |
frames[frames.length] = node;
|
|
116 |
// alert(frames.length + " " + node.localName);
|
|
117 |
}
|
|
118 |
if (node.firstChild) {
|
|
119 |
node = node.firstChild;
|
|
120 |
} else {
|
|
121 |
while (node !== odfbody && !node.nextSibling) {
|
|
122 |
node = node.parentNode;
|
|
123 |
}
|
|
124 |
if (node.nextSibling) {
|
|
125 |
node = node.nextSibling;
|
|
126 |
}
|
|
127 |
}
|
|
128 |
}
|
|
129 |
/*
|
|
130 |
drawiter = doc.evaluate("*"+"//draw:*" +
|
| 109 |
131 |
"[@svg:x|@svg:y|@svg:width|@svg:height|@fo:min-height|@fo:min-width]",
|
| 110 |
|
odfbody, namespaceResolver, XPathResult.ANY_TYPE, null);
|
|
132 |
odfbody, namespaceResolver, 0, null);
|
| 111 |
133 |
node = drawiter.iterateNext();
|
| 112 |
|
frames = [];
|
| 113 |
134 |
while (node) {
|
| 114 |
135 |
frames[frames.length] = node;
|
| 115 |
136 |
node = drawiter.iterateNext();
|
| 116 |
137 |
}
|
|
138 |
*/
|
| 117 |
139 |
for (i = 0; i < frames.length; i += 1) {
|
| 118 |
140 |
node = frames[i];
|
| 119 |
141 |
setFramePosition('frame' + i, node, stylesheet);
|
| ... | ... | |
| 159 |
181 |
|
| 160 |
182 |
odfnode = container.rootElement;
|
| 161 |
183 |
document.importNode(odfnode, true);
|
| 162 |
|
|
| 163 |
184 |
handleStyles(odfnode);
|
| 164 |
185 |
// do content last, because otherwise the document is constantly updated
|
| 165 |
186 |
// whenever the css changes
|