Ejemplo n.º 1
0
        private bool ProcessModifiedRun(IElementProcessingState state, OpenXmlElement modifedRun, string cssClass)
        {
            var vNode = new VNode("span", "", state.Index, modifedRun.InnerText.Length);

            vNode.AddClasses(cssClass);
            state.AddContent(vNode);
            state.CurrentVNode = vNode;
            return(true);
        }
Ejemplo n.º 2
0
        private static void SetErrorNode(IElementProcessingState state)
        {
            var messageNode = new VNode("div", "Error processing table", state.Index);

            messageNode.VOffsets.Add(new VTextOffset
            {
                Index = state.Index,
                Delta = messageNode.Text.Length
            });
            messageNode.SetStyle("color", "red");
            state.AddContent(messageNode);
        }
Ejemplo n.º 3
0
        private void TryAddTable(IElementProcessingState state, Table table)
        {
            if (!state.GetContext(out TableContext tc))
            {
                tc = new TableContext();
                tc.GridStateFactory = GridStateFactory;
                state.SetContext(tc);
            }
            var grid = tc.AddTable(table, state.Index);

            state.AddContent(grid.VNode);
            state.CurrentVNode = grid.VNode;
        }
Ejemplo n.º 4
0
        public bool ProcessElement(IElementProcessingState state, Run run)
        {
            var vSpan = new VNode
            {
                Tag    = _config.RunTag,
                Index  = state.Index,
                Length = run.InnerText.Length
            };

            vSpan.AddClasses(_config.RunCls);
            state.AddContent(vSpan);
            state.CurrentVNode = vSpan;
            return(true);
        }
Ejemplo n.º 5
0
        public bool ProcessElement(IElementProcessingState state, Hyperlink anchor)
        {
            var vAnchor = new VNode
            {
                Tag    = _config.HyperLinkTag,
                Index  = state.Index,
                Length = anchor.InnerText.Length
            };

            vAnchor.AddClasses(_config.HyperLinkCls);
            state.AddContent(vAnchor);
            state.CurrentVNode = vAnchor;
            return(true);
        }
Ejemplo n.º 6
0
        public bool ProcessElement(IElementProcessingState state, Paragraph paragraph)
        {
            if (!(paragraph.Parent is Body))
            {
                var container = new VNode("div");
                container.AddClasses("container");
                state.AddContent(container);
                state.CurrentVNode = container;
            }
            var vP = new VNode {
                Tag = _config.ParagraphTag
            };

            vP.Index  = state.Index;
            vP.Length = paragraph.InnerText.Length;
            vP.Text   = "​"; // zero width white psace
            vP.AddClasses(_config.ParagraphCls);
            state.SetContext(new ParagraphContext {
                Parent = state.CurrentVNode
            });
            state.AddContent(vP);
            state.CurrentVNode = vP;
            return(true);
        }
Ejemplo n.º 7
0
 private void InsertBreak(IElementProcessingState state)
 {
     if (state.Index == 0 &&
         state.GetContext(out ParagraphContext c))
     {
         c.Parent.AddClasses(_config.BreakAtStartCssCls);
     }
     else
     {
         state.AddContent(new VNode
         {
             Index  = state.Index,
             Length = 0,
             Tag    = "br"
         });
     }
 }