Kaydet (Commit) 05530423 authored tarafından Marcos Paulo de Souza's avatar Marcos Paulo de Souza Kaydeden (comit) Björn Michaelsen

Solve one more issue of fdo#59642

The old MathML XML style could begin just with <math. So this commit fixes that.

This commits also fixes some documents that have the BOM marker at begin of file.

Thanks a lot to Bjoern, Caolan and Eike!

Change-Id: Ia2c3b51556e615c1e68e5e8aab4f883124c6adca
Reviewed-on: https://gerrit.libreoffice.org/4742Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst 40026a2f
...@@ -309,30 +309,36 @@ OUString SAL_CALL SmFilterDetect::detect( Sequence< PropertyValue >& lDescriptor ...@@ -309,30 +309,36 @@ OUString SAL_CALL SmFilterDetect::detect( Sequence< PropertyValue >& lDescriptor
} }
else else
{ {
const sal_uInt16 nSize = 5; // 200 should be enough for the XML
// version, encoding and !DOCTYPE
// stuff I hope?
const sal_uInt16 nSize = 200;
sal_Char aBuffer[nSize+1]; sal_Char aBuffer[nSize+1];
aBuffer[nSize] = 0; aBuffer[nSize] = 0;
pStrm->Seek( STREAM_SEEK_TO_BEGIN ); pStrm->Seek( STREAM_SEEK_TO_BEGIN );
pStrm->StartReadingUnicodeText(RTL_TEXTENCODING_DONTKNOW); // avoid BOM marker
sal_uLong nBytesRead = pStrm->Read( aBuffer, nSize ); sal_uLong nBytesRead = pStrm->Read( aBuffer, nSize );
if (nBytesRead == nSize) if (nBytesRead >= 6)
{ {
if (0 == strncmp( "<?xml",aBuffer,nSize)) bool bIsMathType = false;
if (0 == strncmp( "<?xml", aBuffer, 5))
{ {
// 200 should be enough for the XML if (strstr( aBuffer, "<math>" ) ||
// version, encoding and !DOCTYPE strstr( aBuffer, "<math " ) ||
// stuff I hope? strstr( aBuffer, "<math:math " ))
sal_Char aBuffer2[200]; bIsMathType = true;
nBytesRead = pStrm->Read( aBuffer2, sizeof(aBuffer2) - 1); }
aBuffer2[nBytesRead] = 0; // this is the old <math tag to MathML in the beginning of the XML file
if (strstr( aBuffer2, "<math>" ) || else if (0 == strncmp( "<math ", aBuffer, 6) ||
strstr( aBuffer2, "<math " ) || 0 == strncmp( "<math> ", aBuffer, 7) ||
strstr( aBuffer2, "<math:math " )) 0 == strncmp( "<math:math> ", aBuffer, 12))
{ bIsMathType = true;
static const sal_Char sFltrNm_2[] = MATHML_XML;
static const sal_Char sTypeNm_2[] = "math_MathML_XML_Math"; if (bIsMathType){
aFilterName.AssignAscii( sFltrNm_2 ); static const sal_Char sFltrNm_2[] = MATHML_XML;
aTypeName.AssignAscii( sTypeNm_2 ); static const sal_Char sTypeNm_2[] = "math_MathML_XML_Math";
} aFilterName.AssignAscii( sFltrNm_2 );
aTypeName.AssignAscii( sTypeNm_2 );
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment