smlparse.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:879k
- }
- cleanup:
- return pNextSibling;
- }
- HX_RESULT
- CSmilParser::constructTimelineElements(SMILNodeList* 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;
- }
- SMILNode* pNode = (SMILNode*)(*i);
- if(pNode->m_bDelete) // skip this puppy
- {
- continue;
- }
- switch(pNode->m_tag)
- {
- case SMILSeq:
- {
- SMILNode* pChildNode = getTimelineDescendent(pNode, NULL);
- CSmilTimelineElement* 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 SMILExcl:
- case SMILPar:
- {
- SMILNode* 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);
- }
- // /When element has <a>, <priorityClass>, or
- // <switch> child (i.e., a non-timeline element child)
- // which itself has multiple timed children, make sure
- // more than just the first of those elements gets added
- // to the child list (a bug since SMIL-1 implementation):
- pChildNode = getTimelineDescendent(pNode, pChildNode);
- }
- }
- break;
- // XXXMEH - we need to let media objects be time containers
- // - will this have side effect on <anchor>?
- case SMILText:
- case SMILImg:
- case SMILRef:
- case SMILAudio:
- case SMILVideo:
- case SMILAnimation:
- case SMILTextstream:
- case SMILBrush:
- case SMILPrefetch:
- {
- SMILNode* 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
- CSmilParser::handleNextElement(CSmilElementHandler* pHandler)
- {
- HX_RESULT rc = HXR_OK;
- if(m_pPacketQueue->GetCount() > 0)
- {
- CSmilElement* pElement = (CSmilElement*)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;
- }
- HX_RESULT CSmilParser::setAllElementHandlers(CSmilElementHandler* pHandler)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pHandler)
- {
- SMILNode* pNode = findFirstNode(SMILSmil);
- if (pNode)
- {
- retVal = setElementHandler(pNode, pHandler);
- }
- }
- return retVal;
- }
- void
- CSmilParser::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;
- (*pStringMap)["system-required"] = 0;
- (*pStringMap)["systemRequired"] = 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)["backgroundColor"] = 0;
- (*pStringMap)["left"] = 0;
- (*pStringMap)["top"] = 0;
- (*pStringMap)["z-index"] = 0;
- (*pStringMap)["fit"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*pStringMap)["soundLevel"] = 0;
- (*m_pTagAttributeMap)[SMILRegion] = pStringMap;
- // SMILRegPoint
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["left"] = 0;
- (*pStringMap)["top"] = 0;
- (*pStringMap)["right"] = 0;
- (*pStringMap)["bottom"] = 0;
- (*pStringMap)["regAlign"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*m_pTagAttributeMap)[SMILRegPoint] = pStringMap;
- // SMILViewport
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["background-color"] = 0;
- (*pStringMap)["backgroundColor"] = 0;
- (*pStringMap)["width"] = 0;
- (*pStringMap)["height"] = 0;
- (*pStringMap)["open"] = 0;
- (*pStringMap)["close"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*m_pTagAttributeMap)[SMILViewport] = pStringMap;
- // SMILTransition
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["type"] = 0;
- (*pStringMap)["subtype"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["base"] = 0;
- (*pStringMap)["startPercent"] = 0;
- (*pStringMap)["endPercent"] = 0;
- (*pStringMap)["horzRepeat"] = 0;
- (*pStringMap)["vertRepeat"] = 0;
- (*pStringMap)["startX"] = 0;
- (*pStringMap)["startY"] = 0;
- (*pStringMap)["endX"] = 0;
- (*pStringMap)["endY"] = 0;
- (*pStringMap)["borderWidth"] = 0;
- (*pStringMap)["color"] = 0;
- (*m_pTagAttributeMap)[SMILTransition] = pStringMap;
- // SMILRootLayout
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["height"] = 0;
- (*pStringMap)["width"] = 0;
- (*pStringMap)["background-color"] = 0;
- (*pStringMap)["backgroundColor"] = 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;
- // SMILMetadata
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*m_pTagAttributeMap)[SMILMetadata] = pStringMap;
- // SMILBody
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["restart"] = 0;
- (*pStringMap)["restartDefault"] = 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)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["fill"] = 0;
- (*pStringMap)["erase"] = 0;
- (*pStringMap)["region"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*pStringMap)["restart"] = 0;
- (*pStringMap)["restartDefault"] = 0;
- (*pStringMap)["syncTolerance"] = 0;
- (*pStringMap)["syncToleranceDefault"] = 0;
- (*pStringMap)["syncBehavior"] = 0;
- (*pStringMap)["syncBehaviorDefault"] = 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;
- (*pStringMap)["systemBitrate"] = 0;
- (*pStringMap)["systemLanguage"] = 0;
- (*pStringMap)["systemRequired"] = 0;
- (*pStringMap)["systemScreenSize"] = 0;
- (*pStringMap)["systemScreenDepth"] = 0;
- (*pStringMap)["systemCaptions"] = 0;
- (*pStringMap)["systemOverdubOrSubtitle"] = 0;
- (*pStringMap)["systemAudioDesc"] = 0;
- (*pStringMap)["systemCPU"] = 0;
- (*pStringMap)["systemComponent"] = 0;
- (*pStringMap)["systemOperatingSystem"] = 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)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["fill"] = 0;
- (*pStringMap)["erase"] = 0;
- (*pStringMap)["region"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*pStringMap)["restart"] = 0;
- (*pStringMap)["restartDefault"] = 0;
- (*pStringMap)["syncTolerance"] = 0;
- (*pStringMap)["syncToleranceDefault"] = 0;
- (*pStringMap)["syncBehavior"] = 0;
- (*pStringMap)["syncBehaviorDefault"] = 0;
- (*pStringMap)["systemBitrate"] = 0;
- (*pStringMap)["systemLanguage"] = 0;
- (*pStringMap)["systemRequired"] = 0;
- (*pStringMap)["systemScreenSize"] = 0;
- (*pStringMap)["systemScreenDepth"] = 0;
- (*pStringMap)["systemCaptions"] = 0;
- (*pStringMap)["systemOverdubOrSubtitle"] = 0;
- (*pStringMap)["systemAudioDesc"] = 0;
- (*pStringMap)["systemCPU"] = 0;
- (*pStringMap)["systemComponent"] = 0;
- (*pStringMap)["systemOperatingSystem"] = 0;
- (*m_pTagAttributeMap)[SMILSeq] = pStringMap;
- // SMILExcl
- 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)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["fill"] = 0;
- (*pStringMap)["erase"] = 0;
- (*pStringMap)["region"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*pStringMap)["restart"] = 0;
- (*pStringMap)["restartDefault"] = 0;
- (*pStringMap)["syncTolerance"] = 0;
- (*pStringMap)["syncToleranceDefault"] = 0;
- (*pStringMap)["syncBehavior"] = 0;
- (*pStringMap)["syncBehaviorDefault"] = 0;
- (*pStringMap)["systemBitrate"] = 0;
- (*pStringMap)["systemLanguage"] = 0;
- (*pStringMap)["systemRequired"] = 0;
- (*pStringMap)["systemScreenSize"] = 0;
- (*pStringMap)["systemScreenDepth"] = 0;
- (*pStringMap)["systemCaptions"] = 0;
- (*pStringMap)["systemOverdubOrSubtitle"] = 0;
- (*pStringMap)["systemAudioDesc"] = 0;
- (*pStringMap)["systemCPU"] = 0;
- (*pStringMap)["systemComponent"] = 0;
- (*pStringMap)["systemOperatingSystem"] = 0;
- (*m_pTagAttributeMap)[SMILExcl] = pStringMap;
- // SMILPriorityClass
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["peers"] = 0;
- (*pStringMap)["higher"] = 0;
- (*pStringMap)["lower"] = 0;
- (*pStringMap)["pauseDisplay"] = 0;
- (*pStringMap)["restartDefault"] = 0;
- (*pStringMap)["syncToleranceDefault"] = 0;
- (*pStringMap)["syncBehaviorDefault"] = 0;
- (*m_pTagAttributeMap)[SMILPriorityClass] = pStringMap;
- // SMILSwitch
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["restartDefault"] = 0;
- (*pStringMap)["syncToleranceDefault"] = 0;
- (*pStringMap)["syncBehaviorDefault"] = 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)["readindex"] = 0;
- (*pStringMap)["src"] = 0;
- (*pStringMap)["type"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeat"] = 0;
- (*pStringMap)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["fill"] = 0;
- (*pStringMap)["erase"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*pStringMap)["restart"] = 0;
- (*pStringMap)["restartDefault"] = 0;
- (*pStringMap)["syncTolerance"] = 0;
- (*pStringMap)["syncToleranceDefault"] = 0;
- (*pStringMap)["syncBehavior"] = 0;
- (*pStringMap)["syncBehaviorDefault"] = 0;
- (*pStringMap)["clip-begin"] = 0;
- (*pStringMap)["clipBegin"] = 0;
- (*pStringMap)["clip-end"] = 0;
- (*pStringMap)["clipEnd"] = 0;
- (*pStringMap)["sensitivity"] = 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;
- (*pStringMap)["systemBitrate"] = 0;
- (*pStringMap)["systemLanguage"] = 0;
- (*pStringMap)["systemRequired"] = 0;
- (*pStringMap)["systemScreenSize"] = 0;
- (*pStringMap)["systemScreenDepth"] = 0;
- (*pStringMap)["systemCaptions"] = 0;
- (*pStringMap)["systemOverdubOrSubtitle"] = 0;
- (*pStringMap)["systemAudioDesc"] = 0;
- (*pStringMap)["systemCPU"] = 0;
- (*pStringMap)["systemComponent"] = 0;
- (*pStringMap)["systemOperatingSystem"] = 0;
- (*pStringMap)["transition"] = 0;
- (*m_pTagAttributeMap)[SMILRef] = pStringMap;
- // SMILAAnchor
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["href"] = 0;
- (*pStringMap)["alt"] = 0;
- (*pStringMap)["longdesc"] = 0;
- (*pStringMap)["readindex"] = 0;
- (*pStringMap)["show"] = 0;
- (*pStringMap)["restartDefault"] = 0;
- (*pStringMap)["syncToleranceDefault"] = 0;
- (*pStringMap)["syncBehaviorDefault"] = 0;
- (*pStringMap)["sourceLevel"] = 0;
- (*pStringMap)["destinationLevel"] = 0;
- (*pStringMap)["sourcePlaystate"] = 0;
- (*pStringMap)["destinationPlaystate"] = 0;
- (*pStringMap)["external"] = 0;
- (*pStringMap)["actuate"] = 0;
- (*pStringMap)["accesskey"] = 0;
- (*pStringMap)["tabindex"] = 0;
- (*pStringMap)["target"] = 0;
- (*m_pTagAttributeMap)[SMILAAnchor] = pStringMap;
- // SMILArea
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["href"] = 0;
- (*pStringMap)["alt"] = 0;
- (*pStringMap)["longdesc"] = 0;
- (*pStringMap)["readindex"] = 0;
- (*pStringMap)["show"] = 0;
- (*pStringMap)["sourceLevel"] = 0;
- (*pStringMap)["destinationLevel"] = 0;
- (*pStringMap)["sourcePlaystate"] = 0;
- (*pStringMap)["destinationPlaystate"] = 0;
- (*pStringMap)["external"] = 0;
- (*pStringMap)["actuate"] = 0;
- (*pStringMap)["accesskey"] = 0;
- (*pStringMap)["tabindex"] = 0;
- (*pStringMap)["target"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeat"] = 0;
- (*pStringMap)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*pStringMap)["coords"] = 0;
- (*pStringMap)["fragment-id"] = 0;
- (*pStringMap)["fragment"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*pStringMap)["z-index"] = 0;
- (*m_pTagAttributeMap)[SMILArea] = pStringMap;
- // SMILAnchor
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["title"] = 0;
- (*pStringMap)["href"] = 0;
- (*pStringMap)["alt"] = 0;
- (*pStringMap)["longdesc"] = 0;
- (*pStringMap)["readindex"] = 0;
- (*pStringMap)["show"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeat"] = 0;
- (*pStringMap)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*pStringMap)["coords"] = 0;
- (*pStringMap)["fragment-id"] = 0;
- (*pStringMap)["fragment"] = 0;
- (*pStringMap)["skip-content"] = 0;
- (*pStringMap)["z-index"] = 0;
- (*m_pTagAttributeMap)[SMILAnchor] = pStringMap;
- // SMILRendererPreFetch
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["type"] = 0;
- (*m_pTagAttributeMap)[SMILRendererPreFetch] = pStringMap;
- // SMILAnimate
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["attributeName"] = 0;
- (*pStringMap)["targetElement"] = 0;
- (*pStringMap)["from"] = 0;
- (*pStringMap)["to"] = 0;
- (*pStringMap)["by"] = 0;
- (*pStringMap)["values"] = 0;
- (*pStringMap)["calcMode"] = 0;
- (*pStringMap)["accumulate"] = 0;
- (*pStringMap)["additive"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*m_pTagAttributeMap)[SMILAnimate] = pStringMap;
- // SMILSet
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["attributeName"] = 0;
- (*pStringMap)["targetElement"] = 0;
- (*pStringMap)["to"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*m_pTagAttributeMap)[SMILSet] = pStringMap;
- // SMILAnimateMotion
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["targetElement"] = 0;
- (*pStringMap)["from"] = 0;
- (*pStringMap)["to"] = 0;
- (*pStringMap)["by"] = 0;
- (*pStringMap)["values"] = 0;
- (*pStringMap)["accumulate"] = 0;
- (*pStringMap)["additive"] = 0;
- (*pStringMap)["calcMode"] = 0;
- (*pStringMap)["path"] = 0;
- (*pStringMap)["origin"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*m_pTagAttributeMap)[SMILAnimateMotion] = pStringMap;
- // SMILAnimateColor
- pStringMap = new CHXMapStringToOb;
- (*pStringMap)["id"] = 0;
- (*pStringMap)["attributeName"] = 0;
- (*pStringMap)["targetElement"] = 0;
- (*pStringMap)["from"] = 0;
- (*pStringMap)["to"] = 0;
- (*pStringMap)["by"] = 0;
- (*pStringMap)["values"] = 0;
- (*pStringMap)["calcMode"] = 0;
- (*pStringMap)["accumulate"] = 0;
- (*pStringMap)["additive"] = 0;
- (*pStringMap)["begin"] = 0;
- (*pStringMap)["end"] = 0;
- (*pStringMap)["dur"] = 0;
- (*pStringMap)["repeatDur"] = 0;
- (*pStringMap)["repeatCount"] = 0;
- (*pStringMap)["min"] = 0;
- (*pStringMap)["max"] = 0;
- (*m_pTagAttributeMap)[SMILAnimateColor] = pStringMap;
- }
- void
- CSmilParser::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
- CSmilParser::isLegalAttribute(SMILNodeTag 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 == SMILPrefetch ||
- tag == SMILBrush)
- {
- 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
- CSmilParser::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
- CSmilParser::storeNamespaces(SMILNode* 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...
- SMILNamespace* pNS = new SMILNamespace("", pBuffer);
- pNode->m_pNamespaceList->AddHead(pNS);
- if (SMILSmil == pNode->m_tag)
- {
- if (!m_pDefaultNamespace)
- {
- m_pDefaultNamespace = pBuffer;
- m_pDefaultNamespace->AddRef();
- }
- // /XXXEH- TODO: fire off error if there is more than
- // one default namespace?
- // else ...
- }
- }
- 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;
- SMILNamespace* pNS = new SMILNamespace(nsPrefix, pBuffer);
- pNode->m_pNamespaceList->AddHead(pNS);
- // /Now, fix Structure Interop #2.1 (unrecognized smil-tag namespace)
- // and #2.3 (SMIL 2.0-module namespaces in the smil tag):
- const char* pNamespace = (const char*)pBuffer->GetBuffer();
- if (pNamespace && isSupportedNonRNNamespace(pNamespace))
- {
- SMILNamespace* pNS = new SMILNamespace(nsPrefix, pBuffer);
- pNode->m_pNamespaceList->AddHead(pNS);
- if (!m_pRequireTagsMap)
- {
- m_pRequireTagsMap = new CHXMapStringToOb;
- }
- if (nsPrefix && *nsPrefix)
- {
- // /Add the prefix to the require map for systemRequired
- //checks:
- (*m_pRequireTagsMap)[nsPrefix] = 0;
- }
- }
- }
- HX_RELEASE(pBuffer);
- res = pNode->m_pValues->GetNextPropertyCString(pName, pBuffer);
- }
- }
- return rc;
- }
- HX_RESULT
- CSmilParser::addToNamespaceScope(SMILNode* pNode)
- {
- HX_RESULT rc = HXR_OK;
- if (!m_pActiveNamespaceMap)
- {
- m_pActiveNamespaceMap = new CHXMapStringToOb;
- if (!m_pActiveNamespaceMap)
- {
- return HXR_OUTOFMEMORY;
- }
- }
- if (pNode->m_pNamespaceList)
- {
- for (CHXSimpleList::Iterator pIt = pNode->m_pNamespaceList->Begin();
- pIt != pNode->m_pNamespaceList->End(); ++pIt)
- {
- SMILNamespace* pNS = (SMILNamespace*)(*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;
- }
- }
- SMILNamespace* pConflict = new SMILNamespace(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
- CSmilParser::removeFromNamespaceScope(SMILNode* pNode)
- {
- HX_RESULT rc = HXR_OK;
- if (pNode->m_pNamespaceList)
- {
- for (CHXSimpleList::Iterator pIt = pNode->m_pNamespaceList->Begin();
- pIt != pNode->m_pNamespaceList->End(); ++pIt)
- {
- SMILNamespace* pNS = (SMILNamespace*)(*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)
- {
- SMILNamespace* pCon =
- (SMILNamespace*)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;
- }
- BOOL
- CSmilParser::isSupportedNonRNNamespace(const char* pNamespace)
- {
- BOOL bIsSupportedNamespace = FALSE;
- if(m_bNoNamespaces)
- {
- CSmilSMILSyntaxErrorHandler errHandler(m_pContext);
- errHandler.ReportError(SMILErrorSMIL10Document, NULL, 0);
- }
- else
- {
- if (pNamespace && strlen(pNamespace)>0)
- {
- UINT32 ui=0;
- for (ui=0; ui<NUM_SUPPORTED_SMIL_2_0_MODULE_NAMESPACES; ui++)
- {
- if (0 == strcmp(
- (const char*) zm_pSupportedSMIL2ModuleNamespaces[ui],
- pNamespace) )
- {
- bIsSupportedNamespace = TRUE;
- break;
- }
- }
- }
- }
- if (!bIsSupportedNamespace)
- {
- bIsSupportedNamespace =
- (0==strcmp((const char*) SYSTEM_COMPONENT_NAMESPACE, pNamespace));
- }
- return bIsSupportedNamespace;
- }
- HX_RESULT
- CSmilParser::addGlobalNamespace(const char* pNamespace,
- const char* pPrefix)
- {
- HX_RESULT rc = HXR_OK;
- if(m_bNoNamespaces)
- {
- rc = HXR_FAIL;
- CSmilSMILSyntaxErrorHandler errHandler(m_pContext);
- errHandler.ReportError(SMILErrorSMIL10Document, NULL, 0);
- }
- else
- {
- 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
- CSmilParser::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)
- {
- CSmilXMLSyntaxErrorHandler errHandler(m_pContext);
- errHandler.GetReportString(errCode, errorString);
- }
- else
- {
- CSmilSMILSyntaxErrorHandler 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
- CSmilParser::getErrors(CHXPtrArray** pErrs)
- {
- *pErrs = m_pErrors;
- return HXR_OK;
- }
- const char*
- CSmilParser::getDefaultNamespace()
- {
- if (!m_pDefaultNamespace)
- {
- return NULL;
- }
- return (const char*)m_pDefaultNamespace->GetBuffer();
- }
- HX_RESULT CSmilParser::parseRegionDimension(const char* pszStr,
- REF(double) rdValue,
- REF(CSS2Type) reType)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- // "left", "top", "right", "bottom", "width", and "height"
- // must fit this definition from the CSS2 spec
- // (http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-left)
- //
- // <length> | <percentage> | 'auto' | 'inherit'
- //
- // WS := ' ' | 'n' | 'r' | 't'
- // <length> := WS* [+|-] [0-9] ['.'] [0-9] ['px'] WS*
- // <percentage> := WS* [+|-] [0-9] ['.'] [0-9] '%' WS*
- //
- if (!strcmp(pszStr, "auto"))
- {
- rdValue = 0.0;
- reType = CSS2TypeAuto;
- }
- else if (!strcmp(pszStr, "inherit"))
- {
- rdValue = 0.0;
- reType = CSS2TypeInherit;
- }
- else
- {
- // Check to make sure the string is valid
- //
- // Here is the definition of the state machine
- // 0 is the starting state
- // If you end in state 7, you are a <length>
- // If you end in state 6, you are a <percentage>
- // If you end in state -1, this is an error
- //
- // State -1: // error state
- // else goto state -1
- // State 0: // starting state
- // WS goto state 0
- // +,- goto state 1
- // 0-9 goto state 2
- // . goto state 3
- // else goto state -1
- // State 1: // just saw + or -
- // 0-9 goto state 2
- // . goto state 3
- // else goto state -1
- // State 2: // have already seen at least one 0-9
- // 0-9 goto state 2
- // . goto state 4
- // p goto state 5
- // % goto state 6
- // NULL goto state 7
- // WS goto state 7
- // else goto state -1
- // State 3: // saw a . without seeing a 0-9
- // 0-9 goto state 4
- // else goto state -1
- // State 4: // saw a . after seeing a 0-9
- // 0-9 goto state 4
- // p goto state 5
- // % goto state 6
- // NULL goto state 7
- // WS goto state 7
- // else goto state -1
- // State 5:
- // x goto state 7
- // else goto state -1
- // State 6: // <percentage> ending state
- // WS goto state 6
- // NULL goto state 6
- // else goto state -1
- // State 7: // <length> ending state
- // WS goto state 7
- // NULL goto state 7
- // else goto state -1
- //
- const char* pszTmp = pszStr;
- const char* pszLimit = pszTmp + strlen(pszTmp);
- INT32 lState = 0;
- while (pszTmp <= pszLimit)
- {
- char c = *pszTmp++;
- switch (lState)
- {
- case -1:
- break;
- case 0:
- {
- if (c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 0;
- }
- else if (c == '+' || c == '-')
- {
- lState = 1;
- }
- else if (c >= '0' && c <= '9')
- {
- lState = 2;
- }
- else if (c == '.')
- {
- lState = 3;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 1:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 2;
- }
- else if (c == '.')
- {
- lState = 3;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 2:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 2;
- }
- else if (c == '.')
- {
- lState = 4;
- }
- else if (c == 'p')
- {
- lState = 5;
- }
- else if (c == '%')
- {
- lState = 6;
- }
- else if (c == ' ')
- {
- lState = 7;
- }
- else if (c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 7;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 3:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 4;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 4:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 4;
- }
- else if (c == 'p')
- {
- lState = 5;
- }
- else if (c == '%')
- {
- lState = 6;
- }
- else if (c == ' ')
- {
- lState = 7;
- }
- else if (c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 7;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 5:
- {
- if (c == 'x')
- {
- lState = 7;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 6:
- {
- if (c == ' ' || c == 'r' || c == 'n' ||
- c == 't' || c == ' ')
- {
- lState = 6;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 7:
- {
- if (c == ' ' || c == 'r' || c == 'n' ||
- c == 't' || c == ' ')
- {
- lState = 7;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- }
- }
- // Check to see if we ended in a valid state
- if (lState == 6)
- {
- // We are a percentage
- reType = CSS2TypePercentage;
- }
- else if (lState == 7)
- {
- // We are a length
- reType = CSS2TypeLength;
- }
- else
- {
- // Error
- retVal = HXR_FAIL;
- }
- if (SUCCEEDED(retVal))
- {
- // Now it's safe to use strtod() to parse
- // the value
- rdValue = strtod(pszStr, NULL);
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseZIndex(const char* pszStr,
- REF(INT32) rlValue,
- REF(CSS2Type) reType)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- // "z-index" must fit this definition from the CSS2 spec
- // (http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-z-index)
- //
- // <integer> | 'auto' | 'inherit'
- //
- // WS := ' ' | 'n' | 'r' | 't'
- // <integer> := WS* [+|-] [0-9]+ WS*
- //
- if (!strcmp(pszStr, "auto"))
- {
- rlValue = 0;
- reType = CSS2TypeAuto;
- }
- else if (!strcmp(pszStr, "inherit"))
- {
- rlValue = 0;
- reType = CSS2TypeInherit;
- }
- else
- {
- // Check to make sure the string is valid
- //
- // Here is the definition of the state machine
- // 0 is the starting state
- // 3 is the successful ending state
- // If you end in state -1, this is an error
- //
- // State -1: // error state
- // else goto state -1
- // State 0: // starting state
- // WS goto state 0
- // +,- goto state 1
- // 0-9 goto state 2
- // else goto state -1
- // State 1: // just saw + or -
- // 0-9 goto state 2
- // else goto state -1
- // State 2: // have already seen at least one 0-9
- // 0-9 goto state 2
- // WS goto state 3
- // NULL goto state 3
- // else goto state -1
- // State 3: // happy ending state
- // WS goto state 3
- // NULL goto state 3
- // else goto state -1
- //
- const char* pszTmp = pszStr;
- const char* pszLimit = pszTmp + strlen(pszTmp);
- INT32 lState = 0;
- while (pszTmp <= pszLimit)
- {
- char c = *pszTmp++;
- switch (lState)
- {
- case -1:
- break;
- case 0:
- {
- if (c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 0;
- }
- else if (c == '+' || c == '-')
- {
- lState = 1;
- }
- else if (c >= '0' && c <= '9')
- {
- lState = 2;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 1:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 2;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 2:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 2;
- }
- else if (c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 3;
- }
- else if (c == ' ')
- {
- lState = 3;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 3:
- {
- if (c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 3;
- }
- else if (c == ' ')
- {
- lState = 3;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- }
- }
- // Check to see if we ended in a valid state
- if (lState == 3)
- {
- // We are a <integer>
- reType = CSS2TypeInteger;
- // Now we can safely use atol() to
- // parse the value
- rlValue = atol(pszStr);
- }
- else
- {
- // Error
- retVal = HXR_FAIL;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseColor(const char* pszStr,
- REF(UINT32) rulValue,
- REF(CSS2Type) reType)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- // "backgroundColor" must fit this definition from the CSS2 spec
- // (http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-color)
- //
- // <color> | 'transparent' | 'inherit'
- //
- UINT32 ulColor = 0;
- if (!strcmp(pszStr, "transparent"))
- {
- rulValue = 0xFF000000;
- reType = CSS2TypeTransparent;
- }
- else if (!strcmp(pszStr, "inherit"))
- {
- rulValue = 0;
- reType = CSS2TypeInherit;
- }
- else
- {
- UINT32 ulColor = 0;
- retVal = HXParseColorUINT32(pszStr, ulColor);
- if (SUCCEEDED(retVal))
- {
- rulValue = ulColor;
- reType = CSS2TypeColor;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseFit(const char* pszStr,
- REF(Fit) reValue)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- if (!strcmp(pszStr, "fill"))
- {
- reValue = FitFill;
- }
- else if (!strcmp(pszStr, "hidden"))
- {
- reValue = FitHidden;
- }
- else if (!strcmp(pszStr, "meet"))
- {
- reValue = FitMeet;
- }
- else if (!strcmp(pszStr, "scroll"))
- {
- reValue = FitScroll;
- }
- else if (!strcmp(pszStr, "slice"))
- {
- reValue = FitSlice;
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseRegAlign(const char* pszStr,
- REF(RegAlign) reValue)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- if (!strcmp(pszStr, "topLeft"))
- {
- reValue = RegAlignTopLeft;
- }
- else if (!strcmp(pszStr, "topMid"))
- {
- reValue = RegAlignTopMid;
- }
- else if (!strcmp(pszStr, "topRight"))
- {
- reValue = RegAlignTopRight;
- }
- else if (!strcmp(pszStr, "midLeft"))
- {
- reValue = RegAlignMidLeft;
- }
- else if (!strcmp(pszStr, "center"))
- {
- reValue = RegAlignCenter;
- }
- else if (!strcmp(pszStr, "midRight"))
- {
- reValue = RegAlignMidRight;
- }
- else if (!strcmp(pszStr, "bottomLeft"))
- {
- reValue = RegAlignBottomLeft;
- }
- else if (!strcmp(pszStr, "bottomMid"))
- {
- reValue = RegAlignBottomMid;
- }
- else if (!strcmp(pszStr, "bottomRight"))
- {
- reValue = RegAlignBottomRight;
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseOpacity(const char* pszStr, REF(UINT32) rulOpacity)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- // opacity := <raw> | <percentage>
- // <raw> := WS* [0-9]+ WS*
- // <percentage> := WS* [0-9] '.' [0-9] '%' WS*
- // WS := ' ' | 'n' | 'r' | 't'
- //
- // Check to make sure the string is valid
- //
- // Here is the definition of the state machine
- // 0 is the starting state
- // If you end in state 7, you are a <length>
- // If you end in state 6, you are a <percentage>
- // If you end in state -1, this is an error
- //
- // State -1: // error state
- // else goto state -1
- // State 0: // starting state
- // WS goto state 0
- // 0-9 goto state 1
- // . goto state 2
- // else goto state -1
- // State 1: // have already seen at least one 0-9
- // 0-9 goto state 1
- // . goto state 3
- // % goto state 4
- // NULL goto state 5
- // WS goto state 5
- // else goto state -1
- // State 2: // saw a . without seeing a 0-9
- // 0-9 goto state 3
- // else goto state -1
- // State 3: // saw a . after seeing a 0-9
- // 0-9 goto state 3
- // % goto state 4
- // NULL goto state 5
- // WS goto state 5
- // else goto state -1
- // State 4: // <percentage> ending state
- // WS goto state 4
- // NULL goto state 4
- // else goto state -1
- // State 5: // <raw> ending state
- // WS goto state 5
- // NULL goto state 5
- // else goto state -1
- //
- const char* pszTmp = pszStr;
- const char* pszLimit = pszTmp + strlen(pszTmp);
- INT32 lState = 0;
- while (pszTmp <= pszLimit)
- {
- char c = *pszTmp++;
- switch (lState)
- {
- case -1:
- break;
- case 0:
- {
- if (c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 0;
- }
- else if (c >= '0' && c <= '9')
- {
- lState = 1;
- }
- else if (c == '.')
- {
- lState = 2;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 1:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 1;
- }
- else if (c == '.')
- {
- lState = 3;
- }
- else if (c == '%')
- {
- lState = 4;
- }
- else if (c == ' ' || c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 5;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 2:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 3;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 3:
- {
- if (c >= '0' && c <= '9')
- {
- lState = 3;
- }
- else if (c == '%')
- {
- lState = 4;
- }
- else if (c == ' ' || c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 5;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 4:
- {
- if (c == ' ' || c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 4;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- case 5:
- {
- if (c == ' ' || c == ' ' || c == 'r' || c == 'n' || c == 't')
- {
- lState = 5;
- }
- else
- {
- lState = -1;
- }
- }
- break;
- }
- }
- // Are we in a valid state
- if (lState == 4 || lState == 5)
- {
- // Parse the value
- double dVal = strtod(pszStr, NULL);
- if (lState == 4)
- {
- // We are a <percentage>
- //
- // First check the range
- if (dVal >= 0.0 && dVal <= 100.0)
- {
- // Convert to a byte value
- rulOpacity = (UINT32) (dVal * 255.0 / 100.0 + 0.5);
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- // We are a <raw>
- //
- // First check the range
- if (dVal >= 0.0 && dVal <= 255.0)
- {
- // Convert to a byte value
- rulOpacity = (UINT32) (dVal + 0.5);
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- else
- {
- // Error
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseFill(const char* pszStr,
- REF(FillType) reFill)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- if (!strcmp(pszStr, "remove"))
- {
- reFill = FillRemove;
- }
- else if (!strcmp(pszStr, "freeze"))
- {
- reFill = FillFreeze;
- }
- else if (!strcmp(pszStr, "hold"))
- {
- reFill = FillHold;
- }
- else if (!strcmp(pszStr, "transition"))
- {
- reFill = FillTransition;
- }
- else if (!strcmp(pszStr, "auto"))
- {
- reFill = FillAuto;
- }
- else if (!strcmp(pszStr, "default"))
- {
- reFill = FillDefault;
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::getFillString(FillType eFill, REF(CHXString) rcFill)
- {
- HX_RESULT retVal = HXR_OK;
- switch (eFill)
- {
- case FillRemove: rcFill = "remove"; break;
- case FillFreeze: rcFill = "freeze"; break;
- case FillHold: rcFill = "hold"; break;
- case FillTransition: rcFill = "transition"; break;
- case FillAuto: rcFill = "auto"; break;
- case FillDefault: rcFill = "default"; break;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::getEraseString(EraseType eErase, REF(CHXString) rcErase)
- {
- HX_RESULT retVal = HXR_OK;
- switch (eErase)
- {
- case EraseWhenDone: rcErase = "whenDone"; break;
- case EraseNever: rcErase = "never"; break;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseFillDefault(const char* pszStr,
- REF(FillDefaultType) reFillDefault)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- if (!strcmp(pszStr, "remove"))
- {
- reFillDefault = FillDefaultRemove;
- }
- else if (!strcmp(pszStr, "freeze"))
- {
- reFillDefault = FillDefaultFreeze;
- }
- else if (!strcmp(pszStr, "hold"))
- {
- reFillDefault = FillDefaultHold;
- }
- else if (!strcmp(pszStr, "transition"))
- {
- reFillDefault = FillDefaultTransition;
- }
- else if (!strcmp(pszStr, "auto"))
- {
- reFillDefault = FillDefaultAuto;
- }
- else if (!strcmp(pszStr, "inherit"))
- {
- reFillDefault = FillDefaultInherit;
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilParser::parseAccelDecel(const char* pszStr, REF(double) rdVal)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszStr)
- {
- double dVal = 0.0;
- retVal = HXParseDouble(pszStr, dVal);
- if (SUCCEEDED(retVal))
- {
- if (dVal >= 0.0 && dVal <= 1.0)
- {
- rdVal = dVal;
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
- HX_RESULT CSmilParser::getDefaultTransitionSubType(const char* pszType,
- REF(CHXString) rcSubType)
- {
- HX_RESULT retVal = HXR_OK;
- if (pszType)
- {
- if (!strcmp(pszType, "barWipe"))
- {
- rcSubType = "leftToRight";
- }
- else if (!strcmp(pszType, "boxWipe"))
- {
- rcSubType = "topLeft";
- }
- else if (!strcmp(pszType, "fourBoxWipe"))
- {
- rcSubType = "cornersIn";
- }
- else if (!strcmp(pszType, "barnDoorWipe"))
- {
- rcSubType = "vertical";
- }
- else if (!strcmp(pszType, "diagonalWipe"))
- {
- rcSubType = "topLeft";
- }
- else if (!strcmp(pszType, "bowTieWipe"))
- {
- rcSubType = "vertical";
- }
- else if (!strcmp(pszType, "miscDiagonalWipe"))
- {
- rcSubType = "doubleBarnDoor";
- }
- else if (!strcmp(pszType, "veeWipe"))
- {
- rcSubType = "down";
- }
- else if (!strcmp(pszType, "barnVeeWipe"))
- {
- rcSubType = "down";
- }
- else if (!strcmp(pszType, "zigZagWipe"))
- {
- rcSubType = "leftToRight";
- }
- else if (!strcmp(pszType, "barnZigZagWipe"))
- {
- rcSubType = "vertical";
- }
- else if (!strcmp(pszType, "irisWipe"))
- {
- rcSubType = "rectangle";
- }
- else if (!strcmp(pszType, "triangleWipe"))
- {
- rcSubType = "up";
- }
- else if (!strcmp(pszType, "arrowHeadWipe"))
- {
- rcSubType = "up";
- }
- else if (!strcmp(pszType, "pentagonWipe"))
- {
- rcSubType = "up";
- }
- else if (!strcmp(pszType, "hexagonWipe"))
- {
- rcSubType = "horizontal";
- }
- else if (!strcmp(pszType, "ellipseWipe"))
- {
- rcSubType = "circle";
- }
- else if (!strcmp(pszType, "eyeWipe"))
- {
- rcSubType = "horizontal";
- }
- else if (!strcmp(pszType, "roundRectWipe"))
- {
- rcSubType = "horizontal";
- }
- else if (!strcmp(pszType, "starWipe"))
- {
- rcSubType = "fourPoint";
- }
- else if (!strcmp(pszType, "miscShapeWipe"))
- {
- rcSubType = "heart";
- }
- else if (!strcmp(pszType, "clockWipe"))
- {
- rcSubType = "clockwiseTwelve";
- }
- else if (!strcmp(pszType, "pinWheelWipe"))
- {
- rcSubType = "twoBladeVertical";
- }
- else if (!strcmp(pszType, "singleSweepWipe"))
- {
- rcSubType = "clockwiseTop";
- }
- else if (!strcmp(pszType, "fanWipe"))
- {
- rcSubType = "centerTop";
- }
- else if (!strcmp(pszType, "doubleFanWipe"))
- {
- rcSubType = "fanOutVertical";
- }
- else if (!strcmp(pszType, "doubleSweepWipe"))
- {
- rcSubType = "parallelVertical";
- }
- else if (!strcmp(pszType, "saloonDoorWipe"))
- {
- rcSubType = "top";
- }
- else if (!strcmp(pszType, "windshieldWipe"))
- {
- rcSubType = "right";
- }
- else if (!strcmp(pszType, "snakeWipe"))
- {
- rcSubType = "topLeftHorizontal";
- }
- else if (!strcmp(pszType, "spiralWipe"))
- {
- rcSubType = "topLeftClockwise";
- }
- else if (!strcmp(pszType, "parallelSnakesWipe"))
- {
- rcSubType = "verticalTopSame";
- }
- else if (!strcmp(pszType, "boxSnakesWipe"))
- {
- rcSubType = "twoBoxTop";
- }
- else if (!strcmp(pszType, "waterfallWipe"))
- {
- rcSubType = "verticalLeft";
- }
- else if (!strcmp(pszType, "pushWipe"))
- {
- rcSubType = "fromLeft";
- }
- else if (!strcmp(pszType, "slideWipe"))
- {
- rcSubType = "fromLeft";
- }
- else if (!strcmp(pszType, "fade"))
- {
- rcSubType = "crossfade";
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- BOOL CSmilParser::isLegalTransitionType(const char* pszType)
- {
- BOOL bRet = FALSE;
- if (pszType)
- {
- if (!strcmp(pszType, "barWipe") ||
- !strcmp(pszType, "boxWipe") ||
- !strcmp(pszType, "fourBoxWipe") ||
- !strcmp(pszType, "barnDoorWipe") ||
- !strcmp(pszType, "diagonalWipe") ||
- !strcmp(pszType, "bowTieWipe") ||
- !strcmp(pszType, "miscDiagonalWipe") ||
- !strcmp(pszType, "veeWipe") ||
- !strcmp(pszType, "barnVeeWipe") ||
- !strcmp(pszType, "zigZagWipe") ||
- !strcmp(pszType, "barnZigZagWipe") ||
- !strcmp(pszType, "irisWipe") ||
- !strcmp(pszType, "triangleWipe") ||
- !strcmp(pszType, "arrowHeadWipe") ||
- !strcmp(pszType, "pentagonWipe") ||
- !strcmp(pszType, "hexagonWipe") ||
- !strcmp(pszType, "ellipseWipe") ||
- !strcmp(pszType, "eyeWipe") ||
- !strcmp(pszType, "roundRectWipe") ||
- !strcmp(pszType, "starWipe") ||
- !strcmp(pszType, "miscShapeWipe") ||
- !strcmp(pszType, "clockWipe") ||
- !strcmp(pszType, "pinWheelWipe") ||
- !strcmp(pszType, "singleSweepWipe") ||
- !strcmp(pszType, "fanWipe") ||
- !strcmp(pszType, "doubleFanWipe") ||
- !strcmp(pszType, "doubleSweepWipe") ||
- !strcmp(pszType, "saloonDoorWipe") ||
- !strcmp(pszType, "windshieldWipe") ||
- !strcmp(pszType, "snakeWipe") ||
- !strcmp(pszType, "spiralWipe") ||
- !strcmp(pszType, "parallelSnakesWipe") ||
- !strcmp(pszType, "boxSnakesWipe") ||
- !strcmp(pszType, "waterfallWipe") ||
- !strcmp(pszType, "pushWipe") ||
- !strcmp(pszType, "slideWipe") ||
- !strcmp(pszType, "fade"))
- {
- bRet = TRUE;
- }
- }
- return bRet;
- }
- BOOL CSmilParser::isLegalTransitionSubType(const char* pszType, const char* pszSubType)
- {
- BOOL bRet = FALSE;
- if (pszType && pszSubType)
- {
- if (!strcmp(pszType, "barWipe"))
- {
- if (!strcmp(pszSubType, "leftToRight") ||
- !strcmp(pszSubType, "topToBottom"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "boxWipe"))
- {
- if (!strcmp(pszSubType, "topLeft") ||
- !strcmp(pszSubType, "topRight") ||
- !strcmp(pszSubType, "bottomRight") ||
- !strcmp(pszSubType, "bottomLeft") ||
- !strcmp(pszSubType, "topCenter") ||
- !strcmp(pszSubType, "rightCenter") ||
- !strcmp(pszSubType, "bottomCenter") ||
- !strcmp(pszSubType, "leftCenter"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "fourBoxWipe"))
- {
- if (!strcmp(pszSubType, "cornersIn") ||
- !strcmp(pszSubType, "cornersOut"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "barnDoorWipe"))
- {
- if (!strcmp(pszSubType, "vertical") ||
- !strcmp(pszSubType, "horizontal") ||
- !strcmp(pszSubType, "diagonalBottomLeft") ||
- !strcmp(pszSubType, "diagonalTopLeft"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "diagonalWipe"))
- {
- if (!strcmp(pszSubType, "topLeft") ||
- !strcmp(pszSubType, "topRight"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "bowTieWipe"))
- {
- if (!strcmp(pszSubType, "vertical") ||
- !strcmp(pszSubType, "horizontal"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "miscDiagonalWipe"))
- {
- if (!strcmp(pszSubType, "doubleBarnDoor") ||
- !strcmp(pszSubType, "doubleDiamond"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "veeWipe"))
- {
- if (!strcmp(pszSubType, "down") ||
- !strcmp(pszSubType, "left") ||
- !strcmp(pszSubType, "up") ||
- !strcmp(pszSubType, "right"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "barnVeeWipe"))
- {
- if (!strcmp(pszSubType, "down") ||
- !strcmp(pszSubType, "left") ||
- !strcmp(pszSubType, "up") ||
- !strcmp(pszSubType, "right"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "zigZagWipe"))
- {
- if (!strcmp(pszSubType, "leftToRight") ||
- !strcmp(pszSubType, "topToBottom"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "barnZigZagWipe"))
- {
- if (!strcmp(pszSubType, "vertical") ||
- !strcmp(pszSubType, "horizontal"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "irisWipe"))
- {
- if (!strcmp(pszSubType, "rectangle") ||
- !strcmp(pszSubType, "diamond"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "triangleWipe"))
- {
- if (!strcmp(pszSubType, "up") ||
- !strcmp(pszSubType, "right") ||
- !strcmp(pszSubType, "down") ||
- !strcmp(pszSubType, "left"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "arrowHeadWipe"))
- {
- if (!strcmp(pszSubType, "up") ||
- !strcmp(pszSubType, "right") ||
- !strcmp(pszSubType, "down") ||
- !strcmp(pszSubType, "left"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "pentagonWipe"))
- {
- if (!strcmp(pszSubType, "up") ||
- !strcmp(pszSubType, "down"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "hexagonWipe"))
- {
- if (!strcmp(pszSubType, "horizontal") ||
- !strcmp(pszSubType, "vertical"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "ellipseWipe"))
- {
- if (!strcmp(pszSubType, "circle") ||
- !strcmp(pszSubType, "horizontal") ||
- !strcmp(pszSubType, "vertical"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "eyeWipe"))
- {
- if (!strcmp(pszSubType, "horizontal") ||
- !strcmp(pszSubType, "vertical"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "roundRectWipe"))
- {
- if (!strcmp(pszSubType, "horizontal") ||
- !strcmp(pszSubType, "vertical"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "starWipe"))
- {
- if (!strcmp(pszSubType, "fourPoint") ||
- !strcmp(pszSubType, "fivePoint") ||
- !strcmp(pszSubType, "sixPoint"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "miscShapeWipe"))
- {
- if (!strcmp(pszSubType, "heart") ||
- !strcmp(pszSubType, "keyhole"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "clockWipe"))
- {
- if (!strcmp(pszSubType, "clockwiseTwelve") ||
- !strcmp(pszSubType, "clockwiseThree") ||
- !strcmp(pszSubType, "clockwiseSix") ||
- !strcmp(pszSubType, "clockwiseNine"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "pinWheelWipe"))
- {
- if (!strcmp(pszSubType, "twoBladeVertical") ||
- !strcmp(pszSubType, "twoBladeHorizontal") ||
- !strcmp(pszSubType, "fourBlade"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "singleSweepWipe"))
- {
- if (!strcmp(pszSubType, "clockwiseTop") ||
- !strcmp(pszSubType, "clockwiseRight") ||
- !strcmp(pszSubType, "clockwiseBottom") ||
- !strcmp(pszSubType, "clockwiseLeft") ||
- !strcmp(pszSubType, "clockwiseTopLeft") ||
- !strcmp(pszSubType, "counterClockwiseBottomLeft") ||
- !strcmp(pszSubType, "clockwiseBottomRight") ||
- !strcmp(pszSubType, "counterClockwiseTopRight"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "fanWipe"))
- {
- if (!strcmp(pszSubType, "centerTop") ||
- !strcmp(pszSubType, "centerRight") ||
- !strcmp(pszSubType, "top") ||
- !strcmp(pszSubType, "right") ||
- !strcmp(pszSubType, "bottom") ||
- !strcmp(pszSubType, "left"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "doubleFanWipe"))
- {
- if (!strcmp(pszSubType, "fanOutVertical") ||
- !strcmp(pszSubType, "fanOutHorizontal") ||
- !strcmp(pszSubType, "fanInVertical") ||
- !strcmp(pszSubType, "fanInHorizontal"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "doubleSweepWipe"))
- {
- if (!strcmp(pszSubType, "parallelVertical") ||
- !strcmp(pszSubType, "parallelDiagonal") ||
- !strcmp(pszSubType, "oppositeVertical") ||
- !strcmp(pszSubType, "oppositeHorizontal") ||
- !strcmp(pszSubType, "parallelDiagonalTopLeft") ||
- !strcmp(pszSubType, "parallelDiagonalBottomLeft"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "saloonDoorWipe"))
- {
- if (!strcmp(pszSubType, "top") ||
- !strcmp(pszSubType, "left") ||
- !strcmp(pszSubType, "bottom") ||
- !strcmp(pszSubType, "right"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "windshieldWipe"))
- {
- if (!strcmp(pszSubType, "right") ||
- !strcmp(pszSubType, "up") ||
- !strcmp(pszSubType, "vertical") ||
- !strcmp(pszSubType, "horizontal"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "snakeWipe"))
- {
- if (!strcmp(pszSubType, "topLeftHorizontal") ||
- !strcmp(pszSubType, "topLeftVertical") ||
- !strcmp(pszSubType, "topLeftDiagonal") ||
- !strcmp(pszSubType, "topRightDiagonal") ||
- !strcmp(pszSubType, "bottomRightDiagonal") ||
- !strcmp(pszSubType, "bottomLeftDiagonal"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "spiralWipe"))
- {
- if (!strcmp(pszSubType, "topLeftClockwise") ||
- !strcmp(pszSubType, "topRightClockwise") ||
- !strcmp(pszSubType, "bottomRightClockwise") ||
- !strcmp(pszSubType, "bottomLeftClockwise") ||
- !strcmp(pszSubType, "topLeftCounterClockwise") ||
- !strcmp(pszSubType, "topRightCounterClockwise") ||
- !strcmp(pszSubType, "bottomRightCounterClockwise") ||
- !strcmp(pszSubType, "bottomLeftCounterClockwise"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "parallelSnakesWipe"))
- {
- if (!strcmp(pszSubType, "verticalTopSame") ||
- !strcmp(pszSubType, "verticalBottomSame") ||
- !strcmp(pszSubType, "verticalTopLeftOpposite") ||
- !strcmp(pszSubType, "verticalBottomLeftOpposite") ||
- !strcmp(pszSubType, "horizontalLeftSame") ||
- !strcmp(pszSubType, "horizontalRightSame") ||
- !strcmp(pszSubType, "horizontalTopLeftOpposite") ||
- !strcmp(pszSubType, "horizontalTopRightOpposite") ||
- !strcmp(pszSubType, "diagonalBottomLeftOpposite") ||
- !strcmp(pszSubType, "diagonalTopLeftOpposite"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "boxSnakesWipe"))
- {
- if (!strcmp(pszSubType, "twoBoxTop") ||
- !strcmp(pszSubType, "twoBoxBottom") ||
- !strcmp(pszSubType, "twoBoxLeft") ||
- !strcmp(pszSubType, "twoBoxRight") ||
- !strcmp(pszSubType, "fourBoxVertical") ||
- !strcmp(pszSubType, "fourBoxHorizontal"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "waterfallWipe"))
- {
- if (!strcmp(pszSubType, "verticalLeft") ||
- !strcmp(pszSubType, "verticalRight") ||
- !strcmp(pszSubType, "horizontalLeft") ||
- !strcmp(pszSubType, "horizontalRight"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "pushWipe"))
- {
- if (!strcmp(pszSubType, "fromLeft") ||
- !strcmp(pszSubType, "fromTop") ||
- !strcmp(pszSubType, "fromRight") ||
- !strcmp(pszSubType, "fromBottom"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "slideWipe"))
- {
- if (!strcmp(pszSubType, "fromLeft") ||
- !strcmp(pszSubType, "fromTop") ||
- !strcmp(pszSubType, "fromRight") ||
- !strcmp(pszSubType, "fromBottom"))
- {
- bRet = TRUE;
- }
- }
- else if (!strcmp(pszType, "fade"))
- {
- if (!strcmp(pszSubType, "crossfade") ||
- !strcmp(pszSubType, "fadeToColor") ||
- !strcmp(pszSubType, "fadeFromColor"))
- {
- bRet = TRUE;
- }
- }
- }
- return bRet;
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */
- CSmilAnchorElement* CSmilParser::getAnchorOrAreaElement(const char* pID)
- {
- CSmilAnchorElement* pRet = NULL;
- SMILNode* pNode = NULL;
- if(m_pIDMap && pID && m_pIDMap->Lookup(pID, (void*&)pNode))
- {
- if(pNode && pNode->m_pElement &&
- (pNode->m_tag == SMILAnchor || pNode->m_tag == SMILArea))
- {
- pRet = (CSmilAnchorElement*) pNode->m_pElement;
- }
- }
- return pRet;
- }
- CNamespaceInfo::CNamespaceInfo()
- {
- m_pszPrefix = NULL;
- m_pszURL = NULL;
- m_bImplemented = FALSE;
- m_eNamespace = NamespaceNotImplemented;
- }
- CNamespaceInfo::~CNamespaceInfo()
- {
- HX_VECTOR_DELETE(m_pszPrefix);
- HX_VECTOR_DELETE(m_pszURL);
- }
- /*
- * CSmilParserResponse methods
- */
- CSmilParserResponse::CSmilParserResponse(CSmilParser* pParser)
- : m_pParser(pParser)
- , m_lRefCount(0)
- {
- }
- CSmilParserResponse::~CSmilParserResponse()
- {
- }
- STDMETHODIMP
- CSmilParserResponse::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)
- CSmilParserResponse::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- STDMETHODIMP_(ULONG32)
- CSmilParserResponse::Release()
- {
- if (InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- STDMETHODIMP
- CSmilParserResponse::HandleStartElement(const char* pName,
- IHXValues* pAttributes,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- if (m_pParser)
- {
- rc = m_pParser->getParseError();
- if (FAILED(rc))
- {
- return rc;
- }
- }
- SMILNode* pParentNode =
- (SMILNode*)m_pParser->m_pNodeListStack->TopOfStack();
- HX_ASSERT(pParentNode);
- SMILNode* pNode = new SMILNode;
- pNode->m_name = pName;
- pNode->m_pParent = pParentNode;
- pNode->m_pNodeList = new SMILNodeList;
- 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();
- // /Fixes PR 27658:
- // A valid XML Name may only begin with a letter (upper or lower)
- // or a ':' or '_'
- char firstChar = *pID;
- if ((':' != firstChar && '_' != firstChar) &&
- !isalpha(firstChar) )
- {
- rc = HXR_XML_ILLEGALID;
- CSmilXMLSyntaxErrorHandler 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 (!strcmp(pNode->m_name, "region"))
- {
- rc = HXR_XML_ILLEGALID;
- CSmilXMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- const char* pTmp = "region id=""";
- errHandler.ReportError(rc, pTmp, ulLineNumber);
- goto exit;
- }
- // transition attribute must have an id...
- else if (strcmp(pNode->m_name, "transition") == 0)
- {
- rc = HXR_XML_ILLEGALID;
- CSmilXMLSyntaxErrorHandler 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;
- CSmilXMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- errHandler.ReportError(rc, pNode->m_id, ulLineNumber);
- goto exit;
- }
- BOOL bCheckForDeletion = FALSE;
- BOOL bValidTag = FALSE;
- SMIL2Element eElem = m_pParser->getSMIL2Element(pName);
- switch (eElem)
- {
- case SMIL2ElemSmil:
- {
- pNode->m_tag = SMILSmil;
- }
- break;
- case SMIL2ElemLayout:
- {
- 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);
- }
- }
- break;
- case SMIL2ElemMeta:
- {
- pNode->m_tag = SMILMeta;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- case SMIL2ElemMetadata:
- {
- pNode->m_tag = SMILMetadata;
- }
- break;
- case SMIL2ElemHead:
- {
- pNode->m_id = "head";
- pNode->m_tag = SMILHead;
- }
- break;
- case SMIL2ElemBody:
- {
- pNode->m_id = "body";
- pNode->m_tag = SMILBody;
- }
- break;
- case SMIL2ElemRegion:
- {
- pNode->m_tag = SMILRegion;
- }
- break;
- case SMIL2ElemRegPoint:
- {
- pNode->m_tag = SMILRegPoint;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- case SMIL2ElemTopLayout:
- {
- pNode->m_tag = SMILViewport;
- }
- break;
- case SMIL2ElemTransition:
- {
- pNode->m_tag = SMILTransition;
- }
- break;
- case SMIL2ElemRootLayout:
- {
- pNode->m_tag = SMILRootLayout;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- case SMIL2ElemCustomAttributes:
- {
- pNode->m_tag = SMILCustomAttributes;
- }
- break;
- case SMIL2ElemCustomTest:
- {
- pNode->m_tag = SMILCustomTest;
- }
- break;
- case SMIL2ElemSwitch:
- {
- pNode->m_tag = SMILSwitch;
- }
- break;
- case SMIL2ElemText:
- {
- pNode->m_tag = SMILText;
- }
- break;
- case SMIL2ElemImg:
- {
- pNode->m_tag = SMILImg;
- }
- break;
- case SMIL2ElemRef:
- {
- pNode->m_tag = SMILRef;
- }
- break;
- case SMIL2ElemAudio:
- {
- pNode->m_tag = SMILAudio;
- }
- break;
- case SMIL2ElemVideo:
- {
- pNode->m_tag = SMILVideo;
- }
- break;
- case SMIL2ElemAnimation:
- {
- pNode->m_tag = SMILAnimation;
- }
- break;
- case SMIL2ElemTextstream:
- {
- pNode->m_tag = SMILTextstream;
- }
- break;
- case SMIL2ElemBrush:
- {
- pNode->m_tag = SMILBrush;
- }
- break;
- case SMIL2ElemPrefetch:
- {
- pNode->m_tag = SMILPrefetch;
- }
- break;
- case SMIL2ElemA:
- {
- pNode->m_tag = SMILAAnchor;
- }
- break;
- case SMIL2ElemAnchor:
- {
- pNode->m_tag = SMILAnchor;
- pNode->m_bSkipContent = TRUE;
- }
- case SMIL2ElemArea:
- {
- pNode->m_tag = SMILArea;
- }
- break;
- case SMIL2ElemPar:
- {
- pNode->m_tag = SMILPar;
- }
- break;
- case SMIL2ElemSeq:
- {
- pNode->m_tag = SMILSeq;
- }
- break;
- case SMIL2ElemExcl:
- {
- pNode->m_tag = SMILExcl;
- }
- break;
- case SMIL2ElemPriorityClass:
- {
- pNode->m_tag = SMILPriorityClass;
- }
- break;
- case SMIL2ElemAnimate:
- {
- pNode->m_tag = SMILAnimate;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- case SMIL2ElemSet:
- {
- pNode->m_tag = SMILSet;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- case SMIL2ElemAnimateMotion:
- {
- pNode->m_tag = SMILAnimateMotion;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- case SMIL2ElemAnimateColor:
- {
- pNode->m_tag = SMILAnimateColor;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- case SMIL2ElemParam:
- {
- pNode->m_tag = SMILParam;
- pNode->m_bSkipContent = TRUE;
- }
- break;
- default:
- {
- 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
- {
- 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;
- CSmilSMILSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- errHandler.ReportError(SMILErrorUnrecognizedTag, pName, ulLineNumber);
- goto exit;
- }
- else
- {
- bCheckForDeletion = TRUE;
- }
- if (!bValidTag && m_pParser->m_bStoreErrors)
- {
- m_pParser->storeError(SMILErrorUnrecognizedTag, pName, 0,
- ulLineNumber, ulColumnNumber, FALSE);
- }
- }
- }
- }
- #ifdef _WIN32 /* Fixes Windows version of PR 84161 */
- IHXValues * pNewAttributes = NULL;
- if ( HXR_OK == m_pParser->m_pClassFactory->CreateInstance(CLSID_IHXValues, (void**) &pNewAttributes) )
- {
- const char* pKey = NULL;
- HX_RESULT res = pAttributes->GetFirstPropertyCString(pKey, pBuffer);
- while(HXR_OK == res)
- {
- // expat returns strings in UTF-8
- const char* pUTF8String = (const char*)pBuffer->GetBuffer();
- int nLen = MultiByteToWideChar( /* Flawfinder: ignore */
- CP_UTF8, 0, pUTF8String, -1, NULL, 0 );
- UINT16* pUTF16String = new UINT16 [nLen + 1];
- if ( pUTF16String )
- {
- // convert UTF-8 to UTF-16
- memset( pUTF16String, 0, nLen + 1 ); /* Flawfinder: ignore */
- MultiByteToWideChar( CP_UTF8, 0, /* Flawfinder: ignore */
- pUTF8String, -1, pUTF16String, nLen + 1 );
- nLen = WideCharToMultiByte( CP_ACP, 0, /* Flawfinder: ignore */
- pUTF16String, -1, NULL, 0, NULL, NULL );
- char* pNativeString = new char [nLen + 1];
- if ( pNativeString )
- {
- // convert UTF-16 to Windows native string
- memset( pNativeString, 0, nLen + 1 ); /* Flawfinder: ignore */
- WideCharToMultiByte(CP_ACP, 0, pUTF16String, /* Flawfinder: ignore */
- -1, pNativeString, nLen + 1, NULL, NULL );
- m_pParser->addStringProperty( pNewAttributes,
- m_pParser->m_pContext, pKey, pNativeString );
- HX_VECTOR_DELETE( pNativeString );
- }
- HX_VECTOR_DELETE( pUTF16String );
- }
- HX_RELEASE(pBuffer);
- res = pAttributes->GetNextPropertyCString(pKey, pBuffer);
- }
- pNode->m_pValues = pNewAttributes;
- }
- else
- {
- pNode->m_pValues = pAttributes;
- pNode->m_pValues->AddRef();
- }
- #else
- pNode->m_pValues = pAttributes;
- pNode->m_pValues->AddRef();
- #endif /* _WIN32 PR 84161 */
- rc = m_pParser->storeNamespaces(pNode);
- if (SUCCEEDED(rc))
- {
- rc = m_pParser->addToNamespaceScope(pNode);
- }
- BOOL bFound = FALSE;
- const char* pName = NULL;
- HX_RESULT res = pNode->m_pValues->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
- {
- // /If we initialized m_bSkipContent to TRUE, then this
- // is an empty element that must not have skip-content
- // set to false if it contains anything:
- if (pNode->m_bSkipContent)
- {
- CHXString errMsg = '<';
- errMsg += (const char*)pNode->m_name;
- errMsg += " ";
- errMsg += pName;
- errMsg += "="false">";
- CSmilSMILSyntaxErrorHandler errHandler(
- m_pParser->m_pContext);
- errHandler.ReportError(SMILErrorUnexpectedContent,
- (const char*)errMsg,
- pNode->m_ulTagStartLine);
- rc = HXR_FAIL;
- HX_RELEASE(pBuffer);
- goto exit;
- }
- pNode->m_bSkipContent = FALSE;
- }
- }
- HX_RELEASE(pBuffer);
- res = pNode->m_pValues->GetNextPropertyCString(pName, pBuffer);
- }
- // /If the tag is valid but we don't know what to do with it,
- // then only delete it if it's skip-content value is TRUE
- // (otherwise, let its children have a chance to play):
- if (bCheckForDeletion)
- {
- pNode->m_bDelete = bValidTag ? pNode->m_bSkipContent : TRUE;
- }
- m_pParser->m_pNodeListStack->Push(pNode);
- }
- else
- {
- //Even if parent has skip-content set, add this so it pops when
- // end is found instead of popping the next one in the stack:
- m_pParser->m_pNodeListStack->Push(pNode);
- }
- exit:
- if (FAILED(rc))
- {
- if (m_pParser)
- {
- m_pParser->setParseError(rc);
- }
- }
- return rc;
- }
- STDMETHODIMP
- CSmilParserResponse::HandleEndElement(const char* pName,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- if (m_pParser)
- {
- rc = m_pParser->getParseError();
- if (FAILED(rc))
- {
- return rc;
- }
- }
- SMILNode* pCurrentNode = (SMILNode*)m_pParser->m_pNodeListStack->Pop();
- SMILNode* pParentNode = (SMILNode*)m_pParser->m_pNodeListStack->TopOfStack();
- HX_ASSERT(pCurrentNode);
- HX_ASSERT(pParentNode);
- if (pParentNode)
- {
- pParentNode->m_pNodeList->AddTail(pCurrentNode);
- }
- SMILNode* pEndNode = new SMILNode;
- pEndNode->m_name = pName;
- pEndNode->m_id.Format("CLOSE-%s", pName);
- pEndNode->m_bCloseNode = TRUE;
- 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, "excl") == 0)
- {
- pEndNode->m_tag = SMILEndExcl;
- }
- else if(strcmp(pName, "a") == 0)
- {
- pEndNode->m_tag = SMILEndAAnchor;
- }
- else if(strcmp(pName, "priorityClass") == 0)
- {
- pEndNode->m_tag = SMILEndPriorityClass;
- }
- pCurrentNode->m_pNodeList->AddTail(pEndNode);
- rc = m_pParser->removeFromNamespaceScope(pCurrentNode);
- return rc;
- }
- STDMETHODIMP
- CSmilParserResponse::HandleCharacterData(IHXBuffer* pBuffer,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- // The SMIL content model does not allow non-whitespace character
- // data as children of any elements. Therefore, we must check
- // to see if there are any non-whitespace characters here.
- if (pBuffer)
- {
- UINT32 ulLen = pBuffer->GetSize();
- const char* pszBuf = (const char*) pBuffer->GetBuffer();
- char* pCh = (char*) pszBuf;
- if (pCh)
- {
- for (UINT32 i = 0; i < ulLen; i++)
- {
- char c = *pCh++;
- if (!(c == ' ' ||
- c == 'n' ||
- c == 'r' ||
- c == 't' ||
- c == ' '))
- {
- CSmilSMILSyntaxErrorHandler errHandler(m_pParser->m_pContext);
- errHandler.ReportError(SMILErrorUnexpectedContent,
- pszBuf,
- ulLineNumber);
- rc = HXR_FAIL;
- break;
- }
- }
- }
- }
- return rc;
- }
- STDMETHODIMP
- CSmilParserResponse::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
- CSmilParserResponse::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
- CSmilParserResponse::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
- CSmilParserResponse::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)
- {
- m_pParser->m_bNoNamespaces = TRUE;
- m_pParser->m_bIgnoreUnrecognizedElements = FALSE;
- }
- return rc;
- }
- STDMETHODIMP
- CSmilParserResponse::HandleComment(const char* /*IN*/ pComment,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- STDMETHODIMP
- CSmilParserResponse::HandleDefault(IHXBuffer* /*IN*/ pBuffer,
- UINT32 ulLineNumber,
- UINT32 ulColumnNumber)
- {
- HX_RESULT rc = HXR_OK;
- return rc;
- }
- HX_RESULT
- CSmilParserResponse::ErrorInLastTag(HX_RESULT err,
- const char* pErrorString, const char* pFrameString,
- UINT32 ulLineNumber, UINT32 ulLinePosition)
- {
- // XXXJHUG - we could add the error to the actual node...
- // SMILNode* pCurrentNode = (SMILNode*)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);
- }
- /*
- * SMILNode methods
- */
- SMILNode::SMILNode():
- 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_nPrefetchTrackNum((UINT16)-1),
- m_fPartialPlayFactor(1.0),
- m_ulRepeatDur(UINT32(-1)),
- m_bIsSeqWrapperForRepeatElement(FALSE),
- m_bIsOuterWrapperTimeContainer(FALSE),
- m_bBeginHandledByWrapperParent(FALSE),
- m_bEndHandledByWrapperParent(FALSE),
- m_bMinHandledByWrapperParent(FALSE),
- m_bMaxHandledByWrapperParent(FALSE),
- m_bNeedToResolveRepeatDurVSRepeatCount(FALSE),
- m_repeatTag(RepeatUnknown),
- m_eElement(NumSMIL2Elements),
- m_bCloseNode(FALSE),
- m_bNamespacedElement(FALSE)
- {
- }
- #if defined(XXXEH_REPEAT_VALUE_TIMING_SHOULD_BE_EVENT_BASED)
- SMILNode::SMILNode(const SMILNode& rhs, BOOL bKeepId, CSmilParser* pParser)
- #else
- SMILNode::SMILNode(const SMILNode& rhs, BOOL bKeepId, CSmilParser* pParser, UINT32 ulRepeatNum)
- #endif
- {
- if (bKeepId)
- {
- m_id = rhs.m_id;
- }
- else
- {
- // need a unique ID, so make one...
- char* pIDName = new char [256];
- if (pIDName)
- {
- #if defined(XXXEH_REPEAT_VALUE_TIMING_SHOULD_BE_EVENT_BASED)
- #else
- // /For repeated elements, create an ID of the following form:
- // "[rhs.m_id]" + "_repeat_copy_" + "[ulRepeatNum]":
- BOOL bHandledAsRepeatId = FALSE;
- if (rhs.m_repeatid.GetLength() && ulRepeatNum>0)
- {
- // /Combined string must be < 255 (where 236 is 255 minus len of
- // "_repeat_copy_" and also minus 7 for repeat num) otherwise
- // punt:
- if ((LONG32)strlen(rhs.m_id) < 235)
- {
- SafeSprintf(pIDName, 256, "%s_repeat_copy_%lu",
- (const char*)rhs.m_id, ulRepeatNum);
- bHandledAsRepeatId = TRUE;
- }
- }
- if (!bHandledAsRepeatId)
- #endif
- {
- if (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;
- m_fPartialPlayFactor = rhs.m_fPartialPlayFactor;
- m_ulRepeatDur = rhs.m_ulRepeatDur;
- m_bIsSeqWrapperForRepeatElement = rhs.m_bIsSeqWrapperForRepeatElement;
- m_bIsOuterWrapperTimeContainer = rhs.m_bIsOuterWrapperTimeContainer;
- m_bBeginHandledByWrapperParent = rhs.m_bBeginHandledByWrapperParent;
- m_bEndHandledByWrapperParent = rhs.m_bEndHandledByWrapperParent;
- m_bMinHandledByWrapperParent = rhs.m_bMinHandledByWrapperParent;
- m_bMaxHandledByWrapperParent = rhs.m_bMaxHandledByWrapperParent;
- m_bNeedToResolveRepeatDurVSRepeatCount =
- rhs.m_bNeedToResolveRepeatDurVSRepeatCount;
- 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)
- {
- SMILNamespace* pNS = (SMILNamespace*)(*pIt);
- SMILNamespace* pNewNS = new SMILNamespace(pNS);
- m_pNamespaceList->AddHead(pNewNS);
- }
- }
- else
- {
- m_pNamespaceList = NULL;
- }
- }
- SMILNode::~SMILNode()
- {
- HX_DELETE(m_pNodeList);
- HX_DELETE(m_pElement);
- HX_RELEASE(m_pValues);
- if (m_pNamespaceList)
- {
- while (!m_pNamespaceList->IsEmpty())
- {
- SMILNamespace* pNS = (SMILNamespace*)m_pNamespaceList->RemoveHead();
- HX_DELETE(pNS);
- }
- }
- HX_DELETE(m_pNamespaceList);
- }
- SMILNode*
- SMILNode::getFirstChild()
- {
- if(!m_pNodeList)
- {
- return 0;
- }
- m_curPosition = m_pNodeList->GetHeadPosition();
- if(m_curPosition)
- {
- return (SMILNode*)m_pNodeList->GetNext(m_curPosition);
- }
- return 0;
- }
- SMILNode*
- SMILNode::getNextChild()
- {
- if(m_curPosition)
- {
- return (SMILNode*)m_pNodeList->GetNext(m_curPosition);
- }
- return 0;
- }
- SMILNodeList::SMILNodeList():
- m_pParentNode(0)
- {
- }
- SMILNodeList::~SMILNodeList()
- {
- CHXSimpleList::Iterator i;
- for(i = Begin(); i != End(); ++i)
- {
- SMILNode* pNode = (SMILNode*)(*i);
- HX_DELETE(pNode);
- }
- }
- SMILNodeList*
- SMILNodeList::copy(SMILNode* pParent, BOOL bKeepId, CSmilParser* pParser)
- {
- SMILNodeList* pNewList = new SMILNodeList;
- m_pParentNode = pParent;
- CHXSimpleList::Iterator i = Begin();
- for(; i != End(); ++i)
- {
- SMILNode* pNode = (SMILNode*)(*i);
- SMILNode* pNodeCopy = new SMILNode(*pNode, bKeepId, pParser);
- pNodeCopy->m_pParent = pParent;
- pNewList->AddTail(pNodeCopy);
- }
- return pNewList;
- }