예제 #1
0
        protected override TreeNode CreateTreeNodeForAudioNode(TreeNode navPointTreeNode, bool isHeadingNode, XmlNode smilNode, string fullSmilPath)
        {
            PhraseNode audioWrapperNode = m_Presentation.CreatePhraseNode();

            if (smilNode == null || !m_SmilXmlNodeToTreeNodeMap.ContainsKey(smilNode))
            {
                ((SectionNode)navPointTreeNode).AppendChild(audioWrapperNode);

                XmlNode seqParent = smilNode != null ? smilNode.ParentNode : null;
                while (seqParent != null)
                {
                    if ((seqParent.Name == "seq" || seqParent.Name == "par") && (seqParent.Attributes != null && seqParent.Attributes.GetNamedItem("customTest") != null))
                    {
                        break;
                    }
                    seqParent = seqParent.ParentNode;
                }

                string strClass = null;

                if (seqParent != null && seqParent.Attributes.GetNamedItem("class") != null &&
                    (strClass = seqParent.Attributes.GetNamedItem("class").Value) != null &&
                    (strClass == EmptyNode.Annotation || strClass == EmptyNode.EndNote || strClass == EmptyNode.Footnote ||
                     strClass == EmptyNode.ProducerNote || strClass == EmptyNode.Sidebar || strClass == EmptyNode.Note))
                {
                    audioWrapperNode.SetRole(EmptyNode.Role.Custom, strClass);
                    if (!m_Skippable_IdMap.ContainsKey(audioWrapperNode))
                    {
                        ObiNode preceedingNode = audioWrapperNode.PrecedingNode;
                        if (preceedingNode == null || preceedingNode is SectionNode || ((EmptyNode)preceedingNode).CustomRole != audioWrapperNode.CustomRole)
                        {
                            m_Skippable_IdMap.Add(audioWrapperNode, new List <string>());
                            XmlNode seqChild = seqParent;
                            while (seqChild != null && seqChild != smilNode)
                            {
                                if (seqChild.Attributes.GetNamedItem("id") != null)
                                {
                                    m_Skippable_IdMap[audioWrapperNode].Add(Path.GetFileName(fullSmilPath) + "#" + seqChild.Attributes.GetNamedItem("id").Value);
                                }
                                seqChild = seqChild.FirstChild;
                            }


                            AssignSkippableToAnchorNode();
                        }
                    }
                }
                else if (seqParent != null && seqParent.Attributes != null && seqParent.Attributes.GetNamedItem("customTest") != null)
                {
                    XmlNode anchorNode = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(seqParent, true, "a", seqParent.NamespaceURI);
                    if (anchorNode != null)
                    {
                        string strReference = anchorNode.Attributes.GetNamedItem("href").Value;
                        audioWrapperNode.SetRole(EmptyNode.Role.Anchor, null);
                        if (!m_AnchorNodeSmilRefMap.ContainsKey(audioWrapperNode))
                        {
                            string[] refArray = strReference.Split('#');
                            if (refArray.Length == 1 || string.IsNullOrEmpty(refArray[0]))
                            {
                                strReference = Path.GetFileName(fullSmilPath) + "#" + refArray[refArray.Length - 1];
                            }
                            m_AnchorNodeSmilRefMap.Add(audioWrapperNode, strReference);
                        }
                    }
                }
            }
            else
            {
                ((SectionNode)navPointTreeNode).InsertAfter(audioWrapperNode, m_SmilXmlNodeToTreeNodeMap[smilNode]);
                m_SmilXmlNodeToTreeNodeMap[smilNode] = audioWrapperNode;
            }

            return(audioWrapperNode);
        }