19package org.openoffice.xmerge.util;
21import org.w3c.dom.Document;
22import org.w3c.dom.Element;
23import org.w3c.dom.Node;
24import org.w3c.dom.Text;
28import java.util.ArrayList;
47 ArrayList<Node> nodeVec =
new ArrayList<Node>();
54 while ((
text.indexOf(
" ") != -1) || (
text.indexOf(
'\t') != 1)) {
60 int spaceIndex =
text.indexOf(
" ");
61 int tabIndex =
text.indexOf(
'\t');
62 if ((spaceIndex == -1) && (tabIndex == -1))
67 closerIndex = tabIndex;
68 else if (tabIndex == -1)
69 closerIndex = spaceIndex;
71 closerIndex = (spaceIndex > tabIndex) ? tabIndex : spaceIndex;
78 if (closerIndex > 0) {
79 String beginningText =
text.substring(0, closerIndex);
80 Text textNode = parentDoc.createTextNode(beginningText);
81 nodeVec.add(textNode);
90 if (closerIndex == tabIndex) {
97 while ((nrSpaces <
text.length())
98 &&
text.substring(nrSpaces, nrSpaces + 1).equals(
" ")) {
102 Element spaceNode = parentDoc.createElement(
TAG_SPACE);
105 nodeVec.add(spaceNode);
114 if (
text.length() > 0) {
115 Text textNode = parentDoc.createTextNode(
text);
116 nodeVec.add(textNode);
120 Node nodes[] = nodeVec.toArray(
new Node[nodeVec.size()]);
Class providing utility methods for OpenOffice plug-ins.
static Node[] parseText(String text, Document parentDoc)
Method to replace whitespace character within text with appropriate OpenOffice tags.
A Document represents any Document to be converted and the resulting Document from any conversion.
This interface contains constants for StarOffice XML tags, attributes (StarCalc cell types,...
String TAG_TAB_STOP
Element tag for text:tab-stop.
String ATTRIBUTE_SPACE_COUNT
Attribute tag for text:c of element text:s.
String TAG_SPACE
Element tag for text:s.
Document and PluginFactory implementations for XML based formats.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...