19package org.openoffice.xmerge.converter.xml;
21import org.w3c.dom.NodeList;
22import org.w3c.dom.Node;
23import org.w3c.dom.NamedNodeMap;
24import org.w3c.dom.Element;
28abstract class conversionAlgorithm {
29 abstract int I(String val);
35class horizSize
extends conversionAlgorithm {
38 if (
value.endsWith(
"mm")) {
39 float size = (float)0.0;
43 }
catch (Exception e) {
44 Debug.log(Debug.ERROR,
"Error parsing " + value, e);
49 Debug.log(Debug.ERROR,
"Unexpected value (" + value
50 +
") in horizSize.I()");
60class lineHeight
extends conversionAlgorithm {
63 if (
value.endsWith(
"mm")) {
64 float size = (float)0.0;
68 }
catch (Exception e) {
69 Debug.log(Debug.ERROR,
"Error parsing " + value, e);
73 }
else if (
value.endsWith(
"%")) {
74 float size = (float)0.0;
78 }
catch (Exception e) {
79 Debug.log(Debug.ERROR,
"Error parsing " + value, e);
81 int retval = (
int) size;
82 retval |= ParaStyle.LH_PCT;
92class alignment
extends conversionAlgorithm {
95 if (
value.equals(
"end"))
96 return ParaStyle.ALIGN_RIGHT;
97 if (
value.equals(
"right"))
98 return ParaStyle.ALIGN_RIGHT;
99 if (
value.equals(
"center"))
100 return ParaStyle.ALIGN_CENTER;
101 if (
value.equals(
"justify"))
102 return ParaStyle.ALIGN_JUST;
103 if (
value.equals(
"justified"))
104 return ParaStyle.ALIGN_JUST;
105 if (
value.equals(
"start"))
106 return ParaStyle.ALIGN_LEFT;
107 if (
value.equals(
"left"))
108 return ParaStyle.ALIGN_LEFT;
109 Debug.log(Debug.ERROR,
"Unknown string ("
110 + value +
") in alignment.I()");
111 return ParaStyle.ALIGN_LEFT;
190 public static final int LH_PCT = 0x40000000;
197 "style:font-name",
"fo:font-size",
"fo:font-weight",
"fo:color",
198 "fo:language",
"fo:country",
"style:font-name-asian",
199 "style:font-size-asian",
"style:language-asian",
200 "style:country-asian",
"style:font-name-complex",
201 "style:font-size-complex",
"style:language-complex",
202 "style:country-complex",
"style:text-autospace",
"style:punctuation-wrap",
203 "style:line-break",
"fo:keep-with-next",
"fo:font-style",
204 "text:number-lines",
"text:line-number"
223 if (node.hasChildNodes()) {
224 NodeList children = node.getChildNodes();
225 int len = children.getLength();
226 for (
int i = 0;
i < len;
i++) {
227 Node child = children.item(
i);
228 String nodeName = child.getNodeName();
229 if (nodeName.equals(
"style:properties")) {
230 NamedNodeMap childAttrNodes = child.getAttributes();
231 if (childAttrNodes !=
null) {
232 int nChildAttrNodes = childAttrNodes.getLength();
233 for (
int j = 0; j < nChildAttrNodes; j++) {
234 Node attr = childAttrNodes.item(j);
258 super(
name, familyName, parentName,
sc);
260 for (
int i = 0;
i < attribs.length;
i++)
278 super(
name, familyName, parentName, lookup);
280 for (
int i = 0;
i < attribs.length;
i++)
325 this.value[attr] = ((conversionAlgorithm)
algor[attr].newInstance()).
I(
value);
352 if (parentStyle ==
null)
357 }
else if (!
name.equals(
"DEFAULT_STYLE")) {
358 parentStyle = (
ParaStyle)
sc.lookup(
"DEFAULT_STYLE",
null,
null,
365 if (parentStyle !=
null) {
387 return "\"" +
value +
"\",";
402 return "\"" +
value +
"\"";
427 attributes +=
toCSV(
null);
443 Element node = parentDoc.createElement(
name);
459 if (!super.isSubset(style))
499 double temp =
value[
i] / 100.0;
501 node.setAttribute(
attrName[
i], stringVal);
511 stringVal =
Double.toString(temp) +
"mm";
523 default: val =
"unknown";
break;
This class represents a paragraph Style.
static void dumpHdr()
Print a Comma Separated Value (CSV) header line for the spreadsheet dump.
int value[]
Array of attribute values for this paragraph Style.
static final int LH_PCT
Line height percentage.
static final int ALIGN_JUST
Align justified.
ParaStyle(String name, String familyName, String parentName, String attribs[], String values[], StyleCatalog sc)
Constructor for use when going from client device format to DOM.
final String attrName[]
Array of attribute names for this paragraph Style.
Node createNode(org.w3c.dom.Document parentDoc, String name)
Create the Node with the specified elements.
static final int NR_PROPERTIES
Total number of properties.
boolean isIgnored(String attribute)
This code checks whether an attribute is one that we intentionally ignore.
static final int LINE_HEIGHT
Indent right property.
ParaStyle(Node node, StyleCatalog sc)
Constructor for use when going from DOM to client device format.
Style getResolved()
Return the Style in use.
void dumpCSV()
Dump this Style as a Comma Separated Value (CSV) line.
static String toCSV(String value)
Private function to return the value as an element in a Comma Separated Value (CSV) format.
ParaStyle(String name, String familyName, String parentName, int attribs[], String values[], StyleCatalog lookup)
Alternate constructor for use when going from client device format to DOM.
static final int TEXT_INDENT
Indent left property.
void setAttribute(String attr, String value)
Set an attribute for this paragraph Style.
static final int ALIGN_CENTER
Align center.
static final int LH_VALUEMASK
Line height mask.
final Class<?> algor[]
Array of attribute structures for this paragraph Style.
boolean isSet[]
Array of flags indicating which attributes are set for this paragraph Style.
static final int ALIGN_RIGHT
Align right.
boolean isSubset(Style style)
Return true if style is a subset of the Style.
static final int ALIGN_LEFT
Align left.
static String toLastCSV(String value)
Private function to return the value as a last element in a Comma Separated Value (CSV) format.
static String[] ignored
Ignored tags.
static final int TEXT_ALIGN
Align text property.
void setAttribute(int attr, String value)
Set an attribute for this paragraph Style.
void writeAttributes(Element node)
Add Style attributes to the given Node.
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.
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)
bool isAssignableFrom(const Type &_rAssignable, const Type &_rFrom)
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...
PyRef getClass(const OUString &name, const Runtime &runtime)
std::vector< char * > values
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int