📄 c_rtrndr.cpp
字号:
{ m_pTextWindow->incrementNumBreakTagsEncountered(); } bSomeCharsFoundSinceLastBreakTag=0L; } break; case 'C': // /XXXEH- NOTE: I discovered that this same code in textlib's // textprsr.cpp uses 5 for the second parameter of // stringCompare() which means that <clear /> works there but // not here where there can't be a bleepin' thing after the // word "clear" except a "/>". I don't want to fix that here // because that will millions of existing rtrenderers will // fail to clear when they're supposed to if authors think // that just works because they're using some "fixed" version: // format if(!stringCompare(pTagContents, tagContentsLen, "CLEAR", 5)) { //TEXTPRSR_DIFF >>: //All <clear> tags should begin a packet in live, now, // so they will have been translated to <time lc...>://XXXXXEH- HX_ASSERT(!bIsLiveSource); m_pTextWindow->m_bClearWasJustSent = TRUE; //<< END TEXTPRSR_DIFF. //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(); } 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 && //TEXTPRSR_DIFF >>: //Don't do newline if NEWLINES=0 was in pkt hdr // and we haven't seen any text since the latest // packet arrived, i.e., and we are seeing this // <CENTER> tag inside the packet header: (bStartOfPacketNewlinesIsZero || !WeAreInsidePacketOpaqueHeader()) //<< END TEXTPRSR_DIFF. ) { //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; //TEXTPRSR_DIFF >>: (but is for renderer only); this // "<DATA ID=>" gets set in TextLine's OutputPacketHeaderString() // and is the unique identifier of the data in this packet, data // which could have been sent already in a prior packet. The // renderer must decide based on this ID if it has seen this data // already and, if so, return and not parse the rest of this data: case 'D': if(tagContentsLen >= 9) //9==min length (e.g. "DATA ID=8"). { if('A' == pTagContents[1]) { if(pTagContents[2]=='T' && pTagContents[3]=='A' && pTagContents[4]==' ') { //we've found "DATA " so far... _CHAR* pLval; _CHAR* pRval; _CHAR* pRestOfData = &pTagContents[4]; ULONG32 restOfDataLen = tagContentsLen-4; 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; } _CHAR* tmpPtr = pRval; ULONG32 tokenValLen = nextValEndIndex-nextValStartIndex; BOOL bErr = FALSE; if(!stringCompare(pLval, nextTokenEndIndex - nextTokenStartIndex, "ID", 2)) { ULONG32 ulPacketDataID = 0L; //tmpPtr is always NULL-terminated // at this pt: ulPacketDataID = m_pTextWindow-> string_to_ULONG32(tmpPtr, bErr); if(!bErr) { //This function checks the list to // see if this DataID has already // been seen and, if not, it adds it // to the list: if(HaveAlreadySeenThisData( ulPacketDataID)) { //We've seen this data already, // so don't parse it again: goto cleanup; } } //else ignore the tag; is invalid DATA } //end of "if( ..."ID"...)". if(nextValEndIndex < restOfDataLen) { if(0L == nextValEndIndex) { break; //leave the do loop. } pRestOfData = &pRestOfData[nextValEndIndex+1]; restOfDataLen -= (nextValEndIndex+1); } else { restOfDataLen = 0L; } } while(restOfDataLen > 0L); } //end "DATA " tag parsing. } } break; //<< END TEXTPRSR_DIFF. case 'F': if(tagContentsLen > 5) { if(pTagContents[1]=='O' && pTagContents[2]=='N' && pTagContents[3]=='T' && pTagContents[4]==' ') { //we've found "FONT " so far... _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) && //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 char
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -