diff --git a/js/pptx/smoke/api_master/add_layout.js b/js/pptx/smoke/api_master/add_layout.js new file mode 100644 index 00000000..bff6043a --- /dev/null +++ b/js/pptx/smoke/api_master/add_layout.js @@ -0,0 +1,21 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); +oSlide.RemoveAllObjects(); + +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +var nCountBefore = oMaster.GetLayoutsCount(); +var oLayout = Api.CreateLayout(); +oMaster.AddLayout(0, oLayout); +var nCountAfter = oMaster.GetLayoutsCount(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Layouts before: ' + nCountBefore + ', after: ' + nCountAfter); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "AddLayout.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/add_object.js b/js/pptx/smoke/api_master/add_object.js new file mode 100644 index 00000000..6e9979b4 --- /dev/null +++ b/js/pptx/smoke/api_master/add_object.js @@ -0,0 +1,24 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); +oSlide.RemoveAllObjects(); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); + +var nCountBefore = oMaster.GetAllShapes().length; +var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61)); +var oStroke = Api.CreateStroke(0, Api.CreateNoFill()); +var oShape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, oFill, oStroke); +oShape.SetPosition(608400, 1267200); +oShape.SetSize(300 * 36000, 130 * 36000); +oMaster.AddObject(oShape); +var nCountAfter = oMaster.GetAllShapes().length; + +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +var oRun = Api.CreateRun(); +oRun.AddText('before: ' + nCountBefore + ', after: ' + nCountAfter); +oParagraph.AddElement(oRun); +builder.SaveFile("pptx", "AddObject.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/clear_background.js b/js/pptx/smoke/api_master/clear_background.js new file mode 100644 index 00000000..664b0e5f --- /dev/null +++ b/js/pptx/smoke/api_master/clear_background.js @@ -0,0 +1,12 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +var oMaster = oPresentation.GetMaster(0); +var oRGBColor = Api.CreateRGBColor(255, 213, 191); +var oGs1 = Api.CreateGradientStop(oRGBColor, 0); +var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000); +var oFill = Api.CreateRadialGradientFill([oGs1, oGs2]); +oMaster.SetBackground(oFill); +oMaster.ClearBackground(); +builder.SaveFile("pptx", "ClearBackground.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/copy.js b/js/pptx/smoke/api_master/copy.js new file mode 100644 index 00000000..f3ee0bf4 --- /dev/null +++ b/js/pptx/smoke/api_master/copy.js @@ -0,0 +1,19 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster = oPresentation.GetMaster(0); + +var nCountBefore = oPresentation.GetMastersCount(); +var oCopyMaster = oMaster.Copy(); +oPresentation.AddMaster(1, oCopyMaster); +var nCountAfter = oPresentation.GetMastersCount(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Masters before: ' + nCountBefore + ', after: ' + nCountAfter); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "Copy.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/delete.js b/js/pptx/smoke/api_master/delete.js new file mode 100644 index 00000000..7afe5159 --- /dev/null +++ b/js/pptx/smoke/api_master/delete.js @@ -0,0 +1,20 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster1 = oPresentation.GetMaster(0); + +var oMaster2 = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster2); +var nCountBefore = oPresentation.GetMastersCount(); +oMaster2.Delete(); +var nCountAfter = oPresentation.GetMastersCount(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Masters before: ' + nCountBefore + ', after: ' + nCountAfter); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "Delete.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/duplicate.js b/js/pptx/smoke/api_master/duplicate.js new file mode 100644 index 00000000..0bd946ab --- /dev/null +++ b/js/pptx/smoke/api_master/duplicate.js @@ -0,0 +1,18 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster = oPresentation.GetMaster(0); + +var nCountBefore = oPresentation.GetMastersCount(); +oMaster.Duplicate(1); +var nCountAfter = oPresentation.GetMastersCount(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Masters before: ' + nCountBefore + ', after: ' + nCountAfter); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "Duplicate.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_all_charts.js b/js/pptx/smoke/api_master/get_all_charts.js new file mode 100644 index 00000000..3c9ab796 --- /dev/null +++ b/js/pptx/smoke/api_master/get_all_charts.js @@ -0,0 +1,30 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); +oSlide.RemoveAllObjects(); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); + +var oChart = Api.CreateChart("bar3D", [ + [200, 240, 280], + [250, 260, 280] +], ["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016], 4051300, 2347595, 24); +oChart.SetVerAxisTitle("USD In Hundred Thousands", 10); +oChart.SetHorAxisTitle("Year", 11); +oChart.SetLegendPos("bottom"); +oChart.SetShowDataLabels(false, false, true, false); +oChart.SetTitle("Financial Overview", 13); +oChart.SetSize(300 * 36000, 130 * 36000); +oChart.SetPosition(608400, 1267200); +oMaster.AddObject(oChart); +var aCharts = oMaster.GetAllCharts(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Charts count: ' + aCharts.length + ', type: ' + aCharts[0].GetClassType()); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetAllCharts.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_all_drawings.js b/js/pptx/smoke/api_master/get_all_drawings.js new file mode 100644 index 00000000..11cfdf27 --- /dev/null +++ b/js/pptx/smoke/api_master/get_all_drawings.js @@ -0,0 +1,30 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); +oSlide.RemoveAllObjects(); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); + +var oImage = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000); +oMaster.AddObject(oImage); +var oOleObject = Api.CreateOleObject("https://i.ytimg.com/vi_webp/SKGz4pmnpgY/sddefault.webp", 130 * 36000, 90 * 36000, "https://youtu.be/SKGz4pmnpgY", "asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}"); +oOleObject.SetSize(200 * 36000, 130 * 36000); +oOleObject.SetPosition(70 * 36000, 30 * 36000); +oMaster.AddObject(oOleObject); +var aDrawings = oMaster.GetAllDrawings(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Drawings count: ' + aDrawings.length); +oParagraph.AddLineBreak(); +var aDrawingsTypes = [] +for (var i=0; i