| View previous topic :: View next topic |
| Author |
Message |
veru Power User

Joined: 09 Jul 2004 Posts: 80
|
Posted: Thu Nov 30, 2006 9:13 am Post subject: Updating Fields |
|
|
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 |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Thu Nov 30, 2006 10:35 am Post subject: Re: Updating Fields |
|
|
| 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 |
|
 |
veru Power User

Joined: 09 Jul 2004 Posts: 80
|
Posted: Thu Nov 30, 2006 1:38 pm Post subject: |
|
|
| 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 |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Thu Nov 30, 2006 1:58 pm Post subject: |
|
|
the document's getTextFieldMasters() function . You should more often use XRay  |
|
| Back to top |
|
 |
veru Power User

Joined: 09 Jul 2004 Posts: 80
|
Posted: Fri Dec 01, 2006 6:45 am Post subject: |
|
|
Actually I used XRay, but I must have overseen this . Btw, this was really a good tip! |
|
| Back to top |
|
 |
|