use views to parse

Change-Id: I9c0b89c9463065323b1a86aee21163c97b75bb25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107761
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/xmloff/source/xforms/SchemaContext.cxx b/xmloff/source/xforms/SchemaContext.cxx
index 6534121..573805a 100644
--- a/xmloff/source/xforms/SchemaContext.cxx
+++ b/xmloff/source/xforms/SchemaContext.cxx
@@ -44,9 +44,7 @@ SchemaContext::SchemaContext(
{
}

void SchemaContext::HandleAttribute(
    sal_Int32,
    const OUString& )
void SchemaContext::HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & )
{
}

diff --git a/xmloff/source/xforms/SchemaContext.hxx b/xmloff/source/xforms/SchemaContext.hxx
index bc780d2..e23ac37 100644
--- a/xmloff/source/xforms/SchemaContext.hxx
+++ b/xmloff/source/xforms/SchemaContext.hxx
@@ -44,9 +44,7 @@ public:
    // implement TokenContext methods:

protected:
    virtual void HandleAttribute(
        sal_Int32 nAttributeToken,
        const OUString& rValue ) override;
    virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) override;

    virtual SvXMLImportContext* HandleChild(
        sal_Int32 nElementToken,
diff --git a/xmloff/source/xforms/SchemaRestrictionContext.cxx b/xmloff/source/xforms/SchemaRestrictionContext.cxx
index 6d496e7..ccbdbe6 100644
--- a/xmloff/source/xforms/SchemaRestrictionContext.cxx
+++ b/xmloff/source/xforms/SchemaRestrictionContext.cxx
@@ -90,14 +90,12 @@ void SchemaRestrictionContext::CreateDataType()
    SAL_WARN_IF( !mxDataType.is(), "xmloff", "can't create type" );
}

void SchemaRestrictionContext::HandleAttribute(
    sal_Int32 nAttributeToken,
    const OUString& rValue )
void SchemaRestrictionContext::HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
{
    switch (nAttributeToken & TOKEN_MASK)
    switch (aIter.getToken() & TOKEN_MASK)
    {
        case XML_BASE:
            msBaseName = rValue;
            msBaseName = aIter.toString();
            break;
    }
}
diff --git a/xmloff/source/xforms/SchemaRestrictionContext.hxx b/xmloff/source/xforms/SchemaRestrictionContext.hxx
index b928d78..fdf7873 100644
--- a/xmloff/source/xforms/SchemaRestrictionContext.hxx
+++ b/xmloff/source/xforms/SchemaRestrictionContext.hxx
@@ -51,9 +51,7 @@ private:

    // implement TokenContext methods:

    virtual void HandleAttribute(
        sal_Int32 nAttributeToken,
        const OUString& rValue ) override;
    virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) override;

    virtual SvXMLImportContext* HandleChild(
        sal_Int32 nElementToken,
diff --git a/xmloff/source/xforms/SchemaSimpleTypeContext.cxx b/xmloff/source/xforms/SchemaSimpleTypeContext.cxx
index 755f895..cd24519 100644
--- a/xmloff/source/xforms/SchemaSimpleTypeContext.cxx
+++ b/xmloff/source/xforms/SchemaSimpleTypeContext.cxx
@@ -44,14 +44,12 @@ SchemaSimpleTypeContext::SchemaSimpleTypeContext(
{
}

void SchemaSimpleTypeContext::HandleAttribute(
    sal_Int32 nAttributeToken,
    const OUString& rValue )
void SchemaSimpleTypeContext::HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
{
    switch (nAttributeToken & TOKEN_MASK)
    switch (aIter.getToken() & TOKEN_MASK)
    {
        case XML_NAME:
            msTypeName = rValue;
            msTypeName = aIter.toString();
            break;
    }
}
diff --git a/xmloff/source/xforms/SchemaSimpleTypeContext.hxx b/xmloff/source/xforms/SchemaSimpleTypeContext.hxx
index cec5353..a64af99a 100644
--- a/xmloff/source/xforms/SchemaSimpleTypeContext.hxx
+++ b/xmloff/source/xforms/SchemaSimpleTypeContext.hxx
@@ -45,9 +45,7 @@ public:
    // implement TokenContext methods:

protected:
    virtual void HandleAttribute(
        sal_Int32 nAttributeToken,
        const OUString& rValue ) override;
    virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) override;

    virtual SvXMLImportContext* HandleChild(
        sal_Int32 nElementToken,
diff --git a/xmloff/source/xforms/TokenContext.cxx b/xmloff/source/xforms/TokenContext.cxx
index 738b8e6..928ea87 100644
--- a/xmloff/source/xforms/TokenContext.cxx
+++ b/xmloff/source/xforms/TokenContext.cxx
@@ -45,7 +45,7 @@ void TokenContext::startFastElement(
    // - other: warning

    for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
        HandleAttribute( aIter.getToken(), aIter.toString() );
        HandleAttribute( aIter );
}

css::uno::Reference< css::xml::sax::XFastContextHandler > TokenContext::createFastChildContext(
diff --git a/xmloff/source/xforms/TokenContext.hxx b/xmloff/source/xforms/TokenContext.hxx
index b2410f9..5786591 100644
--- a/xmloff/source/xforms/TokenContext.hxx
+++ b/xmloff/source/xforms/TokenContext.hxx
@@ -64,9 +64,7 @@ public:

protected:
    /** will be called for each attribute */
    virtual void HandleAttribute(
        sal_Int32 nAttributeToken,
        const OUString& rValue ) = 0;
    virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) = 0;

    /** will be called for each child element */
    virtual SvXMLImportContext* HandleChild(
diff --git a/xmloff/source/xforms/XFormsBindContext.cxx b/xmloff/source/xforms/XFormsBindContext.cxx
index 3015f31..45a03d4 100644
--- a/xmloff/source/xforms/XFormsBindContext.cxx
+++ b/xmloff/source/xforms/XFormsBindContext.cxx
@@ -59,37 +59,36 @@ XFormsBindContext::XFormsBindContext(
    mxModel->getBindings()->insert( makeAny( mxBinding ) );
}

void XFormsBindContext::HandleAttribute( sal_Int32 nAttributeToken,
                                         const OUString& rValue )
void XFormsBindContext::HandleAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
{
    switch( nAttributeToken & TOKEN_MASK )
    switch( aIter.getToken() & TOKEN_MASK )
    {
    case XML_NODESET:
        xforms_setValue( mxBinding, "BindingExpression", rValue );
        xforms_setValue( mxBinding, "BindingExpression", aIter.toString() );
        break;
    case XML_ID:
        xforms_setValue( mxBinding, "BindingID", rValue );
        xforms_setValue( mxBinding, "BindingID", aIter.toString() );
        break;
    case XML_READONLY:
        xforms_setValue( mxBinding, "ReadonlyExpression", rValue );
        xforms_setValue( mxBinding, "ReadonlyExpression", aIter.toString() );
        break;
    case XML_RELEVANT:
        xforms_setValue( mxBinding, "RelevantExpression", rValue );
        xforms_setValue( mxBinding, "RelevantExpression", aIter.toString() );
        break;
    case XML_REQUIRED:
        xforms_setValue( mxBinding, "RequiredExpression", rValue );
        xforms_setValue( mxBinding, "RequiredExpression", aIter.toString() );
        break;
    case XML_CONSTRAINT:
        xforms_setValue( mxBinding, "ConstraintExpression", rValue );
        xforms_setValue( mxBinding, "ConstraintExpression", aIter.toString() );
        break;
    case XML_CALCULATE:
        xforms_setValue( mxBinding, "CalculateExpression", rValue );
        xforms_setValue( mxBinding, "CalculateExpression", aIter.toString() );
        break;
    case XML_TYPE:
        xforms_setValue( mxBinding, "Type",
                      makeAny( xforms_getTypeName( mxModel->getDataTypeRepository(),
                         xforms_getTypeName( mxModel->getDataTypeRepository(),
                                       GetImport().GetNamespaceMap(),
                                       rValue ) ) );
                                       aIter.toString() ) );
        break;
    default:
        assert( false && "should not happen" );
diff --git a/xmloff/source/xforms/XFormsBindContext.hxx b/xmloff/source/xforms/XFormsBindContext.hxx
index 9498851..dbdcd1e 100644
--- a/xmloff/source/xforms/XFormsBindContext.hxx
+++ b/xmloff/source/xforms/XFormsBindContext.hxx
@@ -49,8 +49,7 @@ public:
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;

protected:
    virtual void HandleAttribute( sal_Int32 nAttributeToken,
                                  const OUString& rValue ) override;
    virtual void HandleAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) override;

    virtual SvXMLImportContext* HandleChild(
        sal_Int32 nElementToken,
diff --git a/xmloff/source/xforms/XFormsInstanceContext.cxx b/xmloff/source/xforms/XFormsInstanceContext.cxx
index 20af158..66a5f1b 100644
--- a/xmloff/source/xforms/XFormsInstanceContext.cxx
+++ b/xmloff/source/xforms/XFormsInstanceContext.cxx
@@ -134,20 +134,18 @@ void XFormsInstanceContext::endUnknownElement(const OUString & /*Namespace*/, co
    mxModel->getInstances()->insert( makeAny( aSequence ) );
}

void XFormsInstanceContext::HandleAttribute(
    sal_Int32 nAttributeToken,
    const OUString& rValue )
void XFormsInstanceContext::HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
{
    switch( nAttributeToken & TOKEN_MASK )
    switch( aIter.getToken() & TOKEN_MASK )
    {
    case XML_SRC:
        msURL = rValue;
        msURL = aIter.toString();
        break;
    case XML_ID:
        msId = rValue;
        msId = aIter.toString();
        break;
    default:
        XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, rValue);
        XMLOFF_WARN_UNKNOWN("xmloff", aIter);
        assert( false && "this should not happen" );
        break;
    }
diff --git a/xmloff/source/xforms/XFormsInstanceContext.hxx b/xmloff/source/xforms/XFormsInstanceContext.hxx
index 68e37be..4727c0f 100644
--- a/xmloff/source/xforms/XFormsInstanceContext.hxx
+++ b/xmloff/source/xforms/XFormsInstanceContext.hxx
@@ -60,9 +60,7 @@ public:
    virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;

protected:
    virtual void HandleAttribute(
        sal_Int32 nAttributeToken,
        const OUString& rValue ) override;
    virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) override;

    virtual SvXMLImportContext* HandleChild(
        sal_Int32 nElementToken,
diff --git a/xmloff/source/xforms/XFormsModelContext.cxx b/xmloff/source/xforms/XFormsModelContext.cxx
index 5a2b490..e5720d4 100644
--- a/xmloff/source/xforms/XFormsModelContext.cxx
+++ b/xmloff/source/xforms/XFormsModelContext.cxx
@@ -50,20 +50,18 @@ XFormsModelContext::XFormsModelContext( SvXMLImport& rImport ) :
{
}

void XFormsModelContext::HandleAttribute(
    sal_Int32 nAttributeToken,
    const OUString& rValue )
void XFormsModelContext::HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
{
    switch( nAttributeToken & TOKEN_MASK)
    switch( aIter.getToken() & TOKEN_MASK)
    {
    case XML_ID:
        mxModel->setPropertyValue( "ID", makeAny( rValue ) );
        mxModel->setPropertyValue( "ID", makeAny( aIter.toString() ) );
        break;
    case XML_SCHEMA:
        GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT );
        break;
    default:
        XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, rValue);
        XMLOFF_WARN_UNKNOWN("xmloff", aIter);
        assert( false && "this should not happen" );
        break;
    }
diff --git a/xmloff/source/xforms/XFormsModelContext.hxx b/xmloff/source/xforms/XFormsModelContext.hxx
index e2f0e1e..bcf7cd9 100644
--- a/xmloff/source/xforms/XFormsModelContext.hxx
+++ b/xmloff/source/xforms/XFormsModelContext.hxx
@@ -45,9 +45,7 @@ public:
    virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;

protected:
    virtual void HandleAttribute(
        sal_Int32 nAttributeToken,
        const OUString& rValue ) override;
    virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) override;

    virtual SvXMLImportContext* HandleChild(
        sal_Int32 nElementToken,
diff --git a/xmloff/source/xforms/XFormsSubmissionContext.cxx b/xmloff/source/xforms/XFormsSubmissionContext.cxx
index ec94634..9588ee3 100644
--- a/xmloff/source/xforms/XFormsSubmissionContext.cxx
+++ b/xmloff/source/xforms/XFormsSubmissionContext.cxx
@@ -56,7 +56,7 @@ XFormsSubmissionContext::XFormsSubmissionContext(

namespace {

Any toBool( std::u16string_view rValue )
Any toBool( std::string_view rValue )
{
    Any aValue;
    bool bValue(false);
@@ -69,59 +69,58 @@ Any toBool( std::u16string_view rValue )

} // namespace

void XFormsSubmissionContext::HandleAttribute( sal_Int32 nAttributeToken,
                                               const OUString& rValue )
void XFormsSubmissionContext::HandleAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
{
    switch( nAttributeToken & TOKEN_MASK )
    switch( aIter.getToken() & TOKEN_MASK )
    {
    case XML_ID:
        xforms_setValue( mxSubmission, "ID", rValue );
        xforms_setValue( mxSubmission, "ID", aIter.toString() );
        break;
    case XML_BIND:
        xforms_setValue( mxSubmission, "Bind", rValue );
        xforms_setValue( mxSubmission, "Bind", aIter.toString() );
        break;
    case XML_REF:
        xforms_setValue( mxSubmission, "Ref", rValue );
        xforms_setValue( mxSubmission, "Ref", aIter.toString() );
        break;
    case XML_ACTION:
        xforms_setValue( mxSubmission, "Action", rValue );
        xforms_setValue( mxSubmission, "Action", aIter.toString() );
        break;
    case XML_METHOD:
        xforms_setValue( mxSubmission, "Method", rValue );
        xforms_setValue( mxSubmission, "Method", aIter.toString() );
        break;
    case XML_VERSION:
        xforms_setValue( mxSubmission, "Version", rValue );
        xforms_setValue( mxSubmission, "Version", aIter.toString() );
        break;
    case XML_INDENT:
        xforms_setValue( mxSubmission, "Indent", toBool( rValue ) );
        xforms_setValue( mxSubmission, "Indent", toBool( aIter.toView() ) );
        break;
    case XML_MEDIATYPE:
        xforms_setValue( mxSubmission, "MediaType", rValue );
        xforms_setValue( mxSubmission, "MediaType", aIter.toString() );
        break;
    case XML_ENCODING:
        xforms_setValue( mxSubmission, "Encoding", rValue );
        xforms_setValue( mxSubmission, "Encoding", aIter.toString() );
        break;
    case XML_OMIT_XML_DECLARATION:
        xforms_setValue( mxSubmission, "OmitXmlDeclaration",
                      toBool( rValue ) );
                      toBool( aIter.toView() ) );
        break;
    case XML_STANDALONE:
        xforms_setValue( mxSubmission, "Standalone", toBool( rValue ) );
        xforms_setValue( mxSubmission, "Standalone", toBool( aIter.toView() ) );
        break;
    case XML_CDATA_SECTION_ELEMENTS:
        xforms_setValue( mxSubmission, "CDataSectionElement", rValue );
        xforms_setValue( mxSubmission, "CDataSectionElement", aIter.toString() );
        break;
    case XML_REPLACE:
        xforms_setValue( mxSubmission, "Replace", rValue );
        xforms_setValue( mxSubmission, "Replace", aIter.toString() );
        break;
    case XML_SEPARATOR:
        xforms_setValue( mxSubmission, "Separator", rValue );
        xforms_setValue( mxSubmission, "Separator", aIter.toString() );
        break;
    case XML_INCLUDENAMESPACEPREFIXES:
        xforms_setValue( mxSubmission, "IncludeNamespacePrefixes", rValue );
        xforms_setValue( mxSubmission, "IncludeNamespacePrefixes", aIter.toString() );
        break;
    default:
        XMLOFF_WARN_UNKNOWN_ATTR("xmloff", nAttributeToken, rValue);
        XMLOFF_WARN_UNKNOWN("xmloff", aIter);
        assert( false && "unknown attribute" );
        break;
    }
diff --git a/xmloff/source/xforms/XFormsSubmissionContext.hxx b/xmloff/source/xforms/XFormsSubmissionContext.hxx
index 8234e93..3d943ca 100644
--- a/xmloff/source/xforms/XFormsSubmissionContext.hxx
+++ b/xmloff/source/xforms/XFormsSubmissionContext.hxx
@@ -44,8 +44,7 @@ public:
    // implement TokenContext methods:

protected:
    virtual void HandleAttribute( sal_Int32 nAttributeToken,
                                  const OUString& rValue ) override;
    virtual void HandleAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter & aIter ) override;

    virtual SvXMLImportContext* HandleChild(
        sal_Int32 nElementToken,
diff --git a/xmloff/source/xforms/xformsapi.cxx b/xmloff/source/xforms/xformsapi.cxx
index 3fbccbe..556ade3 100644
--- a/xmloff/source/xforms/xformsapi.cxx
+++ b/xmloff/source/xforms/xformsapi.cxx
@@ -164,7 +164,7 @@ Reference<XPropertySet> xforms_findXFormsSubmission(
    return lcl_findXFormsBindingOrSubmission( xDocument, rBindingID, false );
}

void xforms_setValue( Reference<XPropertySet> const & xPropertySet,
void xforms_setValueAny( Reference<XPropertySet> const & xPropertySet,
                   const OUString& rName,
                   const Any& rAny )
{
diff --git a/xmloff/source/xforms/xformsapi.hxx b/xmloff/source/xforms/xformsapi.hxx
index 4429376..4f9e407 100644
--- a/xmloff/source/xforms/xformsapi.hxx
+++ b/xmloff/source/xforms/xformsapi.hxx
@@ -44,18 +44,26 @@ css::uno::Reference<css::beans::XPropertySet> xforms_findXFormsBinding( css::uno

css::uno::Reference<css::beans::XPropertySet> xforms_findXFormsSubmission( css::uno::Reference<css::frame::XModel> const &, const OUString& );

void xforms_setValue(
void xforms_setValueAny(
    css::uno::Reference<css::beans::XPropertySet> const & xPropSet,
    const OUString& rName,
    const css::uno::Any& rAny );

template<typename T>
void xforms_setValue(
inline void xforms_setValue(
    css::uno::Reference<css::beans::XPropertySet>& xPropSet,
    const OUString& rName,
    T& aValue )
    const T& aValue )
{
    xforms_setValue( xPropSet, rName, css::uno::makeAny( aValue ) );
    xforms_setValueAny( xPropSet, rName, css::uno::makeAny( aValue ) );
}
template<>
inline void xforms_setValue(
    css::uno::Reference<css::beans::XPropertySet>& xPropSet,
    const OUString& rName,
    const css::uno::Any& aValue )
{
    xforms_setValueAny( xPropSet, rName, aValue );
}

sal_uInt16 xforms_getTypeClass(