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,25 +309,32 @@ OUString SAL_CALL SmFilterDetect::detect( Sequence< PropertyValue >& lDescriptor
}
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];
aBuffer[nSize] = 0;
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
pStrm->StartReadingUnicodeText(RTL_TEXTENCODING_DONTKNOW); // avoid BOM marker
sal_uLong nBytesRead = pStrm->Read( aBuffer, nSize );
if (nBytesRead == nSize)
if (nBytesRead >= 6)
{
if (0 == strncmp( "<?xml",aBuffer,nSize))
{
// 200 should be enough for the XML
// version, encoding and !DOCTYPE
// stuff I hope?
sal_Char aBuffer2[200];
nBytesRead = pStrm->Read( aBuffer2, sizeof(aBuffer2) - 1);
aBuffer2[nBytesRead] = 0;
if (strstr( aBuffer2, "<math>" ) ||
strstr( aBuffer2, "<math " ) ||
strstr( aBuffer2, "<math:math " ))
bool bIsMathType = false;
if (0 == strncmp( "<?xml", aBuffer, 5))
{
if (strstr( aBuffer, "<math>" ) ||
strstr( aBuffer, "<math " ) ||
strstr( aBuffer, "<math:math " ))
bIsMathType = true;
}
// this is the old <math tag to MathML in the beginning of the XML file
else if (0 == strncmp( "<math ", aBuffer, 6) ||
0 == strncmp( "<math> ", aBuffer, 7) ||
0 == strncmp( "<math:math> ", aBuffer, 12))
bIsMathType = true;
if (bIsMathType){
static const sal_Char sFltrNm_2[] = MATHML_XML;
static const sal_Char sTypeNm_2[] = "math_MathML_XML_Math";
aFilterName.AssignAscii( sFltrNm_2 );
......@@ -335,7 +342,6 @@ OUString SAL_CALL SmFilterDetect::detect( Sequence< PropertyValue >& lDescriptor
}
}
}
}
if ( aTypeName.Len() )
{
......
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