Esempio n. 1
0
        public void ConstructorSeparatesPartsOfTheName()
        {
            Document     doc     = new Document();
            var          slide   = new SlideElement(doc);
            ChartElement element = ChartElement.Create(@"TEST_1[""column 1"", 4, 6][2, 4, ""row 1""] FORMAT{""##,#"", ""de-DE""} FIXED LEGEND_FROM{1} SORT{2, ASC} FORMULA{""[column 2] - [column 1]""}", null, slide);

            Assert.AreEqual(@"TEST_1[""column 1"", 4, 6][2, 4, ""row 1""] FORMAT{""##,#"", ""de-DE""} FIXED LEGEND_FROM{1} SORT{2, ASC} FORMULA{""[column 2] - [column 1]""}", element.FullName);
            Assert.AreEqual("TEST_1", element.Name);
            Assert.AreEqual(@"""column 1"", 4, 6", element.DataDescriptor.ColumnIndexesString);
            Assert.AreEqual(@"2, 4, ""row 1""", element.DataDescriptor.RowIndexesString);
            Assert.AreEqual(@"FORMAT{""##,#"", ""de-DE""} FIXED LEGEND_FROM{1} SORT{2, ASC} FORMULA{""[column 2] - [column 1]""}", element.CommandString);
        }
Esempio n. 2
0
        public virtual void DiscoverShapes()
        {
            var shapes = Slide.Descendants <DocumentFormat.OpenXml.Presentation.Shape>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:"));

            Shapes.AddRange(shapes.Select(s => ShapeElement.Create(s.ElementName().Substring(5).Trim(), s, this)).Where(s => s != null));
            var graphicFrames = Slide.Descendants <DocumentFormat.OpenXml.Presentation.GraphicFrame>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:"));

            foreach (var item in graphicFrames)
            {
                string name = item.ElementName().Substring(5).Trim();
                if (item.Graphic.GraphicData.FirstElement <Table>() != null)
                {
                    TableElement table = TableElement.Create(name, item, this);
                    if (table != null)
                    {
                        Shapes.Add(table);
                    }
                }
                else if (item.Graphic.GraphicData.FirstElement <ChartReference>() != null)
                {
                    ChartElement chart = ChartElement.Create(name, item, this);
                    if (chart != null)
                    {
                        Shapes.Add(chart);
                    }
                }
            }
            var paragraphs = Slide.Descendants <Paragraph>();

            foreach (var item in paragraphs)
            {
                if (!item.Ancestors <Table>().Any())
                {
                    if (textTagRegex.Match(item.InnerText).Success)
                    {
                        foreach (Match match in textTagRegex.Matches(item.InnerText))
                        {
                            McKinsey.PowerPointGenerator.Elements.TextElement text = McKinsey.PowerPointGenerator.Elements.TextElement.Create(match.Groups["tag"].Value, item, this);
                            if (text != null)
                            {
                                Shapes.Add(text);
                            }
                        }
                    }
                }
            }
            foreach (ShapeElementBase item in Shapes)
            {
                item.Slide = this;
            }
        }
Esempio n. 3
0
        public void PreprocessSwitchCommandsSetsDefaultValuesWhenNoSwitchCommandsExist()
        {
            Document     doc      = new Document();
            var          slide    = new SlideElement(doc);
            ChartElement element  = ChartElement.Create("TEST", null, slide);
            var          commands = new List <Command>()
            {
                new FormatCommand(), new FormulaCommand(), new NoContentCommand()
            };
            var result = element.PreprocessSwitchCommands(commands);

            Assert.AreEqual(3, result.Count());
            Assert.IsFalse(element.IsWaterfall);
            Assert.IsFalse(element.IsFixed);
            Assert.IsFalse(element.IsPaged);
        }
Esempio n. 4
0
        public void PreprocessSwitchCommandsGetAllCommandsIfTheyExist()
        {
            Document     doc      = new Document();
            var          slide    = new SlideElement(doc);
            ChartElement element  = ChartElement.Create("TEST", null, slide);
            var          commands = new List <Command>()
            {
                new FormatCommand(), new FormulaCommand(), new NoContentCommand(), new FixedCommand(), new WaterfallCommand(), new PageCommand()
            };
            var result = element.PreprocessSwitchCommands(commands);

            Assert.AreEqual(5, result.Count());
            Assert.IsTrue(element.IsWaterfall);
            Assert.IsTrue(element.IsFixed);
            Assert.IsTrue(element.IsPaged);
        }