How to find offset from line and column number
Post here questions and problems related to oXygen frameworks/document types.
How to find offset from line and column number
Hello,
I work with the version 22 of Oxygen SDK and I wonder how can I retrieve the offset from a line number and column number.
I have found the method getOffsetOfLineStart from the class WSTextEditorPage but the offset return is out of the document.
Exemple with the line 80, I get an offset of 3352 but the endOffset of the root element is 172.
Is there a way the have the good offset ?
Thanks in advanced,
Regards,
Isabelle
I work with the version 22 of Oxygen SDK and I wonder how can I retrieve the offset from a line number and column number.
I have found the method getOffsetOfLineStart from the class WSTextEditorPage but the offset return is out of the document.
Exemple with the line 80, I get an offset of 3352 but the endOffset of the root element is 172.
Is there a way the have the good offset ?
Thanks in advanced,
Regards,
Isabelle
-
- Posts: 78
- Joined: Wed Jun 22, 2016 2:48 pm
Re: How to find offset from line and column number
Post by adrian_sorop »
Hi Isabelle,
I don't fully understand your use case, but I'm assuming it's something like:
You have a nodeRange (ro.sync.exml.workspace.api.editor.page.text.xml.WSXMLTextNodeRange) and you want to find the start and end offset of the node mapped in that range.
Your code will be something like:
Let me know if this helps you,
Adrian S.
I don't fully understand your use case, but I'm assuming it's something like:
You have a nodeRange (ro.sync.exml.workspace.api.editor.page.text.xml.WSXMLTextNodeRange) and you want to find the start and end offset of the node mapped in that range.
Your code will be something like:
Code: Select all
WSXMLTextEditorPage textEditorPage = ...;
WSXMLTextNodeRange nodeRange = ...;
try {
int startOffset = textEditorPage.getOffsetOfLineStart(nodeRange.getStartLine()) + nodeRange.getStartColumn() - 1;
int endOffset = textEditorPage.getOffsetOfLineStart(nodeRange.getEndLine()) + nodeRange.getEndColumn() - 1;
} catch (BadLocationException e) {
// handle the exception
e.printStackTrace();
}
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service