21 package org.openoffice.xmerge.converter.xml;
23 import java.awt.Color;
25 import org.w3c.dom.NodeList;
26 import org.w3c.dom.Node;
27 import org.w3c.dom.NamedNodeMap;
28 import org.w3c.dom.Element;
38 final private static int BOLD = 0x01;
40 final private static int ITALIC = 0x02;
78 NamedNodeMap attrNodes = node.getAttributes();
79 if (attrNodes != null) {
80 int len = attrNodes.getLength();
81 for (
int i = 0;
i < len;
i++) {
82 Node attr = attrNodes.item(
i);
90 if (!node.hasChildNodes()) {
93 NodeList children = node.getChildNodes();
94 int len = children.getLength();
95 for (
int i = 0;
i < len;
i++) {
96 Node child = children.item(
i);
97 String nodeName = child.getNodeName();
98 if (nodeName.equals(
"style:properties")) {
99 NamedNodeMap childAttrNodes = child.getAttributes();
100 if (childAttrNodes != null) {
101 int nChildAttrNodes = childAttrNodes.getLength();
102 for (
int j = 0; j < nChildAttrNodes; j++) {
103 Node attr = childAttrNodes.item(j);
105 attr.getNodeValue());
139 int mask,
int values,
int fontSize, String fontName,
StyleCatalog sc) {
140 super(name, family, parent, sc);
143 this.sizeInPoints = fontSize;
160 red =
Integer.parseInt(value.substring(1, 3), 16);
161 green =
Integer.parseInt(value.substring(3, 5), 16);
162 blue =
Integer.parseInt(value.substring(5, 7), 16);
163 }
catch (NumberFormatException e) {
165 }
catch (IndexOutOfBoundsException e) {
168 return new Color(red, green, blue);
179 if (attr.equals(
"fo:font-weight")) {
184 else if (attr.equals(
"fo:font-style")) {
190 else if (attr.equals(
"style:text-underline")) {
191 if (value.equals(
"none"))
197 else if (attr.equals(
"style:text-crossing-out")) {
198 if (value.equals(
"none"))
204 else if (attr.equals(
"style:text-position")) {
205 if (value.startsWith(
"super "))
207 else if (value.startsWith(
"sub "))
209 else if (value.startsWith(
"0% "))
212 String firstPart = value.substring(0, value.indexOf(
' '));
213 if (firstPart.endsWith(
"%")) {
214 firstPart = firstPart.substring(0, value.indexOf(
'%'));
217 amount =
Integer.parseInt(firstPart);
218 }
catch (NumberFormatException e) {
228 else if (attr.equals(
"fo:font-size")) {
229 if (value.endsWith(
"pt")) {
230 String num = value.substring(0, value.length() - 2);
231 sizeInPoints =
Integer.parseInt(num);
235 else if (attr.equals(
"style:font-name"))
238 else if (attr.equals(
"fo:color"))
241 else if (attr.equals(
"style:text-background-color"))
319 if (parentStyle == null)
325 }
else if (!
name.equals(
"DEFAULT_STYLE")) {
326 parentStyle = (
TextStyle)
sc.lookup(
"DEFAULT_STYLE", null,
327 null,
this.getClass());
333 if (parentStyle != null) {
336 if ((sizeInPoints == 0) && (parentStyle.
sizeInPoints != 0))
338 if ((fontName == null) && (parentStyle.
fontName != null))
340 if ((fontColor == null) && (parentStyle.
fontColor != null))
342 if ((bgColor == null) && (parentStyle.
bgColor != null))
345 if (((mask &
m) == 0) && ((parentStyle.
mask & m) != 0)) {
385 return "\"" + value +
"\",";
400 return "\"" + value +
"\"";
419 StringBuilder attributes =
new StringBuilder();
420 for (
int bitVal = 0x01; bitVal <= 0x20; bitVal = bitVal << 1) {
421 if ((bitVal & mask) != 0) {
422 attributes.append(
toCSV(((bitVal & values) != 0) ?
"yes" :
"no"));
425 attributes.append(
toCSV(null));
444 Element node = parentDoc.createElement(name);
460 if (style.getClass() != this.
getClass())
464 if (tStyle.
values != values)
471 if (fontName == null)
473 if (!fontName.equals(tStyle.
fontName))
478 if (fontColor == null)
487 if (!bgColor.equals(tStyle.
bgColor))
502 if ((mask & BOLD) != 0 && (values & BOLD) != 0)
503 node.setAttribute(
"fo:font-weight",
"bold");
505 if ((mask & ITALIC) != 0 && (values & ITALIC) != 0)
506 node.setAttribute(
"fo:font-style",
"italic");
508 if ((mask & UNDERLINE) != 0 && (values & UNDERLINE) != 0)
509 node.setAttribute(
"style:text-underline",
"single");
511 if ((mask & STRIKETHRU) != 0 && (values & STRIKETHRU) != 0)
512 node.setAttribute(
"style:text-crossing-out",
"single-line");
514 if ((mask & SUPERSCRIPT) != 0 && (values & SUPERSCRIPT) != 0)
515 node.setAttribute(
"style:text-position",
"super 58%");
517 if ((mask & SUBSCRIPT) != 0 && (values & SUBSCRIPT) != 0)
518 node.setAttribute(
"style:text-position",
"sub 58%");
520 if (sizeInPoints != 0) {
521 node.setAttribute(
"fo:font-size",
Integer.toString(sizeInPoints) +
"pt");
524 if (fontName != null)
525 node.setAttribute(
"style:font-name", fontName);
527 if (fontColor != null)
531 node.setAttribute(
"style:text-background-color",
543 return String.format(
"#%06X", c.getRGB() & 0x00FFFFFF);
547 "style:text-autospace",
"style:text-underline-color",
548 "fo:margin-left",
"fo:margin-right",
"fo:text-indent",
549 "fo:margin-top",
"fo:margin-bottom",
"text:line-number",
550 "text:number-lines",
"style:country-asian",
551 "style:font-size-asian",
"style:font-name-complex",
552 "style:language-complex",
"style:country-complex",
553 "style:font-size-complex",
"style:punctuation-wrap",
554 "fo:language",
"fo:country",
555 "style:font-name-asian",
"style:language-asian",
556 "style:line-break",
"fo:keep-with-next"
568 for (
String ignored1 : ignored) {
569 if (ignored1.equals(attribute)) {
static final int INFO
Informational messages.
Provides general purpose utilities.
boolean isSubset(Style style)
Return.
static void log(int flag, String msg)
Log message based on the flag type.
String fontName
Font name.
boolean isIgnored(String attribute)
This code checks whether an attribute is one that we intentionally ignore.
final static int ITALIC
Indicates italic text.
static String toCSV(String value)
Private function to return the value as an element in a Comma Separated Value (CSV) format...
void handleAttribute(String attr, String value)
Set an attribute.
final static int SUPERSCRIPT
Indicates superscripted text.
static void dumpHdr()
Print a Comma Separated Value (CSV) header line for the spreadsheet dump.
static final int ERROR
Error messages.
Color getBackgroundColor()
Return the background.
int sizeInPoints
Font size in points.
exports com.sun.star. java
int values
Values of text attributes.
final static int STRIKETHRU
Indicates strike-through in the text.
final static int SUBSCRIPT
Indicates subscripted text.
void turnAttributesOn(int flags)
Set one or more text attributes to on.
PyRef getClass(const OUString &name, const Runtime &runtime)
TextStyle(String name, String family, String parent, int mask, int values, int fontSize, String fontName, StyleCatalog sc)
Constructor for use when going from client device format to DOM.
void writeAttributes(Element node)
Write this.
TextStyle(Node node, StyleCatalog sc)
Constructor for use when going from DOM to client device format.
String buildColorString(Color c)
Given a.
String getFontName()
Return the name of the font for this.
int getFontSize()
Return the font size for this.
Color getFontColor()
Return the font.
int mask
Bitwise mask of text attributes.
String family
Family of the.
String parent
Parent of the.
T * clone(T *const other)
final static int BOLD
Indicates bold text.
Provides interfaces for converting between two.
This class is used for logging debug messages.
Style getResolved()
Return a.
Node createNode(org.w3c.dom.Document parentDoc, String name)
Create a new.
Color parseColorString(String value)
Parse a color specification of the form #rrggbb
static String toLastCSV(String value)
Private function to return the value as a last element in a Comma Separated Value (CSV) format...
void turnAttributesOff(int flags)
Set one or more text attributes to off.
final static int UNDERLINE
Indicates underlined text.