-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OdfTableCell.getDisplayText() includes comment timestamp and text. #220
Comments
Hi, the easiest way is to create a simple test document (with a comment and cell text) and alter an existing test to debug what the code does! I believe you are on the right track - I must admit I do not have such a good memory and this would be exactly the way I would proceed - perhaps also grep on the odfdom test folder for cell (or comment) to see if there any test already working on this. Happy hunting, you might add the result/findings or additional questions... (or perhaps others have something to add) |
I experimented with the Based on the implementation of static String getCellText(OdfTableCell cell)
{
var result = new StringBuilder();
var whitespaceProcesser = new OdfWhitespaceProcessor();
var nodes = cell.getOdfElement().getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
var node = nodes.item(i);
// Ignore comments.
if (!(node instanceof OfficeAnnotationElement)) {
// Add a line break before new paragraphs.
if (result.length() != 0 &&node instanceof OdfTextParagraph) {
result.append("\n");
}
result.append(whitespaceProcesser.getText(node));
}
}
return result.toString();
} It is still not clear to me if
|
I wonder why the method is being called getDisplayText() and not getTextContent()? This getDisplayText() method As stated in #229: Finally, there is some third funcationality in https://github.com/tdf/odftoolkit/blob/master/odfdom/src/main/java/org/odftoolkit/odfdom/incubator/doc/text/OdfTextExtractor.java These approaches should (and will) be harmonized to avoid duplicated implementations. |
If an ODS spreadsheet cell contains a comment, the
OdfTableCell.getDisplayText()
method returns a string which looks something like:"2023-05-22T00:00:00CommentCell"
where I assume the timestamp is the time of the comment, "Comment" is the comment text and "Cell" is the cell text.Is this intentional? And if so, is there any way to obtain just the cell text?
The text was updated successfully, but these errors were encountered: