Exemple #1
0
        public void RunCLassParam_CstrTest()
        {
            var instance = new RunClassParam();

            Assert.IsNull(instance.ParagraphStyleId);
            Assert.IsNull(instance.RunStyleId);
            Assert.IsNull(instance.NumberingId);
            Assert.IsNull(instance.NumberingLevel);
            Assert.IsNull(instance.InlineProperties);
        }
Exemple #2
0
        public void RunCLassParam_PrpCstrTest()
        {
            var rPr      = new RunProperties();
            var instance = new RunClassParam(rPr);

            Assert.AreSame(rPr, instance.InlineProperties);
            Assert.IsNull(instance.RunStyleId);
            Assert.IsNull(instance.ParagraphStyleId);
            Assert.IsNull(instance.NumberingId);
            Assert.IsNull(instance.NumberingLevel);
        }
Exemple #3
0
        public bool ProcessRun(IElementProcessingState state, Run run)
        {
            if (!state.ProcessingState.GetContext(out ICssRegistrator registrator))
            {
                return(false);
            }
            RunClassParam param    = BuildRunCssParam(state, run);
            CssClass      cssClass = registrator.RegisterRun(param);

            state.CurrentVNode.AddClasses(cssClass.Name);

            return(false);
        }
Exemple #4
0
        public void RegisterRun_NewTest()
        {
            var output = new CssClass();
            var param  = new RunClassParam();

            _runClassFactory
            .Build(Arg.Any <RunClassParam>())
            .Returns(output);

            var result = _instance.RegisterRun(param);

            Assert.AreSame(result, output);
        }
Exemple #5
0
        private void AssertRegisterRunCls(RunClassParam expected)
        {
            var param = _cssRegistrator
                        .ReceivedCalls()
                        .Where(x => x.GetMethodInfo().Name == "RegisterRun")
                        .Single()
                        .GetArguments()[0] as RunClassParam;

            Assert.AreSame(expected.InlineProperties, param.InlineProperties);
            Assert.AreSame(expected.TableProperties, param.TableProperties);
            Assert.AreEqual(expected.ParagraphStyleId, param.ParagraphStyleId);
            Assert.AreEqual(expected.NumberingId, param.NumberingId);
            Assert.AreEqual(expected.NumberingLevel, param.NumberingLevel);
        }
Exemple #6
0
        public void RunCLassParam_PrpStyleIdCstrTest()
        {
            var rPr = new RunProperties
            {
                RunStyle = new RunStyle
                {
                    Val = "test"
                }
            };
            var instance = new RunClassParam(rPr);

            Assert.AreSame(rPr, instance.InlineProperties);
            Assert.AreEqual("test", instance.RunStyleId);
            Assert.IsNull(instance.ParagraphStyleId);
            Assert.IsNull(instance.NumberingId);
            Assert.IsNull(instance.NumberingLevel);
        }
Exemple #7
0
        private static RunClassParam BuildRunCssParam(
            IElementProcessingState state,
            Run run)
        {
            var rPr   = run.RunProperties;
            var param = new RunClassParam(rPr);

            state.GetContext(out ParagraphProperties paragraphProperties);
            param.ParagraphStyleId = paragraphProperties?.ParagraphStyleId?.Val?.Value;
            if (state.GetContext(out TableContext tableContext))
            {
                var tableCell = run.Ancestors <TableCell>().FirstOrDefault();
                if (tableCell != null)
                {
                    var cellState = tableContext.GetCell(tableCell);
                    param.TableProperties = cellState?.RunProperties;
                }
            }
            return(param);
        }