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

Updating Fields

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
veru
Power User
Power User


Joined: 09 Jul 2004
Posts: 80

PostPosted: Thu Nov 30, 2006 9:13 am    Post subject: Updating Fields Reply with quote

Hi,
in a document template I've to convert from VBA to StarBasic there is this part:

Code:
    For Each Part In oDoc.StoryRanges
        Part.Fields.Update
        While Not (Part.NextStoryRange Is Nothing)
            Set Part = Part.NextStoryRange
            Part.Fields.Update
        Wend
    Next


This goes trough the whole document and updates all Fields. How would I do the same in OOo? I know that the counterpart to a Word story is a OOo section, the fields are handled different in OOo. I couldn't find them anywhere in the object model.

UPDATE
I used the macro recorder, it gave me the following:
Code:
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:UpdateFields", "", 0, Array())

This works, but isn't there somethig more elegant, without using the dispatch framework?
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Thu Nov 30, 2006 10:35 am    Post subject: Re: Updating Fields Reply with quote

veru wrote:

dispatcher.executeDispatch(document, ".uno:UpdateFields", "", 0, Array())[/code]
This works, but isn't there somethig more elegant, without using the dispatch framework?

The docs say that 'All fields support the interfaces com.sun.star.text.XTextField, com.sun.star.util.XUpdatable, com.sun.star.text.XDependentTextField and the service com.sun.star.text.TextContent', so an update on each single field should be possible. I do not know if you can do an aggregate update by OO API
Back to top
View user's profile Send private message
veru
Power User
Power User


Joined: 09 Jul 2004
Posts: 80

PostPosted: Thu Nov 30, 2006 1:38 pm    Post subject: Reply with quote

But there is still the problem how to get access to the fields. If I know the supported Interfaces I know which methods I can call. But how to obtain a colletction of all fields?
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Thu Nov 30, 2006 1:58 pm    Post subject: Reply with quote

the document's getTextFieldMasters() function . You should more often use XRay Smile
Back to top
View user's profile Send private message
veru
Power User
Power User


Joined: 09 Jul 2004
Posts: 80

PostPosted: Fri Dec 01, 2006 6:45 am    Post subject: Reply with quote

Actually I used XRay, but I must have overseen this Embarassed . Btw, this was really a good tip!
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 Macros and API 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