[Solved+Issue] Automatic update of table of content / index

Discuss the word processor
Post Reply
hhue13@gmail.com
Posts: 4
Joined: Thu Jun 26, 2014 11:23 am

[Solved+Issue] Automatic update of table of content / index

Post by hhue13@gmail.com »

Is there a way so that OO Writer automatically updates in Index / Table of Contents when the document is printed or exported as PDF? Would ensure that the index is always current when a document is printed / exported as PDF for sharing (and sometimes I only realize that I forgot to do that when it is too last :( ).
Last edited by Hagar Delest on Fri Jun 27, 2014 11:04 pm, edited 2 times in total.
Reason: tagged [Solved].
OpenOffice 4.0.1 on RHEL
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Automatic update of table of content / index

Post by acknak »

Greetings and welcome to the community forum!

That could be a nice option, but no. There's no built-in way to to that, as far as I know.
AOO4/LO5 • Linux • Fedora 23
hhue13@gmail.com
Posts: 4
Joined: Thu Jun 26, 2014 11:23 am

Re: Automatic update of table of content / index

Post by hhue13@gmail.com »

Thanks for your response on this. Is there a way to submit such request / suggestions regarding enhancements?
OpenOffice 4.0.1 on RHEL
User avatar
RoryOF
Moderator
Posts: 35223
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Automatic update of table of content / index

Post by RoryOF »

Bugzilla report at
https://issues.apache.org/ooo/show_bug.cgi?id=25710
suggesting automatic update of ToC before printing.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Automatic update of table of content / index

Post by acknak »

Thanks for digging out the issue!

Looking at the issue comments, there's a link to this oooforum thread: http://www.oooforum.org/forum/viewtopic.phtml?t=11826
discussing a macro to do the update. You can bind a macro to an event, such as printing or saving, or to a key press--although that's not much different than simply using the built-in menu: Tools > Update > Indexes & Tables.

Since oooforum can be rather difficult to access, here is the macro code from that thread:

Code: Select all

sub updater
oIndexes = ThisComponent.getDocumentIndexes()

for i = 0 to oIndexes.getCount() - 1
 oIndexes (i).update
 msgBox ("Index updated: " + oIndexes.getByIndex (i).getServiceName ())
next i

end sub
I can't say if it works or not.
AOO4/LO5 • Linux • Fedora 23
hhue13@gmail.com
Posts: 4
Joined: Thu Jun 26, 2014 11:23 am

Re: [Issue] Automatic update of table of content / index

Post by hhue13@gmail.com »

Thanks a lot for your help on this ... will give it a try!
OpenOffice 4.0.1 on RHEL
User avatar
RoryOF
Moderator
Posts: 35223
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Issue] Automatic update of table of content / index

Post by RoryOF »

A side effect of automatic update of Tables of Content or indexes is that if this is carried out at load or at save time on large documents (typically several hundred pages, ToCed and/or Indexed), it may make the Open/Save Processes even slower than they already are; probably the best compromise is automatic update before printing and perhaps an Update button on the toolbar so the process can easily be manually selected.
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
hhue13@gmail.com
Posts: 4
Joined: Thu Jun 26, 2014 11:23 am

Re: [Issue] Automatic update of table of content / index

Post by hhue13@gmail.com »

Well - I've tested the macro approach and it seems to work nicely. I've modified the code slightly to check the document type as I want to do that only for Writer documents and removed the msgBox (as I personally find that annoying after a while).

The current macro is:

Code: Select all

sub updateIndex

if ((ThisComponent.supportsService("com.sun.star.text.TextDocument")) OR (ThisComponent.supportsService("com.sun.star.text.WebDocument"))) Then
	oIndexes = ThisComponent.getDocumentIndexes()
	
	for i = 0 to oIndexes.getCount() - 1
	oIndexes (i).update
	REM If you want to get a message box when the index is updated
	REM remove the "REM" in front of the msgBox line below!!
	REM msgBox ("Index updated: " + oIndexes.getByIndex (i).getServiceName ())
	next i
end if

end sub

and then I've assigned the macro to the following events (Tools --> Customize --> Events tab.):
  • Print Document
    Storing or exporting copy of doc
Note: If you want to apply this macro assignment to all documents make sure to select "OpenOffice" in the "Save in" drop down box

This seems to work pretty well ... thanks for your help on this.
OpenOffice 4.0.1 on RHEL
Post Reply