smlparse.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:137k
- HX_RESULT
- CSmil1Parser::selectSwitchNodes(SMIL1Node* pSwitchNode)
- {
- HX_RESULT rc = HXR_OK;
- SMIL1NodeList* pNodeList = pSwitchNode->m_pNodeList;
- if(!pNodeList)
- {
- return rc;
- }
- SMIL1Node* pSelectedNode = 0;
- CHXSimpleList* pRejectedNodeList = new CHXSimpleList;
- CHXSimpleList::Iterator i;
- for(i=pNodeList->Begin();i!=pNodeList->End();++i)
- {
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(!pNode->m_bDelete)
- {
- if(testAttributeFailed(pNode))
- {
- pRejectedNodeList->AddTail(pNode);
- }
- else
- {
- pSelectedNode = pNode;
- //[SMIL 1.0 Compliance] Fixes PR 26732:
- //Now, update selected node's id to that of the switch so
- // that anchors pointing to the switch id will reference
- // the node of the switch that was selected. Note that
- // we can't fix this the other way around, namely to rename
- // all anchors' id strings to that of the selected node
- // since not all of them have been parsed/set yet:
- HX_ASSERT(pSelectedNode->m_id.GetLength() > 0 &&
- pSwitchNode->m_id.GetLength() > 0);
- if (pSelectedNode->m_id.GetLength() > 0 &&
- pSwitchNode->m_id.GetLength() > 0)
- {
- pSelectedNode->m_id = pSwitchNode->m_id;
- (*m_pIDMap)[(const char*)pSelectedNode->m_id] =
- pSelectedNode;
- pSwitchNode->m_id = assignID("switch");
- (*m_pIDMap)[(const char*)pSwitchNode->m_id] =
- pSwitchNode;
- }
- break;
- }
- }
- }
- HX_DELETE(pRejectedNodeList);
- // delete non-selected nodes
- for(i=pNodeList->Begin();i!=pNodeList->End();++i)
- {
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(pNode != pSelectedNode)
- {
- pNode->m_bDelete = TRUE;
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::markTestAttributeNodes(SMIL1NodeList* pNodeList)
- {
- HX_RESULT rc = HXR_OK;
- if(!pNodeList)
- {
- return rc;
- }
- CHXSimpleList::Iterator i;
- for(i=pNodeList->Begin();i!=pNodeList->End() && SUCCEEDED(rc);++i)
- {
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- rc = addToNamespaceScope(pNode);
- if (FAILED(rc))
- {
- return rc;
- }
- if(pNode->m_tag == SMILSwitch)
- {
- selectSwitchNodes(pNode);
- }
- else
- {
- if(testAttributeFailed(pNode))
- {
- pNode->m_bDelete = TRUE;
- }
- }
- //Fix for PR 21303: we need to keep drilling down
- // through the tree even if we've just called
- // selectSwitchNodes() to delete all but one
- // child of the switch; the descendants of that
- // child may have attributes as well that need
- // to be checked:
- //(For efficiency, only do the following code if
- // the node is not already slated for deletion
- // because a deletable node's children will be
- // deleted anyway):
- if (!pNode->m_bDelete)
- {
- rc = markTestAttributeNodes(pNode->m_pNodeList);
- }
- if (SUCCEEDED(rc))
- {
- rc = removeFromNamespaceScope(pNode);
- }
- }
- return rc;
- }
- BOOL
- CSmil1Parser::firstDependentChild(SMIL1Node* pNode)
- {
- if(getFirstNodeChild(pNode->m_pDependency) == pNode)
- {
- return TRUE;
- }
- return FALSE;
- }
- BOOL
- CSmil1Parser::hasParParent(SMIL1Node* pNode)
- {
- // walk up parent chain until we find a PAR
- BOOL rc = FALSE;
- while(pNode)
- {
- pNode = pNode->m_pParent;
- if(pNode && pNode->m_tag == SMILPar)
- {
- rc = TRUE;
- break;
- }
- }
- return rc;
- }
- SMIL1NodeTag
- CSmil1Parser::getSyncTag(SMIL1Node* pNode)
- {
- // walk up parent chain until we either find
- // a PAR or a SEQ
- SMIL1NodeTag tag = SMILSeq; // assume a SEQ
- while(pNode)
- {
- pNode = pNode->m_pParent;
- if(pNode && pNode->m_tag == SMILPar)
- {
- tag = SMILPar;
- break;
- }
- else if(pNode && pNode->m_tag == SMILSeq)
- {
- tag = SMILSeq;
- break;
- }
- }
- return tag;
- }
- SMIL1Node*
- CSmil1Parser::getSyncParent(SMIL1Node* pNode)
- {
- SMIL1Node* pReturnNode = NULL;
- while(pNode)
- {
- pNode = pNode->m_pParent;
- if(pNode &&
- (pNode->m_tag == SMILPar ||
- pNode->m_tag == SMILSeq))
- {
- pReturnNode = pNode;
- break;
- }
- }
- return pReturnNode;
- }
- BOOL
- CSmil1Parser::inSeq(SMIL1Node* pNode)
- {
- SMIL1NodeTag tag = getSyncTag(pNode);
- return tag == SMILSeq;
- }
- HX_RESULT
- CSmil1Parser::createHeadElements(SMIL1NodeList* pNodeList)
- {
- HX_RESULT rc = HXR_OK;
- if(!pNodeList)
- {
- return rc;
- }
- CHXSimpleList::Iterator i;
- for(i=pNodeList->Begin();i!=pNodeList->End();++i)
- {
- if(HXR_OK != rc)
- {
- return rc;
- }
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(pNode->m_bDelete) // skip this puppy
- {
- continue;
- }
- rc = addToNamespaceScope(pNode);
- if (FAILED(rc))
- {
- return rc;
- }
- switch(pNode->m_tag)
- {
- case SMILRegion:
- {
- //[SMIL 1.0 compliance] Fixes PR 25798: a region element may
- // only be contained inside a layout element:
- if (m_bSMIL10FullCompliance && pNode->m_pParent &&
- pNode->m_pParent->m_name.GetLength() &&
- strcmp((const char*)pNode->m_pParent->m_name,
- "layout"))
- {
- CSmil1SMILSyntaxErrorHandler errHandler(m_pContext);
- errHandler.ReportError(SMILErrorUnexpectedTag,
- (const char*)pNode->m_name,
- pNode->m_ulTagStartLine);
- return HXR_FAIL;
- }
- }
- break;
- case SMILMeta:
- {
- CSmil1Meta* pMeta = makeMeta(pNode);
- if(pMeta)
- {
- pNode->m_pElement = pMeta;
- pMeta->m_ulDelay = 0;
- pMeta->m_ulTimestamp = INITIAL_STREAM0_TIMESTAMP;
- insertElementByTimestamp(pMeta);
- }
- else
- {
- return HXR_FAIL;
- }
- }
- break;
- case SMILBasicLayout:
- {
- const char* pLayoutName = (const char*)pNode->m_id;
- BOOL bHasRegions = FALSE;
- SMIL1Node* pLayoutNode = pNode->getFirstChild();
- while(pLayoutNode && !pLayoutNode->m_bDelete)
- {
- switch(pLayoutNode->m_tag)
- {
- case SMILRootLayout:
- {
- CSmil1RootLayout* pRootLayout =
- makeRootLayout(pLayoutNode);
- if(pRootLayout)
- {
- pLayoutNode->m_pElement = pRootLayout;
- pRootLayout->m_ulDelay = 0;
- pRootLayout->m_ulTimestamp =
- INITIAL_STREAM0_TIMESTAMP;
- insertElementByTimestamp(pRootLayout);
- }
- else
- {
- return HXR_FAIL;
- }
- }
- break;
- case SMILRegion:
- {
- CSmil1Region* pRegion =
- makeRegion(pLayoutNode);
- if(pRegion)
- {
- pLayoutNode->m_pElement = pRegion;
- bHasRegions = TRUE;
- pRegion->m_ulDelay = 0;
- pRegion->m_ulTimestamp =
- INITIAL_STREAM0_TIMESTAMP;
- insertElementByTimestamp(pRegion);
- }
- else
- {
- return HXR_FAIL;
- }
- }
- break;
- case SMILMeta:
- {
- CSmil1Meta* pMeta = makeMeta(pLayoutNode);
- if(pMeta)
- {
- pNode->m_pElement = pMeta;
- pMeta->m_ulDelay = 0;
- pMeta->m_ulTimestamp =
- INITIAL_STREAM0_TIMESTAMP;
- insertElementByTimestamp(pMeta);
- }
- else
- {
- return HXR_FAIL;
- }
- }
- break;
- default:
- break;
- }
- pLayoutNode = pNode->getNextChild();
- }
- if(bHasRegions)
- {
- // send end-layout packet at TS 0
- m_pEndLayout = new CSmil1EndLayout;
- m_pEndLayout->m_ulDelay = 0;
- m_pEndLayout->m_ulTimestamp = INITIAL_STREAM0_TIMESTAMP;
- insertElementByTimestamp(m_pEndLayout);
- }
- }
- break;
-
- case SMILRNRendererList:
- {
- SMIL1Node* pRendererNode = pNode->getFirstChild();
- while(pRendererNode &&
- pRendererNode->m_tag == SMILRendererPreFetch)
- {
- CSmil1RendererPreFetch* pRenderer =
- makeRendererPreFetch(pRendererNode);
- pRendererNode->m_pElement = pRenderer;
- pRenderer->m_ulDelay = 0;
- pRenderer->m_ulTimestamp = INITIAL_STREAM0_TIMESTAMP;
- insertElementByTimestamp(pRenderer);
- pRendererNode = pNode->getNextChild();
- }
- }
- break;
- default:
- break;
- }
- rc = createHeadElements(pNode->m_pNodeList);
- if (SUCCEEDED(rc))
- {
- rc = removeFromNamespaceScope(pNode);
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::setInitialDelays(SMIL1NodeList* pNodeList)
- {
- HX_RESULT rc = HXR_OK;
- UINT16 nGroup = (UINT16)-1;
- if(!pNodeList)
- {
- return rc;
- }
- CHXSimpleList::Iterator i = pNodeList->Begin();
- for(;i!=pNodeList->End();++i)
- {
- if(HXR_OK != rc)
- {
- return rc;
- }
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(pNode->m_bDelete) // skip this puppy
- {
- continue;
- }
- else if(pNode->m_tag == SMILAAnchor ||
- pNode->m_tag == SMILSwitch)
- {
- pNode = getTimelineDescendent(pNode);
- if(!pNode)
- {
- continue;
- }
- }
- setInitialDelay(pNode);
- switch(pNode->m_tag)
- {
- case SMILSeq:
- {
- setInitialDelayOnSeq(pNode);
- }
- break;
- case SMILPar:
- {
- SMIL1Node* pThisNode =
- getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- setInitialDelay(pThisNode);
- pThisNode =
- getTimelineDescendent(pNode, pThisNode);
- }
- }
- break;
- }
- }
- return rc;
- }
- void
- CSmil1Parser::setInitialDelay(SMIL1Node* pNode)
- {
- if(pNode->m_pElement &&
- pNode->m_pElement->m_pTimelineElement &&
- !pNode->m_pElement->m_pTimelineElement->initialDelaySet())
- {
- pNode->m_pElement->m_pTimelineElement->setDelay(0);
- }
- if(pNode->m_pNodeList)
- {
- if(pNode->m_tag == SMILSeq ||
- pNode->m_tag == SMILPar)
- {
- if(pNode->m_pElement &&
- pNode->m_pElement->m_pTimelineElement &&
- pNode->m_pElement->m_ulDuration != (UINT32)-1)
- {
- pNode->m_pElement->m_pTimelineElement->setDuration(
- pNode->m_pElement->m_ulDuration);
- }
- }
- if(pNode->m_tag == SMILSeq)
- {
- setInitialDelayOnSeq(pNode);
- }
- //If the element doesn't exist or it does but the timelineElement
- // doesn't exist, or it does but there is no delay event, or there is
- // one but the delay is already set, then it's ok to set call
- // setInitialDelay():
- else if ((!pNode->m_pElement ||
- !pNode->m_pElement->m_pTimelineElement) ||
- //[SMIL 1.0 Compliance] Helps fix PR 14420:
- //Don't call this if pNode has an unresolved delay event:
- (!pNode->m_pElement->m_pTimelineElement->delayEvent() ||
- pNode->m_pElement->m_pTimelineElement->initialDelaySet() ) )
- {
- SMIL1Node* pThisNode =
- getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- setInitialDelay(pThisNode);
- pThisNode = getTimelineDescendent(pNode, pThisNode);
- }
- }
- }
- }
- void
- CSmil1Parser::setInitialDelayOnSeq(SMIL1Node* pNode)
- {
- UINT16 nGroup = (UINT16)-1;
-
- SMIL1Node* pThisNode = getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- if(pThisNode->m_nGroup != nGroup)
- {
- nGroup = pThisNode->m_nGroup;
- setInitialDelay(pThisNode);
- }
- pThisNode = getTimelineDescendent(pNode, pThisNode);
- }
- }
- HX_RESULT
- CSmil1Parser::assignGroupIndexes(SMIL1NodeList* pNodeList)
- {
- HX_RESULT rc = HXR_OK;
- if(!pNodeList)
- {
- return rc;
- }
- UINT16 nGroup = 0;
- CHXSimpleList::Iterator i = pNodeList->Begin();
- for(; i != pNodeList->End(); ++i)
- {
- if(HXR_OK != rc)
- {
- return rc;
- }
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(pNode->m_bDelete) // skip this puppy
- {
- continue;
- }
- else if(pNode->m_tag == SMILAAnchor ||
- pNode->m_tag == SMILSwitch)
- {
- pNode = getTimelineDescendent(pNode);
- if(!pNode)
- {
- continue;
- }
- }
- switch(pNode->m_tag)
- {
- case SMILSeq:
- {
- SMIL1Node* pThisNode =
- getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- rc = assignGroupIndexOnSeq(pThisNode, nGroup);
- if(HXR_OK == rc)
- {
- pThisNode =
- getTimelineDescendent(pNode, pThisNode);
- nGroup++;
- }
- else
- {
- break;
- }
- }
- }
- break;
- case SMILPar:
- {
- // top-level par, each child has group 0
- SMIL1Node* pThisNode =
- getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- rc = assignGroupIndexOnPar(pThisNode, nGroup);
- if(HXR_OK == rc)
- {
- pThisNode =
- getTimelineDescendent(pNode, pThisNode);
- }
- else
- {
- break;
- }
- }
- }
- break;
- default:
- break;
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::assignGroupIndexOnPar(SMIL1Node* pNode,
- UINT16 nGroup)
- {
- HX_RESULT rc = HXR_OK;
- if(pNode->m_bDelete)
- {
- return rc;
- }
- pNode->m_nGroup = nGroup;
- pNode->m_repeatid.AppendULONG(nGroup);
- if (isMediaObject(pNode))
- {
- addGroup(pNode);
- }
- else if (SMILSeq == pNode->m_tag ||
- SMILPar == pNode->m_tag)
- {
- // top-level par, each child has group 0
- SMIL1Node* pThisNode =
- getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- rc = assignGroupIndexOnPar(pThisNode, nGroup);
- if(HXR_OK == rc)
- {
- pThisNode =
- getTimelineDescendent(pNode, pThisNode);
- }
- else
- {
- break;
- }
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::assignGroupIndexOnSeq(SMIL1Node* pNode,
- UINT16& nGroup)
- {
- HX_RESULT rc = HXR_OK;
- if(pNode->m_bDelete)
- {
- return rc;
- }
- pNode->m_nGroup = nGroup;
- pNode->m_repeatid.AppendULONG(nGroup);
- if (isMediaObject(pNode))
- {
- addGroup(pNode);
- }
- else if (SMILSeq == pNode->m_tag)
- {
- SMIL1Node* pThisNode =
- getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- rc = assignGroupIndexOnSeq(pThisNode, nGroup);
- if(HXR_OK == rc)
- {
- pThisNode = getTimelineDescendent(pNode, pThisNode);
- if (pThisNode)
- {
- if (isMediaObject(pThisNode) ||
- SMILSeq == pThisNode->m_tag ||
- SMILPar == pThisNode->m_tag)
- {
- nGroup++;
- }
- }
- }
- else
- {
- break;
- }
- }
- }
- else if (SMILPar == pNode->m_tag)
- {
- SMIL1Node* pThisNode =
- getTimelineDescendent(pNode, NULL);
- while(pThisNode)
- {
- rc = assignGroupIndexOnPar(pThisNode, nGroup);
- if(HXR_OK == rc)
- {
- pThisNode =
- getTimelineDescendent(pNode, pThisNode);
- }
- else
- {
- break;
- }
- }
- }
- return rc;
- }
- BOOL
- CSmil1Parser::isMediaObject(SMIL1Node* pNode)
- {
- BOOL bResult = FALSE;
- if (NULL == pNode || pNode->m_bDelete)
- {
- goto cleanup;
- }
- switch(pNode->m_tag)
- {
- case SMILRef:
- case SMILText:
- case SMILImg:
- case SMILAudio:
- case SMILVideo:
- case SMILAnimation:
- case SMILTextstream:
- {
- bResult = TRUE;
- }
- break;
-
- default:
- break;
- }
- cleanup:
- return bResult;
- }
- HX_RESULT
- CSmil1Parser::addGroup(SMIL1Node* pNode)
- {
- HX_RESULT rc = HXR_OK;
- // set group info information
- CSmil1AddGroup* pAddGroup = 0;
- if(m_pAddGroupMap->Lookup(pNode->m_nGroup, (void*&)pAddGroup))
- {
- // we don't count self-replicated elements as they
- // share the same track ID
- if (pNode->m_repeatTag == RepeatUnknown)
- {
- pAddGroup->m_nTotalTracks++;
- if(pNode->m_pElement &&
- pNode->m_pElement->m_ulDelay == 0)
- {
- pAddGroup->m_nInitTracks++;
- }
- }
- }
- else
- {
- CSmil1AddGroup* pAddGroup = new CSmil1AddGroup;
- pAddGroup->m_nGroup = pNode->m_nGroup;
-
- // reference PAR properties in group
- if(pNode->m_pDependency &&
- pNode->m_pDependency->m_tag == SMILPar &&
- hasParParent(pNode))
- {
- IHXValues* pValues = pNode->m_pDependency->m_pValues;
- if(pValues)
- {
- pAddGroup->m_pValues = pValues;
- pAddGroup->m_pValues->AddRef();
- }
- pAddGroup->m_ulDuration =
- pNode->m_pDependency->m_pElement->m_ulDuration;
- }
- // XXXJHUG -- If the group is from a Seq, we still want
- // to pass along the Title, author, copyright & abstract from
- // the dependant parrent sequence group.
- if (pNode->m_pDependency &&
- pNode->m_pDependency->m_tag == SMILSeq)
- {
- IHXValues* pValues = pNode->m_pDependency->m_pValues;
- if(pValues)
- {
- // XXXJH should use CCF
- pAddGroup->m_pValues = new CHXHeader();
- IHXBuffer* pBuf = NULL;
- const char* name = NULL;
- pAddGroup->m_pValues->AddRef();
- if (SUCCEEDED(pValues->GetFirstPropertyCString(name, pBuf)))
- {
- do
- {
- if (strcmp("title",name)==0 ||
- strcmp("author",name)==0 ||
- strcmp("abstract",name)==0 ||
- strcmp("copyright",name)==0)
- {
- pAddGroup->m_pValues->SetPropertyCString(name, pBuf);
- }
- HX_RELEASE(pBuf);
- }
- while(SUCCEEDED(pValues->GetNextPropertyCString(name, pBuf)));
- }
- }
- // the duration for a sequence is dependant on the elements
- // within the sequence.
- }
- (*m_pAddGroupMap)[pNode->m_nGroup] = pAddGroup;
- pAddGroup->m_nTotalTracks = 1;
- if(pNode->m_pElement &&
- pNode->m_pElement->m_ulDelay == 0)
- {
- pAddGroup->m_nInitTracks = 1;
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::createBodyElements(SMIL1NodeList* pNodeList)
- {
- HX_RESULT rc = HXR_OK;
- if(!pNodeList)
- {
- return rc;
- }
- if(!m_pNodeDependencies)
- {
- m_pNodeDependencies = new CHXStack;
- }
- if(!m_pAnchorStack)
- {
- m_pAnchorStack = new CHXStack;
- }
- if(!m_pTrackHintList)
- {
- m_pTrackHintList = new CHXSimpleList;
- }
- UINT32 ulTrackHint = 1;
- CHXSimpleList::Iterator i;
- for(i=pNodeList->Begin();i!=pNodeList->End();++i)
- {
- if(HXR_OK != rc)
- {
- return rc;
- }
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(pNode->m_bDelete) // skip this puppy
- {
- continue;
- }
- rc = addToNamespaceScope(pNode);
- if (FAILED(rc))
- {
- return rc;
- }
- switch(pNode->m_tag)
- {
- case SMILSeq:
- {
- CSmil1SeqElement* pElement = makeSeqElement(pNode);
- if(!pElement)
- {
- return HXR_FAIL;
- }
- pNode->m_pElement = pElement;
- CSmil1TimelineSeq* pTimelineSeq =
- new CSmil1TimelineSeq(pElement, this);
- pElement->m_pTimelineElement = pTimelineSeq;
- if(!m_pCurrentDependentNode) // at the top
- {
- //pNode->m_nGroup = (UINT16)-1; // top level
- }
- else
- {
- pNode->m_pDependency = m_pCurrentDependentNode;
- if(!hasParParent(pNode))
- {
- //pNode->m_nGroup =
- // m_pCurrentDependentNode->m_nGroup + 1;
- }
- else
- {
- //pNode->m_nGroup =
- // m_pCurrentDependentNode->m_nGroup;
- }
- }
- m_pCurrentDependentNode = pNode;
- m_pNodeDependencies->Push(m_pCurrentDependentNode);
- ulTrackHint = 1;
- m_pTrackHintList->AddTail((void*)ulTrackHint);
- }
- break;
- case SMILPar:
- {
- CSmil1ParElement* pElement = makeParElement(pNode);
- if(!pElement)
- {
- return HXR_FAIL;
- }
- pNode->m_pElement = pElement;
- CSmil1TimelinePar* pTimelinePar =
- new CSmil1TimelinePar(pElement, this);
- pElement->m_pTimelineElement = pTimelinePar;
- if(!m_pCurrentDependentNode) // at the top
- {
- // pNode->m_nGroup = 0;
- }
- else
- {
- pNode->m_pDependency = m_pCurrentDependentNode;
- if(!hasParParent(pNode))
- {
- //pNode->m_nGroup =
- // m_pCurrentDependentNode->m_nGroup + 1;
- }
- else
- {
- //pNode->m_nGroup = m_pCurrentDependentNode->m_nGroup;
- }
- }
- if(firstDependentChild(pNode) || m_pCurrentDependentNode == 0)
- {
- ulTrackHint = 1;
- m_pTrackHintList->AddTail((void*)ulTrackHint);
- }
- else
- {
- if(m_pTrackHintList->GetCount() > 0)
- {
- ulTrackHint = (UINT32)m_pTrackHintList->RemoveTail();
- }
- m_pTrackHintList->AddTail((void*)++ulTrackHint);
- }
- m_pCurrentDependentNode = pNode;
- m_pNodeDependencies->Push(m_pCurrentDependentNode);
- }
- break;
- case SMILEndSeq:
- {
- m_pCurrentDependentNode =
- (SMIL1Node*)m_pNodeDependencies->Pop();
- if(m_pTrackHintList->GetCount() > 0)
- {
- m_pTrackHintList->RemoveTail();
- }
- }
- break;
- case SMILEndPar:
- {
- m_pCurrentDependentNode =
- (SMIL1Node*)m_pNodeDependencies->Pop();
- if(m_pTrackHintList->GetCount() > 0)
- {
- m_pTrackHintList->RemoveTail();
- }
- }
- break;
- case SMILAAnchor:
- {
- CSmil1AAnchorElement* pElement = makeAAnchorElement(pNode);
- if(pElement)
- {
- pNode->m_pElement = pElement;
- m_pAnchorStack->Push(m_pCurrentAnchor);
- m_pCurrentAnchor = pElement;
- }
- }
- break;
- case SMILEndAAnchor:
- {
- m_pCurrentAnchor = (CSmil1AAnchorElement*)m_pAnchorStack->Pop();
- }
- break;
- case SMILAnchor:
- {
- CSmil1AnchorElement* pElement = makeAnchorElement(pNode);
- if(pElement)
- {
- pNode->m_pElement = pElement;
- //[SMIL 1.0 compliance] Helps fix PR 26471:
- // In order to get a notification that we have a resolved
- // event-based begin time, we need to be a
- // timeline element:
- CSmil1TimelineAnchor* pTimelineAnchor =
- new CSmil1TimelineAnchor(pElement, this);
- pElement->m_pTimelineElement = pTimelineAnchor;
- // add link to parent
- SMIL1Node* pParent = pNode->m_pParent;
- if(pParent->m_pElement)
- {
- pParent->m_pElement->m_pHyperlinks->AddTail(pElement);
- }
- if(!m_pCurrentDependentNode)
- {
- //anchor should NEVER be top element:
- HX_ASSERT(m_pCurrentDependentNode);
- }
- else
- {
- pNode->m_pDependency = m_pCurrentDependentNode;
- }
- if(firstDependentChild(pNode) || m_pCurrentDependentNode == 0)
- {
- ulTrackHint = 1;
- m_pTrackHintList->AddTail((void*)ulTrackHint);
- }
- else
- {
- if(m_pTrackHintList->GetCount() > 0)
- {
- ulTrackHint = (UINT32)m_pTrackHintList->RemoveTail();
- }
- m_pTrackHintList->AddTail((void*)++ulTrackHint);
- }
- m_pCurrentDependentNode = pNode;
- m_pNodeDependencies->Push(m_pCurrentDependentNode);
- //end of part of fix for PR 26471.
- }
- }
- break;
- case SMILRef:
- case SMILText:
- case SMILImg:
- case SMILAudio:
- case SMILVideo:
- case SMILAnimation:
- case SMILTextstream:
- {
- CSmil1Source* pSource = makeSource(pNode);
- if(!pSource)
- {
- return HXR_FAIL;
- }
- m_bContainsSource = TRUE;
- pNode->m_pElement = pSource;
- CSmil1TimelineElement* pTimelineElement =
- new CSmil1TimelineElement(pSource, this);
- pNode->m_pElement->m_pTimelineElement = pTimelineElement;
- // attach any links
- if(m_pCurrentAnchor)
- {
- pSource->m_pHyperlinks->AddTail(m_pCurrentAnchor);
- }
- if(!m_pCurrentDependentNode)
- {
- // make it behave like it's in a SEQ
- pNode->m_pDependency = 0;
- //pNode->m_nGroup = 0;
- m_pCurrentDependentNode = pNode;
- ulTrackHint = 1;
- m_pTrackHintList->AddTail((void*)ulTrackHint);
- }
- else
- {
- pNode->m_pDependency = m_pCurrentDependentNode;
- if(inSeq(pNode))
- {
- if(firstDependentChild(pNode))
- {
- ulTrackHint = 1;
- m_pTrackHintList->AddTail((void*)ulTrackHint);
- }
- else
- {
- if(m_pTrackHintList->GetCount() > 0)
- {
- ulTrackHint =
- (UINT32)m_pTrackHintList->RemoveTail();
- }
- m_pTrackHintList->AddTail((void*)++ulTrackHint);
- }
- }
- else
- {
- if(firstDependentChild(pNode))
- {
- ulTrackHint = 1;
- m_pTrackHintList->AddTail((void*)ulTrackHint);
- }
- }
- if(inSeq(pNode) && !hasParParent(pNode))
- {
- if(firstDependentChild(pNode))
- {
- //pNode->m_nGroup = m_pCurrentDependentNode->m_nGroup;
- }
- else
- {
- //pNode->m_nGroup =
- //m_pCurrentDependentNode->m_nGroup + 1;
- }
- m_pCurrentDependentNode = pNode;
- }
- else if(inSeq(pNode))
- {
- //pNode->m_nGroup = m_pCurrentDependentNode->m_nGroup;
- m_pCurrentDependentNode = pNode;
- }
- else // in PAR
- {
- // pNode->m_nGroup = m_pCurrentDependentNode->m_nGroup;
- }
- }
- // set track hint info
- BOOL bFirstHint = TRUE;
- CHXSimpleList::Iterator hintIter = m_pTrackHintList->Begin();
- for(; hintIter != m_pTrackHintList->End(); ++hintIter)
- {
- char tmpBuf[20]; /* Flawfinder: ignore */
- UINT32 ulTrackHint = (UINT32)(*hintIter);
- if(bFirstHint)
- {
- sprintf(tmpBuf, "%d", ulTrackHint); /* Flawfinder: ignore */
- bFirstHint = FALSE;
- }
- else
- {
- sprintf(tmpBuf, ".%d", ulTrackHint); /* Flawfinder: ignore */
- }
- pNode->m_trackHint += tmpBuf;
- }
- }
- break;
- default:
- break;
- }
- rc = createBodyElements(pNode->m_pNodeList);
-
- if (SUCCEEDED(rc))
- {
- rc = removeFromNamespaceScope(pNode);
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::expandRepeatElements(SMIL1NodeList* pNodeList)
- {
- // walk through tree and expand any "repeat" attributes
-
- HX_RESULT rc = HXR_OK;
- if(!pNodeList)
- {
- return rc;
- }
- LISTPOSITION lPos = pNodeList->GetHeadPosition();
- while (lPos && HXR_OK == rc)
- {
- SMIL1Node* pNode = (SMIL1Node*)pNodeList->GetAt(lPos);
- if(pNode->m_bDelete) // skip this puppy
- {
- pNodeList->GetNext(lPos);
- continue;
- }
- if(pNode->m_pValues)
- {
- const char* pName = 0;
- IHXBuffer* pBuf = 0;
- if (!pNode->m_bRepeatHandled &&
- HXR_OK == pNode->m_pValues->GetPropertyCString("repeat", pBuf))
- {
- BOOL bRepeatIndefinite = FALSE;
- const char* pRepeatCount = (const char*)pBuf->GetBuffer();
- if(pRepeatCount)
- {
- INT32 lRepeatCount = 0;
- if(strcmp(pRepeatCount, "indefinite") == 0)
- {
- bRepeatIndefinite = TRUE;
- lRepeatCount = 2;
- }
- else
- {
- lRepeatCount = atol(pRepeatCount);
- }
- if(lRepeatCount == 0)
- {
- pNode->m_bDelete = TRUE;
- }
- else if(lRepeatCount > 1)
- {
- // build a <seq>/</seq> around the repeated element...
- SMIL1Node* pSeqNode = NULL;
- SMIL1Node* pSeqEndNode = NULL;
-
- createParent(pNode, SMILSeq, pSeqNode, pSeqEndNode);
- SMIL1Node* pNodeCopy = NULL;
- BOOL bOverWrite = TRUE;
- for(INT32 lCount = 0; lCount < lRepeatCount;
- ++lCount)
- {
- // we want to keep the original ids for the
- // 1st repeat so that we don't break any links
- if (0 == lCount)
- {
- pNodeCopy = new SMIL1Node(*pNode, TRUE, this);
- bOverWrite = TRUE;
- }
- else
- {
- pNodeCopy = new SMIL1Node(*pNode, FALSE, this);
- bOverWrite = FALSE;
- }
-
- pNodeCopy->m_pParent = pSeqNode;
- pNodeCopy->m_pNodeList->m_pParentNode = pNodeCopy;
- pNodeCopy->m_bRepeatHandled = TRUE;
- // after the 1st repeat, mark the rest of repeats
- // as replica(used in counting tracks etc.)
- if (lCount > 0)
- {
- if (bRepeatIndefinite)
- {
- if (pNodeCopy->m_tag == SMILSeq ||
- pNodeCopy->m_tag == SMILPar)
- {
- // set indefinite repeat tag on seq
- // will be used in constructing timeline elements
- pSeqNode->m_repeatTag = RepeatIndefiniteOnMe;
- pNodeCopy->m_repeatTag = RepeatIndefiniteOnGroup;
- markRepeatReplica(pNodeCopy->m_pNodeList, RepeatIndefiniteOnGroup);
- }
- else
- {
- pNodeCopy->m_repeatTag = RepeatIndefiniteOnMe;
- }
- }
- else
- {
- pNodeCopy->m_repeatTag = RepeatReplica;
-
- if (pNodeCopy->m_tag == SMILSeq ||
- pNodeCopy->m_tag == SMILPar)
- {
- markRepeatReplica(pNodeCopy->m_pNodeList, RepeatReplica);
- }
- }
- }
- mapID(pNodeCopy, bOverWrite);
- //Fix for PR 13119: internal elements (source
- // elements, especially) of a repeated <seq> or
- // <par> tag were not getting mapped and thus
- // never played, so we need to map the IDs of
- // all in the m_pNodeList of the pNodeCopy:
- mapChildrenIDs(pNodeCopy->m_pNodeList, bOverWrite);
- pSeqNode->m_pNodeList->AddTail(pNodeCopy);
- }
- pSeqNode->m_pNodeList->AddTail(pSeqEndNode);
- // special case to ensure all repeated elements
- // are within the same group(share the same timeline)
- if (!hasParParent(pSeqNode))
- {
- SMIL1Node* pParNode = NULL;
- SMIL1Node* pParEndNode = NULL;
- createParent(pSeqNode, SMILPar, pParNode, pParEndNode);
- pParNode->m_repeatTag = pSeqNode->m_repeatTag;
- pParNode->m_pNodeList->AddTail(pSeqNode);
- pParNode->m_pNodeList->AddTail(pParEndNode);
- // now add the list to the parent...
- pNodeList->InsertBefore(lPos, pParNode);
- pNode->m_bDelete = TRUE; // delete original node
- pNode = pParNode;
- }
- else
- {
- // now add the list to the parent...
- pNodeList->InsertBefore(lPos, pSeqNode);
- pNode->m_bDelete = TRUE; // delete original node
- pNode = pSeqNode;
- }
- }
- }
- }
- }
- // breadth first
- rc = expandRepeatElements(pNode->m_pNodeList);
- pNodeList->GetNext(lPos);
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::createParent (SMIL1Node* pChildNode,
- SMIL1NodeTag tag,
- SMIL1Node*& pParent,
- SMIL1Node*& pParentEnd)
- {
- HX_RESULT hr = HXR_OK;
- pParent = NULL;
- pParentEnd = NULL;
- if (!pChildNode)
- {
- hr = HXR_FAILED;
- goto cleanup;
- }
- pParent = new SMIL1Node;
- pParent->m_pParent = pChildNode->m_pParent;
- pParent->m_tag = tag;
-
- pParent->m_pNodeList = new SMIL1NodeList;
- pParent->m_pNodeList->m_pParentNode = pParent;
-
- pParentEnd = new SMIL1Node;
- pParentEnd->m_pParent = pParent;
- if (SMILPar == tag)
- {
- pParent->m_name = "par";
- pParentEnd->m_name = "par";
- pParentEnd->m_id = assignID("CLOSE-par");
- pParentEnd->m_tag = SMILEndPar;
- }
- else if (SMILSeq == tag)
- {
- pParent->m_name = "seq";
- pParentEnd->m_name = "seq";
- pParentEnd->m_id = assignID("CLOSE-seq");
- pParentEnd->m_tag = SMILEndSeq;
- }
- else
- {
- HX_ASSERT(FALSE);
- hr = HXR_FAILED;
- goto cleanup;
- }
-
- mapID(pParent, TRUE);
- mapID(pParentEnd, TRUE);
- cleanup:
- return hr;
- }
- void
- CSmil1Parser::resetTimeline()
- {
- if (m_pTimelineElementManager)
- {
- m_pTimelineElementManager->resetTimeline();
- }
- }
- SMIL1Node*
- CSmil1Parser::getTimelineDescendent(SMIL1Node* pParentNode)
- {
- SMIL1Node* pDescendentNode = NULL;
- CHXSimpleList* pNodeList = pParentNode->m_pNodeList;
- if(!pNodeList)
- {
- return pDescendentNode;
- }
- CHXSimpleList::Iterator i;
- for(i=pNodeList->Begin();i!=pNodeList->End();++i)
- {
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(pNode->m_bDelete)
- {
- continue;
- }
- if(pNode->m_tag == SMILAAnchor ||
- pNode->m_tag == SMILSwitch)
- {
- pNode = getTimelineDescendent(pNode);
- if(pNode)
- {
- pDescendentNode = pNode;
- break;
- }
- }
- else
- {
- if(pNode->m_tag == SMILSeq ||
- pNode->m_tag == SMILPar ||
- pNode->m_tag == SMILRef ||
- pNode->m_tag == SMILText ||
- pNode->m_tag == SMILImg ||
- pNode->m_tag == SMILAudio ||
- pNode->m_tag == SMILVideo ||
- pNode->m_tag == SMILAnimation ||
- pNode->m_tag == SMILTextstream ||
- pNode->m_tag == SMILAnchor)
- {
- pDescendentNode = pNode;
- break;
- }
- }
- }
- return pDescendentNode;
- }
- SMIL1Node*
- CSmil1Parser::getTimelineDescendent(SMIL1Node* pParentNode, SMIL1Node* pSiblingNode)
- {
- SMIL1Node* pFirstDescendent = getTimelineDescendent(pParentNode);
- if(!pSiblingNode)
- {
- return pFirstDescendent;
- }
- // first, find parent of sibling
- SMIL1Node* pSiblingParent = pSiblingNode->m_pParent;
- while(pSiblingParent &&
- pSiblingParent->m_tag != SMILSeq &&
- pSiblingParent->m_tag != SMILPar)
- {
- pSiblingParent = pSiblingParent->m_pParent;
- }
- if(!pSiblingParent)
- {
- return NULL;
- }
- // now find the sibling, then next sibling will be
- // returned. Brain damaged, but what are ya gonna do?
- BOOL bFoundSibling = FALSE;
- SMIL1Node* pNewSibling = NULL;
- CHXSimpleList::Iterator i = pSiblingParent->m_pNodeList->Begin();
- for(; i != pSiblingParent->m_pNodeList->End() && !pNewSibling; ++i)
- {
- SMIL1Node* pThisNode = (SMIL1Node*)(*i);
- if(pThisNode->m_bDelete)
- {
- continue;
- }
- if(pThisNode->m_tag == SMILAAnchor ||
- pThisNode->m_tag == SMILSwitch)
- {
- CHXSimpleList::Iterator j = pThisNode->m_pNodeList->Begin();
- for(; j != pThisNode->m_pNodeList->End(); ++j)
- {
- SMIL1Node* pChildNode = (SMIL1Node*)(*j);
- if(pChildNode->m_bDelete)
- {
- continue;
- }
- if(pChildNode == pSiblingNode)
- {
- bFoundSibling = TRUE;
- break;
- }
- else if(bFoundSibling)
- {
- pNewSibling = pChildNode;
- break;
- }
- }
- }
- else
- {
- if(pThisNode == pSiblingNode)
- {
- bFoundSibling = TRUE;
- }
- else if(bFoundSibling)
- {
- pNewSibling = pThisNode;
- break;
- }
- }
- }
- return pNewSibling;
- }
- HX_RESULT
- CSmil1Parser::constructTimelineElements(SMIL1NodeList* pNodeList)
- {
- HX_RESULT rc = HXR_OK;
- if(!pNodeList)
- {
- return rc;
- }
- CHXSimpleList::Iterator i;
- for(i=pNodeList->Begin();i!=pNodeList->End();++i)
- {
- if(HXR_OK != rc)
- {
- return rc;
- }
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- if(pNode->m_bDelete) // skip this puppy
- {
- continue;
- }
- switch(pNode->m_tag)
- {
- case SMILSeq:
- {
- SMIL1Node* pChildNode = getTimelineDescendent(pNode, NULL);
- CSmil1TimelineElement* pPrevElement = NULL;
- UINT16 uPrevGroup = (UINT16)-1;
- while(pChildNode)
- {
- if (pChildNode->m_pElement &&
- pChildNode->m_pElement->m_pTimelineElement)
- {
- pNode->m_pElement->m_pTimelineElement->addChild(
- pChildNode->m_pElement->m_pTimelineElement);
- if(pPrevElement &&
- uPrevGroup == pChildNode->m_nGroup)
- {
- pPrevElement->setDependent(pChildNode->m_pElement->m_pTimelineElement);
- }
-
- pPrevElement = pChildNode->m_pElement->m_pTimelineElement;
- uPrevGroup = pChildNode->m_nGroup;
- }
- // there is no dependent on pChildNode which would repeat
- // itself indefinitely within the same seq
- if (pChildNode->m_repeatTag == RepeatIndefiniteOnMe)
- {
- break;
- }
-
- pChildNode = getTimelineDescendent(pNode, pChildNode);
- }
- }
- break;
- case SMILPar:
- {
- SMIL1Node* pChildNode = getTimelineDescendent(pNode, NULL);
- while(pChildNode)
- {
- if(pChildNode->m_pElement &&
- pChildNode->m_pElement->m_pTimelineElement)
- {
- pNode->m_pElement->m_pTimelineElement->addChild(
- pChildNode->m_pElement->m_pTimelineElement);
- }
- pChildNode = getTimelineDescendent(pNode, pChildNode);
- }
- }
- break;
- default:
- break;
- }
- rc = constructTimelineElements(pNode->m_pNodeList);
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::handleNextElement(CSmil1ElementHandler* pHandler)
- {
- HX_RESULT rc = HXR_OK;
- if(m_pPacketQueue->GetCount() > 0)
- {
- CSmil1Element* pElement = (CSmil1Element*)m_pPacketQueue->RemoveHead();
- pElement->m_pHandler = pHandler;
- rc = pElement->handleElement();
- }
- else if(m_bTimestampsResolved)
- {
- rc = HXR_STREAM_DONE;
- }
- else
- {
- rc = HXR_NO_DATA;
- }
- return rc;
- }
- void
- CSmil1Parser::initTagAttributes()
- {
- if(!m_pTagAttributeMap)
- {
- m_pTagAttributeMap = new CHXMapLongToObj;
- }
- CHXMapStringToOb* pStringMap = 0;
- // SMILSmil
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*m_pTagAttributeMap)[SMILSmil] = pStringMap;
- // SMILHead
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*m_pTagAttributeMap)[SMILHead] = pStringMap;
- // SMILBasicLayout
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["type"] = 0;
- (*m_pTagAttributeMap)[SMILBasicLayout] = pStringMap;
- // SMILRegion
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["height"] = 0;
- (*pStringMap)["width"] = 0;
- (*pStringMap)["background-color"] = 0;
- (*pStringMap)["left"] = 0;
- (*pStringMap)["top"] = 0;
- (*pStringMap)["z-index"] = 0;
- (*pStringMap)["fit"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*m_pTagAttributeMap)[SMILRegion] = pStringMap;
- // SMILRootLayout
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["height"] = 0;
- (*pStringMap)["width"] = 0;
- (*pStringMap)["background-color"] = 0;
- (*pStringMap)["overflow"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*m_pTagAttributeMap)[SMILRootLayout] = pStringMap;
- // SMILMeta
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["name"] = 0;
- (*pStringMap)["content"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*m_pTagAttributeMap)[SMILMeta] = pStringMap;
- // SMILBody
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*m_pTagAttributeMap)[SMILBody] = pStringMap;
- // SMILPar
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["abstract"] = 0;
- (*pStringMap)["author"] = 0;
- (*pStringMap)["copyright"] = 0;
- (*pStringMap)["endsync"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeat"] = 0;
- (*pStringMap)["region"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["system-bitrate"] = 0;
- (*pStringMap)["system-language"] = 0;
- (*pStringMap)["system-required"] = 0;
- (*pStringMap)["system-screen-size"] = 0;
- (*pStringMap)["system-screen-depth"] = 0;
- (*pStringMap)["system-captions"] = 0;
- (*pStringMap)["system-overdub-or-caption"] = 0;
- (*m_pTagAttributeMap)[SMILPar] = pStringMap;
- // SMILSeq
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["abstract"] = 0;
- (*pStringMap)["author"] = 0;
- (*pStringMap)["copyright"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeat"] = 0;
- (*pStringMap)["region"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["system-bitrate"] = 0;
- (*pStringMap)["system-language"] = 0;
- (*pStringMap)["system-required"] = 0;
- (*pStringMap)["system-screen-size"] = 0;
- (*pStringMap)["system-screen-depth"] = 0;
- (*pStringMap)["system-captions"] = 0;
- (*pStringMap)["system-overdub-or-caption"] = 0;
- (*m_pTagAttributeMap)[SMILSeq] = pStringMap;
- // SMILSwitch
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*m_pTagAttributeMap)[SMILSwitch] = pStringMap;
- // SMILRef
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["abstract"] = 0;
- (*pStringMap)["author"] = 0;
- (*pStringMap)["copyright"] = 0;
- (*pStringMap)["region"] = 0;
- (*pStringMap)["alt"] = 0;
- (*pStringMap)["longdesc"] = 0;
- (*pStringMap)["src"] = 0;
- (*pStringMap)["type"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeat"] = 0;
- (*pStringMap)["fill"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["clip-begin"] = 0;
- (*pStringMap)["clip-end"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*pStringMap)["system-bitrate"] = 0;
- (*pStringMap)["system-language"] = 0;
- (*pStringMap)["system-required"] = 0;
- (*pStringMap)["system-screen-size"] = 0;
- (*pStringMap)["system-screen-depth"] = 0;
- (*pStringMap)["system-captions"] = 0;
- (*pStringMap)["system-overdub-or-caption"] = 0;
- (*m_pTagAttributeMap)[SMILRef] = pStringMap;
- // SMILAAnchor
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["href"] = 0;
- (*pStringMap)["show"] = 0;
- (*m_pTagAttributeMap)[SMILAAnchor] = pStringMap;
- // SMILAnchor
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["href"] = 0;
- (*pStringMap)["show"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["coords"] = 0;
- (*pStringMap)["fragment-id"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*pStringMap)["z-index"] = 0;
- (*m_pTagAttributeMap)[SMILAnchor] = pStringMap;
- // SMILRendererPreFetch
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["type"] = 0;
- (*m_pTagAttributeMap)[SMILRendererPreFetch] = pStringMap;
- }
- void
- CSmil1Parser::deleteTagAttributes()
- {
- if(m_pTagAttributeMap)
- {
- CHXMapLongToObj::Iterator i = m_pTagAttributeMap->Begin();
- for(; i != m_pTagAttributeMap->End(); ++i)
- {
- CHXMapStringToOb* pStringMap = (CHXMapStringToOb*)(*i);
- delete pStringMap;
- }
- }
- HX_DELETE(m_pTagAttributeMap);
- }
- BOOL
- CSmil1Parser::isLegalAttribute(SMIL1NodeTag tag, const char* pAttName)
- {
- // use SMILRef for all media object checks
- if(tag == SMILText ||
- tag == SMILImg ||
- tag == SMILAudio ||
- tag == SMILVideo ||
- tag == SMILAnimation ||
- tag == SMILTextstream)
- {
- tag = SMILRef;
- }
- CHXMapStringToOb* pStringMap = 0;
- if(m_pTagAttributeMap->Lookup(tag, (void*&)pStringMap))
- {
- void* pVoid = 0;
- if(pStringMap->Lookup(pAttName, pVoid))
- {
- return TRUE;
- }
- else if (strcmp(pAttName, "xmlns") == 0 ||
- strncmp(pAttName, "xmlns:", 6) == 0)
- {
- // accept any namespace declarations.
- return TRUE;
- }
- else
- {
- BOOL bValidAttribute = FALSE;
- char* pColon = (char *)strchr(pAttName, ':');
- if(pColon)
- {
- //check for valid namespace tag we can
- // ignore
- char* pTmpNam = new_string(pAttName);
- char* pNamespace = strtok(pTmpNam, ":");
- if(pNamespace)
- {
- UINT32 ulTemp = 0;
- if(m_pActiveNamespaceMap &&
- (m_pActiveNamespaceMap->Lookup(pNamespace,
- (void*&)ulTemp)))
- {
- // OK, we can ignore it...
- bValidAttribute = TRUE;
- }
- }
- delete[] pTmpNam;
- }
- if(bValidAttribute)
- {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- BOOL
- CSmil1Parser::isRelativeURL(const char* pURL)
- {
- BOOL rc = TRUE;
- CHXURL urlObj(pURL);
- IHXValues* pHeader = urlObj.GetProperties();
- if(pHeader)
- {
- IHXBuffer* pBuffer = NULL;
- if(HXR_OK == pHeader->GetPropertyBuffer(PROPERTY_SCHEME, pBuffer))
- {
- // fully qualified URL
- rc = FALSE;
- HX_RELEASE(pBuffer);
- }
- }
- HX_RELEASE(pHeader);
- return rc;
- }
- HX_RESULT
- CSmil1Parser::storeNamespaces(SMIL1Node* pNode)
- {
- HX_RESULT rc = HXR_OK;
- if (pNode->m_pValues)
- {
- const char* pName = NULL;
- IHXBuffer* pBuffer = NULL;
- HX_RESULT res = pNode->m_pValues->GetFirstPropertyCString(pName, pBuffer);
- while (SUCCEEDED(rc) && SUCCEEDED(res))
- {
- if (strcmp(pName, "xmlns") == 0)
- {
- if (!pNode->m_pNamespaceList)
- {
- pNode->m_pNamespaceList = new CHXSimpleList;
- if (!pNode->m_pNamespaceList)
- {
- rc = HXR_OUTOFMEMORY;
- break;
- }
- }
-
- // duplicate atributes should allready be caught...
- SMIL1Namespace* pNS = new SMIL1Namespace("", pBuffer);
- pNode->m_pNamespaceList->AddHead(pNS);
- }
- else if (strncmp(pName, "xmlns:", 6) == 0)
- {
- if (!pNode->m_pNamespaceList)
- {
- pNode->m_pNamespaceList = new CHXSimpleList;
- if (!pNode->m_pNamespaceList)
- {
- rc = HXR_OUTOFMEMORY;
- break;
- }
- }
- char* nsPrefix = (char *)strchr(pName, ':');
- ++nsPrefix;
- SMIL1Namespace* pNS = new SMIL1Namespace(nsPrefix, pBuffer);
- pNode->m_pNamespaceList->AddHead(pNS);
- }
- HX_RELEASE(pBuffer);
- res = pNode->m_pValues->GetNextPropertyCString(pName, pBuffer);
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::addToNamespaceScope(SMIL1Node* pNode)
- {
- HX_RESULT rc = HXR_OK;
- if (!m_pActiveNamespaceMap)
- {
- m_pActiveNamespaceMap = new CHXMapStringToOb;
- if (!m_pActiveNamespaceMap)
- {
- return HXR_OUTOFMEMORY;
- }
- }
- if (pNode &&
- pNode->m_pNamespaceList)
- {
- for (CHXSimpleList::Iterator pIt = pNode->m_pNamespaceList->Begin();
- pIt != pNode->m_pNamespaceList->End(); ++pIt)
- {
- SMIL1Namespace* pNS = (SMIL1Namespace*)(*pIt);
- IHXBuffer* pBuf = (IHXBuffer*)(*m_pActiveNamespaceMap)[pNS->m_name];
- if (pBuf)
- {
- if (!m_pNSConflictList)
- {
- m_pNSConflictList = new CHXSimpleList;
- if (!m_pNSConflictList)
- {
- rc = HXR_OUTOFMEMORY;
- break;
- }
- }
- SMIL1Namespace* pConflict = new SMIL1Namespace(pNS);
- if (!pConflict)
- {
- rc = HXR_OUTOFMEMORY;
- break;
- }
- m_pNSConflictList->AddHead(pConflict);
-
- HX_RELEASE(pBuf);
- (*m_pActiveNamespaceMap)[pNS->m_name] = pNS->m_pValue;
- pNS->m_pValue->AddRef();
- }
- else
- {
- (*m_pActiveNamespaceMap)[pNS->m_name] = pNS->m_pValue;
- pNS->m_pValue->AddRef();
- }
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::removeFromNamespaceScope(SMIL1Node* pNode)
- {
- HX_RESULT rc = HXR_OK;
-
- if (pNode->m_pNamespaceList)
- {
- for (CHXSimpleList::Iterator pIt = pNode->m_pNamespaceList->Begin();
- pIt != pNode->m_pNamespaceList->End(); ++pIt)
- {
- SMIL1Namespace* pNS = (SMIL1Namespace*)(*pIt);
- HX_ASSERT((*m_pActiveNamespaceMap)[pNS->m_name]);
- IHXBuffer* pBuf = (IHXBuffer*)(*m_pActiveNamespaceMap)[pNS->m_name];
- if (pBuf != NULL)
- {
- HX_RELEASE(pBuf);
- m_pActiveNamespaceMap->RemoveKey(pNS->m_name);
- // check for conficts.
- if (m_pNSConflictList)
- {
- LISTPOSITION pos = m_pNSConflictList->GetHeadPosition();
- while (pos)
- {
- SMIL1Namespace* pCon =
- (SMIL1Namespace*)m_pNSConflictList->GetAt(pos);
- if (strcmp(pCon->m_name, pNS->m_name) == 0)
- {
- (*m_pActiveNamespaceMap)[pCon->m_name] = pCon->m_pValue;
- pCon->m_pValue->AddRef();
- HX_DELETE(pCon);
- m_pNSConflictList->RemoveAt(pos);
- // BREAK at the first found match.
- break;
- }
- m_pNSConflictList->GetNext(pos);
- }
- }
- }
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::addGlobalNamespace(const char* pNamespace,
- const char* pPrefix)
- {
- HX_RESULT rc = HXR_OK;
- if(m_bNoNamespaces)
- {
- rc = HXR_FAIL;
- CSmil1SMILSyntaxErrorHandler errHandler(m_pContext);
- errHandler.ReportError(SMILErrorSMIL10Document, NULL, 0);
- }
- else if (pNamespace)
- {
- if(!m_pActiveNamespaceMap)
- {
- m_pActiveNamespaceMap = new CHXMapStringToOb;
- }
- if (!m_pRequireTagsMap)
- {
- m_pRequireTagsMap = new CHXMapStringToOb;
- }
- if(pPrefix)
- {
- // get an IHXBuffer
- //XXXJEFFA should use CF for this
- IHXBuffer* pBuffer = (IHXBuffer*) new CHXBuffer;
- pBuffer->AddRef();
- pBuffer->Set((UINT8*)pNamespace, strlen(pNamespace) + 1);
- (*m_pActiveNamespaceMap)[pPrefix] = pBuffer;
-
- // add the prefix to the require map so system
- // required checks work
- (*m_pRequireTagsMap)[pPrefix] = 0;
- if(strcmp(pPrefix, (const char*) RN_PREFIX) == 0)
- {
- m_bRNNamespace = TRUE;
- }
- }
- else
- {
- // empty prefix,
- // don't ignore unrecognized elements...
- m_bIgnoreUnrecognizedElements = FALSE;
- }
- }
- return rc;
- }
- HX_RESULT
- CSmil1Parser::storeError(HX_RESULT errCode, const char* pErrorString,
- const char* pFrameString, UINT32 ulLineNumber,
- UINT32 ulLinePosition, BOOL bXml)
- {
- // XXXJHUG - this is what the SMIL error hanndler uses 1024....
- char errorString[1024]; /* Flawfinder: ignore */
- if (bXml)
- {
- CSmil1XMLSyntaxErrorHandler errHandler(m_pContext);
-
- errHandler.GetReportString(errCode, errorString);
- }
- else
- {
- CSmil1SMILSyntaxErrorHandler errHandler(m_pContext);
-
- errHandler.GetReportString((SMILErrorTag)errCode, errorString);
- }
- IHXBuffer* pBuf;
- m_pClassFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pBuf);
- pBuf->SetSize(strlen(errorString) + strlen(pErrorString) + 10);
- char* buffer = (char*) pBuf->GetBuffer();
- sprintf(buffer, errorString, ulLineNumber, pErrorString); /* Flawfinder: ignore */
- m_pErrors->Add(pBuf);
- return HXR_OK;
- }
- HX_RESULT
- CSmil1Parser::getErrors(CHXPtrArray** pErrs)
- {
- *pErrs = m_pErrors;
- return HXR_OK;
- }
- ElementWithinTag
- CSmil1Parser::GetElementWithin(const char* pID)
- {
- ElementWithinTag elementWithinTag = WithinUnknown;
- SMIL1Node* pNode = NULL;
- SMIL1Node* pParentNode = NULL;
- if(!m_pIDMap->Lookup(pID, (void*&)pNode))
- {
- HX_ASSERT(FALSE);
- goto cleanup;
- }
- while (pNode->m_pParent)
- {
- switch (pNode->m_pParent->m_tag)
- {
- case SMILPar:
- if (elementWithinTag == WithinSeq)
- {
- elementWithinTag = WithinSeqInPar;
- }
- else
- {
- elementWithinTag = WithinPar;
- }
- goto cleanup;
- case SMILSeq:
- elementWithinTag = WithinSeq;
- break;
- default:
- break;
- }
- pNode = pNode->m_pParent;
- }
- cleanup:
- return elementWithinTag;
- }
- void
- CSmil1Parser::InitPersistent(UINT32 ulPersistentComponentID,
- ElementWithinTag elementWithinTag)
- {
- m_ulPersistentComponentID = ulPersistentComponentID;
- m_elementWithinTag = elementWithinTag;
- }
- /*
- * CSmil1ParserResponse methods
- */
- CSmil1ParserResponse::CSmil1ParserResponse(CSmil1Parser* pParser)
- : m_pParser(pParser)
- , m_lRefCount(0)
- {
- }
- CSmil1ParserResponse::~CSmil1ParserResponse()
- {
- }
- STDMETHODIMP
- CSmil1ParserResponse::QueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXXMLParserResponse))
- {
- AddRef();
- *ppvObj = (IHXXMLParserResponse*)this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- STDMETHODIMP_(ULONG32)
- CSmil1ParserResponse::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- STDMETHODIMP_(ULONG32)
- CSmil1ParserResponse::Release()
- {
- if (InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleStartElement(const char* pName,
- IHXValues* pAttributes,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- SMIL1Node* pParentNode =
- (SMIL1Node*)m_pParser->m_pNodeListStack->TopOfStack();
- HX_ASSERT(pParentNode);
- SMIL1Node* pNode = new SMIL1Node;
- pNode->m_name = pName;
- pNode->m_pParent = pParentNode;
- pNode->m_pNodeList = new SMIL1NodeList;
- pNode->m_pNodeList->m_pParentNode = pNode;
- pNode->m_ulTagStartLine = ulLineNumber;
- pNode->m_ulTagStartColumn = ulColumnNumber;
- if(!pNode->m_pParent->m_bSkipContent)
- {
- IHXBuffer* pBuffer = NULL;
- if(HXR_OK == pAttributes->GetPropertyCString("id", pBuffer))
- {
- const char* pID = (const char*)pBuffer->GetBuffer();
- // XXXMEH - 04/27/99 - change this to still throw
- // an error for isspace(), but not for isdigit()
- // - not legal SMIL, but we still allowed
- // it in previous players.
- // if (isdigit(*pID) || isspace(*pID))
- if (isspace(*pID))
- {
- rc = HXR_XML_ILLEGALID;
- CSmil1XMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- errHandler.ReportError(rc, pID, ulLineNumber);
- goto exit;
- }
- else if (m_pParser->m_bStoreErrors && isdigit(*pID))
- {
- m_pParser->storeError(HXR_XML_ILLEGALID, pID, 0,
- ulLineNumber, ulColumnNumber);
- }
- else
- {
- // append persistent ID to the end of region id
- // to make it unique in nested meta
- if (!strcmp(pNode->m_name, "region"))
- {
- //char szPersistentComponentID[MAX_DISPLAY_NAME] = {0};
- //itoa(m_pParser->m_ulPersistentComponentID, szPersistentComponentID, 10);
-
- pNode->m_id = pID;
- //pNode->m_id += "_";
- //pNode->m_id += szPersistentComponentID;
- pNode->m_repeatid = pNode->m_id;
- }
- else
- {
- pNode->m_id = pID;
- pNode->m_repeatid = pID;
- }
- HX_RELEASE(pBuffer);
- }
- }
- else
- {
- //[SMIL 1.0 Compliance] Fixes PR 24034: region tag must have
- // an id attribute:
- if (m_pParser->m_bSMIL10FullCompliance &&
- !strcmp(pNode->m_name, "region"))
- {
- rc = HXR_XML_ILLEGALID;
- CSmil1XMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- const char* pTmp = "region id=""";
- errHandler.ReportError(rc, pTmp, ulLineNumber);
- goto exit;
- }
- else
- {
- pNode->m_id = m_pParser->assignID(pName);
- pNode->m_repeatid = pNode->m_id;
- }
- if (m_pParser->m_bStoreErrors && !strcmp(pNode->m_name, "region"))
- {
- const char* pTmp = "region id=""";
- m_pParser->storeError(HXR_XML_ILLEGALID, pTmp, 0,
- ulLineNumber, ulColumnNumber);
- }
- }
-
- if(HXR_OK != m_pParser->mapID(pNode))
- {
- rc = HXR_XML_ILLEGALID;
- CSmil1XMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- errHandler.ReportError(rc, pNode->m_id, ulLineNumber);
- goto exit;
- }
- if(strcmp(pName, "smil") == 0)
- {
- pNode->m_tag = SMILSmil;
- }
- else if(strcmp(pName, "layout") == 0)
- {
- pNode->m_tag = SMILBasicLayout;
- if(HXR_OK == pAttributes->GetPropertyCString("type", pBuffer))
- {
- const char* pType = (const char*)pBuffer->GetBuffer();
- if(strcmp(pType, "text/smil-basic-layout") != 0)
- {
- pNode->m_bDelete = TRUE; // only basic layout supported
- }
- HX_RELEASE(pBuffer);
- }
- }
- else if(strcmp(pName, "meta") == 0)
- {
- pNode->m_tag = SMILMeta;
- pNode->m_bSkipContent = TRUE;
- }
- else if(strcmp(pName, "head") == 0)
- {
- pNode->m_id = "head";
- pNode->m_tag = SMILHead;
- }
- else if(strcmp(pName, "body") == 0)
- {
- pNode->m_id = "body";
- pNode->m_tag = SMILBody;
- }
- else if(strcmp(pName, "region") == 0)
- {
- pNode->m_tag = SMILRegion;
- pNode->m_bSkipContent = TRUE;
- }
- else if(strcmp(pName, "root-layout") == 0)
- {
- pNode->m_tag = SMILRootLayout;
- pNode->m_bSkipContent = TRUE;
- }
- else if(strcmp(pName, "switch") == 0)
- {
- pNode->m_tag = SMILSwitch;
- }
- else if(strcmp(pName, "text") == 0)
- {
- pNode->m_tag = SMILText;
- }
- else if(strcmp(pName, "img") == 0)
- {
- pNode->m_tag = SMILImg;
- }
- else if(strcmp(pName, "ref") == 0)
- {
- pNode->m_tag = SMILRef;
- }
- else if(strcmp(pName, "audio") == 0)
- {
- pNode->m_tag = SMILAudio;
- }
- else if(strcmp(pName, "video") == 0)
- {
- pNode->m_tag = SMILVideo;
- }
- else if(strcmp(pName, "animation") == 0)
- {
- pNode->m_tag = SMILAnimation;
- }
- else if(strcmp(pName, "textstream") == 0)
- {
- pNode->m_tag = SMILTextstream;
- }
- else if(strcmp(pName, "a") == 0)
- {
- pNode->m_tag = SMILAAnchor;
- }
- else if(strcmp(pName, "anchor") == 0)
- {
- pNode->m_tag = SMILAnchor;
- pNode->m_bSkipContent = TRUE;
- }
- else if(strcmp(pName, "par") == 0)
- {
- pNode->m_tag = SMILPar;
- }
- else if(strcmp(pName, "seq") == 0)
- {
- pNode->m_tag = SMILSeq;
- }
- else if(m_pParser->m_bRNNamespace &&
- strcmp(pName, (const char*) RN_TAG_RENDERER_LIST) == 0)
- {
- pNode->m_id = m_pParser->assignID((const char*) RN_TAG_RENDERER_LIST);
- pNode->m_tag = SMILRNRendererList;
- }
- else if(strcmp(pName, (const char*) RN_TAG_RENDERER) == 0)
- {
- pNode->m_tag = SMILRendererPreFetch;
- }
- else
- {
- BOOL bValidTag = FALSE;
- char* pColon = (char *)strchr(pName, ':');
- if(pColon)
- {
- //check for valid namespace tag we can
- // ignore
- char* pTmpNam = new_string(pName);
- char* pNamespace = strtok(pTmpNam, ":");
- if(pNamespace)
- {
- UINT32 ulTemp = 0;
- if(m_pParser->m_pActiveNamespaceMap &&
- (m_pParser->m_pActiveNamespaceMap->Lookup(pNamespace,
- (void*&)ulTemp)))
- {
- // OK, we can ignore it...
- bValidTag = TRUE;
- }
- }
- delete[] pTmpNam;
- }
- if(!bValidTag &&
- !m_pParser->m_bIgnoreUnrecognizedElements)
- {
- rc = HXR_FAIL;
- CSmil1SMILSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- errHandler.ReportError(SMILErrorUnrecognizedTag, pName, ulLineNumber);
- goto exit;
- }
- else
- {
- pNode->m_bDelete = TRUE; // don't ask, don't tell...
- }
- if (!bValidTag && m_pParser->m_bStoreErrors)
- {
- m_pParser->storeError(SMILErrorUnrecognizedTag, pName, 0,
- ulLineNumber, ulColumnNumber, FALSE);
- }
- }
- pNode->m_pValues = pAttributes;
- pNode->m_pValues->AddRef();
- rc = m_pParser->storeNamespaces(pNode);
- if (SUCCEEDED(rc))
- {
- rc = m_pParser->addToNamespaceScope(pNode);
- }
- const char* pName = NULL;
- HX_RESULT res = pAttributes->GetFirstPropertyCString(pName, pBuffer);
- while(HXR_OK == res && SUCCEEDED(rc))
- {
- const char* pActualValue = (const char*)pBuffer->GetBuffer();
- if(!m_pParser->isLegalAttribute(pNode->m_tag, pName) )
- {
- if (!m_pParser->m_bIgnoreUnrecognizedElements)
- {
- rc = HXR_FAIL;
- m_pParser->badAttributeError(pNode->m_tag, pName,
- pNode->m_ulTagStartLine, FALSE);
- break;
- }
-
- if (m_pParser->m_bStoreErrors)
- {
- m_pParser->badAttributeError(pNode->m_tag, pName,
- ulLineNumber, TRUE);
- }
- }
- if(strcmp(pName, "skip-content") == 0)
- {
- if(strcmp(pActualValue, "true") == 0)
- {
- pNode->m_bSkipContent = TRUE;
- }
- else
- {
- pNode->m_bSkipContent = FALSE;
- }
- }
- HX_RELEASE(pBuffer);
- res = pAttributes->GetNextPropertyCString(pName, pBuffer);
- }
- m_pParser->m_pNodeListStack->Push(pNode);
- }
- exit:
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleEndElement(const char* pName,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- SMIL1Node* pCurrentNode = (SMIL1Node*)m_pParser->m_pNodeListStack->Pop();
- SMIL1Node* pParentNode = (SMIL1Node*)m_pParser->m_pNodeListStack->TopOfStack();
- HX_ASSERT(pCurrentNode);
- HX_ASSERT(pParentNode);
- if (pParentNode)
- {
- pParentNode->m_pNodeList->AddTail(pCurrentNode);
- }
- SMIL1Node* pEndNode = new SMIL1Node;
- pEndNode->m_name = pName;
- pEndNode->m_id.Format("CLOSE-%s", pName);
- pEndNode->m_pParent = pParentNode;
- pEndNode->m_ulTagStartLine = ulLineNumber;
- pEndNode->m_ulTagStartColumn = ulColumnNumber;
- if(strcmp(pName, "seq") == 0)
- {
- pEndNode->m_tag = SMILEndSeq;
- }
- else if(strcmp(pName, "par") == 0)
- {
- pEndNode->m_tag = SMILEndPar;
- }
- else if(strcmp(pName, "a") == 0)
- {
- pEndNode->m_tag = SMILEndAAnchor;
- }
- pCurrentNode->m_pNodeList->AddTail(pEndNode);
- rc = m_pParser->removeFromNamespaceScope(pCurrentNode);
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleCharacterData(IHXBuffer* pBuffer,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleProcessingInstruction(const char* pTarget,
- IHXValues* pAttributes,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- if(strcmp(pTarget, "xml:namespace") == 0)
- {
- IHXBuffer* pNamespaceBuffer = NULL;
- IHXBuffer* pPrefixBuffer = NULL;
- const char* pNamespace = NULL;
- const char* pPrefix = NULL;
- if(HXR_OK == pAttributes->GetPropertyCString("ns", pNamespaceBuffer))
- {
- pNamespace = (const char*)pNamespaceBuffer->GetBuffer();
- }
- if(HXR_OK == pAttributes->GetPropertyCString("prefix", pPrefixBuffer))
- {
- pPrefix = (const char*)pPrefixBuffer->GetBuffer();
- }
- rc = m_pParser->addGlobalNamespace(pNamespace, pPrefix);
- HX_RELEASE(pNamespaceBuffer);
- HX_RELEASE(pPrefixBuffer);
- }
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleUnparsedEntityDecl(const char* /*IN*/ pEntityName,
- const char* /*IN*/ pSystemID,
- const char* /*IN*/ pPublicID,
- const char* /*IN*/ pNotationName,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleNotationDecl(const char* /*IN*/ pNotationName,
- const char* /*IN*/ pSystemID,
- const char* /*IN*/ pPublicID,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleUnparsedDoctypeDecl(const char* /*IN*/ pName,
- const char* /*IN*/ pSystemID,
- const char* /*IN*/ pPublicID,
- UINT32 /*IN*/ ulLineNumber,
- UINT32 /*IN*/ ulColumNumber)
- {
- HX_RESULT rc = HXR_OK;
- if(strcmp(pName, "smil") == 0 &&
- strcmp(pSystemID, "http://www.w3.org/TR/REC-smil/SMIL10.dtd") == 0 &&
- strcmp(pPublicID, "-//W3C//DTD SMIL 1.0//EN") == 0)
- {
- // only be strict, still allow namespaces...
- //m_pParser->m_bNoNamespaces = TRUE;
- m_pParser->m_bIgnoreUnrecognizedElements = FALSE;
- }
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleComment(const char* /*IN*/ pComment,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- STDMETHODIMP
- CSmil1ParserResponse::HandleDefault(IHXBuffer* /*IN*/ pBuffer,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- HX_RESULT
- CSmil1ParserResponse::ErrorInLastTag(HX_RESULT err,
- const char* pErrorString, const char* pFrameString,
- UINT32 ulLineNumber, UINT32 ulLinePosition)
- {
- // XXXJHUG - we could add the error to the actual node...
- // SMIL1Node* pCurrentNode = (SMIL1Node*)m_pParser->m_pNodeListStack->Pop();
- // pCurrentNode->m_errs->Add
- //
- // If we were going to warn for errors I think the warnings should be
- // thrown from here. (modify ReportError to have a warning level.)
- //
- // But for dumping the errors there is no benifit for this.
- // therefore we will just add the error to a ptr array of errors.
- // this array will also be added to when the SMIL attributes are bad.
- //
- // XXX to store in the parse tree you also have to make sure the last
- // call was a tag, and not a PI or a directive or something that was
- // ignored.
-
- return m_pParser->storeError(err, pErrorString, pFrameString,
- ulLineNumber, ulLinePosition);
- }
- /*
- * SMIL1Node methods
- */
- SMIL1Node::SMIL1Node():
- m_pNodeList(0),
- m_pParent(0),
- m_pDependency(0),
- m_tag(SMILUnknown),
- m_num(0),
- m_pValues(0),
- m_curPosition(0),
- m_pElement(0),
- m_nGroup((UINT16)-1),
- m_bLastInGroup(FALSE),
- m_bDelete(FALSE),
- m_bSkipContent(FALSE),
- m_pNamespaceList(NULL),
- m_bRepeatHandled(FALSE),
- m_repeatTag(RepeatUnknown)
- {
- }
- SMIL1Node::SMIL1Node(const SMIL1Node& rhs, BOOL bKeepId, CSmil1Parser* pParser)
- {
- if (bKeepId)
- {
- m_id = rhs.m_id;
- }
- else
- {
- // need a unique ID, so make one...
- char* pIDName = new char [256];
- if (pIDName && pParser)
- {
- sprintf(pIDName, "node_copy_%ld", pParser->GetUniqueNumber()); /* Flawfinder: ignore */
- m_id = pIDName;
- }
- HX_VECTOR_DELETE(pIDName);
- }
- m_repeatid = rhs.m_repeatid;
- m_pParent = rhs.m_pParent;
- m_pDependency = rhs.m_pDependency;
- m_tag = rhs.m_tag;
- m_num = rhs.m_num;
- m_curPosition = rhs.m_curPosition;
- m_pElement = rhs.m_pElement;
- m_nGroup = rhs.m_nGroup;
- m_bLastInGroup = rhs.m_bLastInGroup;
- m_bDelete = rhs.m_bDelete;
- m_bSkipContent = rhs.m_bSkipContent;
- m_bRepeatHandled = FALSE;
- m_repeatTag = rhs.m_repeatTag;
- if(rhs.m_pValues)
- {
- m_pValues = rhs.m_pValues;
- m_pValues->AddRef();
- }
- else
- {
- m_pValues = NULL;
- }
- if(rhs.m_pNodeList)
- {
- m_pNodeList = rhs.m_pNodeList->copy(this, bKeepId, pParser);
- }
- else
- {
- m_pNodeList = NULL;
- }
- if (rhs.m_pNamespaceList)
- {
- m_pNamespaceList = new CHXSimpleList;
- for (CHXSimpleList::Iterator pIt = rhs.m_pNamespaceList->Begin();
- pIt != rhs.m_pNamespaceList->End(); ++pIt)
- {
- SMIL1Namespace* pNS = (SMIL1Namespace*)(*pIt);
- SMIL1Namespace* pNewNS = new SMIL1Namespace(pNS);
- m_pNamespaceList->AddHead(pNewNS);
- }
- }
- else
- {
- m_pNamespaceList = NULL;
- }
- }
- SMIL1Node::~SMIL1Node()
- {
- HX_DELETE(m_pNodeList);
- HX_RELEASE(m_pValues);
- if (m_pNamespaceList)
- {
- while (!m_pNamespaceList->IsEmpty())
- {
- SMIL1Namespace* pNS = (SMIL1Namespace*)m_pNamespaceList->RemoveHead();
- HX_DELETE(pNS);
- }
- }
- HX_DELETE(m_pNamespaceList);
- }
- SMIL1Node*
- SMIL1Node::getFirstChild()
- {
- if(!m_pNodeList)
- {
- return 0;
- }
- m_curPosition = m_pNodeList->GetHeadPosition();
- if(m_curPosition)
- {
- return (SMIL1Node*)m_pNodeList->GetNext(m_curPosition);
- }
- return 0;
- }
- SMIL1Node*
- SMIL1Node::getNextChild()
- {
- if(m_curPosition)
- {
- return (SMIL1Node*)m_pNodeList->GetNext(m_curPosition);
- }
- return 0;
- }
- SMIL1NodeList::SMIL1NodeList():
- m_pParentNode(0)
- {
- }
- SMIL1NodeList::~SMIL1NodeList()
- {
- CHXSimpleList::Iterator i;
- for(i = Begin(); i != End(); ++i)
- {
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- HX_DELETE(pNode);
- }
- }
- SMIL1NodeList*
- SMIL1NodeList::copy(SMIL1Node* pParent, BOOL bKeepId, CSmil1Parser* pParser)
- {
- SMIL1NodeList* pNewList = new SMIL1NodeList;
- m_pParentNode = pParent;
- CHXSimpleList::Iterator i = Begin();
- for(; i != End(); ++i)
- {
- SMIL1Node* pNode = (SMIL1Node*)(*i);
- SMIL1Node* pNodeCopy = new SMIL1Node(*pNode, bKeepId, pParser);
- pNodeCopy->m_pParent = pParent;
- pNewList->AddTail(pNodeCopy);
- }
- return pNewList;
- }