Index: sw/source/core/unocore/unoidx.cxx =================================================================== --- sw/source/core/unocore/unoidx.cxx (revision 1373256) +++ sw/source/core/unocore/unoidx.cxx (working copy) @@ -67,8 +67,8 @@ #include #include #include +#include - using namespace ::com::sun::star; using ::rtl::OUString; @@ -583,18 +583,37 @@ /*-- 14.12.98 09:35:05--------------------------------------------------- -----------------------------------------------------------------------*/ +void lcl_CalcLayout(SwDoc *pDoc) +{ + ViewShell *pViewShell = 0; + SwEditShell* pEditShell = pDoc ? pDoc->GetEditShell(&pViewShell) : 0; + if (pEditShell) + { + pEditShell->CalcLayout(); + } + else if (pViewShell) + { + pViewShell->CalcLayout(); + } + +} + void SAL_CALL SwXDocumentIndex::update() throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + vos::OGuard aGuard(Application::GetSolarMutex()); SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); SwTOXBaseSection *const pTOXBase = (pFmt) ? static_cast(pFmt->GetSection()) : 0; - if(!pTOXBase) + if(!pTOXBase) { - throw uno::RuntimeException(); + throw uno::RuntimeException(); } pTOXBase->Update(); + + // the insertion of TOC will affect the document layout + lcl_CalcLayout(m_pImpl->m_pDoc); + // page numbers pTOXBase->UpdatePageNum(); }