tdf#160984 sw continuous endnotes, DOC import: enable this unconditionally

DOC files with <= 2 endnotes were imported fine, but not if they had
more endnotes.

This was added in commit dc11f5b151e1a2ea2623fc8cf806a400763955d9
(tdf#143445 DOC import: limit the usage of the CONTINUOUS_ENDNOTES
compat flag, 2023-05-23), because mapping endnotes to footnotes was a
dead-end.

The limitation can be dropped: I checked that the tdf#143445 bugdoc with
all its 72 endnotes is laid out reasonably.

Also add a new SwFrame::DynCastColumnFrame() to easily get a column
frame from a frame using our own RTTI, if we have it anyway.

Change-Id: If7fd856f5dc5f1feb1366fca69a2ad6b3602044d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167722
Reviewed-by: Miklos Vajna <[email protected]>
Tested-by: Jenkins
diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index af19051a..4cbbfe5 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -30,6 +30,8 @@
#include <fmtwrapinfluenceonobjpos.hxx>
#include <ftnidx.hxx>
#include <tabfrm.hxx>
#include <cntfrm.hxx>
#include <colfrm.hxx>

namespace
{
@@ -298,7 +300,10 @@ CPPUNIT_TEST_FIXTURE(Test, test3Endnotes)
    SwDoc* pDoc = getSwDoc();
    SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
    SwPageFrame* pPage = pLayout->GetLastPage();
    SwFootnoteContFrame* pFootnoteCont = pPage->FindFootnoteCont();
    SwContentFrame* pLastContent = pPage->FindLastBodyContent();
    SwFrame* pSectionFrame = pLastContent->GetNext();
    auto pColumnFrame = pSectionFrame->GetLower()->DynCastColumnFrame();
    SwFootnoteContFrame* pFootnoteCont = pColumnFrame->FindFootnoteCont();
    int nEndnotes = 0;
    for (SwFrame* pLower = pFootnoteCont->GetLower(); pLower; pLower = pLower->GetNext())
    {
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index f0b7439..399ab4d 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -40,6 +40,7 @@ namespace drawinglayer::processor2d { class BaseProcessor2D; }
class SwLayoutFrame;
class SwRootFrame;
class SwPageFrame;
class SwColumnFrame;
class SwBodyFrame;
class SwFlyFrame;
class SwSectionFrame;
@@ -879,6 +880,8 @@ public:
    const SwTextFrame* DynCastTextFrame() const;
    SW_DLLPUBLIC SwPageFrame* DynCastPageFrame();
    const SwPageFrame* DynCastPageFrame() const;
    SW_DLLPUBLIC SwColumnFrame* DynCastColumnFrame();
    const SwColumnFrame* DynCastColumnFrame() const;
    inline bool IsNoTextFrame() const;
    // Frames where its PrtArea depends on their neighbors and that are
    // positioned in the content flow
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index 60ca1fe..e83f4f8 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -18,6 +18,7 @@
 */

#include <pagefrm.hxx>
#include <colfrm.hxx>
#include <rootfrm.hxx>
#include <cellfrm.hxx>
#include <rowfrm.hxx>
@@ -1990,4 +1991,14 @@ const SwPageFrame* SwFrame::DynCastPageFrame() const
    return IsPageFrame() ? static_cast<const SwPageFrame*>(this) : nullptr;
}

SwColumnFrame* SwFrame::DynCastColumnFrame()
{
    return IsColumnFrame() ? static_cast<SwColumnFrame*>(this) : nullptr;
}

const SwColumnFrame* SwFrame::DynCastColumnFrame() const
{
    return IsColumnFrame() ? static_cast<const SwColumnFrame*>(this) : nullptr;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 45eef23..6d16663 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5196,13 +5196,6 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
        if( m_xWDop->nEdn )
            aInfo.m_nFootnoteOffset = m_xWDop->nEdn - 1;
        m_rDoc.SetEndNoteInfo( aInfo );

        if (m_xSBase->GetEndnoteCount() > 2)
        {
            // This compatibility flag only works in easy cases, disable it for anything non-trivial
            // for now.
            m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, false);
        }
    }

    if (m_xWwFib->m_lcbPlcfhdd)