OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Cursor, Text and table

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
paulocordeiro
Newbie
Newbie


Joined: 29 Apr 2008
Posts: 2

PostPosted: Tue Apr 29, 2008 6:03 am    Post subject: Cursor, Text and table Reply with quote

Hello,

In my document exist a text i need find it and change to table.
How set cursor position based in find text?

Delphi code:

oTable := oDoc.createInstance('com.sun.star.text.TextTable');
oTable.initialize( 7, 5 );
oText := oDoc.Text;

otextcursor := otext.createTextCursor;
oText.InsertTextContent(
otextcursor, oTable, False );


Paulo
Back to top
View user's profile Send private message
paulocordeiro
Newbie
Newbie


Joined: 29 Apr 2008
Posts: 2

PostPosted: Wed Apr 30, 2008 12:25 pm    Post subject: [Solved] Cursor, Text and table Reply with quote

Based in posts:

http://www.oooforum.org/forum/viewtopic.phtml?t=68332
http://www.oooforum.org/forum/viewtopic.phtml?t=27199

my problem is solved with code:

Code:

  objSearch := oDoc.createSearchDescriptor;
  objSearch.SearchString := '{table_position}';
  objFound := oDoc.findAll(objSearch);

  for  n:= 0 to objFound.Count - 1 do
  begin
    if not isNullEmpty(objFound.getByIndex(n)) then
    begin
      //Get the cursor position
      objCursor := objFound.getByIndex(n).Text.createTextCursorByRange(objFound.getByIndex(n));
      //Remove the searched for text in the document
      objCursor.String := '';

      //create sample table
      oTable := oDoc.createInstance('com.sun.star.text.TextTable');
      oTable.initialize( 7, 5 );

      //insert table in found position
      oDoc.text.InsertTextContent( objCursor, oTable, False );

    end;

  end;



Paulo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group