LO Writer page numbering resets itself halfway through document

My guess would be you've found a bug ...
           or maybe ghosts :wink:

In addition to all that you've checked, I would check to see if the new page "1" begins with a different page style. I would also check for a section break as section breaks can create new page numbering.

Virgil

On a whim, can you run the macro below. As a paranoid sort, I would say...

1. Save your document.
2. Run this macro.
3. If I missed something and it modifies the document, do not save the changes (it should not change the document).

Sub FindPageBreaks
   REM Author: Andrew Pitonyak
   Dim iCnt As Long
   Dim oCursor as Variant
   Dim oText As Variant
   Dim s As String
   Dim iRightCounter As Long : iRightCounter = 0
   Dim wasRightPage As Boolean : wasRightPage = False

   oText = ThisComponent.Text
   oCursor = oText.CreateTextCursor()
   oCursor.GoToStart(False)
   Do
     If NOT oCursor.gotoEndOfParagraph(True) Then Exit Do
     iCnt = iCnt + 1
     wasRightPage = False
     If NOT IsEmpty(oCursor.PageDescName) Then
       s = s & "Paragraph " & iCnt & " has a new page to style " & _
              oCursor.PageDescName & CHR$(10)
     End If
     If Not IsEmpty(oCursor.PageNumberOffset) Then
       s = s & "Paragraph " & iCnt & " has a new PageNumberOffset to " & _
              oCursor.PageNumberOffset & CHR$(10)
     End If
     If oCursor.BreakType <> com.sun.star.style.BreakType.NONE Then
       s = s & "Paragraph " & iCnt & " has a page break" & CHR$(10)
       'oCursor.BreakType = com.sun.star.style.BreakType.NONE
     End If
   Loop Until NOT oCursor.gotoNextParagraph(False)
   MsgBox s
End Sub

What will it tell you? It should tell you every time that the page style changes, and every time that the page number is specifically told to change "PageNumberOffset".

I am curious if you see that it is showing a page number offset change at a page change when the page numbering changes.

It would be easy to change this macro to "clear" page number changes. At least I expect that it should be as easy as setting an empty value for this. I should test that.

Yep, just checked, I made a change as follows, which clears all page number changes after paragraph 10.

     If Not IsEmpty(oCursor.PageNumberOffset) Then
       s = s & "Paragraph " & iCnt & " has a new PageNumberOffset to " & _
              oCursor.PageNumberOffset & CHR$(10)

     REM THIS IS THE NEW THING HERE
       If iCnt > 10 Then
         Dim oEmpty
         oCursor.PageNumberOffset = oEmpty
       End If
     End If

I suppose I should chime in, as the particular behavior Svenja is describing
is a bug that has been present at least since Writer 3.x, and I have
experienced it many times BUT ONLY WITH DOCUMENTS THAT ARE QUITE LONG. If
you have a table of contents in the beginning, it will show the incorrect
numbers as well (if you hadn't already noticed).

The good news is that the page numbering restarts/changes seem to occur only
in memory, and are not saved. The solution (which I believe someone on this
or some other forum told me) is to Save your latest changes, exit Writer
completely, and then restart it - opening the document again.

You'll see that now your page numbering is correct, and will remain so until
you've worked on the document for a while. Like Svenja, I found that the
page numbers "restarted" at about the same place in the document each time
the problem showed up, but definitely not at the exact same place, so I
suspect it isn't any problem with the way you've specified page styles,
numbering styles, section breaks, or anything like that.

BUT BEWARE - if you export to pdf while the page numbering is quirky, the
pdf will reflect the incorrect page numbers. So my usual practice is always
to save and reload before exporting to pdf.

By the way, I have been using the 64-bit Linux Debian version of LO. It's
been a while since I poked around this particular annoyance, but my
recollection is that I decided through some utility or another that it
wasn't a memory issue with my machine, as there seemed to be plenty
available - I also recall some suggesting varying the memory assigned to LO,
but that didn't seem to make any difference.

I never filed a bug report (sorry Svenja), as the person who informed me
seemed to insinuate that this was a bug that had existed for quite some
time. Given that I knew how to work around it, I just did so - there are
certainly other annoyances that I would like to see addressed as I don't
know how to work around them, but that's life.

Frank

Hi :slight_smile:
When doing anything unusual or new to a document i tend to create a copy of
it. Many of my folders have a sub-folder called "OldVersions-Backups"
where i put such copies.

It's an extra step to add to Andrew's step 1. Making such a "Backup",
thanks to Murphy's Law, usually means that making the back-up was a waste
of time and everything runs smoothly. It's only when i don't make a
back-up that things go wonky and i find i really needed to make one! Grrr
:wink:

I have no idea what the code does but Andrew quite literally "wrote the
book" on macros so i would have complete confidence in running it even
without having made a back-up, but i'd still make a back-up anyway.
Regards from
Tom :slight_smile:

Once more, I ran into the problem with page numbers resetting in the middle
of a document today, and can confirm the following:

a) It doesn't seem to be a size or memory problem per se, as the document I
was working on has only 26 pages.
b) My system has plenty of free memory.
c) I also had other documents open in Writer at the same time.
d) Because of the former item (c), I tried reloading just the document,
rather than restarting Writer as I had suggested to Svenja in the earlier
post. This works! Simply closing and reopening the document restored all the
page numbers to their correct values.
e) I now suspect that the page numbering problem is related to the amount of
activity within the document in question. I'm not certain, but it seems that
I never experienced the problem until I had been writing and making changes
for some time, and that was certainly true today.

If anyone else has experienced this behavior (other than me and Svenja), it
would be nice if you could just post a short reply with the usual OS and LO
version numbers. Otherwise it probably isn't worth filing a bug report as
the developers certainly seem to have their hands full with the easily
reproduced bugs ...

Thanks ....