private HtmlNode BuildNumberingNumber( Paragraph p, IParagraphData paragraphData) { var node = new HtmlNode { Start = PositionWithDelta(1), End = PositionWithDelta(2), Tag = _config.NumberingNumberTag, Z = _config.NumberingNumberZ, TextPrefix = paragraphData.Verbose }; node.AddClasses(_config.NumberingNumberCls); var level = paragraphData.LevelXmlElement; if (level.LevelSuffix?.Val?.Value == LevelSuffixValues.Space) { node.SetStyle("padding-right", "0.5em"); } else if (level.LevelSuffix?.Val?.Value == LevelSuffixValues.Nothing) { } else { node.SetStyle("padding-right", "1.5em"); } return(node); }
private void MockElementContext(int numberingId, int levelId, string verbose) { _p = new Paragraph(); _pData = Substitute.For <IParagraphData>(); _pData.NumberingId.Returns(numberingId); _pData.LevelIndex.Returns(levelId); _pData.Verbose.Returns(verbose); _pData.LevelXmlElement.Returns(_level); _nMapper = Substitute.For <INumberingMapper>(); _nMapper.IsValid.Returns(true); _nMapper.GetNumbering(_p).Returns(_pData); _cssRegistrator = Substitute.For <ICssRegistrator>(); _cssRegistrator .RegisterRun(Arg.Any <ParagraphProperties>(), Arg.Any <RunProperties>(), (numberingId, levelId)) .Returns(new CssClass { Name = $"dynamic-cls" }); _elementContext = Substitute.For <IElementContext>(); _elementContext.Resolve <INumberingMapper>().Returns(_nMapper); _elementContext.TryResolve(out ICssRegistrator z).Returns(x => { x[0] = _cssRegistrator; return(true); }); _elementContext.Element.Returns(_p); _elementContext.RootElement.Returns(_p); _elementContext .When(x => x.AddNode(Arg.Any <HtmlNode>())) .Do(x => _nodes.Add(x.ArgAt <HtmlNode>(0))); _elementContext .When(x => x.AddMutation(Arg.Any <Mutation>())) .Do(x => _mutations.Add(x.ArgAt <Mutation>(0))); }
private void MockCurrent() { _currentVerbose = "1.1"; _current = Substitute.For <IParagraphData>(); _current.NumberingId.Returns(1); _current.LevelIndex.Returns(1); _current.LevelXmlElement.Returns(new Level()); _current.Verbose.Returns(_ => _currentVerbose); _current.Location.Returns("1"); }
private void MockPrevious() { _previousVerbose = "1.1"; _previous = Substitute.For <IParagraphData>(); _previous.NumberingId.Returns(2); _previous.LevelIndex.Returns(2); _previous.LevelXmlElement.Returns(new Level()); _previous.Verbose.Returns(_ => _previousVerbose); _previous.Location.Returns("2"); }
private void AddNumberingNumberValue(VNode numberingNumber, IParagraphData pData) { var span = new VNode("span", pData.Verbose); if (span.Text.Length == 0) { span.Text = ""; } numberingNumber.VLayers[0].Content.Add(span); }
private VNode BuildNumberingNumber(IParagraphData pData) { var numberingNumber = new VNode(_config.NumberingNumberTag); numberingNumber.AddClasses(_config.NumberingNumberCls); AddPadding(numberingNumber, pData); AddTrackChanges(numberingNumber, pData); AddNumberingNumberValue(numberingNumber, pData); return(numberingNumber); }
private void MockElementContext(int numberingId, int levelId, string verbose, TrackChangesFlag flag = TrackChangesFlag.Untouched, string previousVerbose = null) { _p = new Paragraph(); _pData = Substitute.For <IParagraphData>(); _pData.NumberingId.Returns(numberingId); _pData.LevelIndex.Returns(levelId); _pData.Verbose.Returns(verbose); _pData.LevelXmlElement.Returns(_level); _pData.PreviousVerbose.Returns(previousVerbose); _pData.TrackChangesFlag.Returns(flag); _numberingMapper.IsValid.Returns(true); _numberingMapper.GetNumbering(_p).Returns(_pData); }
private HtmlNode BuildNumberingNumber( Paragraph p, ICssRegistrator cssRegistrator, IParagraphData paragraphData) { var node = BuildNumberingNumber(p, paragraphData); var cssClass = cssRegistrator.RegisterRun( p.ParagraphProperties, p.ParagraphProperties?.ParagraphMarkRunProperties, (paragraphData.NumberingId, paragraphData.LevelIndex)); node.AddClasses(cssClass.Name); return(node); }
private static void AddPadding(VNode numberingNumber, IParagraphData pData) { var level = pData.LevelXmlElement; if (level.LevelSuffix?.Val?.Value == LevelSuffixValues.Space) { numberingNumber.SetStyle("padding-right", "0.5em"); } else if (level.LevelSuffix?.Val?.Value == LevelSuffixValues.Nothing) { } else { numberingNumber.SetStyle("padding-right", "1.5em"); } }
private void AddTrackChanges(VNode numberingNumber, IParagraphData pData) { switch (pData.TrackChangesFlag) { case TrackChanges.TrackChangesFlag.Inserted: numberingNumber.AddClasses(_config.NumberingInsertedCls); break; case TrackChanges.TrackChangesFlag.Deleted: numberingNumber.AddClasses(_config.NumberingDeletedCls); break; case TrackChanges.TrackChangesFlag.Changed: var previousNumberingNumber = new VNode(_config.NumberingNumberTag, pData.PreviousVerbose); previousNumberingNumber.AddClasses(_config.PreviousNumberingNumber); numberingNumber.VLayers[0].Content.Add(previousNumberingNumber); numberingNumber.AddClasses(_config.NumberingChangedCls); break; default: break; } }