Page 1 of 1

Exception trying to reach a bookmark

PostPosted: Tue May 14, 2019 8:38 am
by pierrezx
Hello,
I have already several routines that works, to manipulate word documents through the OOO Api.
But when trying to reach a bookmark to insert a bmp image at its position, I can't reach propoerty of the bookmark or property of the cursor.
The exception message indicates "End of content node doesn't have the proper start node".

I have looked a lot on the web, among dozen of pages... but noway...

For exemple, it crashes with these two versions :

- here on the fisrt line (getAnchor or .anchor functions raise the exception) :

Code: Select all   Expand viewCollapse view
     
  Bookmark := FDocumentOpenOffice.Bookmarks.getByName(ABookMarkName).Anchor;
  wCursor := FDocumentOpenOffice.Text.createTextCursorByRange(Bookmark);
  FDocumentOpenOffice.Text.insertTextContent(wCursor, fShape, False);



- and here on the .getstart at the third line :

Code: Select all   Expand viewCollapse view
  wViewCursor := FDocumentOpenOffice.getCurrentController.getViewCursor;
  wCursor := wText.createTextCursorByRange(wViewCursor);
  wText.insertTextContent([size=150]wCursor.getStart[/size], fShape, false);
  wText.insertTextContent(wViewCursor, fShape, false);


I will continue to look for a solution among the web... and the ooo users guide that I have already read with no success... forums, etc...

Re: Exception trying to reach a bookmark

PostPosted: Tue May 14, 2019 9:24 pm
by JeJe
I only know Basic... but as no-one else has responded...

FDocumentOpenOffice.Bookmarks.getByName(ABookMarkName).getAnchor

is exactly the same in Basic. Provided FDocumentOpenOffice is a loaded writer component and ABookMarkName is a valid bookmark I can't see how it can fail. You've only given part of the code though so maybe the problem is before that line? What are your declarations? Try commenting out the part after it and see if you still get the error...