tdf#130151 Fix toc pointing to wrong page

Change-Id: I26c1027722613f751bd39fde97f1e14d3238eefa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97413
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Jenkins
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 08baf27..ed42e0d 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2584,8 +2584,6 @@
            // there is no time to sort this out.
            //TODO: check what exactly needs to be done and make just one function for that
            pViewShell->CalcLayout();
            pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );


            // #122919# Force field update before PDF export, but after layout init (tdf#121962)
            bool bStateChanged = false;
@@ -2599,6 +2597,8 @@
            if( bStateChanged )
                pRenderDocShell->EnableSetModified();

            pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );

            pViewShell->SetPDFExportOption( false );

            // enable view again