smlparse.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:879k
源码类别:

Symbian

开发平台:

C/C++

  1.     }
  2. cleanup:
  3.     return pNextSibling;
  4. }
  5. HX_RESULT
  6. CSmilParser::constructTimelineElements(SMILNodeList* pNodeList)
  7. {
  8.     HX_RESULT rc = HXR_OK;
  9.     if(!pNodeList)
  10.     {
  11. return rc;
  12.     }
  13.     CHXSimpleList::Iterator i;
  14.     for(i=pNodeList->Begin();i!=pNodeList->End();++i)
  15.     {
  16. if(HXR_OK != rc)
  17. {
  18.     return rc;
  19. }
  20. SMILNode* pNode = (SMILNode*)(*i);
  21. if(pNode->m_bDelete) // skip this puppy
  22. {
  23.     continue;
  24. }
  25. switch(pNode->m_tag)
  26. {
  27.     case SMILSeq:
  28.     {
  29. SMILNode* pChildNode = getTimelineDescendent(pNode, NULL);
  30. CSmilTimelineElement* pPrevElement = NULL;
  31. UINT16 uPrevGroup = (UINT16)-1;
  32. while(pChildNode)
  33. {
  34.     if (pChildNode->m_pElement &&
  35. pChildNode->m_pElement->m_pTimelineElement)
  36.     {
  37. pNode->m_pElement->m_pTimelineElement->addChild(
  38. pChildNode->m_pElement->m_pTimelineElement);
  39. if(pPrevElement &&
  40.    uPrevGroup == pChildNode->m_nGroup)
  41. {
  42.     pPrevElement->setDependent(pChildNode->m_pElement->m_pTimelineElement);
  43. }
  44. pPrevElement = pChildNode->m_pElement->m_pTimelineElement;
  45. uPrevGroup = pChildNode->m_nGroup;
  46.     }
  47.     // there is no dependent on pChildNode which would repeat
  48.     // itself indefinitely within the same seq
  49.     if (pChildNode->m_repeatTag == RepeatIndefiniteOnMe)
  50.     {
  51. break;
  52.     }
  53.     pChildNode = getTimelineDescendent(pNode, pChildNode);
  54. }
  55.     }
  56.     break;
  57.     case SMILExcl:
  58.     case SMILPar:
  59.     {
  60. SMILNode* pChildNode = getTimelineDescendent(pNode, NULL);
  61. while(pChildNode)
  62. {
  63.     if(pChildNode->m_pElement &&
  64.        pChildNode->m_pElement->m_pTimelineElement)
  65.     {
  66. pNode->m_pElement->m_pTimelineElement->addChild(
  67.     pChildNode->m_pElement->m_pTimelineElement);
  68.     }
  69.     // /When element has <a>, <priorityClass>, or
  70.     // <switch> child (i.e., a non-timeline element child)
  71.     // which itself has multiple timed children, make sure
  72.     // more than just the first of those elements gets added
  73.     // to the child list (a bug since SMIL-1 implementation):
  74.     pChildNode = getTimelineDescendent(pNode, pChildNode);
  75. }
  76.     }
  77.     break;
  78.             // XXXMEH - we need to let media objects be time containers
  79.             // - will this have side effect on <anchor>?
  80.             case SMILText:
  81.             case SMILImg:
  82.             case SMILRef:
  83.             case SMILAudio:
  84.             case SMILVideo:
  85.             case SMILAnimation:
  86.             case SMILTextstream:
  87.             case SMILBrush:
  88.     case SMILPrefetch:
  89.     {
  90. SMILNode* pChildNode = getTimelineDescendent(pNode, NULL);
  91. while(pChildNode)
  92. {
  93.     if(pChildNode->m_pElement &&
  94.        pChildNode->m_pElement->m_pTimelineElement)
  95.     {
  96. pNode->m_pElement->m_pTimelineElement->addChild(
  97.     pChildNode->m_pElement->m_pTimelineElement);
  98.     }
  99.     pChildNode = getTimelineDescendent(pNode, pChildNode);
  100. }
  101.     }
  102.     break;
  103.     default:
  104.     break;
  105. }
  106. rc = constructTimelineElements(pNode->m_pNodeList);
  107.     }
  108.     return rc;
  109. }
  110. HX_RESULT
  111. CSmilParser::handleNextElement(CSmilElementHandler* pHandler)
  112. {
  113.     HX_RESULT rc = HXR_OK;
  114.     if(m_pPacketQueue->GetCount() > 0)
  115.     {
  116. CSmilElement* pElement = (CSmilElement*)m_pPacketQueue->RemoveHead();
  117. pElement->m_pHandler = pHandler;
  118. rc = pElement->handleElement();
  119.     }
  120.     else if(m_bTimestampsResolved)
  121.     {
  122. rc = HXR_STREAM_DONE;
  123.     }
  124.     else
  125.     {
  126. rc = HXR_NO_DATA;
  127.     }
  128.     return rc;
  129. }
  130. HX_RESULT CSmilParser::setAllElementHandlers(CSmilElementHandler* pHandler)
  131. {
  132.     HX_RESULT retVal = HXR_FAIL;
  133.     if (pHandler)
  134.     {
  135.         SMILNode* pNode = findFirstNode(SMILSmil);
  136.         if (pNode)
  137.         {
  138.             retVal = setElementHandler(pNode, pHandler);
  139.         }
  140.     }
  141.     return retVal;
  142. }
  143. void
  144. CSmilParser::initTagAttributes()
  145. {
  146.     if(!m_pTagAttributeMap)
  147.     {
  148. m_pTagAttributeMap = new CHXMapLongToObj;
  149.     }
  150.     CHXMapStringToOb* pStringMap = 0;
  151.     // SMILSmil
  152.     pStringMap = new CHXMapStringToOb;
  153.     (*pStringMap)["id"] = 0;
  154.     (*m_pTagAttributeMap)[SMILSmil] = pStringMap;
  155.     // SMILHead
  156.     pStringMap = new CHXMapStringToOb;
  157.     (*pStringMap)["id"] = 0;
  158.     (*m_pTagAttributeMap)[SMILHead] = pStringMap;
  159.     // SMILBasicLayout
  160.     pStringMap = new CHXMapStringToOb;
  161.     (*pStringMap)["id"] = 0;
  162.     (*pStringMap)["type"] = 0;
  163.     (*pStringMap)["system-required"] = 0;
  164.     (*pStringMap)["systemRequired"] = 0;
  165.     (*m_pTagAttributeMap)[SMILBasicLayout] = pStringMap;
  166.     // SMILRegion
  167.     pStringMap = new CHXMapStringToOb;
  168.     (*pStringMap)["id"] = 0;
  169.     (*pStringMap)["title"] = 0;
  170.     (*pStringMap)["height"] = 0;
  171.     (*pStringMap)["width"] = 0;
  172.     (*pStringMap)["background-color"] = 0;
  173.     (*pStringMap)["backgroundColor"] = 0;
  174.     (*pStringMap)["left"] = 0;
  175.     (*pStringMap)["top"] = 0;
  176.     (*pStringMap)["z-index"] = 0;
  177.     (*pStringMap)["fit"] = 0;
  178.     (*pStringMap)["skip-content"] = 0;
  179.     (*pStringMap)["soundLevel"] = 0;
  180.     (*m_pTagAttributeMap)[SMILRegion] = pStringMap;
  181.     // SMILRegPoint
  182.     pStringMap = new CHXMapStringToOb;
  183.     (*pStringMap)["id"] = 0;
  184.     (*pStringMap)["title"] = 0;
  185.     (*pStringMap)["left"] = 0;
  186.     (*pStringMap)["top"] = 0;
  187.     (*pStringMap)["right"] = 0;
  188.     (*pStringMap)["bottom"] = 0;
  189.     (*pStringMap)["regAlign"] = 0;
  190.     (*pStringMap)["skip-content"] = 0;
  191.     (*m_pTagAttributeMap)[SMILRegPoint] = pStringMap;
  192.     // SMILViewport
  193.     pStringMap = new CHXMapStringToOb;
  194.     (*pStringMap)["id"] = 0;
  195.     (*pStringMap)["title"] = 0;
  196.     (*pStringMap)["background-color"] = 0;
  197.     (*pStringMap)["backgroundColor"] = 0;
  198.     (*pStringMap)["width"] = 0;
  199.     (*pStringMap)["height"] = 0;
  200.     (*pStringMap)["open"] = 0;
  201.     (*pStringMap)["close"] = 0;
  202.     (*pStringMap)["skip-content"] = 0;
  203.     (*m_pTagAttributeMap)[SMILViewport] = pStringMap;
  204.     // SMILTransition
  205.     pStringMap = new CHXMapStringToOb;
  206.     (*pStringMap)["id"] = 0;
  207.     (*pStringMap)["type"] = 0;
  208.     (*pStringMap)["subtype"] = 0;
  209.     (*pStringMap)["dur"] = 0;
  210.     (*pStringMap)["base"] = 0;
  211.     (*pStringMap)["startPercent"] = 0;
  212.     (*pStringMap)["endPercent"] = 0;
  213.     (*pStringMap)["horzRepeat"] = 0;
  214.     (*pStringMap)["vertRepeat"] = 0;
  215.     (*pStringMap)["startX"] = 0;
  216.     (*pStringMap)["startY"] = 0;
  217.     (*pStringMap)["endX"] = 0;
  218.     (*pStringMap)["endY"] = 0;
  219.     (*pStringMap)["borderWidth"] = 0;
  220.     (*pStringMap)["color"] = 0;
  221.     (*m_pTagAttributeMap)[SMILTransition] = pStringMap;
  222.     // SMILRootLayout
  223.     pStringMap = new CHXMapStringToOb;
  224.     (*pStringMap)["id"] = 0;
  225.     (*pStringMap)["title"] = 0;
  226.     (*pStringMap)["height"] = 0;
  227.     (*pStringMap)["width"] = 0;
  228.     (*pStringMap)["background-color"] = 0;
  229.     (*pStringMap)["backgroundColor"] = 0;
  230.     (*pStringMap)["overflow"] = 0;
  231.     (*pStringMap)["skip-content"] = 0;
  232.     (*m_pTagAttributeMap)[SMILRootLayout] = pStringMap;
  233.     // SMILMeta
  234.     pStringMap = new CHXMapStringToOb;
  235.     (*pStringMap)["name"] = 0;
  236.     (*pStringMap)["content"] = 0;
  237.     (*pStringMap)["skip-content"] = 0;
  238.     (*m_pTagAttributeMap)[SMILMeta] = pStringMap;
  239.     // SMILMetadata
  240.     pStringMap = new CHXMapStringToOb;
  241.     (*pStringMap)["id"] = 0;
  242.     (*pStringMap)["skip-content"] = 0;
  243.     (*m_pTagAttributeMap)[SMILMetadata] = pStringMap;
  244.     // SMILBody
  245.     pStringMap = new CHXMapStringToOb;
  246.     (*pStringMap)["id"] = 0;
  247.     (*pStringMap)["restart"] = 0;
  248.     (*pStringMap)["restartDefault"] = 0;
  249.     (*m_pTagAttributeMap)[SMILBody] = pStringMap;
  250.     // SMILPar
  251.     pStringMap = new CHXMapStringToOb;
  252.     (*pStringMap)["id"] = 0;
  253.     (*pStringMap)["title"] = 0;
  254.     (*pStringMap)["abstract"] = 0;
  255.     (*pStringMap)["author"] = 0;
  256.     (*pStringMap)["copyright"] = 0;
  257.     (*pStringMap)["endsync"] = 0;
  258.     (*pStringMap)["dur"] = 0;
  259.     (*pStringMap)["repeat"] = 0;
  260.     (*pStringMap)["repeatDur"] = 0;
  261.     (*pStringMap)["repeatCount"] = 0;
  262.     (*pStringMap)["fill"] = 0;
  263.     (*pStringMap)["erase"] = 0;
  264.     (*pStringMap)["region"] = 0;
  265.     (*pStringMap)["begin"] = 0;
  266.     (*pStringMap)["end"] = 0;
  267.     (*pStringMap)["min"] = 0;
  268.     (*pStringMap)["max"] = 0;
  269.     (*pStringMap)["restart"] = 0;
  270.     (*pStringMap)["restartDefault"] = 0;
  271.     (*pStringMap)["syncTolerance"] = 0;
  272.     (*pStringMap)["syncToleranceDefault"] = 0;
  273.     (*pStringMap)["syncBehavior"] = 0;
  274.     (*pStringMap)["syncBehaviorDefault"] = 0;
  275.     (*pStringMap)["system-bitrate"] = 0;
  276.     (*pStringMap)["system-language"] = 0;
  277.     (*pStringMap)["system-required"] = 0;
  278.     (*pStringMap)["system-screen-size"] = 0;
  279.     (*pStringMap)["system-screen-depth"] = 0;
  280.     (*pStringMap)["system-captions"] = 0;
  281.     (*pStringMap)["system-overdub-or-caption"] = 0;
  282.     (*pStringMap)["systemBitrate"] = 0;
  283.     (*pStringMap)["systemLanguage"] = 0;
  284.     (*pStringMap)["systemRequired"] = 0;
  285.     (*pStringMap)["systemScreenSize"] = 0;
  286.     (*pStringMap)["systemScreenDepth"] = 0;
  287.     (*pStringMap)["systemCaptions"] = 0;
  288.     (*pStringMap)["systemOverdubOrSubtitle"] = 0;
  289.     (*pStringMap)["systemAudioDesc"] = 0;
  290.     (*pStringMap)["systemCPU"] = 0;
  291.     (*pStringMap)["systemComponent"] = 0;
  292.     (*pStringMap)["systemOperatingSystem"] = 0;
  293.     (*m_pTagAttributeMap)[SMILPar] = pStringMap;
  294.     // SMILSeq
  295.     pStringMap = new CHXMapStringToOb;
  296.     (*pStringMap)["id"] = 0;
  297.     (*pStringMap)["title"] = 0;
  298.     (*pStringMap)["abstract"] = 0;
  299.     (*pStringMap)["author"] = 0;
  300.     (*pStringMap)["copyright"] = 0;
  301.     (*pStringMap)["dur"] = 0;
  302.     (*pStringMap)["repeat"] = 0;
  303.     (*pStringMap)["repeatDur"] = 0;
  304.     (*pStringMap)["repeatCount"] = 0;
  305.     (*pStringMap)["fill"] = 0;
  306.     (*pStringMap)["erase"] = 0;
  307.     (*pStringMap)["region"] = 0;
  308.     (*pStringMap)["begin"] = 0;
  309.     (*pStringMap)["end"] = 0;
  310.     (*pStringMap)["min"] = 0;
  311.     (*pStringMap)["max"] = 0;
  312.     (*pStringMap)["restart"] = 0;
  313.     (*pStringMap)["restartDefault"] = 0;
  314.     (*pStringMap)["syncTolerance"] = 0;
  315.     (*pStringMap)["syncToleranceDefault"] = 0;
  316.     (*pStringMap)["syncBehavior"] = 0;
  317.     (*pStringMap)["syncBehaviorDefault"] = 0;
  318.     (*pStringMap)["systemBitrate"] = 0;
  319.     (*pStringMap)["systemLanguage"] = 0;
  320.     (*pStringMap)["systemRequired"] = 0;
  321.     (*pStringMap)["systemScreenSize"] = 0;
  322.     (*pStringMap)["systemScreenDepth"] = 0;
  323.     (*pStringMap)["systemCaptions"] = 0;
  324.     (*pStringMap)["systemOverdubOrSubtitle"] = 0;
  325.     (*pStringMap)["systemAudioDesc"] = 0;
  326.     (*pStringMap)["systemCPU"] = 0;
  327.     (*pStringMap)["systemComponent"] = 0;
  328.     (*pStringMap)["systemOperatingSystem"] = 0;
  329.     (*m_pTagAttributeMap)[SMILSeq] = pStringMap;
  330.     // SMILExcl
  331.     pStringMap = new CHXMapStringToOb;
  332.     (*pStringMap)["id"] = 0;
  333.     (*pStringMap)["title"] = 0;
  334.     (*pStringMap)["abstract"] = 0;
  335.     (*pStringMap)["author"] = 0;
  336.     (*pStringMap)["copyright"] = 0;
  337.     (*pStringMap)["dur"] = 0;
  338.     (*pStringMap)["repeat"] = 0;
  339.     (*pStringMap)["repeatDur"] = 0;
  340.     (*pStringMap)["repeatCount"] = 0;
  341.     (*pStringMap)["fill"] = 0;
  342.     (*pStringMap)["erase"] = 0;
  343.     (*pStringMap)["region"] = 0;
  344.     (*pStringMap)["begin"] = 0;
  345.     (*pStringMap)["end"] = 0;
  346.     (*pStringMap)["min"] = 0;
  347.     (*pStringMap)["max"] = 0;
  348.     (*pStringMap)["restart"] = 0;
  349.     (*pStringMap)["restartDefault"] = 0;
  350.     (*pStringMap)["syncTolerance"] = 0;
  351.     (*pStringMap)["syncToleranceDefault"] = 0;
  352.     (*pStringMap)["syncBehavior"] = 0;
  353.     (*pStringMap)["syncBehaviorDefault"] = 0;
  354.     (*pStringMap)["systemBitrate"] = 0;
  355.     (*pStringMap)["systemLanguage"] = 0;
  356.     (*pStringMap)["systemRequired"] = 0;
  357.     (*pStringMap)["systemScreenSize"] = 0;
  358.     (*pStringMap)["systemScreenDepth"] = 0;
  359.     (*pStringMap)["systemCaptions"] = 0;
  360.     (*pStringMap)["systemOverdubOrSubtitle"] = 0;
  361.     (*pStringMap)["systemAudioDesc"] = 0;
  362.     (*pStringMap)["systemCPU"] = 0;
  363.     (*pStringMap)["systemComponent"] = 0;
  364.     (*pStringMap)["systemOperatingSystem"] = 0;
  365.     (*m_pTagAttributeMap)[SMILExcl] = pStringMap;
  366.     // SMILPriorityClass
  367.     pStringMap = new CHXMapStringToOb;
  368.     (*pStringMap)["id"] = 0;
  369.     (*pStringMap)["peers"] = 0;
  370.     (*pStringMap)["higher"] = 0;
  371.     (*pStringMap)["lower"] = 0;
  372.     (*pStringMap)["pauseDisplay"] = 0;
  373.     (*pStringMap)["restartDefault"] = 0;
  374.     (*pStringMap)["syncToleranceDefault"] = 0;
  375.     (*pStringMap)["syncBehaviorDefault"] = 0;
  376.     (*m_pTagAttributeMap)[SMILPriorityClass] = pStringMap;
  377.     // SMILSwitch
  378.     pStringMap = new CHXMapStringToOb;
  379.     (*pStringMap)["id"] = 0;
  380.     (*pStringMap)["title"] = 0;
  381.     (*pStringMap)["restartDefault"] = 0;
  382.     (*pStringMap)["syncToleranceDefault"] = 0;
  383.     (*pStringMap)["syncBehaviorDefault"] = 0;
  384.     (*m_pTagAttributeMap)[SMILSwitch] = pStringMap;
  385.     // SMILRef
  386.     pStringMap = new CHXMapStringToOb;
  387.     (*pStringMap)["id"] = 0;
  388.     (*pStringMap)["title"] = 0;
  389.     (*pStringMap)["abstract"] = 0;
  390.     (*pStringMap)["author"] = 0;
  391.     (*pStringMap)["copyright"] = 0;
  392.     (*pStringMap)["region"] = 0;
  393.     (*pStringMap)["alt"] = 0;
  394.     (*pStringMap)["longdesc"] = 0;
  395.     (*pStringMap)["readindex"] = 0;
  396.     (*pStringMap)["src"] = 0;
  397.     (*pStringMap)["type"] = 0;
  398.     (*pStringMap)["dur"] = 0;
  399.     (*pStringMap)["repeat"] = 0;
  400.     (*pStringMap)["repeatDur"] = 0;
  401.     (*pStringMap)["repeatCount"] = 0;
  402.     (*pStringMap)["fill"] = 0;
  403.     (*pStringMap)["erase"] = 0;
  404.     (*pStringMap)["begin"] = 0;
  405.     (*pStringMap)["end"] = 0;
  406.     (*pStringMap)["min"] = 0;
  407.     (*pStringMap)["max"] = 0;
  408.     (*pStringMap)["restart"] = 0;
  409.     (*pStringMap)["restartDefault"] = 0;
  410.     (*pStringMap)["syncTolerance"] = 0;
  411.     (*pStringMap)["syncToleranceDefault"] = 0;
  412.     (*pStringMap)["syncBehavior"] = 0;
  413.     (*pStringMap)["syncBehaviorDefault"] = 0;
  414.     (*pStringMap)["clip-begin"] = 0;
  415.     (*pStringMap)["clipBegin"] = 0;
  416.     (*pStringMap)["clip-end"] = 0;
  417.     (*pStringMap)["clipEnd"] = 0;
  418.     (*pStringMap)["sensitivity"] = 0;
  419.     (*pStringMap)["skip-content"] = 0;
  420.     (*pStringMap)["system-bitrate"] = 0;
  421.     (*pStringMap)["system-language"] = 0;
  422.     (*pStringMap)["system-required"] = 0;
  423.     (*pStringMap)["system-screen-size"] = 0;
  424.     (*pStringMap)["system-screen-depth"] = 0;
  425.     (*pStringMap)["system-captions"] = 0;
  426.     (*pStringMap)["system-overdub-or-caption"] = 0;
  427.     (*pStringMap)["systemBitrate"] = 0;
  428.     (*pStringMap)["systemLanguage"] = 0;
  429.     (*pStringMap)["systemRequired"] = 0;
  430.     (*pStringMap)["systemScreenSize"] = 0;
  431.     (*pStringMap)["systemScreenDepth"] = 0;
  432.     (*pStringMap)["systemCaptions"] = 0;
  433.     (*pStringMap)["systemOverdubOrSubtitle"] = 0;
  434.     (*pStringMap)["systemAudioDesc"] = 0;
  435.     (*pStringMap)["systemCPU"] = 0;
  436.     (*pStringMap)["systemComponent"] = 0;
  437.     (*pStringMap)["systemOperatingSystem"] = 0;
  438.     (*pStringMap)["transition"] = 0;
  439.     (*m_pTagAttributeMap)[SMILRef] = pStringMap;
  440.     // SMILAAnchor
  441.     pStringMap = new CHXMapStringToOb;
  442.     (*pStringMap)["id"] = 0;
  443.     (*pStringMap)["title"] = 0;
  444.     (*pStringMap)["href"] = 0;
  445.     (*pStringMap)["alt"] = 0;
  446.     (*pStringMap)["longdesc"] = 0;
  447.     (*pStringMap)["readindex"] = 0;
  448.     (*pStringMap)["show"] = 0;
  449.     (*pStringMap)["restartDefault"] = 0;
  450.     (*pStringMap)["syncToleranceDefault"] = 0;
  451.     (*pStringMap)["syncBehaviorDefault"] = 0;
  452.     (*pStringMap)["sourceLevel"] = 0;
  453.     (*pStringMap)["destinationLevel"] = 0;
  454.     (*pStringMap)["sourcePlaystate"] = 0;
  455.     (*pStringMap)["destinationPlaystate"] = 0;
  456.     (*pStringMap)["external"] = 0;
  457.     (*pStringMap)["actuate"] = 0;
  458.     (*pStringMap)["accesskey"] = 0;
  459.     (*pStringMap)["tabindex"] = 0;
  460.     (*pStringMap)["target"] = 0;
  461.     (*m_pTagAttributeMap)[SMILAAnchor] = pStringMap;
  462.     // SMILArea
  463.     pStringMap = new CHXMapStringToOb;
  464.     (*pStringMap)["id"] = 0;
  465.     (*pStringMap)["title"] = 0;
  466.     (*pStringMap)["href"] = 0;
  467.     (*pStringMap)["alt"] = 0;
  468.     (*pStringMap)["longdesc"] = 0;
  469.     (*pStringMap)["readindex"] = 0;
  470.     (*pStringMap)["show"] = 0;
  471.     (*pStringMap)["sourceLevel"] = 0;
  472.     (*pStringMap)["destinationLevel"] = 0;
  473.     (*pStringMap)["sourcePlaystate"] = 0;
  474.     (*pStringMap)["destinationPlaystate"] = 0;
  475.     (*pStringMap)["external"] = 0;
  476.     (*pStringMap)["actuate"] = 0;
  477.     (*pStringMap)["accesskey"] = 0;
  478.     (*pStringMap)["tabindex"] = 0;
  479.     (*pStringMap)["target"] = 0;
  480.     (*pStringMap)["begin"] = 0;
  481.     (*pStringMap)["end"] = 0;
  482.     (*pStringMap)["dur"] = 0;
  483.     (*pStringMap)["repeat"] = 0;
  484.     (*pStringMap)["repeatDur"] = 0;
  485.     (*pStringMap)["repeatCount"] = 0;
  486.     (*pStringMap)["min"] = 0;
  487.     (*pStringMap)["max"] = 0;
  488.     (*pStringMap)["coords"] = 0;
  489.     (*pStringMap)["fragment-id"] = 0;
  490.     (*pStringMap)["fragment"] = 0;
  491.     (*pStringMap)["skip-content"] = 0;
  492.     (*pStringMap)["z-index"] = 0;
  493.     (*m_pTagAttributeMap)[SMILArea] = pStringMap;
  494.     // SMILAnchor
  495.     pStringMap = new CHXMapStringToOb;
  496.     (*pStringMap)["id"] = 0;
  497.     (*pStringMap)["title"] = 0;
  498.     (*pStringMap)["href"] = 0;
  499.     (*pStringMap)["alt"] = 0;
  500.     (*pStringMap)["longdesc"] = 0;
  501.     (*pStringMap)["readindex"] = 0;
  502.     (*pStringMap)["show"] = 0;
  503.     (*pStringMap)["begin"] = 0;
  504.     (*pStringMap)["end"] = 0;
  505.     (*pStringMap)["dur"] = 0;
  506.     (*pStringMap)["repeat"] = 0;
  507.     (*pStringMap)["repeatDur"] = 0;
  508.     (*pStringMap)["repeatCount"] = 0;
  509.     (*pStringMap)["min"] = 0;
  510.     (*pStringMap)["max"] = 0;
  511.     (*pStringMap)["coords"] = 0;
  512.     (*pStringMap)["fragment-id"] = 0;
  513.     (*pStringMap)["fragment"] = 0;
  514.     (*pStringMap)["skip-content"] = 0;
  515.     (*pStringMap)["z-index"] = 0;
  516.     (*m_pTagAttributeMap)[SMILAnchor] = pStringMap;
  517.     // SMILRendererPreFetch
  518.     pStringMap = new CHXMapStringToOb;
  519.     (*pStringMap)["type"] = 0;
  520.     (*m_pTagAttributeMap)[SMILRendererPreFetch] = pStringMap;
  521.     // SMILAnimate
  522.     pStringMap = new CHXMapStringToOb;
  523.     (*pStringMap)["id"]            = 0;
  524.     (*pStringMap)["attributeName"] = 0;
  525.     (*pStringMap)["targetElement"] = 0;
  526.     (*pStringMap)["from"]          = 0;
  527.     (*pStringMap)["to"]            = 0;
  528.     (*pStringMap)["by"]            = 0;
  529.     (*pStringMap)["values"]        = 0;
  530.     (*pStringMap)["calcMode"]      = 0;
  531.     (*pStringMap)["accumulate"]    = 0;
  532.     (*pStringMap)["additive"]      = 0;
  533.     (*pStringMap)["begin"]         = 0;
  534.     (*pStringMap)["end"]           = 0;
  535.     (*pStringMap)["dur"]           = 0;
  536.     (*pStringMap)["repeatDur"]     = 0;
  537.     (*pStringMap)["repeatCount"]   = 0;
  538.     (*pStringMap)["min"]           = 0;
  539.     (*pStringMap)["max"]           = 0;
  540.     (*m_pTagAttributeMap)[SMILAnimate] = pStringMap;
  541.     // SMILSet
  542.     pStringMap = new CHXMapStringToOb;
  543.     (*pStringMap)["id"]            = 0;
  544.     (*pStringMap)["attributeName"] = 0;
  545.     (*pStringMap)["targetElement"] = 0;
  546.     (*pStringMap)["to"]            = 0;
  547.     (*pStringMap)["begin"]         = 0;
  548.     (*pStringMap)["end"]           = 0;
  549.     (*pStringMap)["dur"]           = 0;
  550.     (*pStringMap)["repeatDur"]     = 0;
  551.     (*pStringMap)["repeatCount"]   = 0;
  552.     (*pStringMap)["min"]           = 0;
  553.     (*pStringMap)["max"]           = 0;
  554.     (*m_pTagAttributeMap)[SMILSet] = pStringMap;
  555.     // SMILAnimateMotion
  556.     pStringMap = new CHXMapStringToOb;
  557.     (*pStringMap)["id"]            = 0;
  558.     (*pStringMap)["targetElement"] = 0;
  559.     (*pStringMap)["from"]          = 0;
  560.     (*pStringMap)["to"]            = 0;
  561.     (*pStringMap)["by"]            = 0;
  562.     (*pStringMap)["values"]        = 0;
  563.     (*pStringMap)["accumulate"]    = 0;
  564.     (*pStringMap)["additive"]      = 0;
  565.     (*pStringMap)["calcMode"]      = 0;
  566.     (*pStringMap)["path"]          = 0;
  567.     (*pStringMap)["origin"]        = 0;
  568.     (*pStringMap)["begin"]         = 0;
  569.     (*pStringMap)["end"]           = 0;
  570.     (*pStringMap)["dur"]           = 0;
  571.     (*pStringMap)["repeatDur"]     = 0;
  572.     (*pStringMap)["repeatCount"]   = 0;
  573.     (*pStringMap)["min"]           = 0;
  574.     (*pStringMap)["max"]           = 0;
  575.     (*m_pTagAttributeMap)[SMILAnimateMotion] = pStringMap;
  576.     // SMILAnimateColor
  577.     pStringMap = new CHXMapStringToOb;
  578.     (*pStringMap)["id"]            = 0;
  579.     (*pStringMap)["attributeName"] = 0;
  580.     (*pStringMap)["targetElement"] = 0;
  581.     (*pStringMap)["from"]          = 0;
  582.     (*pStringMap)["to"]            = 0;
  583.     (*pStringMap)["by"]            = 0;
  584.     (*pStringMap)["values"]        = 0;
  585.     (*pStringMap)["calcMode"]      = 0;
  586.     (*pStringMap)["accumulate"]    = 0;
  587.     (*pStringMap)["additive"]      = 0;
  588.     (*pStringMap)["begin"]         = 0;
  589.     (*pStringMap)["end"]           = 0;
  590.     (*pStringMap)["dur"]           = 0;
  591.     (*pStringMap)["repeatDur"]     = 0;
  592.     (*pStringMap)["repeatCount"]   = 0;
  593.     (*pStringMap)["min"]           = 0;
  594.     (*pStringMap)["max"]           = 0;
  595.     (*m_pTagAttributeMap)[SMILAnimateColor] = pStringMap;
  596. }
  597. void
  598. CSmilParser::deleteTagAttributes()
  599. {
  600.     if(m_pTagAttributeMap)
  601.     {
  602.         CHXMapLongToObj::Iterator i = m_pTagAttributeMap->Begin();
  603. for(; i != m_pTagAttributeMap->End(); ++i)
  604. {
  605.     CHXMapStringToOb* pStringMap = (CHXMapStringToOb*)(*i);
  606.     delete pStringMap;
  607. }
  608.     }
  609.     HX_DELETE(m_pTagAttributeMap);
  610. }
  611. BOOL
  612. CSmilParser::isLegalAttribute(SMILNodeTag tag, const char* pAttName)
  613. {
  614.     // use SMILRef for all media object checks
  615.     if(tag == SMILText ||
  616.        tag == SMILImg ||
  617.        tag == SMILAudio ||
  618.        tag == SMILVideo ||
  619.        tag == SMILAnimation ||
  620.        tag == SMILTextstream ||
  621.        tag == SMILPrefetch  ||
  622.        tag == SMILBrush)
  623.     {
  624. tag = SMILRef;
  625.     }
  626.     CHXMapStringToOb* pStringMap = 0;
  627.     if(m_pTagAttributeMap->Lookup(tag, (void*&)pStringMap))
  628.     {
  629. void* pVoid = 0;
  630. if(pStringMap->Lookup(pAttName, pVoid))
  631. {
  632.     return TRUE;
  633. }
  634. else if (strcmp(pAttName, "xmlns") == 0 ||
  635.     strncmp(pAttName, "xmlns:", 6) == 0)
  636. {
  637.     // accept any namespace declarations.
  638.     return TRUE;
  639. }
  640. else
  641. {
  642.     BOOL bValidAttribute = FALSE;
  643.     char* pColon = (char *)strchr(pAttName, ':');
  644.     if(pColon)
  645.     {
  646. //check for valid namespace tag we can
  647. // ignore
  648. char* pTmpNam = new_string(pAttName);
  649. char* pNamespace = strtok(pTmpNam, ":");
  650. if(pNamespace)
  651. {
  652.     UINT32 ulTemp = 0;
  653.     if(m_pActiveNamespaceMap &&
  654.       (m_pActiveNamespaceMap->Lookup(pNamespace,
  655.       (void*&)ulTemp)))
  656.     {
  657. // OK, we can ignore it...
  658. bValidAttribute = TRUE;
  659.     }
  660. }
  661. delete[] pTmpNam;
  662.     }
  663.     if(bValidAttribute)
  664.     {
  665. return TRUE;
  666.     }
  667. }
  668.     }
  669.     return FALSE;
  670. }
  671. BOOL
  672. CSmilParser::isRelativeURL(const char* pURL)
  673. {
  674.     BOOL rc = TRUE;
  675.     CHXURL urlObj(pURL);
  676.     IHXValues* pHeader = urlObj.GetProperties();
  677.     if(pHeader)
  678.     {
  679.         IHXBuffer* pBuffer = NULL;
  680. if(HXR_OK == pHeader->GetPropertyBuffer(PROPERTY_SCHEME, pBuffer))
  681. {
  682.     // fully qualified URL
  683.     rc = FALSE;
  684.     HX_RELEASE(pBuffer);
  685. }
  686.     }
  687.     HX_RELEASE(pHeader);
  688.     return rc;
  689. }
  690. HX_RESULT
  691. CSmilParser::storeNamespaces(SMILNode* pNode)
  692. {
  693.     HX_RESULT rc = HXR_OK;
  694.     if (pNode->m_pValues)
  695.     {
  696. const char* pName = NULL;
  697. IHXBuffer* pBuffer = NULL;
  698. HX_RESULT res = pNode->m_pValues->GetFirstPropertyCString(pName, pBuffer);
  699. while (SUCCEEDED(rc) && SUCCEEDED(res))
  700. {
  701.     if (strcmp(pName, "xmlns") == 0)
  702.     {
  703. if (!pNode->m_pNamespaceList)
  704. {
  705.     pNode->m_pNamespaceList = new CHXSimpleList;
  706.     if (!pNode->m_pNamespaceList)
  707.     {
  708. rc = HXR_OUTOFMEMORY;
  709. break;
  710.     }
  711. }
  712. // duplicate atributes should allready be caught...
  713. SMILNamespace* pNS = new SMILNamespace("", pBuffer);
  714. pNode->m_pNamespaceList->AddHead(pNS);
  715. if (SMILSmil == pNode->m_tag)
  716. {
  717.     if (!m_pDefaultNamespace)
  718.     {
  719. m_pDefaultNamespace = pBuffer;
  720. m_pDefaultNamespace->AddRef();
  721.     }
  722.     // /XXXEH- TODO: fire off error if there is more than
  723.     // one default namespace?
  724. //     else ...
  725. }
  726.     }
  727.     else if (strncmp(pName, "xmlns:", 6) == 0)
  728.     {
  729. if (!pNode->m_pNamespaceList)
  730. {
  731.     pNode->m_pNamespaceList = new CHXSimpleList;
  732.     if (!pNode->m_pNamespaceList)
  733.     {
  734. rc = HXR_OUTOFMEMORY;
  735. break;
  736.     }
  737. }
  738. char* nsPrefix = (char *)strchr(pName, ':');
  739. ++nsPrefix;
  740. SMILNamespace* pNS = new SMILNamespace(nsPrefix, pBuffer);
  741. pNode->m_pNamespaceList->AddHead(pNS);
  742. // /Now, fix Structure Interop #2.1 (unrecognized smil-tag namespace)
  743. // and #2.3 (SMIL 2.0-module namespaces in the smil tag):
  744. const char* pNamespace = (const char*)pBuffer->GetBuffer();
  745. if (pNamespace  &&  isSupportedNonRNNamespace(pNamespace))
  746. {
  747.     SMILNamespace* pNS = new SMILNamespace(nsPrefix, pBuffer);
  748.     pNode->m_pNamespaceList->AddHead(pNS);
  749.     if (!m_pRequireTagsMap)
  750.     {
  751. m_pRequireTagsMap = new CHXMapStringToOb;
  752.     }
  753.     if (nsPrefix  &&  *nsPrefix)
  754.     {
  755. // /Add the prefix to the require map for systemRequired
  756. //checks:
  757. (*m_pRequireTagsMap)[nsPrefix] = 0;
  758.     }
  759. }
  760.     }
  761.     HX_RELEASE(pBuffer);
  762.     res = pNode->m_pValues->GetNextPropertyCString(pName, pBuffer);
  763. }
  764.     }
  765.     return rc;
  766. }
  767. HX_RESULT
  768. CSmilParser::addToNamespaceScope(SMILNode* pNode)
  769. {
  770.     HX_RESULT rc = HXR_OK;
  771.     if (!m_pActiveNamespaceMap)
  772.     {
  773. m_pActiveNamespaceMap = new CHXMapStringToOb;
  774. if (!m_pActiveNamespaceMap)
  775. {
  776.     return HXR_OUTOFMEMORY;
  777. }
  778.     }
  779.     if (pNode->m_pNamespaceList)
  780.     {
  781. for (CHXSimpleList::Iterator pIt = pNode->m_pNamespaceList->Begin();
  782.      pIt != pNode->m_pNamespaceList->End(); ++pIt)
  783. {
  784.     SMILNamespace* pNS = (SMILNamespace*)(*pIt);
  785.     IHXBuffer* pBuf = (IHXBuffer*)(*m_pActiveNamespaceMap)[pNS->m_name];
  786.     if (pBuf)
  787.     {
  788. if (!m_pNSConflictList)
  789. {
  790.     m_pNSConflictList = new CHXSimpleList;
  791.     if (!m_pNSConflictList)
  792.     {
  793. rc = HXR_OUTOFMEMORY;
  794. break;
  795.     }
  796. }
  797. SMILNamespace* pConflict = new SMILNamespace(pNS);
  798. if (!pConflict)
  799. {
  800.     rc = HXR_OUTOFMEMORY;
  801.     break;
  802. }
  803. m_pNSConflictList->AddHead(pConflict);
  804. HX_RELEASE(pBuf);
  805. (*m_pActiveNamespaceMap)[pNS->m_name] = pNS->m_pValue;
  806. pNS->m_pValue->AddRef();
  807.     }
  808.     else
  809.     {
  810. (*m_pActiveNamespaceMap)[pNS->m_name] = pNS->m_pValue;
  811. pNS->m_pValue->AddRef();
  812.     }
  813. }
  814.     }
  815.     return rc;
  816. }
  817. HX_RESULT
  818. CSmilParser::removeFromNamespaceScope(SMILNode* pNode)
  819. {
  820.     HX_RESULT rc = HXR_OK;
  821.     if (pNode->m_pNamespaceList)
  822.     {
  823. for (CHXSimpleList::Iterator pIt = pNode->m_pNamespaceList->Begin();
  824.      pIt != pNode->m_pNamespaceList->End(); ++pIt)
  825. {
  826.     SMILNamespace* pNS = (SMILNamespace*)(*pIt);
  827.     HX_ASSERT((*m_pActiveNamespaceMap)[pNS->m_name]);
  828.     IHXBuffer* pBuf = (IHXBuffer*)(*m_pActiveNamespaceMap)[pNS->m_name];
  829.     if (pBuf != NULL)
  830.     {
  831. HX_RELEASE(pBuf);
  832. m_pActiveNamespaceMap->RemoveKey(pNS->m_name);
  833. // check for conficts.
  834. if (m_pNSConflictList)
  835. {
  836.     LISTPOSITION pos = m_pNSConflictList->GetHeadPosition();
  837.     while (pos)
  838.     {
  839. SMILNamespace* pCon =
  840.     (SMILNamespace*)m_pNSConflictList->GetAt(pos);
  841. if (strcmp(pCon->m_name, pNS->m_name) == 0)
  842. {
  843.     (*m_pActiveNamespaceMap)[pCon->m_name] = pCon->m_pValue;
  844.     pCon->m_pValue->AddRef();
  845.     HX_DELETE(pCon);
  846.     m_pNSConflictList->RemoveAt(pos);
  847.     // BREAK at the first found match.
  848.     break;
  849. }
  850. m_pNSConflictList->GetNext(pos);
  851.     }
  852. }
  853.     }
  854. }
  855.     }
  856.     return rc;
  857. }
  858. BOOL
  859. CSmilParser::isSupportedNonRNNamespace(const char* pNamespace)
  860. {
  861.     BOOL bIsSupportedNamespace = FALSE;
  862.     if(m_bNoNamespaces)
  863.     {
  864. CSmilSMILSyntaxErrorHandler errHandler(m_pContext);
  865. errHandler.ReportError(SMILErrorSMIL10Document, NULL, 0);
  866.     }
  867.     else
  868.     {
  869. if (pNamespace  &&  strlen(pNamespace)>0)
  870. {
  871.     UINT32 ui=0;
  872.     for (ui=0; ui<NUM_SUPPORTED_SMIL_2_0_MODULE_NAMESPACES; ui++)
  873.     {
  874. if (0 == strcmp(
  875. (const char*) zm_pSupportedSMIL2ModuleNamespaces[ui],
  876. pNamespace) )
  877. {
  878.     bIsSupportedNamespace = TRUE;
  879.     break;
  880. }
  881.     }
  882. }
  883.     }
  884.     if (!bIsSupportedNamespace)
  885.     {
  886. bIsSupportedNamespace =
  887. (0==strcmp((const char*) SYSTEM_COMPONENT_NAMESPACE, pNamespace));
  888.     }
  889.     return bIsSupportedNamespace;
  890. }
  891. HX_RESULT
  892. CSmilParser::addGlobalNamespace(const char* pNamespace,
  893.   const char* pPrefix)
  894. {
  895.     HX_RESULT rc = HXR_OK;
  896.     if(m_bNoNamespaces)
  897.     {
  898. rc = HXR_FAIL;
  899. CSmilSMILSyntaxErrorHandler errHandler(m_pContext);
  900. errHandler.ReportError(SMILErrorSMIL10Document, NULL, 0);
  901.     }
  902.     else
  903.     {
  904. if(!m_pActiveNamespaceMap)
  905. {
  906.     m_pActiveNamespaceMap = new CHXMapStringToOb;
  907. }
  908. if (!m_pRequireTagsMap)
  909. {
  910.     m_pRequireTagsMap = new CHXMapStringToOb;
  911. }
  912. if(pPrefix)
  913. {
  914.     // get an IHXBuffer
  915.     //XXXJEFFA should use CF for this
  916.     IHXBuffer* pBuffer = (IHXBuffer*) new CHXBuffer;
  917.     pBuffer->AddRef();
  918.     pBuffer->Set((UINT8*)pNamespace, strlen(pNamespace) + 1);
  919.     (*m_pActiveNamespaceMap)[pPrefix] = pBuffer;
  920.     // add the prefix to the require map so system
  921.     // required checks work
  922.     (*m_pRequireTagsMap)[pPrefix] = 0;
  923.     if(strcmp(pPrefix, (const char*) RN_PREFIX) == 0)
  924.     {
  925. m_bRNNamespace = TRUE;
  926.     }
  927. }
  928. else
  929. {
  930.     // empty prefix,
  931.     // don't ignore unrecognized elements...
  932.     m_bIgnoreUnrecognizedElements = FALSE;
  933. }
  934.     }
  935.     return rc;
  936. }
  937. HX_RESULT
  938. CSmilParser::storeError(HX_RESULT errCode, const char* pErrorString,
  939.  const char* pFrameString, UINT32 ulLineNumber,
  940.  UINT32 ulLinePosition, BOOL bXml)
  941. {
  942.     // XXXJHUG - this is what the SMIL error hanndler uses 1024....
  943.     char errorString[1024]; /* Flawfinder: ignore */
  944.     if (bXml)
  945.     {
  946. CSmilXMLSyntaxErrorHandler errHandler(m_pContext);
  947. errHandler.GetReportString(errCode, errorString);
  948.     }
  949.     else
  950.     {
  951. CSmilSMILSyntaxErrorHandler errHandler(m_pContext);
  952. errHandler.GetReportString((SMILErrorTag)errCode, errorString);
  953.     }
  954.     IHXBuffer* pBuf;
  955.     m_pClassFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pBuf);
  956.     pBuf->SetSize(strlen(errorString) + strlen(pErrorString) + 10);
  957.     char* buffer = (char*) pBuf->GetBuffer();
  958.     sprintf(buffer, errorString, ulLineNumber, pErrorString); /* Flawfinder: ignore */
  959.     m_pErrors->Add(pBuf);
  960.     return HXR_OK;
  961. }
  962. HX_RESULT
  963. CSmilParser::getErrors(CHXPtrArray** pErrs)
  964. {
  965.     *pErrs = m_pErrors;
  966.     return HXR_OK;
  967. }
  968. const char*
  969. CSmilParser::getDefaultNamespace()
  970. {
  971.     if (!m_pDefaultNamespace)
  972.     {
  973. return NULL;
  974.     }
  975.     return (const char*)m_pDefaultNamespace->GetBuffer();
  976. }
  977. HX_RESULT CSmilParser::parseRegionDimension(const char*   pszStr,
  978.                                             REF(double)   rdValue,
  979.                                             REF(CSS2Type) reType)
  980. {
  981.     HX_RESULT retVal = HXR_OK;
  982.     if (pszStr)
  983.     {
  984.         // "left", "top", "right", "bottom", "width", and "height"
  985.         // must fit this definition from the CSS2 spec
  986.         // (http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-left)
  987.         //
  988.         // <length> | <percentage> | 'auto' | 'inherit'
  989.         //
  990.         // WS           := ' ' | 'n' | 'r' | 't'
  991.         // <length>     := WS* [+|-] [0-9] ['.'] [0-9] ['px'] WS*
  992.         // <percentage> := WS* [+|-] [0-9] ['.'] [0-9] '%' WS*
  993.         //
  994.         if (!strcmp(pszStr, "auto"))
  995.         {
  996.             rdValue = 0.0;
  997.             reType  = CSS2TypeAuto;
  998.         }
  999.         else if (!strcmp(pszStr, "inherit"))
  1000.         {
  1001.             rdValue = 0.0;
  1002.             reType  = CSS2TypeInherit;
  1003.         }
  1004.         else
  1005.         {
  1006.             // Check to make sure the string is valid
  1007.             //
  1008.             // Here is the definition of the state machine
  1009.             // 0 is the starting state
  1010.             // If you end in state 7, you are a <length>
  1011.             // If you end in state 6, you are a <percentage>
  1012.             // If you end in state -1, this is an error
  1013.             //
  1014.             // State -1: // error state
  1015.             //     else goto state -1
  1016.             // State 0: // starting state
  1017.             //     WS   goto state 0
  1018.             //     +,-  goto state 1
  1019.             //     0-9  goto state 2
  1020.             //     .    goto state 3
  1021.             //     else goto state -1
  1022.             // State 1: // just saw + or -
  1023.             //     0-9  goto state 2
  1024.             //     .    goto state 3
  1025.             //     else goto state -1
  1026.             // State 2: // have already seen at least one 0-9
  1027.             //     0-9  goto state 2
  1028.             //     .    goto state 4
  1029.             //     p    goto state 5
  1030.             //     %    goto state 6
  1031.             //     NULL goto state 7
  1032.             //     WS   goto state 7
  1033.             //     else goto state -1
  1034.             // State 3: // saw a . without seeing a 0-9
  1035.             //     0-9  goto state 4
  1036.             //     else goto state -1
  1037.             // State 4: // saw a . after seeing a 0-9
  1038.             //     0-9  goto state 4
  1039.             //     p    goto state 5
  1040.             //     %    goto state 6
  1041.             //     NULL goto state 7
  1042.             //     WS   goto state 7
  1043.             //     else goto state -1
  1044.             // State 5:
  1045.             //     x    goto state 7
  1046.             //     else goto state -1
  1047.             // State 6: // <percentage> ending state
  1048.             //     WS   goto state 6
  1049.             //     NULL goto state 6
  1050.             //     else goto state -1
  1051.             // State 7: // <length> ending state
  1052.             //     WS   goto state 7
  1053.             //     NULL goto state 7
  1054.             //     else goto state -1
  1055.             //
  1056.             const char* pszTmp   = pszStr;
  1057.             const char* pszLimit = pszTmp + strlen(pszTmp);
  1058.             INT32       lState   = 0;
  1059.             while (pszTmp <= pszLimit)
  1060.             {
  1061.                 char c = *pszTmp++;
  1062.                 switch (lState)
  1063.                 {
  1064.                     case -1:
  1065.                         break;
  1066.                     case 0:
  1067.                         {
  1068.                             if (c == ' ' || c == 'r' || c == 'n' || c == 't')
  1069.                             {
  1070.                                 lState = 0;
  1071.                             }
  1072.                             else if (c == '+' || c == '-')
  1073.                             {
  1074.                                 lState = 1;
  1075.                             }
  1076.                             else if (c >= '0' && c <= '9')
  1077.                             {
  1078.                                 lState = 2;
  1079.                             }
  1080.                             else if (c == '.')
  1081.                             {
  1082.                                 lState = 3;
  1083.                             }
  1084.                             else
  1085.                             {
  1086.                                 lState = -1;
  1087.                             }
  1088.                         }
  1089.                         break;
  1090.                     case 1:
  1091.                         {
  1092.                             if (c >= '0' && c <= '9')
  1093.                             {
  1094.                                 lState = 2;
  1095.                             }
  1096.                             else if (c == '.')
  1097.                             {
  1098.                                 lState = 3;
  1099.                             }
  1100.                             else
  1101.                             {
  1102.                                 lState = -1;
  1103.                             }
  1104.                         }
  1105.                         break;
  1106.                     case 2:
  1107.                         {
  1108.                             if (c >= '0' && c <= '9')
  1109.                             {
  1110.                                 lState = 2;
  1111.                             }
  1112.                             else if (c == '.')
  1113.                             {
  1114.                                 lState = 4;
  1115.                             }
  1116.                             else if (c == 'p')
  1117.                             {
  1118.                                 lState = 5;
  1119.                             }
  1120.                             else if (c == '%')
  1121.                             {
  1122.                                 lState = 6;
  1123.                             }
  1124.                             else if (c == '')
  1125.                             {
  1126.                                 lState = 7;
  1127.                             }
  1128.                             else if (c == ' ' || c == 'r' || c == 'n' || c == 't')
  1129.                             {
  1130.                                 lState = 7;
  1131.                             }
  1132.                             else
  1133.                             {
  1134.                                 lState = -1;
  1135.                             }
  1136.                         }
  1137.                         break;
  1138.                     case 3:
  1139.                         {
  1140.                             if (c >= '0' && c <= '9')
  1141.                             {
  1142.                                 lState = 4;
  1143.                             }
  1144.                             else
  1145.                             {
  1146.                                 lState = -1;
  1147.                             }
  1148.                         }
  1149.                         break;
  1150.                     case 4:
  1151.                         {
  1152.                             if (c >= '0' && c <= '9')
  1153.                             {
  1154.                                 lState = 4;
  1155.                             }
  1156.                             else if (c == 'p')
  1157.                             {
  1158.                                 lState = 5;
  1159.                             }
  1160.                             else if (c == '%')
  1161.                             {
  1162.                                 lState = 6;
  1163.                             }
  1164.                             else if (c == '')
  1165.                             {
  1166.                                 lState = 7;
  1167.                             }
  1168.                             else if (c == ' ' || c == 'r' || c == 'n' || c == 't')
  1169.                             {
  1170.                                 lState = 7;
  1171.                             }
  1172.                             else
  1173.                             {
  1174.                                 lState = -1;
  1175.                             }
  1176.                         }
  1177.                         break;
  1178.                     case 5:
  1179.                         {
  1180.                             if (c == 'x')
  1181.                             {
  1182.                                 lState = 7;
  1183.                             }
  1184.                             else
  1185.                             {
  1186.                                 lState = -1;
  1187.                             }
  1188.                         }
  1189.                         break;
  1190.                     case 6:
  1191.                         {
  1192.                             if (c == ' '  || c == 'r' || c == 'n' ||
  1193.                                 c == 't' || c == '')
  1194.                             {
  1195.                                 lState = 6;
  1196.                             }
  1197.                             else
  1198.                             {
  1199.                                 lState = -1;
  1200.                             }
  1201.                         }
  1202.                         break;
  1203.                     case 7:
  1204.                         {
  1205.                             if (c == ' '  || c == 'r' || c == 'n' ||
  1206.                                 c == 't' || c == '')
  1207.                             {
  1208.                                 lState = 7;
  1209.                             }
  1210.                             else
  1211.                             {
  1212.                                 lState = -1;
  1213.                             }
  1214.                         }
  1215.                         break;
  1216.                 }
  1217.             }
  1218.             // Check to see if we ended in a valid state
  1219.             if (lState == 6)
  1220.             {
  1221.                 // We are a percentage
  1222.                 reType = CSS2TypePercentage;
  1223.             }
  1224.             else if (lState == 7)
  1225.             {
  1226.                 // We are a length
  1227.                 reType = CSS2TypeLength;
  1228.             }
  1229.             else
  1230.             {
  1231.                 // Error
  1232.                 retVal = HXR_FAIL;
  1233.             }
  1234.             if (SUCCEEDED(retVal))
  1235.             {
  1236.                 // Now it's safe to use strtod() to parse
  1237.                 // the value
  1238.                 rdValue = strtod(pszStr, NULL);
  1239.             }
  1240.         }
  1241.     }
  1242.     else
  1243.     {
  1244.         retVal = HXR_FAIL;
  1245.     }
  1246.     return retVal;
  1247. }
  1248. HX_RESULT CSmilParser::parseZIndex(const char*   pszStr,
  1249.                                    REF(INT32)    rlValue,
  1250.                                    REF(CSS2Type) reType)
  1251. {
  1252.     HX_RESULT retVal = HXR_OK;
  1253.     if (pszStr)
  1254.     {
  1255.         // "z-index" must fit this definition from the CSS2 spec
  1256.         // (http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-z-index)
  1257.         //
  1258.         // <integer> | 'auto' | 'inherit'
  1259.         //
  1260.         // WS           := ' ' | 'n' | 'r' | 't'
  1261.         // <integer>    := WS* [+|-] [0-9]+ WS*
  1262.         //
  1263.         if (!strcmp(pszStr, "auto"))
  1264.         {
  1265.             rlValue = 0;
  1266.             reType  = CSS2TypeAuto;
  1267.         }
  1268.         else if (!strcmp(pszStr, "inherit"))
  1269.         {
  1270.             rlValue = 0;
  1271.             reType  = CSS2TypeInherit;
  1272.         }
  1273.         else
  1274.         {
  1275.             // Check to make sure the string is valid
  1276.             //
  1277.             // Here is the definition of the state machine
  1278.             // 0 is the starting state
  1279.             // 3 is the successful ending state
  1280.             // If you end in state -1, this is an error
  1281.             //
  1282.             // State -1: // error state
  1283.             //     else goto state -1
  1284.             // State 0: // starting state
  1285.             //     WS   goto state 0
  1286.             //     +,-  goto state 1
  1287.             //     0-9  goto state 2
  1288.             //     else goto state -1
  1289.             // State 1: // just saw + or -
  1290.             //     0-9  goto state 2
  1291.             //     else goto state -1
  1292.             // State 2: // have already seen at least one 0-9
  1293.             //     0-9  goto state 2
  1294.             //     WS   goto state 3
  1295.             //     NULL goto state 3
  1296.             //     else goto state -1
  1297.             // State 3: // happy ending state
  1298.             //     WS   goto state 3
  1299.             //     NULL goto state 3
  1300.             //     else goto state -1
  1301.             //
  1302.             const char* pszTmp   = pszStr;
  1303.             const char* pszLimit = pszTmp + strlen(pszTmp);
  1304.             INT32       lState   = 0;
  1305.             while (pszTmp <= pszLimit)
  1306.             {
  1307.                 char c = *pszTmp++;
  1308.                 switch (lState)
  1309.                 {
  1310.                     case -1:
  1311.                         break;
  1312.                     case 0:
  1313.                         {
  1314.                             if (c == ' ' || c == 'r' || c == 'n' || c == 't')
  1315.                             {
  1316.                                 lState = 0;
  1317.                             }
  1318.                             else if (c == '+' || c == '-')
  1319.                             {
  1320.                                 lState = 1;
  1321.                             }
  1322.                             else if (c >= '0' && c <= '9')
  1323.                             {
  1324.                                 lState = 2;
  1325.                             }
  1326.                             else
  1327.                             {
  1328.                                 lState = -1;
  1329.                             }
  1330.                         }
  1331.                         break;
  1332.                     case 1:
  1333.                         {
  1334.                             if (c >= '0' && c <= '9')
  1335.                             {
  1336.                                 lState = 2;
  1337.                             }
  1338.                             else
  1339.                             {
  1340.                                 lState = -1;
  1341.                             }
  1342.                         }
  1343.                         break;
  1344.                     case 2:
  1345.                         {
  1346.                             if (c >= '0' && c <= '9')
  1347.                             {
  1348.                                 lState = 2;
  1349.                             }
  1350.                             else if (c == ' ' || c == 'r' || c == 'n' || c == 't')
  1351.                             {
  1352.                                 lState = 3;
  1353.                             }
  1354.                             else if (c == '')
  1355.                             {
  1356.                                 lState = 3;
  1357.                             }
  1358.                             else
  1359.                             {
  1360.                                 lState = -1;
  1361.                             }
  1362.                         }
  1363.                         break;
  1364.                     case 3:
  1365.                         {
  1366.                             if (c == ' ' || c == 'r' || c == 'n' || c == 't')
  1367.                             {
  1368.                                 lState = 3;
  1369.                             }
  1370.                             else if (c == '')
  1371.                             {
  1372.                                 lState = 3;
  1373.                             }
  1374.                             else
  1375.                             {
  1376.                                 lState = -1;
  1377.                             }
  1378.                         }
  1379.                         break;
  1380.                 }
  1381.             }
  1382.             // Check to see if we ended in a valid state
  1383.             if (lState == 3)
  1384.             {
  1385.                 // We are a <integer>
  1386.                 reType = CSS2TypeInteger;
  1387.                 // Now we can safely use atol() to
  1388.                 // parse the value
  1389.                 rlValue = atol(pszStr);
  1390.             }
  1391.             else
  1392.             {
  1393.                 // Error
  1394.                 retVal = HXR_FAIL;
  1395.             }
  1396.         }
  1397.     }
  1398.     else
  1399.     {
  1400.         retVal = HXR_FAIL;
  1401.     }
  1402.     return retVal;
  1403. }
  1404. HX_RESULT CSmilParser::parseColor(const char*   pszStr,
  1405.                                   REF(UINT32)   rulValue,
  1406.                                   REF(CSS2Type) reType)
  1407. {
  1408.     HX_RESULT retVal = HXR_OK;
  1409.     if (pszStr)
  1410.     {
  1411.         // "backgroundColor" must fit this definition from the CSS2 spec
  1412.         // (http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-color)
  1413.         //
  1414.         // <color> | 'transparent' | 'inherit'
  1415.         //
  1416.         UINT32 ulColor = 0;
  1417.         if (!strcmp(pszStr, "transparent"))
  1418.         {
  1419.             rulValue = 0xFF000000;
  1420.             reType   = CSS2TypeTransparent;
  1421.         }
  1422.         else if (!strcmp(pszStr, "inherit"))
  1423.         {
  1424.             rulValue = 0;
  1425.             reType   = CSS2TypeInherit;
  1426.         }
  1427.         else
  1428.         {
  1429.             UINT32 ulColor = 0;
  1430.             retVal         = HXParseColorUINT32(pszStr, ulColor);
  1431.             if (SUCCEEDED(retVal))
  1432.             {
  1433.                 rulValue = ulColor;
  1434.                 reType   = CSS2TypeColor;
  1435.             }
  1436.         }
  1437.     }
  1438.     else
  1439.     {
  1440.         retVal = HXR_FAIL;
  1441.     }
  1442.     return retVal;
  1443. }
  1444. HX_RESULT CSmilParser::parseFit(const char*   pszStr,
  1445.                                 REF(Fit)      reValue)
  1446. {
  1447.     HX_RESULT retVal = HXR_OK;
  1448.     if (pszStr)
  1449.     {
  1450.         if (!strcmp(pszStr, "fill"))
  1451.         {
  1452.             reValue = FitFill;
  1453.         }
  1454.         else if (!strcmp(pszStr, "hidden"))
  1455.         {
  1456.             reValue = FitHidden;
  1457.         }
  1458.         else if (!strcmp(pszStr, "meet"))
  1459.         {
  1460.             reValue = FitMeet;
  1461.         }
  1462.         else if (!strcmp(pszStr, "scroll"))
  1463.         {
  1464.             reValue = FitScroll;
  1465.         }
  1466.         else if (!strcmp(pszStr, "slice"))
  1467.         {
  1468.             reValue = FitSlice;
  1469.         }
  1470.         else
  1471.         {
  1472.             retVal = HXR_FAIL;
  1473.         }
  1474.     }
  1475.     else
  1476.     {
  1477.         retVal = HXR_FAIL;
  1478.     }
  1479.     return retVal;
  1480. }
  1481. HX_RESULT CSmilParser::parseRegAlign(const char*   pszStr,
  1482.                                      REF(RegAlign) reValue)
  1483. {
  1484.     HX_RESULT retVal = HXR_OK;
  1485.     if (pszStr)
  1486.     {
  1487.         if (!strcmp(pszStr, "topLeft"))
  1488.         {
  1489.             reValue = RegAlignTopLeft;
  1490.         }
  1491.         else if (!strcmp(pszStr, "topMid"))
  1492.         {
  1493.             reValue = RegAlignTopMid;
  1494.         }
  1495.         else if (!strcmp(pszStr, "topRight"))
  1496.         {
  1497.             reValue = RegAlignTopRight;
  1498.         }
  1499.         else if (!strcmp(pszStr, "midLeft"))
  1500.         {
  1501.             reValue = RegAlignMidLeft;
  1502.         }
  1503.         else if (!strcmp(pszStr, "center"))
  1504.         {
  1505.             reValue = RegAlignCenter;
  1506.         }
  1507.         else if (!strcmp(pszStr, "midRight"))
  1508.         {
  1509.             reValue = RegAlignMidRight;
  1510.         }
  1511.         else if (!strcmp(pszStr, "bottomLeft"))
  1512.         {
  1513.             reValue = RegAlignBottomLeft;
  1514.         }
  1515.         else if (!strcmp(pszStr, "bottomMid"))
  1516.         {
  1517.             reValue = RegAlignBottomMid;
  1518.         }
  1519.         else if (!strcmp(pszStr, "bottomRight"))
  1520.         {
  1521.             reValue = RegAlignBottomRight;
  1522.         }
  1523.         else
  1524.         {
  1525.             retVal = HXR_FAIL;
  1526.         }
  1527.     }
  1528.     else
  1529.     {
  1530.         retVal = HXR_FAIL;
  1531.     }
  1532.     return retVal;
  1533. }
  1534. HX_RESULT CSmilParser::parseOpacity(const char* pszStr, REF(UINT32) rulOpacity)
  1535. {
  1536.     HX_RESULT retVal = HXR_OK;
  1537.     if (pszStr)
  1538.     {
  1539.         // opacity      := <raw> | <percentage>
  1540.         // <raw>        := WS* [0-9]+ WS*
  1541.         // <percentage> := WS* [0-9] '.' [0-9] '%' WS*
  1542.         // WS           := ' ' | 'n' | 'r' | 't'
  1543.         //
  1544.         // Check to make sure the string is valid
  1545.         //
  1546.         // Here is the definition of the state machine
  1547.         // 0 is the starting state
  1548.         // If you end in state 7, you are a <length>
  1549.         // If you end in state 6, you are a <percentage>
  1550.         // If you end in state -1, this is an error
  1551.         //
  1552.         // State -1: // error state
  1553.         //     else goto state -1
  1554.         // State 0: // starting state
  1555.         //     WS   goto state 0
  1556.         //     0-9  goto state 1
  1557.         //     .    goto state 2
  1558.         //     else goto state -1
  1559.         // State 1: // have already seen at least one 0-9
  1560.         //     0-9  goto state 1
  1561.         //     .    goto state 3
  1562.         //     %    goto state 4
  1563.         //     NULL goto state 5
  1564.         //     WS   goto state 5
  1565.         //     else goto state -1
  1566.         // State 2: // saw a . without seeing a 0-9
  1567.         //     0-9  goto state 3
  1568.         //     else goto state -1
  1569.         // State 3: // saw a . after seeing a 0-9
  1570.         //     0-9  goto state 3
  1571.         //     %    goto state 4
  1572.         //     NULL goto state 5
  1573.         //     WS   goto state 5
  1574.         //     else goto state -1
  1575.         // State 4: // <percentage> ending state
  1576.         //     WS   goto state 4
  1577.         //     NULL goto state 4
  1578.         //     else goto state -1
  1579.         // State 5: // <raw> ending state
  1580.         //     WS   goto state 5
  1581.         //     NULL goto state 5
  1582.         //     else goto state -1
  1583.         //
  1584.         const char* pszTmp   = pszStr;
  1585.         const char* pszLimit = pszTmp + strlen(pszTmp);
  1586.         INT32       lState   = 0;
  1587.         while (pszTmp <= pszLimit)
  1588.         {
  1589.             char c = *pszTmp++;
  1590.             switch (lState)
  1591.             {
  1592.                 case -1:
  1593.                     break;
  1594.                 case 0:
  1595.                     {
  1596.                         if (c == ' ' || c == 'r' || c == 'n' || c == 't')
  1597.                         {
  1598.                             lState = 0;
  1599.                         }
  1600.                         else if (c >= '0' && c <= '9')
  1601.                         {
  1602.                             lState = 1;
  1603.                         }
  1604.                         else if (c == '.')
  1605.                         {
  1606.                             lState = 2;
  1607.                         }
  1608.                         else
  1609.                         {
  1610.                             lState = -1;
  1611.                         }
  1612.                     }
  1613.                     break;
  1614.                 case 1:
  1615.                     {
  1616.                         if (c >= '0' && c <= '9')
  1617.                         {
  1618.                             lState = 1;
  1619.                         }
  1620.                         else if (c == '.')
  1621.                         {
  1622.                             lState = 3;
  1623.                         }
  1624.                         else if (c == '%')
  1625.                         {
  1626.                             lState = 4;
  1627.                         }
  1628.                         else if (c == '' || c == ' ' || c == 'r' || c == 'n' || c == 't')
  1629.                         {
  1630.                             lState = 5;
  1631.                         }
  1632.                         else
  1633.                         {
  1634.                             lState = -1;
  1635.                         }
  1636.                     }
  1637.                     break;
  1638.                 case 2:
  1639.                     {
  1640.                         if (c >= '0' && c <= '9')
  1641.                         {
  1642.                             lState = 3;
  1643.                         }
  1644.                         else
  1645.                         {
  1646.                             lState = -1;
  1647.                         }
  1648.                     }
  1649.                     break;
  1650.                 case 3:
  1651.                     {
  1652.                         if (c >= '0' && c <= '9')
  1653.                         {
  1654.                             lState = 3;
  1655.                         }
  1656.                         else if (c == '%')
  1657.                         {
  1658.                             lState = 4;
  1659.                         }
  1660.                         else if (c == '' || c == ' ' || c == 'r' || c == 'n' || c == 't')
  1661.                         {
  1662.                             lState = 5;
  1663.                         }
  1664.                         else
  1665.                         {
  1666.                             lState = -1;
  1667.                         }
  1668.                     }
  1669.                     break;
  1670.                 case 4:
  1671.                     {
  1672.                         if (c == '' || c == ' ' || c == 'r' || c == 'n' || c == 't')
  1673.                         {
  1674.                             lState = 4;
  1675.                         }
  1676.                         else
  1677.                         {
  1678.                             lState = -1;
  1679.                         }
  1680.                     }
  1681.                     break;
  1682.                 case 5:
  1683.                     {
  1684.                         if (c == '' || c == ' ' || c == 'r' || c == 'n' || c == 't')
  1685.                         {
  1686.                             lState = 5;
  1687.                         }
  1688.                         else
  1689.                         {
  1690.                             lState = -1;
  1691.                         }
  1692.                     }
  1693.                     break;
  1694.             }
  1695.         }
  1696.         // Are we in a valid state
  1697.         if (lState == 4 || lState == 5)
  1698.         {
  1699.             // Parse the value
  1700.             double dVal = strtod(pszStr, NULL);
  1701.             if (lState == 4)
  1702.             {
  1703.                 // We are a <percentage>
  1704.                 //
  1705.                 // First check the range
  1706.                 if (dVal >= 0.0 && dVal <= 100.0)
  1707.                 {
  1708.                     // Convert to a byte value
  1709.                     rulOpacity = (UINT32) (dVal * 255.0 / 100.0 + 0.5);
  1710.                 }
  1711.                 else
  1712.                 {
  1713.                     retVal = HXR_FAIL;
  1714.                 }
  1715.             }
  1716.             else
  1717.             {
  1718.                 // We are a <raw>
  1719.                 //
  1720.                 // First check the range
  1721.                 if (dVal >= 0.0 && dVal <= 255.0)
  1722.                 {
  1723.                     // Convert to a byte value
  1724.                     rulOpacity = (UINT32) (dVal + 0.5);
  1725.                 }
  1726.                 else
  1727.                 {
  1728.                     retVal = HXR_FAIL;
  1729.                 }
  1730.             }
  1731.         }
  1732.         else
  1733.         {
  1734.             // Error
  1735.             retVal = HXR_FAIL;
  1736.         }
  1737.     }
  1738.     else
  1739.     {
  1740.         retVal = HXR_FAIL;
  1741.     }
  1742.     return retVal;
  1743. }
  1744. HX_RESULT CSmilParser::parseFill(const char*   pszStr,
  1745.                                  REF(FillType) reFill)
  1746. {
  1747.     HX_RESULT retVal = HXR_OK;
  1748.     if (pszStr)
  1749.     {
  1750.         if (!strcmp(pszStr, "remove"))
  1751.         {
  1752.             reFill = FillRemove;
  1753.         }
  1754.         else if (!strcmp(pszStr, "freeze"))
  1755.         {
  1756.             reFill = FillFreeze;
  1757.         }
  1758.         else if (!strcmp(pszStr, "hold"))
  1759.         {
  1760.             reFill = FillHold;
  1761.         }
  1762.         else if (!strcmp(pszStr, "transition"))
  1763.         {
  1764.             reFill = FillTransition;
  1765.         }
  1766.         else if (!strcmp(pszStr, "auto"))
  1767.         {
  1768.             reFill = FillAuto;
  1769.         }
  1770.         else if (!strcmp(pszStr, "default"))
  1771.         {
  1772.             reFill = FillDefault;
  1773.         }
  1774.         else
  1775.         {
  1776.             retVal = HXR_FAIL;
  1777.         }
  1778.     }
  1779.     else
  1780.     {
  1781.         retVal = HXR_FAIL;
  1782.     }
  1783.     return retVal;
  1784. }
  1785. HX_RESULT CSmilParser::getFillString(FillType eFill, REF(CHXString) rcFill)
  1786. {
  1787.     HX_RESULT retVal = HXR_OK;
  1788.     switch (eFill)
  1789.     {
  1790.         case FillRemove:     rcFill = "remove";     break;
  1791.         case FillFreeze:     rcFill = "freeze";     break;
  1792.         case FillHold:       rcFill = "hold";       break;
  1793.         case FillTransition: rcFill = "transition"; break;
  1794.         case FillAuto:       rcFill = "auto";       break;
  1795.         case FillDefault:    rcFill = "default";    break;
  1796.     }
  1797.     return retVal;
  1798. }
  1799. HX_RESULT CSmilParser::getEraseString(EraseType eErase, REF(CHXString) rcErase)
  1800. {
  1801.     HX_RESULT retVal = HXR_OK;
  1802.     switch (eErase)
  1803.     {
  1804.         case EraseWhenDone: rcErase = "whenDone"; break;
  1805.         case EraseNever:    rcErase = "never";    break;
  1806.     }
  1807.     return retVal;
  1808. }
  1809. HX_RESULT CSmilParser::parseFillDefault(const char*          pszStr,
  1810.                                         REF(FillDefaultType) reFillDefault)
  1811. {
  1812.     HX_RESULT retVal = HXR_OK;
  1813.     if (pszStr)
  1814.     {
  1815.         if (!strcmp(pszStr, "remove"))
  1816.         {
  1817.             reFillDefault = FillDefaultRemove;
  1818.         }
  1819.         else if (!strcmp(pszStr, "freeze"))
  1820.         {
  1821.             reFillDefault = FillDefaultFreeze;
  1822.         }
  1823.         else if (!strcmp(pszStr, "hold"))
  1824.         {
  1825.             reFillDefault = FillDefaultHold;
  1826.         }
  1827.         else if (!strcmp(pszStr, "transition"))
  1828.         {
  1829.             reFillDefault = FillDefaultTransition;
  1830.         }
  1831.         else if (!strcmp(pszStr, "auto"))
  1832.         {
  1833.             reFillDefault = FillDefaultAuto;
  1834.         }
  1835.         else if (!strcmp(pszStr, "inherit"))
  1836.         {
  1837.             reFillDefault = FillDefaultInherit;
  1838.         }
  1839.         else
  1840.         {
  1841.             retVal = HXR_FAIL;
  1842.         }
  1843.     }
  1844.     else
  1845.     {
  1846.         retVal = HXR_FAIL;
  1847.     }
  1848.     return retVal;
  1849. }
  1850. HX_RESULT CSmilParser::parseAccelDecel(const char* pszStr, REF(double) rdVal)
  1851. {
  1852.     HX_RESULT retVal = HXR_OK;
  1853.     if (pszStr)
  1854.     {
  1855.         double dVal = 0.0;
  1856.         retVal      = HXParseDouble(pszStr, dVal);
  1857.         if (SUCCEEDED(retVal))
  1858.         {
  1859.             if (dVal >= 0.0 && dVal <= 1.0)
  1860.             {
  1861.                 rdVal = dVal;
  1862.             }
  1863.             else
  1864.             {
  1865.                 retVal = HXR_FAIL;
  1866.             }
  1867.         }
  1868.     }
  1869.     else
  1870.     {
  1871.         retVal = HXR_FAIL;
  1872.     }
  1873.     return retVal;
  1874. }
  1875. #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
  1876. HX_RESULT CSmilParser::getDefaultTransitionSubType(const char*    pszType,
  1877.                                                    REF(CHXString) rcSubType)
  1878. {
  1879.     HX_RESULT retVal = HXR_OK;
  1880.     if (pszType)
  1881.     {
  1882.         if (!strcmp(pszType, "barWipe"))
  1883.         {
  1884.             rcSubType = "leftToRight";
  1885.         }
  1886.         else if (!strcmp(pszType, "boxWipe"))
  1887.         {
  1888.             rcSubType = "topLeft";
  1889.         }
  1890.         else if (!strcmp(pszType, "fourBoxWipe"))
  1891.         {
  1892.             rcSubType = "cornersIn";
  1893.         }
  1894.         else if (!strcmp(pszType, "barnDoorWipe"))
  1895.         {
  1896.             rcSubType = "vertical";
  1897.         }
  1898.         else if (!strcmp(pszType, "diagonalWipe"))
  1899.         {
  1900.             rcSubType = "topLeft";
  1901.         }
  1902.         else if (!strcmp(pszType, "bowTieWipe"))
  1903.         {
  1904.             rcSubType = "vertical";
  1905.         }
  1906.         else if (!strcmp(pszType, "miscDiagonalWipe"))
  1907.         {
  1908.             rcSubType = "doubleBarnDoor";
  1909.         }
  1910.         else if (!strcmp(pszType, "veeWipe"))
  1911.         {
  1912.             rcSubType = "down";
  1913.         }
  1914.         else if (!strcmp(pszType, "barnVeeWipe"))
  1915.         {
  1916.             rcSubType = "down";
  1917.         }
  1918.         else if (!strcmp(pszType, "zigZagWipe"))
  1919.         {
  1920.             rcSubType = "leftToRight";
  1921.         }
  1922.         else if (!strcmp(pszType, "barnZigZagWipe"))
  1923.         {
  1924.             rcSubType = "vertical";
  1925.         }
  1926.         else if (!strcmp(pszType, "irisWipe"))
  1927.         {
  1928.             rcSubType = "rectangle";
  1929.         }
  1930.         else if (!strcmp(pszType, "triangleWipe"))
  1931.         {
  1932.             rcSubType = "up";
  1933.         }
  1934.         else if (!strcmp(pszType, "arrowHeadWipe"))
  1935.         {
  1936.             rcSubType = "up";
  1937.         }
  1938.         else if (!strcmp(pszType, "pentagonWipe"))
  1939.         {
  1940.             rcSubType = "up";
  1941.         }
  1942.         else if (!strcmp(pszType, "hexagonWipe"))
  1943.         {
  1944.             rcSubType = "horizontal";
  1945.         }
  1946.         else if (!strcmp(pszType, "ellipseWipe"))
  1947.         {
  1948.             rcSubType = "circle";
  1949.         }
  1950.         else if (!strcmp(pszType, "eyeWipe"))
  1951.         {
  1952.             rcSubType = "horizontal";
  1953.         }
  1954.         else if (!strcmp(pszType, "roundRectWipe"))
  1955.         {
  1956.             rcSubType = "horizontal";
  1957.         }
  1958.         else if (!strcmp(pszType, "starWipe"))
  1959.         {
  1960.             rcSubType = "fourPoint";
  1961.         }
  1962.         else if (!strcmp(pszType, "miscShapeWipe"))
  1963.         {
  1964.             rcSubType = "heart";
  1965.         }
  1966.         else if (!strcmp(pszType, "clockWipe"))
  1967.         {
  1968.             rcSubType = "clockwiseTwelve";
  1969.         }
  1970.         else if (!strcmp(pszType, "pinWheelWipe"))
  1971.         {
  1972.             rcSubType = "twoBladeVertical";
  1973.         }
  1974.         else if (!strcmp(pszType, "singleSweepWipe"))
  1975.         {
  1976.             rcSubType = "clockwiseTop";
  1977.         }
  1978.         else if (!strcmp(pszType, "fanWipe"))
  1979.         {
  1980.             rcSubType = "centerTop";
  1981.         }
  1982.         else if (!strcmp(pszType, "doubleFanWipe"))
  1983.         {
  1984.             rcSubType = "fanOutVertical";
  1985.         }
  1986.         else if (!strcmp(pszType, "doubleSweepWipe"))
  1987.         {
  1988.             rcSubType = "parallelVertical";
  1989.         }
  1990.         else if (!strcmp(pszType, "saloonDoorWipe"))
  1991.         {
  1992.             rcSubType = "top";
  1993.         }
  1994.         else if (!strcmp(pszType, "windshieldWipe"))
  1995.         {
  1996.             rcSubType = "right";
  1997.         }
  1998.         else if (!strcmp(pszType, "snakeWipe"))
  1999.         {
  2000.             rcSubType = "topLeftHorizontal";
  2001.         }
  2002.         else if (!strcmp(pszType, "spiralWipe"))
  2003.         {
  2004.             rcSubType = "topLeftClockwise";
  2005.         }
  2006.         else if (!strcmp(pszType, "parallelSnakesWipe"))
  2007.         {
  2008.             rcSubType = "verticalTopSame";
  2009.         }
  2010.         else if (!strcmp(pszType, "boxSnakesWipe"))
  2011.         {
  2012.             rcSubType = "twoBoxTop";
  2013.         }
  2014.         else if (!strcmp(pszType, "waterfallWipe"))
  2015.         {
  2016.             rcSubType = "verticalLeft";
  2017.         }
  2018.         else if (!strcmp(pszType, "pushWipe"))
  2019.         {
  2020.             rcSubType = "fromLeft";
  2021.         }
  2022.         else if (!strcmp(pszType, "slideWipe"))
  2023.         {
  2024.             rcSubType = "fromLeft";
  2025.         }
  2026.         else if (!strcmp(pszType, "fade"))
  2027.         {
  2028.             rcSubType = "crossfade";
  2029.         }
  2030.         else
  2031.         {
  2032.             retVal = HXR_FAIL;
  2033.         }
  2034.     }
  2035.     else
  2036.     {
  2037.         retVal = HXR_FAIL;
  2038.     }
  2039.     return retVal;
  2040. }
  2041. BOOL CSmilParser::isLegalTransitionType(const char* pszType)
  2042. {
  2043.     BOOL bRet = FALSE;
  2044.     if (pszType)
  2045.     {
  2046.         if (!strcmp(pszType, "barWipe")            ||
  2047.             !strcmp(pszType, "boxWipe")            ||
  2048.             !strcmp(pszType, "fourBoxWipe")        ||
  2049.             !strcmp(pszType, "barnDoorWipe")       ||
  2050.             !strcmp(pszType, "diagonalWipe")       ||
  2051.             !strcmp(pszType, "bowTieWipe")         ||
  2052.             !strcmp(pszType, "miscDiagonalWipe")   ||
  2053.             !strcmp(pszType, "veeWipe")            ||
  2054.             !strcmp(pszType, "barnVeeWipe")        ||
  2055.             !strcmp(pszType, "zigZagWipe")         ||
  2056.             !strcmp(pszType, "barnZigZagWipe")     ||
  2057.             !strcmp(pszType, "irisWipe")           ||
  2058.             !strcmp(pszType, "triangleWipe")       ||
  2059.             !strcmp(pszType, "arrowHeadWipe")      ||
  2060.             !strcmp(pszType, "pentagonWipe")       ||
  2061.             !strcmp(pszType, "hexagonWipe")        ||
  2062.             !strcmp(pszType, "ellipseWipe")        ||
  2063.             !strcmp(pszType, "eyeWipe")            ||
  2064.             !strcmp(pszType, "roundRectWipe")      ||
  2065.             !strcmp(pszType, "starWipe")           ||
  2066.             !strcmp(pszType, "miscShapeWipe")      ||
  2067.             !strcmp(pszType, "clockWipe")          ||
  2068.             !strcmp(pszType, "pinWheelWipe")       ||
  2069.             !strcmp(pszType, "singleSweepWipe")    ||
  2070.             !strcmp(pszType, "fanWipe")            ||
  2071.             !strcmp(pszType, "doubleFanWipe")      ||
  2072.             !strcmp(pszType, "doubleSweepWipe")    ||
  2073.             !strcmp(pszType, "saloonDoorWipe")     ||
  2074.             !strcmp(pszType, "windshieldWipe")     ||
  2075.             !strcmp(pszType, "snakeWipe")          ||
  2076.             !strcmp(pszType, "spiralWipe")         ||
  2077.             !strcmp(pszType, "parallelSnakesWipe") ||
  2078.             !strcmp(pszType, "boxSnakesWipe")      ||
  2079.             !strcmp(pszType, "waterfallWipe")      ||
  2080.             !strcmp(pszType, "pushWipe")           ||
  2081.             !strcmp(pszType, "slideWipe")          ||
  2082.             !strcmp(pszType, "fade"))
  2083.         {
  2084.             bRet = TRUE;
  2085.         }
  2086.     }
  2087.     return bRet;
  2088. }
  2089. BOOL CSmilParser::isLegalTransitionSubType(const char* pszType, const char* pszSubType)
  2090. {
  2091.     BOOL bRet = FALSE;
  2092.     if (pszType && pszSubType)
  2093.     {
  2094.         if (!strcmp(pszType, "barWipe"))
  2095.         {
  2096.             if (!strcmp(pszSubType, "leftToRight") ||
  2097.                 !strcmp(pszSubType, "topToBottom"))
  2098.             {
  2099.                 bRet = TRUE;
  2100.             }
  2101.         }
  2102.         else if (!strcmp(pszType, "boxWipe"))
  2103.         {
  2104.             if (!strcmp(pszSubType, "topLeft")      ||
  2105.                 !strcmp(pszSubType, "topRight")     ||
  2106.                 !strcmp(pszSubType, "bottomRight")  ||
  2107.                 !strcmp(pszSubType, "bottomLeft")   ||
  2108.                 !strcmp(pszSubType, "topCenter")    ||
  2109.                 !strcmp(pszSubType, "rightCenter")  ||
  2110.                 !strcmp(pszSubType, "bottomCenter") ||
  2111.                 !strcmp(pszSubType, "leftCenter"))
  2112.             {
  2113.                 bRet = TRUE;
  2114.             }
  2115.         }
  2116.         else if (!strcmp(pszType, "fourBoxWipe"))
  2117.         {
  2118.             if (!strcmp(pszSubType, "cornersIn") ||
  2119.                 !strcmp(pszSubType, "cornersOut"))
  2120.             {
  2121.                 bRet = TRUE;
  2122.             }
  2123.         }
  2124.         else if (!strcmp(pszType, "barnDoorWipe"))
  2125.         {
  2126.             if (!strcmp(pszSubType, "vertical")           ||
  2127.                 !strcmp(pszSubType, "horizontal")         ||
  2128.                 !strcmp(pszSubType, "diagonalBottomLeft") ||
  2129.                 !strcmp(pszSubType, "diagonalTopLeft"))
  2130.             {
  2131.                 bRet = TRUE;
  2132.             }
  2133.         }
  2134.         else if (!strcmp(pszType, "diagonalWipe"))
  2135.         {
  2136.             if (!strcmp(pszSubType, "topLeft") ||
  2137.                 !strcmp(pszSubType, "topRight"))
  2138.             {
  2139.                 bRet = TRUE;
  2140.             }
  2141.         }
  2142.         else if (!strcmp(pszType, "bowTieWipe"))
  2143.         {
  2144.             if (!strcmp(pszSubType, "vertical") ||
  2145.                 !strcmp(pszSubType, "horizontal"))
  2146.             {
  2147.                 bRet = TRUE;
  2148.             }
  2149.         }
  2150.         else if (!strcmp(pszType, "miscDiagonalWipe"))
  2151.         {
  2152.             if (!strcmp(pszSubType, "doubleBarnDoor") ||
  2153.                 !strcmp(pszSubType, "doubleDiamond"))
  2154.             {
  2155.                 bRet = TRUE;
  2156.             }
  2157.         }
  2158.         else if (!strcmp(pszType, "veeWipe"))
  2159.         {
  2160.             if (!strcmp(pszSubType, "down") ||
  2161.                 !strcmp(pszSubType, "left") ||
  2162.                 !strcmp(pszSubType, "up")   ||
  2163.                 !strcmp(pszSubType, "right"))
  2164.             {
  2165.                 bRet = TRUE;
  2166.             }
  2167.         }
  2168.         else if (!strcmp(pszType, "barnVeeWipe"))
  2169.         {
  2170.             if (!strcmp(pszSubType, "down") ||
  2171.                 !strcmp(pszSubType, "left") ||
  2172.                 !strcmp(pszSubType, "up")   ||
  2173.                 !strcmp(pszSubType, "right"))
  2174.             {
  2175.                 bRet = TRUE;
  2176.             }
  2177.         }
  2178.         else if (!strcmp(pszType, "zigZagWipe"))
  2179.         {
  2180.             if (!strcmp(pszSubType, "leftToRight") ||
  2181.                 !strcmp(pszSubType, "topToBottom"))
  2182.             {
  2183.                 bRet = TRUE;
  2184.             }
  2185.         }
  2186.         else if (!strcmp(pszType, "barnZigZagWipe"))
  2187.         {
  2188.             if (!strcmp(pszSubType, "vertical") ||
  2189.                 !strcmp(pszSubType, "horizontal"))
  2190.             {
  2191.                 bRet = TRUE;
  2192.             }
  2193.         }
  2194.         else if (!strcmp(pszType, "irisWipe"))
  2195.         {
  2196.             if (!strcmp(pszSubType, "rectangle") ||
  2197.                 !strcmp(pszSubType, "diamond"))
  2198.             {
  2199.                 bRet = TRUE;
  2200.             }
  2201.         }
  2202.         else if (!strcmp(pszType, "triangleWipe"))
  2203.         {
  2204.             if (!strcmp(pszSubType, "up")    ||
  2205.                 !strcmp(pszSubType, "right") ||
  2206.                 !strcmp(pszSubType, "down")  ||
  2207.                 !strcmp(pszSubType, "left"))
  2208.             {
  2209.                 bRet = TRUE;
  2210.             }
  2211.         }
  2212.         else if (!strcmp(pszType, "arrowHeadWipe"))
  2213.         {
  2214.             if (!strcmp(pszSubType, "up")    ||
  2215.                 !strcmp(pszSubType, "right") ||
  2216.                 !strcmp(pszSubType, "down")  ||
  2217.                 !strcmp(pszSubType, "left"))
  2218.             {
  2219.                 bRet = TRUE;
  2220.             }
  2221.         }
  2222.         else if (!strcmp(pszType, "pentagonWipe"))
  2223.         {
  2224.             if (!strcmp(pszSubType, "up")    ||
  2225.                 !strcmp(pszSubType, "down"))
  2226.             {
  2227.                 bRet = TRUE;
  2228.             }
  2229.         }
  2230.         else if (!strcmp(pszType, "hexagonWipe"))
  2231.         {
  2232.             if (!strcmp(pszSubType, "horizontal") ||
  2233.                 !strcmp(pszSubType, "vertical"))
  2234.             {
  2235.                 bRet = TRUE;
  2236.             }
  2237.         }
  2238.         else if (!strcmp(pszType, "ellipseWipe"))
  2239.         {
  2240.             if (!strcmp(pszSubType, "circle")     ||
  2241.                 !strcmp(pszSubType, "horizontal") ||
  2242.                 !strcmp(pszSubType, "vertical"))
  2243.             {
  2244.                 bRet = TRUE;
  2245.             }
  2246.         }
  2247.         else if (!strcmp(pszType, "eyeWipe"))
  2248.         {
  2249.             if (!strcmp(pszSubType, "horizontal") ||
  2250.                 !strcmp(pszSubType, "vertical"))
  2251.             {
  2252.                 bRet = TRUE;
  2253.             }
  2254.         }
  2255.         else if (!strcmp(pszType, "roundRectWipe"))
  2256.         {
  2257.             if (!strcmp(pszSubType, "horizontal") ||
  2258.                 !strcmp(pszSubType, "vertical"))
  2259.             {
  2260.                 bRet = TRUE;
  2261.             }
  2262.         }
  2263.         else if (!strcmp(pszType, "starWipe"))
  2264.         {
  2265.             if (!strcmp(pszSubType, "fourPoint") ||
  2266.                 !strcmp(pszSubType, "fivePoint") ||
  2267.                 !strcmp(pszSubType, "sixPoint"))
  2268.             {
  2269.                 bRet = TRUE;
  2270.             }
  2271.         }
  2272.         else if (!strcmp(pszType, "miscShapeWipe"))
  2273.         {
  2274.             if (!strcmp(pszSubType, "heart") ||
  2275.                 !strcmp(pszSubType, "keyhole"))
  2276.             {
  2277.                 bRet = TRUE;
  2278.             }
  2279.         }
  2280.         else if (!strcmp(pszType, "clockWipe"))
  2281.         {
  2282.             if (!strcmp(pszSubType, "clockwiseTwelve") ||
  2283.                 !strcmp(pszSubType, "clockwiseThree")  ||
  2284.                 !strcmp(pszSubType, "clockwiseSix")    ||
  2285.                 !strcmp(pszSubType, "clockwiseNine"))
  2286.             {
  2287.                 bRet = TRUE;
  2288.             }
  2289.         }
  2290.         else if (!strcmp(pszType, "pinWheelWipe"))
  2291.         {
  2292.             if (!strcmp(pszSubType, "twoBladeVertical")   ||
  2293.                 !strcmp(pszSubType, "twoBladeHorizontal") ||
  2294.                 !strcmp(pszSubType, "fourBlade"))
  2295.             {
  2296.                 bRet = TRUE;
  2297.             }
  2298.         }
  2299.         else if (!strcmp(pszType, "singleSweepWipe"))
  2300.         {
  2301.             if (!strcmp(pszSubType, "clockwiseTop")               ||
  2302.                 !strcmp(pszSubType, "clockwiseRight")             ||
  2303.                 !strcmp(pszSubType, "clockwiseBottom")            ||
  2304.                 !strcmp(pszSubType, "clockwiseLeft")              ||
  2305.                 !strcmp(pszSubType, "clockwiseTopLeft")           ||
  2306.                 !strcmp(pszSubType, "counterClockwiseBottomLeft") ||
  2307.                 !strcmp(pszSubType, "clockwiseBottomRight")       ||
  2308.                 !strcmp(pszSubType, "counterClockwiseTopRight"))
  2309.             {
  2310.                 bRet = TRUE;
  2311.             }
  2312.         }
  2313.         else if (!strcmp(pszType, "fanWipe"))
  2314.         {
  2315.             if (!strcmp(pszSubType, "centerTop")   ||
  2316.                 !strcmp(pszSubType, "centerRight") ||
  2317.                 !strcmp(pszSubType, "top")         ||
  2318.                 !strcmp(pszSubType, "right")       ||
  2319.                 !strcmp(pszSubType, "bottom")      ||
  2320.                 !strcmp(pszSubType, "left"))
  2321.             {
  2322.                 bRet = TRUE;
  2323.             }
  2324.         }
  2325.         else if (!strcmp(pszType, "doubleFanWipe"))
  2326.         {
  2327.             if (!strcmp(pszSubType, "fanOutVertical")   ||
  2328.                 !strcmp(pszSubType, "fanOutHorizontal") ||
  2329.                 !strcmp(pszSubType, "fanInVertical")    ||
  2330.                 !strcmp(pszSubType, "fanInHorizontal"))
  2331.             {
  2332.                 bRet = TRUE;
  2333.             }
  2334.         }
  2335.         else if (!strcmp(pszType, "doubleSweepWipe"))
  2336.         {
  2337.             if (!strcmp(pszSubType, "parallelVertical")        ||
  2338.                 !strcmp(pszSubType, "parallelDiagonal")        ||
  2339.                 !strcmp(pszSubType, "oppositeVertical")        ||
  2340.                 !strcmp(pszSubType, "oppositeHorizontal")      ||
  2341.                 !strcmp(pszSubType, "parallelDiagonalTopLeft") ||
  2342.                 !strcmp(pszSubType, "parallelDiagonalBottomLeft"))
  2343.             {
  2344.                 bRet = TRUE;
  2345.             }
  2346.         }
  2347.         else if (!strcmp(pszType, "saloonDoorWipe"))
  2348.         {
  2349.             if (!strcmp(pszSubType, "top")    ||
  2350.                 !strcmp(pszSubType, "left")   ||
  2351.                 !strcmp(pszSubType, "bottom") ||
  2352.                 !strcmp(pszSubType, "right"))
  2353.             {
  2354.                 bRet = TRUE;
  2355.             }
  2356.         }
  2357.         else if (!strcmp(pszType, "windshieldWipe"))
  2358.         {
  2359.             if (!strcmp(pszSubType, "right")    ||
  2360.                 !strcmp(pszSubType, "up")       ||
  2361.                 !strcmp(pszSubType, "vertical") ||
  2362.                 !strcmp(pszSubType, "horizontal"))
  2363.             {
  2364.                 bRet = TRUE;
  2365.             }
  2366.         }
  2367.         else if (!strcmp(pszType, "snakeWipe"))
  2368.         {
  2369.             if (!strcmp(pszSubType, "topLeftHorizontal")   ||
  2370.                 !strcmp(pszSubType, "topLeftVertical")     ||
  2371.                 !strcmp(pszSubType, "topLeftDiagonal")     ||
  2372.                 !strcmp(pszSubType, "topRightDiagonal")    ||
  2373.                 !strcmp(pszSubType, "bottomRightDiagonal") ||
  2374.                 !strcmp(pszSubType, "bottomLeftDiagonal"))
  2375.             {
  2376.                 bRet = TRUE;
  2377.             }
  2378.         }
  2379.         else if (!strcmp(pszType, "spiralWipe"))
  2380.         {
  2381.             if (!strcmp(pszSubType, "topLeftClockwise")            ||
  2382.                 !strcmp(pszSubType, "topRightClockwise")           ||
  2383.                 !strcmp(pszSubType, "bottomRightClockwise")        ||
  2384.                 !strcmp(pszSubType, "bottomLeftClockwise")         ||
  2385.                 !strcmp(pszSubType, "topLeftCounterClockwise")     ||
  2386.                 !strcmp(pszSubType, "topRightCounterClockwise")    ||
  2387.                 !strcmp(pszSubType, "bottomRightCounterClockwise") ||
  2388.                 !strcmp(pszSubType, "bottomLeftCounterClockwise"))
  2389.             {
  2390.                 bRet = TRUE;
  2391.             }
  2392.         }
  2393.         else if (!strcmp(pszType, "parallelSnakesWipe"))
  2394.         {
  2395.             if (!strcmp(pszSubType, "verticalTopSame")            ||
  2396.                 !strcmp(pszSubType, "verticalBottomSame")         ||
  2397.                 !strcmp(pszSubType, "verticalTopLeftOpposite")    ||
  2398.                 !strcmp(pszSubType, "verticalBottomLeftOpposite") ||
  2399.                 !strcmp(pszSubType, "horizontalLeftSame")         ||
  2400.                 !strcmp(pszSubType, "horizontalRightSame")        ||
  2401.                 !strcmp(pszSubType, "horizontalTopLeftOpposite")  ||
  2402.                 !strcmp(pszSubType, "horizontalTopRightOpposite") ||
  2403.                 !strcmp(pszSubType, "diagonalBottomLeftOpposite") ||
  2404.                 !strcmp(pszSubType, "diagonalTopLeftOpposite"))
  2405.             {
  2406.                 bRet = TRUE;
  2407.             }
  2408.         }
  2409.         else if (!strcmp(pszType, "boxSnakesWipe"))
  2410.         {
  2411.             if (!strcmp(pszSubType, "twoBoxTop")       ||
  2412.                 !strcmp(pszSubType, "twoBoxBottom")    ||
  2413.                 !strcmp(pszSubType, "twoBoxLeft")      ||
  2414.                 !strcmp(pszSubType, "twoBoxRight")     ||
  2415.                 !strcmp(pszSubType, "fourBoxVertical") ||
  2416.                 !strcmp(pszSubType, "fourBoxHorizontal"))
  2417.             {
  2418.                 bRet = TRUE;
  2419.             }
  2420.         }
  2421.         else if (!strcmp(pszType, "waterfallWipe"))
  2422.         {
  2423.             if (!strcmp(pszSubType, "verticalLeft")   ||
  2424.                 !strcmp(pszSubType, "verticalRight")  ||
  2425.                 !strcmp(pszSubType, "horizontalLeft") ||
  2426.                 !strcmp(pszSubType, "horizontalRight"))
  2427.             {
  2428.                 bRet = TRUE;
  2429.             }
  2430.         }
  2431.         else if (!strcmp(pszType, "pushWipe"))
  2432.         {
  2433.             if (!strcmp(pszSubType, "fromLeft")  ||
  2434.                 !strcmp(pszSubType, "fromTop")   ||
  2435.                 !strcmp(pszSubType, "fromRight") ||
  2436.                 !strcmp(pszSubType, "fromBottom"))
  2437.             {
  2438.                 bRet = TRUE;
  2439.             }
  2440.         }
  2441.         else if (!strcmp(pszType, "slideWipe"))
  2442.         {
  2443.             if (!strcmp(pszSubType, "fromLeft")  ||
  2444.                 !strcmp(pszSubType, "fromTop")   ||
  2445.                 !strcmp(pszSubType, "fromRight") ||
  2446.                 !strcmp(pszSubType, "fromBottom"))
  2447.             {
  2448.                 bRet = TRUE;
  2449.             }
  2450.         }
  2451.         else if (!strcmp(pszType, "fade"))
  2452.         {
  2453.             if (!strcmp(pszSubType, "crossfade")   ||
  2454.                 !strcmp(pszSubType, "fadeToColor") ||
  2455.                 !strcmp(pszSubType, "fadeFromColor"))
  2456.             {
  2457.                 bRet = TRUE;
  2458.             }
  2459.         }
  2460.     }
  2461.     return bRet;
  2462. }
  2463. #endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */
  2464. CSmilAnchorElement* CSmilParser::getAnchorOrAreaElement(const char* pID)
  2465. {
  2466.     CSmilAnchorElement* pRet  = NULL;
  2467.     SMILNode*           pNode = NULL;
  2468.     if(m_pIDMap && pID && m_pIDMap->Lookup(pID, (void*&)pNode))
  2469.     {
  2470.         if(pNode && pNode->m_pElement &&
  2471. (pNode->m_tag == SMILAnchor  ||  pNode->m_tag == SMILArea))
  2472.         {
  2473.             pRet = (CSmilAnchorElement*) pNode->m_pElement;
  2474.         }
  2475.     }
  2476.     return pRet;
  2477. }
  2478. CNamespaceInfo::CNamespaceInfo()
  2479. {
  2480.     m_pszPrefix    = NULL;
  2481.     m_pszURL       = NULL;
  2482.     m_bImplemented = FALSE;
  2483.     m_eNamespace   = NamespaceNotImplemented;
  2484. }
  2485. CNamespaceInfo::~CNamespaceInfo()
  2486. {
  2487.     HX_VECTOR_DELETE(m_pszPrefix);
  2488.     HX_VECTOR_DELETE(m_pszURL);
  2489. }
  2490. /*
  2491.  * CSmilParserResponse methods
  2492.  */
  2493. CSmilParserResponse::CSmilParserResponse(CSmilParser* pParser)
  2494. :   m_pParser(pParser)
  2495. ,   m_lRefCount(0)
  2496. {
  2497. }
  2498. CSmilParserResponse::~CSmilParserResponse()
  2499. {
  2500. }
  2501. STDMETHODIMP
  2502. CSmilParserResponse::QueryInterface(REFIID riid, void** ppvObj)
  2503. {
  2504.     if (IsEqualIID(riid, IID_IUnknown))
  2505.     {
  2506. AddRef();
  2507. *ppvObj = this;
  2508. return HXR_OK;
  2509.     }
  2510.     else if (IsEqualIID(riid, IID_IHXXMLParserResponse))
  2511.     {
  2512. AddRef();
  2513. *ppvObj = (IHXXMLParserResponse*)this;
  2514. return HXR_OK;
  2515.     }
  2516.     *ppvObj = NULL;
  2517.     return HXR_NOINTERFACE;
  2518. }
  2519. STDMETHODIMP_(ULONG32)
  2520. CSmilParserResponse::AddRef()
  2521. {
  2522.     return InterlockedIncrement(&m_lRefCount);
  2523. }
  2524. STDMETHODIMP_(ULONG32)
  2525. CSmilParserResponse::Release()
  2526. {
  2527.     if (InterlockedDecrement(&m_lRefCount) > 0)
  2528.     {
  2529.         return m_lRefCount;
  2530.     }
  2531.     delete this;
  2532.     return 0;
  2533. }
  2534. STDMETHODIMP
  2535. CSmilParserResponse::HandleStartElement(const char* pName,
  2536.  IHXValues* pAttributes,
  2537.  UINT32 ulLineNumber,
  2538.  UINT32 ulColumnNumber)
  2539. {
  2540.     HX_RESULT rc = HXR_OK;
  2541.     if (m_pParser)
  2542.     {
  2543.         rc = m_pParser->getParseError();
  2544.         if (FAILED(rc))
  2545.         {
  2546.             return rc;
  2547.         }
  2548.     }
  2549.     SMILNode* pParentNode =
  2550. (SMILNode*)m_pParser->m_pNodeListStack->TopOfStack();
  2551.     HX_ASSERT(pParentNode);
  2552.     SMILNode* pNode = new SMILNode;
  2553.     pNode->m_name = pName;
  2554.     pNode->m_pParent = pParentNode;
  2555.     pNode->m_pNodeList = new SMILNodeList;
  2556.     pNode->m_pNodeList->m_pParentNode = pNode;
  2557.     pNode->m_ulTagStartLine = ulLineNumber;
  2558.     pNode->m_ulTagStartColumn = ulColumnNumber;
  2559.     if(!pNode->m_pParent->m_bSkipContent)
  2560.     {
  2561. IHXBuffer* pBuffer = NULL;
  2562. if(HXR_OK == pAttributes->GetPropertyCString("id", pBuffer))
  2563. {
  2564.     const char* pID = (const char*)pBuffer->GetBuffer();
  2565.     // /Fixes PR 27658:
  2566.     // A valid XML Name may only begin with a letter (upper or lower)
  2567.     // or a ':' or '_'
  2568.     char firstChar = *pID;
  2569.     if ((':' != firstChar  &&  '_' != firstChar)  &&
  2570.     !isalpha(firstChar) )
  2571.     {
  2572. rc = HXR_XML_ILLEGALID;
  2573. CSmilXMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
  2574. errHandler.ReportError(rc, pID, ulLineNumber);
  2575. goto exit;
  2576.     }
  2577.     else if (m_pParser->m_bStoreErrors && isdigit(*pID))
  2578.     {
  2579. m_pParser->storeError(HXR_XML_ILLEGALID, pID, 0,
  2580.     ulLineNumber, ulColumnNumber);
  2581.     }
  2582.     else
  2583.     {
  2584. // append persistent ID to the end of region id
  2585. // to make it unique in nested meta
  2586. if (!strcmp(pNode->m_name, "region"))
  2587. {
  2588.     //char szPersistentComponentID[MAX_DISPLAY_NAME] = {0};
  2589.     //itoa(m_pParser->m_ulPersistentComponentID, szPersistentComponentID, 10);
  2590.     pNode->m_id = pID;
  2591.     //pNode->m_id += "_";
  2592.     //pNode->m_id += szPersistentComponentID;
  2593.     pNode->m_repeatid = pNode->m_id;
  2594. }
  2595. else
  2596. {
  2597.     pNode->m_id = pID;
  2598.     pNode->m_repeatid = pID;
  2599. }
  2600. HX_RELEASE(pBuffer);
  2601.     }
  2602. }
  2603. else
  2604. {
  2605.     //[SMIL 1.0 Compliance] Fixes PR 24034: region tag must have
  2606.     // an id attribute:
  2607.     if (!strcmp(pNode->m_name, "region"))
  2608.     {
  2609. rc = HXR_XML_ILLEGALID;
  2610. CSmilXMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
  2611. const char* pTmp = "region id=""";
  2612. errHandler.ReportError(rc, pTmp, ulLineNumber);
  2613. goto exit;
  2614.     }
  2615.     // transition attribute must have an id...
  2616.     else if (strcmp(pNode->m_name, "transition") == 0)
  2617.     {
  2618. rc = HXR_XML_ILLEGALID;
  2619. CSmilXMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
  2620. const char* pTmp = "region id=""";
  2621. errHandler.ReportError(rc, pTmp, ulLineNumber);
  2622. goto exit;
  2623.     }
  2624.     else
  2625.     {
  2626. pNode->m_id = m_pParser->assignID(pName);
  2627. pNode->m_repeatid = pNode->m_id;
  2628.     }
  2629.     if (m_pParser->m_bStoreErrors && !strcmp(pNode->m_name, "region"))
  2630.     {
  2631. const char* pTmp = "region id=""";
  2632. m_pParser->storeError(HXR_XML_ILLEGALID, pTmp, 0,
  2633.     ulLineNumber, ulColumnNumber);
  2634.     }
  2635. }
  2636. if(HXR_OK != m_pParser->mapID(pNode))
  2637. {
  2638.     rc = HXR_XML_ILLEGALID;
  2639.     CSmilXMLSyntaxErrorHandler errHandler(m_pParser->m_pContext);
  2640.     errHandler.ReportError(rc, pNode->m_id, ulLineNumber);
  2641.     goto exit;
  2642. }
  2643. BOOL bCheckForDeletion = FALSE;
  2644. BOOL bValidTag = FALSE;
  2645.         SMIL2Element eElem = m_pParser->getSMIL2Element(pName);
  2646.         switch (eElem)
  2647.         {
  2648.             case SMIL2ElemSmil:
  2649.                 {
  2650.                     pNode->m_tag = SMILSmil;
  2651.                 }
  2652.                 break;
  2653.             case SMIL2ElemLayout:
  2654.                 {
  2655.                     pNode->m_tag = SMILBasicLayout;
  2656.                     if(HXR_OK == pAttributes->GetPropertyCString("type", pBuffer))
  2657.                     {
  2658.                         const char* pType = (const char*)pBuffer->GetBuffer();
  2659.                         if(strcmp(pType, "text/smil-basic-layout") != 0)
  2660.                         {
  2661.                             pNode->m_bDelete = TRUE;    // only basic layout supported
  2662.                         }
  2663.                         HX_RELEASE(pBuffer);
  2664.                     }
  2665.                 }
  2666.                 break;
  2667.             case SMIL2ElemMeta:
  2668.                 {
  2669.                     pNode->m_tag = SMILMeta;
  2670.                     pNode->m_bSkipContent = TRUE;
  2671.                 }
  2672.                 break;
  2673.             case SMIL2ElemMetadata:
  2674.                 {
  2675.                     pNode->m_tag = SMILMetadata;
  2676.                 }
  2677.                 break;
  2678.             case SMIL2ElemHead:
  2679.                 {
  2680.                     pNode->m_id = "head";
  2681.                     pNode->m_tag = SMILHead;
  2682.                 }
  2683.                 break;
  2684.             case SMIL2ElemBody:
  2685.                 {
  2686.                     pNode->m_id = "body";
  2687.                     pNode->m_tag = SMILBody;
  2688.                 }
  2689.                 break;
  2690.             case SMIL2ElemRegion:
  2691.                 {
  2692.                     pNode->m_tag = SMILRegion;
  2693.                 }
  2694.                 break;
  2695.             case SMIL2ElemRegPoint:
  2696.                 {
  2697.                     pNode->m_tag = SMILRegPoint;
  2698.                     pNode->m_bSkipContent = TRUE;
  2699.                 }
  2700.                 break;
  2701.             case SMIL2ElemTopLayout:
  2702.                 {
  2703.                     pNode->m_tag = SMILViewport;
  2704.                 }
  2705.                 break;
  2706.             case SMIL2ElemTransition:
  2707.                 {
  2708.                     pNode->m_tag = SMILTransition;
  2709.                 }
  2710.                 break;
  2711.             case SMIL2ElemRootLayout:
  2712.                 {
  2713.                     pNode->m_tag = SMILRootLayout;
  2714.                     pNode->m_bSkipContent = TRUE;
  2715.                 }
  2716.                 break;
  2717.             case SMIL2ElemCustomAttributes:
  2718.                 {
  2719.                     pNode->m_tag = SMILCustomAttributes;
  2720.                 }
  2721.                 break;
  2722.             case SMIL2ElemCustomTest:
  2723.                 {
  2724.                     pNode->m_tag = SMILCustomTest;
  2725.                 }
  2726.                 break;
  2727.             case SMIL2ElemSwitch:
  2728.                 {
  2729.                     pNode->m_tag = SMILSwitch;
  2730.                 }
  2731.                 break;
  2732.             case SMIL2ElemText:
  2733.                 {
  2734.                     pNode->m_tag = SMILText;
  2735.                 }
  2736.                 break;
  2737.             case SMIL2ElemImg:
  2738.                 {
  2739.                     pNode->m_tag = SMILImg;
  2740.                 }
  2741.                 break;
  2742.             case SMIL2ElemRef:
  2743.                 {
  2744.                     pNode->m_tag = SMILRef;
  2745.                 }
  2746.                 break;
  2747.             case SMIL2ElemAudio:
  2748.                 {
  2749.                     pNode->m_tag = SMILAudio;
  2750.                 }
  2751.                 break;
  2752.             case SMIL2ElemVideo:
  2753.                 {
  2754.                     pNode->m_tag = SMILVideo;
  2755.                 }
  2756.                 break;
  2757.             case SMIL2ElemAnimation:
  2758.                 {
  2759.                     pNode->m_tag = SMILAnimation;
  2760.                 }
  2761.                 break;
  2762.             case SMIL2ElemTextstream:
  2763.                 {
  2764.                     pNode->m_tag = SMILTextstream;
  2765.                 }
  2766.                 break;
  2767.             case SMIL2ElemBrush:
  2768.                 {
  2769.                     pNode->m_tag = SMILBrush;
  2770.                 }
  2771.                 break;
  2772.             case SMIL2ElemPrefetch:
  2773.                 {
  2774.                     pNode->m_tag = SMILPrefetch;
  2775.                 }
  2776.                 break;
  2777.             case SMIL2ElemA:
  2778.                 {
  2779.                     pNode->m_tag = SMILAAnchor;
  2780.                 }
  2781.                 break;
  2782.             case SMIL2ElemAnchor:
  2783.                 {
  2784.                     pNode->m_tag = SMILAnchor;
  2785.                     pNode->m_bSkipContent = TRUE;
  2786.                 }
  2787.             case SMIL2ElemArea:
  2788.                 {
  2789.                     pNode->m_tag = SMILArea;
  2790.                 }
  2791.                 break;
  2792.             case SMIL2ElemPar:
  2793.                 {
  2794.                     pNode->m_tag = SMILPar;
  2795.                 }
  2796.                 break;
  2797.             case SMIL2ElemSeq:
  2798.                 {
  2799.                     pNode->m_tag = SMILSeq;
  2800.                 }
  2801.                 break;
  2802.             case SMIL2ElemExcl:
  2803.                 {
  2804.                     pNode->m_tag = SMILExcl;
  2805.                 }
  2806.                 break;
  2807.             case SMIL2ElemPriorityClass:
  2808.                 {
  2809.                     pNode->m_tag = SMILPriorityClass;
  2810.                 }
  2811.                 break;
  2812.             case SMIL2ElemAnimate:
  2813.                 {
  2814.                     pNode->m_tag = SMILAnimate;
  2815.                     pNode->m_bSkipContent = TRUE;
  2816.                 }
  2817.                 break;
  2818.             case SMIL2ElemSet:
  2819.                 {
  2820.                     pNode->m_tag = SMILSet;
  2821.                     pNode->m_bSkipContent = TRUE;
  2822.                 }
  2823.                 break;
  2824.             case SMIL2ElemAnimateMotion:
  2825.                 {
  2826.                     pNode->m_tag = SMILAnimateMotion;
  2827.                     pNode->m_bSkipContent = TRUE;
  2828.                 }
  2829.                 break;
  2830.             case SMIL2ElemAnimateColor:
  2831.                 {
  2832.                     pNode->m_tag = SMILAnimateColor;
  2833.                     pNode->m_bSkipContent = TRUE;
  2834.                 }
  2835.                 break;
  2836.             case SMIL2ElemParam:
  2837.                 {
  2838.                     pNode->m_tag = SMILParam;
  2839.                     pNode->m_bSkipContent = TRUE;
  2840.                 }
  2841.                 break;
  2842.             default:
  2843.                 {
  2844.                     if(m_pParser->m_bRNNamespace &&
  2845.                         strcmp(pName, (const char*) RN_TAG_RENDERER_LIST) == 0)
  2846.                     {
  2847.                         pNode->m_id = m_pParser->assignID((const char*) RN_TAG_RENDERER_LIST);
  2848.                         pNode->m_tag = SMILRNRendererList;
  2849.                     }
  2850.                     else if(strcmp(pName, (const char*) RN_TAG_RENDERER) == 0)
  2851.                     {
  2852.                         pNode->m_tag = SMILRendererPreFetch;
  2853.                     }
  2854.                     else
  2855.                     {
  2856.                         char* pColon = (char *)strchr(pName, ':');
  2857.                         if(pColon)
  2858.                         {
  2859.                             //check for valid namespace tag we can
  2860.                             // ignore
  2861.                             char* pTmpNam = new_string(pName);
  2862.                             char* pNamespace = strtok(pTmpNam, ":");
  2863.                             if(pNamespace)
  2864.                             {
  2865.                                 UINT32 ulTemp = 0;
  2866.                                 if(m_pParser->m_pActiveNamespaceMap &&
  2867.                                   (m_pParser->m_pActiveNamespaceMap->Lookup(pNamespace,
  2868.                                   (void*&)ulTemp)))
  2869.                                 {
  2870.                                     // OK, we can ignore it...
  2871.                                     bValidTag = TRUE;
  2872.                                 }
  2873.                             }
  2874.                             delete[] pTmpNam;
  2875.                         }
  2876.                         if(!bValidTag &&
  2877.                             !m_pParser->m_bIgnoreUnrecognizedElements)
  2878.                         {
  2879.                             rc = HXR_FAIL;
  2880.                             CSmilSMILSyntaxErrorHandler errHandler(m_pParser->m_pContext);
  2881.                             errHandler.ReportError(SMILErrorUnrecognizedTag, pName, ulLineNumber);
  2882.                             goto exit;
  2883.                         }
  2884.                         else
  2885.                         {
  2886.                             bCheckForDeletion = TRUE;
  2887.                         }
  2888.                         if (!bValidTag && m_pParser->m_bStoreErrors)
  2889.                         {
  2890.                             m_pParser->storeError(SMILErrorUnrecognizedTag, pName, 0,
  2891.                                 ulLineNumber, ulColumnNumber, FALSE);
  2892.                         }
  2893.                     }
  2894.                 }
  2895.         }
  2896. #ifdef _WIN32 /* Fixes Windows version of PR 84161 */
  2897. IHXValues * pNewAttributes = NULL;
  2898.         if ( HXR_OK == m_pParser->m_pClassFactory->CreateInstance(CLSID_IHXValues, (void**) &pNewAttributes) )
  2899. {
  2900.     const char* pKey = NULL;
  2901.     HX_RESULT res = pAttributes->GetFirstPropertyCString(pKey, pBuffer);
  2902.     while(HXR_OK == res)
  2903.     {
  2904. // expat returns strings in UTF-8
  2905. const char* pUTF8String = (const char*)pBuffer->GetBuffer();
  2906. int nLen = MultiByteToWideChar(  /* Flawfinder: ignore */
  2907. CP_UTF8, 0, pUTF8String, -1, NULL, 0 );
  2908. UINT16* pUTF16String = new UINT16 [nLen + 1];
  2909. if ( pUTF16String )
  2910. {
  2911.     // convert UTF-8 to UTF-16
  2912.     memset( pUTF16String, 0, nLen + 1 ); /* Flawfinder: ignore */
  2913.     MultiByteToWideChar( CP_UTF8, 0,  /* Flawfinder: ignore */
  2914.     pUTF8String, -1, pUTF16String, nLen + 1 );
  2915.     nLen = WideCharToMultiByte( CP_ACP, 0, /* Flawfinder: ignore */
  2916.     pUTF16String, -1, NULL, 0, NULL, NULL );
  2917.     char* pNativeString = new char [nLen + 1];
  2918.     if ( pNativeString )
  2919.     {
  2920. // convert UTF-16 to Windows native string
  2921. memset( pNativeString, 0, nLen + 1 ); /* Flawfinder: ignore */
  2922. WideCharToMultiByte(CP_ACP, 0, pUTF16String, /* Flawfinder: ignore */
  2923. -1, pNativeString, nLen + 1, NULL, NULL );
  2924. m_pParser->addStringProperty( pNewAttributes,
  2925. m_pParser->m_pContext, pKey, pNativeString );
  2926. HX_VECTOR_DELETE( pNativeString );
  2927.     }
  2928.     HX_VECTOR_DELETE( pUTF16String );
  2929. }
  2930. HX_RELEASE(pBuffer);
  2931. res = pAttributes->GetNextPropertyCString(pKey, pBuffer);
  2932.     }
  2933.     pNode->m_pValues = pNewAttributes;
  2934. }
  2935. else
  2936. {
  2937.     pNode->m_pValues = pAttributes;
  2938.     pNode->m_pValues->AddRef();
  2939. }
  2940. #else
  2941. pNode->m_pValues = pAttributes;
  2942. pNode->m_pValues->AddRef();
  2943. #endif /* _WIN32 PR 84161 */
  2944. rc = m_pParser->storeNamespaces(pNode);
  2945. if (SUCCEEDED(rc))
  2946. {
  2947.     rc = m_pParser->addToNamespaceScope(pNode);
  2948. }
  2949. BOOL bFound = FALSE;
  2950. const char* pName = NULL;
  2951. HX_RESULT res = pNode->m_pValues->GetFirstPropertyCString(pName, pBuffer);
  2952. while(HXR_OK == res && SUCCEEDED(rc))
  2953. {
  2954.     const char* pActualValue = (const char*)pBuffer->GetBuffer();
  2955.     if(!m_pParser->isLegalAttribute(pNode->m_tag, pName) )
  2956.     {
  2957. if (!m_pParser->m_bIgnoreUnrecognizedElements)
  2958. {
  2959.     rc = HXR_FAIL;
  2960.     m_pParser->badAttributeError(pNode->m_tag, pName,
  2961. pNode->m_ulTagStartLine, FALSE);
  2962.     break;
  2963. }
  2964. if (m_pParser->m_bStoreErrors)
  2965. {
  2966.     m_pParser->badAttributeError(pNode->m_tag, pName,
  2967. ulLineNumber, TRUE);
  2968. }
  2969.     }
  2970.     if (strcmp(pName, "skip-content") == 0)
  2971.     {
  2972. if(strcmp(pActualValue, "true") == 0)
  2973. {
  2974.     pNode->m_bSkipContent = TRUE;
  2975. }
  2976. else
  2977. {
  2978.     // /If we initialized m_bSkipContent to TRUE, then this
  2979.     // is an empty element that must not have skip-content
  2980.     // set to false if it contains anything:
  2981.     if (pNode->m_bSkipContent)
  2982.     {
  2983. CHXString errMsg = '<';
  2984. errMsg += (const char*)pNode->m_name;
  2985. errMsg += " ";
  2986. errMsg += pName;
  2987. errMsg += "="false">";
  2988. CSmilSMILSyntaxErrorHandler errHandler(
  2989. m_pParser->m_pContext);
  2990. errHandler.ReportError(SMILErrorUnexpectedContent,
  2991.        (const char*)errMsg,
  2992.        pNode->m_ulTagStartLine);
  2993. rc = HXR_FAIL;
  2994. HX_RELEASE(pBuffer);
  2995. goto exit;
  2996.     }
  2997.     pNode->m_bSkipContent = FALSE;
  2998. }
  2999.     }
  3000.     HX_RELEASE(pBuffer);
  3001.     res = pNode->m_pValues->GetNextPropertyCString(pName, pBuffer);
  3002. }
  3003. // /If the tag is valid but we don't know what to do with it,
  3004. // then only delete it if it's skip-content value is TRUE
  3005. // (otherwise, let its children have a chance to play):
  3006. if (bCheckForDeletion)
  3007. {
  3008.     pNode->m_bDelete = bValidTag ? pNode->m_bSkipContent : TRUE;
  3009. }
  3010. m_pParser->m_pNodeListStack->Push(pNode);
  3011.     }
  3012.     else
  3013.     {
  3014. //Even if parent has skip-content set, add this so it pops when
  3015. // end is found instead of popping the next one in the stack:
  3016. m_pParser->m_pNodeListStack->Push(pNode);
  3017.     }
  3018. exit:
  3019.     if (FAILED(rc))
  3020.     {
  3021.         if (m_pParser)
  3022.         {
  3023.             m_pParser->setParseError(rc);
  3024.         }
  3025.     }
  3026.     return rc;
  3027. }
  3028. STDMETHODIMP
  3029. CSmilParserResponse::HandleEndElement(const char* pName,
  3030.       UINT32 ulLineNumber,
  3031.       UINT32 ulColumnNumber)
  3032. {
  3033.     HX_RESULT rc = HXR_OK;
  3034.     if (m_pParser)
  3035.     {
  3036.         rc = m_pParser->getParseError();
  3037.         if (FAILED(rc))
  3038.         {
  3039.             return rc;
  3040.         }
  3041.     }
  3042.     SMILNode* pCurrentNode = (SMILNode*)m_pParser->m_pNodeListStack->Pop();
  3043.     SMILNode* pParentNode = (SMILNode*)m_pParser->m_pNodeListStack->TopOfStack();
  3044.     HX_ASSERT(pCurrentNode);
  3045.     HX_ASSERT(pParentNode);
  3046.     if (pParentNode)
  3047.     {
  3048.         pParentNode->m_pNodeList->AddTail(pCurrentNode);
  3049.     }
  3050.     SMILNode* pEndNode = new SMILNode;
  3051.     pEndNode->m_name = pName;
  3052.     pEndNode->m_id.Format("CLOSE-%s", pName);
  3053.     pEndNode->m_bCloseNode = TRUE;
  3054.     pEndNode->m_pParent = pParentNode;
  3055.     pEndNode->m_ulTagStartLine = ulLineNumber;
  3056.     pEndNode->m_ulTagStartColumn = ulColumnNumber;
  3057.     if(strcmp(pName, "seq") == 0)
  3058.     {
  3059. pEndNode->m_tag = SMILEndSeq;
  3060.     }
  3061.     else if(strcmp(pName, "par") == 0)
  3062.     {
  3063. pEndNode->m_tag = SMILEndPar;
  3064.     }
  3065.     else if(strcmp(pName, "excl") == 0)
  3066.     {
  3067. pEndNode->m_tag = SMILEndExcl;
  3068.     }
  3069.     else if(strcmp(pName, "a") == 0)
  3070.     {
  3071. pEndNode->m_tag = SMILEndAAnchor;
  3072.     }
  3073.     else if(strcmp(pName, "priorityClass") == 0)
  3074.     {
  3075. pEndNode->m_tag = SMILEndPriorityClass;
  3076.     }
  3077.     pCurrentNode->m_pNodeList->AddTail(pEndNode);
  3078.     rc = m_pParser->removeFromNamespaceScope(pCurrentNode);
  3079.     return rc;
  3080. }
  3081. STDMETHODIMP
  3082. CSmilParserResponse::HandleCharacterData(IHXBuffer* pBuffer,
  3083.  UINT32 ulLineNumber,
  3084.  UINT32 ulColumnNumber)
  3085. {
  3086.     HX_RESULT rc = HXR_OK;
  3087.     // The SMIL content model does not allow non-whitespace character
  3088.     // data as children of any elements. Therefore, we must check
  3089.     // to see if there are any non-whitespace characters here.
  3090.     if (pBuffer)
  3091.     {
  3092.         UINT32      ulLen  = pBuffer->GetSize();
  3093.         const char* pszBuf = (const char*) pBuffer->GetBuffer();
  3094.         char*       pCh    = (char*) pszBuf;
  3095.         if (pCh)
  3096.         {
  3097.             for (UINT32 i = 0; i < ulLen; i++)
  3098.             {
  3099.                 char c = *pCh++;
  3100.                 if (!(c == ' '  ||
  3101.                       c == 'n' ||
  3102.                       c == 'r' ||
  3103.                       c == 't' ||
  3104.                       c == ''))
  3105.                 {
  3106.                     CSmilSMILSyntaxErrorHandler errHandler(m_pParser->m_pContext);
  3107.                     errHandler.ReportError(SMILErrorUnexpectedContent,
  3108.                                            pszBuf,
  3109.                                            ulLineNumber);
  3110.                     rc = HXR_FAIL;
  3111.                     break;
  3112.                 }
  3113.             }
  3114.         }
  3115.     }
  3116.     return rc;
  3117. }
  3118. STDMETHODIMP
  3119. CSmilParserResponse::HandleProcessingInstruction(const char* pTarget,
  3120.   IHXValues* pAttributes,
  3121.   UINT32 ulLineNumber,
  3122.   UINT32 ulColumnNumber)
  3123. {
  3124.     HX_RESULT rc = HXR_OK;
  3125.     if(strcmp(pTarget, "xml:namespace") == 0)
  3126.     {
  3127. IHXBuffer* pNamespaceBuffer = NULL;
  3128. IHXBuffer* pPrefixBuffer = NULL;
  3129. const char* pNamespace = NULL;
  3130. const char* pPrefix = NULL;
  3131. if(HXR_OK == pAttributes->GetPropertyCString("ns", pNamespaceBuffer))
  3132. {
  3133.     pNamespace = (const char*)pNamespaceBuffer->GetBuffer();
  3134. }
  3135. if(HXR_OK == pAttributes->GetPropertyCString("prefix", pPrefixBuffer))
  3136. {
  3137.     pPrefix = (const char*)pPrefixBuffer->GetBuffer();
  3138. }
  3139. rc = m_pParser->addGlobalNamespace(pNamespace, pPrefix);
  3140. HX_RELEASE(pNamespaceBuffer);
  3141. HX_RELEASE(pPrefixBuffer);
  3142.     }
  3143.     return rc;
  3144. }
  3145. STDMETHODIMP
  3146. CSmilParserResponse::HandleUnparsedEntityDecl(const char* /*IN*/  pEntityName,
  3147.       const char* /*IN*/  pSystemID,
  3148.       const char* /*IN*/  pPublicID,
  3149.       const char* /*IN*/  pNotationName,
  3150.       UINT32 ulLineNumber,
  3151.       UINT32 ulColumnNumber)
  3152. {
  3153.     HX_RESULT rc = HXR_OK;
  3154.     return rc;
  3155. }
  3156. STDMETHODIMP
  3157. CSmilParserResponse::HandleNotationDecl(const char* /*IN*/  pNotationName,
  3158. const char* /*IN*/  pSystemID,
  3159. const char* /*IN*/  pPublicID,
  3160. UINT32 ulLineNumber,
  3161. UINT32 ulColumnNumber)
  3162. {
  3163.     HX_RESULT rc = HXR_OK;
  3164.     return rc;
  3165. }
  3166. STDMETHODIMP
  3167. CSmilParserResponse::HandleUnparsedDoctypeDecl(const char*  /*IN*/ pName,
  3168.     const char*  /*IN*/ pSystemID,
  3169.     const char*  /*IN*/ pPublicID,
  3170.     UINT32  /*IN*/ ulLineNumber,
  3171.     UINT32  /*IN*/ ulColumNumber)
  3172. {
  3173.     HX_RESULT rc = HXR_OK;
  3174.     if(strcmp(pName, "smil") == 0)
  3175.     {
  3176. m_pParser->m_bNoNamespaces = TRUE;
  3177. m_pParser->m_bIgnoreUnrecognizedElements = FALSE;
  3178.     }
  3179.     return rc;
  3180. }
  3181. STDMETHODIMP
  3182. CSmilParserResponse::HandleComment(const char* /*IN*/  pComment,
  3183.    UINT32 ulLineNumber,
  3184.    UINT32 ulColumnNumber)
  3185. {
  3186.     HX_RESULT rc = HXR_OK;
  3187.     return rc;
  3188. }
  3189. STDMETHODIMP
  3190. CSmilParserResponse::HandleDefault(IHXBuffer* /*IN*/ pBuffer,
  3191.    UINT32 ulLineNumber,
  3192.    UINT32 ulColumnNumber)
  3193. {
  3194.     HX_RESULT rc = HXR_OK;
  3195.     return rc;
  3196. }
  3197. HX_RESULT
  3198. CSmilParserResponse::ErrorInLastTag(HX_RESULT err,
  3199.     const char* pErrorString, const char* pFrameString,
  3200.     UINT32 ulLineNumber, UINT32 ulLinePosition)
  3201. {
  3202.     // XXXJHUG - we could add the error to the actual node...
  3203.     // SMILNode* pCurrentNode = (SMILNode*)m_pParser->m_pNodeListStack->Pop();
  3204.     // pCurrentNode->m_errs->Add
  3205.     //
  3206.     // If we were going to warn for errors I think the warnings should be
  3207.     // thrown from here.  (modify ReportError to have a warning level.)
  3208.     //
  3209.     // But for dumping the errors there is no benifit for this.
  3210.     // therefore we will just add the error to a ptr array of errors.
  3211.     // this array will also be added to when the SMIL attributes are bad.
  3212.     //
  3213.     // XXX to store in the parse tree you also have to make sure the last
  3214.     // call was a tag, and not a PI or a directive or something that was
  3215.     // ignored.
  3216.     return m_pParser->storeError(err, pErrorString, pFrameString,
  3217.     ulLineNumber, ulLinePosition);
  3218. }
  3219. /*
  3220.  * SMILNode methods
  3221.  */
  3222. SMILNode::SMILNode():
  3223.     m_pNodeList(0),
  3224.     m_pParent(0),
  3225.     m_pDependency(0),
  3226.     m_tag(SMILUnknown),
  3227.     m_num(0),
  3228.     m_pValues(0),
  3229.     m_curPosition(0),
  3230.     m_pElement(0),
  3231.     m_nGroup((UINT16)-1),
  3232.     m_bLastInGroup(FALSE),
  3233.     m_bDelete(FALSE),
  3234.     m_bSkipContent(FALSE),
  3235.     m_pNamespaceList(NULL),
  3236.     m_bRepeatHandled(FALSE),
  3237.     m_nPrefetchTrackNum((UINT16)-1),
  3238.     m_fPartialPlayFactor(1.0),
  3239.     m_ulRepeatDur(UINT32(-1)),
  3240.     m_bIsSeqWrapperForRepeatElement(FALSE),
  3241.     m_bIsOuterWrapperTimeContainer(FALSE),
  3242.     m_bBeginHandledByWrapperParent(FALSE),
  3243.     m_bEndHandledByWrapperParent(FALSE),
  3244.     m_bMinHandledByWrapperParent(FALSE),
  3245.     m_bMaxHandledByWrapperParent(FALSE),
  3246.     m_bNeedToResolveRepeatDurVSRepeatCount(FALSE),
  3247.     m_repeatTag(RepeatUnknown),
  3248.     m_eElement(NumSMIL2Elements),
  3249.     m_bCloseNode(FALSE),
  3250.     m_bNamespacedElement(FALSE)
  3251. {
  3252. }
  3253. #if defined(XXXEH_REPEAT_VALUE_TIMING_SHOULD_BE_EVENT_BASED)
  3254. SMILNode::SMILNode(const SMILNode& rhs, BOOL bKeepId, CSmilParser* pParser)
  3255. #else
  3256. SMILNode::SMILNode(const SMILNode& rhs, BOOL bKeepId, CSmilParser* pParser, UINT32 ulRepeatNum)
  3257. #endif
  3258. {
  3259.     if (bKeepId)
  3260.     {
  3261. m_id = rhs.m_id;
  3262.     }
  3263.     else
  3264.     {
  3265. // need a unique ID, so make one...
  3266.         char* pIDName = new char [256];
  3267.         if (pIDName)
  3268.         {
  3269. #if defined(XXXEH_REPEAT_VALUE_TIMING_SHOULD_BE_EVENT_BASED)
  3270. #else
  3271.     // /For repeated elements, create an ID of the following form:
  3272.     // "[rhs.m_id]" + "_repeat_copy_" + "[ulRepeatNum]":
  3273.     BOOL bHandledAsRepeatId = FALSE;
  3274.     if (rhs.m_repeatid.GetLength()  &&  ulRepeatNum>0)
  3275.     {
  3276.         // /Combined string must be < 255 (where 236 is 255 minus len of
  3277.         // "_repeat_copy_" and also minus 7 for repeat num) otherwise
  3278.         // punt:
  3279.         if ((LONG32)strlen(rhs.m_id) < 235)
  3280.         {
  3281.     SafeSprintf(pIDName, 256, "%s_repeat_copy_%lu",
  3282.     (const char*)rhs.m_id, ulRepeatNum);
  3283.     bHandledAsRepeatId = TRUE;
  3284.         }
  3285.     }
  3286.     if (!bHandledAsRepeatId)
  3287. #endif
  3288.     {
  3289.                 if (pParser)
  3290.                 {
  3291.                     sprintf(pIDName, "node_copy_%ld", pParser->GetUniqueNumber()); /* Flawfinder: ignore */
  3292.                 }
  3293.     }
  3294.     m_id = pIDName;
  3295.         }
  3296.         HX_VECTOR_DELETE(pIDName);
  3297.     }
  3298.     m_repeatid = rhs.m_repeatid;
  3299.     m_pParent = rhs.m_pParent;
  3300.     m_pDependency = rhs.m_pDependency;
  3301.     m_tag = rhs.m_tag;
  3302.     m_num = rhs.m_num;
  3303.     m_curPosition = rhs.m_curPosition;
  3304.     m_pElement = rhs.m_pElement;
  3305.     m_nGroup = rhs.m_nGroup;
  3306.     m_bLastInGroup = rhs.m_bLastInGroup;
  3307.     m_bDelete = rhs.m_bDelete;
  3308.     m_bSkipContent = rhs.m_bSkipContent;
  3309.     m_bRepeatHandled = FALSE;
  3310.     m_repeatTag = rhs.m_repeatTag;
  3311.     m_fPartialPlayFactor = rhs.m_fPartialPlayFactor;
  3312.     m_ulRepeatDur = rhs.m_ulRepeatDur;
  3313.     m_bIsSeqWrapperForRepeatElement = rhs.m_bIsSeqWrapperForRepeatElement;
  3314.     m_bIsOuterWrapperTimeContainer = rhs.m_bIsOuterWrapperTimeContainer;
  3315.     m_bBeginHandledByWrapperParent = rhs.m_bBeginHandledByWrapperParent;
  3316.     m_bEndHandledByWrapperParent = rhs.m_bEndHandledByWrapperParent;
  3317.     m_bMinHandledByWrapperParent = rhs.m_bMinHandledByWrapperParent;
  3318.     m_bMaxHandledByWrapperParent = rhs.m_bMaxHandledByWrapperParent;
  3319.     m_bNeedToResolveRepeatDurVSRepeatCount =
  3320.     rhs.m_bNeedToResolveRepeatDurVSRepeatCount;
  3321.     if(rhs.m_pValues)
  3322.     {
  3323. m_pValues = rhs.m_pValues;
  3324. m_pValues->AddRef();
  3325.     }
  3326.     else
  3327.     {
  3328. m_pValues = NULL;
  3329.     }
  3330.     if(rhs.m_pNodeList)
  3331.     {
  3332. m_pNodeList = rhs.m_pNodeList->copy(this, bKeepId, pParser);
  3333.     }
  3334.     else
  3335.     {
  3336. m_pNodeList = NULL;
  3337.     }
  3338.     if (rhs.m_pNamespaceList)
  3339.     {
  3340.      m_pNamespaceList = new CHXSimpleList;
  3341. for (CHXSimpleList::Iterator pIt = rhs.m_pNamespaceList->Begin();
  3342.      pIt != rhs.m_pNamespaceList->End(); ++pIt)
  3343. {
  3344.     SMILNamespace* pNS = (SMILNamespace*)(*pIt);
  3345.     SMILNamespace* pNewNS = new SMILNamespace(pNS);
  3346.     m_pNamespaceList->AddHead(pNewNS);
  3347. }
  3348.     }
  3349.     else
  3350.     {
  3351.        m_pNamespaceList = NULL;
  3352.     }
  3353. }
  3354. SMILNode::~SMILNode()
  3355. {
  3356.     HX_DELETE(m_pNodeList);
  3357.     HX_DELETE(m_pElement);
  3358.     HX_RELEASE(m_pValues);
  3359.     if (m_pNamespaceList)
  3360.     {
  3361. while (!m_pNamespaceList->IsEmpty())
  3362. {
  3363.     SMILNamespace* pNS = (SMILNamespace*)m_pNamespaceList->RemoveHead();
  3364.     HX_DELETE(pNS);
  3365. }
  3366.     }
  3367.     HX_DELETE(m_pNamespaceList);
  3368. }
  3369. SMILNode*
  3370. SMILNode::getFirstChild()
  3371. {
  3372.     if(!m_pNodeList)
  3373.     {
  3374. return 0;
  3375.     }
  3376.     m_curPosition = m_pNodeList->GetHeadPosition();
  3377.     if(m_curPosition)
  3378.     {
  3379. return (SMILNode*)m_pNodeList->GetNext(m_curPosition);
  3380.     }
  3381.     return 0;
  3382. }
  3383. SMILNode*
  3384. SMILNode::getNextChild()
  3385. {
  3386.     if(m_curPosition)
  3387.     {
  3388. return (SMILNode*)m_pNodeList->GetNext(m_curPosition);
  3389.     }
  3390.     return 0;
  3391. }
  3392. SMILNodeList::SMILNodeList():
  3393.     m_pParentNode(0)
  3394. {
  3395. }
  3396. SMILNodeList::~SMILNodeList()
  3397. {
  3398.     CHXSimpleList::Iterator i;
  3399.     for(i = Begin(); i != End(); ++i)
  3400.     {
  3401. SMILNode* pNode = (SMILNode*)(*i);
  3402. HX_DELETE(pNode);
  3403.     }
  3404. }
  3405. SMILNodeList*
  3406. SMILNodeList::copy(SMILNode* pParent, BOOL bKeepId, CSmilParser* pParser)
  3407. {
  3408.     SMILNodeList* pNewList = new SMILNodeList;
  3409.     m_pParentNode = pParent;
  3410.     CHXSimpleList::Iterator i = Begin();
  3411.     for(; i != End(); ++i)
  3412.     {
  3413. SMILNode* pNode = (SMILNode*)(*i);
  3414. SMILNode* pNodeCopy = new SMILNode(*pNode, bKeepId, pParser);
  3415. pNodeCopy->m_pParent = pParent;
  3416. pNewList->AddTail(pNodeCopy);
  3417.     }
  3418.     return pNewList;
  3419. }