From 0714464f6bc3f31dff206202704af4b1380aed71 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Thu, 13 Jun 2024 00:15:38 +0000 Subject: [PATCH 01/25] Add shape update --- Directory.Build.props | 2 +- Global/Models/2007/ShapeModel.cs | 496 ++++++-------------------- Presentation/Components/2007/Shape.cs | 15 +- Presentation/Parts/Slide.cs | 27 +- Spreadsheet/Components/2007/Shape.cs | 38 +- Spreadsheet/Parts/Worksheet.cs | 33 ++ 6 files changed, 227 insertions(+), 384 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ad9d4d5c..d806fc63 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ MIT ..\bin\ DraviaVemal - 2.8.0-Alpha.2 + 2.8.0-Alpha.3 DraviaVemal Copyright (c) 2023 DraviaVemal Permission is hereby granted, free of charge, to any person obtaining a copy of this diff --git a/Global/Models/2007/ShapeModel.cs b/Global/Models/2007/ShapeModel.cs index 1a12e3b8..7f383f48 100644 --- a/Global/Models/2007/ShapeModel.cs +++ b/Global/Models/2007/ShapeModel.cs @@ -5,7 +5,7 @@ namespace OpenXMLOffice.Global_2007 /// /// /// - public enum ShapeTypes + public enum ShapeRectangleTypes { /// /// @@ -19,388 +19,119 @@ public enum ShapeTypes /// /// TRIANGLE, - // /// - // /// - // /// - // DIAMOND, - // /// - // /// - // /// - // PARALLELOGRAM, - // /// - // /// - // /// - // TRAPEZOID, - // /// - // /// - // /// - // HEXAGON, - // /// - // /// - // /// - // OCTAGON, - // /// - // /// - // /// - // PLUS_SIGN, - // /// - // /// - // /// - // STAR, - // /// - // /// - // /// - // ARROW, - // /// - // /// - // /// - // CROSS, - // /// - // /// - // /// - // PENTAGON, - // /// - // /// - // /// - // RIGHT_ARROW, - // /// - // /// - // /// - // LEFT_ARROW, - // /// - // /// - // /// - // UP_ARROW, - // /// - // /// - // /// - // DOWN_ARROW, - // /// - // /// - // /// - // LEFT_RIGHT_ARROW, - // /// - // /// - // /// - // UP_DOWN_ARROW, - // /// - // /// - // /// - // QUAD_ARROW, - // /// - // /// - // /// - // LEFT_RIGHT_UP_ARROW, - // /// - // /// - // /// - // BENT_ARROW, - // /// - // /// - // /// - // U_TURN_ARROW, - // /// - // /// - // /// - // CIRCULAR_ARROW, - // /// - // /// - // /// - // LEFT_CIRCULAR_ARROW, - // /// - // /// - // /// - // RIGHT_CIRCULAR_ARROW, - // /// - // /// - // /// - // CURVED_LEFT_ARROW, - // /// - // /// - // /// - // CURVED_RIGHT_ARROW, - // /// - // /// - // /// - // CURVED_UP_ARROW, - // /// - // /// - // /// - // CURVED_DOWN_ARROW, - // /// - // /// - // /// - // FLOWCHART_PROCESS, - // /// - // /// - // /// - // FLOWCHART_DECISION, - // /// - // /// - // /// - // FLOWCHART_INPUT_OUTPUT, - // /// - // /// - // /// - // FLOWCHART_PREDEFINED_PROCESS, - // /// - // /// - // /// - // FLOWCHART_INTERNAL_STORAGE, - // /// - // /// - // /// - // FLOWCHART_DOCUMENT, - // /// - // /// - // /// - // FLOWCHART_MULTI_DOCUMENT, - // /// - // /// - // /// - // FLOWCHART_TERMINATOR, - // /// - // /// - // /// - // FLOWCHART_PREPARATION, - // /// - // /// - // /// - // FLOWCHART_MANUAL_INPUT, - // /// - // /// - // /// - // FLOWCHART_MANUAL_OPERATION, - // /// - // /// - // /// - // FLOWCHART_CONNECTOR, - // /// - // /// - // /// - // FLOWCHART_OFF_PAGE_CONNECTOR, - // /// - // /// - // /// - // FLOWCHART_CARD, - // /// - // /// - // /// - // FLOWCHART_PUNCHED_TAPE, - // /// - // /// - // /// - // FLOWCHART_SUMMING_JUNCTION, - // /// - // /// - // /// - // FLOWCHART_OR, - // /// - // /// - // /// - // FLOWCHART_COLLATE, - // /// - // /// - // /// - // FLOWCHART_SORT, - // /// - // /// - // /// - // FLOWCHART_EXTRACT, - // /// - // /// - // /// - // FLOWCHART_MERGE, - // /// - // /// - // /// - // FLOWCHART_STORED_DATA, - // /// - // /// - // /// - // FLOWCHART_DELAY, - // /// - // /// - // /// - // FLOWCHART_SEQUENTIAL_ACCESS_STORAGE, - // /// - // /// - // /// - // FLOWCHART_MAGNETIC_DISK, - // /// - // /// - // /// - // FLOWCHART_DIRECT_ACCESS_STORAGE, - // /// - // /// - // /// - // FLOWCHART_DISPLAY, - // /// - // /// - // /// - // CALLOUT_RECTANGULAR, - // /// - // /// - // /// - // CALLOUT_ROUNDED_RECTANGULAR, - // /// - // /// - // /// - // CALLOUT_OVAL, - // /// - // /// - // /// - // CALLOUT_CLOUD, - // /// - // /// - // /// - // STAR_5_POINT, - // /// - // /// - // /// - // DOUBLE_STAR, - // /// - // /// - // /// - // STARBURST, - // /// - // /// - // /// - // TEARDROP, - // /// - // /// - // /// - // RIGHT_ARROW_BANNER, - // /// - // /// - // /// - // LEFT_ARROW_BANNER, - // /// - // /// - // /// - // CHEVRON, - // /// - // /// - // /// - // HEPTAGON, - // /// - // /// - // /// - // DECAGON, - // /// - // /// - // /// - // DODECAGON, - // /// - // /// - // /// - // ACTION_BUTTON_CUSTOM, - // /// - // /// - // /// - // ACTION_BUTTON_HOME, - // /// - // /// - // /// - // ACTION_BUTTON_HELP, - // /// - // /// - // /// - // ACTION_BUTTON_INFORMATION, - // /// - // /// - // /// - // ACTION_BUTTON_FORWARD_OR_NEXT, - // /// - // /// - // /// - // ACTION_BUTTON_BACK_OR_PREVIOUS, - // /// - // /// - // /// - // ACTION_BUTTON_END, - // /// - // /// - // /// - // ACTION_BUTTON_BEGINNING, - // /// - // /// - // /// - // ACTION_BUTTON_RETURN, - // /// - // /// - // /// - // ACTION_BUTTON_DOCUMENT, - // /// - // /// - // /// - // ACTION_BUTTON_SOUND, - // /// - // /// - // /// - // ACTION_BUTTON_MOVIE, - // /// - // /// - // /// - // LINE, - // /// - // /// - // /// - // LINE_ARROW, - // /// - // /// - // /// - // LINE_DOUBLE_ARROW, - // /// - // /// - // /// - // CONNECTOR_STRAIGHT, - // /// - // /// - // /// - // CONNECTOR_ELBOW, - // /// - // /// - // /// - // CONNECTOR_CURVED, - // /// - // /// - // /// - // HEART, - // /// - // /// - // /// - // LIGHTNING_BOLT, - // /// - // /// - // /// - // SUN, - // /// - // /// - // /// - // MOON, - // /// - // /// - // /// - // SMILEY_FACE, - // /// - // /// - // /// - // BRACKET_PAIR, - // /// - // /// - // /// - // BRACE_PAIR } /// /// /// - public class ShapeModel + public enum ShapeLineTypes { /// /// /// - public ShapeTypes shapeType = ShapeTypes.RECTANGLE; + LINE, + /// + /// + /// + LINE_ARROW, + /// + /// + /// + LINE_DOUBLE_ARROW, + /// + /// + /// + CONNECTOR_STRAIGHT, + /// + /// + /// + CONNECTOR_ELBOW, + /// + /// + /// + CONNECTOR_CURVED, + } + + /// + /// + /// + public enum ShapeArrowTypes + { + + /// + /// + /// + LEFT, + + /// + /// + /// + RIGHT, + + /// + /// + /// + UP, + + /// + /// + /// + DOWN, + + /// + /// + /// + LEFT_RIGHT, + + /// + /// + /// + UP_DOWN, + + /// + /// + /// + QUAD, + + /// + /// + /// + LEFT_RIGHT_UP, + + /// + /// + /// + CURVED_LEFT, + + /// + /// + /// + CURVED_RIGHT + } + /// + /// + /// + public class ShapeLineModel + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + /// + /// + /// + public ShapeLineTypes lineTypes = ShapeLineTypes.LINE; + /// + /// + /// + public ApplicationSpecificSetting applicationSpecificSetting = new ApplicationSpecificSetting(); + } + /// + /// + /// + public class ShapeRectangleModel + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + /// + /// + /// + public ShapeRectangleTypes rectangleType = ShapeRectangleTypes.RECTANGLE; /// /// /// @@ -408,18 +139,25 @@ public class ShapeModel /// /// /// - public uint x = 0; + public ApplicationSpecificSetting applicationSpecificSetting = new ApplicationSpecificSetting(); + } + /// + /// + /// + public class ShapeArrowModel + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { /// /// /// - public uint y = 0; + public ShapeArrowTypes rectangleType = ShapeArrowTypes.LEFT; /// /// /// - public uint width = 0; + public TextOptions text = null; /// /// /// - public uint height = 0; + public ApplicationSpecificSetting applicationSpecificSetting = new ApplicationSpecificSetting(); } } \ No newline at end of file diff --git a/Presentation/Components/2007/Shape.cs b/Presentation/Components/2007/Shape.cs index 16f4408e..ed562965 100644 --- a/Presentation/Components/2007/Shape.cs +++ b/Presentation/Components/2007/Shape.cs @@ -30,7 +30,20 @@ public void RemoveShape() openXMLShape.Remove(); } - internal Shape AddShape(ShapeModel shapeModel) + internal Shape AddLine(ShapeLineModel lineModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + return this; + } + + internal Shape AddRectangle(ShapeRectangleModel rectangleModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + return this; + } + + internal Shape AddArrow(ShapeArrowModel arrowModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() { return this; } diff --git a/Presentation/Parts/Slide.cs b/Presentation/Parts/Slide.cs index a4c15d9c..4e575163 100644 --- a/Presentation/Parts/Slide.cs +++ b/Presentation/Parts/Slide.cs @@ -190,12 +190,35 @@ public IEnumerable FindShapeByText(string searchText) /// /// Insert Shape into slide /// - public Shape InsertShape(ShapeModel shapeModel) + public Shape InsertShape(ShapeLineModel lineModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() { P.Shape openXmlShape = new P.Shape(); GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); Shape shape = new Shape(openXmlShape); - return shape.AddShape(shapeModel); + return shape.AddLine(lineModel); + } + /// + /// Insert Shape into slide + /// + public Shape InsertShape(ShapeRectangleModel rectangleModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + P.Shape openXmlShape = new P.Shape(); + GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); + Shape shape = new Shape(openXmlShape); + return shape.AddRectangle(rectangleModel); + } + /// + /// Insert Shape into slide + /// + public Shape InsertShape(ShapeArrowModel arrowModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + P.Shape openXmlShape = new P.Shape(); + GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); + Shape shape = new Shape(openXmlShape); + return shape.AddArrow(arrowModel); } /// /// diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index 7f2fcccf..425b5ad9 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -1,12 +1,48 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. +using OpenXMLOffice.Global_2007; +using XDR = DocumentFormat.OpenXml.Drawing.Spreadsheet; + namespace OpenXMLOffice.Spreadsheet_2007 { /// /// Shape Class For Presentation shape manipulation /// - public class Shape + public class Shape : CommonProperties { + private readonly XDR.Shape openXMLShape = new XDR.Shape(); + internal Shape(XDR.Shape shape = null) + { + if (shape != null) + { + openXMLShape = shape; + } + } + + /// + /// Remove Found Shape + /// + public void RemoveShape() + { + openXMLShape.Remove(); + } + + internal Shape AddLine(ShapeLineModel lineModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + return this; + } + + internal Shape AddRectangle(ShapeRectangleModel rectangleModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + return this; + } + internal Shape AddArrow(ShapeArrowModel arrowModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + return this; + } } } \ No newline at end of file diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index e07e82d5..fdc38b9f 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -43,6 +43,39 @@ public string GetSheetName() return sheet.Name; } /// + /// Insert Shape into slide + /// + public Shape InsertShape(ShapeLineModel lineModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + XDR.Shape openXmlShape = new XDR.Shape(); + GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); + Shape shape = new Shape(openXmlShape); + return shape.AddLine(lineModel); + } + /// + /// Insert Shape into slide + /// + public Shape InsertShape(ShapeRectangleModel rectangleModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + XDR.Shape openXmlShape = new XDR.Shape(); + GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); + Shape shape = new Shape(openXmlShape); + return shape.AddRectangle(rectangleModel); + } + /// + /// Insert Shape into slide + /// + public Shape InsertShape(ShapeArrowModel arrowModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + XDR.Shape openXmlShape = new XDR.Shape(); + GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); + Shape shape = new Shape(openXmlShape); + return shape.AddArrow(arrowModel); + } + /// /// Sets the properties for a column based on a starting cell ID in a worksheet. /// public void SetColumn(string cellId, ColumnProperties columnProperties) From e3800d46678dc2511c1ca3ac9e996af9bc5adfa0 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Thu, 13 Jun 2024 07:03:31 +0000 Subject: [PATCH 02/25] organizing --- Global/Models/2007/ShapeModel.cs | 31 ++++++++++++++++++++++++--- Presentation/Components/2007/Shape.cs | 11 +++++++--- Presentation/Parts/Slide.cs | 11 +++++++--- Spreadsheet/Components/2007/Shape.cs | 17 +++++++++------ Spreadsheet/Parts/Worksheet.cs | 11 +++++++--- 5 files changed, 63 insertions(+), 18 deletions(-) diff --git a/Global/Models/2007/ShapeModel.cs b/Global/Models/2007/ShapeModel.cs index 7f383f48..4e08fa11 100644 --- a/Global/Models/2007/ShapeModel.cs +++ b/Global/Models/2007/ShapeModel.cs @@ -110,8 +110,9 @@ public enum ShapeArrowTypes /// /// /// - public class ShapeLineModel + public class ShapeLineModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() { /// /// @@ -121,12 +122,18 @@ public class ShapeLineModel /// /// public ApplicationSpecificSetting applicationSpecificSetting = new ApplicationSpecificSetting(); + /// + /// + /// + public LineColorOption lineColorOption = new LineColorOption(); } /// /// /// - public class ShapeRectangleModel + public class ShapeRectangleModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { /// /// @@ -140,12 +147,22 @@ public class ShapeRectangleModel /// /// public ApplicationSpecificSetting applicationSpecificSetting = new ApplicationSpecificSetting(); + /// + /// + /// + public LineColorOption lineColorOption = new LineColorOption(); + /// + /// + /// + public FillColorOption fillColorOption = new FillColorOption(); } /// /// /// - public class ShapeArrowModel + public class ShapeArrowModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { /// /// @@ -159,5 +176,13 @@ public class ShapeArrowModel /// /// public ApplicationSpecificSetting applicationSpecificSetting = new ApplicationSpecificSetting(); + /// + /// + /// + public LineColorOption lineColorOption = new LineColorOption(); + /// + /// + /// + public FillColorOption fillColorOption = new FillColorOption(); } } \ No newline at end of file diff --git a/Presentation/Components/2007/Shape.cs b/Presentation/Components/2007/Shape.cs index ed562965..79051b30 100644 --- a/Presentation/Components/2007/Shape.cs +++ b/Presentation/Components/2007/Shape.cs @@ -30,20 +30,25 @@ public void RemoveShape() openXMLShape.Remove(); } - internal Shape AddLine(ShapeLineModel lineModel) + internal Shape AddLine(ShapeLineModel lineModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() { return this; } - internal Shape AddRectangle(ShapeRectangleModel rectangleModel) + internal Shape AddRectangle(ShapeRectangleModel rectangleModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { return this; } - internal Shape AddArrow(ShapeArrowModel arrowModel) + internal Shape AddArrow(ShapeArrowModel arrowModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { return this; } diff --git a/Presentation/Parts/Slide.cs b/Presentation/Parts/Slide.cs index 4e575163..f129004b 100644 --- a/Presentation/Parts/Slide.cs +++ b/Presentation/Parts/Slide.cs @@ -190,8 +190,9 @@ public IEnumerable FindShapeByText(string searchText) /// /// Insert Shape into slide /// - public Shape InsertShape(ShapeLineModel lineModel) + public Shape AddShape(ShapeLineModel lineModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() { P.Shape openXmlShape = new P.Shape(); GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); @@ -201,8 +202,10 @@ public Shape InsertShape(ShapeLineModel /// Insert Shape into slide /// - public Shape InsertShape(ShapeRectangleModel rectangleModel) + public Shape AddShape(ShapeRectangleModel rectangleModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { P.Shape openXmlShape = new P.Shape(); GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); @@ -212,8 +215,10 @@ public Shape InsertShape(ShapeRectangleModel /// Insert Shape into slide /// - public Shape InsertShape(ShapeArrowModel arrowModel) + public Shape AddShape(ShapeArrowModel arrowModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { P.Shape openXmlShape = new P.Shape(); GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index 425b5ad9..d62bcb60 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -27,20 +27,25 @@ public void RemoveShape() openXMLShape.Remove(); } - internal Shape AddLine(ShapeLineModel lineModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape AddLine(ShapeLineModel lineModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() { return this; } - internal Shape AddRectangle(ShapeRectangleModel rectangleModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape AddRectangle(ShapeRectangleModel rectangleModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { return this; } - internal Shape AddArrow(ShapeArrowModel arrowModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape AddArrow(ShapeArrowModel arrowModel) + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { return this; } diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index fdc38b9f..5724a4b5 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -45,8 +45,9 @@ public string GetSheetName() /// /// Insert Shape into slide /// - public Shape InsertShape(ShapeLineModel lineModel) + public Shape AddShape(ShapeLineModel lineModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() { XDR.Shape openXmlShape = new XDR.Shape(); GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); @@ -56,8 +57,10 @@ public Shape InsertShape(ShapeLineModel /// Insert Shape into slide /// - public Shape InsertShape(ShapeRectangleModel rectangleModel) + public Shape AddShape(ShapeRectangleModel rectangleModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { XDR.Shape openXmlShape = new XDR.Shape(); GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); @@ -67,8 +70,10 @@ public Shape InsertShape(ShapeRectangleModel /// Insert Shape into slide /// - public Shape InsertShape(ShapeArrowModel arrowModel) + public Shape AddShape(ShapeArrowModel arrowModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where LineColorOption : class, IColorOptions, new() + where FillColorOption : class, IColorOptions, new() { XDR.Shape openXmlShape = new XDR.Shape(); GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); From ec88baaec23a9e861708307a8b432b4a224db4f6 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Fri, 14 Jun 2024 04:59:11 +0000 Subject: [PATCH 03/25] Shape backup --- Spreadsheet/Components/2007/Shape.cs | 44 ++++++++++++++++++++++------ Spreadsheet/Parts/Worksheet.cs | 20 +++++-------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index d62bcb60..d27dd797 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -11,12 +11,10 @@ namespace OpenXMLOffice.Spreadsheet_2007 public class Shape : CommonProperties { private readonly XDR.Shape openXMLShape = new XDR.Shape(); - internal Shape(XDR.Shape shape = null) + private readonly Worksheet worksheet; + internal Shape(Worksheet _worksheet) { - if (shape != null) - { - openXMLShape = shape; - } + worksheet = _worksheet; } /// @@ -27,26 +25,54 @@ public void RemoveShape() openXMLShape.Remove(); } - internal Shape AddLine(ShapeLineModel lineModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape MakeLine(ShapeLineModel lineModel) + where ApplicationSpecificSetting : ExcelSetting, new() where LineColorOption : class, IColorOptions, new() { + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + { + from = new AnchorPosition() + { + row = lineModel.applicationSpecificSetting.from.row, + rowOffset = lineModel.applicationSpecificSetting.from.rowOffset, + column = lineModel.applicationSpecificSetting.from.column, + columnOffset = lineModel.applicationSpecificSetting.from.columnOffset, + }, + to = new AnchorPosition() + { + row = lineModel.applicationSpecificSetting.to.row, + rowOffset = lineModel.applicationSpecificSetting.to.rowOffset, + column = lineModel.applicationSpecificSetting.to.column, + columnOffset = lineModel.applicationSpecificSetting.to.columnOffset, + }, + }); + worksheet.GetDrawing().AppendChild(twoCellAnchor); return this; } - internal Shape AddRectangle(ShapeRectangleModel rectangleModel) + internal Shape MakeRectangle(ShapeRectangleModel rectangleModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + { + + }); + worksheet.GetDrawing().AppendChild(twoCellAnchor); return this; } - internal Shape AddArrow(ShapeArrowModel arrowModel) + internal Shape MakeArrow(ShapeArrowModel arrowModel) where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + { + + }); + worksheet.GetDrawing().AppendChild(twoCellAnchor); return this; } } diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index 5724a4b5..63cb7439 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -46,13 +46,11 @@ public string GetSheetName() /// Insert Shape into slide /// public Shape AddShape(ShapeLineModel lineModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + where ApplicationSpecificSetting : ExcelSetting, new() where LineColorOption : class, IColorOptions, new() { - XDR.Shape openXmlShape = new XDR.Shape(); - GetSlide().CommonSlideData.ShapeTree.Append(openXmlShape); - Shape shape = new Shape(openXmlShape); - return shape.AddLine(lineModel); + Shape shape = new Shape(this); + return shape.MakeLine(lineModel); } /// /// Insert Shape into slide @@ -62,10 +60,8 @@ public Shape AddShape /// Insert Shape into slide @@ -75,10 +71,8 @@ public Shape AddShape /// Sets the properties for a column based on a starting cell ID in a worksheet. From 9035ab3596de5f9dad5b4b5ebe7aba935047c832 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Fri, 14 Jun 2024 05:17:39 +0000 Subject: [PATCH 04/25] Organized Application settings generics --- Presentation/Components/2007/Chart.cs | 52 +++++++++---------- Presentation/Components/2007/Shape.cs | 14 ++--- .../2016/AdvancedChartProperties.cs | 6 +-- Presentation/Components/2016/Chart.cs | 10 ++-- .../Components/Common/ChartProperties.cs | 6 +-- Presentation/Parts/Slide.cs | 49 +++++++---------- Spreadsheet/Components/2007/Chart.cs | 47 ++++++++--------- .../Components/2007/ChartProperties.cs | 6 +-- Spreadsheet/Components/2007/Shape.cs | 9 ++-- Spreadsheet/Parts/Worksheet.cs | 45 +++++++--------- Tests/Presentation.cs | 12 ++--- 11 files changed, 113 insertions(+), 143 deletions(-) diff --git a/Presentation/Components/2007/Chart.cs b/Presentation/Components/2007/Chart.cs index 391e7d63..18dc60a9 100644 --- a/Presentation/Components/2007/Chart.cs +++ b/Presentation/Components/2007/Chart.cs @@ -1,19 +1,19 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. +using System.IO; +using System.Linq; using C = DocumentFormat.OpenXml.Drawing.Charts; using DocumentFormat.OpenXml.Packaging; using OpenXMLOffice.Spreadsheet_2007; using OpenXMLOffice.Global_2007; using OpenXMLOffice.Global_2013; -using System.IO; -using System.Linq; + namespace OpenXMLOffice.Presentation_2007 { /// /// Chart Class Exported out of PPT importing from Global /// - public class Chart : ChartProperties - where ApplicationSpecificSetting : PresentationSetting, new() + public class Chart : ChartProperties where XAxisType : class, IAxisTypeOptions, new() where YAxisType : class, IAxisTypeOptions, new() where ZAxisType : class, IAxisTypeOptions, new() @@ -26,7 +26,7 @@ public class Chart /// YAxisType /// ZAxisType /// - public Chart(Slide slide, DataCell[][] dataRows, AreaChartSetting areaChartSetting) : base(slide, areaChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, AreaChartSetting areaChartSetting) : base(slide, areaChartSetting) { openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -39,7 +39,7 @@ public Chart(Slide slide, DataCell[][] dataRows, AreaChartSetting - public Chart(Slide slide, DataCell[][] dataRows, BarChartSetting barChartSetting) : base(slide, barChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, BarChartSetting barChartSetting) : base(slide, barChartSetting) { openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -52,7 +52,7 @@ public Chart(Slide slide, DataCell[][] dataRows, BarChartSetting - public Chart(Slide slide, DataCell[][] dataRows, ColumnChartSetting columnChartSetting) : base(slide, columnChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, ColumnChartSetting columnChartSetting) : base(slide, columnChartSetting) { openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -65,7 +65,7 @@ public Chart(Slide slide, DataCell[][] dataRows, ColumnChartSetting - public Chart(Slide slide, DataCell[][] dataRows, LineChartSetting lineChartSetting) : base(slide, lineChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, LineChartSetting lineChartSetting) : base(slide, lineChartSetting) { openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -78,7 +78,7 @@ public Chart(Slide slide, DataCell[][] dataRows, LineChartSetting - public Chart(Slide slide, DataCell[][] dataRows, PieChartSetting pieChartSetting) : base(slide, pieChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, PieChartSetting pieChartSetting) : base(slide, pieChartSetting) { openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -91,7 +91,7 @@ public Chart(Slide slide, DataCell[][] dataRows, PieChartSetting - public Chart(Slide slide, DataCell[][] dataRows, ScatterChartSetting scatterChartSetting) : base(slide, scatterChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, ScatterChartSetting scatterChartSetting) : base(slide, scatterChartSetting) { openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -100,7 +100,7 @@ public Chart(Slide slide, DataCell[][] dataRows, ScatterChartSetting /// /// - public Chart(Slide slide, DataCell[][] dataRows, ComboChartSetting comboChartSetting) : base(slide, comboChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, ComboChartSetting comboChartSetting) : base(slide, comboChartSetting) { openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -128,77 +128,77 @@ internal string GetNextChartRelationId() GetChartPart().DataPartReferenceRelationships.Any(item => item.Id == string.Format("rId{0}", nextId))); return string.Format("rId{0}", nextId); } - private void CreateChart(DataCell[][] dataRows, AreaChartSetting areaChartSetting) + private void CreateChart(DataCell[][] dataRows, AreaChartSetting areaChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - AreaChart areaChart = new AreaChart(areaChartSetting, ExcelToPPTdata(dataRows)); + AreaChart areaChart = new AreaChart(areaChartSetting, ExcelToPPTdata(dataRows)); CreateChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), areaChartSetting.hyperlinkProperties); SaveChanges(areaChart); } - private void CreateChart(DataCell[][] dataRows, BarChartSetting barChartSetting) + private void CreateChart(DataCell[][] dataRows, BarChartSetting barChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - BarChart barChart = new BarChart(barChartSetting, ExcelToPPTdata(dataRows)); + BarChart barChart = new BarChart(barChartSetting, ExcelToPPTdata(dataRows)); CreateChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), barChartSetting.hyperlinkProperties); SaveChanges(barChart); } - private void CreateChart(DataCell[][] dataRows, ColumnChartSetting columnChartSetting) + private void CreateChart(DataCell[][] dataRows, ColumnChartSetting columnChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - ColumnChart columnChart = new ColumnChart(columnChartSetting, ExcelToPPTdata(dataRows)); + ColumnChart columnChart = new ColumnChart(columnChartSetting, ExcelToPPTdata(dataRows)); CreateChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), columnChartSetting.hyperlinkProperties); SaveChanges(columnChart); } - private void CreateChart(DataCell[][] dataRows, LineChartSetting lineChartSetting) + private void CreateChart(DataCell[][] dataRows, LineChartSetting lineChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - LineChart lineChart = new LineChart(lineChartSetting, ExcelToPPTdata(dataRows)); + LineChart lineChart = new LineChart(lineChartSetting, ExcelToPPTdata(dataRows)); CreateChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), lineChartSetting.hyperlinkProperties); SaveChanges(lineChart); } - private void CreateChart(DataCell[][] dataRows, PieChartSetting pieChartSetting) + private void CreateChart(DataCell[][] dataRows, PieChartSetting pieChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - PieChart pieChart = new PieChart(pieChartSetting, ExcelToPPTdata(dataRows)); + PieChart pieChart = new PieChart(pieChartSetting, ExcelToPPTdata(dataRows)); CreateChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), pieChartSetting.hyperlinkProperties); SaveChanges(pieChart); } - private void CreateChart(DataCell[][] dataRows, ScatterChartSetting scatterChartSetting) + private void CreateChart(DataCell[][] dataRows, ScatterChartSetting scatterChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - ScatterChart scatterChart = new ScatterChart(scatterChartSetting, ExcelToPPTdata(dataRows)); + ScatterChart scatterChart = new ScatterChart(scatterChartSetting, ExcelToPPTdata(dataRows)); CreateChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), scatterChartSetting.hyperlinkProperties); SaveChanges(scatterChart); } - private void CreateChart(DataCell[][] dataRows, ComboChartSetting comboChartSetting) + private void CreateChart(DataCell[][] dataRows, ComboChartSetting comboChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - ComboChart comboChart = new ComboChart(comboChartSetting, ExcelToPPTdata(dataRows)); + ComboChart comboChart = new ComboChart(comboChartSetting, ExcelToPPTdata(dataRows)); CreateChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), comboChartSetting.hyperlinkProperties); SaveChanges(comboChart); } - private void SaveChanges(ChartBase chart) + private void SaveChanges(ChartBase chart) { chart.GetChartSpace().Append(new C.ExternalData( new C.AutoUpdate() { Val = false }) diff --git a/Presentation/Components/2007/Shape.cs b/Presentation/Components/2007/Shape.cs index 79051b30..ecbb8790 100644 --- a/Presentation/Components/2007/Shape.cs +++ b/Presentation/Components/2007/Shape.cs @@ -30,23 +30,20 @@ public void RemoveShape() openXMLShape.Remove(); } - internal Shape AddLine(ShapeLineModel lineModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape AddLine(ShapeLineModel lineModel) where LineColorOption : class, IColorOptions, new() { return this; } - internal Shape AddRectangle(ShapeRectangleModel rectangleModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape AddRectangle(ShapeRectangleModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { return this; } - internal Shape AddArrow(ShapeArrowModel arrowModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape AddArrow(ShapeArrowModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { @@ -56,8 +53,7 @@ internal Shape AddArrow /// Replace Chart for the source Shape /// - public Chart ReplaceChart(Chart chart) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart ReplaceChart(Chart chart) where XAxisType : class, IAxisTypeOptions, new() where YAxisType : class, IAxisTypeOptions, new() where ZAxisType : class, IAxisTypeOptions, new() @@ -84,7 +80,7 @@ public Chart Replac /// /// Replace 2016 Support Chart for the source Shape /// - public P16.Chart ReplaceChart(P16.Chart chart) where ApplicationSpecificSetting : PresentationSetting, new() + public P16.Chart ReplaceChart(P16.Chart chart) { DocumentFormat.OpenXml.OpenXmlElement parent = openXMLShape.Parent; if (parent == null) diff --git a/Presentation/Components/2016/AdvancedChartProperties.cs b/Presentation/Components/2016/AdvancedChartProperties.cs index 06102a13..197266ab 100644 --- a/Presentation/Components/2016/AdvancedChartProperties.cs +++ b/Presentation/Components/2016/AdvancedChartProperties.cs @@ -1,27 +1,25 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. -using System.Runtime; using DocumentFormat.OpenXml; using OpenXMLOffice.Global_2007; using OpenXMLOffice.Presentation_2007; using A = DocumentFormat.OpenXml.Drawing; using P = DocumentFormat.OpenXml.Presentation; using CX = DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing; -using System.Reflection; using System.Collections.Generic; namespace OpenXMLOffice.Presentation_2016 { /// /// /// - public class AdvancedChartProperties : ChartProperties where ApplicationSpecificSetting : PresentationSetting, new() + public class AdvancedChartProperties : ChartProperties { private AlternateContent alternateContent; private readonly TextBox errorMessage; /// /// /// - public AdvancedChartProperties(Slide slide, ChartSetting chartSetting) : base(slide, chartSetting) + public AdvancedChartProperties(Slide slide, ChartSetting chartSetting) : base(slide, chartSetting) { errorMessage = new TextBox(new TextBoxSetting() { diff --git a/Presentation/Components/2016/Chart.cs b/Presentation/Components/2016/Chart.cs index 414d3fc6..dc549cb5 100644 --- a/Presentation/Components/2016/Chart.cs +++ b/Presentation/Components/2016/Chart.cs @@ -13,7 +13,7 @@ namespace OpenXMLOffice.Presentation_2016 /// /// /// - public class Chart : AdvancedChartProperties where ApplicationSpecificSetting : PresentationSetting, new() + public class Chart : AdvancedChartProperties { /// /// @@ -22,7 +22,7 @@ namespace OpenXMLOffice.Presentation_2016 /// /// /// - public Chart(Slide slide, DataCell[][] dataRows, WaterfallChartSetting waterfallChartSetting) : base(slide, waterfallChartSetting) + public Chart(Slide slide, DataCell[][] dataRows, WaterfallChartSetting waterfallChartSetting) : base(slide, waterfallChartSetting) { OpenXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); @@ -54,17 +54,17 @@ private ExtendedChartPart GetChartPart() { return OpenXMLChartPart; } - private void CreateChart(DataCell[][] dataRows, WaterfallChartSetting waterfallChartSetting) + private void CreateChart(DataCell[][] dataRows, WaterfallChartSetting waterfallChartSetting) { using (Stream stream = GetWorkBookStream()) { WriteDataToExcel(dataRows, stream); }; - WaterfallChart waterfallChart = new WaterfallChart(waterfallChartSetting, ExcelToPPTdata(dataRows)); + WaterfallChart waterfallChart = new WaterfallChart(waterfallChartSetting, ExcelToPPTdata(dataRows)); CreateExtendedChartGraphicFrame(currentSlide.GetSlidePart().GetIdOfPart(GetChartPart()), (uint)currentSlide.GetSlidePart().GetPartsOfType().Count(), waterfallChartSetting.hyperlinkProperties); SaveChanges(waterfallChart); } - private void SaveChanges(AdvanceCharts chart) + private void SaveChanges(AdvanceCharts chart) { GetChartPart().ChartSpace = chart.GetExtendedChartSpace(); GetChartStylePart().ChartStyle = ChartStyle.CreateChartStyles(); diff --git a/Presentation/Components/Common/ChartProperties.cs b/Presentation/Components/Common/ChartProperties.cs index e4ebeab9..0ea21762 100644 --- a/Presentation/Components/Common/ChartProperties.cs +++ b/Presentation/Components/Common/ChartProperties.cs @@ -13,12 +13,12 @@ namespace OpenXMLOffice.Presentation_2007 /// /// /// - public class ChartProperties : CommonProperties where ApplicationSpecificSetting : PresentationSetting, new() + public class ChartProperties : CommonProperties { /// /// /// - internal readonly ChartSetting chartSetting; + internal readonly ChartSetting chartSetting; /// /// /// @@ -30,7 +30,7 @@ namespace OpenXMLOffice.Presentation_2007 /// /// /// - internal ChartProperties(Slide slide, ChartSetting chartSetting) + internal ChartProperties(Slide slide, ChartSetting chartSetting) { this.chartSetting = chartSetting; currentSlide = slide; diff --git a/Presentation/Parts/Slide.cs b/Presentation/Parts/Slide.cs index f129004b..98f25aee 100644 --- a/Presentation/Parts/Slide.cs +++ b/Presentation/Parts/Slide.cs @@ -59,83 +59,75 @@ internal Slide(P.Slide OpenXMLSlide = null, SlideModel slideModel = null) /// /// Adds a Area chart to the slide. /// - public Chart AddChart(DataCell[][] DataCells, AreaChartSetting AreaChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart AddChart(DataCell[][] DataCells, AreaChartSetting AreaChartSetting) { - Chart Chart = new Chart(this, DataCells, AreaChartSetting); + Chart Chart = new Chart(this, DataCells, AreaChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetChartGraphicFrame()); return Chart; } /// /// Adds a Bar chart to the slide. /// - public Chart AddChart(DataCell[][] DataCells, BarChartSetting BarChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart AddChart(DataCell[][] DataCells, BarChartSetting BarChartSetting) { - Chart Chart = new Chart(this, DataCells, BarChartSetting); + Chart Chart = new Chart(this, DataCells, BarChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetChartGraphicFrame()); return Chart; } /// /// Adds a Column chart to the slide. /// - public Chart AddChart(DataCell[][] DataCells, ColumnChartSetting ColumnChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart AddChart(DataCell[][] DataCells, ColumnChartSetting ColumnChartSetting) { - Chart Chart = new Chart(this, DataCells, ColumnChartSetting); + Chart Chart = new Chart(this, DataCells, ColumnChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetChartGraphicFrame()); return Chart; } /// /// Adds a Line chart to the slide. /// - public Chart AddChart(DataCell[][] DataCells, LineChartSetting LineChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart AddChart(DataCell[][] DataCells, LineChartSetting LineChartSetting) { - Chart Chart = new Chart(this, DataCells, LineChartSetting); + Chart Chart = new Chart(this, DataCells, LineChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetChartGraphicFrame()); return Chart; } /// /// Adds a Pie chart to the slide. /// - public Chart AddChart(DataCell[][] DataCells, PieChartSetting PieChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart AddChart(DataCell[][] DataCells, PieChartSetting PieChartSetting) { - Chart Chart = new Chart(this, DataCells, PieChartSetting); + Chart Chart = new Chart(this, DataCells, PieChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetChartGraphicFrame()); return Chart; } /// /// Adds a Scatter chart to the slide. /// - public Chart AddChart(DataCell[][] DataCells, ScatterChartSetting ScatterChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart AddChart(DataCell[][] DataCells, ScatterChartSetting ScatterChartSetting) { - Chart Chart = new Chart(this, DataCells, ScatterChartSetting); + Chart Chart = new Chart(this, DataCells, ScatterChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetChartGraphicFrame()); return Chart; } /// /// Adds a Combo chart to the slide. /// - public Chart AddChart(DataCell[][] DataCells, ComboChartSetting comboChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public Chart AddChart(DataCell[][] DataCells, ComboChartSetting comboChartSetting) where XAxisType : class, IAxisTypeOptions, new() where YAxisType : class, IAxisTypeOptions, new() where ZAxisType : class, IAxisTypeOptions, new() { - Chart Chart = new Chart(this, DataCells, comboChartSetting); + Chart Chart = new Chart(this, DataCells, comboChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetChartGraphicFrame()); return Chart; } /// /// Adds a Combo chart to the slide. /// - public P16.Chart AddChart(DataCell[][] DataCells, WaterfallChartSetting waterfallChartSetting) - where ApplicationSpecificSetting : PresentationSetting, new() + public P16.Chart AddChart(DataCell[][] DataCells, WaterfallChartSetting waterfallChartSetting) { - P16.Chart Chart = new P16.Chart(this, DataCells, waterfallChartSetting); + P16.Chart Chart = new P16.Chart(this, DataCells, waterfallChartSetting); GetSlide().CommonSlideData.ShapeTree.Append(Chart.GetAlternateContent()); return Chart; } @@ -190,8 +182,7 @@ public IEnumerable FindShapeByText(string searchText) /// /// Insert Shape into slide /// - public Shape AddShape(ShapeLineModel lineModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + public Shape AddShape(ShapeLineModel lineModel) where LineColorOption : class, IColorOptions, new() { P.Shape openXmlShape = new P.Shape(); @@ -202,8 +193,7 @@ public Shape AddShape(ShapeLineMode /// /// Insert Shape into slide /// - public Shape AddShape(ShapeRectangleModel rectangleModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + public Shape AddShape(ShapeRectangleModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { @@ -215,8 +205,7 @@ public Shape AddShape /// Insert Shape into slide /// - public Shape AddShape(ShapeArrowModel arrowModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + public Shape AddShape(ShapeArrowModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { diff --git a/Spreadsheet/Components/2007/Chart.cs b/Spreadsheet/Components/2007/Chart.cs index 374d114a..cf38ca84 100644 --- a/Spreadsheet/Components/2007/Chart.cs +++ b/Spreadsheet/Components/2007/Chart.cs @@ -10,8 +10,7 @@ namespace OpenXMLOffice.Spreadsheet_2007 /// /// Chart Class Exported out of Excel importing from Global /// - public class Chart : ChartProperties - where ApplicationSpecificSetting : ExcelSetting, new() + public class Chart : ChartProperties where XAxisType : class, IAxisTypeOptions, new() where YAxisType : class, IAxisTypeOptions, new() where ZAxisType : class, IAxisTypeOptions, new() @@ -20,7 +19,7 @@ public class Chart /// /// Create Area Chart with provided settings /// - internal Chart(Worksheet worksheet, ChartData[][] chartDatas, DataRange dataRange, AreaChartSetting areaChartSetting) : base(worksheet, areaChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartDatas, DataRange dataRange, AreaChartSetting areaChartSetting) : base(worksheet, areaChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); @@ -31,7 +30,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartDatas, DataRange dataRang /// /// Create Bar Chart with provided settings /// - internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, BarChartSetting barChartSetting) : base(worksheet, barChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, BarChartSetting barChartSetting) : base(worksheet, barChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); @@ -42,7 +41,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange /// /// Create Column Chart with provided settings /// - internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ColumnChartSetting columnChartSetting) : base(worksheet, columnChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ColumnChartSetting columnChartSetting) : base(worksheet, columnChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); @@ -53,7 +52,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange /// /// Create Line Chart with provided settings /// - internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, LineChartSetting lineChartSetting) : base(worksheet, lineChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, LineChartSetting lineChartSetting) : base(worksheet, lineChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); @@ -64,7 +63,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange /// /// Create Pie Chart with provided settings /// - internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, PieChartSetting pieChartSetting) : base(worksheet, pieChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, PieChartSetting pieChartSetting) : base(worksheet, pieChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); @@ -75,7 +74,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange /// /// Create Scatter Chart with provided settings /// - internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ScatterChartSetting scatterChartSetting) : base(worksheet, scatterChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ScatterChartSetting scatterChartSetting) : base(worksheet, scatterChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); @@ -86,7 +85,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange /// /// /// - internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ComboChartSetting comboChartSetting) : base(worksheet, comboChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ComboChartSetting comboChartSetting) : base(worksheet, comboChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); @@ -135,42 +134,42 @@ private void ConnectDrawingToChart(Worksheet worksheet, string chartId) }); worksheet.GetDrawing().AppendChild(twoCellAnchor); } - private void CreateChart(ChartData[][] chartData, DataRange dataRange, AreaChartSetting areaChartSetting) + private void CreateChart(ChartData[][] chartData, DataRange dataRange, AreaChartSetting areaChartSetting) { - AreaChart areaChart = new AreaChart(areaChartSetting, chartData, dataRange); + AreaChart areaChart = new AreaChart(areaChartSetting, chartData, dataRange); SaveChanges(areaChart); } - private void CreateChart(ChartData[][] chartData, DataRange dataRange, BarChartSetting barChartSetting) + private void CreateChart(ChartData[][] chartData, DataRange dataRange, BarChartSetting barChartSetting) { - BarChart barChart = new BarChart(barChartSetting, chartData, dataRange); + BarChart barChart = new BarChart(barChartSetting, chartData, dataRange); SaveChanges(barChart); } - private void CreateChart(ChartData[][] chartData, DataRange dataRange, ColumnChartSetting columnChartSetting) + private void CreateChart(ChartData[][] chartData, DataRange dataRange, ColumnChartSetting columnChartSetting) { - ColumnChart columnChart = new ColumnChart(columnChartSetting, chartData, dataRange); + ColumnChart columnChart = new ColumnChart(columnChartSetting, chartData, dataRange); SaveChanges(columnChart); } - private void CreateChart(ChartData[][] chartData, DataRange dataRange, LineChartSetting lineChartSetting) + private void CreateChart(ChartData[][] chartData, DataRange dataRange, LineChartSetting lineChartSetting) { - LineChart lineChart = new LineChart(lineChartSetting, chartData, dataRange); + LineChart lineChart = new LineChart(lineChartSetting, chartData, dataRange); SaveChanges(lineChart); } - private void CreateChart(ChartData[][] chartData, DataRange dataRange, PieChartSetting pieChartSetting) + private void CreateChart(ChartData[][] chartData, DataRange dataRange, PieChartSetting pieChartSetting) { - PieChart pieChart = new PieChart(pieChartSetting, chartData, dataRange); + PieChart pieChart = new PieChart(pieChartSetting, chartData, dataRange); SaveChanges(pieChart); } - private void CreateChart(ChartData[][] chartData, DataRange dataRange, ScatterChartSetting scatterChartSetting) + private void CreateChart(ChartData[][] chartData, DataRange dataRange, ScatterChartSetting scatterChartSetting) { - ScatterChart scatterChart = new ScatterChart(scatterChartSetting, chartData, dataRange); + ScatterChart scatterChart = new ScatterChart(scatterChartSetting, chartData, dataRange); SaveChanges(scatterChart); } - private void CreateChart(ChartData[][] chartData, DataRange dataRange, ComboChartSetting comboChartSetting) + private void CreateChart(ChartData[][] chartData, DataRange dataRange, ComboChartSetting comboChartSetting) { - ComboChart comboChart = new ComboChart(comboChartSetting, chartData, dataRange); + ComboChart comboChart = new ComboChart(comboChartSetting, chartData, dataRange); SaveChanges(comboChart); } - private void SaveChanges(ChartBase chart) + private void SaveChanges(ChartBase chart) { GetChartPart().ChartSpace = chart.GetChartSpace(); // TODO : Ignore Till 2013 color or style implementation use diff --git a/Spreadsheet/Components/2007/ChartProperties.cs b/Spreadsheet/Components/2007/ChartProperties.cs index eec84489..2223b112 100644 --- a/Spreadsheet/Components/2007/ChartProperties.cs +++ b/Spreadsheet/Components/2007/ChartProperties.cs @@ -6,17 +6,17 @@ namespace OpenXMLOffice.Spreadsheet_2007 /// /// /// - public class ChartProperties where ApplicationSpecificSetting : ExcelSetting, new() + public class ChartProperties { /// /// /// - internal readonly ChartSetting chartSetting; + internal readonly ChartSetting chartSetting; /// /// /// internal readonly Worksheet currentWorksheet; - internal ChartProperties(Worksheet worksheet, ChartSetting chartSetting) + internal ChartProperties(Worksheet worksheet, ChartSetting chartSetting) { this.chartSetting = chartSetting; currentWorksheet = worksheet; diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index d27dd797..9e1e2666 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -25,8 +25,7 @@ public void RemoveShape() openXMLShape.Remove(); } - internal Shape MakeLine(ShapeLineModel lineModel) - where ApplicationSpecificSetting : ExcelSetting, new() + internal Shape MakeLine(ShapeLineModel lineModel) where LineColorOption : class, IColorOptions, new() { XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() @@ -50,8 +49,7 @@ internal Shape MakeLine(ShapeLineMo return this; } - internal Shape MakeRectangle(ShapeRectangleModel rectangleModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape MakeRectangle(ShapeRectangleModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { @@ -63,8 +61,7 @@ internal Shape MakeRectangle(ShapeArrowModel arrowModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + internal Shape MakeArrow(ShapeArrowModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index 63cb7439..3474c720 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -9,6 +9,7 @@ using OpenXMLOffice.Global_2007; using X = DocumentFormat.OpenXml.Spreadsheet; using XDR = DocumentFormat.OpenXml.Drawing.Spreadsheet; + namespace OpenXMLOffice.Spreadsheet_2007 { /// @@ -45,8 +46,7 @@ public string GetSheetName() /// /// Insert Shape into slide /// - public Shape AddShape(ShapeLineModel lineModel) - where ApplicationSpecificSetting : ExcelSetting, new() + public Shape AddShape(ShapeLineModel lineModel) where LineColorOption : class, IColorOptions, new() { Shape shape = new Shape(this); @@ -55,8 +55,7 @@ public Shape AddShape(ShapeLineMode /// /// Insert Shape into slide /// - public Shape AddShape(ShapeRectangleModel rectangleModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + public Shape AddShape(ShapeRectangleModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { @@ -66,8 +65,7 @@ public Shape AddShape /// Insert Shape into slide /// - public Shape AddShape(ShapeArrowModel arrowModel) - where ApplicationSpecificSetting : class, ISizeAndPosition, new() + public Shape AddShape(ShapeArrowModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { @@ -269,75 +267,68 @@ public Picture AddPicture(Stream stream, ExcelPictureSetting pictureSetting) /// /// /// - public Chart AddChart(DataRange dataRange, AreaChartSetting areaChartSetting) - where ApplicationSpecificSetting : ExcelSetting, new() + public Chart AddChart(DataRange dataRange, AreaChartSetting areaChartSetting) { ChartData[][] chartData = PrepareCacheData(dataRange); dataRange.sheetName = dataRange.sheetName ?? GetSheetName(); - return new Chart(this, chartData, dataRange, areaChartSetting); + return new Chart(this, chartData, dataRange, areaChartSetting); } /// /// /// - public Chart AddChart(DataRange dataRange, BarChartSetting barChartSetting) - where ApplicationSpecificSetting : ExcelSetting, new() + public Chart AddChart(DataRange dataRange, BarChartSetting barChartSetting) { ChartData[][] chartData = PrepareCacheData(dataRange); dataRange.sheetName = dataRange.sheetName ?? GetSheetName(); - return new Chart(this, chartData, dataRange, barChartSetting); + return new Chart(this, chartData, dataRange, barChartSetting); } /// /// /// - public Chart AddChart(DataRange dataRange, ColumnChartSetting columnChartSetting) - where ApplicationSpecificSetting : ExcelSetting, new() + public Chart AddChart(DataRange dataRange, ColumnChartSetting columnChartSetting) { ChartData[][] chartData = PrepareCacheData(dataRange); dataRange.sheetName = dataRange.sheetName ?? GetSheetName(); - return new Chart(this, chartData, dataRange, columnChartSetting); + return new Chart(this, chartData, dataRange, columnChartSetting); } /// /// /// - public Chart AddChart(DataRange dataRange, LineChartSetting lineChartSetting) - where ApplicationSpecificSetting : ExcelSetting, new() + public Chart AddChart(DataRange dataRange, LineChartSetting lineChartSetting) { ChartData[][] chartData = PrepareCacheData(dataRange); dataRange.sheetName = dataRange.sheetName ?? GetSheetName(); - return new Chart(this, chartData, dataRange, lineChartSetting); + return new Chart(this, chartData, dataRange, lineChartSetting); } /// /// /// - public Chart AddChart(DataRange dataRange, PieChartSetting pieChartSetting) - where ApplicationSpecificSetting : ExcelSetting, new() + public Chart AddChart(DataRange dataRange, PieChartSetting pieChartSetting) { ChartData[][] chartData = PrepareCacheData(dataRange); dataRange.sheetName = dataRange.sheetName ?? GetSheetName(); - return new Chart(this, chartData, dataRange, pieChartSetting); + return new Chart(this, chartData, dataRange, pieChartSetting); } /// /// /// - public Chart AddChart(DataRange dataRange, ScatterChartSetting scatterChartSetting) - where ApplicationSpecificSetting : ExcelSetting, new() + public Chart AddChart(DataRange dataRange, ScatterChartSetting scatterChartSetting) { ChartData[][] chartData = PrepareCacheData(dataRange); dataRange.sheetName = dataRange.sheetName ?? GetSheetName(); - return new Chart(this, chartData, dataRange, scatterChartSetting); + return new Chart(this, chartData, dataRange, scatterChartSetting); } /// /// /// - public Chart AddChart(DataRange dataRange, ComboChartSetting comboChartSetting) - where ApplicationSpecificSetting : ExcelSetting, new() + public Chart AddChart(DataRange dataRange, ComboChartSetting comboChartSetting) where XAxisType : class, IAxisTypeOptions, new() where YAxisType : class, IAxisTypeOptions, new() where ZAxisType : class, IAxisTypeOptions, new() { ChartData[][] chartData = PrepareCacheData(dataRange); dataRange.sheetName = dataRange.sheetName ?? GetSheetName(); - return new Chart(this, chartData, dataRange, comboChartSetting); + return new Chart(this, chartData, dataRange, comboChartSetting); } /// /// Add Merge cell range to the current sheet if it's not overlapping with existing range diff --git a/Tests/Presentation.cs b/Tests/Presentation.cs index 6a16102b..f6e1bb67 100644 --- a/Tests/Presentation.cs +++ b/Tests/Presentation.cs @@ -74,7 +74,7 @@ public void Add2007Charts() applicationSpecificSetting = new() }); //2 - Chart chart = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() + Chart chart = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() { applicationSpecificSetting = new(), areaChartType = G.AreaChartTypes.STACKED, @@ -1051,7 +1051,7 @@ public void OpenExistingPresentationEditBarChart() List shape4 = slide.FindShapeByText("Slide_1_Shape_4").ToList(); List shape5 = slide.FindShapeByText("Slide_1_Shape_5").ToList(); List shape6 = slide.FindShapeByText("Slide_1_Shape_6").ToList(); - shape1[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), + shape1[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.ColumnChartSetting() { applicationSpecificSetting = new(), @@ -1060,7 +1060,7 @@ public void OpenExistingPresentationEditBarChart() isEnableLegend = false }, })); - shape2[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), + shape2[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.BarChartSetting() { applicationSpecificSetting = new(), @@ -1069,7 +1069,7 @@ public void OpenExistingPresentationEditBarChart() legendPosition = G.ChartLegendOptions.LegendPositionValues.RIGHT } })); - shape3[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.LineChartSetting() + shape3[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.LineChartSetting() { applicationSpecificSetting = new(), chartAxisOptions = new() @@ -1090,11 +1090,11 @@ public void OpenExistingPresentationEditBarChart() isMinorValueLinesEnabled = true, } })); - shape4[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.LineChartSetting() + shape4[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.LineChartSetting() { applicationSpecificSetting = new() })); - shape5[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() + shape5[0].ReplaceChart(new Chart(slide, CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() { applicationSpecificSetting = new() })); From cc64c987022f67eb90db04758da7d487097cd071 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Fri, 14 Jun 2024 08:10:15 +0000 Subject: [PATCH 05/25] Reorganizing Shape --- Global/Models/2007/ShapeModel.cs | 7 ++++ Presentation/Components/2007/Chart.cs | 18 ---------- Presentation/Parts/CommonSlideData.cs | 44 ++++++++++++------------- Spreadsheet/Components/2007/Chart.cs | 4 +-- Spreadsheet/Components/2007/Shape.cs | 30 +++++++++++++++-- Spreadsheet/Models/2007/DrawingModel.cs | 4 +++ Spreadsheet/Parts/Drawing.cs | 13 ++++++++ 7 files changed, 76 insertions(+), 44 deletions(-) diff --git a/Global/Models/2007/ShapeModel.cs b/Global/Models/2007/ShapeModel.cs index 4e08fa11..37fda60b 100644 --- a/Global/Models/2007/ShapeModel.cs +++ b/Global/Models/2007/ShapeModel.cs @@ -185,4 +185,11 @@ public class ShapeArrowModel public FillColorOption fillColorOption = new FillColorOption(); } + /// + /// + /// + public class ShapeModel + { + + } } \ No newline at end of file diff --git a/Presentation/Components/2007/Chart.cs b/Presentation/Components/2007/Chart.cs index 18dc60a9..4a592e65 100644 --- a/Presentation/Components/2007/Chart.cs +++ b/Presentation/Components/2007/Chart.cs @@ -22,9 +22,6 @@ public class Chart : ChartProperties /// /// Create Area Chart with provided settings /// Not Required Generic - /// XAxisType - /// YAxisType - /// ZAxisType /// public Chart(Slide slide, DataCell[][] dataRows, AreaChartSetting areaChartSetting) : base(slide, areaChartSetting) { @@ -35,9 +32,6 @@ public Chart(Slide slide, DataCell[][] dataRows, AreaChartSetting /// Create Bar Chart with provided settings /// Not Required Generic - /// XAxisType - /// YAxisType - /// ZAxisType /// public Chart(Slide slide, DataCell[][] dataRows, BarChartSetting barChartSetting) : base(slide, barChartSetting) { @@ -48,9 +42,6 @@ public Chart(Slide slide, DataCell[][] dataRows, BarChartSetting /// Create Column Chart with provided settings /// Not Required Generic - /// XAxisType - /// YAxisType - /// ZAxisType /// public Chart(Slide slide, DataCell[][] dataRows, ColumnChartSetting columnChartSetting) : base(slide, columnChartSetting) { @@ -61,9 +52,6 @@ public Chart(Slide slide, DataCell[][] dataRows, ColumnChartSetting /// Create Line Chart with provided settings /// Not Required Generic - /// XAxisType - /// YAxisType - /// ZAxisType /// public Chart(Slide slide, DataCell[][] dataRows, LineChartSetting lineChartSetting) : base(slide, lineChartSetting) { @@ -74,9 +62,6 @@ public Chart(Slide slide, DataCell[][] dataRows, LineChartSetting /// Create Pie Chart with provided settings /// Not Required Generic - /// XAxisType - /// YAxisType - /// ZAxisType /// public Chart(Slide slide, DataCell[][] dataRows, PieChartSetting pieChartSetting) : base(slide, pieChartSetting) { @@ -87,9 +72,6 @@ public Chart(Slide slide, DataCell[][] dataRows, PieChartSetting /// Create Scatter Chart with provided settings /// Not Required Generic - /// XAxisType - /// YAxisType - /// ZAxisType /// public Chart(Slide slide, DataCell[][] dataRows, ScatterChartSetting scatterChartSetting) : base(slide, scatterChartSetting) { diff --git a/Presentation/Parts/CommonSlideData.cs b/Presentation/Parts/CommonSlideData.cs index ffe56057..8c6bf035 100644 --- a/Presentation/Parts/CommonSlideData.cs +++ b/Presentation/Parts/CommonSlideData.cs @@ -1,8 +1,8 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. -using DocumentFormat.OpenXml.Presentation; using A = DocumentFormat.OpenXml.Drawing; using P = DocumentFormat.OpenXml.Presentation; + namespace OpenXMLOffice.Presentation_2007 { /// @@ -30,9 +30,9 @@ internal P.CommonSlideData GetCommonSlideData() } private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType commonSlideDataType) { - Background background = new Background() + P.Background background = new P.Background() { - BackgroundStyleReference = new BackgroundStyleReference(new A.SchemeColor() + BackgroundStyleReference = new P.BackgroundStyleReference(new A.SchemeColor() { Val = A.SchemeColorValues.Background1 }) @@ -40,9 +40,9 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com Index = 1001 } }; - ShapeTree shapeTree = new ShapeTree() + P.ShapeTree shapeTree = new P.ShapeTree() { - GroupShapeProperties = new GroupShapeProperties() + GroupShapeProperties = new P.GroupShapeProperties() { TransformGroup = new A.TransformGroup() { @@ -68,10 +68,10 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com } } }, - NonVisualGroupShapeProperties = new NonVisualGroupShapeProperties( - new NonVisualDrawingProperties { Id = 1, Name = "" }, - new NonVisualGroupShapeDrawingProperties(), - new ApplicationNonVisualDrawingProperties() + NonVisualGroupShapeProperties = new P.NonVisualGroupShapeProperties( + new P.NonVisualDrawingProperties { Id = 1, Name = "" }, + new P.NonVisualGroupShapeDrawingProperties(), + new P.ApplicationNonVisualDrawingProperties() ) }; switch (commonSlideDataType) @@ -93,19 +93,19 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com private static P.Shape CreateShape1() { P.Shape shape = new P.Shape(); - NonVisualShapeProperties nonVisualShapeProperties = new NonVisualShapeProperties( - new NonVisualDrawingProperties { Id = 2, Name = "Title 1" }, - new NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), - new ApplicationNonVisualDrawingProperties(new PlaceholderShape { Type = PlaceholderValues.Title }) + P.NonVisualShapeProperties nonVisualShapeProperties = new P.NonVisualShapeProperties( + new P.NonVisualDrawingProperties { Id = 2, Name = "Title 1" }, + new P.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), + new P.ApplicationNonVisualDrawingProperties(new P.PlaceholderShape { Type = P.PlaceholderValues.Title }) ); - ShapeProperties shapeProperties = new ShapeProperties( + P.ShapeProperties shapeProperties = new P.ShapeProperties( new A.Transform2D( new A.Offset { X = 838200L, Y = 365125L }, new A.Extents { Cx = 10515600L, Cy = 1325563L } ), new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle } ); - TextBody textBody = new TextBody( + P.TextBody textBody = new P.TextBody( new A.BodyProperties(), new A.ListStyle(), new A.Paragraph( @@ -124,20 +124,20 @@ private static P.Shape CreateShape1() private static P.Shape CreateShape2() { P.Shape shape = new P.Shape(); - NonVisualShapeProperties nonVisualShapeProperties = new NonVisualShapeProperties( - new NonVisualDrawingProperties { Id = 3U, Name = "Text Placeholder 2" }, - new NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), - new ApplicationNonVisualDrawingProperties( - new PlaceholderShape { Index = 1U, Type = PlaceholderValues.Body }) + P.NonVisualShapeProperties nonVisualShapeProperties = new P.NonVisualShapeProperties( + new P.NonVisualDrawingProperties { Id = 3U, Name = "Text Placeholder 2" }, + new P.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), + new P.ApplicationNonVisualDrawingProperties( + new P.PlaceholderShape { Index = 1U, Type = P.PlaceholderValues.Body }) ); - ShapeProperties shapeProperties = new ShapeProperties( + P.ShapeProperties shapeProperties = new P.ShapeProperties( new A.Transform2D( new A.Offset { X = 838200L, Y = 1825625L }, new A.Extents { Cx = 10515600L, Cy = 4351338L } ), new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle } ); - TextBody textBody = new TextBody( + P.TextBody textBody = new P.TextBody( new A.BodyProperties(), new A.ListStyle(), new A.Paragraph( diff --git a/Spreadsheet/Components/2007/Chart.cs b/Spreadsheet/Components/2007/Chart.cs index cf38ca84..9123c025 100644 --- a/Spreadsheet/Components/2007/Chart.cs +++ b/Spreadsheet/Components/2007/Chart.cs @@ -19,13 +19,13 @@ public class Chart : ChartProperties /// /// Create Area Chart with provided settings /// - internal Chart(Worksheet worksheet, ChartData[][] chartDatas, DataRange dataRange, AreaChartSetting areaChartSetting) : base(worksheet, areaChartSetting) + internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, AreaChartSetting areaChartSetting) : base(worksheet, areaChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); - CreateChart(chartDatas, dataRange, areaChartSetting); + CreateChart(chartData, dataRange, areaChartSetting); } /// /// Create Bar Chart with provided settings diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index 9e1e2666..cc53a470 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -55,7 +55,20 @@ internal Shape MakeRectangle(ShapeRectangleMod { XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { - + from = new AnchorPosition() + { + row = rectangleModel.applicationSpecificSetting.from.row, + rowOffset = rectangleModel.applicationSpecificSetting.from.rowOffset, + column = rectangleModel.applicationSpecificSetting.from.column, + columnOffset = rectangleModel.applicationSpecificSetting.from.columnOffset, + }, + to = new AnchorPosition() + { + row = rectangleModel.applicationSpecificSetting.to.row, + rowOffset = rectangleModel.applicationSpecificSetting.to.rowOffset, + column = rectangleModel.applicationSpecificSetting.to.column, + columnOffset = rectangleModel.applicationSpecificSetting.to.columnOffset, + }, }); worksheet.GetDrawing().AppendChild(twoCellAnchor); return this; @@ -67,7 +80,20 @@ internal Shape MakeArrow(ShapeArrowModel /// /// + public ShapeModel shapeModel; + /// + /// + /// public uint x = 0; /// /// diff --git a/Spreadsheet/Parts/Drawing.cs b/Spreadsheet/Parts/Drawing.cs index 512e2598..e1ec5d34 100644 --- a/Spreadsheet/Parts/Drawing.cs +++ b/Spreadsheet/Parts/Drawing.cs @@ -6,6 +6,9 @@ using A = DocumentFormat.OpenXml.Drawing; using X = DocumentFormat.OpenXml.Spreadsheet; using OpenXMLOffice.Global_2007; +using DocumentFormat.OpenXml; +using System; + namespace OpenXMLOffice.Spreadsheet_2007 { /// @@ -82,8 +85,18 @@ internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorM { twoCellAnchor.AddChild(CreatePicture(twoCellAnchorModel.drawingPictureModel)); } + if (twoCellAnchorModel.shapeModel != null) + { + twoCellAnchor.AddChild(CreateModel(twoCellAnchorModel.shapeModel)); + } return twoCellAnchor; } + + private XDR.Shape CreateModel(ShapeModel shapeModel) + { + return new XDR.Shape(); + } + private static XDR.GraphicFrame CreateGraphicFrame(DrawingGraphicFrame drawingGraphicFrame) { return new XDR.GraphicFrame() From 6057a1b589bd0c0bde779fb9d4ce98d3f807cc34 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Sat, 15 Jun 2024 09:45:02 +0000 Subject: [PATCH 06/25] Reorganizing Shape and common components --- Global/Models/2007/ShapeModel.cs | 40 ++++++++++++++++- Presentation/Components/2007/Chart.cs | 6 +-- Presentation/Components/2007/Picture.cs | 10 ++--- .../2007/PresentationCommonProperties.cs | 45 +++++++++++++++++++ Presentation/Components/2007/Shape.cs | 12 ++--- Presentation/Components/2007/TextBox.cs | 24 +++++----- .../2016/AdvancedChartProperties.cs | 2 +- Presentation/Components/2016/Chart.cs | 6 +-- .../Components/Common/ChartProperties.cs | 4 +- Presentation/Internal/Presentation.cs | 10 ++--- Presentation/Internal/PresentationCore.cs | 18 ++++---- Presentation/Parts/CommonSlideData.cs | 17 +++---- Presentation/Parts/SlideLayout.cs | 4 +- Presentation/Parts/SlideMaster.cs | 8 ++-- Presentation/Parts/ViewProperties.cs | 8 ++-- Spreadsheet/Components/2007/Chart.cs | 2 +- Spreadsheet/Components/2007/Picture.cs | 4 +- Spreadsheet/Components/2007/Shape.cs | 14 +++--- .../2007/SpreadSheetCommonProperties.cs | 44 ++++++++++++++++++ Spreadsheet/Components/2007/TextBox.cs | 2 +- Spreadsheet/Models/2007/DrawingModel.cs | 5 ++- Spreadsheet/Parts/Drawing.cs | 14 ++---- Spreadsheet/Parts/Worksheet.cs | 10 +++-- 23 files changed, 217 insertions(+), 92 deletions(-) create mode 100644 Presentation/Components/2007/PresentationCommonProperties.cs create mode 100644 Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs diff --git a/Global/Models/2007/ShapeModel.cs b/Global/Models/2007/ShapeModel.cs index 37fda60b..5ece8467 100644 --- a/Global/Models/2007/ShapeModel.cs +++ b/Global/Models/2007/ShapeModel.cs @@ -1,5 +1,7 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. +using DocumentFormat.OpenXml; + namespace OpenXMLOffice.Global_2007 { /// @@ -188,8 +190,42 @@ public class ShapeArrowModel /// /// - public class ShapeModel + public class ShapePropertiesModel { - + /// + /// + /// + public int X = 1562100; + /// + /// + /// + public int Y = 1524000; + /// + /// + /// + public int Cx = 4743450; + /// + /// + /// + public int Cy = 1419225; + } + /// + /// + /// + public class ShapeModel + where TextColorOption : class, IColorOptions, new() + { + /// + /// + /// + public string Name = ""; + /// + /// + /// + public ShapePropertiesModel shapePropertiesModel = new ShapePropertiesModel(); + /// + /// + /// + public DrawingParagraphModel drawingParagraph; } } \ No newline at end of file diff --git a/Presentation/Components/2007/Chart.cs b/Presentation/Components/2007/Chart.cs index 4a592e65..db614bae 100644 --- a/Presentation/Components/2007/Chart.cs +++ b/Presentation/Components/2007/Chart.cs @@ -207,9 +207,9 @@ private ChartStylePart GetChartStylePart() } private void InitializeChartParts() { - GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); - GetChartPart().AddNewPart(GetNextChartRelationId()); - GetChartPart().AddNewPart(GetNextChartRelationId()); + var unused2 = GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); + var unused1 = GetChartPart().AddNewPart(GetNextChartRelationId()); + var unused = GetChartPart().AddNewPart(GetNextChartRelationId()); } } } diff --git a/Presentation/Components/2007/Picture.cs b/Presentation/Components/2007/Picture.cs index 00e2104c..3fb393ee 100644 --- a/Presentation/Components/2007/Picture.cs +++ b/Presentation/Components/2007/Picture.cs @@ -11,7 +11,7 @@ namespace OpenXMLOffice.Presentation_2007 /// /// Picture Import Class /// - public class Picture : CommonProperties + public class Picture : PresentationCommonProperties { private readonly Slide currentSlide; private readonly P.Picture openXMLPicture; @@ -71,13 +71,13 @@ private void Initialize(Stream stream, Slide slide, PictureSetting pictureSettin case HyperlinkPropertyTypeValues.EXISTING_FILE: pictureSetting.hyperlinkProperties.relationId = relationId; pictureSetting.hyperlinkProperties.action = "ppaction://hlinkfile"; - slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); + var unused2 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SLIDE: pictureSetting.hyperlinkProperties.relationId = relationId; pictureSetting.hyperlinkProperties.action = "ppaction://hlinksldjump"; //TODO: Update Target Slide Prop - slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); + var unused1 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SHEET: throw new ArgumentException("This Option is valid only for Excel Files"); @@ -95,7 +95,7 @@ private void Initialize(Stream stream, Slide slide, PictureSetting pictureSettin break; default:// Web URL pictureSetting.hyperlinkProperties.relationId = relationId; - slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); + var unused = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); break; } } @@ -172,7 +172,7 @@ private void CreatePicture(string EmbedId, HyperlinkProperties hyperlinkProperti ); if (hyperlinkProperties != null) { - GetPicture().NonVisualPictureProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); + var unused = GetPicture().NonVisualPictureProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); } GetPicture().ShapeProperties = new P.ShapeProperties( new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle } diff --git a/Presentation/Components/2007/PresentationCommonProperties.cs b/Presentation/Components/2007/PresentationCommonProperties.cs new file mode 100644 index 00000000..ffd07453 --- /dev/null +++ b/Presentation/Components/2007/PresentationCommonProperties.cs @@ -0,0 +1,45 @@ +// Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. + +using A = DocumentFormat.OpenXml.Drawing; +using P = DocumentFormat.OpenXml.Presentation; +namespace OpenXMLOffice.Global_2007 +{ + /// + /// Common Properties organized in one place to get inherited by child classes + /// + public class PresentationCommonProperties : CommonProperties + { + /// + /// + /// + protected P.Shape CreateShape(ShapeModel shapeModel) + where TextColorOption : class, IColorOptions, new() + { + P.Shape shape = new P.Shape() + { + NonVisualShapeProperties = new P.NonVisualShapeProperties( + new P.NonVisualDrawingProperties { Id = 2, Name = shapeModel.Name }, + new P.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), + new P.ApplicationNonVisualDrawingProperties(new P.PlaceholderShape { Type = P.PlaceholderValues.Title })), + ShapeProperties = new P.ShapeProperties( + new A.Transform2D( + new A.Offset + { + X = shapeModel.shapePropertiesModel.X, + Y = shapeModel.shapePropertiesModel.Y + }, + new A.Extents + { + Cx = shapeModel.shapePropertiesModel.Cx, + Cy = shapeModel.shapePropertiesModel.Cy + } + ), + new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle }), + TextBody = new P.TextBody(new A.BodyProperties(), + new A.ListStyle(), + CreateDrawingParagraph(shapeModel.drawingParagraph)) + }; + return shape; + } + } +} diff --git a/Presentation/Components/2007/Shape.cs b/Presentation/Components/2007/Shape.cs index ecbb8790..ac3f1cd1 100644 --- a/Presentation/Components/2007/Shape.cs +++ b/Presentation/Components/2007/Shape.cs @@ -11,7 +11,7 @@ namespace OpenXMLOffice.Presentation_2007 /// /// Shape Class For Presentation shape manipulation /// - public class Shape : CommonProperties + public class Shape : PresentationCommonProperties { private readonly P.Shape openXMLShape = new P.Shape(); internal Shape(P.Shape shape = null) @@ -71,7 +71,7 @@ public Chart ReplaceChart - /// Represents Textbox class to build on + /// Represents TextBox class to build on /// - public class TextBox : CommonProperties + public class TextBox : PresentationCommonProperties { private readonly TextBoxSetting textBoxSetting; private P.Shape openXMLShape; private readonly Slide slide; /// - /// Create Textbox with provided settings + /// Create TextBox with provided settings /// internal TextBox(TextBoxSetting TextBoxSetting) { textBoxSetting = TextBoxSetting; - CreateTextBox(); + var unused = CreateTextBox(); } /// - /// Create Textbox with provided settings + /// Create TextBox with provided settings /// public TextBox(Slide Slide, TextBoxSetting TextBoxSetting) { slide = Slide; textBoxSetting = TextBoxSetting; - CreateTextBox(); + var unused = CreateTextBox(); slide.GetSlide().CommonSlideData.ShapeTree.Append(GetTextBoxShape()); } /// - /// Get Textbox Shape + /// Get TextBox Shape /// internal P.Shape GetTextBoxShape() { return openXMLShape; } /// - /// Update Textbox Position + /// Update TextBox Position /// public void UpdatePosition(uint X, uint Y) { @@ -57,7 +57,7 @@ public void UpdatePosition(uint X, uint Y) } } /// - /// Update Textbox Size + /// Update TextBox Size /// public void UpdateSize(uint Width, uint Height) { @@ -113,13 +113,13 @@ private P.Shape CreateTextBox() case HyperlinkPropertyTypeValues.EXISTING_FILE: textBlock.hyperlinkProperties.relationId = relationId; textBlock.hyperlinkProperties.action = "ppaction://hlinkfile"; - slide.GetSlidePart().AddHyperlinkRelationship(new System.Uri(textBlock.hyperlinkProperties.value), true, relationId); + var unused2 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SLIDE: textBlock.hyperlinkProperties.relationId = relationId; textBlock.hyperlinkProperties.action = "ppaction://hlinksldjump"; //TODO: Update Target Slide Prop - slide.GetSlidePart().AddHyperlinkRelationship(new System.Uri(textBlock.hyperlinkProperties.value), true, relationId); + var unused1 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SHEET: throw new ArgumentException("This Option is valid only for Excel Files"); @@ -137,7 +137,7 @@ private P.Shape CreateTextBox() break; default:// Web URL textBlock.hyperlinkProperties.relationId = relationId; - slide.GetSlidePart().AddHyperlinkRelationship(new System.Uri(textBlock.hyperlinkProperties.value), true, relationId); + var unused = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); break; } } diff --git a/Presentation/Components/2016/AdvancedChartProperties.cs b/Presentation/Components/2016/AdvancedChartProperties.cs index 197266ab..57d7159e 100644 --- a/Presentation/Components/2016/AdvancedChartProperties.cs +++ b/Presentation/Components/2016/AdvancedChartProperties.cs @@ -44,7 +44,7 @@ internal void CreateExtendedChartGraphicFrame(string relationshipId, uint id, Hy }; if (hyperlinkProperties != null) { - nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); + var unused = nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); } graphicFrame = new P.GraphicFrame() { diff --git a/Presentation/Components/2016/Chart.cs b/Presentation/Components/2016/Chart.cs index dc549cb5..2a66cfb2 100644 --- a/Presentation/Components/2016/Chart.cs +++ b/Presentation/Components/2016/Chart.cs @@ -84,9 +84,9 @@ private ChartStylePart GetChartStylePart() } private void InitializeChartParts() { - GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); - GetChartPart().AddNewPart(GetNextChartRelationId()); - GetChartPart().AddNewPart(GetNextChartRelationId()); + var unused2 = GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); + var unused1 = GetChartPart().AddNewPart(GetNextChartRelationId()); + var unused = GetChartPart().AddNewPart(GetNextChartRelationId()); } } } diff --git a/Presentation/Components/Common/ChartProperties.cs b/Presentation/Components/Common/ChartProperties.cs index 0ea21762..79e6290c 100644 --- a/Presentation/Components/Common/ChartProperties.cs +++ b/Presentation/Components/Common/ChartProperties.cs @@ -13,7 +13,7 @@ namespace OpenXMLOffice.Presentation_2007 /// /// /// - public class ChartProperties : CommonProperties + public class ChartProperties : PresentationCommonProperties { /// /// @@ -150,7 +150,7 @@ internal void CreateChartGraphicFrame(string relationshipId, uint id, HyperlinkP }; if (hyperlinkProperties != null) { - nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); + var unused = nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); } graphicFrame = new P.GraphicFrame() { diff --git a/Presentation/Internal/Presentation.cs b/Presentation/Internal/Presentation.cs index 3ebfef3b..eccd6e46 100644 --- a/Presentation/Internal/Presentation.cs +++ b/Presentation/Internal/Presentation.cs @@ -21,7 +21,7 @@ internal Slide AddSlide(PresentationConstants.SlideLayoutType slideLayoutType) SlidePart slidePart = GetPresentationPart().AddNewPart(GetNextPresentationRelationId()); Slide slide = new Slide(); slidePart.Slide = slide.GetSlide(); - slidePart.AddPart(GetSlideLayoutPart(slideLayoutType)); + var unused = slidePart.AddPart(GetSlideLayoutPart(slideLayoutType)); P.SlideIdList slideIdList = GetSlideIdList(); P.SlideId slideId = new P.SlideId() { Id = GetNextSlideId(), RelationshipId = GetPresentationPart().GetIdOfPart(slidePart) }; slideIdList.Append(slideId); @@ -51,8 +51,8 @@ internal void MoveSlideByIndex(int SourceIndex, int TargetIndex) { P.SlideId SourceSlideId = (P.SlideId)GetSlideIdList().ElementAt(SourceIndex); P.SlideId TargetSlideId = (P.SlideId)GetSlideIdList().ElementAt(TargetIndex); - GetSlideIdList().RemoveChild(SourceSlideId); - GetSlideIdList().InsertBefore(SourceSlideId, TargetSlideId); + var unused1 = GetSlideIdList().RemoveChild(SourceSlideId); + var unused = GetSlideIdList().InsertBefore(SourceSlideId, TargetSlideId); presentationDocument.Save(); } else @@ -66,7 +66,7 @@ internal void RemoveSlideByIndex(int SlideIndex) { P.SlideId SlideId = (P.SlideId)GetSlideIdList().ElementAt(SlideIndex); SlidePart SlidePart = (SlidePart)GetPresentationPart().GetPartById(SlideId.RelationshipId.Value); - GetSlideIdList().RemoveChild(SlideId); + var unused1 = GetSlideIdList().RemoveChild(SlideId); try { GetPresentationPart().DeleteReferenceRelationship(SlideId.RelationshipId.Value); @@ -76,7 +76,7 @@ internal void RemoveSlideByIndex(int SlideIndex) { throw; } - GetPresentationPart().DeletePart(SlidePart); + var unused = GetPresentationPart().DeletePart(SlidePart); } else { diff --git a/Presentation/Internal/PresentationCore.cs b/Presentation/Internal/PresentationCore.cs index a77ffe99..c0da61b3 100644 --- a/Presentation/Internal/PresentationCore.cs +++ b/Presentation/Internal/PresentationCore.cs @@ -137,7 +137,7 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) SlideLayout slideLayout = new SlideLayout(); if (presentationDocument.CoreFilePropertiesPart == null) { - presentationDocument.AddCoreFilePropertiesPart(); + var unused8 = presentationDocument.AddCoreFilePropertiesPart(); using (Stream stream = presentationDocument.CoreFilePropertiesPart.GetStream(FileMode.OpenOrCreate, FileAccess.ReadWrite)) { CoreProperties.AddCoreProperties(stream, powerPointProperties.coreProperties); @@ -160,23 +160,23 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) } if (presentationPart.Presentation.GetFirstChild() == null) { - presentationPart.Presentation.AppendChild(new P.SlideMasterIdList()); + var unused7 = presentationPart.Presentation.AppendChild(new P.SlideMasterIdList()); } if (presentationPart.Presentation.SlideIdList == null) { - presentationPart.Presentation.AppendChild(new P.SlideIdList()); + var unused6 = presentationPart.Presentation.AppendChild(new P.SlideIdList()); } if (presentationPart.Presentation.GetFirstChild() == null) { - presentationPart.Presentation.AppendChild(new P.SlideSize { Cx = 12192000, Cy = 6858000 }); + var unused5 = presentationPart.Presentation.AppendChild(new P.SlideSize { Cx = 12192000, Cy = 6858000 }); } if (presentationPart.Presentation.GetFirstChild() == null) { - presentationPart.Presentation.AppendChild(new P.NotesSize { Cx = 6858000, Cy = 6858000 }); + var unused4 = presentationPart.Presentation.AppendChild(new P.NotesSize { Cx = 6858000, Cy = 6858000 }); } if (presentationPart.Presentation.GetFirstChild() == null) { - presentationPart.Presentation.AppendChild(CreateDefaultTextStyle()); + var unused3 = presentationPart.Presentation.AppendChild(CreateDefaultTextStyle()); } if (presentationPart.ViewPropertiesPart == null) { @@ -203,7 +203,7 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) SlideLayoutPart slideLayoutPart = slideMasterPart.AddNewPart(GetNextPresentationRelationId()); slideMaster.AddSlideLayoutIdToList(slideMasterPart.GetIdOfPart(slideLayoutPart)); slideLayoutPart.SlideLayout = slideLayout.GetSlideLayout(); - slideLayout.UpdateRelationship(slideMasterPart, presentationPart.GetIdOfPart(slideMasterPart)); + var unused2 = slideLayout.UpdateRelationship(slideMasterPart, presentationPart.GetIdOfPart(slideMasterPart)); slideLayoutPart.SlideLayout.Save(); slideMasterPart.SlideMaster.Save(); } @@ -230,14 +230,14 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) } if (presentationPart.ThemePart == null) { - presentationPart.AddNewPart(GetNextPresentationRelationId()); + var unused1 = presentationPart.AddNewPart(GetNextPresentationRelationId()); } if (presentationPart.ThemePart.Theme == null) { Theme theme = new Theme(powerPointProperties.theme); presentationPart.ThemePart.Theme = theme.GetTheme(); } - slideMaster.UpdateRelationship(presentationPart.ThemePart, presentationPart.GetIdOfPart(presentationPart.ThemePart)); + var unused = slideMaster.UpdateRelationship(presentationPart.ThemePart, presentationPart.GetIdOfPart(presentationPart.ThemePart)); presentationPart.Presentation.Save(); } } diff --git a/Presentation/Parts/CommonSlideData.cs b/Presentation/Parts/CommonSlideData.cs index 8c6bf035..3acefb04 100644 --- a/Presentation/Parts/CommonSlideData.cs +++ b/Presentation/Parts/CommonSlideData.cs @@ -1,14 +1,15 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. +using OpenXMLOffice.Global_2007; using A = DocumentFormat.OpenXml.Drawing; using P = DocumentFormat.OpenXml.Presentation; namespace OpenXMLOffice.Presentation_2007 { /// - /// Common Slide Data Class used to create the base components of a slide, slidemaster. + /// Common Slide Data Class used to create the base components of a slide, slideMaster. /// - public class CommonSlideData + public class CommonSlideData : PresentationCommonProperties { private readonly P.CommonSlideData openXMLCommonSlideData; internal CommonSlideData(PresentationConstants.CommonSlideDataType commonSlideDataType, PresentationConstants.SlideLayoutType layoutType) @@ -77,16 +78,16 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com switch (commonSlideDataType) { case PresentationConstants.CommonSlideDataType.SLIDE_MASTER: - openXMLCommonSlideData.AppendChild(background); - openXMLCommonSlideData.AppendChild(shapeTree); + var unused5 = openXMLCommonSlideData.AppendChild(background); + var unused4 = openXMLCommonSlideData.AppendChild(shapeTree); break; case PresentationConstants.CommonSlideDataType.SLIDE_LAYOUT: - shapeTree.AppendChild(CreateShape1()); - shapeTree.AppendChild(CreateShape2()); - openXMLCommonSlideData.AppendChild(shapeTree); + var unused3 = shapeTree.AppendChild(CreateShape1()); + var unused2 = shapeTree.AppendChild(CreateShape2()); + var unused1 = openXMLCommonSlideData.AppendChild(shapeTree); break; default: // slide - openXMLCommonSlideData.AppendChild(shapeTree); + var unused = openXMLCommonSlideData.AppendChild(shapeTree); break; } } diff --git a/Presentation/Parts/SlideLayout.cs b/Presentation/Parts/SlideLayout.cs index 2b9ff6ea..85e57652 100644 --- a/Presentation/Parts/SlideLayout.cs +++ b/Presentation/Parts/SlideLayout.cs @@ -25,11 +25,11 @@ public string UpdateRelationship(OpenXmlPart openXmlPart, string RelationshipId) } private void CreateSlideLayout() { - openXMLSlideLayout.AppendChild(commonSlideData.GetCommonSlideData()); + var unused1 = openXMLSlideLayout.AppendChild(commonSlideData.GetCommonSlideData()); openXMLSlideLayout.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); openXMLSlideLayout.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); openXMLSlideLayout.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); - openXMLSlideLayout.AppendChild(new P.ColorMapOverride() + var unused = openXMLSlideLayout.AppendChild(new P.ColorMapOverride() { MasterColorMapping = new A.MasterColorMapping() }); diff --git a/Presentation/Parts/SlideMaster.cs b/Presentation/Parts/SlideMaster.cs index 0c02dc8c..638b2b45 100644 --- a/Presentation/Parts/SlideMaster.cs +++ b/Presentation/Parts/SlideMaster.cs @@ -16,7 +16,7 @@ internal class SlideMaster } public void AddSlideLayoutIdToList(string relationshipId) { - slideLayoutIdList.AppendChild(new P.SlideLayoutId() + var unused = slideLayoutIdList.AppendChild(new P.SlideLayoutId() { Id = (uint)(2147483649 + slideLayoutIdList.Count() + 1), RelationshipId = relationshipId @@ -41,7 +41,7 @@ private void CreateSlideMaster() openXMLSlideMaster.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); openXMLSlideMaster.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); openXMLSlideMaster.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); - openXMLSlideMaster.AppendChild(new P.ColorMap() + var unused2 = openXMLSlideMaster.AppendChild(new P.ColorMap() { Accent1 = A.ColorSchemeIndexValues.Accent1, Accent2 = A.ColorSchemeIndexValues.Accent2, @@ -56,8 +56,8 @@ private void CreateSlideMaster() Hyperlink = A.ColorSchemeIndexValues.Hyperlink, FollowedHyperlink = A.ColorSchemeIndexValues.FollowedHyperlink }); - openXMLSlideMaster.AppendChild(slideLayoutIdList); - openXMLSlideMaster.AppendChild(CreateTextStyles()); + var unused1 = openXMLSlideMaster.AppendChild(slideLayoutIdList); + var unused = openXMLSlideMaster.AppendChild(CreateTextStyles()); } private static P.TextStyles CreateTextStyles() { diff --git a/Presentation/Parts/ViewProperties.cs b/Presentation/Parts/ViewProperties.cs index a209936e..983fc370 100644 --- a/Presentation/Parts/ViewProperties.cs +++ b/Presentation/Parts/ViewProperties.cs @@ -18,10 +18,10 @@ public ViewProperties() openXMLViewProperties.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); openXMLViewProperties.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); openXMLViewProperties.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); - openXMLViewProperties.AppendChild(CreateNormalViewProperties()); - openXMLViewProperties.AppendChild(CreateSlideViewProperties()); - openXMLViewProperties.AppendChild(CreateNotesTextViewProperties()); - openXMLViewProperties.AppendChild(new P.GridSpacing() + var unused3 = openXMLViewProperties.AppendChild(CreateNormalViewProperties()); + var unused2 = openXMLViewProperties.AppendChild(CreateSlideViewProperties()); + var unused1 = openXMLViewProperties.AppendChild(CreateNotesTextViewProperties()); + var unused = openXMLViewProperties.AppendChild(new P.GridSpacing() { Cx = 72008, Cy = 72008 diff --git a/Spreadsheet/Components/2007/Chart.cs b/Spreadsheet/Components/2007/Chart.cs index 9123c025..98cf90e6 100644 --- a/Spreadsheet/Components/2007/Chart.cs +++ b/Spreadsheet/Components/2007/Chart.cs @@ -108,7 +108,7 @@ internal string GetNextChartRelationId() private void ConnectDrawingToChart(Worksheet worksheet, string chartId) { // Add anchor to drawing for chart graphics - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { anchorEditType = AnchorEditType.NONE, from = new AnchorPosition() diff --git a/Spreadsheet/Components/2007/Picture.cs b/Spreadsheet/Components/2007/Picture.cs index 26bc6ed3..4e2969ad 100644 --- a/Spreadsheet/Components/2007/Picture.cs +++ b/Spreadsheet/Components/2007/Picture.cs @@ -10,7 +10,7 @@ namespace OpenXMLOffice.Spreadsheet_2007 /// /// Excel Picture /// - public class Picture : CommonProperties + public class Picture : SpreadSheetCommonProperties { private readonly ExcelPictureSetting excelPictureSetting; private readonly Worksheet currentWorksheet; @@ -71,7 +71,7 @@ private void AddImageToDrawing(Stream stream) break; } } - XDR.TwoCellAnchor twoCellAnchor = currentWorksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = currentWorksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { anchorEditType = AnchorEditType.ONE_CELL, from = excelPictureSetting.from, diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index cc53a470..94e7002c 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -8,7 +8,7 @@ namespace OpenXMLOffice.Spreadsheet_2007 /// /// Shape Class For Presentation shape manipulation /// - public class Shape : CommonProperties + public class Shape : SpreadSheetCommonProperties { private readonly XDR.Shape openXMLShape = new XDR.Shape(); private readonly Worksheet worksheet; @@ -28,7 +28,7 @@ public void RemoveShape() internal Shape MakeLine(ShapeLineModel lineModel) where LineColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { from = new AnchorPosition() { @@ -49,11 +49,12 @@ internal Shape MakeLine(ShapeLineModel(ShapeRectangleModel rectangleModel) + internal Shape MakeRectangle(ShapeRectangleModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() + where TextColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { from = new AnchorPosition() { @@ -74,11 +75,12 @@ internal Shape MakeRectangle(ShapeRectangleMod return this; } - internal Shape MakeArrow(ShapeArrowModel arrowModel) + internal Shape MakeArrow(ShapeArrowModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() + where TextColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { from = new AnchorPosition() { diff --git a/Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs b/Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs new file mode 100644 index 00000000..a87101f0 --- /dev/null +++ b/Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs @@ -0,0 +1,44 @@ +// Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. + +using A = DocumentFormat.OpenXml.Drawing; +using XDR = DocumentFormat.OpenXml.Drawing.Spreadsheet; +namespace OpenXMLOffice.Global_2007 +{ + /// + /// Common Properties organized in one place to get inherited by child classes + /// + public class SpreadSheetCommonProperties : CommonProperties + { + /// + /// + /// + protected XDR.Shape CreateShape(ShapeModel shapeModel) + where TextColorOption : class, IColorOptions, new() + { + XDR.Shape shape = new XDR.Shape() + { + NonVisualShapeProperties = new XDR.NonVisualShapeProperties( + new XDR.NonVisualDrawingProperties { Id = 2, Name = shapeModel.Name }, + new XDR.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true })), + ShapeProperties = new XDR.ShapeProperties( + new A.Transform2D( + new A.Offset + { + X = shapeModel.shapePropertiesModel.X, + Y = shapeModel.shapePropertiesModel.Y + }, + new A.Extents + { + Cx = shapeModel.shapePropertiesModel.Cx, + Cy = shapeModel.shapePropertiesModel.Cy + } + ), + new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle }), + TextBody = new XDR.TextBody(new A.BodyProperties(), + new A.ListStyle(), + CreateDrawingParagraph(shapeModel.drawingParagraph)) + }; + return shape; + } + } +} diff --git a/Spreadsheet/Components/2007/TextBox.cs b/Spreadsheet/Components/2007/TextBox.cs index 0572f33b..f35872cf 100644 --- a/Spreadsheet/Components/2007/TextBox.cs +++ b/Spreadsheet/Components/2007/TextBox.cs @@ -8,7 +8,7 @@ namespace OpenXMLOffice.Spreadsheet_2007 /// /// Represents Text box class to build on /// - public class TextBox : CommonProperties + public class TextBox : SpreadSheetCommonProperties { private readonly TextBoxSetting textBoxSetting; private readonly XDR.Shape openXMLShape; diff --git a/Spreadsheet/Models/2007/DrawingModel.cs b/Spreadsheet/Models/2007/DrawingModel.cs index 61fd9b6e..4a497609 100644 --- a/Spreadsheet/Models/2007/DrawingModel.cs +++ b/Spreadsheet/Models/2007/DrawingModel.cs @@ -72,7 +72,8 @@ public class DrawingGraphicFrame /// /// /// - public class TwoCellAnchorModel + public class TwoCellAnchorModel + where TextColorOption : class, IColorOptions, new() { /// /// @@ -97,7 +98,7 @@ public class TwoCellAnchorModel /// /// /// - public ShapeModel shapeModel; + public ShapeModel shapeModel; /// /// /// diff --git a/Spreadsheet/Parts/Drawing.cs b/Spreadsheet/Parts/Drawing.cs index e1ec5d34..bed1d8af 100644 --- a/Spreadsheet/Parts/Drawing.cs +++ b/Spreadsheet/Parts/Drawing.cs @@ -6,15 +6,13 @@ using A = DocumentFormat.OpenXml.Drawing; using X = DocumentFormat.OpenXml.Spreadsheet; using OpenXMLOffice.Global_2007; -using DocumentFormat.OpenXml; -using System; namespace OpenXMLOffice.Spreadsheet_2007 { /// /// /// - public class Drawing : CommonProperties + public class Drawing : SpreadSheetCommonProperties { /// /// @@ -43,7 +41,8 @@ protected XDR.WorksheetDrawing GetDrawing(Worksheet worksheet) /// /// /// - internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorModel) + internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorModel) + where TextColorOption : class, IColorOptions, new() { XDR.TwoCellAnchor twoCellAnchor = new XDR.TwoCellAnchor(new XDR.ClientData()) { @@ -87,16 +86,11 @@ internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorM } if (twoCellAnchorModel.shapeModel != null) { - twoCellAnchor.AddChild(CreateModel(twoCellAnchorModel.shapeModel)); + twoCellAnchor.AddChild(CreateShape(twoCellAnchorModel.shapeModel)); } return twoCellAnchor; } - private XDR.Shape CreateModel(ShapeModel shapeModel) - { - return new XDR.Shape(); - } - private static XDR.GraphicFrame CreateGraphicFrame(DrawingGraphicFrame drawingGraphicFrame) { return new XDR.GraphicFrame() diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index 3474c720..37d2126b 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -55,22 +55,24 @@ public Shape AddShape(ShapeLineModel /// Insert Shape into slide /// - public Shape AddShape(ShapeRectangleModel rectangleModel) + public Shape AddShape(ShapeRectangleModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() + where TextColorOption : class, IColorOptions, new() { Shape shape = new Shape(this); - return shape.MakeRectangle(rectangleModel); + return shape.MakeRectangle(rectangleModel); } /// /// Insert Shape into slide /// - public Shape AddShape(ShapeArrowModel arrowModel) + public Shape AddShape(ShapeArrowModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() + where TextColorOption : class, IColorOptions, new() { Shape shape = new Shape(this); - return shape.MakeArrow(arrowModel); + return shape.MakeArrow(arrowModel); } /// /// Sets the properties for a column based on a starting cell ID in a worksheet. From ceca7570d7a4fdb756ccbcf1b68b6d79df26dc1b Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Sat, 15 Jun 2024 17:15:33 +0000 Subject: [PATCH 07/25] Shape Extension Update --- Global/Components/2007/CommonProperties.cs | 2 +- Global/Components/Charts/2007/ChartBase.cs | 14 +- Global/Components/Charts/2007/LineChart.cs | 4 +- Global/Components/Charts/2007/ScatterChart.cs | 2 +- Global/Models/2007/CommonPropertiesModel.cs | 6 +- Global/Models/2007/ShapeModel.cs | 35 +++- .../2007/PresentationCommonProperties.cs | 14 +- Presentation/Components/2007/Table.cs | 14 +- Presentation/Components/2007/TextBox.cs | 2 +- Presentation/Parts/CommonSlideData.cs | 182 ++++++++---------- Spreadsheet/Components/2007/Chart.cs | 2 +- Spreadsheet/Components/2007/Picture.cs | 2 +- Spreadsheet/Components/2007/Shape.cs | 6 +- .../2007/SpreadSheetCommonProperties.cs | 14 +- Spreadsheet/Models/2007/DrawingModel.cs | 7 +- Spreadsheet/Parts/Drawing.cs | 2 +- 16 files changed, 155 insertions(+), 153 deletions(-) diff --git a/Global/Components/2007/CommonProperties.cs b/Global/Components/2007/CommonProperties.cs index 31084e0f..3869c4ca 100644 --- a/Global/Components/2007/CommonProperties.cs +++ b/Global/Components/2007/CommonProperties.cs @@ -436,7 +436,7 @@ protected static OpenXmlElement CreateColorComponent(ColorOptionMod /// protected C.ShapeProperties CreateChartShapeProperties() { - return CreateChartShapeProperties(new ShapePropertiesModel()); + return CreateChartShapeProperties(new ShapePropertiesModel()); } /// /// Create Shape Properties diff --git a/Global/Components/Charts/2007/ChartBase.cs b/Global/Components/Charts/2007/ChartBase.cs index e8aa4819..960e8a7e 100644 --- a/Global/Components/Charts/2007/ChartBase.cs +++ b/Global/Components/Charts/2007/ChartBase.cs @@ -82,7 +82,7 @@ internal C.TrendlineLabel CreateTrendLineLabel() { NumberingFormat = new C.NumberingFormat() { FormatCode = "General", SourceLinked = false }, }; - trendlineLabel.Append(CreateChartShapeProperties(new ShapePropertiesModel())); + trendlineLabel.Append(CreateChartShapeProperties(new ShapePropertiesModel())); trendlineLabel.Append(CreateChartTextProperties(new ChartTextPropertiesModel() { drawingBodyProperties = new DrawingBodyPropertiesModel() @@ -569,7 +569,7 @@ private C.BackWall CreateBackWall() return new C.BackWall() { Thickness = new C.Thickness() { Val = 0 }, - ShapeProperties = CreateChartShapeProperties(new ShapePropertiesModel() + ShapeProperties = CreateChartShapeProperties(new ShapePropertiesModel() { shapeProperty3D = new ShapeProperty3D() }), @@ -580,7 +580,7 @@ private C.SideWall CreateSideWall() return new C.SideWall() { Thickness = new C.Thickness() { Val = 0 }, - ShapeProperties = CreateChartShapeProperties(new ShapePropertiesModel() + ShapeProperties = CreateChartShapeProperties(new ShapePropertiesModel() { shapeProperty3D = new ShapeProperty3D() }), @@ -591,7 +591,7 @@ private C.Floor CreateFloor() return new C.Floor() { Thickness = new C.Thickness() { Val = 0 }, - ShapeProperties = CreateChartShapeProperties(new ShapePropertiesModel() + ShapeProperties = CreateChartShapeProperties(new ShapePropertiesModel() { shapeProperty3D = new ShapeProperty3D() }), @@ -729,7 +729,7 @@ protected static A.Field CreateField(string type, string text) } private C.MajorGridlines CreateMajorGridLine() { - return new C.MajorGridlines(CreateChartShapeProperties(new ShapePropertiesModel() + return new C.MajorGridlines(CreateChartShapeProperties(new ShapePropertiesModel() { lineColor = new OutlineModel() { @@ -754,7 +754,7 @@ private C.MajorGridlines CreateMajorGridLine() } private C.MinorGridlines CreateMinorGridLine() { - return new C.MinorGridlines(CreateChartShapeProperties(new ShapePropertiesModel() + return new C.MinorGridlines(CreateChartShapeProperties(new ShapePropertiesModel() { lineColor = new OutlineModel() { @@ -853,7 +853,7 @@ internal C.Trendline CreateTrendLine(TrendLineModel trendLineModel) { TrendlineName = new C.TrendlineName(trendLineModel.trendLineName) }; - trendLine.Append(CreateChartShapeProperties(new ShapePropertiesModel() + trendLine.Append(CreateChartShapeProperties(new ShapePropertiesModel() { lineColor = new OutlineModel() { diff --git a/Global/Components/Charts/2007/LineChart.cs b/Global/Components/Charts/2007/LineChart.cs index 3100df2e..1170e1f2 100644 --- a/Global/Components/Charts/2007/LineChart.cs +++ b/Global/Components/Charts/2007/LineChart.cs @@ -154,7 +154,7 @@ private C.LineChartSeries CreateLineChartSeries(int seriesIndex, ChartDataGroupi outlineModel.lineColor.colorOption.transparency = (int)lineChartLineFormat.transparency; } } - ShapePropertiesModel shapePropertiesModel = new ShapePropertiesModel() + ShapePropertiesModel shapePropertiesModel = new ShapePropertiesModel() { lineColor = outlineModel, }; @@ -204,7 +204,7 @@ private C.LineChartSeries CreateLineChartSeries(int seriesIndex, ChartDataGroupi } else { - MarkerModel marketModel = new MarkerModel() + MarkerModel marketModel = new MarkerModel() { markerShapeType = MarkerShapeTypes.NONE, }; diff --git a/Global/Components/Charts/2007/ScatterChart.cs b/Global/Components/Charts/2007/ScatterChart.cs index 325de7d3..e41786fd 100644 --- a/Global/Components/Charts/2007/ScatterChart.cs +++ b/Global/Components/Charts/2007/ScatterChart.cs @@ -224,7 +224,7 @@ private C.ScatterChartSeries CreateScatterChartSeries(int seriesIndex, ChartData } else { - MarkerModel markerModel = new MarkerModel(); + MarkerModel markerModel = new MarkerModel(); if (scatterChartSetting.scatterChartType != ScatterChartTypes.BUBBLE && scatterChartSetting.scatterChartType != ScatterChartTypes.BUBBLE_3D) { series.Append(CreateMarker(markerModel)); diff --git a/Global/Models/2007/CommonPropertiesModel.cs b/Global/Models/2007/CommonPropertiesModel.cs index 7498f3c1..1852101f 100644 --- a/Global/Models/2007/CommonPropertiesModel.cs +++ b/Global/Models/2007/CommonPropertiesModel.cs @@ -503,11 +503,11 @@ public class EffectListModel /// public interface IColorOptions { } /// - /// + /// This will update NoFill Color as result /// - public class NoOptions : IColorOptions { } + public class NoFillOptions : IColorOptions { } /// - /// + /// Solid Fill options /// public class SolidOptions : IColorOptions { diff --git a/Global/Models/2007/ShapeModel.cs b/Global/Models/2007/ShapeModel.cs index 5ece8467..e0121890 100644 --- a/Global/Models/2007/ShapeModel.cs +++ b/Global/Models/2007/ShapeModel.cs @@ -112,7 +112,15 @@ public enum ShapeArrowTypes /// /// /// - public class ShapeLineModel + public interface IShapeTypeDetailsModel { } + /// + /// + /// + public class NoShape : IShapeTypeDetailsModel { } + /// + /// + /// + public class ShapeLineModel : IShapeTypeDetailsModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() { @@ -132,7 +140,7 @@ public class ShapeLineModel /// /// /// - public class ShapeRectangleModel + public class ShapeRectangleModel : IShapeTypeDetailsModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() @@ -161,7 +169,7 @@ public class ShapeRectangleModel /// /// - public class ShapeArrowModel + public class ShapeArrowModel : IShapeTypeDetailsModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() @@ -195,30 +203,39 @@ public class ShapePropertiesModel /// /// /// - public int X = 1562100; + public double x = 1562100L; /// /// /// - public int Y = 1524000; + public double y = 1524000L; /// /// /// - public int Cx = 4743450; + public double cx = 4743450L; /// /// /// - public int Cy = 1419225; + public double cy = 1419225L; } /// /// /// - public class ShapeModel + public class ShapeModel where TextColorOption : class, IColorOptions, new() + where ShapeTypeOptions : class, IShapeTypeDetailsModel, new() { /// /// /// - public string Name = ""; + public uint id = 1; + /// + /// + /// + public string name = ""; + /// + /// + /// + public ShapeTypeOptions shapeTypeOptions = new ShapeTypeOptions(); /// /// /// diff --git a/Presentation/Components/2007/PresentationCommonProperties.cs b/Presentation/Components/2007/PresentationCommonProperties.cs index ffd07453..a0c60fb5 100644 --- a/Presentation/Components/2007/PresentationCommonProperties.cs +++ b/Presentation/Components/2007/PresentationCommonProperties.cs @@ -1,5 +1,6 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. +using DocumentFormat.OpenXml; using A = DocumentFormat.OpenXml.Drawing; using P = DocumentFormat.OpenXml.Presentation; namespace OpenXMLOffice.Global_2007 @@ -12,26 +13,27 @@ public class PresentationCommonProperties : CommonProperties /// /// /// - protected P.Shape CreateShape(ShapeModel shapeModel) + protected P.Shape CreateShape(ShapeModel shapeModel) where TextColorOption : class, IColorOptions, new() + where ShapeTypeOptions : class, IShapeTypeDetailsModel, new() { P.Shape shape = new P.Shape() { NonVisualShapeProperties = new P.NonVisualShapeProperties( - new P.NonVisualDrawingProperties { Id = 2, Name = shapeModel.Name }, + new P.NonVisualDrawingProperties { Id = 2, Name = shapeModel.name }, new P.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), new P.ApplicationNonVisualDrawingProperties(new P.PlaceholderShape { Type = P.PlaceholderValues.Title })), ShapeProperties = new P.ShapeProperties( new A.Transform2D( new A.Offset { - X = shapeModel.shapePropertiesModel.X, - Y = shapeModel.shapePropertiesModel.Y + X = (Int64Value)shapeModel.shapePropertiesModel.x, + Y = (Int64Value)shapeModel.shapePropertiesModel.y }, new A.Extents { - Cx = shapeModel.shapePropertiesModel.Cx, - Cy = shapeModel.shapePropertiesModel.Cy + Cx = (Int64Value)shapeModel.shapePropertiesModel.cx, + Cy = (Int64Value)shapeModel.shapePropertiesModel.cy } ), new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle }), diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index 387b1c75..fcabfc02 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -383,7 +383,7 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, } else { - tableCellProperties.Append(new A.LeftBorderLineProperties(CreateColorComponent())); + tableCellProperties.Append(new A.LeftBorderLineProperties(CreateColorComponent())); } if (cell.borderSettings.rightBorder.showBorder) { @@ -404,7 +404,7 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, } else { - tableCellProperties.Append(new A.RightBorderLineProperties(CreateColorComponent())); + tableCellProperties.Append(new A.RightBorderLineProperties(CreateColorComponent())); } if (cell.borderSettings.topBorder.showBorder) { @@ -425,7 +425,7 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, } else { - tableCellProperties.Append(new A.TopBorderLineProperties(CreateColorComponent())); + tableCellProperties.Append(new A.TopBorderLineProperties(CreateColorComponent())); } if (cell.borderSettings.bottomBorder.showBorder) { @@ -446,7 +446,7 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, } else { - tableCellProperties.Append(new A.BottomBorderLineProperties(CreateColorComponent())); + tableCellProperties.Append(new A.BottomBorderLineProperties(CreateColorComponent())); } if (cell.borderSettings.topLeftToBottomRightBorder.showBorder) { @@ -467,7 +467,7 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, } else { - tableCellProperties.Append(new A.TopLeftToBottomRightBorderLineProperties(CreateColorComponent())); + tableCellProperties.Append(new A.TopLeftToBottomRightBorderLineProperties(CreateColorComponent())); } if (cell.borderSettings.bottomLeftToTopRightBorder.showBorder) { @@ -488,7 +488,7 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, } else { - tableCellProperties.Append(new A.BottomLeftToTopRightBorderLineProperties(CreateColorComponent())); + tableCellProperties.Append(new A.BottomLeftToTopRightBorderLineProperties(CreateColorComponent())); } if (cell.cellBackground != null || row.rowBackground != null) { @@ -502,7 +502,7 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, } else { - tableCellProperties.Append(CreateColorComponent()); + tableCellProperties.Append(CreateColorComponent()); } tableCellXml.Append(tableCellProperties); return tableCellXml; diff --git a/Presentation/Components/2007/TextBox.cs b/Presentation/Components/2007/TextBox.cs index 337dde98..a8cbce81 100644 --- a/Presentation/Components/2007/TextBox.cs +++ b/Presentation/Components/2007/TextBox.cs @@ -99,7 +99,7 @@ private P.Shape CreateTextBox() } else { - ShapeProperties.Append(CreateColorComponent(new ColorOptionModel())); + ShapeProperties.Append(CreateColorComponent(new ColorOptionModel())); } List> drawingRunModels = new List>(); foreach (TextBlock textBlock in textBoxSetting.textBlocks) diff --git a/Presentation/Parts/CommonSlideData.cs b/Presentation/Parts/CommonSlideData.cs index 3acefb04..348844d2 100644 --- a/Presentation/Parts/CommonSlideData.cs +++ b/Presentation/Parts/CommonSlideData.cs @@ -1,5 +1,6 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. +using System.Collections.Generic; using OpenXMLOffice.Global_2007; using A = DocumentFormat.OpenXml.Drawing; using P = DocumentFormat.OpenXml.Presentation; @@ -78,113 +79,92 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com switch (commonSlideDataType) { case PresentationConstants.CommonSlideDataType.SLIDE_MASTER: - var unused5 = openXMLCommonSlideData.AppendChild(background); - var unused4 = openXMLCommonSlideData.AppendChild(shapeTree); + openXMLCommonSlideData.AppendChild(background); + openXMLCommonSlideData.AppendChild(shapeTree); break; case PresentationConstants.CommonSlideDataType.SLIDE_LAYOUT: - var unused3 = shapeTree.AppendChild(CreateShape1()); - var unused2 = shapeTree.AppendChild(CreateShape2()); - var unused1 = openXMLCommonSlideData.AppendChild(shapeTree); + shapeTree.AppendChild(CreateShape(new ShapeModel>() + { + id = (uint)shapeTree.ChildElements.Count + 1, + name = "Title 1", + shapeTypeOptions = new ShapeRectangleModel() + { + rectangleType = ShapeRectangleTypes.RECTANGLE, + lineColorOption = new SolidOptions() + { + hexColor = "FFFFFF", + } + }, + shapePropertiesModel = new ShapePropertiesModel() + { + x = 838200L, + y = 365125L, + cx = 10515600L, + cy = 1325563L + }, + drawingParagraph = new DrawingParagraphModel() + { + drawingRuns = new List>() + { + new DrawingRunModel(){ + text = "Click to edit Master title style", + drawingRunProperties = new DrawingRunPropertiesModel() + } + }.ToArray() + } + })); + shapeTree.AppendChild(CreateShape(new ShapeModel>() + { + id = (uint)shapeTree.ChildElements.Count + 1, + name = "Text Placeholder 1", + shapeTypeOptions = new ShapeRectangleModel() + { + rectangleType = ShapeRectangleTypes.RECTANGLE, + lineColorOption = new SolidOptions() + { + hexColor = "FFFFFF", + } + }, + shapePropertiesModel = new ShapePropertiesModel() + { + x = 838200L, + y = 1825625L, + cx = 10515600L, + cy = 4351338L + }, + drawingParagraph = new DrawingParagraphModel() + { + drawingRuns = new List>() + { + new DrawingRunModel(){ + text = "Click to edit Master title style", + drawingRunProperties = new DrawingRunPropertiesModel() + }, + new DrawingRunModel(){ + text = "Second Level", + drawingRunProperties = new DrawingRunPropertiesModel() + }, + new DrawingRunModel(){ + text = "Third Level", + drawingRunProperties = new DrawingRunPropertiesModel() + }, + new DrawingRunModel(){ + text = "Fourth Level", + drawingRunProperties = new DrawingRunPropertiesModel() + }, + new DrawingRunModel(){ + text = "Fifth Level", + drawingRunProperties = new DrawingRunPropertiesModel() + } + }.ToArray() + } + })); + openXMLCommonSlideData.AppendChild(shapeTree); break; default: // slide - var unused = openXMLCommonSlideData.AppendChild(shapeTree); + openXMLCommonSlideData.AppendChild(shapeTree); break; } } - private static P.Shape CreateShape1() - { - P.Shape shape = new P.Shape(); - P.NonVisualShapeProperties nonVisualShapeProperties = new P.NonVisualShapeProperties( - new P.NonVisualDrawingProperties { Id = 2, Name = "Title 1" }, - new P.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), - new P.ApplicationNonVisualDrawingProperties(new P.PlaceholderShape { Type = P.PlaceholderValues.Title }) - ); - P.ShapeProperties shapeProperties = new P.ShapeProperties( - new A.Transform2D( - new A.Offset { X = 838200L, Y = 365125L }, - new A.Extents { Cx = 10515600L, Cy = 1325563L } - ), - new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle } - ); - P.TextBody textBody = new P.TextBody( - new A.BodyProperties(), - new A.ListStyle(), - new A.Paragraph( - new A.Run( - new A.RunProperties { Language = "en-IN" }, - new A.Text { Text = "Click to edit Master title style" } - ), - new A.EndParagraphRunProperties { Language = "en-IN" } - ) - ); - shape.Append(nonVisualShapeProperties); - shape.Append(shapeProperties); - shape.Append(textBody); - return shape; - } - private static P.Shape CreateShape2() - { - P.Shape shape = new P.Shape(); - P.NonVisualShapeProperties nonVisualShapeProperties = new P.NonVisualShapeProperties( - new P.NonVisualDrawingProperties { Id = 3U, Name = "Text Placeholder 2" }, - new P.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true }), - new P.ApplicationNonVisualDrawingProperties( - new P.PlaceholderShape { Index = 1U, Type = P.PlaceholderValues.Body }) - ); - P.ShapeProperties shapeProperties = new P.ShapeProperties( - new A.Transform2D( - new A.Offset { X = 838200L, Y = 1825625L }, - new A.Extents { Cx = 10515600L, Cy = 4351338L } - ), - new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle } - ); - P.TextBody textBody = new P.TextBody( - new A.BodyProperties(), - new A.ListStyle(), - new A.Paragraph( - new A.ParagraphProperties { Level = 0 }, - new A.Run( - new A.RunProperties { Language = "en-IN" }, - new A.Text("Click to edit Master text styles") - ) - ), - new A.Paragraph( - new A.ParagraphProperties { Level = 1 }, - new A.Run( - new A.RunProperties { Language = "en-IN" }, - new A.Text("Second Level") - ) - ), - new A.Paragraph( - new A.ParagraphProperties { Level = 2 }, - new A.Run( - new A.RunProperties { Language = "en-IN" }, - new A.Text("Third Level") - ) - ), - new A.Paragraph( - new A.ParagraphProperties { Level = 3 }, - new A.Run( - new A.RunProperties { Language = "en-IN" }, - new A.Text("Fourth Level") - ) - ), - new A.Paragraph( - new A.ParagraphProperties { Level = 4 }, - new A.Run( - new A.RunProperties { Language = "en-IN" }, - new A.Text("Fifth Level") - ), - new A.EndParagraphRunProperties() - { - Language = "en-IN" - } - ) - ); - shape.Append(nonVisualShapeProperties); - shape.Append(shapeProperties); - shape.Append(textBody); - return shape; - } } } diff --git a/Spreadsheet/Components/2007/Chart.cs b/Spreadsheet/Components/2007/Chart.cs index 98cf90e6..a809b537 100644 --- a/Spreadsheet/Components/2007/Chart.cs +++ b/Spreadsheet/Components/2007/Chart.cs @@ -108,7 +108,7 @@ internal string GetNextChartRelationId() private void ConnectDrawingToChart(Worksheet worksheet, string chartId) { // Add anchor to drawing for chart graphics - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { anchorEditType = AnchorEditType.NONE, from = new AnchorPosition() diff --git a/Spreadsheet/Components/2007/Picture.cs b/Spreadsheet/Components/2007/Picture.cs index 4e2969ad..a2083efd 100644 --- a/Spreadsheet/Components/2007/Picture.cs +++ b/Spreadsheet/Components/2007/Picture.cs @@ -71,7 +71,7 @@ private void AddImageToDrawing(Stream stream) break; } } - XDR.TwoCellAnchor twoCellAnchor = currentWorksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = currentWorksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { anchorEditType = AnchorEditType.ONE_CELL, from = excelPictureSetting.from, diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index 94e7002c..13b3b973 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -28,7 +28,7 @@ public void RemoveShape() internal Shape MakeLine(ShapeLineModel lineModel) where LineColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { from = new AnchorPosition() { @@ -54,7 +54,7 @@ internal Shape MakeRectangle( where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { from = new AnchorPosition() { @@ -80,7 +80,7 @@ internal Shape MakeArrow(Shap where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() { from = new AnchorPosition() { diff --git a/Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs b/Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs index a87101f0..2de9f68b 100644 --- a/Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs +++ b/Spreadsheet/Components/2007/SpreadSheetCommonProperties.cs @@ -1,5 +1,6 @@ // Copyright (c) DraviaVemal. Licensed under the MIT License. See License in the project root. +using DocumentFormat.OpenXml; using A = DocumentFormat.OpenXml.Drawing; using XDR = DocumentFormat.OpenXml.Drawing.Spreadsheet; namespace OpenXMLOffice.Global_2007 @@ -12,25 +13,26 @@ public class SpreadSheetCommonProperties : CommonProperties /// /// /// - protected XDR.Shape CreateShape(ShapeModel shapeModel) + protected XDR.Shape CreateShape(ShapeModel shapeModel) where TextColorOption : class, IColorOptions, new() + where ShapeTypeOptions : class, IShapeTypeDetailsModel, new() { XDR.Shape shape = new XDR.Shape() { NonVisualShapeProperties = new XDR.NonVisualShapeProperties( - new XDR.NonVisualDrawingProperties { Id = 2, Name = shapeModel.Name }, + new XDR.NonVisualDrawingProperties { Id = 2, Name = shapeModel.name }, new XDR.NonVisualShapeDrawingProperties(new A.ShapeLocks { NoGrouping = true })), ShapeProperties = new XDR.ShapeProperties( new A.Transform2D( new A.Offset { - X = shapeModel.shapePropertiesModel.X, - Y = shapeModel.shapePropertiesModel.Y + X = (Int64Value)shapeModel.shapePropertiesModel.x, + Y = (Int64Value)shapeModel.shapePropertiesModel.y }, new A.Extents { - Cx = shapeModel.shapePropertiesModel.Cx, - Cy = shapeModel.shapePropertiesModel.Cy + Cx = (Int64Value)shapeModel.shapePropertiesModel.cx, + Cy = (Int64Value)shapeModel.shapePropertiesModel.cy } ), new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle }), diff --git a/Spreadsheet/Models/2007/DrawingModel.cs b/Spreadsheet/Models/2007/DrawingModel.cs index 4a497609..a5530a1a 100644 --- a/Spreadsheet/Models/2007/DrawingModel.cs +++ b/Spreadsheet/Models/2007/DrawingModel.cs @@ -72,8 +72,9 @@ public class DrawingGraphicFrame /// /// /// - public class TwoCellAnchorModel - where TextColorOption : class, IColorOptions, new() + public class TwoCellAnchorModel + where TextColorOption : class, IColorOptions, new() + where ShapeTypeOptions : class, IShapeTypeDetailsModel, new() { /// /// @@ -98,7 +99,7 @@ public class TwoCellAnchorModel /// /// /// - public ShapeModel shapeModel; + public ShapeModel shapeModel; /// /// /// diff --git a/Spreadsheet/Parts/Drawing.cs b/Spreadsheet/Parts/Drawing.cs index bed1d8af..61ee2bae 100644 --- a/Spreadsheet/Parts/Drawing.cs +++ b/Spreadsheet/Parts/Drawing.cs @@ -41,7 +41,7 @@ protected XDR.WorksheetDrawing GetDrawing(Worksheet worksheet) /// /// /// - internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorModel) + internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorModel) where TextColorOption : class, IColorOptions, new() { XDR.TwoCellAnchor twoCellAnchor = new XDR.TwoCellAnchor(new XDR.ClientData()) From 6a394d91600ac8cbd0d349da25d923c6e58dff71 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Sat, 15 Jun 2024 19:12:17 +0000 Subject: [PATCH 08/25] renaming --- Global/Models/2007/ShapeModel.cs | 6 ++-- Presentation/Components/2007/Shape.cs | 6 ++-- Presentation/Parts/CommonSlideData.cs | 8 ++--- Presentation/Parts/Slide.cs | 6 ++-- Spreadsheet/Components/2007/Shape.cs | 49 ++++++++++++++++++++------- Spreadsheet/Parts/Drawing.cs | 3 +- Spreadsheet/Parts/Worksheet.cs | 6 ++-- 7 files changed, 55 insertions(+), 29 deletions(-) diff --git a/Global/Models/2007/ShapeModel.cs b/Global/Models/2007/ShapeModel.cs index e0121890..61225215 100644 --- a/Global/Models/2007/ShapeModel.cs +++ b/Global/Models/2007/ShapeModel.cs @@ -120,7 +120,7 @@ public class NoShape : IShapeTypeDetailsModel { } /// /// /// - public class ShapeLineModel : IShapeTypeDetailsModel + public class LineShapeModel : IShapeTypeDetailsModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() { @@ -140,7 +140,7 @@ public class ShapeLineModel : IShap /// /// /// - public class ShapeRectangleModel : IShapeTypeDetailsModel + public class RectangleShapeModel : IShapeTypeDetailsModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() @@ -169,7 +169,7 @@ public class ShapeRectangleModel /// /// - public class ShapeArrowModel : IShapeTypeDetailsModel + public class ArrowShapeModel : IShapeTypeDetailsModel where ApplicationSpecificSetting : class, ISizeAndPosition, new() where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() diff --git a/Presentation/Components/2007/Shape.cs b/Presentation/Components/2007/Shape.cs index ac3f1cd1..2137f43c 100644 --- a/Presentation/Components/2007/Shape.cs +++ b/Presentation/Components/2007/Shape.cs @@ -30,20 +30,20 @@ public void RemoveShape() openXMLShape.Remove(); } - internal Shape AddLine(ShapeLineModel lineModel) + internal Shape AddLine(LineShapeModel lineModel) where LineColorOption : class, IColorOptions, new() { return this; } - internal Shape AddRectangle(ShapeRectangleModel rectangleModel) + internal Shape AddRectangle(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { return this; } - internal Shape AddArrow(ShapeArrowModel arrowModel) + internal Shape AddArrow(ArrowShapeModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { diff --git a/Presentation/Parts/CommonSlideData.cs b/Presentation/Parts/CommonSlideData.cs index 348844d2..124753d8 100644 --- a/Presentation/Parts/CommonSlideData.cs +++ b/Presentation/Parts/CommonSlideData.cs @@ -83,11 +83,11 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com openXMLCommonSlideData.AppendChild(shapeTree); break; case PresentationConstants.CommonSlideDataType.SLIDE_LAYOUT: - shapeTree.AppendChild(CreateShape(new ShapeModel>() + shapeTree.AppendChild(CreateShape(new ShapeModel>() { id = (uint)shapeTree.ChildElements.Count + 1, name = "Title 1", - shapeTypeOptions = new ShapeRectangleModel() + shapeTypeOptions = new RectangleShapeModel() { rectangleType = ShapeRectangleTypes.RECTANGLE, lineColorOption = new SolidOptions() @@ -113,11 +113,11 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com }.ToArray() } })); - shapeTree.AppendChild(CreateShape(new ShapeModel>() + shapeTree.AppendChild(CreateShape(new ShapeModel>() { id = (uint)shapeTree.ChildElements.Count + 1, name = "Text Placeholder 1", - shapeTypeOptions = new ShapeRectangleModel() + shapeTypeOptions = new RectangleShapeModel() { rectangleType = ShapeRectangleTypes.RECTANGLE, lineColorOption = new SolidOptions() diff --git a/Presentation/Parts/Slide.cs b/Presentation/Parts/Slide.cs index 98f25aee..37306751 100644 --- a/Presentation/Parts/Slide.cs +++ b/Presentation/Parts/Slide.cs @@ -182,7 +182,7 @@ public IEnumerable FindShapeByText(string searchText) /// /// Insert Shape into slide /// - public Shape AddShape(ShapeLineModel lineModel) + public Shape AddShape(LineShapeModel lineModel) where LineColorOption : class, IColorOptions, new() { P.Shape openXmlShape = new P.Shape(); @@ -193,7 +193,7 @@ public Shape AddShape(ShapeLineModel /// Insert Shape into slide /// - public Shape AddShape(ShapeRectangleModel rectangleModel) + public Shape AddShape(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { @@ -205,7 +205,7 @@ public Shape AddShape(ShapeRectangleModel /// Insert Shape into slide /// - public Shape AddShape(ShapeArrowModel arrowModel) + public Shape AddShape(ArrowShapeModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index 13b3b973..cbd5853d 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -10,11 +10,15 @@ namespace OpenXMLOffice.Spreadsheet_2007 /// public class Shape : SpreadSheetCommonProperties { - private readonly XDR.Shape openXMLShape = new XDR.Shape(); + private XDR.TwoCellAnchor twoCellAnchor = new XDR.TwoCellAnchor(); private readonly Worksheet worksheet; - internal Shape(Worksheet _worksheet) + internal Shape(Worksheet _worksheet, XDR.TwoCellAnchor _twoCellAnchor = null) { worksheet = _worksheet; + if (twoCellAnchor != null) + { + twoCellAnchor = _twoCellAnchor; + } } /// @@ -22,13 +26,13 @@ internal Shape(Worksheet _worksheet) /// public void RemoveShape() { - openXMLShape.Remove(); + twoCellAnchor.Remove(); } - internal Shape MakeLine(ShapeLineModel lineModel) + internal Shape MakeLine(LineShapeModel lineModel) where LineColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel>() { from = new AnchorPosition() { @@ -44,17 +48,24 @@ internal Shape MakeLine(ShapeLineModel>() + { + + } }); - worksheet.GetDrawing().AppendChild(twoCellAnchor); + if (twoCellAnchor.Parent == null) + { + worksheet.GetDrawing().AppendChild(twoCellAnchor); + } return this; } - internal Shape MakeRectangle(ShapeRectangleModel rectangleModel) + internal Shape MakeRectangle(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel>() { from = new AnchorPosition() { @@ -70,17 +81,24 @@ internal Shape MakeRectangle( column = rectangleModel.applicationSpecificSetting.to.column, columnOffset = rectangleModel.applicationSpecificSetting.to.columnOffset, }, + shapeModel = new ShapeModel>() + { + + } }); - worksheet.GetDrawing().AppendChild(twoCellAnchor); + if (twoCellAnchor.Parent == null) + { + worksheet.GetDrawing().AppendChild(twoCellAnchor); + } return this; } - internal Shape MakeArrow(ShapeArrowModel arrowModel) + internal Shape MakeArrow(ArrowShapeModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() { - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel>() { from = new AnchorPosition() { @@ -96,8 +114,15 @@ internal Shape MakeArrow(Shap column = arrowModel.applicationSpecificSetting.to.column, columnOffset = arrowModel.applicationSpecificSetting.to.columnOffset, }, + shapeModel = new ShapeModel>() + { + + } }); - worksheet.GetDrawing().AppendChild(twoCellAnchor); + if (twoCellAnchor.Parent == null) + { + worksheet.GetDrawing().AppendChild(twoCellAnchor); + } return this; } } diff --git a/Spreadsheet/Parts/Drawing.cs b/Spreadsheet/Parts/Drawing.cs index 61ee2bae..6d7ba1ee 100644 --- a/Spreadsheet/Parts/Drawing.cs +++ b/Spreadsheet/Parts/Drawing.cs @@ -41,8 +41,9 @@ protected XDR.WorksheetDrawing GetDrawing(Worksheet worksheet) /// /// /// - internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorModel) + internal XDR.TwoCellAnchor CreateTwoCellAnchor(TwoCellAnchorModel twoCellAnchorModel) where TextColorOption : class, IColorOptions, new() + where ShapeTypeOptions : class, IShapeTypeDetailsModel, new() { XDR.TwoCellAnchor twoCellAnchor = new XDR.TwoCellAnchor(new XDR.ClientData()) { diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index 37d2126b..3c01db7b 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -46,7 +46,7 @@ public string GetSheetName() /// /// Insert Shape into slide /// - public Shape AddShape(ShapeLineModel lineModel) + public Shape AddShape(LineShapeModel lineModel) where LineColorOption : class, IColorOptions, new() { Shape shape = new Shape(this); @@ -55,7 +55,7 @@ public Shape AddShape(ShapeLineModel /// Insert Shape into slide /// - public Shape AddShape(ShapeRectangleModel rectangleModel) + public Shape AddShape(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() @@ -66,7 +66,7 @@ public Shape AddShape(ShapeRe /// /// Insert Shape into slide /// - public Shape AddShape(ShapeArrowModel arrowModel) + public Shape AddShape(ArrowShapeModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() From 14305ff66bf589316e39b2a4fa85ee03f8a2de43 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Sun, 16 Jun 2024 14:44:44 +0000 Subject: [PATCH 09/25] Auto Fix Mistake undo --- Global/Components/Charts/2007/ChartBase.cs | 6 +- Global/Models/2007/ChartBaseModel.cs | 73 +++++++++++++++++-- Global/Models/2007/TextBoxModel.cs | 8 +- Global/Parts/Theme.cs | 10 +-- Presentation/Components/2007/Chart.cs | 28 +++---- Presentation/Components/2007/Picture.cs | 24 +++--- Presentation/Components/2007/Shape.cs | 69 ++++++++++-------- Presentation/Components/2007/TextBox.cs | 34 ++++----- .../2016/AdvancedChartProperties.cs | 18 ++--- Presentation/Components/2016/Chart.cs | 6 +- .../Components/Common/ChartProperties.cs | 34 ++++----- Presentation/Internal/Presentation.cs | 10 +-- Presentation/Internal/PresentationCore.cs | 18 ++--- Presentation/Parts/CommonSlideData.cs | 16 ++-- Presentation/Parts/Slide.cs | 32 ++++---- Presentation/Parts/SlideLayout.cs | 16 ++-- Presentation/Parts/SlideMaster.cs | 24 +++--- Presentation/Parts/ViewProperties.cs | 18 ++--- Spreadsheet/Components/2007/Chart.cs | 22 +++--- Spreadsheet/Components/2007/TextBox.cs | 4 +- Spreadsheet/Parts/Worksheet.cs | 26 +++---- Tests/Presentation.cs | 23 +++++- 22 files changed, 301 insertions(+), 218 deletions(-) diff --git a/Global/Components/Charts/2007/ChartBase.cs b/Global/Components/Charts/2007/ChartBase.cs index 960e8a7e..940414e7 100644 --- a/Global/Components/Charts/2007/ChartBase.cs +++ b/Global/Components/Charts/2007/ChartBase.cs @@ -27,7 +27,7 @@ namespace OpenXMLOffice.Global_2007 /// internal ChartSetting chartSetting; private readonly C.Chart chart; - private readonly C.ChartSpace openXMLChartSpace; + private readonly C.ChartSpace documentChartSpace; /// /// Chart base class constructor restricted only for inheritance use /// @@ -38,7 +38,7 @@ internal ChartBase(ChartSetting chartSetting) CategoryAxisId = chartSetting.categoryAxisId ?? CategoryAxisId; ValueAxisId = chartSetting.valueAxisId ?? ValueAxisId; this.chartSetting = chartSetting; - openXMLChartSpace = CreateChartSpace(); + documentChartSpace = CreateChartSpace(); chart = CreateChart(); GetChartSpace().Append(chart); } @@ -47,7 +47,7 @@ internal ChartBase(ChartSetting chartSetting) /// public virtual C.ChartSpace GetChartSpace() { - return openXMLChartSpace; + return documentChartSpace; } /// /// Create Bubble Size Axis for the chart diff --git a/Global/Models/2007/ChartBaseModel.cs b/Global/Models/2007/ChartBaseModel.cs index 75e2eca0..24929f59 100644 --- a/Global/Models/2007/ChartBaseModel.cs +++ b/Global/Models/2007/ChartBaseModel.cs @@ -655,21 +655,78 @@ public interface ISizeAndPosition { } public class PresentationSetting : ISizeAndPosition { /// - /// Chart Height in EMU + /// Value in EMU /// - public uint height = 6858000; + private int _height = 6858000; + private int _width = 12192000; /// - /// Chart Width in EMU + /// Value in EMU /// - public uint width = 12192000; + private int _y = 0; /// - /// Chart X Position in EMU + /// Value in EMU /// - public uint x = 0; + private int _x = 0; /// - /// Chart Y Position in EMU + /// Chart Height in Px /// - public uint y = 0; + public int Height + { + get + { + return _height; + } + set + { + // _height = (int)ConverterUtils.PixelsToEmu(value); + _height = value; + } + } + /// + /// Chart Width in Px + /// + public int Width + { + get + { + return _width; + } + set + { + // _width = (int)ConverterUtils.PixelsToEmu(value); + _width = value; + } + } + /// + /// Chart X Position in Px + /// + public int X + { + get + { + return _x; + } + set + { + // _x = (int)ConverterUtils.PixelsToEmu(value); + _x = value; + } + } + /// + /// Chart Y Position in Px + /// + public int Y + { + get + { + return _y; + } + set + { + // _y = (int)ConverterUtils.PixelsToEmu(value); + _y = value; + } + } } /// /// diff --git a/Global/Models/2007/TextBoxModel.cs b/Global/Models/2007/TextBoxModel.cs index 613a27c7..9026496a 100644 --- a/Global/Models/2007/TextBoxModel.cs +++ b/Global/Models/2007/TextBoxModel.cs @@ -93,18 +93,18 @@ public class TextBoxSetting /// /// Gets or sets the height of the text box. /// - public uint height = 100; + public int height = 100; /// /// Gets or sets the width of the text box. /// - public uint width = 100; + public int width = 100; /// /// Gets or sets the X-coordinate of the text box in EMUs (English Metric Units). /// - public uint x = 0; + public int x = 0; /// /// Gets or sets the Y-coordinate of the text box in EMUs (English Metric Units). /// - public uint y = 0; + public int y = 0; } } diff --git a/Global/Parts/Theme.cs b/Global/Parts/Theme.cs index ae7d1e95..82e33250 100644 --- a/Global/Parts/Theme.cs +++ b/Global/Parts/Theme.cs @@ -24,7 +24,7 @@ public class Theme new int?[]{50000, 130000 ,103000,90000,98000}, new int?[]{100000, 120000 ,null,63000,null} }; - private readonly A.Theme openXMLTheme = new A.Theme(); + private readonly A.Theme documentTheme = new A.Theme(); /// /// Creates a new theme with the given pallet. /// @@ -41,7 +41,7 @@ public Theme(ThemePallet ThemePallet = null) /// public A.Theme GetTheme() { - return openXMLTheme; + return documentTheme; } private static A.Outline AppendNodes(int width) { @@ -66,9 +66,9 @@ private static A.Outline[] GenerateOutlines() } private void CreateTheme(ThemePallet ThemePallet) { - openXMLTheme.Name = "Office Theme"; - openXMLTheme.ObjectDefaults = new A.ObjectDefaults(); - openXMLTheme.ThemeElements = new A.ThemeElements() + documentTheme.Name = "Office Theme"; + documentTheme.ObjectDefaults = new A.ObjectDefaults(); + documentTheme.ThemeElements = new A.ThemeElements() { FontScheme = GenerateFontScheme(), FormatScheme = GenerateFormatScheme(), diff --git a/Presentation/Components/2007/Chart.cs b/Presentation/Components/2007/Chart.cs index db614bae..eb446ab9 100644 --- a/Presentation/Components/2007/Chart.cs +++ b/Presentation/Components/2007/Chart.cs @@ -18,14 +18,14 @@ public class Chart : ChartProperties where YAxisType : class, IAxisTypeOptions, new() where ZAxisType : class, IAxisTypeOptions, new() { - private readonly ChartPart openXMLChartPart; + private readonly ChartPart documentChartPart; /// /// Create Area Chart with provided settings /// Not Required Generic /// public Chart(Slide slide, DataCell[][] dataRows, AreaChartSetting areaChartSetting) : base(slide, areaChartSetting) { - openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); + documentChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); CreateChart(dataRows, areaChartSetting); } @@ -35,7 +35,7 @@ public Chart(Slide slide, DataCell[][] dataRows, AreaChartSetting public Chart(Slide slide, DataCell[][] dataRows, BarChartSetting barChartSetting) : base(slide, barChartSetting) { - openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); + documentChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); CreateChart(dataRows, barChartSetting); } @@ -45,7 +45,7 @@ public Chart(Slide slide, DataCell[][] dataRows, BarChartSetting public Chart(Slide slide, DataCell[][] dataRows, ColumnChartSetting columnChartSetting) : base(slide, columnChartSetting) { - openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); + documentChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); CreateChart(dataRows, columnChartSetting); } @@ -55,7 +55,7 @@ public Chart(Slide slide, DataCell[][] dataRows, ColumnChartSetting public Chart(Slide slide, DataCell[][] dataRows, LineChartSetting lineChartSetting) : base(slide, lineChartSetting) { - openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); + documentChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); CreateChart(dataRows, lineChartSetting); } @@ -65,7 +65,7 @@ public Chart(Slide slide, DataCell[][] dataRows, LineChartSetting public Chart(Slide slide, DataCell[][] dataRows, PieChartSetting pieChartSetting) : base(slide, pieChartSetting) { - openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); + documentChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); CreateChart(dataRows, pieChartSetting); } @@ -75,7 +75,7 @@ public Chart(Slide slide, DataCell[][] dataRows, PieChartSetting public Chart(Slide slide, DataCell[][] dataRows, ScatterChartSetting scatterChartSetting) : base(slide, scatterChartSetting) { - openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); + documentChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); CreateChart(dataRows, scatterChartSetting); } @@ -84,7 +84,7 @@ public Chart(Slide slide, DataCell[][] dataRows, ScatterChartSetting public Chart(Slide slide, DataCell[][] dataRows, ComboChartSetting comboChartSetting) : base(slide, comboChartSetting) { - openXMLChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); + documentChartPart = slide.GetSlidePart().AddNewPart(slide.GetNextSlideRelationId()); InitializeChartParts(); CreateChart(dataRows, comboChartSetting); } @@ -195,21 +195,21 @@ private void SaveChanges(ChartBase chart) } private ChartColorStylePart GetChartColorStylePart() { - return openXMLChartPart.ChartColorStyleParts.FirstOrDefault(); + return documentChartPart.ChartColorStyleParts.FirstOrDefault(); } private ChartPart GetChartPart() { - return openXMLChartPart; + return documentChartPart; } private ChartStylePart GetChartStylePart() { - return openXMLChartPart.ChartStyleParts.FirstOrDefault(); + return documentChartPart.ChartStyleParts.FirstOrDefault(); } private void InitializeChartParts() { - var unused2 = GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); - var unused1 = GetChartPart().AddNewPart(GetNextChartRelationId()); - var unused = GetChartPart().AddNewPart(GetNextChartRelationId()); + GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); + GetChartPart().AddNewPart(GetNextChartRelationId()); + GetChartPart().AddNewPart(GetNextChartRelationId()); } } } diff --git a/Presentation/Components/2007/Picture.cs b/Presentation/Components/2007/Picture.cs index 3fb393ee..9db2c015 100644 --- a/Presentation/Components/2007/Picture.cs +++ b/Presentation/Components/2007/Picture.cs @@ -14,7 +14,7 @@ namespace OpenXMLOffice.Presentation_2007 public class Picture : PresentationCommonProperties { private readonly Slide currentSlide; - private readonly P.Picture openXMLPicture; + private readonly P.Picture documentPicture; private readonly PictureSetting pictureSetting; /// @@ -24,7 +24,7 @@ public Picture(string filePath, Slide slide, PictureSetting pictureSetting) { currentSlide = slide; this.pictureSetting = pictureSetting; - openXMLPicture = new P.Picture(); + documentPicture = new P.Picture(); using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { Initialize(fileStream, slide, pictureSetting); @@ -38,7 +38,7 @@ public Picture(Stream stream, Slide slide, PictureSetting pictureSetting) { currentSlide = slide; this.pictureSetting = pictureSetting; - openXMLPicture = new P.Picture(); + documentPicture = new P.Picture(); Initialize(stream, slide, pictureSetting); } @@ -71,13 +71,13 @@ private void Initialize(Stream stream, Slide slide, PictureSetting pictureSettin case HyperlinkPropertyTypeValues.EXISTING_FILE: pictureSetting.hyperlinkProperties.relationId = relationId; pictureSetting.hyperlinkProperties.action = "ppaction://hlinkfile"; - var unused2 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); + slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SLIDE: pictureSetting.hyperlinkProperties.relationId = relationId; pictureSetting.hyperlinkProperties.action = "ppaction://hlinksldjump"; //TODO: Update Target Slide Prop - var unused1 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); + slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SHEET: throw new ArgumentException("This Option is valid only for Excel Files"); @@ -95,7 +95,7 @@ private void Initialize(Stream stream, Slide slide, PictureSetting pictureSettin break; default:// Web URL pictureSetting.hyperlinkProperties.relationId = relationId; - var unused = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); + slide.GetSlidePart().AddHyperlinkRelationship(new Uri(pictureSetting.hyperlinkProperties.value), true, relationId); break; } } @@ -125,9 +125,9 @@ public void UpdatePosition(uint X, uint Y) { pictureSetting.x = (uint)ConverterUtils.PixelsToEmu((int)X); pictureSetting.y = (uint)ConverterUtils.PixelsToEmu((int)Y); - if (openXMLPicture != null) + if (documentPicture != null) { - openXMLPicture.ShapeProperties.Transform2D = new A.Transform2D + documentPicture.ShapeProperties.Transform2D = new A.Transform2D { Offset = new A.Offset { X = pictureSetting.x, Y = pictureSetting.y }, Extents = new A.Extents { Cx = pictureSetting.width, Cy = pictureSetting.height } @@ -141,9 +141,9 @@ public void UpdateSize(uint Width, uint Height) { pictureSetting.width = (uint)ConverterUtils.PixelsToEmu((int)Width); pictureSetting.height = (uint)ConverterUtils.PixelsToEmu((int)Height); - if (openXMLPicture != null) + if (documentPicture != null) { - openXMLPicture.ShapeProperties.Transform2D = new A.Transform2D + documentPicture.ShapeProperties.Transform2D = new A.Transform2D { Offset = new A.Offset { X = pictureSetting.x, Y = pictureSetting.y }, Extents = new A.Extents { Cx = pictureSetting.width, Cy = pictureSetting.height } @@ -152,7 +152,7 @@ public void UpdateSize(uint Width, uint Height) } internal P.Picture GetPicture() { - return openXMLPicture; + return documentPicture; } private void CreatePicture(string EmbedId, HyperlinkProperties hyperlinkProperties) { @@ -172,7 +172,7 @@ private void CreatePicture(string EmbedId, HyperlinkProperties hyperlinkProperti ); if (hyperlinkProperties != null) { - var unused = GetPicture().NonVisualPictureProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); + GetPicture().NonVisualPictureProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); } GetPicture().ShapeProperties = new P.ShapeProperties( new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle } diff --git a/Presentation/Components/2007/Shape.cs b/Presentation/Components/2007/Shape.cs index 2137f43c..0d871396 100644 --- a/Presentation/Components/2007/Shape.cs +++ b/Presentation/Components/2007/Shape.cs @@ -13,12 +13,12 @@ namespace OpenXMLOffice.Presentation_2007 /// public class Shape : PresentationCommonProperties { - private readonly P.Shape openXMLShape = new P.Shape(); + private readonly P.Shape documentShape = new P.Shape(); internal Shape(P.Shape shape = null) { if (shape != null) { - openXMLShape = shape; + documentShape = shape; } } @@ -27,7 +27,12 @@ internal Shape(P.Shape shape = null) /// public void RemoveShape() { - openXMLShape.Remove(); + documentShape.Remove(); + } + + internal P.Shape GetDocumentShape() + { + return documentShape; } internal Shape AddLine(LineShapeModel lineModel) @@ -58,22 +63,22 @@ public Chart ReplaceChart ReplaceChart public P16.Chart ReplaceChart(P16.Chart chart) { - DocumentFormat.OpenXml.OpenXmlElement parent = openXMLShape.Parent; + DocumentFormat.OpenXml.OpenXmlElement parent = documentShape.Parent; if (parent == null) { throw new InvalidOperationException("Old shape must have a parent."); } - if (openXMLShape.ShapeProperties.Transform2D != null) + if (documentShape.ShapeProperties.Transform2D != null) { - A.Transform2D oldTransform = openXMLShape.ShapeProperties.Transform2D; + A.Transform2D oldTransform = documentShape.ShapeProperties.Transform2D; chart.UpdateSize((uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cx), (uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cy)); chart.UpdatePosition((uint)ConverterUtils.EmuToPixels(oldTransform.Offset.X), (uint)ConverterUtils.EmuToPixels(oldTransform.Offset.Y)); } if (chart.GetAlternateContent().Parent == null) { - var unused = parent.InsertBefore(chart.GetAlternateContent(), openXMLShape); + parent.InsertBefore(chart.GetAlternateContent(), documentShape); } - openXMLShape.Remove(); + documentShape.Remove(); return chart; } @@ -106,22 +111,22 @@ public P16.Chart ReplaceChart(P16.Chart chart) /// public Picture ReplacePicture(Picture picture) { - DocumentFormat.OpenXml.OpenXmlElement parent = openXMLShape.Parent; + DocumentFormat.OpenXml.OpenXmlElement parent = documentShape.Parent; if (parent == null) { throw new InvalidOperationException("Old shape must have a parent."); } - if (openXMLShape.ShapeProperties.Transform2D != null) + if (documentShape.ShapeProperties.Transform2D != null) { - A.Transform2D oldTransform = openXMLShape.ShapeProperties.Transform2D; + A.Transform2D oldTransform = documentShape.ShapeProperties.Transform2D; picture.UpdateSize((uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cx), (uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cy)); picture.UpdatePosition((uint)ConverterUtils.EmuToPixels(oldTransform.Offset.X), (uint)ConverterUtils.EmuToPixels(oldTransform.Offset.Y)); } if (picture.GetPicture().Parent == null) { - var unused = parent.InsertBefore(picture.GetPicture(), openXMLShape); + parent.InsertBefore(picture.GetPicture(), documentShape); } - openXMLShape.Remove(); + documentShape.Remove(); return picture; } @@ -130,22 +135,22 @@ public Picture ReplacePicture(Picture picture) /// public Table ReplaceTable(Table table) { - DocumentFormat.OpenXml.OpenXmlElement parent = openXMLShape.Parent; + DocumentFormat.OpenXml.OpenXmlElement parent = documentShape.Parent; if (parent == null) { throw new InvalidOperationException("Old shape must have a parent."); } - if (openXMLShape.ShapeProperties.Transform2D != null) + if (documentShape.ShapeProperties.Transform2D != null) { - A.Transform2D oldTransform = openXMLShape.ShapeProperties.Transform2D; + A.Transform2D oldTransform = documentShape.ShapeProperties.Transform2D; table.UpdateSize((uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cx), (uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cy)); table.UpdatePosition((uint)ConverterUtils.EmuToPixels(oldTransform.Offset.X), (uint)ConverterUtils.EmuToPixels(oldTransform.Offset.Y)); } if (table.GetTableGraphicFrame().Parent == null) { - var unused = parent.InsertBefore(table.GetTableGraphicFrame(), openXMLShape); + parent.InsertBefore(table.GetTableGraphicFrame(), documentShape); } - openXMLShape.Remove(); + documentShape.Remove(); return table; } @@ -154,27 +159,27 @@ public Table ReplaceTable(Table table) /// public TextBox ReplaceTextBox(TextBox textBox) { - DocumentFormat.OpenXml.OpenXmlElement parent = openXMLShape.Parent; + DocumentFormat.OpenXml.OpenXmlElement parent = documentShape.Parent; if (parent == null) { throw new InvalidOperationException("Old shape must have a parent."); } - if (openXMLShape.ShapeProperties.Transform2D != null) + if (documentShape.ShapeProperties.Transform2D != null) { - A.Transform2D oldTransform = openXMLShape.ShapeProperties.Transform2D; + A.Transform2D oldTransform = documentShape.ShapeProperties.Transform2D; textBox.UpdateSize((uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cx), (uint)ConverterUtils.EmuToPixels(oldTransform.Extents.Cy)); textBox.UpdatePosition((uint)ConverterUtils.EmuToPixels(oldTransform.Offset.X), (uint)ConverterUtils.EmuToPixels(oldTransform.Offset.Y)); - if (openXMLShape.ShapeStyle != null) + if (documentShape.ShapeStyle != null) { - P.ShapeStyle ShapeStyle = (P.ShapeStyle)openXMLShape.ShapeStyle.Clone(); + P.ShapeStyle ShapeStyle = (P.ShapeStyle)documentShape.ShapeStyle.Clone(); textBox.UpdateShapeStyle(ShapeStyle); } } if (textBox.GetTextBoxShape().Parent == null) { - var unused = parent.InsertBefore(textBox.GetTextBoxShape(), openXMLShape); + parent.InsertBefore(textBox.GetTextBoxShape(), documentShape); } - openXMLShape.Remove(); + documentShape.Remove(); return textBox; } @@ -183,9 +188,9 @@ public TextBox ReplaceTextBox(TextBox textBox) /// public void UpdateShape(ShapeTextModel shapeTextModel) { - if (openXMLShape.TextBody != null) + if (documentShape.TextBody != null) { - A.Paragraph paragraph = openXMLShape.TextBody.GetFirstChild(); + A.Paragraph paragraph = documentShape.TextBody.GetFirstChild(); if (paragraph != null) { paragraph.RemoveAllChildren(); diff --git a/Presentation/Components/2007/TextBox.cs b/Presentation/Components/2007/TextBox.cs index a8cbce81..3b9a6245 100644 --- a/Presentation/Components/2007/TextBox.cs +++ b/Presentation/Components/2007/TextBox.cs @@ -13,7 +13,7 @@ namespace OpenXMLOffice.Presentation_2007 public class TextBox : PresentationCommonProperties { private readonly TextBoxSetting textBoxSetting; - private P.Shape openXMLShape; + private P.Shape documentShape; private readonly Slide slide; /// /// Create TextBox with provided settings @@ -21,7 +21,7 @@ public class TextBox : PresentationCommonProperties internal TextBox(TextBoxSetting TextBoxSetting) { textBoxSetting = TextBoxSetting; - var unused = CreateTextBox(); + CreateTextBox(); } /// /// Create TextBox with provided settings @@ -30,7 +30,7 @@ public TextBox(Slide Slide, TextBoxSetting TextBoxSetting) { slide = Slide; textBoxSetting = TextBoxSetting; - var unused = CreateTextBox(); + CreateTextBox(); slide.GetSlide().CommonSlideData.ShapeTree.Append(GetTextBoxShape()); } /// @@ -38,18 +38,18 @@ public TextBox(Slide Slide, TextBoxSetting TextBoxSetting) /// internal P.Shape GetTextBoxShape() { - return openXMLShape; + return documentShape; } /// /// Update TextBox Position /// public void UpdatePosition(uint X, uint Y) { - textBoxSetting.x = (uint)ConverterUtils.PixelsToEmu((int)X); - textBoxSetting.y = (uint)ConverterUtils.PixelsToEmu((int)Y); - if (openXMLShape != null) + textBoxSetting.x = (int)ConverterUtils.PixelsToEmu((int)X); + textBoxSetting.y = (int)ConverterUtils.PixelsToEmu((int)Y); + if (documentShape != null) { - openXMLShape.ShapeProperties.Transform2D = new A.Transform2D + documentShape.ShapeProperties.Transform2D = new A.Transform2D { Offset = new A.Offset { X = textBoxSetting.x, Y = textBoxSetting.y }, Extents = new A.Extents { Cx = textBoxSetting.width, Cy = textBoxSetting.height } @@ -61,11 +61,11 @@ public void UpdatePosition(uint X, uint Y) /// public void UpdateSize(uint Width, uint Height) { - textBoxSetting.width = (uint)ConverterUtils.PixelsToEmu((int)Width); - textBoxSetting.height = (uint)ConverterUtils.PixelsToEmu((int)Height); - if (openXMLShape != null) + textBoxSetting.width = (int)ConverterUtils.PixelsToEmu((int)Width); + textBoxSetting.height = (int)ConverterUtils.PixelsToEmu((int)Height); + if (documentShape != null) { - openXMLShape.ShapeProperties.Transform2D = new A.Transform2D + documentShape.ShapeProperties.Transform2D = new A.Transform2D { Offset = new A.Offset { X = textBoxSetting.x, Y = textBoxSetting.y }, Extents = new A.Extents { Cx = textBoxSetting.width, Cy = textBoxSetting.height } @@ -113,13 +113,13 @@ private P.Shape CreateTextBox() case HyperlinkPropertyTypeValues.EXISTING_FILE: textBlock.hyperlinkProperties.relationId = relationId; textBlock.hyperlinkProperties.action = "ppaction://hlinkfile"; - var unused2 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); + slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SLIDE: textBlock.hyperlinkProperties.relationId = relationId; textBlock.hyperlinkProperties.action = "ppaction://hlinksldjump"; //TODO: Update Target Slide Prop - var unused1 = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); + slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); break; case HyperlinkPropertyTypeValues.TARGET_SHEET: throw new ArgumentException("This Option is valid only for Excel Files"); @@ -137,7 +137,7 @@ private P.Shape CreateTextBox() break; default:// Web URL textBlock.hyperlinkProperties.relationId = relationId; - var unused = slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); + slide.GetSlidePart().AddHyperlinkRelationship(new Uri(textBlock.hyperlinkProperties.value), true, relationId); break; } } @@ -173,7 +173,7 @@ private P.Shape CreateTextBox() }; drawingRunModels.Add(drawingRunModel); } - openXMLShape = new P.Shape() + documentShape = new P.Shape() { NonVisualShapeProperties = new P.NonVisualShapeProperties( new P.NonVisualDrawingProperties() @@ -196,7 +196,7 @@ private P.Shape CreateTextBox() drawingRuns = drawingRunModels.ToArray() })), }; - return openXMLShape; + return documentShape; } } } diff --git a/Presentation/Components/2016/AdvancedChartProperties.cs b/Presentation/Components/2016/AdvancedChartProperties.cs index 57d7159e..4b6c29ef 100644 --- a/Presentation/Components/2016/AdvancedChartProperties.cs +++ b/Presentation/Components/2016/AdvancedChartProperties.cs @@ -24,10 +24,10 @@ public AdvancedChartProperties(Slide slide, ChartSetting ch errorMessage = new TextBox(new TextBoxSetting() { textBlocks = new List() { new TextBlock() { textValue = "This chart is not supported in this version of PowerPoint. Requires PowerPoint 2016 or later.", } }.ToArray(), - x = chartSetting.applicationSpecificSetting.x, - y = chartSetting.applicationSpecificSetting.y, - width = chartSetting.applicationSpecificSetting.width, - height = chartSetting.applicationSpecificSetting.height, + x = chartSetting.applicationSpecificSetting.X, + y = chartSetting.applicationSpecificSetting.Y, + width = chartSetting.applicationSpecificSetting.Width, + height = chartSetting.applicationSpecificSetting.Height, }); } /// @@ -44,7 +44,7 @@ internal void CreateExtendedChartGraphicFrame(string relationshipId, uint id, Hy }; if (hyperlinkProperties != null) { - var unused = nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); + nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); } graphicFrame = new P.GraphicFrame() { @@ -52,13 +52,13 @@ internal void CreateExtendedChartGraphicFrame(string relationshipId, uint id, Hy Transform = new P.Transform( new A.Offset { - X = chartSetting.applicationSpecificSetting.x, - Y = chartSetting.applicationSpecificSetting.y + X = chartSetting.applicationSpecificSetting.X, + Y = chartSetting.applicationSpecificSetting.Y }, new A.Extents { - Cx = chartSetting.applicationSpecificSetting.width, - Cy = chartSetting.applicationSpecificSetting.height + Cx = chartSetting.applicationSpecificSetting.Width, + Cy = chartSetting.applicationSpecificSetting.Height }), Graphic = new A.Graphic( new A.GraphicData( diff --git a/Presentation/Components/2016/Chart.cs b/Presentation/Components/2016/Chart.cs index 2a66cfb2..dc549cb5 100644 --- a/Presentation/Components/2016/Chart.cs +++ b/Presentation/Components/2016/Chart.cs @@ -84,9 +84,9 @@ private ChartStylePart GetChartStylePart() } private void InitializeChartParts() { - var unused2 = GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); - var unused1 = GetChartPart().AddNewPart(GetNextChartRelationId()); - var unused = GetChartPart().AddNewPart(GetNextChartRelationId()); + GetChartPart().AddNewPart(EmbeddedPackagePartType.Xlsx.ContentType, GetNextChartRelationId()); + GetChartPart().AddNewPart(GetNextChartRelationId()); + GetChartPart().AddNewPart(GetNextChartRelationId()); } } } diff --git a/Presentation/Components/Common/ChartProperties.cs b/Presentation/Components/Common/ChartProperties.cs index 79e6290c..6fde0a99 100644 --- a/Presentation/Components/Common/ChartProperties.cs +++ b/Presentation/Components/Common/ChartProperties.cs @@ -56,18 +56,18 @@ internal void WriteDataToExcel(DataCell[][] dataRows, Stream stream) /// /// X,Y /// - internal Tuple GetPosition() + internal Tuple GetPosition() { - return Tuple.Create(chartSetting.applicationSpecificSetting.x, chartSetting.applicationSpecificSetting.y); + return Tuple.Create(chartSetting.applicationSpecificSetting.X, chartSetting.applicationSpecificSetting.Y); } /// /// /// /// Width,Height /// - internal Tuple GetSize() + internal Tuple GetSize() { - return Tuple.Create(chartSetting.applicationSpecificSetting.width, chartSetting.applicationSpecificSetting.height); + return Tuple.Create(chartSetting.applicationSpecificSetting.Width, chartSetting.applicationSpecificSetting.Height); } /// /// Update Chart Position @@ -78,14 +78,14 @@ internal Tuple GetSize() /// public virtual void UpdatePosition(uint X, uint Y) { - chartSetting.applicationSpecificSetting.x = (uint)ConverterUtils.PixelsToEmu((int)X); - chartSetting.applicationSpecificSetting.y = (uint)ConverterUtils.PixelsToEmu((int)Y); + chartSetting.applicationSpecificSetting.X = (int)ConverterUtils.PixelsToEmu((int)X); + chartSetting.applicationSpecificSetting.Y = (int)ConverterUtils.PixelsToEmu((int)Y); if (graphicFrame != null) { graphicFrame.Transform = new P.Transform { - Offset = new A.Offset { X = chartSetting.applicationSpecificSetting.x, Y = chartSetting.applicationSpecificSetting.y }, - Extents = new A.Extents { Cx = chartSetting.applicationSpecificSetting.width, Cy = chartSetting.applicationSpecificSetting.height } + Offset = new A.Offset { X = chartSetting.applicationSpecificSetting.X, Y = chartSetting.applicationSpecificSetting.Y }, + Extents = new A.Extents { Cx = chartSetting.applicationSpecificSetting.Width, Cy = chartSetting.applicationSpecificSetting.Height } }; } } @@ -98,14 +98,14 @@ public virtual void UpdatePosition(uint X, uint Y) /// public virtual void UpdateSize(uint Width, uint Height) { - chartSetting.applicationSpecificSetting.width = (uint)ConverterUtils.PixelsToEmu((int)Width); - chartSetting.applicationSpecificSetting.height = (uint)ConverterUtils.PixelsToEmu((int)Height); + chartSetting.applicationSpecificSetting.Width = (int)ConverterUtils.PixelsToEmu((int)Width); + chartSetting.applicationSpecificSetting.Height = (int)ConverterUtils.PixelsToEmu((int)Height); if (graphicFrame != null) { graphicFrame.Transform = new P.Transform { - Offset = new A.Offset { X = chartSetting.applicationSpecificSetting.x, Y = chartSetting.applicationSpecificSetting.y }, - Extents = new A.Extents { Cx = chartSetting.applicationSpecificSetting.width, Cy = chartSetting.applicationSpecificSetting.height } + Offset = new A.Offset { X = chartSetting.applicationSpecificSetting.X, Y = chartSetting.applicationSpecificSetting.Y }, + Extents = new A.Extents { Cx = chartSetting.applicationSpecificSetting.Width, Cy = chartSetting.applicationSpecificSetting.Height } }; } } @@ -150,7 +150,7 @@ internal void CreateChartGraphicFrame(string relationshipId, uint id, HyperlinkP }; if (hyperlinkProperties != null) { - var unused = nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); + nonVisualProperties.NonVisualDrawingProperties.InsertAt(CreateHyperLink(hyperlinkProperties), 0); } graphicFrame = new P.GraphicFrame() { @@ -158,13 +158,13 @@ internal void CreateChartGraphicFrame(string relationshipId, uint id, HyperlinkP Transform = new P.Transform( new A.Offset { - X = chartSetting.applicationSpecificSetting.x, - Y = chartSetting.applicationSpecificSetting.y + X = chartSetting.applicationSpecificSetting.X, + Y = chartSetting.applicationSpecificSetting.Y }, new A.Extents { - Cx = chartSetting.applicationSpecificSetting.width, - Cy = chartSetting.applicationSpecificSetting.height + Cx = chartSetting.applicationSpecificSetting.Width, + Cy = chartSetting.applicationSpecificSetting.Height }), Graphic = new A.Graphic( new A.GraphicData( diff --git a/Presentation/Internal/Presentation.cs b/Presentation/Internal/Presentation.cs index eccd6e46..3ebfef3b 100644 --- a/Presentation/Internal/Presentation.cs +++ b/Presentation/Internal/Presentation.cs @@ -21,7 +21,7 @@ internal Slide AddSlide(PresentationConstants.SlideLayoutType slideLayoutType) SlidePart slidePart = GetPresentationPart().AddNewPart(GetNextPresentationRelationId()); Slide slide = new Slide(); slidePart.Slide = slide.GetSlide(); - var unused = slidePart.AddPart(GetSlideLayoutPart(slideLayoutType)); + slidePart.AddPart(GetSlideLayoutPart(slideLayoutType)); P.SlideIdList slideIdList = GetSlideIdList(); P.SlideId slideId = new P.SlideId() { Id = GetNextSlideId(), RelationshipId = GetPresentationPart().GetIdOfPart(slidePart) }; slideIdList.Append(slideId); @@ -51,8 +51,8 @@ internal void MoveSlideByIndex(int SourceIndex, int TargetIndex) { P.SlideId SourceSlideId = (P.SlideId)GetSlideIdList().ElementAt(SourceIndex); P.SlideId TargetSlideId = (P.SlideId)GetSlideIdList().ElementAt(TargetIndex); - var unused1 = GetSlideIdList().RemoveChild(SourceSlideId); - var unused = GetSlideIdList().InsertBefore(SourceSlideId, TargetSlideId); + GetSlideIdList().RemoveChild(SourceSlideId); + GetSlideIdList().InsertBefore(SourceSlideId, TargetSlideId); presentationDocument.Save(); } else @@ -66,7 +66,7 @@ internal void RemoveSlideByIndex(int SlideIndex) { P.SlideId SlideId = (P.SlideId)GetSlideIdList().ElementAt(SlideIndex); SlidePart SlidePart = (SlidePart)GetPresentationPart().GetPartById(SlideId.RelationshipId.Value); - var unused1 = GetSlideIdList().RemoveChild(SlideId); + GetSlideIdList().RemoveChild(SlideId); try { GetPresentationPart().DeleteReferenceRelationship(SlideId.RelationshipId.Value); @@ -76,7 +76,7 @@ internal void RemoveSlideByIndex(int SlideIndex) { throw; } - var unused = GetPresentationPart().DeletePart(SlidePart); + GetPresentationPart().DeletePart(SlidePart); } else { diff --git a/Presentation/Internal/PresentationCore.cs b/Presentation/Internal/PresentationCore.cs index c0da61b3..a77ffe99 100644 --- a/Presentation/Internal/PresentationCore.cs +++ b/Presentation/Internal/PresentationCore.cs @@ -137,7 +137,7 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) SlideLayout slideLayout = new SlideLayout(); if (presentationDocument.CoreFilePropertiesPart == null) { - var unused8 = presentationDocument.AddCoreFilePropertiesPart(); + presentationDocument.AddCoreFilePropertiesPart(); using (Stream stream = presentationDocument.CoreFilePropertiesPart.GetStream(FileMode.OpenOrCreate, FileAccess.ReadWrite)) { CoreProperties.AddCoreProperties(stream, powerPointProperties.coreProperties); @@ -160,23 +160,23 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) } if (presentationPart.Presentation.GetFirstChild() == null) { - var unused7 = presentationPart.Presentation.AppendChild(new P.SlideMasterIdList()); + presentationPart.Presentation.AppendChild(new P.SlideMasterIdList()); } if (presentationPart.Presentation.SlideIdList == null) { - var unused6 = presentationPart.Presentation.AppendChild(new P.SlideIdList()); + presentationPart.Presentation.AppendChild(new P.SlideIdList()); } if (presentationPart.Presentation.GetFirstChild() == null) { - var unused5 = presentationPart.Presentation.AppendChild(new P.SlideSize { Cx = 12192000, Cy = 6858000 }); + presentationPart.Presentation.AppendChild(new P.SlideSize { Cx = 12192000, Cy = 6858000 }); } if (presentationPart.Presentation.GetFirstChild() == null) { - var unused4 = presentationPart.Presentation.AppendChild(new P.NotesSize { Cx = 6858000, Cy = 6858000 }); + presentationPart.Presentation.AppendChild(new P.NotesSize { Cx = 6858000, Cy = 6858000 }); } if (presentationPart.Presentation.GetFirstChild() == null) { - var unused3 = presentationPart.Presentation.AppendChild(CreateDefaultTextStyle()); + presentationPart.Presentation.AppendChild(CreateDefaultTextStyle()); } if (presentationPart.ViewPropertiesPart == null) { @@ -203,7 +203,7 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) SlideLayoutPart slideLayoutPart = slideMasterPart.AddNewPart(GetNextPresentationRelationId()); slideMaster.AddSlideLayoutIdToList(slideMasterPart.GetIdOfPart(slideLayoutPart)); slideLayoutPart.SlideLayout = slideLayout.GetSlideLayout(); - var unused2 = slideLayout.UpdateRelationship(slideMasterPart, presentationPart.GetIdOfPart(slideMasterPart)); + slideLayout.UpdateRelationship(slideMasterPart, presentationPart.GetIdOfPart(slideMasterPart)); slideLayoutPart.SlideLayout.Save(); slideMasterPart.SlideMaster.Save(); } @@ -230,14 +230,14 @@ private void InitializePresentation(PowerPointProperties powerPointProperties) } if (presentationPart.ThemePart == null) { - var unused1 = presentationPart.AddNewPart(GetNextPresentationRelationId()); + presentationPart.AddNewPart(GetNextPresentationRelationId()); } if (presentationPart.ThemePart.Theme == null) { Theme theme = new Theme(powerPointProperties.theme); presentationPart.ThemePart.Theme = theme.GetTheme(); } - var unused = slideMaster.UpdateRelationship(presentationPart.ThemePart, presentationPart.GetIdOfPart(presentationPart.ThemePart)); + slideMaster.UpdateRelationship(presentationPart.ThemePart, presentationPart.GetIdOfPart(presentationPart.ThemePart)); presentationPart.Presentation.Save(); } } diff --git a/Presentation/Parts/CommonSlideData.cs b/Presentation/Parts/CommonSlideData.cs index 124753d8..68b91391 100644 --- a/Presentation/Parts/CommonSlideData.cs +++ b/Presentation/Parts/CommonSlideData.cs @@ -12,10 +12,10 @@ namespace OpenXMLOffice.Presentation_2007 /// public class CommonSlideData : PresentationCommonProperties { - private readonly P.CommonSlideData openXMLCommonSlideData; + private readonly P.CommonSlideData documentCommonSlideData; internal CommonSlideData(PresentationConstants.CommonSlideDataType commonSlideDataType, PresentationConstants.SlideLayoutType layoutType) { - openXMLCommonSlideData = new P.CommonSlideData() + documentCommonSlideData = new P.CommonSlideData() { Name = PresentationConstants.GetSlideLayoutType(layoutType) }; @@ -23,12 +23,12 @@ internal CommonSlideData(PresentationConstants.CommonSlideDataType commonSlideDa } internal CommonSlideData(P.CommonSlideData commonSlideData) { - openXMLCommonSlideData = commonSlideData; + documentCommonSlideData = commonSlideData; } // Return OpenXML CommonSlideData Object internal P.CommonSlideData GetCommonSlideData() { - return openXMLCommonSlideData; + return documentCommonSlideData; } private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType commonSlideDataType) { @@ -79,8 +79,8 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com switch (commonSlideDataType) { case PresentationConstants.CommonSlideDataType.SLIDE_MASTER: - openXMLCommonSlideData.AppendChild(background); - openXMLCommonSlideData.AppendChild(shapeTree); + documentCommonSlideData.AppendChild(background); + documentCommonSlideData.AppendChild(shapeTree); break; case PresentationConstants.CommonSlideDataType.SLIDE_LAYOUT: shapeTree.AppendChild(CreateShape(new ShapeModel>() @@ -159,10 +159,10 @@ private void CreateCommonSlideData(PresentationConstants.CommonSlideDataType com }.ToArray() } })); - openXMLCommonSlideData.AppendChild(shapeTree); + documentCommonSlideData.AppendChild(shapeTree); break; default: // slide - openXMLCommonSlideData.AppendChild(shapeTree); + documentCommonSlideData.AppendChild(shapeTree); break; } } diff --git a/Presentation/Parts/Slide.cs b/Presentation/Parts/Slide.cs index 37306751..f49c0a45 100644 --- a/Presentation/Parts/Slide.cs +++ b/Presentation/Parts/Slide.cs @@ -17,7 +17,7 @@ namespace OpenXMLOffice.Presentation_2007 /// public class Slide { - private readonly P.Slide openXMLSlide = new P.Slide(); + private readonly P.Slide documentSlide = new P.Slide(); /// /// /// @@ -25,11 +25,11 @@ public bool ShowHideSlide { get { - return openXMLSlide.Show; + return documentSlide.Show; } set { - openXMLSlide.Show = value; + documentSlide.Show = value; } } internal Slide(P.Slide OpenXMLSlide = null, SlideModel slideModel = null) @@ -40,20 +40,20 @@ internal Slide(P.Slide OpenXMLSlide = null, SlideModel slideModel = null) } if (OpenXMLSlide != null) { - openXMLSlide = OpenXMLSlide; + documentSlide = OpenXMLSlide; } else { CommonSlideData commonSlideData = new CommonSlideData(PresentationConstants.CommonSlideDataType.SLIDE, PresentationConstants.SlideLayoutType.BLANK); - openXMLSlide.CommonSlideData = commonSlideData.GetCommonSlideData(); - openXMLSlide.ColorMapOverride = new P.ColorMapOverride() + documentSlide.CommonSlideData = commonSlideData.GetCommonSlideData(); + documentSlide.ColorMapOverride = new P.ColorMapOverride() { MasterColorMapping = new A.MasterColorMapping() }; - openXMLSlide.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); - openXMLSlide.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + documentSlide.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); + documentSlide.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); } - openXMLSlide.Show = !slideModel.hideSlide; + documentSlide.Show = !slideModel.hideSlide; } /// @@ -197,10 +197,10 @@ public Shape AddShape(RectangleShapeModel /// Insert Shape into slide @@ -235,15 +235,15 @@ internal string GetNextSlideRelationId() } internal P.Slide GetSlide() { - return openXMLSlide; + return documentSlide; } internal SlidePart GetSlidePart() { - return openXMLSlide.SlidePart; + return documentSlide.SlidePart; } private P.CommonSlideData GetCommonSlideData() { - return openXMLSlide.CommonSlideData; + return documentSlide.CommonSlideData; } } } diff --git a/Presentation/Parts/SlideLayout.cs b/Presentation/Parts/SlideLayout.cs index 85e57652..2b6c588e 100644 --- a/Presentation/Parts/SlideLayout.cs +++ b/Presentation/Parts/SlideLayout.cs @@ -8,7 +8,7 @@ namespace OpenXMLOffice.Presentation_2007 internal class SlideLayout { private readonly CommonSlideData commonSlideData = new CommonSlideData(PresentationConstants.CommonSlideDataType.SLIDE_LAYOUT, PresentationConstants.SlideLayoutType.BLANK); - private readonly P.SlideLayout openXMLSlideLayout = new P.SlideLayout() + private readonly P.SlideLayout documentSlideLayout = new P.SlideLayout() { Type = P.SlideLayoutValues.Text }; public SlideLayout() @@ -17,19 +17,19 @@ internal class SlideLayout } public P.SlideLayout GetSlideLayout() { - return openXMLSlideLayout; + return documentSlideLayout; } public string UpdateRelationship(OpenXmlPart openXmlPart, string RelationshipId) { - return openXMLSlideLayout.SlideLayoutPart.CreateRelationshipToPart(openXmlPart, RelationshipId); + return documentSlideLayout.SlideLayoutPart.CreateRelationshipToPart(openXmlPart, RelationshipId); } private void CreateSlideLayout() { - var unused1 = openXMLSlideLayout.AppendChild(commonSlideData.GetCommonSlideData()); - openXMLSlideLayout.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); - openXMLSlideLayout.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); - openXMLSlideLayout.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); - var unused = openXMLSlideLayout.AppendChild(new P.ColorMapOverride() + documentSlideLayout.AppendChild(commonSlideData.GetCommonSlideData()); + documentSlideLayout.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); + documentSlideLayout.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + documentSlideLayout.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); + documentSlideLayout.AppendChild(new P.ColorMapOverride() { MasterColorMapping = new A.MasterColorMapping() }); diff --git a/Presentation/Parts/SlideMaster.cs b/Presentation/Parts/SlideMaster.cs index 638b2b45..817f1c3c 100644 --- a/Presentation/Parts/SlideMaster.cs +++ b/Presentation/Parts/SlideMaster.cs @@ -8,7 +8,7 @@ namespace OpenXMLOffice.Presentation_2007 { internal class SlideMaster { - internal P.SlideMaster openXMLSlideMaster = new P.SlideMaster(); + internal P.SlideMaster documentSlideMaster = new P.SlideMaster(); internal P.SlideLayoutIdList slideLayoutIdList; private readonly CommonSlideData commonSlideData = new CommonSlideData(PresentationConstants.CommonSlideDataType.SLIDE_MASTER, PresentationConstants.SlideLayoutType.BLANK); public SlideMaster() { @@ -16,7 +16,7 @@ internal class SlideMaster } public void AddSlideLayoutIdToList(string relationshipId) { - var unused = slideLayoutIdList.AppendChild(new P.SlideLayoutId() + slideLayoutIdList.AppendChild(new P.SlideLayoutId() { Id = (uint)(2147483649 + slideLayoutIdList.Count() + 1), RelationshipId = relationshipId @@ -24,24 +24,24 @@ public void AddSlideLayoutIdToList(string relationshipId) } public P.SlideMaster GetSlideMaster() { - return openXMLSlideMaster; + return documentSlideMaster; } public string UpdateRelationship(OpenXmlPart openXmlPart, string RelationshipId) { - if (openXMLSlideMaster.SlideMasterPart != null) + if (documentSlideMaster.SlideMasterPart != null) { - return openXMLSlideMaster.SlideMasterPart.CreateRelationshipToPart(openXmlPart, RelationshipId); + return documentSlideMaster.SlideMasterPart.CreateRelationshipToPart(openXmlPart, RelationshipId); } return null; } private void CreateSlideMaster() { slideLayoutIdList = new P.SlideLayoutIdList(); - openXMLSlideMaster = new P.SlideMaster(commonSlideData.GetCommonSlideData()); - openXMLSlideMaster.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); - openXMLSlideMaster.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); - openXMLSlideMaster.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); - var unused2 = openXMLSlideMaster.AppendChild(new P.ColorMap() + documentSlideMaster = new P.SlideMaster(commonSlideData.GetCommonSlideData()); + documentSlideMaster.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); + documentSlideMaster.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + documentSlideMaster.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); + documentSlideMaster.AppendChild(new P.ColorMap() { Accent1 = A.ColorSchemeIndexValues.Accent1, Accent2 = A.ColorSchemeIndexValues.Accent2, @@ -56,8 +56,8 @@ private void CreateSlideMaster() Hyperlink = A.ColorSchemeIndexValues.Hyperlink, FollowedHyperlink = A.ColorSchemeIndexValues.FollowedHyperlink }); - var unused1 = openXMLSlideMaster.AppendChild(slideLayoutIdList); - var unused = openXMLSlideMaster.AppendChild(CreateTextStyles()); + documentSlideMaster.AppendChild(slideLayoutIdList); + documentSlideMaster.AppendChild(CreateTextStyles()); } private static P.TextStyles CreateTextStyles() { diff --git a/Presentation/Parts/ViewProperties.cs b/Presentation/Parts/ViewProperties.cs index 983fc370..f83a0f25 100644 --- a/Presentation/Parts/ViewProperties.cs +++ b/Presentation/Parts/ViewProperties.cs @@ -9,19 +9,19 @@ namespace OpenXMLOffice.Presentation_2007 /// public class ViewProperties { - private readonly P.ViewProperties openXMLViewProperties = new P.ViewProperties(); + private readonly P.ViewProperties documentViewProperties = new P.ViewProperties(); /// /// Create New View Properties /// public ViewProperties() { - openXMLViewProperties.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); - openXMLViewProperties.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); - openXMLViewProperties.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); - var unused3 = openXMLViewProperties.AppendChild(CreateNormalViewProperties()); - var unused2 = openXMLViewProperties.AppendChild(CreateSlideViewProperties()); - var unused1 = openXMLViewProperties.AppendChild(CreateNotesTextViewProperties()); - var unused = openXMLViewProperties.AppendChild(new P.GridSpacing() + documentViewProperties.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); + documentViewProperties.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + documentViewProperties.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); + documentViewProperties.AppendChild(CreateNormalViewProperties()); + documentViewProperties.AppendChild(CreateSlideViewProperties()); + documentViewProperties.AppendChild(CreateNotesTextViewProperties()); + documentViewProperties.AppendChild(new P.GridSpacing() { Cx = 72008, Cy = 72008 @@ -34,7 +34,7 @@ public ViewProperties() /// public P.ViewProperties GetViewProperties() { - return openXMLViewProperties; + return documentViewProperties; } private static P.NotesTextViewProperties CreateNotesTextViewProperties() { diff --git a/Spreadsheet/Components/2007/Chart.cs b/Spreadsheet/Components/2007/Chart.cs index a809b537..5d3c940f 100644 --- a/Spreadsheet/Components/2007/Chart.cs +++ b/Spreadsheet/Components/2007/Chart.cs @@ -15,14 +15,14 @@ public class Chart : ChartProperties where YAxisType : class, IAxisTypeOptions, new() where ZAxisType : class, IAxisTypeOptions, new() { - private readonly ChartPart openXMLChartPart; + private readonly ChartPart documentChartPart; /// /// Create Area Chart with provided settings /// internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, AreaChartSetting areaChartSetting) : base(worksheet, areaChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); - openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); + documentChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); CreateChart(chartData, dataRange, areaChartSetting); @@ -33,7 +33,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, BarChartSetting barChartSetting) : base(worksheet, barChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); - openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); + documentChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); CreateChart(chartData, dataRange, barChartSetting); @@ -44,7 +44,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ColumnChartSetting columnChartSetting) : base(worksheet, columnChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); - openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); + documentChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); CreateChart(chartData, dataRange, columnChartSetting); @@ -55,7 +55,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, LineChartSetting lineChartSetting) : base(worksheet, lineChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); - openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); + documentChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); CreateChart(chartData, dataRange, lineChartSetting); @@ -66,7 +66,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, PieChartSetting pieChartSetting) : base(worksheet, pieChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); - openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); + documentChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); CreateChart(chartData, dataRange, pieChartSetting); @@ -77,7 +77,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ScatterChartSetting scatterChartSetting) : base(worksheet, scatterChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); - openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); + documentChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); CreateChart(chartData, dataRange, scatterChartSetting); @@ -88,7 +88,7 @@ internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange internal Chart(Worksheet worksheet, ChartData[][] chartData, DataRange dataRange, ComboChartSetting comboChartSetting) : base(worksheet, comboChartSetting) { string chartId = worksheet.GetNextDrawingPartRelationId(); - openXMLChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); + documentChartPart = worksheet.GetDrawingsPart().AddNewPart(chartId); InitializeChartParts(); ConnectDrawingToChart(worksheet, chartId); CreateChart(chartData, dataRange, comboChartSetting); @@ -181,15 +181,15 @@ private void SaveChanges(ChartBase chart) } private ChartColorStylePart GetChartColorStylePart() { - return openXMLChartPart.ChartColorStyleParts.FirstOrDefault(); + return documentChartPart.ChartColorStyleParts.FirstOrDefault(); } private ChartPart GetChartPart() { - return openXMLChartPart; + return documentChartPart; } private ChartStylePart GetChartStylePart() { - return openXMLChartPart.ChartStyleParts.FirstOrDefault(); + return documentChartPart.ChartStyleParts.FirstOrDefault(); } private void InitializeChartParts() { diff --git a/Spreadsheet/Components/2007/TextBox.cs b/Spreadsheet/Components/2007/TextBox.cs index f35872cf..7f9fc9b1 100644 --- a/Spreadsheet/Components/2007/TextBox.cs +++ b/Spreadsheet/Components/2007/TextBox.cs @@ -11,7 +11,7 @@ namespace OpenXMLOffice.Spreadsheet_2007 public class TextBox : SpreadSheetCommonProperties { private readonly TextBoxSetting textBoxSetting; - private readonly XDR.Shape openXMLShape; + private readonly XDR.Shape documentShape; private readonly Worksheet worksheet; /// /// Create Text box with provided settings @@ -33,7 +33,7 @@ public TextBox(Worksheet Worksheet, TextBoxSetting TextBoxSetting) /// internal XDR.Shape GetTextBoxShape() { - return openXMLShape; + return documentShape; } } } diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index 3c01db7b..a6ce87a7 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -18,7 +18,7 @@ namespace OpenXMLOffice.Spreadsheet_2007 public class Worksheet : Drawing { private readonly Excel excel; - private readonly X.Worksheet openXMLworksheet; + private readonly X.Worksheet documentWorksheet; private readonly X.Sheet sheet; /// /// Initializes a new instance of the class. @@ -26,7 +26,7 @@ public class Worksheet : Drawing internal Worksheet(Excel excel, X.Worksheet worksheet, X.Sheet _sheet) { this.excel = excel; - openXMLworksheet = worksheet; + documentWorksheet = worksheet; sheet = _sheet; } /// @@ -92,11 +92,11 @@ public void SetColumn(int col, ColumnProperties columnProperties) { throw new ArgumentOutOfRangeException("Column Property starts from 1"); } - X.Columns columns = openXMLworksheet.GetFirstChild(); + X.Columns columns = documentWorksheet.GetFirstChild(); if (columns == null) { columns = new X.Columns(); - openXMLworksheet.InsertBefore(columns, openXMLworksheet.GetFirstChild()); + documentWorksheet.InsertBefore(columns, documentWorksheet.GetFirstChild()); } X.Column existingColumn = columns.Elements().FirstOrDefault(c => c.Max.Value == col && c.Min.Value == col); if (existingColumn != null) @@ -246,7 +246,7 @@ public void SetRow(string cellId, DataCell[] dataCells, RowProperties rowPropert } } } - openXMLworksheet.Save(); + documentWorksheet.Save(); } /// /// @@ -357,7 +357,7 @@ public bool SetMergeCell(MergeCellRange mergeCellRange) if (mergeCells == null) { mergeCells = new X.MergeCells(); - openXMLworksheet.Append(mergeCells); + documentWorksheet.Append(mergeCells); } if (mergeCells != null && mergeCells.Count > 0) { @@ -421,25 +421,25 @@ public List GetMergeCellList() } internal X.Worksheet GetWorksheet() { - return openXMLworksheet; + return documentWorksheet; } internal X.SheetData GetWorkSheetData() { - X.SheetData SheetData = openXMLworksheet.Elements().FirstOrDefault(); + X.SheetData SheetData = documentWorksheet.Elements().FirstOrDefault(); if (SheetData == null) { - return openXMLworksheet.AppendChild(new X.SheetData()); + return documentWorksheet.AppendChild(new X.SheetData()); } return SheetData; } internal X.Hyperlinks GetWorkSheetHyperlinks() { - X.Hyperlinks hyperlinks = openXMLworksheet.Elements().FirstOrDefault(); + X.Hyperlinks hyperlinks = documentWorksheet.Elements().FirstOrDefault(); return hyperlinks; } internal X.MergeCells GetWorkSheetMergeCell() { - X.MergeCells mergeCells = openXMLworksheet.Elements().FirstOrDefault(); + X.MergeCells mergeCells = documentWorksheet.Elements().FirstOrDefault(); return mergeCells; } internal void AddHyperlink(string relationshipId, string toolTip) @@ -448,7 +448,7 @@ internal void AddHyperlink(string relationshipId, string toolTip) } internal void AddHyperlink(string relationshipId, string toolTip, string location) { - X.Hyperlinks hyperlinks = GetWorkSheetHyperlinks() ?? openXMLworksheet.AppendChild(new X.Hyperlinks()); + X.Hyperlinks hyperlinks = GetWorkSheetHyperlinks() ?? documentWorksheet.AppendChild(new X.Hyperlinks()); if (location != null) { hyperlinks.AppendChild(new X.Hyperlink() @@ -469,7 +469,7 @@ internal void AddHyperlink(string relationshipId, string toolTip, string locatio } internal WorksheetPart GetWorksheetPart() { - return openXMLworksheet.WorksheetPart; + return documentWorksheet.WorksheetPart; } internal string GetNextSheetPartRelationId() { diff --git a/Tests/Presentation.cs b/Tests/Presentation.cs index f6e1bb67..ad7b20f1 100644 --- a/Tests/Presentation.cs +++ b/Tests/Presentation.cs @@ -4,6 +4,7 @@ using G = OpenXMLOffice.Global_2007; using OpenXMLOffice.Presentation_2007; using OpenXMLOffice.Global_2016; +using OpenXMLOffice.Global_2007; namespace OpenXMLOffice.Tests { /// @@ -103,7 +104,7 @@ public void Add2007Charts() sheet.SetRow(11, 1, CommonMethod.CreateDataCellPayload()[2], null); excel.SaveAs(chart.GetWorkBookStream()); //3 - var areaChart = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() + Chart areaChart = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() { applicationSpecificSetting = new(), titleOptions = new() @@ -507,6 +508,26 @@ public void AddBlankSlide() Assert.IsTrue(true); } /// + /// Add Shape to Slide + /// + [TestMethod] + public void AddRectangleShape() + { + Slide slide = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK); + RectangleShapeModel rectangleShapeModel = new() + { + applicationSpecificSetting = new() + { + X = 0, + Y = 0, + Height = (int)ConverterUtils.PixelsToEmu(100), + Width = (int)ConverterUtils.PixelsToEmu(100) + } + }; + slide.AddShape(rectangleShapeModel); + Assert.IsTrue(true); + } + /// /// Add Single Chart to the Slide /// [TestMethod] From 6378f919781e449b9ddfcad4e4d63a86f115f226 Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Wed, 19 Jun 2024 04:56:52 +0000 Subject: [PATCH 10/25] reorganizing --- Global/Models/2007/ShapeModel.cs | 15 +++++++++++---- README.md | 2 +- Spreadsheet/Components/2007/Chart.cs | 2 +- Spreadsheet/Components/2007/Picture.cs | 2 +- Tests/Presentation.cs | 15 +++++++-------- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Global/Models/2007/ShapeModel.cs b/Global/Models/2007/ShapeModel.cs index 61225215..8bbb4be2 100644 --- a/Global/Models/2007/ShapeModel.cs +++ b/Global/Models/2007/ShapeModel.cs @@ -116,7 +116,14 @@ public interface IShapeTypeDetailsModel { } /// /// /// - public class NoShape : IShapeTypeDetailsModel { } + public class NoShape : IShapeTypeDetailsModel + where ApplicationSpecificSetting : class, ISizeAndPosition, new() + { + /// + /// + /// + public ApplicationSpecificSetting applicationSpecificSetting = new ApplicationSpecificSetting(); + } /// /// /// @@ -148,11 +155,11 @@ public class RectangleShapeModel /// /// - public ShapeRectangleTypes rectangleType = ShapeRectangleTypes.RECTANGLE; + public TextOptions text = null; /// /// /// - public TextOptions text = null; + public ShapeRectangleTypes rectangleType = ShapeRectangleTypes.RECTANGLE; /// /// /// @@ -165,7 +172,7 @@ public class RectangleShapeModel public FillColorOption fillColorOption = new FillColorOption(); - } + } /// /// /// diff --git a/README.md b/README.md index 5f98ee33..6b0aba63 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ It's important to note that OpenXML-Office supports the creation of documents th - **Easy Creation of Office Documents**: Create and manipulate Excel, Word, and PowerPoint files with ease. - **[OpenXML SDK 3.0](https://github.com/dotnet/Open-XML-SDK)**: Built on the robust foundation of the OpenXML SDK. - **Modular Architecture**: Dedicated modules for each Office application for better manageability. -- **[.Net Support Version](https://www.nuget.org/packages/OpenXMLOffice.Presentation/2.7.0-Alpha.28#supportedframeworks-body-tab)** : This package support application package starting from .Net 4.5 +- **[.Net Support Version](https://www.nuget.org/packages/OpenXMLOffice.Presentation/#supportedframeworks-body-tab)** : This package support application package starting from .Net 4.5 - **Office Support Version** : Our package ensures compatibility with Office 2007 and later versions for document creation. New features introduced post 2007 will be segregated into respective namespace years. ## Documentation [Link](https://openxml-office.draviavemal.com/) diff --git a/Spreadsheet/Components/2007/Chart.cs b/Spreadsheet/Components/2007/Chart.cs index 5d3c940f..08ce1920 100644 --- a/Spreadsheet/Components/2007/Chart.cs +++ b/Spreadsheet/Components/2007/Chart.cs @@ -108,7 +108,7 @@ internal string GetNextChartRelationId() private void ConnectDrawingToChart(Worksheet worksheet, string chartId) { // Add anchor to drawing for chart graphics - XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel>() { anchorEditType = AnchorEditType.NONE, from = new AnchorPosition() diff --git a/Spreadsheet/Components/2007/Picture.cs b/Spreadsheet/Components/2007/Picture.cs index a2083efd..e54946fa 100644 --- a/Spreadsheet/Components/2007/Picture.cs +++ b/Spreadsheet/Components/2007/Picture.cs @@ -71,7 +71,7 @@ private void AddImageToDrawing(Stream stream) break; } } - XDR.TwoCellAnchor twoCellAnchor = currentWorksheet.CreateTwoCellAnchor(new TwoCellAnchorModel() + XDR.TwoCellAnchor twoCellAnchor = currentWorksheet.CreateTwoCellAnchor(new TwoCellAnchorModel>() { anchorEditType = AnchorEditType.ONE_CELL, from = excelPictureSetting.from, diff --git a/Tests/Presentation.cs b/Tests/Presentation.cs index ad7b20f1..64d9554b 100644 --- a/Tests/Presentation.cs +++ b/Tests/Presentation.cs @@ -2,9 +2,8 @@ using X = OpenXMLOffice.Spreadsheet_2007; using G = OpenXMLOffice.Global_2007; +using G16 = OpenXMLOffice.Global_2016; using OpenXMLOffice.Presentation_2007; -using OpenXMLOffice.Global_2016; -using OpenXMLOffice.Global_2007; namespace OpenXMLOffice.Tests { /// @@ -104,7 +103,7 @@ public void Add2007Charts() sheet.SetRow(11, 1, CommonMethod.CreateDataCellPayload()[2], null); excel.SaveAs(chart.GetWorkBookStream()); //3 - Chart areaChart = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() + Chart areaChart = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.AreaChartSetting() { applicationSpecificSetting = new(), titleOptions = new() @@ -491,7 +490,7 @@ public void Add2016Charts() dataType = X.CellDataType.NUMBER }; } - powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(data, new WaterfallChartSetting() + powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(data, new G16.WaterfallChartSetting() { applicationSpecificSetting = new(), }); @@ -514,14 +513,14 @@ public void AddBlankSlide() public void AddRectangleShape() { Slide slide = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK); - RectangleShapeModel rectangleShapeModel = new() + G.RectangleShapeModel rectangleShapeModel = new() { applicationSpecificSetting = new() { X = 0, Y = 0, - Height = (int)ConverterUtils.PixelsToEmu(100), - Width = (int)ConverterUtils.PixelsToEmu(100) + Height = (int)G.ConverterUtils.PixelsToEmu(100), + Width = (int)G.ConverterUtils.PixelsToEmu(100) } }; slide.AddShape(rectangleShapeModel); @@ -1020,7 +1019,7 @@ public void OpenExistingPresentationShape() List shapes1 = slide.FindShapeByText("Slide_1_Shape_1").ToList(); List shapes2 = slide.FindShapeByText("Slide_1_Shape_2").ToList(); List shapes3 = slide.FindShapeByText("Test Update").ToList(); - shapes1[0].ReplaceChart(slide.AddChart(data, new WaterfallChartSetting() + shapes1[0].ReplaceChart(slide.AddChart(data, new G16.WaterfallChartSetting() { applicationSpecificSetting = new(), })); From ca260f5189e4c433e230718259fc8222389588e3 Mon Sep 17 00:00:00 2001 From: Dravia Vemal Date: Thu, 20 Jun 2024 02:56:02 +0000 Subject: [PATCH 11/25] Checking Commit --- Presentation/Components/2007/Shape.cs | 12 ++++++------ Presentation/Parts/Slide.cs | 8 +++++--- Spreadsheet/Components/2007/Shape.cs | 9 +++------ Spreadsheet/Parts/Worksheet.cs | 9 ++++++--- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Presentation/Components/2007/Shape.cs b/Presentation/Components/2007/Shape.cs index 0d871396..3d196035 100644 --- a/Presentation/Components/2007/Shape.cs +++ b/Presentation/Components/2007/Shape.cs @@ -35,24 +35,24 @@ internal P.Shape GetDocumentShape() return documentShape; } - internal Shape AddLine(LineShapeModel lineModel) + internal void MakeLine(LineShapeModel lineModel) where LineColorOption : class, IColorOptions, new() { - return this; + } - internal Shape AddRectangle(RectangleShapeModel rectangleModel) + internal void MakeRectangle(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { - return this; + } - internal Shape AddArrow(ArrowShapeModel arrowModel) + internal void MakeArrow(ArrowShapeModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() { - return this; + } /// diff --git a/Presentation/Parts/Slide.cs b/Presentation/Parts/Slide.cs index f49c0a45..591f2996 100644 --- a/Presentation/Parts/Slide.cs +++ b/Presentation/Parts/Slide.cs @@ -188,7 +188,8 @@ public Shape AddShape(LineShapeModel /// Insert Shape into slide @@ -198,7 +199,7 @@ public Shape AddShape(RectangleShapeModel(ArrowShapeModel /// diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index cbd5853d..2f13fe61 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -29,7 +29,7 @@ public void RemoveShape() twoCellAnchor.Remove(); } - internal Shape MakeLine(LineShapeModel lineModel) + internal void MakeLine(LineShapeModel lineModel) where LineColorOption : class, IColorOptions, new() { twoCellAnchor = worksheet.CreateTwoCellAnchor(new TwoCellAnchorModel>() @@ -57,10 +57,9 @@ internal Shape MakeLine(LineShapeModel(RectangleShapeModel rectangleModel) + internal void MakeRectangle(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() @@ -90,10 +89,9 @@ internal Shape MakeRectangle( { worksheet.GetDrawing().AppendChild(twoCellAnchor); } - return this; } - internal Shape MakeArrow(ArrowShapeModel arrowModel) + internal void MakeArrow(ArrowShapeModel arrowModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() where TextColorOption : class, IColorOptions, new() @@ -123,7 +121,6 @@ internal Shape MakeArrow(Arro { worksheet.GetDrawing().AppendChild(twoCellAnchor); } - return this; } } } \ No newline at end of file diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index a6ce87a7..aedb4114 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -50,7 +50,8 @@ public Shape AddShape(LineShapeModel /// Insert Shape into slide @@ -61,7 +62,8 @@ public Shape AddShape(Rectang where TextColorOption : class, IColorOptions, new() { Shape shape = new Shape(this); - return shape.MakeRectangle(rectangleModel); + shape.MakeRectangle(rectangleModel); + return shape; } /// /// Insert Shape into slide @@ -72,7 +74,8 @@ public Shape AddShape(ArrowSh where TextColorOption : class, IColorOptions, new() { Shape shape = new Shape(this); - return shape.MakeArrow(arrowModel); + shape.MakeArrow(arrowModel); + return shape; } /// /// Sets the properties for a column based on a starting cell ID in a worksheet. From 7a06599c6875d68c3779d342040b00a65c9db176 Mon Sep 17 00:00:00 2001 From: Dravia Vemal Date: Thu, 20 Jun 2024 03:01:18 +0000 Subject: [PATCH 12/25] test commit Signed-off-by: Dravia Vemal --- Spreadsheet/Components/2007/Shape.cs | 2 +- Spreadsheet/Parts/Worksheet.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Spreadsheet/Components/2007/Shape.cs b/Spreadsheet/Components/2007/Shape.cs index 2f13fe61..2d2bfee2 100644 --- a/Spreadsheet/Components/2007/Shape.cs +++ b/Spreadsheet/Components/2007/Shape.cs @@ -58,7 +58,7 @@ internal void MakeLine(LineShapeModel(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() diff --git a/Spreadsheet/Parts/Worksheet.cs b/Spreadsheet/Parts/Worksheet.cs index aedb4114..e1fe7633 100644 --- a/Spreadsheet/Parts/Worksheet.cs +++ b/Spreadsheet/Parts/Worksheet.cs @@ -54,8 +54,13 @@ public Shape AddShape(LineShapeModel - /// Insert Shape into slide + /// Add Rectangle Shape To the Worksheet /// + /// Shape border line Color option + /// Shape Fill Color option + /// Shape Text Color Option + /// Shape model data + /// OpenXML-Office Shape Object that can manipulate additional properties public Shape AddShape(RectangleShapeModel rectangleModel) where LineColorOption : class, IColorOptions, new() where FillColorOption : class, IColorOptions, new() From 22f4b2f75dd1a3b27b7f9f5859f4a8a2d38a279c Mon Sep 17 00:00:00 2001 From: Dravia Vemal Date: Thu, 27 Jun 2024 06:19:16 +0000 Subject: [PATCH 13/25] PR action setup update --- .github/workflows/pr-validation-main.yml | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr-validation-main.yml b/.github/workflows/pr-validation-main.yml index 2501b92a..51f7129e 100644 --- a/.github/workflows/pr-validation-main.yml +++ b/.github/workflows/pr-validation-main.yml @@ -8,22 +8,7 @@ on: branches: - main jobs: - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup .NET 7 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: "7.0" - - name: Test Runner - working-directory: Tests - run: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=../TestResults/cobertura.xml - - name: Publish Coverage - working-directory: TestResults - run: export CODACY_PROJECT_TOKEN=${{secrets.CODACY_PROJECT_TOKEN}} && bash <(curl -Ls https://coverage.codacy.com/get.sh) build: - needs: coverage runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -37,3 +22,15 @@ jobs: run: dotnet build --no-restore -c Release - name: Pack Project DLL run: dotnet pack -c Release -o nupkgs + coverage: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET 7 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "7.0" + - name: Test Runner + working-directory: Tests + run: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=../TestResults/cobertura.xml From 6ac4fdec5fe4dde0e044e887b5e4270215357613 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Mon, 24 Jun 2024 19:51:24 +0530 Subject: [PATCH 14/25] - feat: Pie Chart Data Labels Formatting - feat: Dynamic X,Y,Z Axis Line Color for Charts - feat: Table Cell Border Color ( Needs Review) --- Global/Components/Charts/2007/ChartBase.cs | 19 ++- .../Components/Charts/2013/ChartAdvanced.cs | 4 + Global/Models/2007/ChartBaseModel.cs | 4 + Global/Utils/Validation.cs | 2 +- Presentation/Components/2007/Table.cs | 73 +++++++---- Tests/Presentation.cs | 122 ++++++++++++++++-- 6 files changed, 187 insertions(+), 37 deletions(-) diff --git a/Global/Components/Charts/2007/ChartBase.cs b/Global/Components/Charts/2007/ChartBase.cs index 940414e7..8fc4d542 100644 --- a/Global/Components/Charts/2007/ChartBase.cs +++ b/Global/Components/Charts/2007/ChartBase.cs @@ -334,7 +334,24 @@ internal OpenXmlElement CreateAxis(AxisSetting.GetLabelAxesPosition(axisSetting.axisOptions.chartAxesOptions.axesLabelPosition) }); - axis.Append(CreateChartShapeProperties()); + if(axisSetting.axisOptions.axisLineColor != null) + { + axis.Append(new List { CreateChartShapeProperties(new ShapePropertiesModel() + { + lineColor = new OutlineModel() + { + lineColor = new ColorOptionModel() + { + colorOption = new SolidOptions() + { + hexColor = axisSetting.axisOptions.axisLineColor + } + } + } + }) }); + } else { + axis.Append(new List { CreateChartShapeProperties() }); + } ColorOptionModel textColorOption = new ColorOptionModel() { colorOption = new SolidOptions() diff --git a/Global/Components/Charts/2013/ChartAdvanced.cs b/Global/Components/Charts/2013/ChartAdvanced.cs index f458da9c..59fcb970 100644 --- a/Global/Components/Charts/2013/ChartAdvanced.cs +++ b/Global/Components/Charts/2013/ChartAdvanced.cs @@ -34,6 +34,10 @@ internal C.DataLabels CreateDataLabels(ChartDataLabel chartDataLabel, int? dataL } C.ExtensionList extensionList = new C.ExtensionList(extension); C.DataLabels dataLabels = new C.DataLabels(); + if (chartDataLabel.formatCode != null) + { + dataLabels.InsertAt(new C.NumberingFormat { FormatCode = chartDataLabel.formatCode, SourceLinked = true }, 0); + } if (chartSetting.chartDataSetting.advancedDataLabel.showValueFromColumn) { for (int i = 0; i < dataLabelCount; i++) diff --git a/Global/Models/2007/ChartBaseModel.cs b/Global/Models/2007/ChartBaseModel.cs index 24929f59..f15130a9 100644 --- a/Global/Models/2007/ChartBaseModel.cs +++ b/Global/Models/2007/ChartBaseModel.cs @@ -293,6 +293,10 @@ public class ChartAxisTitle : ChartTextOptions { } /// public bool isAxesVisible = true; /// + /// axis line color for the chart + /// + public string axisLineColor; + /// /// Option for Axis's Axes label options /// public ChartAxesLabel chartAxesOptions = new ChartAxesLabel(); diff --git a/Global/Utils/Validation.cs b/Global/Utils/Validation.cs index 1007290f..eb0b64b2 100644 --- a/Global/Utils/Validation.cs +++ b/Global/Utils/Validation.cs @@ -13,7 +13,7 @@ public static class Validation /// public static bool IsWithinRange(int x, int y, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - return x >= topLeftX && x <= bottomRightX && y >= topLeftY && y <= bottomRightY; + return x > topLeftX && x < bottomRightX && y > topLeftY && y < bottomRightY; } } } diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index fcabfc02..331deb7a 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -7,6 +7,7 @@ using A = DocumentFormat.OpenXml.Drawing; using G = OpenXMLOffice.Global_2007; using P = DocumentFormat.OpenXml.Presentation; +using A16 = DocumentFormat.OpenXml.Office2016.Drawing; namespace OpenXMLOffice.Presentation_2007 { /// @@ -155,14 +156,14 @@ private A.TableGrid CreateTableGrid(int ColumnCount) { for (int i = 0; i < ColumnCount; i++) { - TableGrid.Append(new A.GridColumn() { Width = tableSetting.width / ColumnCount }); + TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = tableSetting.width / ColumnCount }); } } else { - for (int i = 0; i < ColumnCount; i++) + for (int i = 0; i <= ColumnCount; i++) { - TableGrid.Append(new A.GridColumn() { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); + TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); } } return TableGrid; @@ -250,6 +251,7 @@ private A.TableRow CreateTableRow(TableRow row, int rowIndex, int columnSize) { TableRow.Append(CreateTableCell(new TableCell(), row, rowIndex, columnIndex)); } + TableRow.Append(new A.ExtensionList(new A.Extension( new A16.RowIdIdentifier() { Val = (UInt32) (10000 + rowIndex) }) {Uri = "{0D108BD9-81ED-4DB2-BD59-A6C34878D82A}" })); return TableRow; } @@ -374,11 +376,16 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, hexColor = cell.borderSettings.leftBorder.borderColor } }), - new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.leftBorder.dashStyle) } + new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.leftBorder.dashStyle) }, + new A.Round() { }, + new A.HeadEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }, + new A.TailEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium } ) { Width = (DocumentFormat.OpenXml.Int32Value)G.ConverterUtils.PixelsToEmu((int)cell.borderSettings.leftBorder.width), - CompoundLineType = GetBorderStyleValue(cell.borderSettings.leftBorder.borderStyle) + CompoundLineType = GetBorderStyleValue(cell.borderSettings.leftBorder.borderStyle), + CapType = A.LineCapValues.Flat, + Alignment = A.PenAlignmentValues.Center }); } else @@ -388,19 +395,24 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, if (cell.borderSettings.rightBorder.showBorder) { tableCellProperties.Append(new A.RightBorderLineProperties( - CreateColorComponent(new G.ColorOptionModel() - { - colorOption = new G.SolidOptions() - { - hexColor = cell.borderSettings.rightBorder.borderColor - } - }), - new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.rightBorder.dashStyle) } + CreateColorComponent(new G.ColorOptionModel() + { + colorOption = new G.SolidOptions() + { + hexColor = cell.borderSettings.rightBorder.borderColor + } + }), + new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.rightBorder.dashStyle) }, + new A.Round() { }, + new A.HeadEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }, + new A.TailEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium } ) { Width = (DocumentFormat.OpenXml.Int32Value)G.ConverterUtils.PixelsToEmu((int)cell.borderSettings.rightBorder.width), - CompoundLineType = GetBorderStyleValue(cell.borderSettings.rightBorder.borderStyle) - }); + CompoundLineType = GetBorderStyleValue(cell.borderSettings.rightBorder.borderStyle), + CapType = A.LineCapValues.Flat, + Alignment = A.PenAlignmentValues.Center + }); // Convert to array before calling Append } else { @@ -416,11 +428,16 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, hexColor = cell.borderSettings.topBorder.borderColor } }), - new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.topBorder.dashStyle) } + new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.topBorder.dashStyle) }, + new A.Round() { }, + new A.HeadEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }, + new A.TailEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium } ) { Width = (DocumentFormat.OpenXml.Int32Value)G.ConverterUtils.PixelsToEmu((int)cell.borderSettings.topBorder.width), - CompoundLineType = GetBorderStyleValue(cell.borderSettings.topBorder.borderStyle) + CompoundLineType = GetBorderStyleValue(cell.borderSettings.topBorder.borderStyle), + CapType = A.LineCapValues.Flat, + Alignment = A.PenAlignmentValues.Center }); } else @@ -437,11 +454,16 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, hexColor = cell.borderSettings.bottomBorder.borderColor } }), - new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.bottomBorder.dashStyle) } + new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.bottomBorder.dashStyle) }, + new A.Round() { }, + new A.HeadEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }, + new A.TailEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium } ) { Width = (DocumentFormat.OpenXml.Int32Value)G.ConverterUtils.PixelsToEmu((int)cell.borderSettings.bottomBorder.width), - CompoundLineType = GetBorderStyleValue(cell.borderSettings.bottomBorder.borderStyle) + CompoundLineType = GetBorderStyleValue(cell.borderSettings.bottomBorder.borderStyle), + CapType = A.LineCapValues.Flat, + Alignment = A.PenAlignmentValues.Center }); } else @@ -458,11 +480,16 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, hexColor = cell.borderSettings.topLeftToBottomRightBorder.borderColor } }), - new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.topLeftToBottomRightBorder.dashStyle) } + new A.PresetDash() { Val = GetDashStyleValue(cell.borderSettings.topLeftToBottomRightBorder.dashStyle) }, + new A.Round() { }, + new A.HeadEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium }, + new A.TailEnd() { Type = A.LineEndValues.None, Width = A.LineEndWidthValues.Medium, Length = A.LineEndLengthValues.Medium } ) { Width = (DocumentFormat.OpenXml.Int32Value)G.ConverterUtils.PixelsToEmu((int)cell.borderSettings.topLeftToBottomRightBorder.width), - CompoundLineType = GetBorderStyleValue(cell.borderSettings.topLeftToBottomRightBorder.borderStyle) + CompoundLineType = GetBorderStyleValue(cell.borderSettings.topLeftToBottomRightBorder.borderStyle), + CapType = A.LineCapValues.Flat, + Alignment = A.PenAlignmentValues.Center }); } else @@ -483,7 +510,9 @@ private A.TableCell CreateTableCell(TableCell cell, TableRow row, int rowIndex, ) { Width = (DocumentFormat.OpenXml.Int32Value)G.ConverterUtils.PixelsToEmu((int)cell.borderSettings.bottomLeftToTopRightBorder.width), - CompoundLineType = GetBorderStyleValue(cell.borderSettings.bottomLeftToTopRightBorder.borderStyle) + CompoundLineType = GetBorderStyleValue(cell.borderSettings.bottomLeftToTopRightBorder.borderStyle), + CapType = A.LineCapValues.Flat, + Alignment = A.PenAlignmentValues.Center }); } else diff --git a/Tests/Presentation.cs b/Tests/Presentation.cs index 64d9554b..267c1a26 100644 --- a/Tests/Presentation.cs +++ b/Tests/Presentation.cs @@ -124,7 +124,8 @@ public void Add2007Charts() { textValue = "Value ax", TextAngle = -90, - } + }, + axisLineColor = "FF0000" }, } }); @@ -506,6 +507,24 @@ public void AddBlankSlide() powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK); Assert.IsTrue(true); } + [TestMethod] + [TestCategory("Chart")] + public void AddColumChartAxesLine(){ + powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.ColumnChartSetting() + { + applicationSpecificSetting = new(), + columnChartType = G.ColumnChartTypes.CLUSTERED, + chartAxisOptions = new() { + xAxisOptions = new() { + axisLineColor = "FF0000", + }, + yAxisOptions = new() { + axisLineColor = "00FF00", + } + } + }); + Assert.IsTrue(true); + } /// /// Add Shape to Slide /// @@ -777,6 +796,67 @@ public void AddPicture() public void RemoveSlideByIndex() { powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK); + powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK); + powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.BarChartSetting() + { + chartAxisOptions = new() + { + xAxisOptions = new() + { + chartAxesOptions = new() + { + inReverseOrder = true, + TextAngle = 20 + }, + chartAxisTitle = new() + { + textValue = "cat axis", + TextAngle = -20 + } + }, + yAxisOptions = new() + { + chartAxesOptions = new() + { + inReverseOrder = true, + TextAngle = 20 + }, + chartAxisTitle = new() + { + textValue = "val axis", + TextAngle = -20 + } + } + }, + applicationSpecificSetting = new(), + titleOptions = new() + { + isItalic = true, + textValue = "Bar Chart" + }, + barChartType = G.BarChartTypes.STACKED, + barChartDataLabel = new() + { + dataLabelPosition = G.BarChartDataLabel.DataLabelPositionValues.INSIDE_END, + showValue = true + }, + chartDataSetting = new() + { + advancedDataLabel = new Global_2013.AdvancedDataLabel() + { + showValueFromColumn = true, + valueFromColumn = new() + { + [3] = 1 + } + } + } + }); + powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK).AddChart(CommonMethod.CreateDataCellPayload(), new G.ColumnChartSetting() + { + applicationSpecificSetting = new(), + columnChartType = G.ColumnChartTypes.CLUSTERED + }); int totalCount = powerPoint.GetSlideCount(); powerPoint.RemoveSlideByIndex(totalCount - 1); } @@ -1140,6 +1220,7 @@ public void OpenExistingPresentationNonEdit() Assert.IsTrue(true); } + // Create a table row payload with multiple rows and columns for testing with each row contains three rowspan and column contains three colspan private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCount = 5) { TableRow[] data = new TableRow[rowCount]; @@ -1148,18 +1229,20 @@ private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCoun List tableCells = new(); for (int j = 0; j < columnCount; j++) { - tableCells.Add(new() - { - textValue = $"Row {i + 1}, Column {j + 1}", - textColor = "FF0000", - fontSize = 25 / (j + 1), - rowSpan = (uint)((i == 0 && j == 0) ? 3 : 0), - columnSpan = (uint)(i == 5 && j == 2 ? 3 : 0), - borderSettings = new() + uint colSpanVal = 0; + if(i == 5 && j == 0){ + colSpanVal = 2; + } else if (i == 5 && j == 2){ + colSpanVal = 3; + } + TableBorderSettings borderColorSetting = new(){}; + if (i == 3 && j == 3) { + borderColorSetting = new() { leftBorder = new() { - showBorder = false + showBorder = true, + borderColor = "FF0000", }, topBorder = new() { @@ -1169,13 +1252,26 @@ private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCoun }, rightBorder = new() { - showBorder = false + showBorder = true, + borderColor = "FF0000", }, bottomBorder = new() { - showBorder = true + showBorder = true, + borderColor = "FF0000" } - }, + }; + } + + + tableCells.Add(new() + { + textValue = $"Row {i + 1}, Column {j + 1}", + textColor = "FF0000", + fontSize = 25 / (j + 1), + rowSpan = (uint)((i == 0 && j == 0) ? 3 : 0), + columnSpan = colSpanVal, + borderSettings = borderColorSetting, horizontalAlignment = G.HorizontalAlignmentValues.LEFT + (i % 4) }); } From af3a8fcc6e536278f9abc07ab1d2c3cd10bc6094 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Tue, 25 Jun 2024 17:56:28 +0530 Subject: [PATCH 15/25] - Feat: Added Smooth Line option for line chart --- Global/Components/Charts/2007/LineChart.cs | 1 + Global/Models/2007/LineChartModel.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Global/Components/Charts/2007/LineChart.cs b/Global/Components/Charts/2007/LineChart.cs index 1170e1f2..41aaa350 100644 --- a/Global/Components/Charts/2007/LineChart.cs +++ b/Global/Components/Charts/2007/LineChart.cs @@ -161,6 +161,7 @@ private C.LineChartSeries CreateLineChartSeries(int seriesIndex, ChartDataGroupi C.LineChartSeries series = new C.LineChartSeries( new C.Index { Val = new UInt32Value((uint)chartDataGrouping.id) }, new C.Order { Val = new UInt32Value((uint)chartDataGrouping.id) }, + new C.Smooth { Val = lineChartLineFormat.smoothLine ?? false }, CreateSeriesText(chartDataGrouping.seriesHeaderFormula, new[] { chartDataGrouping.seriesHeaderCells })); series.Append(CreateChartShapeProperties(shapePropertiesModel)); if (new[] { LineChartTypes.CLUSTERED_MARKER, LineChartTypes.STACKED_MARKER, LineChartTypes.PERCENT_STACKED_MARKER }.Contains(lineChartSetting.lineChartType)) diff --git a/Global/Models/2007/LineChartModel.cs b/Global/Models/2007/LineChartModel.cs index 757ef1a4..1b814822 100644 --- a/Global/Models/2007/LineChartModel.cs +++ b/Global/Models/2007/LineChartModel.cs @@ -153,6 +153,10 @@ public class LineChartLineFormat /// /// public LineWidthValues? lineEndWidth; + /// + /// Smooth Line for the Line Chart + /// + public bool? smoothLine = false; } /// /// From 025e03e96787a8c58b657807490efb1021d21d32 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Wed, 26 Jun 2024 15:44:11 +0530 Subject: [PATCH 16/25] fix: Test case enhancement --- Global/Components/Charts/2007/LineChart.cs | 2 +- Presentation/Components/2007/Table.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Global/Components/Charts/2007/LineChart.cs b/Global/Components/Charts/2007/LineChart.cs index 41aaa350..923d33d9 100644 --- a/Global/Components/Charts/2007/LineChart.cs +++ b/Global/Components/Charts/2007/LineChart.cs @@ -161,7 +161,7 @@ private C.LineChartSeries CreateLineChartSeries(int seriesIndex, ChartDataGroupi C.LineChartSeries series = new C.LineChartSeries( new C.Index { Val = new UInt32Value((uint)chartDataGrouping.id) }, new C.Order { Val = new UInt32Value((uint)chartDataGrouping.id) }, - new C.Smooth { Val = lineChartLineFormat.smoothLine ?? false }, + new C.Smooth { Val = lineChartLineFormat != null && lineChartLineFormat.smoothLine != null ? lineChartLineFormat.smoothLine : false }, CreateSeriesText(chartDataGrouping.seriesHeaderFormula, new[] { chartDataGrouping.seriesHeaderCells })); series.Append(CreateChartShapeProperties(shapePropertiesModel)); if (new[] { LineChartTypes.CLUSTERED_MARKER, LineChartTypes.STACKED_MARKER, LineChartTypes.PERCENT_STACKED_MARKER }.Contains(lineChartSetting.lineChartType)) diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index 331deb7a..90897c0f 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -161,7 +161,7 @@ private A.TableGrid CreateTableGrid(int ColumnCount) } else { - for (int i = 0; i <= ColumnCount; i++) + for (int i = 0; i < ColumnCount; i++) { TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); } From c26c7be4d9b22877c654c6e3c372e1008e59d765 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Wed, 26 Jun 2024 19:16:12 +0530 Subject: [PATCH 17/25] fix: Powerpoint table generation fix --- Global/Utils/Validation.cs | 2 +- Presentation/Components/2007/Table.cs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Global/Utils/Validation.cs b/Global/Utils/Validation.cs index eb0b64b2..1007290f 100644 --- a/Global/Utils/Validation.cs +++ b/Global/Utils/Validation.cs @@ -13,7 +13,7 @@ public static class Validation /// public static bool IsWithinRange(int x, int y, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - return x > topLeftX && x < bottomRightX && y > topLeftY && y < bottomRightY; + return x >= topLeftX && x <= bottomRightX && y >= topLeftY && y <= bottomRightY; } } } diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index 90897c0f..0f7e7d0f 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -170,17 +170,17 @@ private A.TableGrid CreateTableGrid(int ColumnCount) } private void AddMergeRange(int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - if (mergeRanges.Any( - range => - G.Validation.IsWithinRange(topLeftX, topLeftY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY) || - G.Validation.IsWithinRange(bottomRightX, bottomRightY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY))) - { - MergeRange errorRange = mergeRanges.Find( - range => - G.Validation.IsWithinRange(topLeftX, topLeftY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY) || - G.Validation.IsWithinRange(bottomRightX, bottomRightY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY)); - throw new ArgumentException(string.Format("Table Merge Range Conflict: Found Overlap Range X:{0} Y:{1} cX:{2} cY:{3}", errorRange.topLeftX, errorRange.topLeftY, errorRange.bottomRightX, errorRange.bottomRightY)); - } + // if (mergeRanges.Any( + // range => + // G.Validation.IsWithinRange(topLeftX, topLeftY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY) || + // G.Validation.IsWithinRange(bottomRightX, bottomRightY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY))) + // { + // MergeRange errorRange = mergeRanges.Find( + // range => + // G.Validation.IsWithinRange(topLeftX, topLeftY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY) || + // G.Validation.IsWithinRange(bottomRightX, bottomRightY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY)); + // throw new ArgumentException(string.Format("Table Merge Range Conflict: Found Overlap Range X:{0} Y:{1} cX:{2} cY:{3}", errorRange.topLeftX, errorRange.topLeftY, errorRange.bottomRightX, errorRange.bottomRightY)); + // } mergeRanges.Add(new MergeRange() { topLeftX = topLeftX, From cb3fb8b49b3443f222073933441652873b9dd597 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Mon, 24 Jun 2024 19:51:24 +0530 Subject: [PATCH 18/25] - feat: Pie Chart Data Labels Formatting - feat: Dynamic X,Y,Z Axis Line Color for Charts - feat: Table Cell Border Color ( Needs Review) --- Global/Utils/Validation.cs | 2 +- Presentation/Components/2007/Table.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Global/Utils/Validation.cs b/Global/Utils/Validation.cs index 1007290f..eb0b64b2 100644 --- a/Global/Utils/Validation.cs +++ b/Global/Utils/Validation.cs @@ -13,7 +13,7 @@ public static class Validation /// public static bool IsWithinRange(int x, int y, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - return x >= topLeftX && x <= bottomRightX && y >= topLeftY && y <= bottomRightY; + return x > topLeftX && x < bottomRightX && y > topLeftY && y < bottomRightY; } } } diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index 0f7e7d0f..3929168f 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -161,7 +161,7 @@ private A.TableGrid CreateTableGrid(int ColumnCount) } else { - for (int i = 0; i < ColumnCount; i++) + for (int i = 0; i <= ColumnCount; i++) { TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); } From 63501782cc6109f58421d939cb01d285472ce017 Mon Sep 17 00:00:00 2001 From: Dravia Vemal Date: Thu, 27 Jun 2024 06:28:57 +0000 Subject: [PATCH 19/25] bug fix --- Global/Components/Charts/2007/ChartBase.cs | 2 +- Global/Utils/Validation.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Global/Components/Charts/2007/ChartBase.cs b/Global/Components/Charts/2007/ChartBase.cs index 8fc4d542..427d7250 100644 --- a/Global/Components/Charts/2007/ChartBase.cs +++ b/Global/Components/Charts/2007/ChartBase.cs @@ -336,7 +336,7 @@ internal OpenXmlElement CreateAxis(AxisSetting.GetLabelAxesPosition(axisSetting.axisOptions.chartAxesOptions.axesLabelPosition) }); if(axisSetting.axisOptions.axisLineColor != null) { - axis.Append(new List { CreateChartShapeProperties(new ShapePropertiesModel() + axis.Append(new List { CreateChartShapeProperties(new ShapePropertiesModel() { lineColor = new OutlineModel() { diff --git a/Global/Utils/Validation.cs b/Global/Utils/Validation.cs index eb0b64b2..1007290f 100644 --- a/Global/Utils/Validation.cs +++ b/Global/Utils/Validation.cs @@ -13,7 +13,7 @@ public static class Validation /// public static bool IsWithinRange(int x, int y, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - return x > topLeftX && x < bottomRightX && y > topLeftY && y < bottomRightY; + return x >= topLeftX && x <= bottomRightX && y >= topLeftY && y <= bottomRightY; } } } From 0b3ff27868ef9bb605e140d63fb928627d18b798 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Thu, 27 Jun 2024 13:35:52 +0530 Subject: [PATCH 20/25] fix: Added Overlapping auto merger condition resolve --- Presentation/Components/2007/Table.cs | 66 ++++++++++++++++++--------- Tests/Presentation.cs | 16 +++++-- 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index 3929168f..73f8c27d 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -8,6 +8,7 @@ using G = OpenXMLOffice.Global_2007; using P = DocumentFormat.OpenXml.Presentation; using A16 = DocumentFormat.OpenXml.Office2016.Drawing; +using OpenXMLOffice.Global_2007; namespace OpenXMLOffice.Presentation_2007 { /// @@ -156,38 +157,61 @@ private A.TableGrid CreateTableGrid(int ColumnCount) { for (int i = 0; i < ColumnCount; i++) { - TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = tableSetting.width / ColumnCount }); + TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension(new A16.ColIdIdentifier() { Val = (UInt32)(20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = tableSetting.width / ColumnCount }); } } else { for (int i = 0; i <= ColumnCount; i++) { - TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); + TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension(new A16.ColIdIdentifier() { Val = (UInt32)(20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); } } return TableGrid; } private void AddMergeRange(int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - // if (mergeRanges.Any( - // range => - // G.Validation.IsWithinRange(topLeftX, topLeftY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY) || - // G.Validation.IsWithinRange(bottomRightX, bottomRightY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY))) - // { - // MergeRange errorRange = mergeRanges.Find( - // range => - // G.Validation.IsWithinRange(topLeftX, topLeftY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY) || - // G.Validation.IsWithinRange(bottomRightX, bottomRightY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY)); - // throw new ArgumentException(string.Format("Table Merge Range Conflict: Found Overlap Range X:{0} Y:{1} cX:{2} cY:{3}", errorRange.topLeftX, errorRange.topLeftY, errorRange.bottomRightX, errorRange.bottomRightY)); - // } - mergeRanges.Add(new MergeRange() - { - topLeftX = topLeftX, - topLeftY = topLeftY, - bottomRightX = bottomRightX, - bottomRightY = bottomRightY, - }); + var overlappingRanges = mergeRanges.Where(range => + G.Validation.IsWithinRange(topLeftX, topLeftY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY) || + G.Validation.IsWithinRange(bottomRightX, bottomRightY, range.topLeftX, range.topLeftY, range.bottomRightX, range.bottomRightY)).ToList(); + + if (overlappingRanges.Any()) + { + LogUtils.ShowWarning(string.Format("Warning: Table Merge Range Conflict: Found Overlap Range X:{0} Y:{1} cX:{2} cY:{3}", topLeftX, topLeftY, bottomRightX, bottomRightY)); + LogUtils.ShowWarning("Rewriting the merge range"); + // Merge the new range with the overlapping ranges + int newTopLeftX = Math.Min(topLeftX, overlappingRanges.Min(range => range.topLeftX)); + int newTopLeftY = Math.Min(topLeftY, overlappingRanges.Min(range => range.topLeftY)); + int newBottomRightX = Math.Max(bottomRightX, overlappingRanges.Max(range => range.bottomRightX)); + int newBottomRightY = Math.Max(bottomRightY, overlappingRanges.Max(range => range.bottomRightY)); + + LogUtils.ShowWarning(string.Format("Warning: Table Merge Range Conflict: Updating New Range X:{0} Y:{1} cX:{2} cY:{3}", newTopLeftX, newTopLeftY, newBottomRightX, newBottomRightY)); + // Remove the overlapping ranges from the list + foreach (var range in overlappingRanges) + { + mergeRanges.Remove(range); + } + + // Adding the merged range to the list + mergeRanges.Add(new MergeRange() + { + topLeftX = newTopLeftX, + topLeftY = newTopLeftY, + bottomRightX = newBottomRightX, + bottomRightY = newBottomRightY + }); + } + else + { + // If there's no overlap, add the new range as is + mergeRanges.Add(new MergeRange() + { + topLeftX = topLeftX, + topLeftY = topLeftY, + bottomRightX = bottomRightX, + bottomRightY = bottomRightY + }); + } } private bool CheckIsColumnMerged(int col, int row) { @@ -251,7 +275,7 @@ private A.TableRow CreateTableRow(TableRow row, int rowIndex, int columnSize) { TableRow.Append(CreateTableCell(new TableCell(), row, rowIndex, columnIndex)); } - TableRow.Append(new A.ExtensionList(new A.Extension( new A16.RowIdIdentifier() { Val = (UInt32) (10000 + rowIndex) }) {Uri = "{0D108BD9-81ED-4DB2-BD59-A6C34878D82A}" })); + TableRow.Append(new A.ExtensionList(new A.Extension(new A16.RowIdIdentifier() { Val = (UInt32)(10000 + rowIndex) }) { Uri = "{0D108BD9-81ED-4DB2-BD59-A6C34878D82A}" })); return TableRow; } diff --git a/Tests/Presentation.cs b/Tests/Presentation.cs index 70a6f4a1..579d28b1 100644 --- a/Tests/Presentation.cs +++ b/Tests/Presentation.cs @@ -942,7 +942,7 @@ public void AddTable() { name = "New Table", widthType = TableSetting.WidthOptionValues.PERCENTAGE, - tableColumnWidth = new() { 40, 30, 15, 10, 5 }, + tableColumnWidth = new() { 10, 10, 10, 10, 10, 10, 10, 10 }, x = (uint)G.ConverterUtils.PixelsToEmu(10), y = (uint)G.ConverterUtils.PixelsToEmu(10), }); @@ -1047,7 +1047,7 @@ public void OpenExistingPresentationShapeEdit() { name = "New Table", widthType = TableSetting.WidthOptionValues.PERCENTAGE, - tableColumnWidth = new() { 40, 30, 15, 10, 5 }, + tableColumnWidth = new() { 10, 10, 10, 10, 10, 10, 10, 10 }, })); shapes2[0].ReplacePicture(slide.AddPicture("./TestFiles/tom_and_jerry.jpg", new G.PictureSetting() { @@ -1221,7 +1221,7 @@ public void OpenExistingPresentationNonEdit() } // Create a table row payload with multiple rows and columns for testing with each row contains three rowspan and column contains three colspan - private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCount = 5) + private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCount = 8) { TableRow[] data = new TableRow[rowCount]; for (int i = 0; i < rowCount; i++) @@ -1234,6 +1234,14 @@ private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCoun colSpanVal = 2; } else if (i == 5 && j == 2){ colSpanVal = 3; + } else if (i == 5 && j == 5){ + colSpanVal = 3; + } + uint rowSpanVal = 0; + if(i == 6 && j == 0){ + rowSpanVal = 2; + } else if (i == 6 && j == 2){ + rowSpanVal = 2; } TableBorderSettings borderColorSetting = new(){}; if (i == 3 && j == 3) { @@ -1268,7 +1276,7 @@ private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCoun { textValue = $"Row {i + 1}, Column {j + 1}", textColor = "FF0000", - fontSize = 25 / (j + 1), + fontSize = 12, rowSpan = (uint)((i == 0 && j == 0) ? 3 : 0), columnSpan = colSpanVal, borderSettings = borderColorSetting, From e4d92b6ed1da3bdfa025b8987c03d38686132a71 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Thu, 27 Jun 2024 14:45:38 +0530 Subject: [PATCH 21/25] fix: Test case update --- Tests/Presentation.cs | 54 +++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/Tests/Presentation.cs b/Tests/Presentation.cs index 579d28b1..2e6e1597 100644 --- a/Tests/Presentation.cs +++ b/Tests/Presentation.cs @@ -1230,60 +1230,74 @@ private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCoun for (int j = 0; j < columnCount; j++) { uint colSpanVal = 0; - if(i == 5 && j == 0){ - colSpanVal = 2; - } else if (i == 5 && j == 2){ - colSpanVal = 3; - } else if (i == 5 && j == 5){ - colSpanVal = 3; - } uint rowSpanVal = 0; - if(i == 6 && j == 0){ + TableBorderSettings borderColorSetting = new(); + + if (i == 5) + { + if (j == 0) + { + colSpanVal = 2; + } + else if (j == 2) + { + colSpanVal = 3; + } + else if (j == 5) + { + colSpanVal = 3; + } + } + + if (i == 0 && j == 0) + { rowSpanVal = 2; - } else if (i == 6 && j == 2){ + } + else if (i == 6 && j == 2) + { rowSpanVal = 2; } - TableBorderSettings borderColorSetting = new(){}; - if (i == 3 && j == 3) { - borderColorSetting = new() + + if (i == 3 && j == 3) + { + borderColorSetting = new TableBorderSettings { - leftBorder = new() + leftBorder = new () { showBorder = true, borderColor = "FF0000", }, - topBorder = new() + topBorder = new () { showBorder = true, borderColor = "FF0000", width = 2 }, - rightBorder = new() + rightBorder = new () { showBorder = true, borderColor = "FF0000", }, - bottomBorder = new() + bottomBorder = new () { showBorder = true, borderColor = "FF0000" } }; } - - tableCells.Add(new() + tableCells.Add(new TableCell { textValue = $"Row {i + 1}, Column {j + 1}", textColor = "FF0000", fontSize = 12, - rowSpan = (uint)((i == 0 && j == 0) ? 3 : 0), + rowSpan = rowSpanVal, columnSpan = colSpanVal, borderSettings = borderColorSetting, horizontalAlignment = G.HorizontalAlignmentValues.LEFT + (i % 4) }); } - TableRow row = new() + TableRow row = new TableRow { height = 370840, tableCells = tableCells From 60f2918399790c4528ca152a004524492339a7b9 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Mon, 24 Jun 2024 19:51:24 +0530 Subject: [PATCH 22/25] - feat: Pie Chart Data Labels Formatting - feat: Dynamic X,Y,Z Axis Line Color for Charts - feat: Table Cell Border Color ( Needs Review) --- Global/Utils/Validation.cs | 2 +- Presentation/Components/2007/Table.cs | 13 ++++++------- Tests/Presentation.cs | 7 ++++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Global/Utils/Validation.cs b/Global/Utils/Validation.cs index 1007290f..eb0b64b2 100644 --- a/Global/Utils/Validation.cs +++ b/Global/Utils/Validation.cs @@ -13,7 +13,7 @@ public static class Validation /// public static bool IsWithinRange(int x, int y, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - return x >= topLeftX && x <= bottomRightX && y >= topLeftY && y <= bottomRightY; + return x > topLeftX && x < bottomRightX && y > topLeftY && y < bottomRightY; } } } diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index 73f8c27d..0486e969 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -8,7 +8,6 @@ using G = OpenXMLOffice.Global_2007; using P = DocumentFormat.OpenXml.Presentation; using A16 = DocumentFormat.OpenXml.Office2016.Drawing; -using OpenXMLOffice.Global_2007; namespace OpenXMLOffice.Presentation_2007 { /// @@ -157,14 +156,14 @@ private A.TableGrid CreateTableGrid(int ColumnCount) { for (int i = 0; i < ColumnCount; i++) { - TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension(new A16.ColIdIdentifier() { Val = (UInt32)(20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = tableSetting.width / ColumnCount }); + TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = tableSetting.width / ColumnCount }); } } else { for (int i = 0; i <= ColumnCount; i++) { - TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension(new A16.ColIdIdentifier() { Val = (UInt32)(20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); + TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); } } return TableGrid; @@ -177,15 +176,15 @@ private void AddMergeRange(int topLeftX, int topLeftY, int bottomRightX, int bot if (overlappingRanges.Any()) { - LogUtils.ShowWarning(string.Format("Warning: Table Merge Range Conflict: Found Overlap Range X:{0} Y:{1} cX:{2} cY:{3}", topLeftX, topLeftY, bottomRightX, bottomRightY)); - LogUtils.ShowWarning("Rewriting the merge range"); + G.LogUtils.ShowWarning(string.Format("Warning: Table Merge Range Conflict: Found Overlap Range X:{0} Y:{1} cX:{2} cY:{3}", topLeftX, topLeftY, bottomRightX, bottomRightY)); + G.LogUtils.ShowWarning("Rewriting the merge range"); // Merge the new range with the overlapping ranges int newTopLeftX = Math.Min(topLeftX, overlappingRanges.Min(range => range.topLeftX)); int newTopLeftY = Math.Min(topLeftY, overlappingRanges.Min(range => range.topLeftY)); int newBottomRightX = Math.Max(bottomRightX, overlappingRanges.Max(range => range.bottomRightX)); int newBottomRightY = Math.Max(bottomRightY, overlappingRanges.Max(range => range.bottomRightY)); - LogUtils.ShowWarning(string.Format("Warning: Table Merge Range Conflict: Updating New Range X:{0} Y:{1} cX:{2} cY:{3}", newTopLeftX, newTopLeftY, newBottomRightX, newBottomRightY)); + G.LogUtils.ShowWarning(string.Format("Warning: Table Merge Range Conflict: Updating New Range X:{0} Y:{1} cX:{2} cY:{3}", newTopLeftX, newTopLeftY, newBottomRightX, newBottomRightY)); // Remove the overlapping ranges from the list foreach (var range in overlappingRanges) { @@ -275,7 +274,7 @@ private A.TableRow CreateTableRow(TableRow row, int rowIndex, int columnSize) { TableRow.Append(CreateTableCell(new TableCell(), row, rowIndex, columnIndex)); } - TableRow.Append(new A.ExtensionList(new A.Extension(new A16.RowIdIdentifier() { Val = (UInt32)(10000 + rowIndex) }) { Uri = "{0D108BD9-81ED-4DB2-BD59-A6C34878D82A}" })); + TableRow.Append(new A.ExtensionList(new A.Extension( new A16.RowIdIdentifier() { Val = (UInt32) (10000 + rowIndex) }) {Uri = "{0D108BD9-81ED-4DB2-BD59-A6C34878D82A}" })); return TableRow; } diff --git a/Tests/Presentation.cs b/Tests/Presentation.cs index 2e6e1597..a84ea18b 100644 --- a/Tests/Presentation.cs +++ b/Tests/Presentation.cs @@ -1285,13 +1285,14 @@ private static TableRow[] CreateTableRowPayload(int rowCount = 5, int columnCoun } }; } + - tableCells.Add(new TableCell + tableCells.Add(new() { textValue = $"Row {i + 1}, Column {j + 1}", textColor = "FF0000", - fontSize = 12, - rowSpan = rowSpanVal, + fontSize = 25 / (j + 1), + rowSpan = (uint)((i == 0 && j == 0) ? 3 : 0), columnSpan = colSpanVal, borderSettings = borderColorSetting, horizontalAlignment = G.HorizontalAlignmentValues.LEFT + (i % 4) From 5adcfa576163f440fb7181975ad69a475cc68804 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Wed, 26 Jun 2024 15:44:11 +0530 Subject: [PATCH 23/25] fix: Test case enhancement --- Presentation/Components/2007/Table.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Presentation/Components/2007/Table.cs b/Presentation/Components/2007/Table.cs index 0486e969..e7237c6d 100644 --- a/Presentation/Components/2007/Table.cs +++ b/Presentation/Components/2007/Table.cs @@ -161,7 +161,7 @@ private A.TableGrid CreateTableGrid(int ColumnCount) } else { - for (int i = 0; i <= ColumnCount; i++) + for (int i = 0; i < ColumnCount; i++) { TableGrid.Append(new A.GridColumn(new A.ExtensionList(new A.Extension( new A16.ColIdIdentifier() { Val = (UInt32) (20000 + i) }) { Uri = "{9D8B030D-6E8A-4147-A177-3AD203B41FA5}" })) { Width = CalculateColumnWidth(tableSetting.widthType, tableSetting.tableColumnWidth[i]) }); } From 22d89ed92b288811b01ccf9494af4f1eb7577b15 Mon Sep 17 00:00:00 2001 From: "Prashanth.S" Date: Wed, 26 Jun 2024 19:16:12 +0530 Subject: [PATCH 24/25] fix: Powerpoint table generation fix --- Global/Utils/Validation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Global/Utils/Validation.cs b/Global/Utils/Validation.cs index eb0b64b2..1007290f 100644 --- a/Global/Utils/Validation.cs +++ b/Global/Utils/Validation.cs @@ -13,7 +13,7 @@ public static class Validation /// public static bool IsWithinRange(int x, int y, int topLeftX, int topLeftY, int bottomRightX, int bottomRightY) { - return x > topLeftX && x < bottomRightX && y > topLeftY && y < bottomRightY; + return x >= topLeftX && x <= bottomRightX && y >= topLeftY && y <= bottomRightY; } } } From caae9c5cc50df4a652ced841a0bfbeb2ba037d77 Mon Sep 17 00:00:00 2001 From: Dravia Vemal Date: Thu, 27 Jun 2024 11:18:14 +0000 Subject: [PATCH 25/25] Simple commit to check rules --- Presentation/Components/2007/PresentationCommonProperties.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Presentation/Components/2007/PresentationCommonProperties.cs b/Presentation/Components/2007/PresentationCommonProperties.cs index a0c60fb5..b69d16c1 100644 --- a/Presentation/Components/2007/PresentationCommonProperties.cs +++ b/Presentation/Components/2007/PresentationCommonProperties.cs @@ -11,7 +11,7 @@ namespace OpenXMLOffice.Global_2007 public class PresentationCommonProperties : CommonProperties { /// - /// + /// Create Shape /// protected P.Shape CreateShape(ShapeModel shapeModel) where TextColorOption : class, IColorOptions, new()