Beispiel #1
0
        public override void InsertCss(CssData cssData)
        {
            string color = Color;

            if (color != null)
            {
                cssData.AddAttribute(Selector, "color", color);
            }
        }
Beispiel #2
0
        public override void InsertCss(CssData cssData)
        {
            short i = JustifyContent;

            if (i != EMPTY)
            {
                cssData.AddAttribute(Selector, "text-align", MapJusitfyValues[i]);
            }
        }
Beispiel #3
0
        public override void InsertCss(CssData cssData)
        {
            var i = GetColorCode(Element);

            if (i > -1)
            {
                cssData.AddAttribute(Selector, "background-color", ColorAssociation[i]);
            }
        }
Beispiel #4
0
        public void AsCss_SimpleTest()
        {
            var expected = new CssData();

            expected.AddAttribute("span.test", "text-decoration", "underline solid");

            var data = _instance.AsCss();

            Assert.AreEqual(expected, data);
        }
Beispiel #5
0
        public void AsCss_Test()
        {
            var expectedCssData = new CssData();

            expectedCssData.AddAttribute("span.test-cls", "font-weight", "bold");

            var css = _instance.AsCss();

            Assert.AreEqual(expectedCssData, css);
        }
Beispiel #6
0
        public void RenderInto_MediaQueryTest()
        {
            string mq          = "(max-width: 21.59cm)";
            string expectedCss =
                @"@media (max-width: 21.59cm) { .test {color: blue;font-weigth: light;}p {color: red;font-weigth: bold;} }";
            var cssData = new CssData();

            cssData.AddAttribute(mq, "p", "font-weigth", "bold");
            cssData.AddAttribute(mq, "p", "color", "red");
            cssData.AddAttribute(mq, ".test", "font-weigth", "light");
            cssData.AddAttribute(mq, ".test", "color", "blue");

            var sb = new StringBuilder();

            cssData.RenderInto(sb);
            var result = sb.ToString().Trim();

            Assert.AreEqual(expectedCss, result);
        }
Beispiel #7
0
 private void AddWidthCss(CssData cssData)
 {
     if (Width > 0)
     {
         cssData.AddAttribute(
             CssTableSelector,
             "width",
             $"{Math.Round(WidthCmValue, 2)}cm"
             );
     }
 }
Beispiel #8
0
        public void SetOff_Test()
        {
            var data         = new CssData();
            var expectedData = new CssData();

            expectedData.AddAttribute("span.test", "font-style", "normal");

            _instance.SetOff(data);

            Assert.AreEqual(expectedData, data);
        }
Beispiel #9
0
        public void AsCss_ValNoneTest()
        {
            var expected = new CssData();

            expected.AddAttribute("span.test", "text-decoration", "underline solid white");
            _instance.Element.Val = UnderlineValues.None;

            var data = _instance.AsCss();

            Assert.AreEqual(expected, data);
        }
Beispiel #10
0
        public void SetOn_Test()
        {
            var expected = new CssData();

            expected.AddAttribute("span.test", "font-variant", "small-caps");
            var data = new CssData();

            _instance.SetOn(data);

            Assert.AreEqual(expected, data);
        }
Beispiel #11
0
        public void AsCss_ValColorNameTest()
        {
            var expectedCss = new CssData();

            expectedCss.AddAttribute("p", "color", "red");
            _instance.Element.Val = new StringValue("red");

            var result = _instance.AsCss();

            Assert.AreEqual(expectedCss, result);
        }
Beispiel #12
0
        public void AsCss_ValDefaultTest()
        {
            var expected = new CssData();

            expected.AddAttribute("span.test", "text-decoration", "none");
            _instance.Element.Color = new StringValue("FF00FF");

            var data = _instance.AsCss();

            Assert.AreEqual(expected, data);
        }
Beispiel #13
0
        public void AsCss_SimpleTest()
        {
            var expected = new CssData();

            _instance.Element.Val = new EnumValue <UnderlineValues>(UnderlineValues.Single);
            expected.AddAttribute("span.test", "text-decoration", "underline solid");

            var data = _instance.AsCss();

            Assert.AreEqual(expected, data);
        }
Beispiel #14
0
        public void AsCss_ColorTest()
        {
            var expected = new CssData();

            expected.AddAttribute("span.test", "text-decoration", "underline wavy #FFFF00");
            _instance.Element.Val   = new EnumValue <UnderlineValues>(UnderlineValues.Wave);
            _instance.Element.Color = new StringValue("FFFF00");

            var data = _instance.AsCss();

            Assert.AreEqual(expected, data);
        }
Beispiel #15
0
        public void AsCss_ThemeColorNameTest()
        {
            var expectedCss = new CssData();

            expectedCss.AddAttribute("p", "color", "red");
            _themeColorProvider.GetColor(ThemeColorValues.Accent1).Returns("red");
            _instance.Element.ThemeColor = new DocumentFormat.OpenXml.EnumValue <ThemeColorValues>(ThemeColorValues.Accent1);

            var result = _instance.AsCss();

            Assert.AreEqual(expectedCss, result);
        }
Beispiel #16
0
        public void AssCss_OffTest()
        {
            var expectedCssData = new CssData();

            expectedCssData.AddAttribute("span.test-cls", "text-transform", "lowercase");

            var cssData = new CssData();

            _instance.SetOff(cssData);

            Assert.AreEqual(expectedCssData, cssData);
        }
Beispiel #17
0
        public void Equals_TrueTest()
        {
            var cssData1 = new CssData();

            cssData1.AddAttribute("span", "color", "red");

            var cssData2 = new CssData();

            cssData2.AddAttribute("span", "color", "red");

            Assert.AreEqual(cssData1, cssData2);
        }
Beispiel #18
0
        public CssData AsCssData()
        {
            var cssData = new CssData();

            cssData.AddAttribute(CssTableSelector, "display", "grid");
            //AddGridTemplateColumns(cssData);
            AddJustificationCss(cssData);
            AddBorderCss(cssData);
            AddGridCellCss(cssData);
            AddWidthCss(cssData);
            return(cssData);
        }
Beispiel #19
0
        public void AsCssData_Test()
        {
            var prop1CssData = new CssData();

            prop1CssData.AddAttribute(".test", "color", "red");
            prop1CssData.AddAttribute(".test", "", "red");
            var prop1 = Substitute.For <ICssProperty>();

            prop1
            .When(x => x.InsertCss(Arg.Any <CssPropertiesSet>(), Arg.Any <CssData>()))
            .Do(x => x.ArgAt <CssData>(1).AddRange(prop1CssData));

            _instance.Add(prop1);
            _instance.Selector = ".test";
            var r = new CssData();

            _instance.InsertCss(r);

            Assert.AreEqual(prop1CssData, r);
            prop1.Received(1).Selector = ".test";
        }
Beispiel #20
0
        public void InsertCss_Test()
        {
            MockCssProps();
            var expected = new CssData();

            expected.AddAttribute(".some-class", "color", "red");

            var cssData = new CssData();

            _instance.InsertCss(cssData);

            Assert.AreEqual(expected, cssData);
        }
Beispiel #21
0
        public void AddRange_Test()
        {
            var expected = new CssData();

            expected.AddAttribute("span", "color", "red");
            expected.AddAttribute("span", "font", "bold");
            expected.AddAttribute("p", "margin-top", "20px");

            var cssData1 = new CssData();

            cssData1.AddAttribute("span", "color", "blue");
            cssData1.AddAttribute("span", "font", "bold");

            var cssData2 = new CssData();

            cssData2.AddAttribute("span", "color", "red");
            cssData2.AddAttribute("p", "margin-top", "20px");

            cssData1.AddRange(cssData2);

            Assert.AreEqual(expected, cssData1);
        }
Beispiel #22
0
        public void AsCss_OffTest()
        {
            _instance.Element = new Bold {
                Val = new OnOffValue(false)
            };
            var expectedCssData = new CssData();

            expectedCssData.AddAttribute("span.test-cls", "font-weight", "normal");

            var css = _instance.AsCss();

            Assert.AreEqual(expectedCssData, css);
        }
Beispiel #23
0
        public void AsCss_ThemeColorTest()
        {
            var expected = new CssData();

            expected.AddAttribute("span.test", "text-decoration", "underline dashed #000000");
            _themeColorProvider.GetColor(Arg.Is(ThemeColorValues.Dark1)).Returns("000000");
            _instance.Element.Val        = new EnumValue <UnderlineValues>(UnderlineValues.DashedHeavy);
            _instance.Element.Color      = new StringValue("FFFFFF");
            _instance.Element.ThemeColor = new EnumValue <ThemeColorValues>(ThemeColorValues.Dark1);

            var data = _instance.AsCss();

            Assert.AreEqual(expected, data);
        }
Beispiel #24
0
        public void InsertCss_SpacingPctTest()
        {
            var expected = new CssData();

            expected.AddAttribute(".test", "margin-left", "2%");
            _instance = new BorderState
            {
                Spacing     = 2f,
                SpacingType = WUV.Pct
            };

            _instance.InsertCss(_prefix, 3, _cssData);

            Assert.AreEqual(expected, _cssData);
        }
Beispiel #25
0
        public void SetOn_Test()
        {
            var expected = new CssData();

            expected.AddAttribute(".test", "display", "none");
            var instance = new SpecVanishCssProperty {
                Selector = ".test"
            };

            var cssData = new CssData();

            instance.SetOn(cssData);

            Assert.AreEqual(expected, cssData);
        }
Beispiel #26
0
        private void AddGridTemplateColumns(CssData cssData)
        {
            string[] columns = new string[_width.Count];
            int      i       = 0;

            foreach (int k in _width.Keys.OrderBy(x => x))
            {
                var val = Utils.TwipsToCm(_width[k]);
                columns[i] = val + "cm";
                i++;
            }
            string gridTemplateColumns = string.Join(" ", columns);

            cssData.AddAttribute(CssTableSelector, "grid-template-columns", gridTemplateColumns);
        }
Beispiel #27
0
        public void InsertCss_MarginDxaTest()
        {
            var expected = new CssData();

            expected.AddAttribute(".test", "padding-top", "10.5pt");
            _instance = new BorderState
            {
                Margin     = 10.5f,
                MarginType = WUV.Dxa
            };

            _instance.InsertCss(_prefix, 0, _cssData);

            Assert.AreEqual(expected, _cssData);
        }
Beispiel #28
0
        public void InsertCss_MarginPctTest()
        {
            var expected = new CssData();

            expected.AddAttribute(".test", "padding-right", "5%");
            _instance = new BorderState
            {
                Margin     = 5f,
                MarginType = WUV.Pct
            };

            _instance.InsertCss(_prefix, 1, _cssData);

            Assert.AreEqual(expected, _cssData);
        }
Beispiel #29
0
        public void InsertCss_Test()
        {
            var expected = new CssData();

            expected.AddAttribute("span", "color", "red");
            expected.AddAttribute("p", "border", "1px solid black");

            var cls1 = new CssClass
            {
                Props = new CssPropertiesSet {
                    new MockProp1 {
                        Out = ("span", "color", "red")
                    }
                }
            };
            var cls2 = new CssClass
            {
                Props = new CssPropertiesSet
                {
                    new MockProp2 {
                        Out = ("p", "border", "1px solid black")
                    }
                }
            };

            _runClassFactory.Build(Arg.Any <RunClassParam>()).Returns(cls1);
            _paragraphClassFactory.Build(Arg.Any <ParagraphClassParam>()).Returns(cls2);
            _instance.RegisterRun(BuildPPr(), BuildRPr());
            _instance.RegisterParagraph(BuildPPr());

            var cssData = new CssData();

            _instance.InsertCss(cssData);

            Assert.AreEqual(expected, cssData);
        }
Beispiel #30
0
        public void InsertCss_SpacingDxaTest()
        {
            var expected = new CssData();

            expected.AddAttribute(".test", "margin-bottom", "0.2pt");
            _instance = new BorderState
            {
                Spacing     = 0.2f,
                SpacingType = WUV.Dxa
            };

            _instance.InsertCss(_prefix, 2, _cssData);

            Assert.AreEqual(expected, _cssData);
        }