Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/com/pensioenpage/jynx/ods2csv/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ private static class XMLParser extends DefaultHandler {
private boolean _insideCellText;
private boolean _hadCells;
private boolean _stringValueType;
private String _text = "";


//----------------------------------------------------------------------
Expand Down Expand Up @@ -276,7 +277,7 @@ public void startElement(String uri, String localName, String qName, Attributes
_insideCell = true;

// Start of cell text inside table cell
} else if (TEXT_NS.equals(uri) && "p".equals(localName) && _insideCell) {
} else if (TEXT_NS.equals(uri) && "p".equals(localName) && _insideCell && !_insideCellText) {
_insideCellText = true;
}
}
Expand All @@ -297,8 +298,12 @@ public void endElement(String uri, String localName, String qName)
_hadCells = true;

// Closing text element inside table cell
} else if (TEXT_NS.equals(uri) && "p".equals(localName) && _insideCellText) {
} else if (TEXT_NS.equals(uri) && "p".equals(localName) && _insideCell && _insideCellText) {
_insideCellText = false;
if (_text.length() > 0) {
output('"' + _text + '"');
}
_text = "";
}
}

Expand All @@ -312,22 +317,17 @@ public void characters(char[] ch, int start, int length)
}

// TODO: Review the performance of the for-loop below
output('"');

final int end = start + length;
for (int i = start; i < end; i++) {
char c = ch[i];
switch (c) {
case '"':
output('"');
output('"');
_text = _text + '"' + '"';
break;
default:
output(c);
_text = _text + c;
}
}

output('"');
}

private void output(char c) throws SAXException {
Expand Down