コード例 #1
0
 private void AddTableStyle(CssClass cssClass, List <OpenXmlElement> tableProperties)
 {
     if (tableProperties == null || tableProperties.Count == 0)
     {
         return;
     }
     for (int i = tableProperties.Count - 1; i >= 0; i--)
     {
         var cssPropSet = _propsFac.Build(tableProperties[i]);
         cssClass.Props.AddMany(cssPropSet);
     }
 }
コード例 #2
0
 private void AddTableProps(List <OpenXmlElement> tableProperties, CssClass cssClass)
 {
     if (tableProperties == null || tableProperties.Count == 0)
     {
         return;
     }
     for (int i = tableProperties.Count - 1; i >= 0; i--)
     {
         var elem  = tableProperties[i];
         var props = _propsFac.Build(elem);
         AddOrSet(cssClass, props);
     }
 }
コード例 #3
0
        public void Paragraph_SomeTest()
        {
            var expected = new CssPropertiesSet {
                new MockProp1()
            };

            _propsFac
            .Build(Arg.Is(PDefaults))
            .Returns(expected);

            var result = _instance.Paragraph;

            Assert.IsTrue(expected.Equals(result));
        }
コード例 #4
0
 private CssPropertiesSet BuildInline(OpenXmlElement pPr)
 {
     if (pPr == null)
     {
         return(new CssPropertiesSet());
     }
     return(_propsFac.Build(pPr));
 }
コード例 #5
0
 public override CssPropertiesSet BuildProps(WStyle style)
 {
     if (style.StyleParagraphProperties != null)
     {
         return(_propsFac.Build(style.StyleParagraphProperties));
     }
     return(new CssPropertiesSet());
 }
コード例 #6
0
        public void Build_DyncPropsTest()
        {
            var rPr   = new RunProperties();
            var props = new CssPropertiesSet
            {
                new MockProp1(),
                new MockProp2()
            };

            _propsFac.Build(Arg.Is(rPr)).Returns(props);

            var result = _instance.Build(new RunClassParam
            {
                InlineProperties = rPr
            });

            Utils.AssertDynamicClass(_config, result);
            Assert.IsTrue(props.Equals(result.Props));
        }
コード例 #7
0
        public void Build_DynFromPropsTest()
        {
            var pPr   = new ParagraphProperties();
            var props = new CssPropertiesSet
            {
                new MockProp1(),
                new MockProp2()
            };

            _propsFac.Build(Arg.Is(pPr)).Returns(props);

            var result = _instance.Build(new ParagraphClassParam
            {
                InlineProperties = pPr
            });

            Utils.AssertDynamicClass(_nameGen.Prefix, result);
            Assert.IsTrue(props.Equals(result.Props));
        }
コード例 #8
0
        public override CssPropertiesSet BuildPropertiesSet(Level arg)
        {
            if (arg.NumberingSymbolRunProperties == null)
            {
                return(new CssPropertiesSet());
            }

            var set = new CssPropertiesSet();

            set.AddMany(_propsFac.Build(arg.NumberingSymbolRunProperties));
            return(set);
        }
コード例 #9
0
        private CssPropertiesSet MockFactory(
            string styleId,
            params ICssProperty[] props)
        {
            var style = _styles.First(x => x.StyleId == styleId);
            var set   = new CssPropertiesSet(props);

            _propsFac
            .Build(style)
            .Returns(set);
            return(set);
        }
コード例 #10
0
        public override CssPropertiesSet BuildPropertiesSet(Level arg)
        {
            if (arg.PreviousParagraphProperties == null)
            {
                return(new CssPropertiesSet());
            }

            var set = new CssPropertiesSet();

            set.AddMany(_propsFac.Build(arg.PreviousParagraphProperties));
            return(set);
        }
コード例 #11
0
        private CssPropertiesSet BuildInline(OpenXmlElement rProps)
        {
            var set = new CssPropertiesSet();

            if (rProps == null)
            {
                return(set);
            }
            var props = _propsFac.Build(rProps);

            set.AddMany(props);
            return(set);
        }
コード例 #12
0
        public void Run_SomeTest()
        {
            var expected = new CssPropertiesSet {
                new MockProp1()
            };

            _rPropsFac
            .Build(Arg.Is(RDefaults()))
            .Returns(expected);

            var result = _instance.Run;

            Assert.IsTrue(expected.Equals(result));
        }
コード例 #13
0
        public void BuildPropsSet_Test()
        {
            var props = new CssPropertiesSet {
                new MockProp1()
            };
            var level = new Level {
                PreviousParagraphProperties = new PreviousParagraphProperties()
            };

            _propsFac
            .Build(Arg.Is(level.PreviousParagraphProperties))
            .Returns(props);

            var result = _instance.BuildPropertiesSet(level);

            Assert.AreSame(props.Single(), result.Single());
        }
コード例 #14
0
        public void BuildPropsSet_Test()
        {
            var props = new CssPropertiesSet {
                new MockProp1()
            };
            var level = new Level {
                NumberingSymbolRunProperties = new NumberingSymbolRunProperties()
            };

            _propsFac
            .Build(Arg.Is(level.NumberingSymbolRunProperties))
            .Returns(props);

            var result = _instance.BuildPropertiesSet(level);

            Assert.AreSame(props.Single(), result.Single());
        }
コード例 #15
0
        public void Initialize()
        {
            _config   = new StyleConfig();
            _defaults = Substitute.For <IDefaultsProvider>();
            _defaults.Run.Returns(new CssPropertiesSet());
            _pStylePropsCache = Substitute.For <IStylePropsCache>();
            _numPropsCache    = Substitute.For <INumberingPropsCache>();
            _rStylePropsCache = Substitute.For <IStylePropsCache>();
            _rStylePropsCache.Get(Arg.Any <string>()).Returns(new CssPropertiesSet());
            _propsFac = Substitute.For <ICssPropertiesFactory>();
            _propsFac.Build(null).ReturnsForAnyArgs(x => new CssPropertiesSet());

            _instance = new RunClassFactory(
                _config,
                new ClsNameGenerator(_config),
                _defaults,
                _pStylePropsCache,
                _numPropsCache,
                _rStylePropsCache,
                FacBuilder);
        }
コード例 #16
0
 public void Initialize()
 {
     _propsFac = Substitute.For <ICssPropertiesFactory>();
     _propsFac
     .Build(Arg.Any <OpenXmlElement>())
     .ReturnsForAnyArgs(x => new CssPropertiesSet());
     _stylePropsCache = Substitute.For <IStylePropsCache>();
     _stylePropsCache.Get(Arg.Any <string>())
     .Returns(new CssPropertiesSet());
     _numPropsCache = Substitute.For <INumberingPropsCache>();
     _defaults      = Substitute.For <IDefaultsProvider>();
     _defaults.Paragraph.Returns(new CssPropertiesSet());
     _nameGen = new NameGenerator()
     {
         Prefix = "d"
     };
     _instance = new ParagraphClassFactory(
         _nameGen,
         _defaults,
         _stylePropsCache,
         _numPropsCache,
         _propsFac);
 }
コード例 #17
0
 public void Initialize()
 {
     _defaults = Substitute.For <IDefaultsProvider>();
     _defaults.Run.Returns(new CssPropertiesSet());
     _defaults.DefaultRunStyle.Returns(x => null);
     _defaults.DefaultParagraphStyle.Returns(x => null);
     _pStylePropsCache = Substitute.For <IStylePropsCache>();
     _numPropsCache    = Substitute.For <INumberingPropsCache>();
     _rStylePropsCache = Substitute.For <IStylePropsCache>();
     _rStylePropsCache.Get(Arg.Any <string>()).Returns(new CssPropertiesSet());
     _propsFac = Substitute.For <ICssPropertiesFactory>();
     _propsFac.Build(null).ReturnsForAnyArgs(x => new CssPropertiesSet());
     _nameGen = new NameGenerator()
     {
         Prefix = "d"
     };
     _instance = new RunClassFactory(
         _nameGen,
         _defaults,
         _pStylePropsCache,
         _numPropsCache,
         _rStylePropsCache,
         _propsFac);
 }
コード例 #18
0
 public override CssPropertiesSet BuildProps(WStyle style) =>
 _propsFac.Build(style);