19package org.openoffice.xmerge.converter.xml.sxc;
23import org.w3c.dom.NodeList;
24import org.w3c.dom.Node;
25import org.w3c.dom.NamedNodeMap;
26import 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);
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% "))
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")) {
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%");
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"
A StyleCatalog holds a collection of Style objects.
An object of class Style represents a style in an OpenOffice document.
String parent
Parent of the Style.
String family
Family of the Style.
String name
Name of the Style.
Represents a text Style in an OpenOffice document.
CellStyle(Node node, StyleCatalog sc)
Constructor for use when going from DOM to client device format.
boolean isSubset(Style style)
Return true if style specifies as much or less than this Style, and nothing it specifies contradicts ...
Style getResolved()
Return a Style object corresponding to this one, but with all of the inherited information from paren...
void writeAttributes(Element node)
Write this Style object's attributes to a Node in the Document.
String buildColorString(Color c)
Given a Color, return a string of the form #rrggbb.
Format getFormat()
Returns the Format object for this particular style.
Color parseColorString(String value)
Parse a color specification of the form #rrggbb.
CellStyle(String name, String family, String parent, Format fmt, StyleCatalog sc)
Constructor for use when going from client device format to DOM.
boolean isIgnored(String attribute)
This code checks whether an attribute is one that we intentionally ignore.
Node createNode(org.w3c.dom.Document parentDoc, String name)
Create a new Node in the Document, and write this Style to it.
void handleAttribute(String attr, String value)
Set an attribute.
This class is used for logging debug messages.
static final int INFO
Informational messages.
static void log(int flag, String msg)
Log message based on the flag type.
static final int ERROR
Error messages.
T * clone(T *const other)
Document and PluginFactory implementations for XML based formats.
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...