📄 textprsr.cpp
字号:
//Don't use if color already pushed: !(ulCurrentStacksPushed & FONT_COLOR)) { COLORTYPE colortype_retVal; BOOL isAValidColor = FALSE; if(tokenValLen >= 1 && '#'==tmpPtr[0] || (tokenValLen>=2 && '\"'==tmpPtr[0] && '#'==tmpPtr[1]) ) { //Color was presented as "#RRGGBB" in hex: isAValidColor = convertColorValStringToCOLORTYPE( tmpPtr, tokenValLen, colortype_retVal); } // Returns FALSE if colorName contains an // unrecognized color: else { //Color was named, e.g., "darkblue": isAValidColor = convertColorNameToCOLORTYPE( tmpPtr, tokenValLen, colortype_retVal); } if(isAValidColor) { //Is A legal color name, so push it on stack: m_pTextWindow->pushTextColorStack( colortype_retVal, FALSE); ulCurrentStacksPushed |= FONT_COLOR; //Added the following to see // if we're inside an <A> tag so that we can // properly back out font colors after hyperlink // text is done: if(m_pTextWindow->hasValidURL()) { m_pTextWindow-> incrementNumberOfFontColorPushesInsideLinkText(); } } //else ignore the tag; is invalid color. } //end of "else if( ..."COLOR" ...)". else if(!stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "BGCOLOR", 7) && //Don't use if bgcolor already pushed: !(ulCurrentStacksPushed & FONT_BGCOLOR)) { COLORTYPE colortype_retVal; BOOL isAValidColor = FALSE; if(tokenValLen >= 1 && '#'==tmpPtr[0] || (tokenValLen>=2 && '\"'==tmpPtr[0] && '#'==tmpPtr[1]) ) { //Color was presented as "#RRGGBB" in hex: isAValidColor = convertColorValStringToCOLORTYPE( tmpPtr, tokenValLen, colortype_retVal); } // Returns FALSE if colorName contains an // unrecognized color: else { //Color was named, e.g., "darkblue": isAValidColor = convertColorNameToCOLORTYPE( tmpPtr, tokenValLen, colortype_retVal); } if(isAValidColor) { //Is A legal color name, so push it on stack: m_pTextWindow->pushTextBackgroundColorStack( colortype_retVal, FALSE); ulCurrentStacksPushed |= FONT_BGCOLOR; } //else ignore the tag; is invalid color. } //end of "else if( ..."BGCOLOR" ...)". else if(!stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "CHARSET", 7) && tokenValLen>1 && //Don't use if charset already pushed: !(ulCurrentStacksPushed & FONT_CHARSET)) { // Returns FALSE if tmpPtr contains an // unrecognized charset: ULONG32 ulCharset_retVal = CHARSET__default; if('\"' == tmpPtr[0]) { tmpPtr=tmpPtr+1; tokenValLen--; } if('\"' == tmpPtr[tokenValLen-1]) { tokenValLen--; } if (HXR_OK == convertCharsetNameToCharsetULONG32( tmpPtr, tokenValLen, REALTEXT_MAX_CHARSET_LEVEL_SUPPORTED, ulCharset_retVal)) { //Is a legal charset name, so push it on stack: m_pTextWindow->pushFontCharsetStack( ulCharset_retVal, FALSE); ulCurrentStacksPushed |= FONT_CHARSET; } //else ignore the tag; is invalid charset. } //end of "else if( ..."CHARSET" ...)". //Added this else-if to handle // font "faces", e.g., "helvetica": else if( (!stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "FACE", 4) || !stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "NAME", 4) ) && tokenValLen>1 && //Don't use if face has already been pushed: !(ulCurrentStacksPushed & FONT_FACE) ) { //XXXEH- Replace the // following hack with a function to do this: {//hack start: if('\"' == tmpPtr[0]) { tmpPtr=tmpPtr+1; tokenValLen--; } if('\"' == tmpPtr[tokenValLen-1]) { tmpPtr[tokenValLen-1] = '\0'; tokenValLen--; } tmpPtr[tokenValLen] = '\0'; ///convertToUpperCase(tmpPtr, tokenValLen); { //Is an allowed font face name, so push it on // the stack: ULONG32 faceIndx = getFontFaceIndexFromString( tmpPtr, tokenValLen, m_pTextWindow-> getMajorContentVersion(), m_pTextWindow-> getMinorContentVersion() ); m_pTextWindow->pushFontFaceStack( faceIndx); ulCurrentStacksPushed |= FONT_FACE; } }//hack end. } //end of "else if( ..."FACE" ...)". if(nextValEndIndex < restOfDataLen) { if(0L == nextValEndIndex) { break; //leave the do loop. } pRestOfData = &pRestOfData[nextValEndIndex+1]; restOfDataLen -= (nextValEndIndex+1); } else { restOfDataLen = 0L; } } while(restOfDataLen > 0L); //The following code sets up the // font stack to keep track of ALL parameters // pushed in the above do-while loop so that a // subsequent </FONT> can pop all involoved stacks // simultaneously: if(0L != ulCurrentStacksPushed) { m_pTextWindow->pushFontStack( ulCurrentStacksPushed); //C_RTRNDRDIFF >>: //Added this to keep track of location in file of // every FONT tag so, when forming a packet, it // can be determined where the matching <FONT> // for each </FONT> is and, for each </FONT> // whose matching <FONT> is in a prior packet, // we can prepend an appropriate <FONT> tag in // the packet's header: m_pTextWindow->pushFontTagStartByteInFileStack( ulByteOffsetIntoFile+indexOfLeftBracket); //<< END C_RTRNDRDIFF. } } //end of "if(pTagContents[1]==...) <==i.e., if "FONT". } //C_RTRNDRDIFF >>: // /Don't document this until it gets QA'd: // In non-live scenarios, you don't want to do most of these: // /This allows live-text author to blow away all state // information without having to use closing tags for // every yet-unclosed tag so far. This allows a memory- // build-up problem to be controlled by the author in // the case where they've sent a lot of open tags but // haven't kept track of what needs closing. Syntax // is flush="all" or flush="tags". "tags" clears out all // font, bold, ...etc. stacks. "all" does that and also // clears out other structures like savedPacketDataList: if (!bIsFontTag && tagContentsLen >= 5 && !stringCompare(pTagContents, 5, "FLUSH", 5) && /* bIsLiveSource && */ isspace(pTagContents[5])) { UINT32 ui = tagContentsLen - 5; _CHAR* pFlushTarget = strstr(&pTagContents[6], "TARGET"); if (pFlushTarget) { _CHAR* pTmp = &pFlushTarget[6]; if (pTmp) { while (isspace(*pTmp)) { pTmp++; ui--; } if ('=' == *pTmp) { *pTmp++; ui--; while (isspace(*pTmp)) { pTmp++; ui--; } if ('\"' == *pTmp) { pTmp++; ui--; while (isspace(*pTmp)) { pTmp++; ui--; } if (*pTmp) { // /Flags are: // / 0x1 =font stacks // / 0x2 =ticker stacks // / 0x4 =bold, Italics, // / underlined, strikethrough // / 0x8 =indent amount stacks // / 0x10=TextContainerList // / 0x20=TextLineList (m_pTLList) ULONG32 ulFlags = 0x0; ULONG32 ulTmpLen = (ULONG32)strlen(pTmp); if (ui>=3 && !stringCompare(pTmp, 3, "all", 3)) { m_pTextWindow->reset(); ulFlags = 0xFFFFFFFF; } else if (ulTmpLen>=4 && *pTmp && !stringCompare(pTmp, 4, "tags", 4)) { ulFlags |= 0x00000007; } if ( (ulFlags & 0x00000001) || (ulTmpLen>=8 && *pTmp && !stringCompare(pTmp, 8, "fontTags", 8)) ) { m_pTextWindow-> TextAttributeStacks:: flushFontStacks(); m_pTextWindow-> m_pFontUndoTagList-> flush(); ulFlags |= 0x00000001; } if ( (ulFlags & 0x00000002) || (ulTmpLen>=10 && *pTmp && !stringCompare(pTmp, 10, "tickerTags", 10)) ) { m_pTextWindow-> TextAttributeStacks:: flushTickerStacks(); ulFlags |= 0x00000002; } if ( (ulFlags & 0x0000004) || (ulTmpLen>=4 && *pTmp && !stringCompare(pTmp, 4, "bius", 4)) ) { m_pTextWindow-> TextAttributeStacks:: flushBIUSandBlinkStacks(); ulFlags |= 0x00000004; } if ( (ulFlags & 0x00000008) || (ulTmpLen>=6 && *pTmp && !stringCompare(pTmp, 6, "indent", 6)) ) { m_pTextWindow-> TextAttributeStacks:: flushIndentAmtStack(); ulFlags |= 0x00000008; } if ( (ulFlags & 0x00000010) || (ulTmpLen>=8 && *pTmp && !stringCompare(pTmp, 8, "wordList", 8)) ) { m_pTextWindow-> TextContainerList::flush(); ulFlags |= 0x00000010; } if ( (ulFlags & 0x00000020) || (ulTmpLen>=8 && *pTmp && !stringCompare(pTmp, 8, "lineList", 8)) ) { m_pTextWindow->m_pTLList->flush(); ulFlags |= 0x00000020; } } } } } } } //<< END C_RTRNDRDIFF. break; } // /End case 'F'. case 'H': //Added the following to allow better // handling of HTML text imported as RealText: //XXXEH- for now, treat as 2 line breaks, but in future, // also draw a line (horizontal rule): if(!stringCompare(pTagContents, tagContentsLen, "HR", 2)) { //Added the surrounding if() so that // this code doesn't get called if horizontal motion: if(m_pTextWindow->getCrawlRate() == 0 || m_pTextWindow->getScrollRate() != 0) { //If we got <pos ..>x<hr/>, where "x" contains no // plain text (other than spaces, tabs, newlines), // then don't do a line break at all, but rather // update the NewPktStartYAtTimeZero() value: if(bUserPosTagFoundSinceLastTextContainer && !bSomeCharsFoundSinceLastPosTag) { LONG32 lCurY = m_pTextWindow-> GetNewPktStartYAtTimeZero(); HX_ASSERT(INVALID_LONG32 != lCurY); m_pTextWindow-> SetNewPktStartYAtTimeZero( lCurY + (2*DEFAULT_LINE_BREAK_SIZE)); } else { m_pTextWindow->incrementNumBreakTagsEncountered(); m_pTextWindow->incrementNumBreakTagsEncountered(); } bSomeCharsFoundSinceLastBreakTag=0L; } } case 'I': if(!stringCompare(pTagContents, tagContentsLen, "I", 1)) //start of italics tag { m_pTextWindow->pushIsItalicizedStack(TRUE); } break; case 'L': if(!stringCompare(pTagContents, tagContentsLen, "LOOP", 4)) { m_pTextWindow->loop(TRUE); } //Added the following to allow better // handling of HTML text imported as RealText: //XXXEH- for now, treat as line break tag, but in future, // add indent based on depth of nested ULs and OLs: else if(!stringCompare(pTagContents, tagContentsLen, "LI", 2)) { //Added the surrounding if() so that // this code doesn't get called if horizontal motion: if(m_pTextWindow->getCrawlRate() == 0 || m_pTextWindow->getScrollRate() != 0) { //If we got <pos ..>x<center>, where "x" contains // no plain text (other than spaces, tabs, // newlines), then don't do a line break at all: if(bUserPosTagFoundSinceLastTextContainer && !bSomeCharsFoundSinceLastPosTag) { ; } else { m_pTextWindow-> incrementNumBreakTagsEncountered(); } bSomeCharsFoundSinceLastBreakTag=0L; } } break; case 'O': //Added the following to allow better // handling of HTML text imported as RealText: //X
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -