⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c_rtrndr.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	    HX_ASSERT(pTC);	    if(!pTC)	    {		if (bDataCHARwasAllocd  &&  pData_CHAR)		{		    delete [] pData_CHAR;		}		return; //mem alloc error occurred, so quit.	    }	    //TEXTPRSR_DIFF >>:	    //We've seen some text since the packet header so we can deal	    // with <CENTER> and other tags properly, knowing that any such	    // tags we see from here on in the packet are NOT in this	    // packet's opaque data's header:	    SetWeAreInsidePacketOpaqueHeader(FALSE);	    //<< END TEXTPRSR_DIFF.	    pTC->setNumNewlinesAtStart(		    m_pTextWindow->getNumBreakTagsEncountered());	    m_pTextWindow->clearNumBreakTagsEncountered();	    //TEXTPRSR_DIFF >>:	    bStartOfPacketNewlinesIsZero=FALSE;	    //Added this so wordwrap calculating could be	    // removed from the renderer end; the FF now sends "<WR>"s	    // whenever the text that follows starts a new line due to	    // wordwrapping (as calculated by the file format in a	    // platform-independent way):	    pTC->isWordWrapNewLine(bIsWordWrapNewLine);	    bIsWordWrapNewLine = FALSE;	    //<< END TEXTPRSR_DIFF.	    //This has to be kept track of because insertAtEndOfList(),	    // below, resets m_bClearWasJustSent to FALSE:	    BOOL bClearWasJustSent = m_pTextWindow->m_bClearWasJustSent;	    BOOL bRenderTimeIsSameOrMoreRecent =		    IsTimeASameOrMoreRecentThanTimeB(		    m_pTextWindow->GetLatestSentTimeToRender(),		    m_pTextWindow->GetLatestSentTimeToStopRendering(),		    bIsLiveSource);	    //Reset the current endtime so all text	    // that follows a <CLEAR> has an endtime equal to that of	    // the end of the stream:	    if(bClearWasJustSent		    //This fixes a bug where the author wanted something		    // to end at a certain time after the <CLEAR> but		    // couldn't without a <time> tag after the <CLEAR>,		    // e.g., "<time start=10 end=20><CLEAR>foo" should		    // behave as follows: foo appears at 10 seconds and		    // goes away at 20; however:		    // "<time end=10>blah <time start=10><CLEAR>foo" should		    // have blah appear up to 10 seconds and foo appear from		    // 10 seconds until the end of the stream (or until the		    // next CLEAR tag's start time).		    &&  bRenderTimeIsSameOrMoreRecent)	    {		//If liveSource, start time of stream may not be at time 0		// and ULONG_MAX may be *earlier* than cur time (since time		// val is ULONG32 and may wrap); we want to set this to		// "infinity" (which is 0xfffffffe):		m_pTextWindow->SetLatestSentTimeToStopRendering(			(ULONG32)ULONG_MAX);		if(bIsLiveSource)		{		    m_pTextWindow->SetLatestSentTimeToStopRendering(			    TIME_INFINITY);		}	    }	    //Set begin and end render times of this new TextContainer	    //  to the begin/end values of the most recent <TIME ..> tag:           pTC->setBeginTime(                   m_pTextWindow->GetLatestSentTimeToRender());           pTC->setEndTime(                   m_pTextWindow->GetLatestSentTimeToStopRendering());	   if(m_pTextWindow->hasValidURL())	    {		pTC->copyIntoHrefBuf(m_pTextWindow->getURL(),			m_pTextWindow->getLenURLbuf(),			m_pTextWindow->getTargetOfURL() );	    }	    m_pTextWindow->setTextAttributesToTopsOfStacksVals(*pTC);	    	    if(bDealingWithTabCharWithPre  &&		    !bSomeCharsFoundSinceLastBreakTag)	    {		//If all we've got is a tab char in the TC, don't		// paint any bg color:		pTC->setTextBackgroundColor(DEFAULT_TEXT_BGCOLOR);	    }	    //TEXTPRSR_DIFF >>:	    // Do this first since insertAtEndOfList() checks time of last	    // clear to see if it should pay attention to the POS tag or not:	    if(bClearWasJustSent)	    {#if defined(XXXEH_TESTING_DATAURLPLAINTEXT_HANDLING)FILE* f1 = ::fopen("c:\\LogDataURLhandling.txt", "a+");::fprintf(f1, "\tOnData(), TimeOfLastClearTag was set\n");::fclose(f1);#endif		m_pTextWindow->setTimeOfLastClearTag();	    }	    //<< END TEXTPRSR_DIFF:	    bUserPosTagFoundSinceLastTextContainer = FALSE;	    //2nd parameter, "TRUE", means this is being called from within	    // the renderer's code (and not from live (rtlive) or the	    // file format (rtffplin):	    if(!m_pTextWindow->insertAtEndOfList(pTC,		    //TEXTPRSR_DIFF:		    TRUE,		    // /In plain text, handling word wrap and tabs means that		    // x y[tab] will be broken into "x " and "y" and tab		    // should *not* be applied to space between "x " and "y":		    bNextTabInPlainTextIsAfterNextWhitespaceChar?		    FALSE : bDealingWithTabCharWithPre) )	    {		delete pTC;	    }	    else	    {		//TEXTPRSR_DIFF >>:		//Convert to proper chars if charset is incosistent with OS,		// but only with new content; don't "break" old content		// --(XXXEH!?).  Also: XXXEH: docs need updating: version="1.2"		if(m_pTextWindow->getMajorContentVersion() >			REAL_TEXT_MAC_CHARSET_HANDLING_CONTENT_MAJOR_VERSION			||			(m_pTextWindow->getMajorContentVersion() ==			REAL_TEXT_MAC_CHARSET_HANDLING_CONTENT_MAJOR_VERSION			&&			m_pTextWindow->getMinorContentVersion() >=			REAL_TEXT_MAC_CHARSET_HANDLING_CONTENT_MINOR_VERSION)			)		{		    pTC->ConvertNativeCharsetChars(TRUE /* in renderer.*/,			    REALTEXT_MAX_CHARSET_LEVEL_SUPPORTED);		}		//Make sure packet-start "<..NEWLINES=..>" is erased for all		// subsequent TextContainers in this packet that get inserted		// into the list:		m_pTextWindow->SetNumNewlinesStatedInPacketHeader(0L);		//Don't adjust start time if looping because it will be		// later than it should be if some looping has already		// happened (which means *this's x,y at time 0 are higher		// than their original vals, on which "adjustStart...()"		// depends):		if(!m_pTextWindow->isLooping())		{		//<< END TEXTPRSR_DIFF:		    //Added this to adjust start & end times based on visibility		    // in window, e.g., the start time of		    // pTC might be 0 but it doesn't scroll into the window		    // until 4300msec, so this calculates and adjusts to that:		    BOOL bShouldNeverBeFalse =			    pTC->adjustStartAndEndTimes(m_pTextWindow);		    HX_ASSERT(bShouldNeverBeFalse);		//TEXTPRSR_DIFF >>:		}		//<< END TEXTPRSR_DIFF.				if(m_pTextWindow->isLooping()			//TEXTPRSR_DIFF >>:			&&  pTC->getEndTime() )	//XXXEH- Why not in FF???			//<< END TEXTPRSR_DIFF.		{		    //We don't want to use the end time calculated in 		    // adjustStartAndEndTimes() above because looping means		    // the end time may be "infinite" since it could loop		    // "forever"; however, if there is an active <TIME end=t>		    // tag, use t instead of "infinity".		    // NOTE: as soon as another CLEAR tag is seen, this		    // T.C.'s endTime will be reset to time of the CLEAR:		    pTC->setEndTime(m_pTextWindow->			    GetLatestSentTimeToStopRendering());		}		if(bIsLiveSource  &&  TIME_INVALID == pTC->getEndTime())		{		    //Make end time be "infinity":		    pTC->setEndTime(TIME_INFINITY);		}		//Moved this from below "CLEAR" parsing		// code so that the adjustment would be made after the pTC's		// official start time is known:		if(bClearWasJustSent)		{		    ULONG32 ulTmpStartTime = pTC->getStartTime();		    ULONG32 ulTmpEndTime = pTC->getEndTime();		    m_pTextWindow->SetLatestSentTimeToRender(ulTmpStartTime);		    //	is just after a <CLEAR> tag, so clear everything in		    //	TextContainerList whose m_endTime is greater		    //	than the latestSentTimeToRender:		    m_pTextWindow->MarkAllForClear(  //(the T.C.List version)			    bIsLiveSource);		    //Now, since pTC is already inserted in the T.C.List, its		    // endTime may have been adjusted in MarkAllForClear(),		    // so let's restore it:		    pTC->setStartTime(ulTmpStartTime);		    pTC->setEndTime(ulTmpEndTime);		    m_pTextWindow->setTimeOfLastClearTag();		    //follows a CLEAR tag but has no "newlines" before it,		    // so we can't set num newlines to non-zero, so this		    // tells us we've started a newline with no prior spacing		    pTC->isFakeNewLine(TRUE);		}		//TEXTPRSR_DIFF >>: (but is for renderer only):		//These are needed so we can figure out how much looping has		// occured since the last <CLEAR> tag became effective (NOT		// when the <CLEAR> was parsed, i.e., NOW, which is probably		// earlier):		pTC->setTimeOfLastClearTag(			m_pTextWindow->getTimeOfLastClearTag());		//<< END TEXTPRSR_DIFF.	    }	} //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,			    //TEXTPRSR_DIFF >>:			    //these 3 are ignored by HandleEndTag() if we're			    // calling this from renderer:			    0L, 0L, 0L,			    //FALSE means we're calling this function from renderer,			    // (not from file format or live encoder):			    FALSE);			    //<< END TEXTPRSR_DIFF.		}//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);				//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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -