public void DiscoverCommandsIgnorwsUnknownCommands() { Document doc = new Document(); var slide = new SlideElement(doc); ShapeElement element = ShapeElement.Create("TEST ADD_COLUMN_HEADER", null, slide); var commands = CommandManager.DiscoverCommands(element).ToList(); Assert.AreEqual(0, commands.Count); }
public void DiscoverCommandsReturnsEmptyListWhenNoCommandsAreFound() { Document doc = new Document(); var slide = new SlideElement(doc); ShapeElement element = ShapeElement.Create("TEST", null, slide); var commands = CommandManager.DiscoverCommands(element).ToList(); Assert.AreEqual(0, commands.Count); }
public void ProcessReplacesFormattedTagInTheElement() { Shape s = new Shape(Resources.TestShapeWithTag); ShapeElementProcessor processor = new ShapeElementProcessor(); ShapeElement element = ShapeElement.Create("customer", s, null); element.Data = Helpers.CreateSingleValueElement("customer", "IBM"); processor.Process(element); Assert.AreEqual("Business profile, IBM, 2014", s.InnerText); }
public void ProcessReplacesWholeShapeContent() { Shape s = new Shape(Resources.TestShape); ShapeElementProcessor processor = new ShapeElementProcessor(); ShapeElement element = ShapeElement.Create("customer", s, null); element.Data = Helpers.CreateSingleValueElement("customer", "IBM"); processor.Process(element); Assert.AreEqual("IBM", s.InnerText); }
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; } }
public void PreprocessSwitchCommandsSetsDefaultValuesWhenNoSwitchCommandsExist() { Document doc = new Document(); var slide = new SlideElement(doc); ShapeElement element = ShapeElement.Create("TEST", null, slide); var commands = new List <Command>() { new FormatCommand(), new FormulaCommand(), new FixedCommand() }; var result = element.PreprocessSwitchCommands(commands); Assert.AreEqual(3, result.Count()); Assert.IsFalse(element.IsContentProtected); }
public void PreprocessSwitchCommandsGetAllCommandsIfTheyExist() { Document doc = new Document(); var slide = new SlideElement(doc); ShapeElement element = ShapeElement.Create("TEST", null, slide); var commands = new List <Command>() { new FormatCommand(), new FormulaCommand(), new NoContentCommand(), new FixedCommand() }; var result = element.PreprocessSwitchCommands(commands); Assert.AreEqual(3, result.Count()); Assert.IsTrue(element.IsContentProtected); }
public void DiscoverCommandsSetsArgumentsString() { Document doc = new Document(); var slide = new SlideElement(doc); ShapeElement element = ShapeElement.Create("TEST FORMAT(\"##,#\", \"de-DE\") FIXED TRANSPOSE LEGEND(\"#Cl1N#\", \"G1=='Q1'\", \"Q1\") SORT(2, ASC) FORMULA(\"'column 2' - 'column 1'\")", null, slide); var commands = CommandManager.DiscoverCommands(element).ToList(); Assert.AreEqual(6, commands.Count); Assert.AreEqual("\"##,#\", \"de-DE\"", commands[0].ArgumentsString); Assert.AreEqual("", commands[1].ArgumentsString); Assert.AreEqual("", commands[2].ArgumentsString); Assert.AreEqual("\"#Cl1N#\", \"G1=='Q1'\", \"Q1\"", commands[3].ArgumentsString); Assert.AreEqual("2, ASC", commands[4].ArgumentsString); Assert.AreEqual("\"'column 2' - 'column 1'\"", commands[5].ArgumentsString); }
public void DiscoverCommandsResolvesCommandsAndSetsProcessingOrder() { Document doc = new Document(); var slide = new SlideElement(doc); ShapeElement element = ShapeElement.Create("TEST FORMAT(\"##,#\", \"de-DE\") FIXED TRANSPOSE LEGEND(\"#Cl1N#\", \"G1=='Q1'\", \"Q1\") SORT(2, ASC) FORMULA(\"'column 2' - 'column 1'\")", null, slide); var commands = CommandManager.DiscoverCommands(element).ToList(); Assert.AreEqual(6, commands.Count); Assert.IsInstanceOfType(commands[0], typeof(FormatCommand)); Assert.IsInstanceOfType(commands[1], typeof(FixedCommand)); Assert.IsInstanceOfType(commands[2], typeof(TransposeCommand)); Assert.IsInstanceOfType(commands[3], typeof(LegendCommand)); Assert.IsInstanceOfType(commands[4], typeof(SortCommand)); Assert.IsInstanceOfType(commands[5], typeof(FormulaCommand)); }
private async Task InitGridAndShapeElementAsync() { var blockItemsData = _startGameData.NewGame ? Option <GameStateModel> .None : (await _gameStateModule.LoadLevelState() .ThrowIfErrorAsync("Cannot load level data")).ToOption(); var gridData = blockItemsData.Cata( v => _blockItemsPoolModule.GetBlockItems(v.GridBlocks).ToSome(), () => Option <BlockItem[]> .None); var shapeBlocksData = blockItemsData.Cata( v => _blockItemsPoolModule.GetBlockItems(v.ShapeBlocks).ToSome(), () => Option <BlockItem[]> .None); _gameGrid = new GameGrid(_playFieldAreaBounds, gridData, _blockItemsPoolModule); var inputReceiver = InputReceiver.Create(); _shapeElement = ShapeElement.Create(inputReceiver, _gameGrid, _blockItemsPoolModule, shapeBlocksData); }
public override void ParseArguments() { Match match = regex.Match(ArgumentsString); if (match.Success) { Index = new Index(match.Groups["index"].Value); Formula = match.Groups["formula"].Value; LegendObjectName = match.Groups["target"].Value; } if (TargetElement.Slide != null && TargetElement.Slide.Slide != null) { var shape = TargetElement.Slide.Slide.Descendants <DocumentFormat.OpenXml.Presentation.Shape>().FirstOrDefault(s => s.ElementName().Equals(LegendObjectName, StringComparison.OrdinalIgnoreCase)); if (shape != null) { LegendObject = ShapeElement.Create(LegendObjectName, shape, TargetElement.Slide); } } Formula = FormulaHelper.ParseFormulaIndexes(Formula, UsedIndexes); }