tdf#129883 Section links are lost on save and reload

Revert "convert XMLSectionSourceImportContext to FastParser APIs"
This reverts commit ccdcc25a085299bda45bc5ea4b3594e856f2d315.

THis was one of my earliest fastparser attempts before I properly
understood the weirde workings of the SvImportXML stuff.

Change-Id: I729467cb513740d36c0483eb6f8c84ffa4cab578
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87038
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/xmloff/source/text/XMLSectionSourceImportContext.cxx b/xmloff/source/text/XMLSectionSourceImportContext.cxx
index 82e0197..2ae4e67 100644
--- a/xmloff/source/text/XMLSectionSourceImportContext.cxx
+++ b/xmloff/source/text/XMLSectionSourceImportContext.cxx
@@ -32,7 +32,6 @@
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::xml::sax::XAttributeList;
using ::com::sun::star::xml::sax::XFastAttributeList;

using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
@@ -53,31 +52,54 @@
{
}


void XMLSectionSourceImportContext::startFastElement(sal_Int32 /*nElement*/,
    const Reference<XFastAttributeList> & xAttrList)
namespace {
enum XMLSectionSourceToken
{
    XML_TOK_SECTION_XLINK_HREF,
    XML_TOK_SECTION_TEXT_FILTER_NAME,
    XML_TOK_SECTION_TEXT_SECTION_NAME
};

}

static const SvXMLTokenMapEntry aSectionSourceTokenMap[] =
{
    { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_SECTION_XLINK_HREF },
    { XML_NAMESPACE_TEXT, XML_FILTER_NAME, XML_TOK_SECTION_TEXT_FILTER_NAME },
    { XML_NAMESPACE_TEXT, XML_SECTION_NAME,
                                        XML_TOK_SECTION_TEXT_SECTION_NAME },
    XML_TOKEN_MAP_END
};


void XMLSectionSourceImportContext::StartElement(
    const Reference<XAttributeList> & xAttrList)
{
    static const SvXMLTokenMap aTokenMap(aSectionSourceTokenMap);
    OUString sURL;
    OUString sFilterName;
    OUString sSectionName;

    sax_fastparser::FastAttributeList *pAttribList =
            sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList );

    for (auto &aIter : *pAttribList)
    sal_Int16 nLength = xAttrList->getLength();
    for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
    {
        switch (aIter.getToken())
        OUString sLocalName;
        sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
            GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
                              &sLocalName );

        switch (aTokenMap.Get(nPrefix, sLocalName))
        {
            case XML_ELEMENT(XLINK, XML_HREF):
                sURL = aIter.toString();
            case XML_TOK_SECTION_XLINK_HREF:
                sURL = xAttrList->getValueByIndex(nAttr);
                break;

            case XML_ELEMENT(TEXT, XML_FILTER_NAME):
                sFilterName = aIter.toString();
            case XML_TOK_SECTION_TEXT_FILTER_NAME:
                sFilterName = xAttrList->getValueByIndex(nAttr);
                break;

            case XML_ELEMENT(TEXT, XML_SECTION_NAME):
                sSectionName = aIter.toString();
            case XML_TOK_SECTION_TEXT_SECTION_NAME:
                sSectionName = xAttrList->getValueByIndex(nAttr);
                break;

            default:
@@ -105,7 +127,7 @@
    }
}

void XMLSectionSourceImportContext::endFastElement(sal_Int32 /*nElement*/)
void XMLSectionSourceImportContext::EndElement()
{
    // this space intentionally left blank.
}
diff --git a/xmloff/source/text/XMLSectionSourceImportContext.hxx b/xmloff/source/text/XMLSectionSourceImportContext.hxx
index 838375f..865e975 100644
--- a/xmloff/source/text/XMLSectionSourceImportContext.hxx
+++ b/xmloff/source/text/XMLSectionSourceImportContext.hxx
@@ -45,10 +45,10 @@

protected:

    virtual void SAL_CALL startFastElement(sal_Int32 nElement,
        const css::uno::Reference<css::xml::sax::XFastAttributeList> & xAttrList) override;
    virtual void StartElement(
        const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;

    virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
    virtual void EndElement() override;
};

#endif