summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-29 13:52:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-29 20:16:28 +0200
commitb7bfe6ae08f5b214f2d03d70a40b66c894c0b659 (patch)
treec2a657a570190865e322f916f2926f648809171b
parent7787bac16cbe63698f56a9a70d9b1b217f3ea860 (diff)
Convert TokenContext to fastparser APIs
Change-Id: Ib40e2f3d37c52b03f2ecbd67aaeed9605e644fea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93163 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/xmloff/xformsimport.hxx5
-rw-r--r--sw/source/filter/xml/xmlimp.cxx2
-rw-r--r--xmloff/inc/DomBuilderContext.hxx23
-rw-r--r--xmloff/source/core/DomBuilderContext.cxx77
-rw-r--r--xmloff/source/core/xmlimp.cxx1
-rw-r--r--xmloff/source/forms/layerimport.cxx2
-rw-r--r--xmloff/source/xforms/SchemaContext.cxx32
-rw-r--r--xmloff/source/xforms/SchemaContext.hxx12
-rw-r--r--xmloff/source/xforms/SchemaRestrictionContext.cxx88
-rw-r--r--xmloff/source/xforms/SchemaRestrictionContext.hxx12
-rw-r--r--xmloff/source/xforms/SchemaSimpleTypeContext.cxx36
-rw-r--r--xmloff/source/xforms/SchemaSimpleTypeContext.hxx12
-rw-r--r--xmloff/source/xforms/TokenContext.cxx71
-rw-r--r--xmloff/source/xforms/TokenContext.hxx42
-rw-r--r--xmloff/source/xforms/XFormsBindContext.cxx54
-rw-r--r--xmloff/source/xforms/XFormsBindContext.hxx15
-rw-r--r--xmloff/source/xforms/XFormsInstanceContext.cxx44
-rw-r--r--xmloff/source/xforms/XFormsInstanceContext.hxx21
-rw-r--r--xmloff/source/xforms/XFormsModelContext.cxx65
-rw-r--r--xmloff/source/xforms/XFormsModelContext.hxx14
-rw-r--r--xmloff/source/xforms/XFormsSubmissionContext.cxx67
-rw-r--r--xmloff/source/xforms/XFormsSubmissionContext.hxx10
-rw-r--r--xmloff/source/xforms/xformsimport.cxx7
23 files changed, 238 insertions, 474 deletions
diff --git a/include/xmloff/xformsimport.hxx b/include/xmloff/xformsimport.hxx
index 5975ea993416..3bf554d9a7b2 100644
--- a/include/xmloff/xformsimport.hxx
+++ b/include/xmloff/xformsimport.hxx
@@ -35,10 +35,7 @@ namespace com { namespace sun { namespace star {
} } }
/** create import context for xforms:model element. */
-XMLOFF_DLLPUBLIC SvXMLImportContext* createXFormsModelContext(
- SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName );
+XMLOFF_DLLPUBLIC SvXMLImportContext* createXFormsModelContext( SvXMLImport& rImport );
/** perform the actual binding of an XForms-binding with the suitable control
* @param document which contains the XForms-model(s)
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 0ea3690eddac..eaded191bdcc 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -260,7 +260,7 @@ SvXMLImportContextRef SwXMLDocContext_Impl::CreateChildContext(
switch( rTokenMap.Get( nPrefix, rLocalName ) )
{
case XML_TOK_DOC_XFORMS:
- pContext = createXFormsModelContext(GetImport(), nPrefix, rLocalName);
+ pContext = createXFormsModelContext(GetImport());
break;
}
diff --git a/xmloff/inc/DomBuilderContext.hxx b/xmloff/inc/DomBuilderContext.hxx
index cf73d6e7d608..a3ce39574473 100644
--- a/xmloff/inc/DomBuilderContext.hxx
+++ b/xmloff/inc/DomBuilderContext.hxx
@@ -32,7 +32,7 @@ namespace com { namespace sun { namespace star {
class XDocument;
} }
namespace xml { namespace sax {
- class XAttributeList;
+ class XFastAttributeList;
} }
} } }
class SvXMLImport;
@@ -48,14 +48,11 @@ class DomBuilderContext final : public SvXMLImportContext
public:
/** default constructor: create new DOM tree */
- DomBuilderContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName );
+ DomBuilderContext( SvXMLImport& rImport, sal_Int32 nElement );
/** constructor: create DOM subtree under the given node */
DomBuilderContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
+ sal_Int32 nElement,
css::uno::Reference<css::xml::dom::XNode> const & );
virtual ~DomBuilderContext() override;
@@ -70,16 +67,12 @@ public:
// implement SvXMLImportContext methods:
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList >& xAttrList ) override;
-
- virtual void StartElement(
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
-
- virtual void EndElement() override;
+ virtual void SAL_CALL startFastElement( sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
virtual void Characters( const OUString& rChars ) override;
};
diff --git a/xmloff/source/core/DomBuilderContext.cxx b/xmloff/source/core/DomBuilderContext.cxx
index 9f893d710ae0..d6f01954f14b 100644
--- a/xmloff/source/core/DomBuilderContext.cxx
+++ b/xmloff/source/core/DomBuilderContext.cxx
@@ -55,17 +55,13 @@ using com::sun::star::xml::dom::NodeType_ELEMENT_NODE;
// helper functions; implemented below
static Reference<XNode> lcl_createDomInstance();
static Reference<XNode> lcl_createElement( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
+ sal_Int32 nElement,
const Reference<XNode>& xParent);
-DomBuilderContext::DomBuilderContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName ) :
- SvXMLImportContext( rImport, nPrefix, rLocalName ),
- mxNode( lcl_createElement( rImport, nPrefix, rLocalName,
- lcl_createDomInstance() ) )
+DomBuilderContext::DomBuilderContext( SvXMLImport& rImport, sal_Int32 nElement ) :
+ SvXMLImportContext( rImport ),
+ mxNode( lcl_createElement( rImport, nElement, lcl_createDomInstance() ) )
{
SAL_WARN_IF( !mxNode.is(), "xmloff", "empty XNode not allowed" );
SAL_WARN_IF( !Reference<XElement>( mxNode, UNO_QUERY ).is(), "xmloff", "need element" );
@@ -73,11 +69,10 @@ DomBuilderContext::DomBuilderContext( SvXMLImport& rImport,
}
DomBuilderContext::DomBuilderContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
+ sal_Int32 nElement,
Reference<XNode> const & xParent ) :
- SvXMLImportContext( rImport, nPrefix, rLocalName ),
- mxNode( lcl_createElement( rImport, nPrefix, rLocalName, xParent ) )
+ SvXMLImportContext( rImport ),
+ mxNode( lcl_createElement( rImport, nElement, xParent ) )
{
SAL_WARN_IF( !mxNode.is(), "xmloff", "empty XNode not allowed" );
SAL_WARN_IF( !Reference<XElement>( mxNode, UNO_QUERY ).is(), "xmloff", "need element" );
@@ -94,43 +89,39 @@ Reference<XDocument> DomBuilderContext::getTree()
return mxNode->getOwnerDocument();
}
-SvXMLImportContextRef DomBuilderContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList>& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > DomBuilderContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
{
// create DomBuilder for subtree
- return new DomBuilderContext( GetImport(), nPrefix, rLocalName, mxNode );
+ return new DomBuilderContext( GetImport(), nElement, mxNode );
}
-void DomBuilderContext::StartElement(
- const Reference<XAttributeList>& xAttrList )
+void DomBuilderContext::startFastElement(
+ sal_Int32 /*nElement*/,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
SAL_WARN_IF( !mxNode.is(), "xmloff", "empty XNode not allowed" );
SAL_WARN_IF( !mxNode->getOwnerDocument().is(), "xmloff", "XNode must have XDocument" );
// add attribute nodes to new node
- sal_Int16 nAttributeCount = xAttrList->getLength();
- for( sal_Int16 i = 0; i < nAttributeCount; i++ )
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
{
// get name & value for attribute
- const OUString& rName = xAttrList->getNameByIndex( i );
- const OUString& rValue = xAttrList->getValueByIndex( i );
+ OUString aName = SvXMLImport::getNameFromToken(aIter.getToken());
+ OUString aValue = aIter.toString();
// namespace handling: determine namespace & namespace key
- OUString sNamespace;
- sal_uInt16 nNamespaceKey =
- GetImport().GetNamespaceMap().GetKeyByAttrName(
- rName, nullptr, nullptr, &sNamespace);
+ sal_Int32 nNamespacePrefix = (( aIter.getToken() & NMSP_MASK ) >> NMSP_SHIFT) - 1;
// create attribute node and set value
Reference<XElement> xElement( mxNode, UNO_QUERY_THROW );
- switch( nNamespaceKey )
+ switch( nNamespacePrefix )
{
case XML_NAMESPACE_NONE:
// no namespace: create a non-namespaced attribute
- xElement->setAttribute( rName, rValue );
+ xElement->setAttribute( aName, aValue );
break;
case XML_NAMESPACE_XMLNS:
// namespace declaration: ignore, since the DOM tree handles these
@@ -140,25 +131,20 @@ void DomBuilderContext::StartElement(
// unknown namespace: illegal input. Raise Warning.
{
Sequence<OUString> aSeq(2);
- aSeq[0] = rName;
- aSeq[1] = rValue;
+ aSeq[0] = aName;
+ aSeq[1] = aValue;
GetImport().SetError(
XMLERROR_FLAG_WARNING | XMLERROR_NAMESPACE_TROUBLE, aSeq );
}
break;
default:
// a real and proper namespace: create namespaced attribute
- xElement->setAttributeNS( sNamespace, rName, rValue );
+ xElement->setAttributeNS( SvXMLImport::getNamespaceURIFromToken(aIter.getToken()), aName, aValue );
break;
}
}
}
-void DomBuilderContext::EndElement()
-{
- // nothing to be done!
-}
-
void DomBuilderContext::Characters( const OUString& rCharacters )
{
SAL_WARN_IF( !mxNode.is(), "xmloff", "empty XNode not allowed" );
@@ -189,8 +175,7 @@ static Reference<XNode> lcl_createDomInstance()
}
static Reference<XNode> lcl_createElement( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
+ sal_Int32 nElement,
const Reference<XNode>& xParent)
{
SAL_WARN_IF( !xParent.is(), "xmloff", "need parent node" );
@@ -203,18 +188,20 @@ static Reference<XNode> lcl_createElement( SvXMLImport& rImport,
// multiple prefixes for the same namespace. Fortunately, those are rare.
Reference<XElement> xElement;
- switch( nPrefix )
+ sal_Int32 nNamespacePrefix = (( nElement & NMSP_MASK ) >> NMSP_SHIFT) - 1;
+ OUString aLocalName = SvXMLImport::getNameFromToken(nElement);
+ switch( nNamespacePrefix )
{
case XML_NAMESPACE_NONE:
// no namespace: use local name
- xElement = xDocument->createElement( rLocalName );
+ xElement = xDocument->createElement( aLocalName );
break;
case XML_NAMESPACE_XMLNS:
case XML_NAMESPACE_UNKNOWN:
// both cases are illegal; raise warning (and use only local name)
- xElement = xDocument->createElement( rLocalName );
+ xElement = xDocument->createElement( aLocalName );
{
- Sequence<OUString> aSeq { rLocalName };
+ Sequence<OUString> aSeq { aLocalName };
rImport.SetError(
XMLERROR_FLAG_WARNING | XMLERROR_NAMESPACE_TROUBLE, aSeq );
}
@@ -225,8 +212,8 @@ static Reference<XNode> lcl_createElement( SvXMLImport& rImport,
// this is a bug, since this will fail for multiple prefixes used for
// the same namespace.
xElement = xDocument->createElementNS(
- rImport.GetNamespaceMap().GetNameByKey( nPrefix ),
- rImport.GetNamespaceMap().GetQNameByKey( nPrefix, rLocalName ) );
+ rImport.GetNamespaceMap().GetNameByKey( nNamespacePrefix ),
+ rImport.GetNamespaceMap().GetQNameByKey( nNamespacePrefix, aLocalName ) );
break;
}
SAL_WARN_IF( !xElement.is(), "xmloff", "can't create element" );
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index cc515c645a23..99be12818ea8 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -2254,6 +2254,7 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName,
const OUString& rAttrValue = xAttrList->getValueByIndex( i );
sal_uInt16 const nAttrPrefix(mrImport->mpNamespaceMap->GetKeyByAttrName(
rAttrName, nullptr, &aLocalAttrName, &aNamespace));
+ SAL_WARN("xmloff", "nAttrPrefix=" << nAttrPrefix);
if( XML_NAMESPACE_XMLNS != nAttrPrefix )
{
Sequence< sal_Int8 > aAttrSeq( reinterpret_cast<sal_Int8 const *>(
diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx
index 0263989f07d1..8bb17c32b14c 100644
--- a/xmloff/source/forms/layerimport.cxx
+++ b/xmloff/source/forms/layerimport.cxx
@@ -458,7 +458,7 @@ SvXMLImportContext* OFormLayerXMLImport_Impl::createContext(const sal_uInt16 _nP
else if ( _nPrefix == XML_NAMESPACE_XFORMS
&& xmloff::token::IsXMLToken( _rLocalName, xmloff::token::XML_MODEL ) )
{
- pContext = createXFormsModelContext( m_rImporter, _nPrefix, _rLocalName );
+ pContext = createXFormsModelContext( m_rImporter );
}
return pContext;
diff --git a/xmloff/source/xforms/SchemaContext.cxx b/xmloff/source/xforms/SchemaContext.cxx
index 6c19cbfa019a..36346bc9393f 100644
--- a/xmloff/source/xforms/SchemaContext.cxx
+++ b/xmloff/source/xforms/SchemaContext.cxx
@@ -25,6 +25,7 @@
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmltkmap.hxx>
+#include <xmloff/xmlimp.hxx>
#include <com/sun/star/xforms/XDataTypeRepository.hpp>
@@ -34,42 +35,27 @@ using com::sun::star::xforms::XDataTypeRepository;
using namespace xmloff::token;
-static const SvXMLTokenMapEntry aAttributes[] =
-{
- XML_TOKEN_MAP_END
-};
-
-static const SvXMLTokenMapEntry aChildren[] =
-{
- TOKEN_MAP_ENTRY( XSD, SIMPLETYPE ),
- XML_TOKEN_MAP_END
-};
-
SchemaContext::SchemaContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const Reference<XDataTypeRepository>& rRepository ) :
- TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
+ TokenContext( rImport ),
mxRepository( rRepository )
{
}
-void SchemaContext::HandleAttribute(
- sal_uInt16,
+bool SchemaContext::HandleAttribute(
+ sal_Int32 ,
const OUString& )
{
+ return false;
}
SvXMLImportContext* SchemaContext::HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList>& )
+ sal_Int32 nElement,
+ const Reference<css::xml::sax::XFastAttributeList>& )
{
- if ( nToken == XML_SIMPLETYPE )
- return new SchemaSimpleTypeContext( GetImport(), nPrefix, rLocalName,
- mxRepository );
+ if ( nElement == XML_ELEMENT(XSD, XML_SIMPLETYPE))
+ return new SchemaSimpleTypeContext( GetImport(), mxRepository );
return nullptr;
}
diff --git a/xmloff/source/xforms/SchemaContext.hxx b/xmloff/source/xforms/SchemaContext.hxx
index 1e65995eb2a2..eca66406bdd3 100644
--- a/xmloff/source/xforms/SchemaContext.hxx
+++ b/xmloff/source/xforms/SchemaContext.hxx
@@ -39,22 +39,18 @@ class SchemaContext : public TokenContext
public:
SchemaContext( SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
const css::uno::Reference<css::xforms::XDataTypeRepository>& rRepository );
// implement TokenContext methods:
protected:
- virtual void HandleAttribute(
- sal_uInt16 nToken,
+ virtual bool HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue ) override;
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
};
#endif
diff --git a/xmloff/source/xforms/SchemaRestrictionContext.cxx b/xmloff/source/xforms/SchemaRestrictionContext.cxx
index cafaab50b16c..e4db981de1ab 100644
--- a/xmloff/source/xforms/SchemaRestrictionContext.cxx
+++ b/xmloff/source/xforms/SchemaRestrictionContext.cxx
@@ -53,37 +53,11 @@ using com::sun::star::xforms::XDataTypeRepository;
using namespace xmloff::token;
-static const SvXMLTokenMapEntry aAttributes[] =
-{
- TOKEN_MAP_ENTRY( NONE, BASE ),
- XML_TOKEN_MAP_END
-};
-
-static const SvXMLTokenMapEntry aChildren[] =
-{
- TOKEN_MAP_ENTRY( XSD, LENGTH ),
- TOKEN_MAP_ENTRY( XSD, MINLENGTH ),
- TOKEN_MAP_ENTRY( XSD, MAXLENGTH ),
- TOKEN_MAP_ENTRY( XSD, MININCLUSIVE ),
- TOKEN_MAP_ENTRY( XSD, MINEXCLUSIVE ),
- TOKEN_MAP_ENTRY( XSD, MAXINCLUSIVE ),
- TOKEN_MAP_ENTRY( XSD, MAXEXCLUSIVE ),
- TOKEN_MAP_ENTRY( XSD, PATTERN ),
- // ??? XML_ENUMERATION
- TOKEN_MAP_ENTRY( XSD, WHITESPACE ),
- TOKEN_MAP_ENTRY( XSD, TOTALDIGITS ),
- TOKEN_MAP_ENTRY( XSD, FRACTIONDIGITS ),
- XML_TOKEN_MAP_END
-};
-
-
SchemaRestrictionContext::SchemaRestrictionContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
Reference<css::xforms::XDataTypeRepository> const & rRepository,
const OUString& sTypeName ) :
- TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
+ TokenContext( rImport ),
mxRepository( rRepository ),
msTypeName( sTypeName ),
msBaseName()
@@ -116,14 +90,16 @@ void SchemaRestrictionContext::CreateDataType()
SAL_WARN_IF( !mxDataType.is(), "xmloff", "can't create type" );
}
-void SchemaRestrictionContext::HandleAttribute(
- sal_uInt16 nToken,
+bool SchemaRestrictionContext::HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue )
{
- if( nToken == XML_BASE )
+ if( nElement == XML_ELEMENT(NONE, XML_BASE) )
{
msBaseName = rValue;
+ return true;
}
+ return false;
}
typedef Any (*convert_t)( const OUString& );
@@ -210,59 +186,55 @@ static Any xforms_time( const OUString& rValue )
return aAny;
}
-
SvXMLImportContext* SchemaRestrictionContext::HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList>& xAttrList )
+ sal_Int32 nElement,
+ const Reference<css::xml::sax::XFastAttributeList>& xAttrList )
{
// find value
OUString sValue;
- sal_Int16 nLength = xAttrList->getLength();
- for( sal_Int16 n = 0; n < nLength; n++ )
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
{
- if( IsXMLToken( xAttrList->getNameByIndex( n ), XML_VALUE ) )
- sValue = xAttrList->getValueByIndex( n );
+ if( (aIter.getToken() & TOKEN_MASK) == XML_VALUE )
+ sValue = aIter.toString();
}
// determine property name + suitable converter
OUString sPropertyName;
convert_t pConvert = nullptr;
- switch( nToken )
+ switch( nElement )
{
- case XML_LENGTH:
+ case XML_ELEMENT(XSD, XML_LENGTH):
sPropertyName = "Length";
pConvert = &xforms_int32;
break;
- case XML_MINLENGTH:
+ case XML_ELEMENT(XSD, XML_MINLENGTH):
sPropertyName = "MinLength";
pConvert = &xforms_int32;
break;
- case XML_MAXLENGTH:
+ case XML_ELEMENT(XSD, XML_MAXLENGTH):
sPropertyName = "MaxLength";
pConvert = &xforms_int32;
break;
- case XML_TOTALDIGITS:
+ case XML_ELEMENT(XSD, XML_TOTALDIGITS):
sPropertyName = "TotalDigits";
pConvert = &xforms_int32;
break;
- case XML_FRACTIONDIGITS:
+ case XML_ELEMENT(XSD, XML_FRACTIONDIGITS):
sPropertyName = "FractionDigits";
pConvert = &xforms_int32;
break;
- case XML_PATTERN:
+ case XML_ELEMENT(XSD, XML_PATTERN):
sPropertyName = "Pattern";
pConvert = &xforms_string;
break;
- case XML_WHITESPACE:
+ case XML_ELEMENT(XSD, XML_WHITESPACE):
sPropertyName = "WhiteSpace";
pConvert = &xforms_whitespace;
break;
- case XML_MININCLUSIVE:
- case XML_MINEXCLUSIVE:
- case XML_MAXINCLUSIVE:
- case XML_MAXEXCLUSIVE:
+ case XML_ELEMENT(XSD, XML_MININCLUSIVE):
+ case XML_ELEMENT(XSD, XML_MINEXCLUSIVE):
+ case XML_ELEMENT(XSD, XML_MAXINCLUSIVE):
+ case XML_ELEMENT(XSD, XML_MAXEXCLUSIVE):
{
// these attributes are mapped to different properties.
// To determine the property name, we use an attribute
@@ -270,18 +242,18 @@ SvXMLImportContext* SchemaRestrictionContext::HandleChild(
// converter is only type dependent.
// first, attribute-dependent prefix
- switch( nToken )
+ switch( nElement )
{
- case XML_MININCLUSIVE:
+ case XML_ELEMENT(XSD, XML_MININCLUSIVE):
sPropertyName = "MinInclusive";
break;
- case XML_MINEXCLUSIVE:
+ case XML_ELEMENT(XSD, XML_MINEXCLUSIVE):
sPropertyName = "MinExclusive";
break;
- case XML_MAXINCLUSIVE:
+ case XML_ELEMENT(XSD, XML_MAXINCLUSIVE):
sPropertyName = "MaxInclusive";
break;
- case XML_MAXEXCLUSIVE:
+ case XML_ELEMENT(XSD, XML_MAXEXCLUSIVE):
sPropertyName = "MaxExclusive";
break;
}
@@ -336,7 +308,7 @@ SvXMLImportContext* SchemaRestrictionContext::HandleChild(
break;
default:
- OSL_FAIL( "unknown facet" );
+ SAL_WARN("xmloff", "unknown element " << SvXMLImport::getPrefixAndNameFromToken(nElement));
}
// finally, set the property
@@ -356,7 +328,7 @@ SvXMLImportContext* SchemaRestrictionContext::HandleChild(
}
}
- return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+ return new SvXMLImportContext( GetImport() );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/xforms/SchemaRestrictionContext.hxx b/xmloff/source/xforms/SchemaRestrictionContext.hxx
index 29a36247a335..1c3e84f1c4d6 100644
--- a/xmloff/source/xforms/SchemaRestrictionContext.hxx
+++ b/xmloff/source/xforms/SchemaRestrictionContext.hxx
@@ -42,8 +42,6 @@ class SchemaRestrictionContext : public TokenContext
public:
SchemaRestrictionContext( SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
css::uno::Reference<css::xforms::XDataTypeRepository> const & rRepository,
const OUString& sTypeName );
@@ -53,15 +51,13 @@ private:
// implement TokenContext methods:
- virtual void HandleAttribute(
- sal_uInt16 nToken,
+ virtual bool HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue ) override;
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
};
#endif
diff --git a/xmloff/source/xforms/SchemaSimpleTypeContext.cxx b/xmloff/source/xforms/SchemaSimpleTypeContext.cxx
index 0c01874efbf5..47f770325ee3 100644
--- a/xmloff/source/xforms/SchemaSimpleTypeContext.cxx
+++ b/xmloff/source/xforms/SchemaSimpleTypeContext.cxx
@@ -25,6 +25,7 @@
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmltkmap.hxx>
+#include <xmloff/xmlimp.hxx>
#include <osl/diagnose.h>
@@ -34,49 +35,34 @@ using com::sun::star::xforms::XDataTypeRepository;
using namespace xmloff::token;
-static const SvXMLTokenMapEntry aAttributes[] =
-{
- TOKEN_MAP_ENTRY( NONE, NAME ),
- XML_TOKEN_MAP_END
-};
-
-static const SvXMLTokenMapEntry aChildren[] =
-{
- TOKEN_MAP_ENTRY( XSD, RESTRICTION ),
- XML_TOKEN_MAP_END
-};
-
SchemaSimpleTypeContext::SchemaSimpleTypeContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const Reference<XDataTypeRepository>& rRepository ) :
- TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
+ TokenContext( rImport ),
mxRepository( rRepository )
{
}
-void SchemaSimpleTypeContext::HandleAttribute(
- sal_uInt16 nToken,
+bool SchemaSimpleTypeContext::HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue )
{
- if( nToken == XML_NAME )
+ if( nElement == XML_ELEMENT(NONE, XML_NAME) )
{
msTypeName = rValue;
+ return true;
}
+ return false;
}
SvXMLImportContext* SchemaSimpleTypeContext::HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList>& )
+ sal_Int32 nElement,
+ const Reference<css::xml::sax::XFastAttributeList>& )
{
- switch( nToken )
+ switch( nElement )
{
- case XML_RESTRICTION:
+ case XML_ELEMENT(XSD, XML_RESTRICTION):
return new SchemaRestrictionContext( GetImport(),
- nPrefix, rLocalName,
mxRepository, msTypeName );
break;
}
diff --git a/xmloff/source/xforms/SchemaSimpleTypeContext.hxx b/xmloff/source/xforms/SchemaSimpleTypeContext.hxx
index 0280b0870f3c..72341b0b3a5d 100644
--- a/xmloff/source/xforms/SchemaSimpleTypeContext.hxx
+++ b/xmloff/source/xforms/SchemaSimpleTypeContext.hxx
@@ -40,22 +40,18 @@ class SchemaSimpleTypeContext : public TokenContext
public:
SchemaSimpleTypeContext( SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
const css::uno::Reference<css::xforms::XDataTypeRepository>& rRepository );
// implement TokenContext methods:
protected:
- virtual void HandleAttribute(
- sal_uInt16 nToken,
+ virtual bool HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue ) override;
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
};
#endif
diff --git a/xmloff/source/xforms/TokenContext.cxx b/xmloff/source/xforms/TokenContext.cxx
index 71215c4395d7..d5b410ab94be 100644
--- a/xmloff/source/xforms/TokenContext.cxx
+++ b/xmloff/source/xforms/TokenContext.cxx
@@ -29,84 +29,51 @@
#include <algorithm>
using com::sun::star::uno::Reference;
-using com::sun::star::xml::sax::XAttributeList;
-const SvXMLTokenMapEntry aEmptyMap[1] =
-{
- XML_TOKEN_MAP_END
-};
-
-TokenContext::TokenContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const SvXMLTokenMapEntry* pAttributes,
- const SvXMLTokenMapEntry* pChildren )
- : SvXMLImportContext( rImport, nPrefix, rLocalName ),
- mpAttributes( pAttributes ),
- mpChildren( pChildren )
+TokenContext::TokenContext( SvXMLImport& rImport )
+ : SvXMLImportContext( rImport )
{
}
-void TokenContext::StartElement(
- const Reference<XAttributeList>& xAttributeList )
+void TokenContext::startFastElement(
+ sal_Int32 /*nElement*/,
+ const Reference<css::xml::sax::XFastAttributeList>& xAttributeList )
{
// iterate over attributes
// - if in map: call HandleAttribute
// - xmlns:... : ignore
// - other: warning
- SAL_WARN_IF( mpAttributes == nullptr, "xmloff", "no token map for attributes" );
- SvXMLTokenMap aMap( mpAttributes );
- sal_Int16 nCount = xAttributeList->getLength();
- for( sal_Int16 i = 0; i < nCount; i++ )
+ for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttributeList ))
{
- // get key/local-name pair from namespace map
- OUString sLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName( xAttributeList->getNameByIndex(i), &sLocalName );
-
- // get token from token map
- sal_uInt16 nToken = aMap.Get( nPrefix, sLocalName );
-
// and the value...
- const OUString& rValue = xAttributeList->getValueByIndex(i);
+ OUString aValue = aIter.toString();
- if( nToken != XML_TOK_UNKNOWN )
- {
- HandleAttribute( nToken, rValue );
- }
- else if( nPrefix != XML_NAMESPACE_XMLNS )
+ if (HandleAttribute( aIter.getToken(), aValue ))
+ ; //fine
+ else if ( IsTokenInNamespace(aIter.getToken(), XML_NAMESPACE_XMLNS) )
+ ; // ignore
+ else
{
// error handling, for all attribute that are not
// namespace declarations
GetImport().SetError( XMLERROR_UNKNOWN_ATTRIBUTE,
- sLocalName, rValue);
+ SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()), aValue);
}
}
}
-SvXMLImportContextRef TokenContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList>& xAttrList )
+css::uno::Reference< css::xml::sax::XFastContextHandler > TokenContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
{
- // call HandleChild for elements in token map. Ignore other content.
-
- SvXMLImportContext* pContext = nullptr;
-
- SAL_WARN_IF( mpChildren == nullptr, "xmloff", "no token map for child elements" );
- SvXMLTokenMap aMap( mpChildren );
- sal_uInt16 nToken = aMap.Get( nPrefix, rLocalName );
- if( nToken != XML_TOK_UNKNOWN )
- {
- // call handle child, and pass down arguments
- pContext = HandleChild( nToken, nPrefix, rLocalName, xAttrList );
- }
+ // call handle child, and pass down arguments
+ SvXMLImportContext* pContext = HandleChild( nElement, xAttrList );
// error handling: create default context and generate warning
if( pContext == nullptr )
{
- GetImport().SetError( XMLERROR_UNKNOWN_ELEMENT, rLocalName );
+ GetImport().SetError( XMLERROR_UNKNOWN_ELEMENT, SvXMLImport::getPrefixAndNameFromToken(nElement) );
}
return pContext;
}
diff --git a/xmloff/source/xforms/TokenContext.hxx b/xmloff/source/xforms/TokenContext.hxx
index 97b595232726..a8cd89bdf1e7 100644
--- a/xmloff/source/xforms/TokenContext.hxx
+++ b/xmloff/source/xforms/TokenContext.hxx
@@ -24,46 +24,33 @@
#include <xmloff/xmltkmap.hxx>
namespace com { namespace sun { namespace star {
- namespace xml { namespace sax { class XAttributeList; } }
+ namespace xml { namespace sax { class XFastAttributeList; } }
namespace uno { template<typename T> class Reference; }
} } }
class SvXMLImport;
-#define TOKEN_MAP_ENTRY(NAMESPACE,TOKEN) { XML_NAMESPACE_##NAMESPACE, xmloff::token::XML_##TOKEN, xmloff::token::XML_##TOKEN }
-
-extern const SvXMLTokenMapEntry aEmptyMap[1];
-
/** handle attributes through an SvXMLTokenMap */
class TokenContext : public SvXMLImportContext
{
-protected:
- const SvXMLTokenMapEntry* mpAttributes; /// static token map
- const SvXMLTokenMapEntry* mpChildren; /// static token map
-
public:
- TokenContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const SvXMLTokenMapEntry* pAttributes,
- const SvXMLTokenMapEntry* pChildren );
+ TokenContext( SvXMLImport& rImport );
// implement SvXMLImportContext methods:
/** call HandleAttribute for each attribute in the token map;
* create a warning for all others. Classes that wish to override
* StartElement need to call the parent method. */
- virtual void StartElement(
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ virtual void SAL_CALL startFastElement( sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
/** call HandleChild for each child element in the token map;
* create a warning for all others. Classes that wish to override
* CreateChildContext may want to call the parent method for
* handling of defaults. */
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
/** Create a warning for all non-namespace character
* content. Classes that wish to deal with character content have
@@ -72,20 +59,15 @@ public:
virtual void Characters( const OUString& rChars ) override;
protected:
- /** will be called for each attribute */
- virtual void HandleAttribute(
- sal_uInt16 nToken,
+ /** will be called for each attribute. return true for success. */
+ virtual bool HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue ) = 0;
/** will be called for each child element */
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
-
- // the following attributes are mainly to be used for child
- // context creation
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) = 0;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) = 0;
};
#endif
diff --git a/xmloff/source/xforms/XFormsBindContext.cxx b/xmloff/source/xforms/XFormsBindContext.cxx
index c975e8b65b5c..cd848f9e1275 100644
--- a/xmloff/source/xforms/XFormsBindContext.cxx
+++ b/xmloff/source/xforms/XFormsBindContext.cxx
@@ -44,29 +44,14 @@ using com::sun::star::xforms::XModel2;
using namespace xmloff::token;
-static const struct SvXMLTokenMapEntry aAttributeMap[] =
-{
- TOKEN_MAP_ENTRY( NONE, NODESET ),
- TOKEN_MAP_ENTRY( NONE, ID ),
- TOKEN_MAP_ENTRY( NONE, READONLY ),
- TOKEN_MAP_ENTRY( NONE, RELEVANT ),
- TOKEN_MAP_ENTRY( NONE, REQUIRED ),
- TOKEN_MAP_ENTRY( NONE, CONSTRAINT ),
- TOKEN_MAP_ENTRY( NONE, CALCULATE ),
- TOKEN_MAP_ENTRY( NONE, TYPE ),
- XML_TOKEN_MAP_END
-};
-
// helper function; see below
static void lcl_fillNamespaceContainer( const SvXMLNamespaceMap&,
Reference<XNameContainer> const & );
XFormsBindContext::XFormsBindContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const Reference<XModel2>& xModel ) :
- TokenContext( rImport, nPrefix, rLocalName, aAttributeMap, aEmptyMap ),
+ TokenContext( rImport ),
mxModel( xModel )
{
// attach binding to model
@@ -75,46 +60,47 @@ XFormsBindContext::XFormsBindContext(
mxModel->getBindings()->insert( makeAny( mxBinding ) );
}
-void XFormsBindContext::HandleAttribute( sal_uInt16 nToken,
+bool XFormsBindContext::HandleAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- switch( nToken )
+ switch( nElement )
{
- case XML_NODESET:
+ case XML_ELEMENT(NONE, XML_NODESET):
xforms_setValue( mxBinding, "BindingExpression", rValue );
break;
- case XML_ID:
+ case XML_ELEMENT(NONE, XML_ID):
xforms_setValue( mxBinding, "BindingID", rValue );
break;
- case XML_READONLY:
+ case XML_ELEMENT(NONE, XML_READONLY):
xforms_setValue( mxBinding, "ReadonlyExpression", rValue );
break;
- case XML_RELEVANT:
+ case XML_ELEMENT(NONE, XML_RELEVANT):
xforms_setValue( mxBinding, "RelevantExpression", rValue );
break;
- case XML_REQUIRED:
+ case XML_ELEMENT(NONE, XML_REQUIRED):
xforms_setValue( mxBinding, "RequiredExpression", rValue );
break;
- case XML_CONSTRAINT:
+ case XML_ELEMENT(NONE, XML_CONSTRAINT):
xforms_setValue( mxBinding, "ConstraintExpression", rValue );
break;
- case XML_CALCULATE:
+ case XML_ELEMENT(NONE, XML_CALCULATE):
xforms_setValue( mxBinding, "CalculateExpression", rValue );
break;
- case XML_TYPE:
+ case XML_ELEMENT(NONE, XML_TYPE):
xforms_setValue( mxBinding, "Type",
makeAny( xforms_getTypeName( mxModel->getDataTypeRepository(),
GetImport().GetNamespaceMap(),
rValue ) ) );
break;
default:
- OSL_FAIL( "should not happen" );
- break;
+ return false;
}
+ return true;
}
-void XFormsBindContext::StartElement(
- const Reference<XAttributeList>& xAttributeList )
+void XFormsBindContext::startFastElement(
+ sal_Int32 nElement,
+ const Reference<css::xml::sax::XFastAttributeList>& xAttributeList )
{
// we need to register the namespaces
Reference<XNameContainer> xContainer(
@@ -126,15 +112,13 @@ void XFormsBindContext::StartElement(
lcl_fillNamespaceContainer( GetImport().GetNamespaceMap(), xContainer);
// call super-class for attribute handling
- TokenContext::StartElement( xAttributeList );
+ TokenContext::startFastElement( nElement, xAttributeList );
}
/** will be called for each child element */
SvXMLImportContext* XFormsBindContext::HandleChild(
- sal_uInt16,
- sal_uInt16,
- const OUString&,
- const Reference<XAttributeList>& )
+ sal_Int32,
+ const Reference<css::xml::sax::XFastAttributeList>& )
{
OSL_FAIL( "no children supported" );
return nullptr;
diff --git a/xmloff/source/xforms/XFormsBindContext.hxx b/xmloff/source/xforms/XFormsBindContext.hxx
index 26424b8c406f..a4c7a47a48fd 100644
--- a/xmloff/source/xforms/XFormsBindContext.hxx
+++ b/xmloff/source/xforms/XFormsBindContext.hxx
@@ -40,24 +40,21 @@ class XFormsBindContext : public TokenContext
public:
XFormsBindContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const css::uno::Reference<css::xforms::XModel2>& xModel );
// implement SvXMLImportContext & TokenContext methods:
- virtual void StartElement(
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ virtual void SAL_CALL startFastElement(
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
protected:
- virtual void HandleAttribute( sal_uInt16 nToken,
+ virtual bool HandleAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nNamespace,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
};
diff --git a/xmloff/source/xforms/XFormsInstanceContext.cxx b/xmloff/source/xforms/XFormsInstanceContext.cxx
index e1a81a3f6c37..05beebbb2e11 100644
--- a/xmloff/source/xforms/XFormsInstanceContext.cxx
+++ b/xmloff/source/xforms/XFormsInstanceContext.cxx
@@ -46,28 +46,18 @@ using com::sun::star::xml::sax::XAttributeList;
using xmloff::token::XML_SRC;
using xmloff::token::XML_ID;
-static const SvXMLTokenMapEntry aAttributes[] =
-{
- TOKEN_MAP_ENTRY( NONE, SRC ),
- TOKEN_MAP_ENTRY( NONE, ID ),
- XML_TOKEN_MAP_END
-};
-
XFormsInstanceContext::XFormsInstanceContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const Reference<XModel2> & xModel ) :
- TokenContext( rImport, nPrefix, rLocalName, aAttributes, aEmptyMap ),
+ TokenContext( rImport ),
mxModel( xModel )
{
SAL_WARN_IF( !mxModel.is(), "xmloff", "need model" );
}
-SvXMLImportContextRef XFormsInstanceContext::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList>& )
+css::uno::Reference< css::xml::sax::XFastContextHandler > XFormsInstanceContext::createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
{
SvXMLImportContext* pContext = nullptr;
@@ -76,13 +66,12 @@ SvXMLImportContextRef XFormsInstanceContext::CreateChildContext(
// ignored.
if( mxInstance.is() )
{
- GetImport().SetError( XMLERROR_XFORMS_ONLY_ONE_INSTANCE_ELEMENT, rLocalName );
+ GetImport().SetError( XMLERROR_XFORMS_ONLY_ONE_INSTANCE_ELEMENT, SvXMLImport::getPrefixAndNameFromToken(nElement) );
}
else
{
// create new DomBuilderContext. Save reference to tree in Model.
- DomBuilderContext* pInstance =
- new DomBuilderContext( GetImport(), nPrefix, rLocalName );
+ DomBuilderContext* pInstance = new DomBuilderContext( GetImport(), nElement );
mxInstance = pInstance->getTree();
pContext = pInstance;
}
@@ -92,7 +81,7 @@ SvXMLImportContextRef XFormsInstanceContext::CreateChildContext(
}
-void XFormsInstanceContext::EndElement()
+void XFormsInstanceContext::endFastElement(sal_Int32 )
{
Sequence<PropertyValue> aSequence( 3 );
PropertyValue* pSequence = aSequence.getArray();
@@ -107,29 +96,28 @@ void XFormsInstanceContext::EndElement()
}
-void XFormsInstanceContext::HandleAttribute(
- sal_uInt16 nToken,
+bool XFormsInstanceContext::HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue )
{
- switch( nToken )
+ switch( nElement )
{
- case XML_SRC:
+ case XML_ELEMENT(NONE, XML_SRC):
msURL = rValue;
break;
- case XML_ID:
+ case XML_ELEMENT(NONE, XML_ID):
msId = rValue;
break;
default:
- OSL_FAIL( "should not happen" );
+ return false;
break;
}
+ return true;
}
SvXMLImportContext* XFormsInstanceContext::HandleChild(
- sal_uInt16,
- sal_uInt16,
- const OUString&,
- const Reference<XAttributeList>& )
+ sal_Int32,
+ const Reference<css::xml::sax::XFastAttributeList>& )
{
OSL_FAIL( "to be handled by CreateChildContext" );
return nullptr;
diff --git a/xmloff/source/xforms/XFormsInstanceContext.hxx b/xmloff/source/xforms/XFormsInstanceContext.hxx
index df77d00a7e18..92734dcadc89 100644
--- a/xmloff/source/xforms/XFormsInstanceContext.hxx
+++ b/xmloff/source/xforms/XFormsInstanceContext.hxx
@@ -43,8 +43,6 @@ class XFormsInstanceContext : public TokenContext
public:
XFormsInstanceContext( SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
const css::uno::Reference<css::xforms::XModel2> & xModel );
// implement SvXMLImportContext & TokenContext methods:
@@ -52,23 +50,20 @@ public:
// arbitrary DOM elements. For the attributes, we use the
// TokenContext mechanism.
- virtual SvXMLImportContextRef CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList >& xAttrList ) override;
+ virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
- virtual void EndElement() override;
+ virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
protected:
- virtual void HandleAttribute(
- sal_uInt16 nToken,
+ virtual bool HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue ) override;
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nNamespace,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
};
#endif
diff --git a/xmloff/source/xforms/XFormsModelContext.cxx b/xmloff/source/xforms/XFormsModelContext.cxx
index e846e54b5866..9217ab30c14d 100644
--- a/xmloff/source/xforms/XFormsModelContext.cxx
+++ b/xmloff/source/xforms/XFormsModelContext.cxx
@@ -44,77 +44,52 @@ using namespace com::sun::star::uno;
using namespace xmloff::token;
-static const SvXMLTokenMapEntry aAttributes[] =
-{
- TOKEN_MAP_ENTRY( NONE, ID ),
- TOKEN_MAP_ENTRY( NONE, SCHEMA ),
- XML_TOKEN_MAP_END
-};
-
-static const SvXMLTokenMapEntry aChildren[] =
-{
- TOKEN_MAP_ENTRY( XFORMS, INSTANCE ),
- TOKEN_MAP_ENTRY( XFORMS, BIND ),
- TOKEN_MAP_ENTRY( XFORMS, SUBMISSION ),
- TOKEN_MAP_ENTRY( XSD, SCHEMA ),
- XML_TOKEN_MAP_END
-};
-
-
-XFormsModelContext::XFormsModelContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName ) :
- TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
+XFormsModelContext::XFormsModelContext( SvXMLImport& rImport ) :
+ TokenContext( rImport ),
mxModel( xforms_createXFormsModel() )
{
}
-void XFormsModelContext::HandleAttribute(
- sal_uInt16 nToken,
+bool XFormsModelContext::HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue )
{
- switch( nToken )
+ switch( nElement )
{
- case XML_ID:
+ case XML_ELEMENT(NONE, XML_ID):
mxModel->setPropertyValue( "ID", makeAny( rValue ) );
break;
- case XML_SCHEMA:
+ case XML_ELEMENT(NONE, XML_SCHEMA):
GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT );
break;
default:
- OSL_FAIL( "this should not happen" );
+ return false;
break;
}
+ return true;
}
SvXMLImportContext* XFormsModelContext::HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const Reference<XAttributeList>& )
+ sal_Int32 nElement,
+ const Reference<css::xml::sax::XFastAttributeList>& )
{
SvXMLImportContext* pContext = nullptr;
- switch( nToken )
+ switch( nElement )
{
- case XML_INSTANCE:
- pContext = new XFormsInstanceContext( GetImport(), nPrefix, rLocalName,
- mxModel );
+ case XML_ELEMENT(XFORMS, XML_INSTANCE):
+ pContext = new XFormsInstanceContext( GetImport(), mxModel );
break;
- case XML_BIND:
- pContext = new XFormsBindContext( GetImport(), nPrefix, rLocalName,
- mxModel );
+ case XML_ELEMENT(XFORMS, XML_BIND):
+ pContext = new XFormsBindContext( GetImport(), mxModel );
break;
- case XML_SUBMISSION:
- pContext = new XFormsSubmissionContext( GetImport(), nPrefix,
- rLocalName, mxModel );
+ case XML_ELEMENT(XFORMS, XML_SUBMISSION):
+ pContext = new XFormsSubmissionContext( GetImport(), mxModel );
break;
- case XML_SCHEMA:
- pContext = new SchemaContext(
- GetImport(), nPrefix, rLocalName, mxModel->getDataTypeRepository() );
+ case XML_ELEMENT(XSD, XML_SCHEMA):
+ pContext = new SchemaContext( GetImport(), mxModel->getDataTypeRepository() );
break;
default:
- OSL_FAIL( "Boooo!" );
break;
}
diff --git a/xmloff/source/xforms/XFormsModelContext.hxx b/xmloff/source/xforms/XFormsModelContext.hxx
index d80b33088a7d..1e44951ad26d 100644
--- a/xmloff/source/xforms/XFormsModelContext.hxx
+++ b/xmloff/source/xforms/XFormsModelContext.hxx
@@ -38,24 +38,20 @@ class XFormsModelContext : public TokenContext
css::uno::Reference<css::xforms::XModel2> mxModel;
public:
- XFormsModelContext( SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName );
+ XFormsModelContext( SvXMLImport& rImport );
// implement SvXMLImportContext & TokenContext methods:
virtual void EndElement() override;
protected:
- virtual void HandleAttribute(
- sal_uInt16 nToken,
+ virtual bool HandleAttribute(
+ sal_Int32 nElement,
const OUString& rValue ) override;
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
};
#endif
diff --git a/xmloff/source/xforms/XFormsSubmissionContext.cxx b/xmloff/source/xforms/XFormsSubmissionContext.cxx
index 254c7b97b11d..695b70808a87 100644
--- a/xmloff/source/xforms/XFormsSubmissionContext.cxx
+++ b/xmloff/source/xforms/XFormsSubmissionContext.cxx
@@ -41,32 +41,10 @@ using namespace com::sun::star::uno;
using namespace xmloff::token;
-static const struct SvXMLTokenMapEntry aAttributeMap[] =
-{
- TOKEN_MAP_ENTRY( NONE, ID ),
- TOKEN_MAP_ENTRY( NONE, BIND ),
- TOKEN_MAP_ENTRY( NONE, REF ),
- TOKEN_MAP_ENTRY( NONE, ACTION ),
- TOKEN_MAP_ENTRY( NONE, METHOD ),
- TOKEN_MAP_ENTRY( NONE, VERSION ),
- TOKEN_MAP_ENTRY( NONE, INDENT ),
- TOKEN_MAP_ENTRY( NONE, MEDIATYPE ),
- TOKEN_MAP_ENTRY( NONE, ENCODING ),
- TOKEN_MAP_ENTRY( NONE, OMIT_XML_DECLARATION ),
- TOKEN_MAP_ENTRY( NONE, STANDALONE ),
- TOKEN_MAP_ENTRY( NONE, CDATA_SECTION_ELEMENTS ),
- TOKEN_MAP_ENTRY( NONE, REPLACE ),
- TOKEN_MAP_ENTRY( NONE, SEPARATOR ),
- TOKEN_MAP_ENTRY( NONE, INCLUDENAMESPACEPREFIXES ),
- XML_TOKEN_MAP_END
-};
-
XFormsSubmissionContext::XFormsSubmissionContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const Reference<XModel2>& xModel ) :
- TokenContext( rImport, nPrefix, rLocalName, aAttributeMap, aEmptyMap ),
+ TokenContext( rImport ),
mxSubmission()
{
// register submission with model
@@ -91,69 +69,68 @@ Any toBool( const OUString& rValue )
} // namespace
-void XFormsSubmissionContext::HandleAttribute( sal_uInt16 nToken,
+bool XFormsSubmissionContext::HandleAttribute( sal_Int32 nElement,
const OUString& rValue )
{
- switch( nToken )
+ switch( nElement )
{
- case XML_ID:
+ case XML_ELEMENT(NONE, XML_ID):
xforms_setValue( mxSubmission, "ID", rValue );
break;
- case XML_BIND:
+ case XML_ELEMENT(NONE, XML_BIND):
xforms_setValue( mxSubmission, "Bind", rValue );
break;
- case XML_REF:
+ case XML_ELEMENT(NONE, XML_REF):
xforms_setValue( mxSubmission, "Ref", rValue );
break;
- case XML_ACTION:
+ case XML_ELEMENT(NONE, XML_ACTION):
xforms_setValue( mxSubmission, "Action", rValue );
break;
- case XML_METHOD:
+ case XML_ELEMENT(NONE, XML_METHOD):
xforms_setValue( mxSubmission, "Method", rValue );
break;
- case XML_VERSION:
+ case XML_ELEMENT(NONE, XML_VERSION):
xforms_setValue( mxSubmission, "Version", rValue );
break;
- case XML_INDENT:
+ case XML_ELEMENT(NONE, XML_INDENT):
xforms_setValue( mxSubmission, "Indent", toBool( rValue ) );
break;
- case XML_MEDIATYPE:
+ case XML_ELEMENT(NONE, XML_MEDIATYPE):
xforms_setValue( mxSubmission, "MediaType", rValue );
break;
- case XML_ENCODING:
+ case XML_ELEMENT(NONE, XML_ENCODING):
xforms_setValue( mxSubmission, "Encoding", rValue );
break;
- case XML_OMIT_XML_DECLARATION:
+ case XML_ELEMENT(NONE, XML_OMIT_XML_DECLARATION):
xforms_setValue( mxSubmission, "OmitXmlDeclaration",
toBool( rValue ) );
break;
- case XML_STANDALONE:
+ case XML_ELEMENT(NONE, XML_STANDALONE):
xforms_setValue( mxSubmission, "Standalone", toBool( rValue ) );
break;
- case XML_CDATA_SECTION_ELEMENTS:
+ case XML_ELEMENT(NONE, XML_CDATA_SECTION_ELEMENTS):
xforms_setValue( mxSubmission, "CDataSectionElement", rValue );
break;
- case XML_REPLACE:
+ case XML_ELEMENT(NONE, XML_REPLACE):
xforms_setValue( mxSubmission, "Replace", rValue );
break;
- case XML_SEPARATOR:
+ case XML_ELEMENT(NONE, XML_SEPARATOR):
xforms_setValue( mxSubmission, "Separator", rValue );
break;
- case XML_INCLUDENAMESPACEPREFIXES:
+ case XML_ELEMENT(NONE, XML_INCLUDENAMESPACEPREFIXES):
xforms_setValue( mxSubmission, "IncludeNamespacePrefixes", rValue );
break;
default:
- OSL_FAIL( "unknown attribute" );
+ return false;
break;
}
+ return true;
}
/** will be called for each child element */
SvXMLImportContext* XFormsSubmissionContext::HandleChild(
- sal_uInt16,
- sal_uInt16,
- const OUString&,
- const Reference<XAttributeList>& )
+ sal_Int32,
+ const Reference<css::xml::sax::XFastAttributeList>& )
{
OSL_FAIL( "no children supported" );
return nullptr;
diff --git a/xmloff/source/xforms/XFormsSubmissionContext.hxx b/xmloff/source/xforms/XFormsSubmissionContext.hxx
index 33ac54542bd8..5fe7d4d379ef 100644
--- a/xmloff/source/xforms/XFormsSubmissionContext.hxx
+++ b/xmloff/source/xforms/XFormsSubmissionContext.hxx
@@ -39,21 +39,17 @@ class XFormsSubmissionContext : public TokenContext
public:
XFormsSubmissionContext( SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
const css::uno::Reference<css::xforms::XModel2>& xModel );
// implement TokenContext methods:
protected:
- virtual void HandleAttribute( sal_uInt16 nToken,
+ virtual bool HandleAttribute( sal_Int32 nElement,
const OUString& rValue ) override;
virtual SvXMLImportContext* HandleChild(
- sal_uInt16 nToken,
- sal_uInt16 nNamespace,
- const OUString& rLocalName,
- const css::uno::Reference<css::xml::sax::XAttributeList>& xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList ) override;
};
diff --git a/xmloff/source/xforms/xformsimport.cxx b/xmloff/source/xforms/xformsimport.cxx
index 4d07507a6e68..2579d2cf0d93 100644
--- a/xmloff/source/xforms/xformsimport.cxx
+++ b/xmloff/source/xforms/xformsimport.cxx
@@ -54,12 +54,9 @@ using com::sun::star::form::binding::XListEntrySink;
using com::sun::star::form::submission::XSubmission;
using com::sun::star::form::submission::XSubmissionSupplier;
-SvXMLImportContext* createXFormsModelContext(
- SvXMLImport& rImport,
- sal_uInt16 nPrefix,
- const OUString& rLocalName )
+SvXMLImportContext* createXFormsModelContext( SvXMLImport& rImport )
{
- return new XFormsModelContext( rImport, nPrefix, rLocalName );
+ return new XFormsModelContext( rImport );
}
void bindXFormsValueBinding(Reference<XModel> const& xModel,