diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-12-02 14:23:59 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-12-07 14:47:10 +0100 |
commit | efe72126d9942aa6c62608f801670db06a31828f (patch) | |
tree | ef553d3a834d1d213bcf22e17e897cb5c4fd30ca /starmath | |
parent | d7017dbc1754c3b6f27501d3eae997a39f62daf8 (diff) |
merge two duplicates of a function
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/node.hxx | 5 | ||||
-rw-r--r-- | starmath/source/mathtype.cxx | 37 | ||||
-rw-r--r-- | starmath/source/node.cxx | 33 | ||||
-rw-r--r-- | starmath/source/ooxmlexport.cxx | 43 |
4 files changed, 45 insertions, 73 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 1ecde44b406e..385aa8e8dd53 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -502,6 +502,11 @@ public: virtual void GetAccessibleText( String &rText ) const; void Accept(SmVisitor* pVisitor); + /** + Converts the character from StarMath's private area symbols to a matching Unicode + character, if necessary. To be used when converting GetText() to a normal text. + */ + static sal_Unicode ConvertSymbolToUnicode(sal_Unicode nIn); }; diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx index bd5386f1cfb8..58d37d7217d0 100644 --- a/starmath/source/mathtype.cxx +++ b/starmath/source/mathtype.cxx @@ -33,39 +33,6 @@ #define APPEND(str,ascii) str.AppendAscii(RTL_CONSTASCII_STRINGPARAM(ascii)) -static sal_Unicode Convert(sal_Unicode nIn) -{ - //Find the best match in accepted unicode for our private area symbols - static const sal_Unicode aStarMathPrivateToUnicode[] = - { - 0x2030, 0xF613, 0xF612, 0x002B, 0x003C, 0x003E, 0xE425, 0xE421, 0xE088, 0x2208, - 0x0192, 0x2026, 0x2192, 0x221A, 0x221A, 0x221A, 0xE090, 0x005E, 0x02C7, 0x02D8, - 0x00B4, 0x0060, 0x02DC, 0x00AF, 0x0362, 0xE099, 0xE09A, 0x20DB, 0xE09C, 0xE09D, - 0x0028, 0x0029, 0x2220, 0x22AF, 0xE0A2, 0xE0A3, 0xE0A4, 0xE0A5, 0xE0A6, 0xE0A7, - 0x002F, 0x005C, 0x274F, 0xE0AB, 0x0393, 0x0394, 0x0398, 0x039b, 0x039e, 0x03A0, - 0x03a3, 0x03a5, 0x03a6, 0x03a8, 0x03A9, 0x03B1, 0x03B2, 0x03b3, 0x03b4, 0x03b5, - 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, - 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x03b5, - 0x03d1, 0x03d6, 0xE0D2, 0x03db, 0x2118, 0x2202, 0x2129, 0xE0D7, 0xE0D8, 0x22A4, - 0xE0DA, 0x2190, 0x2191, 0x2193 - }; - if ((nIn >= 0xE080) && (nIn <= 0xE0DD)) - nIn = aStarMathPrivateToUnicode[nIn-0xE080]; - - //For whatever unicode glyph that equation editor doesn't ship with that - //we have a possible match we can munge it to. - switch (nIn) - { - case 0x2223: - nIn = '|'; - break; - default: - break; - } - - return nIn; -} - void MathType::Init() { //These are the default MathType sizes @@ -3124,7 +3091,7 @@ void MathType::HandleMath(SmNode *pNode, int /*nLevel*/) SmMathSymbolNode *pTemp=(SmMathSymbolNode *)pNode; for(xub_StrLen i=0;i<pTemp->GetText().Len();i++) { - sal_Unicode nArse = Convert(pTemp->GetText().GetChar(i)); + sal_Unicode nArse = SmTextNode::ConvertSymbolToUnicode(pTemp->GetText().GetChar(i)); if ((nArse == 0x2224) || (nArse == 0x2288) || (nArse == 0x2285) || (nArse == 0x2289)) { @@ -3364,7 +3331,7 @@ void MathType::HandleText(SmNode *pNode, int /*nLevel*/) nFace = 0x7; *pS << sal_uInt8(nFace+128); //typeface sal_uInt16 nChar = pTemp->GetText().GetChar(i); - *pS << Convert(nChar); + *pS << SmTextNode::ConvertSymbolToUnicode(nChar); //Mathtype can only have these sort of character //attributes on a single character, starmath can put them diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 17965432111d..58010e7b4485 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -2503,6 +2503,39 @@ void SmTextNode::AdjustFontDesc() } } +sal_Unicode SmTextNode::ConvertSymbolToUnicode(sal_Unicode nIn) +{ + //Find the best match in accepted unicode for our private area symbols + static const sal_Unicode aStarMathPrivateToUnicode[] = + { + 0x2030, 0xF613, 0xF612, 0x002B, 0x003C, 0x003E, 0xE425, 0xE421, 0xE088, 0x2208, + 0x0192, 0x2026, 0x2192, 0x221A, 0x221A, 0x221A, 0xE090, 0x005E, 0x02C7, 0x02D8, + 0x00B4, 0x0060, 0x02DC, 0x00AF, 0x0362, 0xE099, 0xE09A, 0x20DB, 0xE09C, 0xE09D, + 0x0028, 0x0029, 0x2220, 0x22AF, 0xE0A2, 0xE0A3, 0xE0A4, 0xE0A5, 0xE0A6, 0xE0A7, + 0x002F, 0x005C, 0x274F, 0xE0AB, 0x0393, 0x0394, 0x0398, 0x039b, 0x039e, 0x03A0, + 0x03a3, 0x03a5, 0x03a6, 0x03a8, 0x03A9, 0x03B1, 0x03B2, 0x03b3, 0x03b4, 0x03b5, + 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, + 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x03b5, + 0x03d1, 0x03d6, 0xE0D2, 0x03db, 0x2118, 0x2202, 0x2129, 0xE0D7, 0xE0D8, 0x22A4, + 0xE0DA, 0x2190, 0x2191, 0x2193 + }; + if ((nIn >= 0xE080) && (nIn <= 0xE0DD)) + nIn = aStarMathPrivateToUnicode[nIn-0xE080]; + + //For whatever unicode glyph that equation editor doesn't ship with that + //we have a possible match we can munge it to. + switch (nIn) + { + case 0x2223: + nIn = '|'; + break; + default: + break; + } + + return nIn; +} + /**************************************************************************/ void SmMatrixNode::CreateTextFromNode(String &rText) diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx index b84fd385aaa3..360489424f36 100644 --- a/starmath/source/ooxmlexport.cxx +++ b/starmath/source/ooxmlexport.cxx @@ -34,41 +34,6 @@ using namespace oox; using namespace oox::core; -// TODO duped from MathType - -static sal_Unicode Convert(sal_Unicode nIn) -{ - //Find the best match in accepted unicode for our private area symbols - static const sal_Unicode aStarMathPrivateToUnicode[] = - { - 0x2030, 0xF613, 0xF612, 0x002B, 0x003C, 0x003E, 0xE425, 0xE421, 0xE088, 0x2208, - 0x0192, 0x2026, 0x2192, 0x221A, 0x221A, 0x221A, 0xE090, 0x005E, 0x02C7, 0x02D8, - 0x00B4, 0x0060, 0x02DC, 0x00AF, 0x0362, 0xE099, 0xE09A, 0x20DB, 0xE09C, 0xE09D, - 0x0028, 0x0029, 0x2220, 0x22AF, 0xE0A2, 0xE0A3, 0xE0A4, 0xE0A5, 0xE0A6, 0xE0A7, - 0x002F, 0x005C, 0x274F, 0xE0AB, 0x0393, 0x0394, 0x0398, 0x039b, 0x039e, 0x03A0, - 0x03a3, 0x03a5, 0x03a6, 0x03a8, 0x03A9, 0x03B1, 0x03B2, 0x03b3, 0x03b4, 0x03b5, - 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, - 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x03b5, - 0x03d1, 0x03d6, 0xE0D2, 0x03db, 0x2118, 0x2202, 0x2129, 0xE0D7, 0xE0D8, 0x22A4, - 0xE0DA, 0x2190, 0x2191, 0x2193 - }; - if ((nIn >= 0xE080) && (nIn <= 0xE0DD)) - nIn = aStarMathPrivateToUnicode[nIn-0xE080]; - - //For whatever unicode glyph that equation editor doesn't ship with that - //we have a possible match we can munge it to. - switch (nIn) - { - case 0x2223: - nIn = '|'; - break; - default: - break; - } - - return nIn; -} - SmOoxmlExport::SmOoxmlExport( const String &rIn, const SmNode* pIn, OoxmlVersion v ) : str( rIn ) , pTree( pIn ) @@ -268,7 +233,7 @@ void SmOoxmlExport::HandleText( const SmNode* pNode, int /*nLevel*/) *pS << sal_uInt8(nFace+128); //typeface #endif sal_uInt16 nChar = pTemp->GetText().GetChar(i); - m_pSerializer->writeEscaped( rtl::OUString( Convert(nChar))); + m_pSerializer->writeEscaped( rtl::OUString( SmTextNode::ConvertSymbolToUnicode(nChar))); #if 0 //Mathtype can only have these sort of character @@ -454,8 +419,10 @@ void SmOoxmlExport::HandleRoot( const SmRootNode* pNode, int nLevel ) static rtl::OString mathSymbolToString( const SmNode* node ) { - OSL_ASSERT( node->GetType() == NMATH && static_cast< const SmTextNode* >( node )->GetText().Len() == 1 ); - sal_Unicode chr = Convert( static_cast< const SmTextNode* >( node )->GetText().GetChar( 0 )); + assert( node->GetType() == NMATH ); + const SmTextNode* txtnode = static_cast< const SmTextNode* >( node ); + assert( txtnode->GetText().Len() == 1 ); + sal_Unicode chr = SmTextNode::ConvertSymbolToUnicode( txtnode->GetText().GetChar( 0 )); return rtl::OUStringToOString( rtl::OUString( chr ), RTL_TEXTENCODING_UTF8 ); } |