summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/toolbox.hxx2
-rw-r--r--starmath/source/mathmlexport.cxx8
-rw-r--r--starmath/source/mathmlimport.cxx4
-rw-r--r--starmath/source/mathtype.cxx8
-rw-r--r--starmath/source/node.cxx6
-rw-r--r--starmath/source/smdetect.cxx64
-rw-r--r--starmath/source/toolbox.cxx6
-rw-r--r--starmath/source/view.cxx2
8 files changed, 76 insertions, 24 deletions
diff --git a/starmath/inc/toolbox.hxx b/starmath/inc/toolbox.hxx
index 7b625e08a97e..ca6700ba4cc2 100644
--- a/starmath/inc/toolbox.hxx
+++ b/starmath/inc/toolbox.hxx
@@ -36,7 +36,7 @@ class SmToolBoxWindow : public SfxFloatingWindow
protected:
ToolBox aToolBoxCat;
- FixedLine aToolBoxCat_Delim; // to visualy seperate the catalog part
+ FixedLine aToolBoxCat_Delim; // to visualy separate the catalog part
ToolBox *pToolBoxCmd;
ToolBox *vToolBoxCategories[NUM_TBX_CATEGORIES];
ImageList *aImageLists [NUM_TBX_CATEGORIES + 1]; /* regular */
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index bcd26ce298cc..8f0026da63cd 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -443,7 +443,7 @@ uno::Reference< uno::XInterface > SAL_CALL SmXMLExport_createInstance(
{
// #110680#
// return (cppu::OWeakObject*)new SmXMLExport( EXPORT_ALL );
- // EXPORT_OASIS is required here allthough there is no differrence between
+ // EXPORT_OASIS is required here although there is no differrence between
// OOo and OASIS, because without the flag, a transformation to OOo would
// be chained in.
return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_ALL );
@@ -869,7 +869,7 @@ void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/)
sal_Unicode cTmp = ConvertMathToMathML( nArse[0] );
if (cTmp != 0)
nArse[0] = cTmp;
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
+ DBG_ASSERT(nArse[0] != 0xffff,"Non existent symbol");
nArse[1] = 0;
GetDocHandler()->characters(nArse);
}
@@ -1073,11 +1073,11 @@ void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel)
nArse[1] = 0;
nArse[0] = static_cast<
const SmMathSymbolNode* >(pLeft)->GetText().GetChar(0);
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
+ DBG_ASSERT(nArse[0] != 0xffff,"Non existent symbol");
AddAttribute(XML_NAMESPACE_MATH, XML_OPEN,nArse);
nArse[0] = static_cast<
const SmMathSymbolNode* >(pRight)->GetText().GetChar(0);
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
+ DBG_ASSERT(nArse[0] != 0xffff,"Non existent symbol");
AddAttribute(XML_NAMESPACE_MATH, XML_CLOSE,nArse);
pFences = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MFENCED,
sal_True,sal_True);
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index ed087375e6fc..fd2354b9665b 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -2437,7 +2437,7 @@ void SmXMLRowContext_Impl::EndElement()
//If the first or last element is an operator with stretchyness
//set then we must create a brace node here from those elements,
//removing the stretchness from the operators and applying it to
- //ourselves, and creating the appropiate dummy StarMath none bracket
+ //ourselves, and creating the appropriate dummy StarMath none bracket
//to balance the arrangement
if (((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
&& (aRelationArray[0]->GetType() == NMATH))
@@ -2551,7 +2551,7 @@ SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext(
break;
/*Note: The maligngroup should only be seen when the row
- * (or decendants) are in a table*/
+ * (or descendants) are in a table*/
case XML_TOK_MALIGNGROUP:
pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName,
xAttrList);
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 7f4f6e05d80f..fb86991854c1 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -723,7 +723,7 @@ int MathType::Parse(SotStorage *pStor)
#endif
int nRet = HandleRecords();
- //little crude hack to close ocassionally open expressions
+ //little crude hack to close occasionally open expressions
//a sophisticated system to determine what expressions are
//opened is required, but this is as much work as rewriting
//starmaths internals.
@@ -1827,7 +1827,7 @@ int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
//symbols that follow some of these
//records. Foo Data.
- /*In matrices and piles we cannot seperate equation
+ /*In matrices and piles we cannot separate equation
*lines with the newline keyword*/
if (nMatrixCols==0)
newline++;
@@ -2214,7 +2214,7 @@ int MathType::StartTemplate(sal_uInt16 nSelector,sal_uInt16 nVariation)
//theres just no way we can now handle any character
//attributes (from mathtypes perspective) centered
//over an expression but above template attribute
- //such as widevec and similiar constructs
+ //such as widevec and similar constructs
//we have to drop them
nPendingAttributes=0;
return nOldPending;
@@ -3357,7 +3357,7 @@ void MathType::HandleAttributes(SmNode *pNode,int nLevel)
//theres just no way we can now handle any character
//attributes (from mathtypes perspective) centered
//over an expression but above template attributes
- //such as widevec and similiar constructs
+ //such as widevec and similar constructs
//we have to drop them
nOldPending = StartTemplate(0x2f,0x01);
break;
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 86832dd18a8c..bff9321f2c38 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -1001,7 +1001,7 @@ void SmRootNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
pRootSym->Arrange(rDev, rFormat);
Point aPos = pRootSym->AlignTo(*pBody, RP_LEFT, RHA_CENTER, RVA_BASELINE);
- //! overrride calulated vertical position
+ //! overrride calculated vertical position
aPos.Y() = pRootSym->GetTop() + pBody->GetBottom() - pRootSym->GetBottom();
aPos.Y() -= nVerOffset;
pRootSym->MoveTo(aPos);
@@ -2578,7 +2578,7 @@ void SmMatrixNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
// norm distance from which the following two are calcutated
const int nNormDist = 3 * GetFont().GetSize().Height();
- // define horizontal and vertical minimal distances that seperate
+ // define horizontal and vertical minimal distances that separate
// the elements
long nHorDist = nNormDist * rFormat.GetDistance(DIS_MATRIXCOL) / 100L,
nVerDist = nNormDist * rFormat.GetDistance(DIS_MATRIXROW) / 100L;
@@ -2882,7 +2882,7 @@ bool lcl_IsFromGreekSymbolSet( const String &rTokenText )
{
bool bRes = false;
- // valid symbol name needs to have a '%' at pos 0 and at least an additonal char
+ // valid symbol name needs to have a '%' at pos 0 and at least an additional char
if (rTokenText.Len() > 2 && rTokenText.GetBuffer()[0] == (sal_Unicode)'%')
{
String aName( rTokenText.Copy(1) );
diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx
index 4b50fd66dfed..94d8d9ccd267 100644
--- a/starmath/source/smdetect.cxx
+++ b/starmath/source/smdetect.cxx
@@ -326,17 +326,69 @@ SmFilterDetect::~SmFilterDetect()
}
else
{
- const sal_uInt16 nSize = 5;
- sal_Char aBuffer[nSize+1];
- aBuffer[nSize] = 0;
+ // #124636# detection should not only check for xml, but at least also for
+ // the math start element and the MathML URL. Additionally take their order
+ // into account. Also allow the case where the start element has a namespace
+ // (e.g. <bla:math), but in that case ensure that it is in front of an evtl.
+ // xmlns:math namespace declaration and thus not part of that
+ const sal_uInt16 nReadSize(4095);
+ sal_Char aBuffer[nReadSize+1];
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
- sal_uLong nBytesRead = pStrm->Read( aBuffer, nSize );
- if (nBytesRead == nSize)
+ const sal_uLong nBytesRead(pStrm->Read( aBuffer, nReadSize ));
+
+ if(nBytesRead > (5 + 1 + 34 + 5)) // xml + '>' + URL + '(<|:)math'
{
- if (0 == strncmp( "<?xml",aBuffer,nSize))
+ // end string with null
+ aBuffer[nBytesRead + 1] = 0;
+
+ // is it a xml file?
+ const sal_Char* pXML = strstr(aBuffer, "<?xml");
+ bool isMathFile(false);
+
+ if(pXML)
+ {
+ // does it have the MathML URL?
+ const sal_Char* pURL = strstr(aBuffer, "http://www.w3.org/1998/Math/MathML");
+
+ // URL has to be after XML start
+ if(pURL && pURL > pXML)
+ {
+ // look if we have a direct math start element
+ sal_Char* pMathStart = strstr(aBuffer, "<math");
+
+ if(!pMathStart)
+ {
+ // if not, look if we have a math start element in another namespace
+ pMathStart = strstr(aBuffer, ":math");
+
+ if(pMathStart)
+ {
+ // if found, this has to be in front of the evtl. also existing namespace
+ // declaration also containing :math to be the start element
+ sal_Char* pNamespaceMath = strstr(aBuffer, "xmlns:math");
+
+ if(pNamespaceMath && pMathStart > pNamespaceMath)
+ {
+ // invalid :math found (probably part of the namespace declaration)
+ // -> this cannot be the math start element
+ pMathStart = 0;
+ }
+ }
+ }
+
+ // MathStart has to be before the URL
+ if(pMathStart && pMathStart < pURL)
+ {
+ isMathFile = true;
+ }
+ }
+ }
+
+ if(isMathFile)
{
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 );
}
diff --git a/starmath/source/toolbox.cxx b/starmath/source/toolbox.cxx
index 44fc2893ad91..40ec9e63f859 100644
--- a/starmath/source/toolbox.cxx
+++ b/starmath/source/toolbox.cxx
@@ -60,7 +60,7 @@ static sal_uInt16 GetImageListRID( sal_uInt16 nCategoryRID, sal_Bool bHighContr
case RID_FORMAT_CAT : nRes = RID_IL_FORMAT; break;
case RID_MISC_CAT : nRes = RID_IL_MISC; break;
default :
- DBG_ERROR( "unkown category" );
+ DBG_ERROR( "unknown category" );
}
if (nRes != 0xFFFF && bHighContrast)
++nRes; //! the resource ID for the high contrast image list is just +1 compared to the regular ones
@@ -116,7 +116,7 @@ static sal_uInt16 GetCategoryRID( sal_uInt16 nResId )
if (nResId != RID_IL_CATALOG && nResId != RID_ILH_CATALOG)
{
#if OSL_DEBUG_LEVEL > 1
- DBG_ERROR( "unkown category" );
+ DBG_ERROR( "unknown category" );
#endif
}
}
@@ -341,7 +341,7 @@ void SmToolBoxWindow::SetCategory(sal_uInt16 nCategoryRID)
pToolBoxCmd->Hide();
sal_Int16 nIdx = GetToolBoxCategoriesIndex( nCategoryRID );
- DBG_ASSERT( nIdx >= 0, "unkown category" );
+ DBG_ASSERT( nIdx >= 0, "unknown category" );
if (nIdx >= 0)
pToolBoxCmd = vToolBoxCategories[nIdx];
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 8caf0db57fd7..acc528abb63a 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -640,7 +640,7 @@ void SmCmdBoxWindow::StateChanged( StateChangedType nStateChange )
// aEdit.GrabFocus();
// grab focus as above does not work...
- // Thus we implement a timer based solution to get the inital
+ // Thus we implement a timer based solution to get the initial
// focus in the Edit window.
aInitialFocusTimer.Start();
}