msxml3: Make positions returned by ISAXLocator compatible with msxml6.
This commit is contained in:
parent
a8444d7fd1
commit
e84c41028b
|
@ -81,7 +81,12 @@ static const struct clsid_version_t clsid_versions_table[] =
|
||||||
{ &CLSID_MXXMLWriter, MSXML_DEFAULT },
|
{ &CLSID_MXXMLWriter, MSXML_DEFAULT },
|
||||||
{ &CLSID_MXXMLWriter30, MSXML3 },
|
{ &CLSID_MXXMLWriter30, MSXML3 },
|
||||||
{ &CLSID_MXXMLWriter40, MSXML4 },
|
{ &CLSID_MXXMLWriter40, MSXML4 },
|
||||||
{ &CLSID_MXXMLWriter60, MSXML6 }
|
{ &CLSID_MXXMLWriter60, MSXML6 },
|
||||||
|
|
||||||
|
{ &CLSID_SAXXMLReader, MSXML_DEFAULT },
|
||||||
|
{ &CLSID_SAXXMLReader30, MSXML3 },
|
||||||
|
{ &CLSID_SAXXMLReader40, MSXML4 },
|
||||||
|
{ &CLSID_SAXXMLReader60, MSXML6 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static MSXML_VERSION get_msxml_version(const GUID *clsid)
|
static MSXML_VERSION get_msxml_version(const GUID *clsid)
|
||||||
|
@ -267,7 +272,6 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClassFactory xmldoccf = { { &ClassFactoryVtbl }, XMLDocument_create };
|
static ClassFactory xmldoccf = { { &ClassFactoryVtbl }, XMLDocument_create };
|
||||||
static ClassFactory saxreadcf = { { &ClassFactoryVtbl }, SAXXMLReader_create };
|
|
||||||
static ClassFactory httpreqcf = { { &ClassFactoryVtbl }, XMLHTTPRequest_create };
|
static ClassFactory httpreqcf = { { &ClassFactoryVtbl }, XMLHTTPRequest_create };
|
||||||
static ClassFactory xsltemplatecf = { { &ClassFactoryVtbl }, XSLTemplate_create };
|
static ClassFactory xsltemplatecf = { { &ClassFactoryVtbl }, XSLTemplate_create };
|
||||||
static ClassFactory mxnsmanagercf = { {&ClassFactoryVtbl }, MXNamespaceManager_create };
|
static ClassFactory mxnsmanagercf = { {&ClassFactoryVtbl }, MXNamespaceManager_create };
|
||||||
|
@ -317,7 +321,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
|
||||||
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ) ||
|
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ) ||
|
||||||
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader60 ))
|
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader60 ))
|
||||||
{
|
{
|
||||||
cf = &saxreadcf.IClassFactory_iface;
|
return DOMClassFactory_Create(rclsid, riid, ppv, SAXXMLReader_create);
|
||||||
}
|
}
|
||||||
else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest ) ||
|
else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest ) ||
|
||||||
IsEqualCLSID( rclsid, &CLSID_XMLHTTP) ||
|
IsEqualCLSID( rclsid, &CLSID_XMLHTTP) ||
|
||||||
|
|
|
@ -433,7 +433,7 @@ extern IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, B
|
||||||
extern HRESULT DOMDocument_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
|
extern HRESULT DOMDocument_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT SchemaCache_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
|
extern HRESULT SchemaCache_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT XMLDocument_create(IUnknown*, void**) DECLSPEC_HIDDEN;
|
extern HRESULT XMLDocument_create(IUnknown*, void**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT SAXXMLReader_create(IUnknown*, void**) DECLSPEC_HIDDEN;
|
extern HRESULT SAXXMLReader_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT XMLHTTPRequest_create(IUnknown*, void **) DECLSPEC_HIDDEN;
|
extern HRESULT XMLHTTPRequest_create(IUnknown*, void **) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT XSLTemplate_create(IUnknown*, void**) DECLSPEC_HIDDEN;
|
extern HRESULT XSLTemplate_create(IUnknown*, void**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT MXWriter_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
|
extern HRESULT MXWriter_create(MSXML_VERSION, IUnknown*, void**) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -92,6 +92,7 @@ typedef struct _saxreader
|
||||||
BOOL isParsing;
|
BOOL isParsing;
|
||||||
struct bstrpool pool;
|
struct bstrpool pool;
|
||||||
enum ReaderFeatures features;
|
enum ReaderFeatures features;
|
||||||
|
MSXML_VERSION version;
|
||||||
} saxreader;
|
} saxreader;
|
||||||
|
|
||||||
typedef struct _saxlocator
|
typedef struct _saxlocator
|
||||||
|
@ -1155,6 +1156,13 @@ static void libxmlStartDocument(void *ctx)
|
||||||
saxlocator *This = ctx;
|
saxlocator *This = ctx;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
if(This->saxreader->version >= MSXML6) {
|
||||||
|
xmlChar *end = (xmlChar*)This->pParserCtxt->input->cur;
|
||||||
|
while(end>This->pParserCtxt->input->base && *end!='>')
|
||||||
|
end--;
|
||||||
|
update_position(This, end);
|
||||||
|
}
|
||||||
|
|
||||||
if(has_content_handler(This))
|
if(has_content_handler(This))
|
||||||
{
|
{
|
||||||
if(This->vbInterface)
|
if(This->vbInterface)
|
||||||
|
@ -1174,8 +1182,15 @@ static void libxmlEndDocument(void *ctx)
|
||||||
saxlocator *This = ctx;
|
saxlocator *This = ctx;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
if(This->saxreader->version >= MSXML6) {
|
||||||
|
update_position(This, NULL);
|
||||||
|
if(This->column > 1)
|
||||||
|
This->line++;
|
||||||
|
This->column = 0;
|
||||||
|
} else {
|
||||||
This->column = 0;
|
This->column = 0;
|
||||||
This->line = 0;
|
This->line = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(This->ret != S_OK) return;
|
if(This->ret != S_OK) return;
|
||||||
|
|
||||||
|
@ -1208,7 +1223,9 @@ static void libxmlStartElementNS(
|
||||||
saxattributes *attr;
|
saxattributes *attr;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
if(*(This->pParserCtxt->input->cur) == '/')
|
if(This->saxreader->version >= MSXML6)
|
||||||
|
update_position(This, NULL);
|
||||||
|
else if(*(This->pParserCtxt->input->cur) == '/')
|
||||||
update_position(This, (xmlChar*)This->pParserCtxt->input->cur+2);
|
update_position(This, (xmlChar*)This->pParserCtxt->input->cur+2);
|
||||||
else
|
else
|
||||||
update_position(This, (xmlChar*)This->pParserCtxt->input->cur+1);
|
update_position(This, (xmlChar*)This->pParserCtxt->input->cur+1);
|
||||||
|
@ -1274,9 +1291,13 @@ static void libxmlEndElementNS(
|
||||||
int nsNr, index;
|
int nsNr, index;
|
||||||
|
|
||||||
end = (xmlChar*)This->pParserCtxt->input->cur;
|
end = (xmlChar*)This->pParserCtxt->input->cur;
|
||||||
if(*(end-1) != '>' || *(end-2) != '/')
|
if(This->saxreader->version >= MSXML6) {
|
||||||
|
while(end>This->pParserCtxt->input->base && *end!='>')
|
||||||
|
end--;
|
||||||
|
} else if(*(end-1) != '>' || *(end-2) != '/') {
|
||||||
while(end-2>=This->pParserCtxt->input->base
|
while(end-2>=This->pParserCtxt->input->base
|
||||||
&& *(end-2)!='<' && *(end-1)!='/') end--;
|
&& *(end-2)!='<' && *(end-1)!='/') end--;
|
||||||
|
}
|
||||||
|
|
||||||
update_position(This, end);
|
update_position(This, end);
|
||||||
|
|
||||||
|
@ -1362,6 +1383,18 @@ static void libxmlCharacters(
|
||||||
|
|
||||||
if(!lastEvent) *end = '\n';
|
if(!lastEvent) *end = '\n';
|
||||||
|
|
||||||
|
if(This->saxreader->version >= MSXML6) {
|
||||||
|
update_position(This, end);
|
||||||
|
if(*end == '\n') {
|
||||||
|
This->line++;
|
||||||
|
This->column = 1;
|
||||||
|
} else
|
||||||
|
This->column++;
|
||||||
|
|
||||||
|
if(!lastEvent)
|
||||||
|
This->column = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Chars = pooled_bstr_from_xmlCharN(&This->saxreader->pool, cur, end-cur+1);
|
Chars = pooled_bstr_from_xmlCharN(&This->saxreader->pool, cur, end-cur+1);
|
||||||
if(This->vbInterface)
|
if(This->vbInterface)
|
||||||
hr = IVBSAXContentHandler_characters(
|
hr = IVBSAXContentHandler_characters(
|
||||||
|
@ -1905,7 +1938,7 @@ static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator, B
|
||||||
locator->publicId = NULL;
|
locator->publicId = NULL;
|
||||||
locator->systemId = NULL;
|
locator->systemId = NULL;
|
||||||
locator->lastCur = NULL;
|
locator->lastCur = NULL;
|
||||||
locator->line = 0;
|
locator->line = (reader->version>=MSXML6 ? 1 : 0);
|
||||||
locator->column = 0;
|
locator->column = 0;
|
||||||
locator->ret = S_OK;
|
locator->ret = S_OK;
|
||||||
locator->nsStackSize = 8;
|
locator->nsStackSize = 8;
|
||||||
|
@ -3046,7 +3079,7 @@ static const struct ISAXXMLReaderVtbl isaxreader_vtbl =
|
||||||
isaxxmlreader_parseURL
|
isaxxmlreader_parseURL
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
HRESULT SAXXMLReader_create(MSXML_VERSION version, IUnknown *pUnkOuter, LPVOID *ppObj)
|
||||||
{
|
{
|
||||||
saxreader *reader;
|
saxreader *reader;
|
||||||
|
|
||||||
|
@ -3072,6 +3105,7 @@ HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
||||||
reader->pool.index = 0;
|
reader->pool.index = 0;
|
||||||
reader->pool.len = 0;
|
reader->pool.len = 0;
|
||||||
reader->features = Namespaces;
|
reader->features = Namespaces;
|
||||||
|
reader->version = version;
|
||||||
|
|
||||||
memset(&reader->sax, 0, sizeof(xmlSAXHandler));
|
memset(&reader->sax, 0, sizeof(xmlSAXHandler));
|
||||||
reader->sax.initialized = XML_SAX2_MAGIC;
|
reader->sax.initialized = XML_SAX2_MAGIC;
|
||||||
|
@ -3095,7 +3129,7 @@ HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
HRESULT SAXXMLReader_create(MSXML_VERSION version, IUnknown *pUnkOuter, LPVOID *ppObj)
|
||||||
{
|
{
|
||||||
MESSAGE("This program tried to use a SAX XML Reader object, but\n"
|
MESSAGE("This program tried to use a SAX XML Reader object, but\n"
|
||||||
"libxml2 support was not present at compile time.\n");
|
"libxml2 support was not present at compile time.\n");
|
||||||
|
|
Loading…
Reference in New Issue