Exception trying to reach a bookmark

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
pierrezx
Posts: 1
Joined: Tue May 14, 2019 8:23 am

Exception trying to reach a bookmark

Post 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

      
  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

  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...
Open Office 4.0.4.2 / Windows 7 / Delphi Seattle
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Exception trying to reach a bookmark

Post 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...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply