Which operations I can do with the FileContentProvider

The Application Programming Interface and the OASIS Open Document Format

Which operations I can do with the FileContentProvider

Postby Peter18 » Fri Oct 21, 2011 12:11 pm

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
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Which opperations I can do with the FileContentProvider

Postby RoryOF » Fri Oct 21, 2011 12:16 pm

For much implied information on using bookmarks, look at
http://extensions.services.openoffice.org/en/project/VisibleBookmarks
and examine the code used.
Apache OpenOffice 4.1.7 on Xubuntu 18.04.4 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31095
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Which opperations I can do with the FileContentProvider

Postby Peter18 » Mon Oct 24, 2011 2:07 pm

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
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Which opperations I can do with the FileContentProvider

Postby B Marcelly » Mon Oct 24, 2011 7:06 pm

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)
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
B Marcelly
Volunteer
 
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Which opperations I can do with the FileContentProvider

Postby Peter18 » Tue Oct 25, 2011 11:29 am

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
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Which opperations I can do with the FileContentProvider

Postby Peter18 » Wed Oct 26, 2011 5:35 pm

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
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest