Пример #1
0
        private Paragraph ConvertParagraphBlock(ParagraphBlock paragraphBlock, int numberingId, int nestLevel)
        {
            var inlineConverter    = new InlineConverter(Manipulator, UserSettingStyleMap, BaseFolderPathForRelativePath);
            var oxmlInlineElements = inlineConverter.Convert(paragraphBlock.Inline);

            var styleId       = UserSettingStyleMap.GetStyleId(UserSettingStyleMap.StyleMapKeyType.Paragraph, null);
            var oxmlParagraph = Manipulator.ElementCreator.CreateParagraphElement(oxmlInlineElements, styleId, numberingId, nestLevel);

            Manipulator.AdjustImageDimension(oxmlParagraph);

            return(oxmlParagraph);
        }
Пример #2
0
        private Paragraph ConvertHeadingBlock(HeadingBlock headingBlock)
        {
            var inlineConverter    = new InlineConverter(Manipulator, UserSettingStyleMap, BaseFolderPathForRelativePath);
            var oxmlInlineElements = inlineConverter.Convert(headingBlock.Inline);

            var styleId = UserSettingStyleMap.GetStyleId(UserSettingStyleMap.StyleMapKeyType.Heading, new UserSettingStyleMap.HeadingStyleMapArgs()
            {
                Level = headingBlock.Level
            });
            var oxmlHeading = Manipulator.ElementCreator.CreateHeadingElement(oxmlInlineElements, styleId);

            Manipulator.AdjustImageDimension(oxmlHeading);

            return(oxmlHeading);
        }
Пример #3
0
        private OpenXmlElement[] ConvertQuoteBlock(QuoteBlock quoteBlock, int numberingId, int nestLevel)
        {
            var styleId = UserSettingStyleMap.GetStyleId(UserSettingStyleMap.StyleMapKeyType.Quote, null);

            var oxmlElements = new List <OpenXmlElement>();

            foreach (var block in quoteBlock)
            {
                switch (block)
                {
                case ParagraphBlock paragraphBlock:
                    var oxmlParagraph      = ConvertParagraphBlock(paragraphBlock, WordDocumentNumberingManager.OutsideOfListNumberingId, 0);
                    var oxmlQuoteParagraph = Manipulator.ElementCreator.CreateQuoteElement(oxmlParagraph, styleId, numberingId, nestLevel);

                    Manipulator.AdjustImageDimension(oxmlQuoteParagraph);

                    oxmlElements.Add(oxmlQuoteParagraph);
                    break;

                case ListBlock listBlock:
                    var oxmlListItems = ConvertListBlock(listBlock, WordDocumentNumberingManager.OutsideOfListNumberingId, 0);
                    foreach (var oxmlListItem in oxmlListItems)
                    {
                        if (oxmlListItem.GetType() == typeof(Paragraph))
                        {
                            var oxmlListItemParagraph      = (Paragraph)oxmlListItem;
                            var oxmlListItemQuoteParagraph = Manipulator.ElementCreator.CreateQuoteElement(oxmlListItemParagraph, styleId, numberingId, nestLevel);

                            Manipulator.AdjustImageDimension(oxmlListItemQuoteParagraph);

                            oxmlElements.Add(oxmlListItemQuoteParagraph);
                        }
                    }
                    break;

                default:
                    throw new NotImplementedException(string.Format("Unknown block type within the quote block: {0}", block.GetType().FullName));
                }
            }

            return(oxmlElements.ToArray());
        }