예제 #1
0
        /// <summary>
        /// Converts FB2 Title object to XHTML Title
        /// </summary>
        /// <param name="titleItem">title item to convert</param>
        /// <param name="titleConverterParams"></param>
        /// <returns></returns>
        public Div Convert(TitleItem titleItem, TitleConverterParamsV2 titleConverterParams)
        {
            if (titleItem == null)
            {
                throw new ArgumentNullException("titleItem");
            }
            _level = titleConverterParams.TitleLevel;
            var title = new Div(HTMLElementType.XHTML11);

            foreach (var fb2TextItem in titleItem.TitleData)
            {
                if (fb2TextItem is ParagraphItem)
                {
                    var paragraphStyle     = GetParagraphStyleByLevel(_level);
                    var paragraphConverter = new ParagraphConverterV2();
                    title.Add(paragraphConverter.Convert(fb2TextItem as ParagraphItem,
                                                         new ParagraphConverterParamsV2 {
                        ResultType = paragraphStyle, Settings = titleConverterParams.Settings, StartSection = false
                    }));
                }
                else if (fb2TextItem is EmptyLineItem)
                {
                    var emptyLineConverter = new EmptyLineConverterV2();
                    title.Add(emptyLineConverter.Convert());
                }
                else
                {
                    Debug.WriteLine("invalid type in Title - {0}", fb2TextItem.GetType());
                }
            }
            SetClassType(title, ElementStylesV2.PoemTitle);
            return(title);
        }
 /// <summary>
 /// Converts FB2 Title object to XHTML Title 
 /// </summary>
 /// <param name="titleItem">title item to convert</param>
 /// <param name="titleConverterParams"></param>
 /// <returns></returns>
 public Div Convert(TitleItem titleItem,  TitleConverterParamsV2 titleConverterParams)
 {
     if (titleItem == null)
     {
         throw new ArgumentNullException("titleItem");
     }
     _level = titleConverterParams.TitleLevel;
     var title = new Div(HTMLElementType.XHTML11);
     foreach (var fb2TextItem in titleItem.TitleData)
     {
         if (fb2TextItem is ParagraphItem)
         {
             var paragraphStyle = GetParagraphStyleByLevel(_level);
             var paragraphConverter = new ParagraphConverterV2();
             title.Add(paragraphConverter.Convert(fb2TextItem as ParagraphItem,
                 new ParagraphConverterParamsV2 { ResultType = paragraphStyle, Settings = titleConverterParams.Settings, StartSection = false }));
         }
         else if (fb2TextItem is EmptyLineItem)
         {
             var emptyLineConverter = new EmptyLineConverterV2();
             title.Add(emptyLineConverter.Convert());
         }
         else
         {
             Debug.WriteLine("invalid type in Title - {0}", fb2TextItem.GetType());
         }
     }
     SetClassType(title, ElementStylesV2.PoemTitle);
     return title;
 }
예제 #3
0
        /// <summary>
        /// Converts FB2 epigraph element
        /// </summary>
        /// <param name="epigraphItem"></param>
        /// <param name="epigraphConverterParams"></param>
        /// <returns>XHTML representation</returns>
        public Div Convert(EpigraphItem epigraphItem, EpigraphConverterParamsV2 epigraphConverterParams)
        {
            if (epigraphItem == null)
            {
                throw new ArgumentNullException("epigraphItem");
            }
            var content = new Div(HTMLElementType.XHTML11);

            foreach (var element in epigraphItem.EpigraphData)
            {
                if (element is ParagraphItem)
                {
                    var paragraphConverter = new ParagraphConverterV2();
                    content.Add(paragraphConverter.Convert(element as ParagraphItem,
                                                           new ParagraphConverterParamsV2 {
                        ResultType = ParagraphConvTargetEnumV2.Paragraph, Settings = epigraphConverterParams.Settings, StartSection = false
                    }));
                }
                if (element is PoemItem)
                {
                    var poemConverter = new PoemConverterV2();
                    content.Add(poemConverter.Convert(element as PoemItem,
                                                      new PoemConverterParamsV2 {
                        Level = epigraphConverterParams.Level + 1, Settings = epigraphConverterParams.Settings
                    }
                                                      ));
                }
                if (element is CiteItem)
                {
                    var citationConverter = new CitationConverterV2();
                    content.Add(citationConverter.Convert(element as CiteItem,
                                                          new CitationConverterParamsV2 {
                        Level = epigraphConverterParams.Level + 1, Settings = epigraphConverterParams.Settings
                    }));
                }
                if (element is EmptyLineItem)
                {
                    var emptyLineConverter = new EmptyLineConverterV2();
                    content.Add(emptyLineConverter.Convert());
                }
            }

            foreach (var author in epigraphItem.TextAuthors)
            {
                var epigraphAuthorConverter = new EpigraphAuthorConverterV2();
                content.Add(epigraphAuthorConverter.Convert(author as TextAuthorItem, new EpigraphAuthorConverterParamsV2 {
                    Settings = epigraphConverterParams.Settings
                }));
            }

            SetClassType(content, ElementStylesV2.PoemEpigraph);

            content.GlobalAttributes.ID.Value = epigraphConverterParams.Settings.ReferencesManager.AddIdUsed(epigraphItem.ID, content);

            return(content);
        }
        /// <summary>
        /// Converts FB2 epigraph element
        /// </summary>
        /// <param name="epigraphItem"></param>
        /// <param name="epigraphConverterParams"></param>
        /// <returns>XHTML representation</returns>
        public Div Convert(EpigraphItem epigraphItem,EpigraphConverterParamsV2 epigraphConverterParams)
        {
            if (epigraphItem == null)
            {
                throw new ArgumentNullException("epigraphItem");
            }
            var content = new Div(HTMLElementType.XHTML11);

            foreach (var element in epigraphItem.EpigraphData)
            {
                if (element is ParagraphItem)
                {
                    var paragraphConverter = new ParagraphConverterV2();
                    content.Add(paragraphConverter.Convert(element as ParagraphItem,
                        new ParagraphConverterParamsV2 {ResultType = ParagraphConvTargetEnumV2.Paragraph , Settings = epigraphConverterParams.Settings, StartSection = false}));
                }
                if (element is PoemItem)
                {
                    var poemConverter = new PoemConverterV2();
                    content.Add(poemConverter.Convert(element as PoemItem,
                        new PoemConverterParamsV2 { Level = epigraphConverterParams.Level + 1 ,Settings = epigraphConverterParams.Settings}
                        ));
                }
                if (element is CiteItem)
                {
                    var citationConverter = new CitationConverterV2();
                    content.Add(citationConverter.Convert(element as CiteItem,
                        new CitationConverterParamsV2 { Level = epigraphConverterParams.Level + 1,Settings = epigraphConverterParams.Settings}));
                }
                if (element is EmptyLineItem)
                {
                    var emptyLineConverter = new EmptyLineConverterV2();
                    content.Add(emptyLineConverter.Convert());
                }
            }

            foreach (var author in epigraphItem.TextAuthors)
            {
                var epigraphAuthorConverter = new EpigraphAuthorConverterV2();
                content.Add(epigraphAuthorConverter.Convert(author as TextAuthorItem,  new EpigraphAuthorConverterParamsV2 { Settings = epigraphConverterParams.Settings }));
            }

            SetClassType(content, ElementStylesV2.Epigraph);

            content.GlobalAttributes.ID.Value = epigraphConverterParams.Settings.ReferencesManager.AddIdUsed(epigraphItem.ID, content);

            return content;
        }