diff options
author | Frédéric Wang <fred.wang@free.fr> | 2013-06-27 21:35:28 +0200 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-06-28 09:56:36 +0000 |
commit | 43cf39adff66d20862956869d11fbcc184eb5702 (patch) | |
tree | a0d8ad03ab6b0a9d98efe80288400d667954b8e9 /starmath/source | |
parent | 4f294a90877d2f91bb88c7d6cd5b74e8e546a025 (diff) |
fdo#66088 Export some math symbols as <mi> elements.
Change-Id: Ib08717c3d4d41abc7bce4cd6bc2e63bda7db6086
Reviewed-on: https://gerrit.libreoffice.org/4595
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/mathmlexport.cxx | 24 | ||||
-rw-r--r-- | starmath/source/mathtype.cxx | 1 | ||||
-rw-r--r-- | starmath/source/node.cxx | 1 | ||||
-rw-r--r-- | starmath/source/ooxmlexport.cxx | 4 | ||||
-rw-r--r-- | starmath/source/parse.cxx | 32 | ||||
-rw-r--r-- | starmath/source/rtfexport.cxx | 4 | ||||
-rw-r--r-- | starmath/source/visitors.cxx | 2 | ||||
-rw-r--r-- | starmath/source/wordexportbase.cxx | 1 |
8 files changed, 49 insertions, 20 deletions
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index d23662c47065..fb1e6c365130 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -871,7 +871,26 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel) void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/) { const SmMathSymbolNode *pTemp = static_cast<const SmMathSymbolNode *>(pNode); - SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, sal_True, sal_False); + SvXMLElementExport *pMath = 0; + + if (pNode->GetType() == NMATH) + { + // Export NMATH symbols as <mo> elements + pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MO, sal_True, sal_False); + } + else + { + // Export NMATHIDENT and NPLACE symbols as <mi> elements: + // - These math symbols should not be drawn slanted. Hence we should + // attach a mathvariant="normal" attribute to single-char <mi> elements + // that are not mathematical alphanumeric symbol. For simplicity and to + // work around browser limitations, we always attach such an attribute. + // - The MathML specification suggests to use empty <mi> elements as + // placeholders but they won't be visible in most MathML rendering + // engines so let's use an empty square for NPLACE instead. + AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_NORMAL); + pMath = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False); + } sal_Unicode nArse[2]; nArse[0] = pTemp->GetText()[0]; sal_Unicode cTmp = ConvertMathToMathML( nArse[0] ); @@ -880,6 +899,8 @@ void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/) OSL_ENSURE(nArse[0] != 0xffff,"Non existent symbol"); nArse[1] = 0; GetDocHandler()->characters(nArse); + + delete pMath; } void SmXMLExport::ExportText(const SmNode *pNode, int /*nLevel*/) @@ -1520,6 +1541,7 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel) } } break; + case NMATHIDENT : case NPLACE: ExportMath(pNode, nLevel); break; diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx index 8b958a144a42..3de5817b5885 100644 --- a/starmath/source/mathtype.cxx +++ b/starmath/source/mathtype.cxx @@ -1997,6 +1997,7 @@ sal_uInt8 MathType::HandleNodes(SmNode *pNode,int nLevel) } break; case NMATH: + case NMATHIDENT: HandleMath(pNode,nLevel); break; case NSUBSUP: diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index d3ae70573602..ccfc4b07166e 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -621,6 +621,7 @@ void SmNode::DumpAsDot(std::ostream &out, OUString* label, int number, int& id, case NROOTSYMBOL: out<<"SmRootSymbolNode"; break; case NRECTANGLE: out<<"SmRectangleNode"; break; case NVERTICAL_BRACE: out<<"SmVerticalBraceNode"; break; + case NMATHIDENT: out<<"SmMathIdentifierNode"; break; default: out<<"Unknown Node"; } diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx index 3cbdf45f0875..c7ab7ff5bed4 100644 --- a/starmath/source/ooxmlexport.cxx +++ b/starmath/source/ooxmlexport.cxx @@ -236,7 +236,7 @@ void SmOoxmlExport::HandleRoot( const SmRootNode* pNode, int nLevel ) static OString mathSymbolToString( const SmNode* node ) { - assert( node->GetType() == NMATH ); + assert( node->GetType() == NMATH || node->GetType() == NMATHIDENT ); const SmTextNode* txtnode = static_cast< const SmTextNode* >( node ); assert( txtnode->GetText().getLength() == 1 ); sal_Unicode chr = SmTextNode::ConvertSymbolToUnicode( txtnode->GetText()[0] ); @@ -463,7 +463,7 @@ void SmOoxmlExport::HandleBrace( const SmBraceNode* pNode, int nLevel ) for( int i = 0; i < body->GetNumSubNodes(); ++i ) { const SmNode* subnode = body->GetSubNode( i ); - if( subnode->GetType() == NMATH ) + if (subnode->GetType() == NMATH || subnode->GetType() == NMATHIDENT) { // do not write, but write what separator it is const SmMathSymbolNode* math = static_cast< const SmMathSymbolNode* >( subnode ); if( !separatorWritten ) diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index cdb6865db623..4477d1006516 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -1485,24 +1485,10 @@ void SmParser::Term(bool bGroupNumberIdent) case TRIGHTARROW : case TUPARROW : case TDOWNARROW : - case TSETN : - case TSETZ : - case TSETQ : - case TSETR : - case TSETC : - case THBAR : - case TLAMBDABAR : case TCIRC : case TDRARROW : case TDLARROW : case TDLRARROW : - case TBACKEPSILON : - case TALEPH : - case TIM : - case TRE : - case TWP : - case TEMPTYSET : - case TINFINITY : case TEXISTS : case TNOTEXISTS : case TFORALL : @@ -1519,6 +1505,24 @@ void SmParser::Term(bool bGroupNumberIdent) NextToken(); break; + case TSETN : + case TSETZ : + case TSETQ : + case TSETR : + case TSETC : + case THBAR : + case TLAMBDABAR : + case TBACKEPSILON : + case TALEPH : + case TIM : + case TRE : + case TWP : + case TEMPTYSET : + case TINFINITY : + m_aNodeStack.push(new SmMathIdentifierNode(m_aCurToken)); + NextToken(); + break; + case TPLACE: m_aNodeStack.push(new SmPlaceNode(m_aCurToken)); NextToken(); diff --git a/starmath/source/rtfexport.cxx b/starmath/source/rtfexport.cxx index fd6f6d03ca26..9dffbcf02b18 100644 --- a/starmath/source/rtfexport.cxx +++ b/starmath/source/rtfexport.cxx @@ -179,7 +179,7 @@ void SmRtfExport::HandleRoot(const SmRootNode* pNode, int nLevel) namespace { OString mathSymbolToString(const SmNode* node, rtl_TextEncoding nEncoding) { - assert(node->GetType() == NMATH); + assert(node->GetType() == NMATH || node->GetType() == NMATHIDENT); const SmTextNode* txtnode = static_cast<const SmTextNode*>(node); if (txtnode->GetText().isEmpty()) return OString(); @@ -403,7 +403,7 @@ void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel) for (int i = 0; i < body->GetNumSubNodes(); ++i) { const SmNode* subnode = body->GetSubNode(i); - if (subnode->GetType() == NMATH) + if (subnode->GetType() == NMATH || subnode->GetType() == NMATHIDENT) { // do not write, but write what separator it is const SmMathSymbolNode* math = static_cast<const SmMathSymbolNode*>(subnode); if(!separatorWritten) diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx index fc0ffc80cc7a..91032b21845c 100644 --- a/starmath/source/visitors.cxx +++ b/starmath/source/visitors.cxx @@ -115,7 +115,7 @@ void SmVisitorTest::Visit( SmGlyphSpecialNode* pNode ) void SmVisitorTest::Visit( SmMathSymbolNode* pNode ) { - OSL_ENSURE( pNode->GetType( ) == NMATH, "the visitor-patterns isn't implemented correctly" ); + OSL_ENSURE( pNode->GetType( ) == NMATH || pNode->GetType( ) == NMATHIDENT, "the visitor-patterns isn't implemented correctly" ); VisitChildren( pNode ); } diff --git a/starmath/source/wordexportbase.cxx b/starmath/source/wordexportbase.cxx index 0a7a6b866c98..f0df05c43b91 100644 --- a/starmath/source/wordexportbase.cxx +++ b/starmath/source/wordexportbase.cxx @@ -65,6 +65,7 @@ void SmWordExportBase::HandleNode( const SmNode* pNode, int nLevel ) break; } case NMATH: + case NMATHIDENT: HandleMath(pNode,nLevel); break; case NSUBSUP: |