Issue 68579 - Table of Content Page Numbers wrong when updated from Macro via command line
Summary: Table of Content Page Numbers wrong when updated from Macro via command line
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: programming (show other issues)
Version: OOo 2.0.3
Hardware: All Windows XP
: P3 Trivial with 3 votes (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-14 04:41 UTC by kingargyle
Modified: 2013-08-07 14:44 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Sample Document (137.00 KB, application/vnd.oasis.opendocument.text)
2006-08-14 04:44 UTC, kingargyle
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description kingargyle 2006-08-14 04:41:37 UTC
When using OpenOffice Basic to update the table of contents for large documents
generated outside of the OpenOffice, the table of contents are not updated
correctly with the correct page numbers unless you wait a minimum of 30 seconds
to allow open office to repaginate and create the layout cache.   If the
document is opened, and then saved.   The page numbers are generated correctly
as the layout cache seems to have been updated correctly.    If using the
dispatcher and UNO to update the table of contents everything updates correctly,
however, this can only be used if OO is going to be running in the foreground
and not being used to batch conversion of files to PDF.

The following is some sample macro code:
Sub SaveAsPDF( cFile )
   Dim oDoc as Object
   Dim oIndexes as Object
   Dim oIndex as Object

 cURL = ConvertToURL( cFile )
   oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, (_
            Array(MakePropertyValue( "Hidden", True ),))


   cFile = Left( cFile, Len( cFile ) - 4 ) + ".doc"
   cURL = ConvertToURL( cFile )

  ' Update the Indexes (does not work correctly on 100+ page documents)
   oIndexes = oDoc.getDocumentIndexes()

	for i = 0 to oIndexes.Count -1
	 oIndexes(i).update
	next i

' Save the document using a PDF filter.   
   cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf"
   cURL = ConvertToURL( cFile )

   oDoc.storeToURL( cURL, Array(_
            MakePropertyValue( "FilterName", "writer_pdf_Export" ),)
  
   oDoc.close( True )
end sub

Also attached is a sample document.   If the document is opened normally and the
uno macro is allowed to run it works correctly.  But the UI is not going to be
available when this is run from a batch mode via ANT during a build.
Comment 1 kingargyle 2006-08-14 04:44:17 UTC
Created attachment 38483 [details]
Sample Document
Comment 2 michael.ruess 2006-08-14 07:13:33 UTC
Reassigned to ES.
Comment 3 eric.savary 2006-08-14 11:41:23 UTC
ES->CN: please, have a look.
Comment 4 chne 2006-09-04 11:50:31 UTC
cn->tl: I can reproduce this. Just download the attached document. Do not open
it. Then copy the macro and modify and run it. Open the created pdf. The last
entries of the content table have a correct link but a wrong page number.
Comment 5 thomas.lange 2006-09-05 14:32:18 UTC
TL->FME: Please take ove as discussed. Thanks!
Comment 6 thomas.lange 2006-09-05 14:33:45 UTC
Sub Main

   Dim oDoc as Object
   Dim oIndexes as Object
   Dim oIndex as Object

   Dim aHidden(1) as new com.sun.star.beans.PropertyValue
   aHidden(0).Name	= "Hidden"
   aHidden(0).Value	= true
   Dim aFilter(1) as new com.sun.star.beans.PropertyValue
   aFilter(0).Name	= "FilterName"
   aFilter(0).Value	= "writer_pdf_Export"
   
   cFile = "x:\tl\AcknowledgeServicePlan.odt"
   cURL = ConvertToURL( cFile )
   oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, aHidden, )


   cFile = Left( cFile, Len( cFile ) - 4 ) + ".doc"
   cURL = ConvertToURL( cFile )

  ' Update the Indexes (does not work correctly on 100+ page documents)
   oIndexes = oDoc.getDocumentIndexes()

   for i = 0 to oIndexes.Count -1
	 oIndexes(i).update
   next i

' Save the document using a PDF filter.   
   cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf"
   cURL = ConvertToURL( cFile )

   oDoc.storeToURL( cURL, aFilter, )
  
   oDoc.close( True )


End Sub
Comment 7 frank.meies 2006-09-05 15:13:31 UTC
FME: Set target and prio.
Comment 8 frank.meies 2007-12-04 07:46:22 UTC
.
Comment 9 sytze_kl 2009-03-06 12:41:37 UTC
Exactly my problem too. I have a master document, with 20 subdocuments, in total
about 150 real pages. Update TOC with a basic macro works only partially. For
about half of the chapters, page numbers upto 300 can be seen in the TOC. Adding
several minutes of delays does not help. Tried adding a "event listener" too,
and wait until it's quiete, but that did not help either. The UNO dispatcher
trick does not work. So I'm stuck...