tdf#71737 xmloff: ODF 1.2 doesn't allow hyperlinks in ...

... text:illustration-index-entry-template, so store these elements
only in ODF 1.2 extended, and in loext namespace.

Change-Id: Icf919e91114f5c9aed2adc3f5359b9df61eb3433
Reviewed-on: https://gerrit.libreoffice.org/46088
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
diff --git a/xmloff/source/text/XMLIndexTemplateContext.cxx b/xmloff/source/text/XMLIndexTemplateContext.cxx
index 87295c1..b538860 100644
--- a/xmloff/source/text/XMLIndexTemplateContext.cxx
+++ b/xmloff/source/text/XMLIndexTemplateContext.cxx
@@ -217,7 +217,7 @@ SvXMLImportContextRef XMLIndexTemplateContext::CreateChildContext(
{
    SvXMLImportContext* pContext = nullptr;

    if (XML_NAMESPACE_TEXT == nPrefix)
    if (XML_NAMESPACE_TEXT == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix)
    {
        TemplateTokenType nToken;
        if (SvXMLUnitConverter::convertEnum(nToken, rLocalName,
diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx
index 1eac782..899cb51 100644
--- a/xmloff/source/text/XMLSectionExport.cxx
+++ b/xmloff/source/text/XMLSectionExport.cxx
@@ -1256,6 +1256,7 @@ void XMLSectionExport::ExportIndexTemplateElement(

    // convert type to token (and check validity) ...
    XMLTokenEnum eElement(XML_TOKEN_INVALID);
    sal_uInt16 nNamespace(XML_NAMESPACE_TEXT);
    switch(nTokenType)
    {
        case TOK_TTYPE_ENTRY_TEXT:
@@ -1301,6 +1302,27 @@ void XMLSectionExport::ExportIndexTemplateElement(
            break;
    }

    if (eType != TEXT_SECTION_TYPE_TOC)
    {
        switch (nTokenType)
        {
            case TOK_TTYPE_HYPERLINK_START:
            case TOK_TTYPE_HYPERLINK_END:
                if (SvtSaveOptions::ODFVER_012 < aODFVersion)
                {
                    assert(eType == TEXT_SECTION_TYPE_ILLUSTRATION);
                    nNamespace = XML_NAMESPACE_LO_EXT;
                }
                else
                {
                    eElement = XML_TOKEN_INVALID; // not allowed in ODF <= 1.2
                }
                break;
            default:
                break;
        }
    }

    //--->i90246
    //check the ODF version being exported
    if( aODFVersion == SvtSaveOptions::ODFVER_011
@@ -1455,7 +1477,7 @@ void XMLSectionExport::ExportIndexTemplateElement(
                                     OUString::number(nLevel));
        }
        // export template
        SvXMLElementExport aTemplateElement(GetExport(), XML_NAMESPACE_TEXT,
        SvXMLElementExport aTemplateElement(GetExport(), nNamespace,
                                            GetXMLToken(eElement),
                                            true, false)
            ;