📄 textprsr.cpp
字号:
} //end "while(tempLen > 0)". //Now, for PRE tag newlines found after pTC's text, increment // the num newlines to perform on the next TC: if(ulNumPREtagNewlineCharsFound) { for(ULONG32 ix=0L; ix<ulNumPREtagNewlineCharsFound; ix++) { m_pTextWindow->incrementNumBreakTagsEncountered(); } ulNumPREtagNewlineCharsFound = 0L; } if(-1 == indexOfLeftBracket || -1 == indexOfRightBracket) { break; //We're done with pData. } if(bIgnoringNewlineChars || bDealingWithTabCharWithPre) { bIgnoringNewlineChars = bDealingWithTabCharWithPre = FALSE; startIndex = indexOfRightBracket+1;//where next tag-search starts if(startIndex >= len) { break; } continue; } pData_CHAR[indexOfLeftBracket] = '<'; //retore the char. //Now, find out what's in the markup tag, first temporarily // NULL-terminating it where the tag ends, then converting it // to uppercase: pData_CHAR[indexOfRightBracket] = '\0'; _CHAR* pTagContents = &pData_CHAR[indexOfLeftBracket+1]; ULONG32 tagContentsLen = indexOfRightBracket-indexOfLeftBracket-1; if(bSlashFoundAtEndOfTag) //XML-style end-of-tag "/" was found: { tagContentsLen--; } convertToUpperCase(pTagContents, tagContentsLen); switch(pTagContents[0]) { case '/': //tag is the end of a binary tag, e.g. "</B>": { if(tagContentsLen > 1) { HandleEndTag(pTagContents, tagContentsLen, bSomeCharsFoundSinceLastBreakTag, bSomeCharsFoundSinceLastPosTag, bUserPosTagFoundSinceLastTextContainer, //C_RTRNDRDIFF >> ulByteOffsetIntoFile, indexOfLeftBracket, indexOfRightBracket, bFileFormatIsCallingThis); //<< END C_RTRNDRDIFF. }//end "if(tagContentsLen > 1)". }//end "case '/':" break; case 'A': if(tagContentsLen > 2) { if(' '==pTagContents[1]) { //we've found "A " so far... _CHAR* pLval; _CHAR* pRval; _CHAR* pRestOfData = &pTagContents[2]; ULONG32 restOfDataLen = tagContentsLen-2; ULONG32 nextTokenStartIndex, nextTokenEndIndex; ULONG32 nextValStartIndex, nextValEndIndex; do { if(GetNextTokenLvalueRvaluePair(pRestOfData, restOfDataLen, nextTokenStartIndex, nextTokenEndIndex, nextValStartIndex, nextValEndIndex) ) { pLval = &pRestOfData[nextTokenStartIndex]; pRestOfData[nextTokenEndIndex]='\0'; pRval = &pRestOfData[nextValStartIndex]; pRestOfData[nextValEndIndex]='\0'; } else { break; } if(!stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "HREF", 4) && nextValEndIndex-nextValStartIndex > 0L) { m_pTextWindow->setURL(pRval, nextValEndIndex-nextValStartIndex);/* C_RTRNDRDIFF: Don't do this at File Format side -- sending the <A > tag will be enough for the renderer to know the <U> and <FONT color=> information it needs; (we don't want this duplicated in the packet header now that packet headers include <A > tags): //Added the following to set // the text that follows to the hyperlink color: m_pTextWindow->pushTextColorStack( m_pTextWindow->getLinkColor(), TRUE); m_pTextWindow->setNumberOfFontColorPushesInsideLinkText(0L); if(m_pTextWindow->usingUnderlineHyperlinks()) { m_pTextWindow->pushIsUnderlinedStack(TRUE); }*/ } else if(!stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "TARGET", 6)) { //Redo this in case it was in quotes: convertToUpperCase(pRval, nextValEndIndex-nextValStartIndex); if(!stringCompare(pRval, nextValEndIndex-nextValStartIndex, "_PLAYER", 7)) { m_pTextWindow->setTargetOfURL( URL_TARGET_PLAYER); } else if(!stringCompare(pRval, nextValEndIndex-nextValStartIndex, "_BROWSER", 7)) { m_pTextWindow->setTargetOfURL( URL_TARGET_BROWSER); } else { m_pTextWindow->setTargetOfURL( URL_TARGET_INVALID); } } if(nextValEndIndex < restOfDataLen) { if(0L == nextValEndIndex) { break; //leave the do loop. } pRestOfData = &pRestOfData[nextValEndIndex+1]; restOfDataLen -= (nextValEndIndex+1); } else { restOfDataLen = 0L; } } while(restOfDataLen > 0L); } } break; case 'B': if(!stringCompare(pTagContents, tagContentsLen, "B", 1)) //start of bold tag { m_pTextWindow->pushIsBoldStack(TRUE); } //or maybe a line break tag: else if(!stringCompare(pTagContents, tagContentsLen, "BR", 2)) { //If we got <pos ..>x<br/>, 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 + DEFAULT_LINE_BREAK_SIZE); } else { m_pTextWindow->incrementNumBreakTagsEncountered(); } bSomeCharsFoundSinceLastBreakTag=0L; } break; case 'C': if (tagContentsLen>=5 && !stringCompare(pTagContents, 5, "CLEAR", 5)) { // /ONLY do the following if it's live: if (bIsLiveSource) { // /These are needed for seeking in non-live case, // but in live they just cause a memory build-up // without any benefit. ULONG32 numTextLinesDeleted = m_pTextWindow->m_pTLList->flush(); // /These are needed up to the point where the clear // tag's begin time is effective, and, in non-live, // you can have a clear tag in the middle of a packet // and we don't want to remove the text that precedes // it if that text is valid now and if the clear has // a begin time that is currently in the future. ULONG32 numTextContainersDeleted = m_pTextWindow->TextContainerList::flush(); } m_pTextWindow->m_bClearWasJustSent = TRUE; //XXXEH- moved this out of txtwindw.cpp's // insertAtEndOfList() so, if "<BR/><CLEAR>foo" is seen, // the <BR/> will be ignored, but if <CLEAR><BR/>foo" is // seen, the <BR/> will be honored: m_pTextWindow->clearNumBreakTagsEncountered(); m_pTextWindow->setTimeOfLastClearTag();//#error:XXXXXEH- if isLiveSource, return and start a new pkt here!! } else if(!stringCompare(pTagContents, tagContentsLen, "CENTER", 6)) { m_pTextWindow->pushIsCenteredStack(TRUE); //Do a line break, but only if 0 line breaks so far, // and not if there is no raw text yet, i.e., not if // this <CENTER> tag starts the data part of the file, // nor if a <CLEAR> tag was just sent: if(!m_pTextWindow->getNumBreakTagsEncountered() && !m_pTextWindow->m_bClearWasJustSent && m_pTextWindow->size()>0L) { //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 'F': { BOOL bIsFontTag = FALSE; if(tagContentsLen > 5) { if(pTagContents[1]=='O' && pTagContents[2]=='N' && pTagContents[3]=='T' && pTagContents[4]==' ') { //we've found "FONT " so far... bIsFontTag = TRUE; _CHAR* pLval; _CHAR* pRval; _CHAR* pRestOfData = &pTagContents[5]; ULONG32 restOfDataLen = tagContentsLen-5; ULONG32 nextTokenStartIndex, nextTokenEndIndex; ULONG32 nextValStartIndex, nextValEndIndex; //Added the following variable to // keep track of all attributes that get pushed in // the following do loop so that the fontStack can // tell us what to do with a subsequent </FONT> tag; // E.g., "<FONT size=+2 color=red>" could get parsed // below and we need to keep track of the fact that // +2 and red were pushed on their respective stacks // at the same time so that a subsequent </FONT> can // force a pop of BOTH the size and the color stacks: ULONG32 ulCurrentStacksPushed = 0L; do { if(GetNextTokenLvalueRvaluePair(pRestOfData, restOfDataLen, nextTokenStartIndex, nextTokenEndIndex, nextValStartIndex, nextValEndIndex) ) { pLval = &pRestOfData[nextTokenStartIndex]; pRestOfData[nextTokenEndIndex]='\0'; pRval = &pRestOfData[nextValStartIndex]; pRestOfData[nextValEndIndex]='\0'; } else { break; } _CHAR* tmpPtr = pRval; ULONG32 tokenValLen = nextValEndIndex-nextValStartIndex; if(!stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "SIZE", 4) && //Don't use if size already pushed: !(ulCurrentStacksPushed & FONT_SIZE)) { LONG32 lTmp = 0L; if(1L == tokenValLen) { _CHAR ch = tmpPtr[0]; if(ch >= '0' && ch <= '9') { lTmp = LONG32(ch - '0'); if(!lTmp) { lTmp = 1L; } else if(lTmp > 7L) { lTmp = 7L; } } } //"+0" exists so default val could be had // without using </FONT> to get back to it: if(lTmp==3L || !stringCompare(tmpPtr, tokenValLen, "+0", 2)) { m_pTextWindow->pushFontPointSizeStack( DEFAULT_FONT_PTSIZE, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(lTmp==4L || !stringCompare(tmpPtr, tokenValLen, "+1", 2)) { m_pTextWindow->pushFontPointSizeStack( FONT_SIZE_PLUS1, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(lTmp==5L || !stringCompare(tmpPtr, tokenValLen, "+2", 2)) { m_pTextWindow->pushFontPointSizeStack( FONT_SIZE_PLUS2, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(lTmp==6L || !stringCompare(tmpPtr, tokenValLen, "+3", 2)) { m_pTextWindow->pushFontPointSizeStack( FONT_SIZE_PLUS3, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(lTmp==7L || !stringCompare(tmpPtr, tokenValLen, "+4", 2)) { m_pTextWindow->pushFontPointSizeStack( FONT_SIZE_PLUS4, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(lTmp==2L || !stringCompare(tmpPtr, tokenValLen, "-1", 2)) { m_pTextWindow->pushFontPointSizeStack( FONT_SIZE_MINUS1, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(lTmp==1L || !stringCompare(tmpPtr, tokenValLen, "-2", 2) ) { m_pTextWindow->pushFontPointSizeStack( FONT_SIZE_MINUS2, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(tokenValLen>=2) { INT32 i = atoi(tmpPtr); if(i < -2) { m_pTextWindow-> pushFontPointSizeStack( FONT_SIZE_MINUS2, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } else if(i > 4) { m_pTextWindow-> pushFontPointSizeStack( FONT_SIZE_PLUS4, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } //this "else" should only get entered // if "-0" was seen; we have to push // something for each <FONT> tag so that // the next </FONT> tag doesn't cause // an erroneous pop of the prior <FONT> // tag's push: else { m_pTextWindow-> pushFontPointSizeStack( DEFAULT_FONT_PTSIZE, FALSE); ulCurrentStacksPushed |= FONT_SIZE; } } } //end of "else if( ..."SIZE" ...)". else if(!stringCompare(pLval, nextTokenEndIndex-nextTokenStartIndex, "COLOR", 5) &&
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -