Ejemplo n.º 1
0
        protected override void XukInChild(XmlReader source, IProgressHandler handler)
        {
            bool readItem = false;

            if (source.NamespaceURI == XukAble.XUK_NS)
            {
                readItem = true;
                if (m_firstXukInAttribute &&
                    XukAble.GetXukName(typeof(MetadataAttribute)).Match(source.LocalName))
                {
                    XukInMetadataAttribute(source, handler);
                }
                else if (PrettyFormat &&
                         source.LocalName == XukStrings.MetadataOtherAttributes)
                {
                    XukInMetadataOtherAttributes(source, handler);
                }
                else if (!PrettyFormat &&
                         XukAble.GetXukName(typeof(MetadataAttribute)).Match(source.LocalName))
                {
                    XukInMetadataAttribute(source, handler);
                }
                else
                {
                    readItem = false;
                }
            }
            if (!(readItem || source.IsEmptyElement))
            {
                source.ReadSubtree().Close(); //Read past unknown child
            }
        }
 private void XukInPCMFormat(XmlReader source, IProgressHandler handler)
 {
     if (!source.IsEmptyElement)
     {
         while (source.Read())
         {
             if (source.NodeType == XmlNodeType.Element)
             {
                 if (source.NamespaceURI == XukAble.XUK_NS &&
                     XukAble.GetXukName(typeof(PCMFormatInfo)).Match(source.LocalName)
                     )
                 {
                     PCMFormatInfo newInfo = new PCMFormatInfo();
                     newInfo.XukIn(source, handler);
                     PCMFormat = newInfo;
                 }
                 else if (!source.IsEmptyElement)
                 {
                     source.ReadSubtree().Close();
                 }
             }
             else if (source.NodeType == XmlNodeType.EndElement)
             {
                 break;
             }
             if (source.EOF)
             {
                 throw new exception.XukException("Unexpectedly reached EOF");
             }
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a phrase node belonging to this presentation.
        /// </summary>
        public PhraseNode CreatePhraseNode()
        {
            PhraseNode node = (PhraseNode)m_ObiNodeFactory.createNode(XukAble.GetXukName(typeof(PhraseNode)).z(PrettyFormat), DataModelFactory.NS); //sdk2 :local ObiNode factory used

            node.AddProperty(PropertyFactory.CreateChannelsProperty());
            return(node);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new node given a QName.
 /// </summary>
 /// <param name="localName">the local part of the qname.</param>
 /// <param name="namespaceUri">the namespace URI of the qname.</param>
 /// <returns>A new node or null if the qname corresponds to no known node.</returns>
 public TreeNode createNode(string localName, string namespaceUri)
 {
     if (namespaceUri == DataModelFactory.NS)
     {
         if (
             XukAble.GetXukName(typeof(ObiRootNode)).Match(localName)
             //localName == XukAble.GetXukName(typeof(ObiRootNode)).z(m_Presentation.PrettyFormat)
             )
         {
             return(m_Presentation.TreeNodeFactory.Create <ObiRootNode>());
         }
         else if (
             XukAble.GetXukName(typeof(PhraseNode)).Match(localName)
             //localName == XukAble.GetXukName(typeof(PhraseNode)).z(m_Presentation.PrettyFormat)
             )
         {
             return(m_Presentation.TreeNodeFactory.Create <PhraseNode>());
         }
         else if (
             XukAble.GetXukName(typeof(SectionNode)).Match(localName)
             //localName == XukAble.GetXukName(typeof(SectionNode)).z(m_Presentation.PrettyFormat)
             )
         {
             return(m_Presentation.TreeNodeFactory.Create <SectionNode>());
         }
         else if (XukAble.GetXukName(typeof(EmptyNode)).Match(localName)
                  //localName == XukAble.GetXukName(typeof(EmptyNode)).z(m_Presentation.PrettyFormat)
                  )
         {
             return(m_Presentation.TreeNodeFactory.Create <EmptyNode>());
         }
     }
     //base.CreateNode(localName, namespaceUri);
     return(m_Presentation.TreeNodeFactory.Create(localName, namespaceUri));//sdk2
 }
 private void XukInMetadata(XmlReader source, IProgressHandler handler)
 {
     if (source.IsEmptyElement)
     {
         return;
     }
     while (source.Read())
     {
         if (source.NodeType == XmlNodeType.Element)
         {
             if (source.NamespaceURI == XukAble.XUK_NS &&
                 XukAble.GetXukName(typeof(Metadata)).Match(source.LocalName))
             {
                 Metadata md = Presentation.MetadataFactory.CreateMetadata();
                 md.XukIn(source, handler);
                 m_Metadata.Insert(m_Metadata.Count, md);
             }
         }
         else if (source.NodeType == XmlNodeType.EndElement)
         {
             break;
         }
         if (source.EOF)
         {
             throw new exception.XukException("Unexpectedly reached EOF");
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Create a section node belonging to this presentation.
        /// </summary>
        public SectionNode CreateSectionNode()
        {
            SectionNode node = (SectionNode)m_ObiNodeFactory.createNode(XukAble.GetXukName(typeof(SectionNode)).z(PrettyFormat), DataModelFactory.NS); //sdk2 :local ObiNode factory used

            urakawa.property.channel.ChannelsProperty channelsProperty = PropertyFactory.CreateChannelsProperty();
            node.AddProperty(channelsProperty);
            // Create the text media object for the label with a default label
            TextMedia labelMedia = MediaFactory.CreateTextMedia();

            labelMedia.Text = Localizer.Message("default_section_label");
            channelsProperty.SetMedia(ChannelsManager.GetOrCreateTextChannel(), labelMedia);
            return(node);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Reads the <see cref="XmlAttribute"/>s from the <c>&lt;mXmlAttributes&gt;</c> child element
 /// </summary>
 /// <param name="source">The source <see cref="XmlReader"/></param>
 /// <param name="handler">The handler for progress</param>
 protected virtual void XukInXmlAttribute(XmlReader source, IProgressHandler handler)
 {
     if (source.NamespaceURI == XukAble.XUK_NS &&
         XukAble.GetXukName(typeof(XmlAttribute)).Match(source.LocalName))
     {
         XmlAttribute attr = new XmlAttribute();
         attr.XukIn(source, handler);
         SetAttribute(attr);
     }
     else if (!source.IsEmptyElement)
     {
         source.ReadSubtree().Close();
     }
 }
        protected override void XukInChild(XmlReader source, IProgressHandler handler)
        {
            bool readItem = false;

            if (source.NamespaceURI == XukAble.XUK_NS)
            {
                readItem = true;
                if (source.LocalName == XukStrings.Metadatas)
                {
                    XukInMetadata(source, handler);
                }
                else if (XukAble.GetXukName(typeof(TextMedia)).Match(source.LocalName))
                {
                    if (m_Text != null)
                    {
                        throw new exception.XukException("AlternateContent Text XukIn, already set !");
                    }
                    m_Text = Presentation.MediaFactory.CreateTextMedia();
                    m_Text.XukIn(source, handler);
                }
                else if (XukAble.GetXukName(typeof(ManagedAudioMedia)).Match(source.LocalName))
                {
                    if (m_Audio != null)
                    {
                        throw new exception.XukException("AlternateContent Audio XukIn, already set !");
                    }
                    m_Audio = Presentation.MediaFactory.CreateManagedAudioMedia();
                    m_Audio.XukIn(source, handler);
                }
                else if (XukAble.GetXukName(typeof(ManagedImageMedia)).Match(source.LocalName))
                {
                    if (m_Image != null)
                    {
                        throw new exception.XukException("AlternateContent Image XukIn, already set !");
                    }
                    m_Image = Presentation.MediaFactory.CreateManagedImageMedia();
                    m_Image.XukIn(source, handler);
                }
                else
                {
                    readItem = false;
                }
            }
            if (!(readItem || source.IsEmptyElement))
            {
                source.ReadSubtree().Close(); //Read past unknown child
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Reads a child of a Project xuk element.
        /// </summary>
        /// <param name="source">The source <see cref="XmlReader"/></param>
        /// <param name="handler">The handler for progress</param>
        protected override void XukInChild(XmlReader source, IProgressHandler handler)
        {
            bool readItem = false;

            if (source.NamespaceURI == XukAble.XUK_NS)
            {
                if (XukAble.GetXukName(typeof(PresentationFactory)).Match(source.LocalName))
                {
                    PresentationFactory.XukIn(source, handler);
                    readItem = true;
                }
                else if (source.LocalName == XukStrings.Presentations)
                {
                    XukInPresentations(source, handler);
                    readItem = true;
                }
            }
            if (!readItem)
            {
                base.XukInChild(source, handler);
            }
        }
Ejemplo n.º 10
0
        protected virtual void XukInMetadataAttribute(XmlReader source, IProgressHandler handler)
        {
            if (source.NamespaceURI == XukAble.XUK_NS &&
                XukAble.GetXukName(typeof(MetadataAttribute)).Match(source.LocalName))
            {
                MetadataAttribute attr = new MetadataAttribute();
                attr.XukIn(source, handler);

                if (m_firstXukInAttribute)
                {
                    NameContentAttribute  = attr;
                    m_firstXukInAttribute = false;
                }
                else
                {
                    OtherAttributes.Insert(OtherAttributes.Count, attr);
                }
            }
            else if (!source.IsEmptyElement)
            {
                source.ReadSubtree().Close();
            }
        }
Ejemplo n.º 11
0
        public override bool PreVisit(TreeNode node)
        {
            if (m_RootNode == null)
            {
                m_RootNode = node;
            }

            if (TreeNodeMustBeSkipped(node))
            {
                return(false);
            }
            if (TreeNodeTriggersNewAudioFile(node))
            {
                createNextAudioFile(node);
            }

            if (node.HasProperties(typeof(ChannelsProperty)))
            {
                ChannelsProperty chProp = node.GetChannelsProperty();

                ManagedAudioMedia mam = chProp.GetMedia(SourceChannel) as ManagedAudioMedia;
                if (mam != null)
                {
                    AudioMediaData amd = mam.AudioMediaData;

                    if (mCurrentAudioFileStream == null)
                    {
                        createNextAudioFile(node);
                    }
                    else if (mCurrentAudioFilePCMFormat != null &&
                             !mCurrentAudioFilePCMFormat.Data.IsCompatibleWith(amd.PCMFormat.Data))
                    {
#if DEBUG
                        Debugger.Break();
#endif
                        createNextAudioFile(node);
                    }

                    if (mCurrentAudioFileStream != null && mCurrentAudioFilePCMFormat == null)
                    {
                        writeInitialHeader(amd.PCMFormat);
                    }

                    Time durationFromRiffHeader = amd.AudioDuration;

                    Time clipBegin = new Time(mCurrentAudioFilePCMFormat.Data.ConvertBytesToTime(mCurrentAudioFileStream.Position - mCurrentAudioFileStreamRiffWaveHeaderLength));
                    Time clipEnd   = new Time(clipBegin.AsTimeSpanTicks + durationFromRiffHeader.AsTimeSpanTicks, true);

                    //BinaryReader rd = new BinaryReader(stream);

                    Stream stream = amd.OpenPcmInputStream();
                    try
                    {
                        const uint BUFFER_SIZE = 1024 * 1024 * 3; // 3 MB MAX BUFFER
                        StreamUtils.Copy(stream, 0, mCurrentAudioFileStream, BUFFER_SIZE);
                    }
                    finally
                    {
                        stream.Close();
                    }

                    ExternalAudioMedia eam = node.Presentation.MediaFactory.Create <ExternalAudioMedia>();
                    if (eam == null)
                    {
                        throw new exception.FactoryCannotCreateTypeException(String.Format(
                                                                                 "The media facotry cannot create a ExternalAudioMedia matching QName {1}:{0}",

                                                                                 XukAble.GetXukName(typeof(ExternalAudioMedia), true) ?? typeof(ExternalAudioMedia).Name,
                                                                                 node.Presentation.Project.GetXukNamespace()));
                    }

                    eam.Language  = mam.Language;
                    eam.Src       = node.Presentation.RootUri.MakeRelativeUri(GetCurrentAudioFileUri()).ToString();
                    eam.ClipBegin = clipBegin;
                    eam.ClipEnd   = clipEnd;

                    if (chProp.GetMedia(DestinationChannel) != null)
                    {
#if DEBUG
                        Debugger.Break();
#endif
                        chProp.SetMedia(DestinationChannel, null);
                    }
                    chProp.SetMedia(DestinationChannel, eam);
                }
            }
            return(true);
        }