📄 rpfilobj.cpp
字号:
// Output images for (itr = m_cImageList.Begin(); itr != m_cImageList.End(); itr++) { CIMFImage *pImage = (CIMFImage *) *itr; pImage->RenderText(rText); rText += "\r\n "; } rText += "\r\n "; // Output effects for (itr = m_cEffectList.Begin(); itr != m_cEffectList.End(); itr++) { CIMFEffect *pEffect = (CIMFEffect *) *itr; pEffect->RenderText(rText); rText += "\r\n "; } rText += "\r\n"; rText += m_pszIMFEndTag; rText += "\r\n";}HX_RESULT CIMFFileObject::InitImageUseFlags(){ // If no effects, then no work to do if (m_cEffectList.Size() == 0) { return HXR_OK; } // Loop through effects setting first and last use flags GListIterator itr1; for (itr1 = m_cEffectList.Begin(); itr1 != m_cEffectList.End(); itr1++) { // Get the effect CIMFEffect *pEffect1 = (CIMFEffect *) *itr1; if (pEffect1 == NULL) { return HXR_FAILED; } // Does this effect have a target image? if (pEffect1->HasTargetImage()) { // This effect DOES have a target image, so first we determine if // the target image has been previously used. We look from the // beginning of the list up to (but not including, obviously) // the current effect GListIterator itr2; BOOL bHandleMatch = FALSE; for (itr2 = m_cEffectList.Begin(); itr2 != itr1; itr2++) { CIMFEffect *pEffect2 = (CIMFEffect *) *itr2; if (pEffect2 == NULL) { return HXR_FAILED; } if (pEffect2->HasTargetImage()) { if (pEffect1->GetTargetImageHandle() == pEffect2->GetTargetImageHandle()) { bHandleMatch = TRUE; break; } } } if (bHandleMatch == TRUE) { // This was NOT the first use of the image pEffect1->SetFirstUse(FALSE); } else { // This WAS the first use of the image pEffect1->SetFirstUse(TRUE); } // Now we find if this is the last use of this image. We start looking at // the last effect in the list and work our way backwards. bHandleMatch = FALSE; for (itr2 = m_cEffectList.End() - 1; itr2 != itr1; itr2--) { CIMFEffect *pEffect2 = (CIMFEffect *) *itr2; if (pEffect2 == NULL) { return HXR_FAILED; } if (pEffect2->HasTargetImage()) { if (pEffect1->GetTargetImageHandle() == pEffect2->GetTargetImageHandle()) { bHandleMatch = TRUE; break; } } } if (bHandleMatch == TRUE) { // This was NOT the last use of the image pEffect1->SetLastUse(FALSE); } else { // This WAS the last use of the image pEffect1->SetLastUse(TRUE); } } else { // This effect does NOT have a target image, so both flags are false pEffect1->SetFirstUse(FALSE); pEffect1->SetLastUse(FALSE); } } return HXR_OK;}BOOL CIMFFileObject::InitFromText(GString &rText, UINT32& rulErrorID, CHXString& rErrText){ UINT32 ulLastTarget = 0; // Look for start tag LONG32 lStartPos = rText.find(m_pszIMFStartTag); if (lStartPos < 0) { rulErrorID = IDS_ERR_PIX_NOSTART; rErrText = ""; return FALSE; } // Look for end tag LONG32 lEndPos = rText.find(m_pszIMFEndTag, lStartPos + strlen(m_pszIMFStartTag)); if (lEndPos < 0) { rulErrorID = IDS_ERR_PIX_NOEND; rErrText = ""; return FALSE; } // Pull out the substring with the contents // between <imfl> and </imfl> GString cText = rText.substr(lStartPos + strlen(m_pszIMFStartTag), lEndPos - 1); // Now go into a loop, looking for tag starts and ends and // take the appropriate action based on whether the tag is // "head", "image", or one of the effect tags. LONG32 lCurPos = 0; BOOL bValidHead = FALSE; BOOL bComputeDuration = FALSE; BOOL bRet; HX_RESULT retVal; while (1) { // Find tag begin ("<") lCurPos = cText.find(m_pszTagStart, lCurPos); if (lCurPos < 0) break; LONG32 lTagStart = lCurPos; // Find first non-whitespace after the tag begin lCurPos = cText.find_first_not_of(m_pszWhitespace, lCurPos + strlen(m_pszTagStart)); if (lCurPos < 0) break; LONG32 lTagStrStart = lCurPos; // Check to see if it's a comment if (cText.substr(lTagStrStart, lTagStrStart + 2) == "!--") { lCurPos = cText.find('>', lCurPos); if (lCurPos < 0) break; continue; } // Find first whitespace after tag name lCurPos = cText.find_first_of(m_pszWhitespace, lCurPos); if (lCurPos < 0) break; LONG32 lTagStrEnd = lCurPos - 1; LONG32 lAttrStrStart = lCurPos; // Find tag end ("/>") lCurPos = cText.find(m_pszTagEnd, lCurPos); if (lCurPos < 0) break; LONG32 lAttrStrEnd = lCurPos - 1; // Update position in order to look for next tag lCurPos += strlen(m_pszTagEnd); GString cTagStr = cText.substr(lTagStrStart, lTagStrEnd); GString cAttrStr = cText.substr(lAttrStrStart, lAttrStrEnd); GString cWholeTag = cText.substr(lTagStart, lAttrStrEnd + 2); // Check to make sure no tag start is found within the attribute string. If // we do find this, this would indicate someone forgot the tag end "/>". if (cAttrStr.length() > 0) { LONG32 lEarlyEnd = cAttrStr.find(m_pszTagStart); if (lEarlyEnd >= 0) { rulErrorID = IDS_ERR_PIX_NOXMLEND; rErrText = cWholeTag.c_str(); return FALSE; } } // Choose action based on tag if (cTagStr == "head") { // Get the version string GString cVersion; bRet = SetAttributeValue(cAttrStr, m_pszHeadVersionAttribute, cVersion); if (bRet == TRUE) { if (cVersion.length() == 0) { rulErrorID = IDS_ERR_PIX_NULLVERSION; rErrText = ""; return FALSE; } char *pszToken = strtok((char *) cVersion.c_str(), "."); UINT32 ulDotNum = 0; INT32 lVer[4] = {0, 0, 0, 0}; while(pszToken != NULL && ulDotNum < 4) { lVer[ulDotNum++] = atol(pszToken); pszToken = strtok(NULL, "."); } m_ulContentVersion = (UINT32) ((lVer[0] << 28L) | (lVer[1] << 20L) | (lVer[2] << 12L) | lVer[3]); } else { m_ulContentVersion = BASE_VERSION; } // For optional tags, it's OK if we they are not present. However, if they // ARE present in the .imf file, we will check their value bRet = SetAttributeValue(cAttrStr, m_pszHeadTitleAttribute, m_cTitle); if (bRet == TRUE) { if (m_cTitle.length() == 0) { rulErrorID = IDS_ERR_PIX_NULLTITLE; rErrText = ""; return FALSE; } } bRet = SetAttributeValue(cAttrStr, m_pszHeadAuthorAttribute, m_cAuthor); if (bRet == TRUE) { if (m_cAuthor.length() == 0) { rulErrorID = IDS_ERR_PIX_NULLAUTHOR; rErrText = ""; return FALSE; } } bRet = SetAttributeValue(cAttrStr, m_pszHeadCopyrightAttribute, m_cCopyright); if (bRet == TRUE) { if (m_cCopyright.length() == 0) { rulErrorID = IDS_ERR_PIX_NULLCOPYRIGHT; rErrText = ""; return FALSE; } } // Get the background color GString cColorStr; bRet = GetAttributeSubstring(cAttrStr, m_pszHeadBackgroundColorAttr, cColorStr); if (bRet) { PXColor cColor; HX_RESULT rv = cColor.InitFromString(cColorStr.c_str()); if (FAILED(rv)) { rulErrorID = IDS_ERR_PIX_BADBGCOLOR; rErrText = ""; return FALSE; } // Assign the background color m_ulBackgroundColor = (cColor.GetRed() << 16) | (cColor.GetGreen() << 8) | cColor.GetBlue(); // If we see the background color attribute in the <head> tag, we bump // the content version to force any older renderers to auto-upgrade. if (m_ulContentVersion < U2_VERSION) { m_ulContentVersion = U2_VERSION; } } // Get the opacity GString cOpacityStr; bRet = GetAttributeSubstring(cAttrStr, m_pszHeadOpacityAttr, cOpacityStr); if (bRet) { // Parse the opacity HXParseOpacity(cOpacityStr.c_str(), m_ulOpacity); // If the opacity is set in the <head> tag, then we // need to bump up the content version to force any // older renderers to upgrade if (m_ulContentVersion < OPACITY_VERSION) { m_ulContentVersion = OPACITY_VERSION; } } // We need to determine the timeformat before we get any of the time-related attributes GString cTimeFormatStr; bRet = SetAttributeValue(cAttrStr, m_pszHeadTimeFormatAttribute, cTimeFormatStr); if (bRet == FALSE) { // No timeformat attribute was present, so we'll assume the default m_ulTimeFormat = kTimeFormatMilliseconds; } else { if (cTimeFormatStr == "dd:hh:mm:ss.xyz") { m_ulTimeFormat = kTimeFormatDHMS; } else if (cTimeFormatStr == "milliseconds") { m_ulTimeFormat = kTimeFormatMilliseconds; } else { rulErrorID = IDS_ERR_PIX_BADTIMEFORMAT; rErrText = cTimeFormatStr.c_str(); return FALSE; } } // Get start time retVal = SetAttributeTimeValue(cAttrStr, m_pszHeadStartAttribute, m_ulTimeFormat, m_ulStartTime); if (retVal != HXR_OK) { if (retVal == HXR_PROP_NOT_FOUND) { // start time not specified, so just assign default m_ulStartTime = 0; } else { rulErrorID = IDS_ERR_PIX_BADSTARTTIME; rErrText = ""; return FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -