Page 1 of 1

Which operations I can do with the FileContentProvider

PostPosted: Fri Oct 21, 2011 12:11 pm
by Peter18
A friendly hallo to anybody,

I would like to do some things, I did not find in the manuals. If I record a macro, basic preferes the "dispatcher", but I wold like to do it whith the "FileContentProvider" because I want to do it via Delphi 4.

I want to do whith a textdocument:
Put the Cursor after a bookmark
Delete the previous character
Insert a textfile
Insert a picture

I found several cursor methods, but no one dealing with a bookmark. May be it is in a manual, but how to find the right one! There are how to's for formating and others. I am in a forest and can't find a tree. :(

Greetings from the North Sea

Peter

Re: Which opperations I can do with the FileContentProvider

PostPosted: Fri Oct 21, 2011 12:16 pm
by RoryOF
For much implied information on using bookmarks, look at
http://extensions.services.openoffice.org/en/project/VisibleBookmarks
and examine the code used.

Re: Which opperations I can do with the FileContentProvider

PostPosted: Mon Oct 24, 2011 2:07 pm
by Peter18
Hallo RoryOF,

thank you for your answer. I am sorry but it did not realy help. I found some code:
Code: Select all   Expand viewCollapse view
oTC = oTxt.createTextCursorByRange(oBMA.start)
oBookM.attach(oTC)

But it did not work via API. While I continued searching I found:
Code: Select all   Expand viewCollapse view
OO.FCP      := OO.OpenOffice.createInstance('com.sun.star.ucb.FileContentProvider');
OO.Fil      := OO.StarDesktop.loadComponentFromURL( Path, '_blank', 0, Par );
OO.BookMark := OO.Fil.getBookmarks.getByName( BM );
OO.Cur      := OO.Fil.Text.createTextCursorByRange(OO.BookMark.Anchor);

But with "createTextCursorByRange" I got an OLE-Error but not with "createTextCursor". :?:

I hope somebody can show me the way though this very dark wood.

Greetinngs

Peter

Re: Which opperations I can do with the FileContentProvider

PostPosted: Mon Oct 24, 2011 7:06 pm
by B Marcelly
Hi,
Forget about FileContentProvider, it has no relation with what you want to do.

The example you have found is a simple case. It works if the bookmark is in the main text.
But there are many "texts" in a Writer document : a cell in a table, the text of a frame, the text in a header or footer, etc. From the bookmark you have to get its text and use it to create your cursor.
The example in the Basic Guide should be written like this (Basic) :
Code: Select all   Expand viewCollapse view
Bookmark = Doc.Bookmarks.getByName("My bookmarks")
bmText = Bookmark.getAnchor.getText
Cursor = bmText.createTextCursorByRange(Bookmark.getAnchor)

Re: Which opperations I can do with the FileContentProvider

PostPosted: Tue Oct 25, 2011 11:29 am
by Peter18
Hello B Marcelly,

thank you for your answer. I found a tree! Now I understand the problem. I have to take the text and not the document to create a cursor. Now there is no error. :D One problem solved.

Is there a method to insert a text document?

Greetings

Peter

Re: Which opperations I can do with the FileContentProvider

PostPosted: Wed Oct 26, 2011 5:35 pm
by Peter18
A friendly hello to anybody,

I found a method to insert a text document: "insertDocumentFromURL". But there is a Problem left, I'll start a new Thred for this problem.

Greetings

Peter