Issue 116909

Summary: PageCount (DocumentStatistics) via Macro is not correct
Product: Writer Reporter: Oliver Brinzing <oliver.brinzing>
Component: codeAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: issues
Version: OOo 3.3   
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description Oliver Brinzing 2011-02-10 12:25:02 UTC
steps to reproduce:

- open new writer document
- run macro provided below
- result: "PageCount" (DocumentStatistics) is not 
  correct, it shows "0" instead of "1"
- open File - Properties - "Statistics"
- run macro again
- result is "1" now ...

Sub Test()
	MsgBox getPageCount(ThisComponent) & Chr(13) &
ThisComponent.getCurrentController().PageCount
End Sub

Function getPageCount(oDoc)
	oProps = oDoc.getDocumentProperties()
	aStats = oProps.DocumentStatistics
	for i = uBound(aStats) to 0 step -1
  		x = aStats(i)
		if x.Name = "PageCount" then exit for
	next
	getPageCount = 0
	if i > -1 then getPageCount = x.Value
End Function
Comment 1 eric.savary 2011-02-10 12:46:47 UTC
Reassigned
Comment 2 michael.ruess 2011-02-10 13:12:30 UTC
MRU->OS: reproducible in 300m99. The page count via Macro will only be correct
after the File.properties.statistics tab page has been opened.
Comment 3 bmarcelly 2011-02-13 08:27:13 UTC
There is a better way to force document formatting and get the current value of
PageCount and LineCount.

MsgBox("Page Count = " & ThisComponent.CurrentController.PageCount)

See service c.s.s.text.TextDocumentView
Comment 4 Marcus 2017-05-20 11:20:07 UTC
Reset assigne to the default "issues@openoffice.apache.org".