Issue 116909 - PageCount (DocumentStatistics) via Macro is not correct
Summary: PageCount (DocumentStatistics) via Macro is not correct
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOo 3.3
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-10 12:25 UTC by Oliver Brinzing
Modified: 2017-05-20 11:20 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this issue.
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".