19 package org.openoffice.xmerge.converter.xml.sxc;
21 import java.awt.Color;
23 import org.w3c.dom.NodeList;
24 import org.w3c.dom.Node;
25 import org.w3c.dom.NamedNodeMap;
26 import org.w3c.dom.Element;
53 NamedNodeMap attrNodes = node.getAttributes();
54 if (attrNodes != null) {
55 int len = attrNodes.getLength();
56 for (
int i = 0;
i < len;
i++) {
57 Node attr = attrNodes.item(
i);
65 if (node.hasChildNodes()) {
66 NodeList children = node.getChildNodes();
67 int len = children.getLength();
68 for (
int i = 0;
i < len;
i++) {
69 Node child = children.item(
i);
70 String nodeName = child.getNodeName();
71 if (nodeName.equals(
"style:properties")) {
72 NamedNodeMap childAttrNodes = child.getAttributes();
73 if (childAttrNodes != null) {
74 int nChildAttrNodes = childAttrNodes.getLength();
75 for (
int j = 0; j < nChildAttrNodes; j++) {
76 Node attr = childAttrNodes.item(j);
100 super(name, family, parent, sc);
126 red =
Integer.parseInt(value.substring(1, 3), 16);
127 green =
Integer.parseInt(value.substring(3, 5), 16);
128 blue =
Integer.parseInt(value.substring(5, 7), 16);
129 }
catch (NumberFormatException e) {
131 }
catch (IndexOutOfBoundsException e) {
134 return new Color(red, green, blue, 0);
145 if (attr.equals(
"fo:font-weight")) {
149 else if (attr.equals(
"fo:font-style")) {
150 if (value.equals(
"italic") || value.equals(
"oblique"))
152 else if (value.equals(
"normal"))
156 else if (attr.equals(
"style:text-underline")) {
160 else if (attr.equals(
"style:text-crossing-out")) {
164 else if (attr.equals(
"style:text-position")) {
165 if (value.startsWith(
"super "))
167 else if (value.startsWith(
"sub "))
169 else if (value.startsWith(
"0% "))
172 String firstPart = value.substring(0, value.indexOf(
' '));
173 if (firstPart.endsWith(
"%")) {
174 firstPart = firstPart.substring(0, value.indexOf(
'%'));
177 amount =
Integer.parseInt(firstPart);
178 }
catch (NumberFormatException e) {
188 else if (attr.equals(
"fo:font-size")) {
189 if (value.endsWith(
"pt")) {
190 String num = value.substring(0, value.length() - 2);
195 else if (attr.equals(
"style:font-name"))
198 else if (attr.equals(
"fo:color"))
201 else if (attr.equals(
"fo:background-color"))
204 else if (attr.equals(
"fo:text-align")) {
205 if(value.equals(
"center")) {
207 }
else if(value.equals(
"end")) {
209 }
else if(value.equals(
"start")) {
214 else if (attr.equals(
"fo:vertical-align")) {
215 if(value.equals(
"top")) {
217 }
else if(value.equals(
"middle")) {
219 }
else if(value.equals(
"bottom")) {
224 else if (attr.equals(
"fo:border")) {
230 else if (attr.equals(
"fo:border-top")) {
233 else if (attr.equals(
"fo:border-bottom")) {
236 else if (attr.equals(
"fo:border-left")) {
239 else if (attr.equals(
"fo:border-right")) {
242 else if (attr.equals(
"fo:wrap-option")) {
279 if (parentStyle == null)
285 }
else if (!
name.equals(
"DEFAULT_STYLE")) {
286 parentStyle = (
CellStyle)
sc.lookup(
"DEFAULT_STYLE", null,
287 null,
this.getClass());
293 if (parentStyle != null) {
332 Element node = parentDoc.createElement(name);
348 if (style.getClass() != this.
getClass())
366 node.setAttribute(
"fo:text-align",
"end");
369 node.setAttribute(
"fo:text-align",
"start");
372 node.setAttribute(
"fo:text-align",
"center");
375 node.setAttribute(
"fo:vertical-align",
"top");
378 node.setAttribute(
"fo:vertical-align",
"middle");
381 node.setAttribute(
"fo:vertical-align",
"bottom");
384 node.setAttribute(
"fo:font-weight",
"bold");
387 node.setAttribute(
"fo:font-style",
"italic");
390 node.setAttribute(
"style:text-underline",
"single");
393 node.setAttribute(
"style:text-crossing-out",
"single-line");
396 node.setAttribute(
"style:text-position",
"super 58%");
399 node.setAttribute(
"style:text-position",
"sub 58%");
406 node.setAttribute(
"style:font-name", fmt.
getFontName());
412 node.setAttribute(
"fo:background-color",
416 node.setAttribute(
"fo:border-top",
"0.0008inch solid #000000");
419 node.setAttribute(
"fo:border-bottom",
"0.0008inch solid #000000");
422 node.setAttribute(
"fo:border-right",
"0.0008inch solid #000000");
425 node.setAttribute(
"fo:border-left",
"0.0008inch solid #000000");
428 node.setAttribute(
"fo:wrap-option",
"wrap");
440 return String.format(
"#%06X", c.getRGB() & 0x00FFFFFF);
444 "style:text-autospace",
"style:text-underline-color",
445 "fo:margin-left",
"fo:margin-right",
"fo:text-indent",
446 "fo:margin-top",
"fo:margin-bottom",
"text:line-number",
447 "text:number-lines",
"style:country-asian",
448 "style:font-size-asian",
"style:font-name-complex",
449 "style:language-complex",
"style:country-complex",
450 "style:font-size-complex",
"style:punctuation-wrap",
451 "fo:language",
"fo:country",
452 "style:font-name-asian",
"style:language-asian",
453 "style:line-break",
"fo:keep-with-next"
465 for (
int i = 0;
i < ignored.length;
i++) {
466 if (ignored[
i].equals(attribute))
static final int INFO
Informational messages.
Node createNode(org.w3c.dom.Document parentDoc, String name)
Create a new.
Color parseColorString(String value)
Parse a color specification of the form { #rrggbb}.
Provides general purpose utilities.
static void log(int flag, String msg)
Log message based on the flag type.
String buildColorString(Color c)
Given a.
static final int ERROR
Error messages.
exports com.sun.star. java
void handleAttribute(String attr, String value)
Set an attribute.
PyRef getClass(const OUString &name, const Runtime &runtime)
String family
Family of the.
CellStyle(Node node, StyleCatalog sc)
Constructor for use when going from DOM to client device format.
String parent
Parent of the.
boolean isIgnored(String attribute)
This code checks whether an attribute is one that we intentionally ignore.
Format getFormat()
Returns the.
T * clone(T *const other)
boolean isSubset(Style style)
Return.
Provides interfaces for converting between two.
This class is used for logging debug messages.
void writeAttributes(Element node)
Write this.
CellStyle(String name, String family, String parent, Format fmt, StyleCatalog sc)
Constructor for use when going from client device format to DOM.
Style getResolved()
Return a.