summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2013-07-05 12:03:01 -0300
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2013-07-05 21:56:41 +0000
commit05530423d3cff1391769192a62ae470500978ee6 (patch)
tree7a64c33e9d60823034384f1c8b3c978a0051382f /starmath
parent40026a2fcd88851e18f701a10c3cddc87b549476 (diff)
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/4742 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/smdetect.cxx42
1 files changed, 24 insertions, 18 deletions
diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx
index d82fa0337f94..a0fc6ecb8c43 100644
--- a/starmath/source/smdetect.cxx
+++ b/starmath/source/smdetect.cxx
@@ -309,30 +309,36 @@ 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))
+ bool bIsMathType = false;
+ if (0 == strncmp( "<?xml", aBuffer, 5))
{
- // 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 " ))
- {
- static const sal_Char sFltrNm_2[] = MATHML_XML;
- static const sal_Char sTypeNm_2[] = "math_MathML_XML_Math";
- aFilterName.AssignAscii( sFltrNm_2 );
- aTypeName.AssignAscii( sTypeNm_2 );
- }
+ 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 );
+ aTypeName.AssignAscii( sTypeNm_2 );
}
}
}