From 9a1374b54144b15cfef1a0d8eeba861a69fec875 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 13 Oct 2010 11:39:15 +0200 Subject: cws tl84: #i114767# Math: added option to save only used symbols --- starmath/inc/parse.hxx | 80 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 32 deletions(-) mode change 100644 => 100755 starmath/inc/parse.hxx (limited to 'starmath/inc/parse.hxx') diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx old mode 100644 new mode 100755 index facf17d561e2..4c672df058ce --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -33,11 +33,16 @@ #include #include +#include +#include +#include + #include "types.hxx" class SmNode; class SmDocShell; +////////////////////////////////////////////////////////////////////// // TokenGroups #define TGOPER 0x00000001 @@ -113,17 +118,18 @@ enum SmTokenType struct SmToken { - // token text - String aText; - // token info - SmTokenType eType; + + String aText; // token text + SmTokenType eType; // token info sal_Unicode cMathChar; + // parse-help info - ULONG nGroup; - USHORT nLevel; + ULONG nGroup; + USHORT nLevel; + // token position - USHORT nRow; - xub_StrLen nCol; + USHORT nRow; + xub_StrLen nCol; SmToken(); }; @@ -152,6 +158,7 @@ struct SmErrorDesc String Text; }; + DECLARE_STACK(SmNodeStack, SmNode *) DECLARE_LIST(SmErrDescList, SmErrorDesc *) @@ -170,19 +177,22 @@ enum SmConvert class SmParser { - String BufferString; - SmToken CurToken; - SmNodeStack NodeStack; - SmErrDescList ErrDescList; - int CurError; - LanguageType nLang; - xub_StrLen BufferIndex, - nTokenIndex; - USHORT Row, - ColOff; - SmConvert eConversion; - BOOL bImportSymNames, - bExportSymNames; + String m_aBufferString; + SmToken m_aCurToken; + SmNodeStack m_aNodeStack; + SmErrDescList m_aErrDescList; + int m_nCurError; + LanguageType m_nLang; + xub_StrLen m_nBufferIndex, + m_nTokenIndex; + USHORT m_Row, + m_nColOff; + SmConvert m_eConversion; + BOOL m_bImportSymNames, + m_bExportSymNames; + + // map of used symbols (used to reduce file size by exporting only actually used symbols) + std::set< rtl::OUString > m_aUsedSymbols; // declare copy-constructor and assignment-operator private SmParser(const SmParser &); @@ -193,7 +203,7 @@ protected: BOOL IsDelimiter( const String &rTxt, xub_StrLen nPos ); #endif void NextToken(); - xub_StrLen GetTokenIndex() const { return nTokenIndex; } + xub_StrLen GetTokenIndex() const { return m_nTokenIndex; } void Insert(const String &rText, USHORT nPos); void Replace( USHORT nPos, USHORT nLen, const String &rText ); @@ -231,37 +241,43 @@ protected: void GlyphSpecial(); // end of grammar - LanguageType GetLanguage() const { return nLang; } - void SetLanguage( LanguageType nNewLang ) { nLang = nNewLang; } + LanguageType GetLanguage() const { return m_nLang; } + void SetLanguage( LanguageType nNewLang ) { m_nLang = nNewLang; } void Error(SmParseError Error); + void ClearUsedSymbols() { m_aUsedSymbols.clear(); } + void AddToUsedSymbols( const String &rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); } + public: SmParser(); SmNode *Parse(const String &rBuffer); - const String & GetText() const { return BufferString; }; + const String & GetText() const { return m_aBufferString; }; - SmConvert GetConversion() const { return eConversion; } - void SetConversion(SmConvert eConv) { eConversion = eConv; } + SmConvert GetConversion() const { return m_eConversion; } + void SetConversion(SmConvert eConv) { m_eConversion = eConv; } - BOOL IsImportSymbolNames() const { return bImportSymNames; } - void SetImportSymbolNames(BOOL bVal) { bImportSymNames = bVal; } - BOOL IsExportSymbolNames() const { return bExportSymNames; } - void SetExportSymbolNames(BOOL bVal) { bExportSymNames = bVal; } + BOOL IsImportSymbolNames() const { return m_bImportSymNames; } + void SetImportSymbolNames(BOOL bVal) { m_bImportSymNames = bVal; } + BOOL IsExportSymbolNames() const { return m_bExportSymNames; } + void SetExportSymbolNames(BOOL bVal) { m_bExportSymNames = bVal; } USHORT AddError(SmParseError Type, SmNode *pNode); const SmErrorDesc * NextError(); const SmErrorDesc * PrevError(); const SmErrorDesc * GetError(USHORT i = 0xFFFF); + + bool IsUsedSymbol( const String &rSymbolName ) const { m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); } + std::set< rtl::OUString > GetUsedSymbols() const { return m_aUsedSymbols; } }; inline BOOL SmParser::TokenInGroup(ULONG nGroup) { - return (CurToken.nGroup & nGroup) ? TRUE : FALSE; + return (m_aCurToken.nGroup & nGroup) ? TRUE : FALSE; } -- cgit From c7e862d6a588a4828213a09d69da8c1120c469b5 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 10 Dec 2010 09:13:28 +0100 Subject: cws tl84: warning-free code --- starmath/inc/parse.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'starmath/inc/parse.hxx') diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index 4c672df058ce..e30193490539 100755 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -270,7 +270,7 @@ public: const SmErrorDesc * PrevError(); const SmErrorDesc * GetError(USHORT i = 0xFFFF); - bool IsUsedSymbol( const String &rSymbolName ) const { m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); } + bool IsUsedSymbol( const String &rSymbolName ) const { return m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); } std::set< rtl::OUString > GetUsedSymbols() const { return m_aUsedSymbols; } }; -- cgit