summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <cmc@openoffice.org>2001-01-18 13:57:19 +0000
committerCaolán McNamara <cmc@openoffice.org>2001-01-18 13:57:19 +0000
commita0c8015b88b16a4192000bd841eeff594dae9c65 (patch)
tree4ec7cba73614d92966862b640760001e255f77d4
parentada4b04c6497c1166563cfa0dbc424d419821ce7 (diff)
#81141# MathML->StarMath editable text display
-rw-r--r--starmath/inc/node.hxx17
-rw-r--r--starmath/inc/symbol.hxx6
-rw-r--r--starmath/source/document.cxx14
-rw-r--r--starmath/source/mathml.cxx686
-rw-r--r--starmath/source/mathml.hxx12
-rw-r--r--starmath/source/mathtype.cxx97
-rw-r--r--starmath/source/mathtype.hxx9
-rw-r--r--starmath/source/node.cxx263
8 files changed, 961 insertions, 143 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index 93b6152fea36..6eebf5fb1860 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: node.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: cmc $ $Date: 2000-11-21 12:31:18 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:55:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -180,6 +180,7 @@ public:
virtual void Move(const Point &rPosition);
void MoveTo(const Point &rPosition) { Move(rPosition - GetTopLeft()); }
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ virtual void CreateTextFromNode(String &rText);
virtual void Draw(OutputDevice &rDev, const Point &rPosition) const;
@@ -391,6 +392,8 @@ public:
virtual void Prepare(const SmFormat &rFormat);
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ virtual void CreateTextFromNode(String &rText);
+
virtual void Draw(OutputDevice &rDev, const Point &rPosition) const;
};
@@ -448,6 +451,7 @@ public:
virtual void Prepare(const SmFormat &rFormat);
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
};
@@ -532,6 +536,7 @@ public:
{}
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
};
@@ -569,6 +574,7 @@ public:
}
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
};
@@ -605,6 +611,7 @@ public:
virtual SmNode * GetLeftMost() { return this; }
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
};
@@ -678,6 +685,8 @@ public:
SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode(1 + eSubSup); };
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
+
};
@@ -694,6 +703,7 @@ public:
}
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
};
@@ -808,9 +818,11 @@ public:
void SetSizeParameter(const Fraction &rValue, USHORT nType);
const Fraction & GetSizeParameter() const {return aFontSize;}
+ const USHORT& GetSizeType() const {return nSizeType;}
virtual void Prepare(const SmFormat &rFormat);
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
};
@@ -836,6 +848,7 @@ public:
virtual SmNode * GetLeftMost() { return this; }
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ void CreateTextFromNode(String &rText);
};
diff --git a/starmath/inc/symbol.hxx b/starmath/inc/symbol.hxx
index b10fd7b67047..d05589acb016 100644
--- a/starmath/inc/symbol.hxx
+++ b/starmath/inc/symbol.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: symbol.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 16:57:25 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:55:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -193,7 +193,7 @@ public:
SmSymSetManager& operator = (const SmSymSetManager& rSymbolSetManager);
- USHORT GetCount() const { return NoSymbolSets; }
+ UINT32 GetCount() const { return NoSymbolSets; }
SmSymSet *GetSymbolSet(USHORT SymbolSetNo) const { return SymbolSets.Get(SymbolSetNo);}
USHORT AddSymbolSet(SmSymSet* pSymbolSet);
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index ac4629ef6b17..13beb4ced726 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: document.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: cmc $ $Date: 2000-11-15 10:47:20 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:57:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -639,8 +639,14 @@ BOOL SmDocShell::ConvertFrom(SfxMedium &rMedium)
pTree = aEquation.Import(rMedium);
if (pTree)
{
- //ToDo
- //aText = pTree->CreateTextFromTree();
+ pTree->CreateTextFromNode(aText);
+ aText.EraseTrailingChars();
+ while((aText.GetChar(0) == '{') &&
+ (aText.GetChar(aText.Len()-1) == '}'))
+ {
+ aText.Erase(0,1);
+ aText.Erase(aText.Len()-1,1);
+ }
bSuccess = TRUE;
}
}
diff --git a/starmath/source/mathml.cxx b/starmath/source/mathml.cxx
index d7b0505b16c3..3f9066111408 100644
--- a/starmath/source/mathml.cxx
+++ b/starmath/source/mathml.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mathml.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: cmc $ $Date: 2001-01-11 13:44:16 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:57:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,7 +78,9 @@ one go*/
#ifndef _TOOLS_DEBUG_H
#include <tools/debug.hxx>
#endif
-
+#ifndef _TOOLS_SOLMATH_H
+#include <tools/solmath.hxx>
+#endif
#ifndef _SFXDOCFILE_HXX
#include <sfx2/docfile.hxx>
#endif
@@ -86,10 +88,13 @@ one go*/
#ifndef MATHML_HXX
#include <mathml.hxx>
#endif
-
#ifndef DOCUMENT_HXX
#include <document.hxx>
#endif
+#ifndef UTILITY_HXX
+#include <utility.hxx>
+#endif
+
#ifndef _XMLOFF_XMLNMSPE_HXX
#include <xmloff/xmlnmspe.hxx>
@@ -122,12 +127,15 @@ one go*/
using namespace com::sun::star;
using namespace rtl;
-extern sal_Unicode aMathTypeTable[256];
+#ifndef MATHTYPE_HXX
+#include "mathtype.hxx"
+#endif
+
sal_Unicode UnicodeToStarMath(sal_uInt16 rChar)
{
sal_Unicode cMathChar = rChar;
- for (int i=sizeof(aMathTypeTable)-1;i>=0;i--)
- if (rChar == aMathTypeTable[i])
+ for (int i=sizeof(MathType::aMathTypeTable)-1;i>=0;i--)
+ if (rChar == MathType::aMathTypeTable[i])
{
cMathChar = i | 0xf000;
break;
@@ -296,9 +304,12 @@ public:
virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+ SvXMLImportContext *StrictCreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList);
void EndElement();
protected:
- USHORT nElementCount;
+ ULONG nElementCount;
};
class SmXMLFracContext_Impl : public SmXMLRowContext_Impl
@@ -328,32 +339,200 @@ public:
void EndElement();
};
+struct SmXMLContext_Helper
+{
+ SmXMLContext_Helper(SmXMLImportContext &rImport) : rContext(rImport),
+ nIsBold(-1), nIsItalic(-1),nFontSize(0.0) {}
+ void RetrieveAttrs(const uno::Reference< xml::sax::XAttributeList > &
+ xAttrList );
+ void ApplyAttrs();
+
+ sal_Int8 nIsBold;
+ sal_Int8 nIsItalic;
+ double nFontSize;
+ sal_Bool bFontNodeNeeded;
+ OUString sFontFamily;
+ OUString sColor;
+
+ SmXMLImportContext rContext;
+};
+
+void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+ sal_Int8 nOldIsBold=nIsBold;
+ sal_Int8 nOldIsItalic=nIsItalic;
+ double nOldFontSize=nFontSize;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ OUString sOldFontFamily = sFontFamily;
+ for (sal_Int16 i=0;i<nAttrCount;i++)
+ {
+ OUString sAttrName = xAttrList->getNameByIndex(i);
+ OUString aLocalName;
+ sal_uInt16 nPrefix = rContext.GetSmImport().GetNamespaceMap().
+ GetKeyByAttrName(sAttrName,&aLocalName);
+ OUString sValue = xAttrList->getValueByIndex(i);
+ const SvXMLTokenMap &rAttrTokenMap =
+ rContext.GetSmImport().GetPresLayoutAttrTokenMap();
+ switch(rAttrTokenMap.Get(nPrefix,aLocalName))
+ {
+ case XML_TOK_FONTWEIGHT:
+ nIsBold = sValue.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(
+ sXML_bold)));
+ break;
+ case XML_TOK_FONTSTYLE:
+ nIsItalic = sValue.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(
+ sXML_italic)));
+ break;
+ case XML_TOK_FONTSIZE:
+ SvXMLUnitConverter::convertNumber(nFontSize,sValue);
+ rContext.GetSmImport().GetMM100UnitConverter().
+ setXMLMeasureUnit(MAP_POINT);
+ if (-1 == sValue.indexOf(OUString(
+ RTL_CONSTASCII_USTRINGPARAM(sXML_unit_pt))))
+ if (-1 == sValue.indexOf('%'))
+ nFontSize=0.0;
+ else
+ {
+ rContext.GetSmImport().GetMM100UnitConverter().
+ setXMLMeasureUnit(MAP_RELATIVE);
+ }
+ break;
+ case XML_TOK_FONTFAMILY:
+ sFontFamily = sValue;
+ break;
+ case XML_TOK_COLOR:
+ sColor = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
+ (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
+ || sColor.getLength())
+ bFontNodeNeeded=sal_True;
+ else
+ bFontNodeNeeded=sal_False;
+}
+
+void SmXMLContext_Helper::ApplyAttrs()
+{
+ SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack();
+
+ if (bFontNodeNeeded)
+ {
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+
+ if (nIsBold != -1)
+ {
+ if (nIsBold)
+ aToken.eType = TBOLD;
+ else
+ aToken.eType = TNBOLD;
+ SmStructureNode *pFontNode = static_cast<SmStructureNode *>
+ (new SmFontNode(aToken));
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (nIsItalic != -1)
+ {
+ if (nIsItalic)
+ aToken.eType = TITALIC;
+ else
+ aToken.eType = TNITALIC;
+ SmStructureNode *pFontNode = static_cast<SmStructureNode *>
+ (new SmFontNode(aToken));
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (nFontSize != 0.0)
+ {
+ aToken.eType = TSIZE;
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+
+ if (MAP_RELATIVE == rContext.GetSmImport().GetMM100UnitConverter().
+ getXMLMeasureUnit())
+ {
+ if (nFontSize < 100.00)
+ pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
+ FNTSIZ_DIVIDE);
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
+ FNTSIZ_MULTIPLY);
+ }
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
+
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (sFontFamily.getLength())
+ {
+ if (sFontFamily.equalsIgnoreCase(OUString(
+ RTL_CONSTASCII_USTRINGPARAM(sXML_fixed))))
+ aToken.eType = TFIXED;
+ else if (sFontFamily.equalsIgnoreCase(OUString(
+ RTL_CONSTASCII_USTRINGPARAM("sans"))))
+ aToken.eType = TSANS;
+ else if (sFontFamily.equalsIgnoreCase(OUString(
+ RTL_CONSTASCII_USTRINGPARAM("serif"))))
+ aToken.eType = TSERIF;
+ else //Just give up, we need to extend our font mechanism to be
+ //more general
+ return;
+
+ aToken.aText = sFontFamily;
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (sColor.getLength())
+ {
+ //Again we can only handle a small set of colours in
+ //StarMath for now.
+ const SvXMLTokenMap& rTokenMap =
+ rContext.GetSmImport().GetColorTokenMap();
+ aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
+ XML_NAMESPACE_MATH, sColor));
+ if (aToken.eType != -1)
+ {
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ }
+
+ }
+}
+
class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl
{
public:
/*Right now the style tag is completely ignored*/
SmXMLStyleContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName),bIsBold(sal_False),
- bIsItalic(sal_False),nFontSize(0)
- {}
+ const OUString& rLName) : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
+ aStyleHelper(*this) {}
void EndElement();
void StartElement(const uno::Reference< xml::sax::XAttributeList > &
xAttrList );
protected:
- sal_Bool bIsBold;
- sal_Bool bIsItalic;
- sal_Int32 nFontSize;
- sal_Bool bFontNodeNeeded;
- OUString sFontFamily;
+ SmXMLContext_Helper aStyleHelper;
};
void SmXMLStyleContext_Impl::StartElement(const uno::Reference<
xml::sax::XAttributeList > & xAttrList )
{
- sal_Bool bOldIsBold=bIsBold;
- sal_Bool bOldIsItalic=bIsItalic;
- sal_Int32 nOldFontSize=nFontSize;
+#if 1
+ aStyleHelper.RetrieveAttrs(xAttrList);
+#else
+ sal_Int8 nOldIsBold=nIsBold;
+ sal_Int8 nOldIsItalic=nIsItalic;
+ double nOldFontSize=nFontSize;
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
OUString sOldFontFamily = sFontFamily;
for (sal_Int16 i=0;i<nAttrCount;i++)
@@ -368,32 +547,45 @@ void SmXMLStyleContext_Impl::StartElement(const uno::Reference<
switch(rAttrTokenMap.Get(nPrefix,aLocalName))
{
case XML_TOK_FONTWEIGHT:
- bIsBold = sValue.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(
+ nIsBold = sValue.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(
sXML_bold)));
break;
case XML_TOK_FONTSTYLE:
- bIsItalic = sValue.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(
+ nIsItalic = sValue.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(
sXML_italic)));
break;
case XML_TOK_FONTSIZE:
+ SvXMLUnitConverter::convertNumber(nFontSize,sValue);
GetSmImport().GetMM100UnitConverter().
setXMLMeasureUnit(MAP_POINT);
- GetSmImport().GetMM100UnitConverter().convertMeasure(nFontSize,
- sValue,MAP_POINT);
+ if (-1 == sValue.indexOf(OUString(
+ RTL_CONSTASCII_USTRINGPARAM(sXML_unit_pt))))
+ if (-1 == sValue.indexOf('%'))
+ nFontSize=0.0;
+ else
+ {
+ GetSmImport().GetMM100UnitConverter().
+ setXMLMeasureUnit(MAP_RELATIVE);
+ }
break;
case XML_TOK_FONTFAMILY:
sFontFamily = sValue;
break;
+ case XML_TOK_COLOR:
+ sColor = sValue;
+ break;
default:
break;
}
}
- if ((bOldIsBold!=bIsBold) || (bOldIsItalic!=bIsItalic) ||
- (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily))
+ if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
+ (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
+ || sColor.getLength())
bFontNodeNeeded=sal_True;
else
bFontNodeNeeded=sal_False;
+#endif
}
@@ -407,7 +599,9 @@ void SmXMLStyleContext_Impl::EndElement()
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
if (rNodeStack.Count() - nElementCount > 1)
SmXMLRowContext_Impl::EndElement();
-
+#if 1
+ aStyleHelper.ApplyAttrs();
+#else
if (bFontNodeNeeded)
{
SmToken aToken;
@@ -415,35 +609,53 @@ void SmXMLStyleContext_Impl::EndElement()
aToken.nGroup = 0;
aToken.nLevel = 5;
- if (bIsBold)
+ if (nIsBold != -1)
{
- aToken.eType = TBOLD;
+ if (nIsBold)
+ aToken.eType = TBOLD;
+ else
+ aToken.eType = TNBOLD;
SmStructureNode *pFontNode = static_cast<SmStructureNode *>
(new SmFontNode(aToken));
pFontNode->SetSubNodes(0,rNodeStack.Pop());
rNodeStack.Push(pFontNode);
}
- if (bIsItalic)
+ if (nIsItalic != -1)
{
- aToken.eType = TITALIC;
+ if (nIsItalic)
+ aToken.eType = TITALIC;
+ else
+ aToken.eType = TNITALIC;
SmStructureNode *pFontNode = static_cast<SmStructureNode *>
(new SmFontNode(aToken));
pFontNode->SetSubNodes(0,rNodeStack.Pop());
rNodeStack.Push(pFontNode);
}
- if (nFontSize)
+ if (nFontSize != 0.0)
{
aToken.eType = TSIZE;
- Fraction aValue = nFontSize;
SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSizeParameter(aValue,FNTSIZ_ABSOLUT);
+
+ if (MAP_RELATIVE == GetSmImport().GetMM100UnitConverter().
+ getXMLMeasureUnit())
+ {
+ if (nFontSize < 100.00)
+ pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
+ FNTSIZ_DIVIDE);
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
+ FNTSIZ_MULTIPLY);
+ }
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
+
pFontNode->SetSubNodes(0,rNodeStack.Pop());
rNodeStack.Push(pFontNode);
}
if (sFontFamily.getLength())
{
if (sFontFamily.equalsIgnoreCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("fixed"))))
+ RTL_CONSTASCII_USTRINGPARAM(sXML_fixed))))
aToken.eType = TFIXED;
else if (sFontFamily.equalsIgnoreCase(OUString(
RTL_CONSTASCII_USTRINGPARAM("sans"))))
@@ -460,10 +672,26 @@ void SmXMLStyleContext_Impl::EndElement()
pFontNode->SetSubNodes(0,rNodeStack.Pop());
rNodeStack.Push(pFontNode);
}
+ if (sColor.getLength())
+ {
+ //Again we can only handle a small set of colours in
+ //StarMath for now.
+ const SvXMLTokenMap& rTokenMap =
+ GetSmImport().GetColorTokenMap();
+ aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
+ XML_NAMESPACE_MATH, sColor));
+ if (aToken.eType != -1)
+ {
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ }
+
}
+#endif
}
-
class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl
{
public:
@@ -590,7 +818,7 @@ void SmXMLFencedContext_Impl::EndElement()
aToken.aText = ',';
aToken.eType = TIDENT;
- USHORT i=rNodeStack.Count()-nElementCount;
+ ULONG i=rNodeStack.Count()-nElementCount;
if (rNodeStack.Count()-nElementCount > 1)
i+=rNodeStack.Count()-1-nElementCount;
aRelationArray.SetSize(i);
@@ -720,8 +948,12 @@ class SmXMLIdentifierContext_Impl : public SmXMLImportContext
public:
SmXMLIdentifierContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName) {}
- virtual void TCharacters(const ::rtl::OUString &rChars);
+ : SmXMLImportContext(rImport,nPrefix,rLName),aStyleHelper(*this) {}
+ void TCharacters(const ::rtl::OUString &rChars);
+ void StartElement(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList ) {aStyleHelper.RetrieveAttrs(xAttrList);};
+protected:
+ SmXMLContext_Helper aStyleHelper;
};
void SmXMLIdentifierContext_Impl::TCharacters(const ::rtl::OUString &rChars)
@@ -732,7 +964,36 @@ void SmXMLIdentifierContext_Impl::TCharacters(const ::rtl::OUString &rChars)
aToken.aText = rChars;
aToken.nLevel = 5;
aToken.eType = TIDENT;
- GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_VARIABLE));
+ SmTextNode *pNode = 0;
+
+ //we will handle identifier italic/normal here instead of with a standalone
+ //font node
+ if (((aStyleHelper.nIsItalic == -1) && (rChars.getLength() > 1))
+ || ((aStyleHelper.nIsItalic == 0) && (rChars.getLength() == 1)))
+ {
+ pNode = new SmTextNode(aToken,FNT_FUNCTION);
+ pNode->GetFont().SetItalic(ITALIC_NONE);
+ aStyleHelper.nIsItalic = -1;
+ }
+ else
+ pNode = new SmTextNode(aToken,FNT_VARIABLE);
+ if (aStyleHelper.bFontNodeNeeded && aStyleHelper.nIsItalic != -1)
+ {
+ if (aStyleHelper.nIsItalic)
+ pNode->GetFont().SetItalic(ITALIC_NORMAL);
+ else
+ pNode->GetFont().SetItalic(ITALIC_NONE);
+ }
+
+ if ((-1!=aStyleHelper.nIsBold) || (0.0!=aStyleHelper.nFontSize) ||
+ (aStyleHelper.sFontFamily.getLength()) ||
+ aStyleHelper.sColor.getLength())
+ aStyleHelper.bFontNodeNeeded=sal_True;
+ else
+ aStyleHelper.bFontNodeNeeded=sal_False;
+ if (aStyleHelper.bFontNodeNeeded)
+ aStyleHelper.ApplyAttrs();
+ GetSmImport().GetNodeStack().Push(pNode);
}
class SmXMLOperatorContext_Impl : public SmXMLImportContext
@@ -807,8 +1068,8 @@ public:
SmXMLSpaceContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
const OUString& rLName)
: SmXMLImportContext(rImport,nPrefix,rLName) {}
- void SmXMLSpaceContext_Impl::StartElement(
- const uno::Reference<xml::sax::XAttributeList >& xAttrList );
+ void StartElement(const uno::Reference<
+ xml::sax::XAttributeList >& xAttrList );
};
void SmXMLSpaceContext_Impl::StartElement(
@@ -852,7 +1113,7 @@ void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType,SmSubSup aSubSup)
// initialize subnodes array
SmNodeArray aSubNodes;
aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (int i = 1; i < aSubNodes.GetSize(); i++)
+ for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
aSubNodes.Put(i, NULL);
aSubNodes.Put(aSubSup+1,rNodeStack.Pop());
@@ -901,7 +1162,7 @@ void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
// initialize subnodes array
SmNodeArray aSubNodes;
aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (int i = 1; i < aSubNodes.GetSize(); i++)
+ for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
aSubNodes.Put(i, NULL);
aSubNodes.Put(aSup+1,rNodeStack.Pop());
@@ -1176,6 +1437,7 @@ static __FAR_DATA SvXMLTokenMapEntry aPresLayoutAttrTokenMap[] =
{ XML_NAMESPACE_MATH, sXML_fontstyle, XML_TOK_FONTSTYLE },
{ XML_NAMESPACE_MATH, sXML_fontsize, XML_TOK_FONTSIZE },
{ XML_NAMESPACE_MATH, sXML_fontfamily, XML_TOK_FONTFAMILY },
+ { XML_NAMESPACE_MATH, sXML_color, XML_TOK_COLOR },
XML_TOKEN_MAP_END
};
@@ -1218,6 +1480,19 @@ static __FAR_DATA SvXMLTokenMapEntry aPresTableElemTokenMap[] =
XML_TOKEN_MAP_END
};
+static __FAR_DATA SvXMLTokenMapEntry aColorTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, sXML_black, TBLACK},
+ { XML_NAMESPACE_MATH, sXML_white, TWHITE},
+ { XML_NAMESPACE_MATH, sXML_red, TRED},
+ { XML_NAMESPACE_MATH, sXML_green, TGREEN},
+ { XML_NAMESPACE_MATH, sXML_blue, TBLUE},
+ { XML_NAMESPACE_MATH, sXML_aqua, TCYAN},
+ { XML_NAMESPACE_MATH, sXML_fuchsia, TMAGENTA},
+ { XML_NAMESPACE_MATH, sXML_yellow, TYELLOW},
+ XML_TOKEN_MAP_END
+};
+
const SvXMLTokenMap& SmXMLImport::GetMathElemTokenMap()
{
@@ -1274,11 +1549,17 @@ const SvXMLTokenMap& SmXMLImport::GetPresScriptEmptyElemTokenMap()
const SvXMLTokenMap& SmXMLImport::GetPresTableElemTokenMap()
{
if(!pPresTableElemTokenMap)
- pPresTableElemTokenMap = new
- SvXMLTokenMap(aPresTableElemTokenMap);
+ pPresTableElemTokenMap = new SvXMLTokenMap(aPresTableElemTokenMap);
return *pPresTableElemTokenMap;
}
+const SvXMLTokenMap& SmXMLImport::GetColorTokenMap()
+{
+ if(!pColorTokenMap)
+ pColorTokenMap = new SvXMLTokenMap(aColorTokenMap);
+ return *pColorTokenMap;
+}
+
SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -1287,6 +1568,9 @@ SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
SvXMLImportContext* pContext = 0L;
const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresLayoutElemTokenMap();
+
+ UINT32 nTest = rTokenMap.Get(nPrefix, rLocalName);
+
switch(rTokenMap.Get(nPrefix, rLocalName))
{
/*General Layout Schemata*/
@@ -1364,17 +1648,14 @@ SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
rLocalName, xAttrList);
break;
default:
- /*Basically theres an implicit mrow around bare elements*/
- SvXMLImportContext *pTempContext =
- GetSmImport().CreateRowContext(nPrefix,
- OUString(RTL_CONSTASCII_USTRINGPARAM("mrow")),xAttrList);
- pContext = pTempContext->CreateChildContext(nPrefix, rLocalName,
- xAttrList);
- delete pTempContext;
-#if 0
- pContext = GetSmImport().CreateMathContext(nPrefix,rLocalName,
- xAttrList);
-#endif
+ /*Basically theres an implicit mrow around certain bare
+ *elements, use a RowContext to see if this is one of
+ *those ones*/
+ SmXMLRowContext_Impl aTempContext(GetSmImport(),nPrefix,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_mrow)));
+
+ pContext = aTempContext.StrictCreateChildContext(nPrefix,
+ rLocalName, xAttrList);
break;
}
return pContext;
@@ -1386,7 +1667,7 @@ void SmXMLDocContext_Impl::EndElement()
ContextArray.SetSize(1);
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- for(USHORT i=0;i< 1;i++)
+ for(ULONG i=0;i< 1;i++)
ContextArray.Put(i, rNodeStack.Pop());
SmToken aDummy;
@@ -1395,9 +1676,9 @@ void SmXMLDocContext_Impl::EndElement()
rNodeStack.Push(pSNode);
SmNodeArray LineArray;
- USHORT n = rNodeStack.Count();
+ ULONG n = rNodeStack.Count();
LineArray.SetSize(n);
- for (USHORT j = 0; j < n; j++)
+ for (ULONG j = 0; j < n; j++)
LineArray.Put(n - (j + 1), rNodeStack.Pop());
SmStructureNode *pSNode2 = new SmTableNode(aDummy);
pSNode2->SetSubNodes(LineArray);
@@ -1469,12 +1750,12 @@ void SmXMLRowContext_Impl::EndElement()
{
SmNodeArray aRelationArray;
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- USHORT nSize = rNodeStack.Count()-nElementCount;
+ ULONG nSize = rNodeStack.Count()-nElementCount;
if (nSize)
{
aRelationArray.SetSize(nSize);
- for(USHORT j=rNodeStack.Count()-nElementCount;j > 0;j--)
+ for(ULONG j=rNodeStack.Count()-nElementCount;j > 0;j--)
aRelationArray.Put(j-1,rNodeStack.Pop());
@@ -1490,7 +1771,6 @@ void SmXMLRowContext_Impl::EndElement()
{
SmToken aToken;
aToken.cMathChar = '\0';
- aToken.aText = 'none';
aToken.nGroup = 0;
aToken.nLevel = 5;
@@ -1523,7 +1803,7 @@ void SmXMLRowContext_Impl::EndElement()
aRelationArray2.SetSize(nSize-nLeft-nRight);
- for(ULONG i=0;i < nSize-nLeft-nRight;i++)
+ for(USHORT i=0;i < nSize-nLeft-nRight;i++)
aRelationArray2.Put(i,aRelationArray.Get(i+nLeft));
SmToken aDummy;
@@ -1557,7 +1837,8 @@ void SmXMLRowContext_Impl::EndElement()
-SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
+
+SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
const uno::Reference<xml::sax::XAttributeList>& xAttrList)
@@ -1599,19 +1880,33 @@ SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName,
xAttrList);
break;
-
-
default:
- //All of those are end nodes, i.e. nothing embedded in them
- //anything else will be a schemata of some kind.
- pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
break;
}
return pContext;
}
+
+SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ SvXMLImportContext* pContext = StrictCreateChildContext(nPrefix,
+ rLocalName, xAttrList);
+
+ if (!pContext)
+ {
+ //Hmm, unrecognized for this level, check to see if its
+ //an element that can have an implicit schema around it
+ pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix,
+ rLocalName,xAttrList);
+ }
+ return pContext;
+}
+
+
SvXMLImportContext *SmXMLMultiScriptsContext_Impl::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLocalName,
@@ -1654,7 +1949,7 @@ void SmXMLMultiScriptsContext_Impl::MiddleElement()
aToken.nGroup = 0;
aToken.nLevel = 0;
aToken.eType = TRSUB;
- USHORT nFinalCount = rNodeStack.Count()-nElementCount-1;
+ ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
SmNodeStack aReverseStack;
while (rNodeStack.Count()-nElementCount)
@@ -1663,14 +1958,14 @@ void SmXMLMultiScriptsContext_Impl::MiddleElement()
aReverseStack.Push(pThing);
}
- for (USHORT nCount=0;nCount < nFinalCount;nCount+=2)
+ for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
{
SmSubSupNode *pNode = new SmSubSupNode(aToken);
// initialize subnodes array
SmNodeArray aSubNodes;
aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (int i = 1; i < aSubNodes.GetSize(); i++)
+ for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
aSubNodes.Put(i, NULL);
/*On each loop the base and its sub sup pair becomes the
@@ -1704,19 +1999,37 @@ void SmXMLTableContext_Impl::EndElement()
SmNodeStack aReverseStack;
aExpressionArray.SetSize(rNodeStack.Count()-nElementCount);
- USHORT nRows = rNodeStack.Count()-nElementCount;
+ ULONG nRows = rNodeStack.Count()-nElementCount;
USHORT nCols = 0;
SmStructureNode *pArray;
- for(USHORT i=rNodeStack.Count()-nElementCount;i > 0;i--)
+ for(ULONG i=rNodeStack.Count()-nElementCount;i > 0;i--)
{
pArray = (SmStructureNode *)rNodeStack.Pop();
+ if (pArray->GetNumSubNodes() == 0)
+ {
+ //This is a little tricky, it is possible that there was
+ //be elements that were not inside a <mtd> pair, in which
+ //case they will not be in a row, i.e. they will not have
+ //SubNodes, so we have to wait until here before we can
+ //resolve the situation. Implicitsurrounding tags are
+ //surprisingly difficult to get right within this
+ //architecture
+
+ SmNodeArray aRelationArray;
+ aRelationArray.SetSize(1);
+ aRelationArray.Put(0,pArray);
+ SmToken aDummy;
+ pArray = new SmExpressionNode(aDummy);
+ pArray->SetSubNodes(aRelationArray);
+ }
+
if (pArray->GetNumSubNodes() > nCols)
nCols = pArray->GetNumSubNodes();
aReverseStack.Push(pArray);
}
aExpressionArray.SetSize(nCols*nRows);
- USHORT j=0;
+ ULONG j=0;
while (aReverseStack.Count())
{
pArray = (SmStructureNode *)aReverseStack.Pop();
@@ -1731,7 +2044,7 @@ void SmXMLTableContext_Impl::EndElement()
aToken.eType = TMATRIX;
SmMatrixNode *pSNode = new SmMatrixNode(aToken);
pSNode->SetSubNodes(aExpressionArray);
- pSNode->SetRowCol(nRows,nCols);
+ pSNode->SetRowCol(static_cast<USHORT>(nRows),nCols);
rNodeStack.Push(pSNode);
}
@@ -1794,19 +2107,19 @@ void SmXMLMultiScriptsContext_Impl::EndElement()
aToken.nGroup = 0;
aToken.nLevel = 0;
aToken.eType = TLSUB;
- USHORT nFinalCount = rNodeStack.Count()-nElementCount-1;
+ ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
SmNodeStack aReverseStack;
while (rNodeStack.Count()-nElementCount)
aReverseStack.Push(rNodeStack.Pop());
- for (USHORT nCount=0;nCount < nFinalCount;nCount+=2)
+ for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
{
SmSubSupNode *pNode = new SmSubSupNode(aToken);
// initialize subnodes array
SmNodeArray aSubNodes;
aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (int i = 1; i < aSubNodes.GetSize(); i++)
+ for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
aSubNodes.Put(i, NULL);
/*On each loop the base and its sub sup pair becomes the
@@ -1837,7 +2150,7 @@ void SmXMLActionContext_Impl::EndElement()
first pushed one*/
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- for(USHORT i=rNodeStack.Count()-nElementCount;i > 1;i--)
+ for(ULONG i=rNodeStack.Count()-nElementCount;i > 1;i--)
{
delete rNodeStack.Pop();
}
@@ -1900,13 +2213,6 @@ SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix,
}
-SvXMLImportContext *SmXMLImport::CreateMathContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> &xAttrList)
-{
- return NULL;
-}
-
SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix,
const OUString &rLocalName,
const uno::Reference <xml::sax::XAttributeList> &xAttrList)
@@ -2075,6 +2381,8 @@ SmXMLImport::~SmXMLImport()
delete pPresLayoutAttrTokenMap;
if (pFencedAttrTokenMap)
delete pFencedAttrTokenMap;
+ if (pColorTokenMap)
+ delete pColorTokenMap;
if (pOperatorAttrTokenMap)
delete pOperatorAttrTokenMap;
}
@@ -2104,7 +2412,7 @@ void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode,int nLevel)
void SmXMLExport::ExportExpression(const SmNode *pNode,int nLevel)
{
SvXMLElementExport *pRow=0;
- USHORT nSize = pNode->GetNumSubNodes();
+ ULONG nSize = pNode->GetNumSubNodes();
if (nSize > 1)
pRow = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_mrow,
@@ -2182,7 +2490,7 @@ void SmXMLExport::ExportMath(const SmNode *pNode, int nLevel)
SvXMLElementExport aMath(*this,XML_NAMESPACE_MATH,sXML_mo,
sal_True,sal_False);
sal_Unicode nArse[2];
- nArse[0] = aMathTypeTable[pTemp->GetText().GetChar(0)&0x00FF];
+ nArse[0] = MathType::aMathTypeTable[pTemp->GetText().GetChar(0)&0x00FF];
nArse[1] = 0;
GetDocHandler()->characters(nArse);
}
@@ -2190,11 +2498,21 @@ void SmXMLExport::ExportMath(const SmNode *pNode, int nLevel)
void SmXMLExport::ExportText(const SmNode *pNode, int nLevel)
{
SvXMLElementExport *aText;
+ const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode);
switch (pNode->GetToken().eType)
{
+ default:
case TIDENT:
- //Note that we should change the fontstyle away from
- //italic for one char strings if needed, and vice versa
+ //Note that we change the fontstyle to italic for strings that
+ //are italic and longer than a single character.
+ if ((pTemp->GetText().Len() > 1) &&
+ (pTemp->GetFont().GetItalic() == ITALIC_NORMAL))
+ AddAttribute(XML_NAMESPACE_MATH,sXML_fontstyle,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_italic)));
+ else if ((pTemp->GetText().Len() == 1) &&
+ (pTemp->GetFont().GetItalic() == ITALIC_NONE))
+ AddAttribute(XML_NAMESPACE_MATH,sXML_fontstyle,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_normal)));
aText = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_mi,
sal_True,sal_False);
break;
@@ -2202,12 +2520,11 @@ void SmXMLExport::ExportText(const SmNode *pNode, int nLevel)
aText = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_mn,
sal_True,sal_False);
break;
- default:
+ case TTEXT:
aText = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_mtext,
sal_True,sal_False);
break;
- }
- const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode);
+ }
GetDocHandler()->characters(pTemp->GetText());
delete aText;
}
@@ -2216,7 +2533,7 @@ void SmXMLExport::ExportSubSupScript(const SmNode *pNode,int nLevel)
{
const SmNode *pSub,*pSup,*pCSub,*pCSup,*pLSub,*pLSup;
SvXMLElementExport *pThing=0,*pThing2=0;
-
+#if 0
if ((pCSub = pNode->GetSubNode(CSUB+1))&&(pCSup=pNode->GetSubNode(CSUP+1)))
{
pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
@@ -2232,6 +2549,7 @@ void SmXMLExport::ExportSubSupScript(const SmNode *pNode,int nLevel)
pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_mover,
sal_True,sal_True);
}
+#endif
//if we have prescripts at all then we must use the tensor notation
@@ -2245,8 +2563,33 @@ void SmXMLExport::ExportSubSupScript(const SmNode *pNode,int nLevel)
SvXMLElementExport aMultiScripts(*this,XML_NAMESPACE_MATH,
sXML_mmultiscripts, sal_True, sal_True);
+
+ if ((pCSub = pNode->GetSubNode(CSUB+1))
+ && (pCSup=pNode->GetSubNode(CSUP+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
+ sXML_munderover, sal_True,sal_True);
+ }
+ else if (pCSub = pNode->GetSubNode(CSUB+1))
+ {
+ pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
+ sXML_munder, sal_True,sal_True);
+ }
+ else if (pCSup = pNode->GetSubNode(CSUP+1))
+ {
+ pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
+ sXML_mover, sal_True,sal_True);
+ }
+
ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
+ if (pCSub)
+ ExportNodes(pCSub, nLevel+1);
+ if (pCSup)
+ ExportNodes(pCSup, nLevel+1);
+ if (pThing2)
+ delete pThing2;
+
pSub = pNode->GetSubNode(RSUB+1);
pSup = pNode->GetSubNode(RSUP+1);
if (pSub || pSup)
@@ -2309,8 +2652,30 @@ void SmXMLExport::ExportSubSupScript(const SmNode *pNode,int nLevel)
sal_True,sal_True);
}
+ if ((pCSub = pNode->GetSubNode(CSUB+1))
+ && (pCSup=pNode->GetSubNode(CSUP+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
+ sXML_munderover, sal_True,sal_True);
+ }
+ else if (pCSub = pNode->GetSubNode(CSUB+1))
+ {
+ pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
+ sXML_munder, sal_True,sal_True);
+ }
+ else if (pCSup = pNode->GetSubNode(CSUP+1))
+ {
+ pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
+ sXML_mover, sal_True,sal_True);
+ }
ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
+ if (pCSub)
+ ExportNodes(pCSub, nLevel+1);
+ if (pCSup)
+ ExportNodes(pCSup, nLevel+1);
+ if (pThing2)
+ delete pThing2;
if (pSub)
ExportNodes(pSub, nLevel+1);
@@ -2319,13 +2684,14 @@ void SmXMLExport::ExportSubSupScript(const SmNode *pNode,int nLevel)
if (pThing)
delete pThing;
}
-
+#if 0
if (pCSub)
ExportNodes(pCSub, nLevel+1);
if (pCSup)
ExportNodes(pCSup, nLevel+1);
if (pThing2)
delete pThing2;
+#endif
}
void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel)
@@ -2343,9 +2709,11 @@ void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel)
{
sal_Unicode nArse[2];
nArse[1] = 0;
- nArse[0] = aMathTypeTable[pLeft->GetText().GetChar(0)&0x00FF];
+ nArse[0] = MathType::aMathTypeTable[pLeft->GetText().GetChar(0)
+ & 0x00FF];
AddAttribute(XML_NAMESPACE_MATH,sXML_open,nArse);
- nArse[0] = aMathTypeTable[pRight->GetText().GetChar(0)&0x00FF];
+ nArse[0] = MathType::aMathTypeTable[pRight->GetText().GetChar(0)
+ & 0x00FF];
AddAttribute(XML_NAMESPACE_MATH,sXML_close,nArse);
pFences = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_mfenced,
sal_True,sal_True);
@@ -2415,6 +2783,8 @@ void SmXMLExport::ExportOperator(const SmNode *pNode, int nLevel)
GetDocHandler()->characters(pTemp->GetText());
}
#endif
+ SvXMLElementExport aRow(*this,XML_NAMESPACE_MATH,sXML_mrow,
+ sal_True, sal_True);
ExportNodes(pNode->GetSubNode(0),nLevel+1);
ExportNodes(pNode->GetSubNode(1),nLevel+1);
}
@@ -2426,14 +2796,14 @@ void SmXMLExport::ExportAttributes(const SmNode *pNode, int nLevel)
if (pNode->GetToken().eType == TUNDERLINE)
{
AddAttribute(XML_NAMESPACE_MATH,sXML_accentunder,
- OUString(RTL_CONSTASCII_USTRINGPARAM("True")));
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));
pElement = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_munder,
sal_True,sal_True);
}
else
{
AddAttribute(XML_NAMESPACE_MATH,sXML_accent,
- OUString(RTL_CONSTASCII_USTRINGPARAM("True")));
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));
pElement = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,sXML_mover,
sal_True,sal_True);
}
@@ -2488,21 +2858,103 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
break;
case TBOLD:
AddAttribute(XML_NAMESPACE_MATH,sXML_fontweight,
- OUString(RTL_CONSTASCII_USTRINGPARAM("bold")));
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_bold)));
break;
case TITALIC:
AddAttribute(XML_NAMESPACE_MATH,sXML_fontstyle,
- OUString(RTL_CONSTASCII_USTRINGPARAM("italic")));
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_italic)));
+ break;
+ case TNBOLD:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_fontweight,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_weight_normal)));
+ break;
+ case TNITALIC:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_fontstyle,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_weight_normal)));
+ break;
+ case TBLACK:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_black)));
+ break;
+ case TWHITE:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_white)));
+ break;
+ case TRED:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_red)));
+ break;
+ case TGREEN:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_green)));
+ break;
+ case TBLUE:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_blue)));
+ break;
+ case TCYAN:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_aqua)));
+ break;
+ case TMAGENTA:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_fuchsia)));
+ break;
+ case TYELLOW:
+ AddAttribute(XML_NAMESPACE_MATH,sXML_color,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_yellow)));
break;
case TSIZE:
{
const SmFontNode *pFontNode = static_cast<const SmFontNode *>
(pNode);
const Fraction &aFrac = pFontNode->GetSizeParameter();
+
OUStringBuffer sStrBuf;
- GetMM100UnitConverter().setXMLMeasureUnit(MAP_POINT);
- GetMM100UnitConverter().convertMeasure(sStrBuf,
- static_cast<long>(aFrac),MAP_POINT);
+ switch(pFontNode->GetSizeType())
+ {
+ case FNTSIZ_MULTIPLY:
+ SvXMLUnitConverter::convertNumber(sStrBuf,
+ static_cast<double>(aFrac*Fraction(100.00)));
+ sStrBuf.append(static_cast<sal_Unicode>('%'));
+ break;
+ case FNTSIZ_DIVIDE:
+ SvXMLUnitConverter::convertNumber(sStrBuf,
+ static_cast<double>(Fraction(100.00)/aFrac));
+ sStrBuf.append(static_cast<sal_Unicode>('%'));
+ break;
+ case FNTSIZ_ABSOLUT:
+ SvXMLUnitConverter::convertNumber(sStrBuf,
+ static_cast<double>(aFrac));
+ sStrBuf.append(
+ OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_unit_pt)));
+ break;
+ default:
+ {
+ //The problem here is that the wheels fall off because
+ //font size is stored in 100th's of a mm not pts, and
+ //rounding errors take their toll on the original
+ //value specified in points.
+
+ //Must fix StarMath to retain the original pt values
+ Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().
+ GetSize().Height());
+
+ if (pFontNode->GetSizeType() == FNTSIZ_MINUS)
+ aTemp-=aFrac;
+ else
+ aTemp+=aFrac;
+
+ double mytest = static_cast<double>(aTemp);
+
+ mytest = SolarMath::Round(mytest,1);
+ SvXMLUnitConverter::convertNumber(sStrBuf,mytest);
+ sStrBuf.append(OUString(
+ RTL_CONSTASCII_USTRINGPARAM(sXML_unit_pt)));
+ }
+ break;
+ }
+
OUString sStr(sStrBuf.makeStringAndClear());
AddAttribute(XML_NAMESPACE_MATH,sXML_fontsize,sStr);
}
@@ -2561,8 +3013,8 @@ void SmXMLExport::ExportVerticalBrace(const SmNode *pNode, int nLevel)
SvXMLElementExport aOver1(*this,XML_NAMESPACE_MATH,pWhich, sal_True,
sal_True);
{//Scoping
- AddAttribute(XML_NAMESPACE_MATH,sXML_accent,
- OUString(RTL_CONSTASCII_USTRINGPARAM("True")));
+ AddAttribute(XML_NAMESPACE_MATH,sXML_accent,OUString(
+ RTL_CONSTASCII_USTRINGPARAM(sXML_accent)));
SvXMLElementExport aOver2(*this,XML_NAMESPACE_MATH,pWhich, sal_True,
sal_True);
ExportNodes(pNode->GetSubNode(0),nLevel);
@@ -2577,11 +3029,11 @@ void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
sal_True, sal_True);
const SmMatrixNode *pMatrix = static_cast<const SmMatrixNode *>(pNode);
USHORT i=0;
- for (USHORT y = 0; y < pMatrix->GetNumRows(); y++)
+ for (ULONG y = 0; y < pMatrix->GetNumRows(); y++)
{
SvXMLElementExport aRow(*this,XML_NAMESPACE_MATH,sXML_mtr,
sal_True, sal_True);
- for (USHORT x = 0; x < pMatrix->GetNumCols(); x++)
+ for (ULONG x = 0; x < pMatrix->GetNumCols(); x++)
if (const SmNode *pTemp = pNode->GetSubNode(i++))
{
SvXMLElementExport aCell(*this,XML_NAMESPACE_MATH,
@@ -2607,8 +3059,14 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
case NTEXT:
ExportText(pNode,nLevel);
break;
- case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in the XML engine.
+ case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in
+ //the XML engine.
case NMATH:
+ //To fully handle generic MathML we need to implement the full
+ //operator dictionary, we will generate MathML with explicit
+ //stretchiness for now.
+ AddAttribute(XML_NAMESPACE_MATH,sXML_stretchy,OUString(
+ RTL_CONSTASCII_USTRINGPARAM(sXML_false)));
ExportMath(pNode,nLevel);
break;
case NBINHOR:
@@ -2647,8 +3105,8 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
#if 0
default:
{
- USHORT nSize = pNode->GetNumSubNodes();
- for (USHORT i = 0; i < nSize; i++)
+ ULONG nSize = pNode->GetNumSubNodes();
+ for (ULONG i = 0; i < nSize; i++)
if (SmNode *pTemp = pNode->GetSubNode(i))
ExportNodes(pTemp,nLevel+1);
}
diff --git a/starmath/source/mathml.hxx b/starmath/source/mathml.hxx
index 44c87657e39d..f02036166545 100644
--- a/starmath/source/mathml.hxx
+++ b/starmath/source/mathml.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mathml.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: cmc $ $Date: 2001-01-11 13:44:17 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:57:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -95,7 +95,7 @@ public:
pMathElemTokenMap(0), pPresLayoutElemTokenMap(0), pPresElemTokenMap(0),
pPresScriptEmptyElemTokenMap(0), pPresTableElemTokenMap(0),
pPresLayoutAttrTokenMap(0),pFencedAttrTokenMap(0),
- pOperatorAttrTokenMap(0)
+ pOperatorAttrTokenMap(0),pColorTokenMap(0)
{}
SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
const rtl::OUString &rLocalName,
@@ -229,6 +229,7 @@ public:
const SvXMLTokenMap &GetPresElemTokenMap();
const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
const SvXMLTokenMap &GetPresTableElemTokenMap();
+ const SvXMLTokenMap &GetColorTokenMap();
virtual ~SmXMLImport();
SmNodeStack & GetNodeStack() {return aNodeStack;}
SmNode *GetTree() { return aNodeStack.Pop();}
@@ -241,6 +242,7 @@ private:
SvXMLTokenMap *pPresElemTokenMap;
SvXMLTokenMap *pPresScriptEmptyElemTokenMap;
SvXMLTokenMap *pPresTableElemTokenMap;
+ SvXMLTokenMap *pColorTokenMap;
SmNodeStack aNodeStack;
};
@@ -277,7 +279,8 @@ enum SmXMLPresLayoutAttrTokenMap
XML_TOK_FONTWEIGHT,
XML_TOK_FONTSTYLE,
XML_TOK_FONTSIZE,
- XML_TOK_FONTFAMILY
+ XML_TOK_FONTFAMILY,
+ XML_TOK_COLOR
};
@@ -294,7 +297,6 @@ enum SmXMLPresTableElemTokenMap
XML_TOK_MTD
};
-
enum SmXMLPresElemTokenMap
{
XML_TOK_MI,
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 0f769502b8bb..68482f9633ca 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mathtype.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: cmc $ $Date: 2000-12-12 17:11:33 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:57:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -191,7 +191,7 @@ String aSizes[7] =
/*This table is not fully complete and is pending on what decisions are
*made as regards the StarMath to Unicode stuff*/
-sal_Unicode aMathTypeTable[256] =
+sal_Unicode MathType::aMathTypeTable[256] =
{
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009,
0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013,
@@ -201,14 +201,17 @@ sal_Unicode aMathTypeTable[256] =
0x21D0, 0x21D4, 0xffff, 0xffff, 0x2218, 0xffff, 0xffff, 0xffff, 0x003A, 0x003B,
0x003C, 0x003D, 0x003E, 0x00BF, 0x2260, 0x002B, 0x2212, 0x002A, 0x00D7, 0x22C5,
0x00F7, 0x00B1, 0x2213, 0x2295, 0x2296, 0x2297, 0x2298, 0x2299, 0x222A, 0x2229,
-0x003C, 0x003E, 0x2264, 0x2265, 0x2264, 0x2265, 0x226A, 0x226B, 0x007E, 0x2245,
+//0x003C, 0x003E, 0x2264, 0x2265,0x2264, 0x2265, 0x226A, 0x226B, 0x007E, 0x2245,
+0x003C, 0x003E, 0x2264, 0x2265, 0xE425, 0xE421, 0x226A, 0x226B, 0x007E, 0x2245,
0x2248, 0x225D, 0x2261, 0x221D, 0x2202, 0x2282, 0x2283, 0x2286, 0x2287, 0x2284,
0x2285, 0x2288, 0x2289, 0x2208, 0x2209, 0x2208, 0x2203, 0x220B, 0x2135, 0x2111,
0x211C, 0x2118, 0x0192, 0x2221, 0x2222, 0x007C, 0x2225, 0x22A5, 0x2026, 0x22EF,
0x22EE, 0x22F0, 0x22F1, 0x22B6, 0x22B7, 0x2192, 0x005C, 0x00AC, 0x222B, 0x222C,
0x222D, 0x222E, 0x222F, 0x2230, 0x221A, 0x221A, 0x221A, 0x221A, 0x2210, 0x220F,
-0x2211, 0x2207, 0x2200, 0x2225, 0x005E, 0x02C7, 0x02D8, 0x00B4, 0x0060, 0x02DC,
-0x00AF, 0x2192, 0x02D9, 0x00A8, 0xffff, 0x02DA, 0x2227, 0x2228, 0x220D, 0x2205,
+0x2211, 0x2207, 0x2200, 0xffff, 0x005E, 0x02C7, 0x02D8, 0x00B4, 0x0060, 0x02DC,
+//0x2211, 0x2207, 0x2200, 0x2225,0x005E, 0x02C7, 0x02D8, 0x00B4, 0x0060, 0x02DC,
+//0x00AF, 0x2192, 0x02D9, 0x00A8,0xffff, 0x02DA, 0x2227, 0x2228, 0x220D, 0x2205,
+0x00AF, 0x0362, 0x02D9, 0x00A8, 0xffff, 0x02DA, 0x2227, 0x2228, 0x220D, 0x2205,
0x007B, 0x007D, 0x0028, 0x0029, 0x2329, 0x232a, 0x005B, 0x005D, 0x2220, 0x221F,
0xffff, 0x225C, 0x2254, 0x2255, 0x21B3, 0x2197, 0x2198, 0x2245, 0x301A, 0x301B,
0xffff, 0xffff, 0xffff, 0xffff, 0x2112, 0x2130, 0x2131, 0xffff, 0xffff, 0x002F,
@@ -258,12 +261,16 @@ void EQNOLEFILEHDR::Write(SvStorageStream *pS)
between math symbols and ordinary text e.g. 1=2 rather
than 1 = 2
*/
-BOOL MathType::LookupChar(sal_Unicode nChar)
+sal_Bool MathType::LookupChar(sal_Unicode nChar,String &rRet,BYTE nVersion,
+ BYTE nTypeFace)
{
BOOL bRet=FALSE;
const char *pC = NULL;
switch(nChar)
{
+ case 0x0000:
+ pC = " none ";
+ break;
case 0x00ac:
pC = " neg ";
break;
@@ -279,6 +286,24 @@ BOOL MathType::LookupChar(sal_Unicode nChar)
bRet=TRUE;
}
break;
+ case 0x007b:
+ pC = " lbrace ";
+ break;
+ case 0x007c:
+ pC = " divides ";
+ break;
+ case 0x007d:
+ pC = " rbrace ";
+ break;
+ case 0x007e:
+ pC = " sim ";
+ break;
+ case 0x2224:
+ pC = " ndivides ";
+ break;
+ case 0x2225:
+ pC = " parallel ";
+ break;
case 0x00d7:
if (nVersion < 3)
pC = " cdot ";
@@ -297,18 +322,33 @@ BOOL MathType::LookupChar(sal_Unicode nChar)
case 0x2022:
pC = " cdot ";
break;
+ case 0x2102:
+ pC = " setC ";
+ break;
case 0x210f:
pC = " hbar ";
break;
case 0x2111:
pC = " Im ";
break;
+ case 0x2115:
+ pC = " setN ";
+ break;
case 0x2118:
pC = " wp ";
break;
+ case 0x211a:
+ pC = " setQ ";
+ break;
case 0x211c:
pC = " Re ";
break;
+ case 0x211d:
+ pC = " setR ";
+ break;
+ case 0x2124:
+ pC = " setZ ";
+ break;
case 0x2135:
pC = " aleph ";
break;
@@ -321,9 +361,18 @@ BOOL MathType::LookupChar(sal_Unicode nChar)
case 0x2192:
pC = " rightarrow ";
break;
+ case 0x0362:
+ pC = " vec ";
+ break;
case 0x2193:
pC = " downarrow ";
break;
+ case 0x21d0:
+ pC = " dlarrow ";
+ break;
+ case 0x21d2:
+ pC = " drarrow ";
+ break;
case 0x21d4:
pC = " dlrarrow ";
break;
@@ -420,12 +469,21 @@ BOOL MathType::LookupChar(sal_Unicode nChar)
case 0x2284:
pC = " nsubset ";
break;
+ case 0x2285:
+ pC = " nsupset ";
+ break;
case 0x2286:
pC = " subseteq ";
break;
case 0x2287:
pC = " supseteq ";
break;
+ case 0x2288:
+ pC = " nsubseteq ";
+ break;
+ case 0x2289:
+ pC = " nsupseteq ";
+ break;
case 0x227a:
case 0x227b:
case 0x22b2:
@@ -452,6 +510,24 @@ BOOL MathType::LookupChar(sal_Unicode nChar)
case 0x22f1:
pC = " dotsdown ";
break;
+ case 0x2329:
+ pC = " langle ";
+ break;
+ case 0x232a:
+ pC = " rangle ";
+ break;
+ case 0x301a:
+ pC = " ldbracket ";
+ break;
+ case 0x301b:
+ pC = " rdbracket ";
+ break;
+ case 0xE421:
+ pC = " geslant ";
+ break;
+ case 0xE425:
+ pC = " leslant ";
+ break;
case 0xeb01: //no space
case 0xeb08: //normal space
bRet=TRUE;
@@ -2688,7 +2764,7 @@ int MathType::HandleChar(xub_StrLen &rTextStart,int &rSetSize,int nLevel,
rTextStart = rRet.Len();
}
nOldLen = rRet.Len();
- if (!LookupChar(nChar))
+ if (!LookupChar(nChar,rRet,nVersion,nTypeFace))
{
if (nOldLen - rTextStart > 1)
{
@@ -2862,6 +2938,10 @@ void MathType::HandleMath(SmNode *pNode,int nLevel)
}
else if (nArse == 0x2225)
*pS << USHORT(0xEC09);
+ else if (nArse == 0xE421)
+ *pS << USHORT(0x2265);
+ else if (nArse == 0xE425)
+ *pS << USHORT(0x2264);
else if (nArse == 0x226A)
{
*pS << USHORT(0x3C);
@@ -3085,4 +3165,3 @@ void MathType::HandleText(SmNode *pNode,int nLevel)
}
}
}
-
diff --git a/starmath/source/mathtype.hxx b/starmath/source/mathtype.hxx
index a7cf86b1fdb2..43cef9076f8e 100644
--- a/starmath/source/mathtype.hxx
+++ b/starmath/source/mathtype.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mathtype.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 16:57:26 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:57:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -130,7 +130,6 @@ private:
int HandleRecords(int nLevel=0,BYTE nSelector=-1,
BYTE nVariation=-1,int nRows=0,int nCols=0);
- BOOL LookupChar(sal_Unicode nChar);
BOOL HandleSize(INT16 nLSize,INT16 nDSize, int &rSetSize);
void HandleAlign(BYTE nHAlign,BYTE nVAlign, int &rSetAlign);
int HandlePile(int &rSetAlign,int nLevel,BYTE nSelector,BYTE nVariation);
@@ -197,6 +196,10 @@ private:
tmOBAR,tmLARROW,tmRARROW,tmBARROW,tmSINT,tmDINT,tmTINT,tmSSINT,
tmDSINT,tmTSINT,tmUHBRACE,tmLHBRACE,tmSUM
};
+public:
+ static sal_Bool LookupChar(sal_Unicode nChar,String &rRet,
+ BYTE nVersion=3,BYTE nTypeFace=0);
+ static sal_Unicode aMathTypeTable[256]; //Magic lookup table
};
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 3680c6883500..acf196ba9363 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: node.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 16:57:26 $
+ * last change: $Author: cmc $ $Date: 2001-01-18 14:57:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,6 +60,7 @@
************************************************************************/
#pragma hdrstop
+#define APPEND(str,ascii) str.AppendAscii(RTL_CONSTASCII_STRINGPARAM(ascii))
#ifndef _SV_GEN_HXX //autogen
#include <tools/gen.hxx>
@@ -67,6 +68,9 @@
#ifndef _FRACT_HXX //autogen
#include <tools/fract.hxx>
#endif
+#ifndef _TOOLS_SOLMATH_H
+#include <tools/solmath.hxx>
+#endif
#ifndef _SV_COLOR_HXX //autogen
#include <vcl/color.hxx>
#endif
@@ -111,6 +115,9 @@
#ifndef _SMMOD_HXX
#include "smmod.hxx"
#endif
+#ifndef _MATHTYPE_HXX
+#include "mathtype.hxx"
+#endif
#include <math.h>
#include <float.h>
@@ -262,7 +269,8 @@ void SmNode::SetFontSize(const Fraction &rSize, USHORT nType)
{
Fraction aVal (SmPtsTo100th_mm(rSize.GetNumerator()),
rSize.GetDenominator());
- long nHeight = (long) aVal;
+ //long nHeight = SolarMath::Round(aVal);
+ long nHeight = (long)aVal;
aSize = GetFont().GetSize();
aSize.Width() = 0;
@@ -417,6 +425,46 @@ void SmNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
pNode->Arrange(rDev, rFormat);
}
+void SmNode::CreateTextFromNode(String &rText)
+{
+ SmNode *pNode;
+ USHORT nSize = GetNumSubNodes();
+ if (nSize > 1)
+ rText.Append('{');
+ for (USHORT i = 0; i < nSize; i++)
+ if (pNode = GetSubNode(i))
+ pNode->CreateTextFromNode(rText);
+ if (nSize > 1)
+ {
+ rText.EraseTrailingChars();
+ APPEND(rText,"} ");
+ }
+}
+
+void SmExpressionNode::CreateTextFromNode(String &rText)
+{
+ SmNode *pNode;
+ USHORT nSize = GetNumSubNodes();
+ if (nSize > 1)
+ rText.Append('{');
+ for (USHORT i = 0; i < nSize; i++)
+ if (pNode = GetSubNode(i))
+ {
+ pNode->CreateTextFromNode(rText);
+ //Just a bit of foo to make unary +asd -asd +-asd -+asd look nice
+ if (pNode->GetType() == NMATH)
+ if ((nSize != 2) || ((rText.GetChar(rText.Len()-1) != '+') &&
+ (rText.GetChar(rText.Len()-1) != '-')))
+ rText.Append(' ');
+ }
+
+ if (nSize > 1)
+ {
+ rText.EraseTrailingChars();
+ APPEND(rText,"} ");
+ }
+}
+
void SmNode::Draw(OutputDevice &rDev, const Point &rPosition) const
{
@@ -795,6 +843,20 @@ void SmRootNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
}
+void SmRootNode::CreateTextFromNode(String &rText)
+{
+ SmNode *pExtra = GetSubNode(0);
+ if (pExtra)
+ {
+ APPEND(rText,"nroot ");
+ pExtra->CreateTextFromNode(rText);
+ }
+ else
+ APPEND(rText,"sqrt ");
+ GetSubNode(2)->CreateTextFromNode(rText);
+}
+
+
/**************************************************************************/
@@ -895,6 +957,16 @@ void SmBinVerNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
ExtendBy(*pDenom, RCP_NONE).ExtendBy(*pLine, RCP_NONE, pLine->GetCenterY());
}
+void SmBinVerNode::CreateTextFromNode(String &rText)
+{
+ SmNode *pNum = GetSubNode(0),
+ *pLine = GetSubNode(1),
+ *pDenom = GetSubNode(2);
+ pNum->CreateTextFromNode(rText);
+ APPEND(rText,"over ");
+ pDenom->CreateTextFromNode(rText);
+}
+
/**************************************************************************/
@@ -1278,9 +1350,61 @@ void SmSubSupNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
}
}
+void SmSubSupNode::CreateTextFromNode(String &rText)
+{
+ SmNode *pNode;
+ GetSubNode(0)->CreateTextFromNode(rText);
+
+ if (pNode = GetSubNode(LSUB+1))
+ {
+ APPEND(rText,"lsub ");
+ pNode->CreateTextFromNode(rText);
+ }
+ if (pNode = GetSubNode(LSUP+1))
+ {
+ APPEND(rText,"lsup ");
+ pNode->CreateTextFromNode(rText);
+ }
+ if (pNode = GetSubNode(CSUB+1))
+ {
+ APPEND(rText,"csub ");
+ pNode->CreateTextFromNode(rText);
+ }
+ if (pNode = GetSubNode(CSUP+1))
+ {
+ APPEND(rText,"csup ");
+ pNode->CreateTextFromNode(rText);
+ }
+ if (pNode = GetSubNode(RSUB+1))
+ {
+ rText.EraseTrailingChars();
+ rText.Append('_');
+ pNode->CreateTextFromNode(rText);
+ }
+ if (pNode = GetSubNode(RSUP+1))
+ {
+ rText.EraseTrailingChars();
+ rText.Append('^');
+ pNode->CreateTextFromNode(rText);
+ }
+}
+
/**************************************************************************/
+void SmBraceNode::CreateTextFromNode(String &rText)
+{
+ if (GetScaleMode() == SCALE_HEIGHT)
+ APPEND(rText,"left ");
+ GetSubNode(0)->CreateTextFromNode(rText);
+ rText.Append(' ');
+ GetSubNode(1)->CreateTextFromNode(rText);
+ if (GetScaleMode() == SCALE_HEIGHT)
+ APPEND(rText,"right ");
+ GetSubNode(2)->CreateTextFromNode(rText);
+ rText.Append(' ');
+
+}
void SmBraceNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
{
@@ -1638,6 +1762,95 @@ void SmAttributNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
/**************************************************************************/
+
+
+void SmFontNode::CreateTextFromNode(String &rText)
+{
+ switch (GetToken().eType)
+ {
+ case TBOLD:
+ APPEND(rText,"bold ");
+ break;
+ case TNBOLD:
+ APPEND(rText,"nbold ");
+ break;
+ case TITALIC:
+ APPEND(rText,"italic ");
+ break;
+ case TNITALIC:
+ APPEND(rText,"nitalic ");
+ break;
+ case TPHANTOM:
+ APPEND(rText,"phantom ");
+ break;
+ case TSIZE:
+ {
+ APPEND(rText,"size ");
+ switch (nSizeType)
+ {
+ case FNTSIZ_PLUS:
+ rText.Append('+');
+ break;
+ case FNTSIZ_MINUS:
+ rText.Append('-');
+ break;
+ case FNTSIZ_MULTIPLY:
+ rText.Append('*');
+ break;
+ case FNTSIZ_DIVIDE:
+ rText.Append('/');
+ break;
+ case FNTSIZ_ABSOLUT:
+ default:
+ break;
+ }
+ String sResult;
+ SolarMath::DoubleToString(sResult,
+ static_cast<double>(aFontSize),'A',INT_MAX,'.',sal_True);
+ rText.Append(sResult);
+ rText.Append(' ');
+ }
+ break;
+ case TBLACK:
+ APPEND(rText,"color black ");
+ break;
+ case TWHITE:
+ APPEND(rText,"color white ");
+ break;
+ case TRED:
+ APPEND(rText,"color red ");
+ break;
+ case TGREEN:
+ APPEND(rText,"color green ");
+ break;
+ case TBLUE:
+ APPEND(rText,"color blue ");
+ break;
+ case TCYAN:
+ APPEND(rText,"color cyan ");
+ break;
+ case TMAGENTA:
+ APPEND(rText,"color magenta ");
+ break;
+ case TYELLOW:
+ APPEND(rText,"color yellow ");
+ break;
+ case TSANS:
+ APPEND(rText,"font sans ");
+ break;
+ case TSERIF:
+ APPEND(rText,"font serif ");
+ break;
+ case TFIXED:
+ APPEND(rText,"font fixed ");
+ break;
+ default:
+ break;
+ }
+ GetSubNode(1)->CreateTextFromNode(rText);
+}
+
+
void SmFontNode::Prepare(const SmFormat &rFormat)
{
//! prepare subnodes first
@@ -2067,6 +2280,21 @@ void SmTextNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
SmRect::operator = (SmRect(aTmpDev, &rFormat, aText, GetFont().GetBorderWidth()));
}
+void SmTextNode::CreateTextFromNode(String &rText)
+{
+ if (GetToken().eType == TTEXT)
+ rText.Append('\"');
+ else if ((GetToken().eType == TIDENT) &&
+ (GetFontDesc() == FNT_FUNCTION))
+ {
+ //Search for existing functions and remove extraenous keyword
+ APPEND(rText,"func ");
+ }
+ rText.Append(GetToken().aText);
+ if (GetToken().eType == TTEXT)
+ rText.Append('\"');
+ rText.Append(' ');
+}
void SmTextNode::Draw(OutputDevice &rDev, const Point& rPosition) const
{
@@ -2097,6 +2325,24 @@ void SmTextNode::Draw(OutputDevice &rDev, const Point& rPosition) const
/**************************************************************************/
+void SmMatrixNode::CreateTextFromNode(String &rText)
+{
+ APPEND(rText,"matrix {");
+ for (int i = 0; i < nNumRows; i++)
+ {
+ for (int j = 0; j < nNumCols; j++)
+ {
+ SmNode *pNode = GetSubNode(i * nNumCols + j);
+ pNode->CreateTextFromNode(rText);
+ if (j != nNumCols-1)
+ APPEND(rText,"# ");
+ }
+ if (i != nNumRows-1)
+ APPEND(rText,"## ");
+ }
+ rText.EraseTrailingChars();
+ APPEND(rText,"} ");
+}
void SmMatrixNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
{
@@ -2316,6 +2562,17 @@ void SmMathSymbolNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat
SmRect::operator = (SmRect(aTmpDev, &rFormat, rText, GetFont().GetBorderWidth()));
}
+void SmMathSymbolNode::CreateTextFromNode(String &rText)
+{
+// rText.Append(MathType::aMathTypeTable[GetToken().cMathChar&0x00FF]);
+ String sStr;
+ MathType::LookupChar(MathType::aMathTypeTable[GetToken().cMathChar&0x00FF],
+ sStr);
+ sStr.EraseLeadingAndTrailingChars();
+ rText.Append(sStr);
+}
+
+
/**************************************************************************/