Finding character after Formula anchor point
Michael Stahl
mstahl at redhat.com
Mon Apr 22 04:21:30 PDT 2013
On 20/04/13 08:21, Rheinländer wrote:
> Hi,
>
> I'm trying to find the character after a Formula's anchor. It's anchored
> "as character" so I thought this would be easy...
>
> // Create a model cursor at the anchor point
> Reference < XTextContent > formula = ...
> Reference < XText > xDocumentText = formula->getAnchor()->getText();
> Reference < XTextCursor > xModelCursor =
> xDocumentText->createTextCursorByRange(formula->getAnchor()->getEnd());
>
> // Get the first paragraph of the cursor's text
> Reference< XEnumerationAccess > xEnum(xModelCursor->getText(),
> UNO_QUERY_THROW);
guess here it's going wrong: XText from getText() is most likely the
Body text and that enumeration will contain all paragraphs/tables in it.
i think you will have more luck by moving the cursor to the right by 1
with "true" parameter to get a selection and then reading the text (i
don't actually know know if that getAnchor()->getEnd() puts you "before"
or "after" the frame, if it's before you need 2 cursor moves).
anything anchored AS-character is represented by one "dummy character"
in the paragraph text that you can move over with the XTextCursor etc. APIs.
More information about the LibreOffice
mailing list