From b6f077efce1dc4c808e5c2228d91d9de70601ccb Mon Sep 17 00:00:00 2001 From: lemonowl Date: Sat, 10 Aug 2024 13:33:31 +0300 Subject: [PATCH 1/6] new tests --- js/pptx/smoke/api_master/add_layout.js | 22 ++++ js/pptx/smoke/api_master/add_object.js | 25 +++++ js/pptx/smoke/api_master/copy.js | 19 ++++ js/pptx/smoke/api_master/delete.js | 19 ++++ js/pptx/smoke/api_master/duplicate.js | 18 +++ js/pptx/smoke/api_master/get_all_charts.js | 31 ++++++ js/pptx/smoke/api_master/get_all_drawings.js | 25 +++++ js/pptx/smoke/api_master/get_all_images.js | 21 ++++ .../smoke/api_master/get_all_ole_objects.js | 23 ++++ js/pptx/smoke/api_master/get_all_shapes.js | 25 +++++ js/pptx/smoke/api_master/get_class_type.js | 15 +++ spec/pptx/smoke/api_master_spec.rb | 105 ++++++++++++++++++ 12 files changed, 348 insertions(+) create mode 100644 js/pptx/smoke/api_master/add_layout.js create mode 100644 js/pptx/smoke/api_master/add_object.js create mode 100644 js/pptx/smoke/api_master/copy.js create mode 100644 js/pptx/smoke/api_master/delete.js create mode 100644 js/pptx/smoke/api_master/duplicate.js create mode 100644 js/pptx/smoke/api_master/get_all_charts.js create mode 100644 js/pptx/smoke/api_master/get_all_drawings.js create mode 100644 js/pptx/smoke/api_master/get_all_images.js create mode 100644 js/pptx/smoke/api_master/get_all_ole_objects.js create mode 100644 js/pptx/smoke/api_master/get_all_shapes.js create mode 100644 js/pptx/smoke/api_master/get_class_type.js create mode 100644 spec/pptx/smoke/api_master_spec.rb 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..c4a79848 --- /dev/null +++ b/js/pptx/smoke/api_master/add_layout.js @@ -0,0 +1,22 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); + +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); +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(); \ No newline at end of file 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..8478fbd4 --- /dev/null +++ b/js/pptx/smoke/api_master/add_object.js @@ -0,0 +1,25 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +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(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/copy.js b/js/pptx/smoke/api_master/copy.js new file mode 100644 index 00000000..44a9348c --- /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(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/delete.js b/js/pptx/smoke/api_master/delete.js new file mode 100644 index 00000000..e3474870 --- /dev/null +++ b/js/pptx/smoke/api_master/delete.js @@ -0,0 +1,19 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); + +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +var nCountBefore = oPresentation.GetMastersCount(); +oMaster.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(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/duplicate.js b/js/pptx/smoke/api_master/duplicate.js new file mode 100644 index 00000000..53c31114 --- /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(); \ No newline at end of file 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..9affaee0 --- /dev/null +++ b/js/pptx/smoke/api_master/get_all_charts.js @@ -0,0 +1,31 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +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(); \ No newline at end of file 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..6c32da63 --- /dev/null +++ b/js/pptx/smoke/api_master/get_all_drawings.js @@ -0,0 +1,25 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61)); +var oStroke = Api.CreateStroke(0, Api.CreateNoFill()); +var oDrawing = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, oFill, oStroke); +oDrawing.SetPosition(608400, 1267200); +oDrawing.SetSize(300 * 36000, 130 * 36000); +oMaster.AddObject(oDrawing); +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 + ', type: ' + aDrawings[0].GetClassType()); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetAllDrawings.pptx"); +builder.CloseFile(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/get_all_images.js b/js/pptx/smoke/api_master/get_all_images.js new file mode 100644 index 00000000..9fa28477 --- /dev/null +++ b/js/pptx/smoke/api_master/get_all_images.js @@ -0,0 +1,21 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +var oImage = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000); +oMaster.AddObject(oImage); +var aImages = oMaster.GetAllImages(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Images count: ' + aImages.length + ', type: ' + aImages[0].GetClassType()); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetAllImages.pptx"); +builder.CloseFile(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/get_all_ole_objects.js b/js/pptx/smoke/api_master/get_all_ole_objects.js new file mode 100644 index 00000000..a60d37f1 --- /dev/null +++ b/js/pptx/smoke/api_master/get_all_ole_objects.js @@ -0,0 +1,23 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +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 aOleObjects = oMaster.GetAllOleObjects(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('OleObjects count: ' + aOleObjects.length + ', type: ' + aOleObjects[0].GetClassType()); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetAllOleObjects.pptx"); +builder.CloseFile(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/get_all_shapes.js b/js/pptx/smoke/api_master/get_all_shapes.js new file mode 100644 index 00000000..687cf08d --- /dev/null +++ b/js/pptx/smoke/api_master/get_all_shapes.js @@ -0,0 +1,25 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +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 aShapes = oMaster.GetAllShapes(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Shapes count: ' + aShapes.length + ', type: ' + aShapes[0].GetClassType()); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetAllShapes.pptx"); +builder.CloseFile(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/get_class_type.js b/js/pptx/smoke/api_master/get_class_type.js new file mode 100644 index 00000000..f85fb678 --- /dev/null +++ b/js/pptx/smoke/api_master/get_class_type.js @@ -0,0 +1,15 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster = oPresentation.GetMaster(0); +var sType = oMaster.GetClassType(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Type: ' + sType); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetClassType.pptx"); +builder.CloseFile(); diff --git a/spec/pptx/smoke/api_master_spec.rb b/spec/pptx/smoke/api_master_spec.rb new file mode 100644 index 00000000..4a67aabc --- /dev/null +++ b/spec/pptx/smoke/api_master_spec.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true + +require 'spec_helper' +describe 'ApiMaster section tests' do + it 'ApiMaster | AddLayout method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/add_layout.js') + expect(pptx.slide_masters.size).to eq(1) + expect(pptx.slide_layouts.size).to eq(1) + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Layouts before: 0, after: 1') + end + + # it 'ApiMaster | AddObject method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/add_object.js') + # expect('').to eq('') + # end + + # it 'ApiMaster | ClearBackground method' do + # expect('').to eq('') + # end + + it 'ApiMaster | Copy method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/copy.js') + expect(pptx.slide_masters.size).to eq(2) + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Masters before: 1, after: 2') + end + + it 'ApiMaster | Delete method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/delete.js') + expect(pptx.slide_masters.size).to eq(1) + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Masters before: 2, after: 1') + end + + it 'ApiMaster | Duplicate method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/duplicate.js') + expect(pptx.slide_masters.size).to eq(2) + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Masters before: 1, after: 2') + end + + # it 'ApiMaster | GetAllCharts method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_charts.js') + # expect('').to eq('') + # end + + # it 'ApiMaster | GetAllDrawings method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_drawings.js') + # expect('').to eq('') + # end + + # it 'ApiMaster | GetAllImages method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_images.js') + # expect('').to eq('') + # end + + # it 'ApiMaster | GetAllOleObjects method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_ole_objects.js') + # expect('').to eq('') + # end + + # it 'ApiMaster | GetAllShapes method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_shapes.js') + # expect('').to eq('') + # end + + it 'ApiMaster | GetClassType method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_class_type.js') + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Type: master') + end + + # it 'ApiMaster | GetLayout method' do + # expect('').to eq('') + # end + + # it 'ApiMaster | GetLayoutsCount method' do + # expect('').to eq('') + # end + + # it 'ApiMaster | GetTheme method' do + # expect('').to eq('') + # end + + # it 'ApiMaster | RemoveLayout method' do + # expect('').to eq('') + # end + + # it 'ApiMaster | RemoveObject method' do + # expect('').to eq('') + # end + + # it 'ApiMaster | SetBackground method' do + # expect('').to eq('') + # end + + # it 'ApiMaster | SetTheme method' do + # expect('').to eq('') + # end + + # it 'ApiMaster | ToJSON method' do + # expect('').to eq('') + # end +end \ No newline at end of file From f2d55661188b46ddda71e28fe9229c8427a343c7 Mon Sep 17 00:00:00 2001 From: lemonowl Date: Mon, 12 Aug 2024 17:53:56 +0300 Subject: [PATCH 2/6] new tests --- js/pptx/smoke/api_master/add_layout.js | 2 +- js/pptx/smoke/api_master/add_object.js | 2 +- js/pptx/smoke/api_master/clear_background.js | 12 +++++ js/pptx/smoke/api_master/copy.js | 2 +- js/pptx/smoke/api_master/delete.js | 2 +- js/pptx/smoke/api_master/duplicate.js | 2 +- js/pptx/smoke/api_master/get_all_charts.js | 2 +- js/pptx/smoke/api_master/get_all_drawings.js | 2 +- js/pptx/smoke/api_master/get_all_images.js | 2 +- .../smoke/api_master/get_all_ole_objects.js | 2 +- js/pptx/smoke/api_master/get_all_shapes.js | 2 +- js/pptx/smoke/api_master/get_layout.js | 28 +++++++++++ js/pptx/smoke/api_master/get_layouts_count.js | 21 ++++++++ js/pptx/smoke/api_master/get_theme.js | 15 ++++++ js/pptx/smoke/api_master/remove_layout.js | 18 +++++++ js/pptx/smoke/api_master/remove_object.js | 29 +++++++++++ js/pptx/smoke/api_master/set_background.js | 11 ++++ spec/pptx/smoke/api_master_spec.rb | 50 +++++++++++++------ 18 files changed, 178 insertions(+), 26 deletions(-) create mode 100644 js/pptx/smoke/api_master/clear_background.js create mode 100644 js/pptx/smoke/api_master/get_layout.js create mode 100644 js/pptx/smoke/api_master/get_layouts_count.js create mode 100644 js/pptx/smoke/api_master/get_theme.js create mode 100644 js/pptx/smoke/api_master/remove_layout.js create mode 100644 js/pptx/smoke/api_master/remove_object.js create mode 100644 js/pptx/smoke/api_master/set_background.js diff --git a/js/pptx/smoke/api_master/add_layout.js b/js/pptx/smoke/api_master/add_layout.js index c4a79848..9574ac01 100644 --- a/js/pptx/smoke/api_master/add_layout.js +++ b/js/pptx/smoke/api_master/add_layout.js @@ -19,4 +19,4 @@ oParagraph.AddText('Layouts before: ' + nCountBefore + ', after: ' + nCountAfter oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "AddLayout.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/add_object.js b/js/pptx/smoke/api_master/add_object.js index 8478fbd4..2c6dd844 100644 --- a/js/pptx/smoke/api_master/add_object.js +++ b/js/pptx/smoke/api_master/add_object.js @@ -22,4 +22,4 @@ var oRun = Api.CreateRun(); oRun.AddText('before: ' + nCountBefore + ', after: ' + nCountAfter); oParagraph.AddElement(oRun); builder.SaveFile("pptx", "AddObject.pptx"); -builder.CloseFile(); \ No newline at end of file +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..b921f6fc --- /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(); \ No newline at end of file diff --git a/js/pptx/smoke/api_master/copy.js b/js/pptx/smoke/api_master/copy.js index 44a9348c..f3ee0bf4 100644 --- a/js/pptx/smoke/api_master/copy.js +++ b/js/pptx/smoke/api_master/copy.js @@ -16,4 +16,4 @@ oParagraph.AddText('Masters before: ' + nCountBefore + ', after: ' + nCountAfter oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "Copy.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/delete.js b/js/pptx/smoke/api_master/delete.js index e3474870..5014f964 100644 --- a/js/pptx/smoke/api_master/delete.js +++ b/js/pptx/smoke/api_master/delete.js @@ -16,4 +16,4 @@ oParagraph.AddText('Masters before: ' + nCountBefore + ', after: ' + nCountAfter oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "Delete.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/duplicate.js b/js/pptx/smoke/api_master/duplicate.js index 53c31114..0bd946ab 100644 --- a/js/pptx/smoke/api_master/duplicate.js +++ b/js/pptx/smoke/api_master/duplicate.js @@ -15,4 +15,4 @@ oParagraph.AddText('Masters before: ' + nCountBefore + ', after: ' + nCountAfter oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "Duplicate.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_all_charts.js b/js/pptx/smoke/api_master/get_all_charts.js index 9affaee0..d457bbd2 100644 --- a/js/pptx/smoke/api_master/get_all_charts.js +++ b/js/pptx/smoke/api_master/get_all_charts.js @@ -28,4 +28,4 @@ oParagraph.AddText('Charts count: ' + aCharts.length + ', type: ' + aCharts[0].G oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "GetAllCharts.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_all_drawings.js b/js/pptx/smoke/api_master/get_all_drawings.js index 6c32da63..f1f06df9 100644 --- a/js/pptx/smoke/api_master/get_all_drawings.js +++ b/js/pptx/smoke/api_master/get_all_drawings.js @@ -22,4 +22,4 @@ oParagraph.AddText('Drawings count: ' + aDrawings.length + ', type: ' + aDrawing oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "GetAllDrawings.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_all_images.js b/js/pptx/smoke/api_master/get_all_images.js index 9fa28477..26ce56c6 100644 --- a/js/pptx/smoke/api_master/get_all_images.js +++ b/js/pptx/smoke/api_master/get_all_images.js @@ -18,4 +18,4 @@ oParagraph.AddText('Images count: ' + aImages.length + ', type: ' + aImages[0].G oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "GetAllImages.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_all_ole_objects.js b/js/pptx/smoke/api_master/get_all_ole_objects.js index a60d37f1..238e682d 100644 --- a/js/pptx/smoke/api_master/get_all_ole_objects.js +++ b/js/pptx/smoke/api_master/get_all_ole_objects.js @@ -20,4 +20,4 @@ oParagraph.AddText('OleObjects count: ' + aOleObjects.length + ', type: ' + aOle oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "GetAllOleObjects.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_all_shapes.js b/js/pptx/smoke/api_master/get_all_shapes.js index 687cf08d..94708022 100644 --- a/js/pptx/smoke/api_master/get_all_shapes.js +++ b/js/pptx/smoke/api_master/get_all_shapes.js @@ -22,4 +22,4 @@ oParagraph.AddText('Shapes count: ' + aShapes.length + ', type: ' + aShapes[0].G oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "GetAllShapes.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_layout.js b/js/pptx/smoke/api_master/get_layout.js new file mode 100644 index 00000000..fb66109f --- /dev/null +++ b/js/pptx/smoke/api_master/get_layout.js @@ -0,0 +1,28 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +var oLayout = Api.CreateLayout(); +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); +oLayout.AddObject(oShape); +var oImage = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000); +oLayout.AddObject(oImage); +oMaster.AddLayout(0, oLayout); + +oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Layout shapes: ' + oMaster.GetLayout(0).GetAllDrawings().length); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetLayout.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_layouts_count.js b/js/pptx/smoke/api_master/get_layouts_count.js new file mode 100644 index 00000000..fdb1599b --- /dev/null +++ b/js/pptx/smoke/api_master/get_layouts_count.js @@ -0,0 +1,21 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +var oLayout = Api.CreateLayout(); +oMaster.AddLayout(0, oLayout); +oMaster.AddLayout(1, oLayout); + +oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Layouts count: ' + oMaster.GetLayoutsCount()); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetLayoutsCount.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/get_theme.js b/js/pptx/smoke/api_master/get_theme.js new file mode 100644 index 00000000..6733976e --- /dev/null +++ b/js/pptx/smoke/api_master/get_theme.js @@ -0,0 +1,15 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +var oMaster = oPresentation.GetMaster(0); +oSlide.RemoveAllObjects(); +var oTheme = oMaster.GetTheme(); + +var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Theme type: ' + oTheme.GetClassType()); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "GetTheme.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/remove_layout.js b/js/pptx/smoke/api_master/remove_layout.js new file mode 100644 index 00000000..bd005952 --- /dev/null +++ b/js/pptx/smoke/api_master/remove_layout.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 = oMaster.GetLayoutsCount(); +oMaster.RemoveLayout(3, 7); +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 count before: ' + nCountBefore + ' after: ' + nCountAfter); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "RemoveLayout.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/remove_object.js b/js/pptx/smoke/api_master/remove_object.js new file mode 100644 index 00000000..7b6c6ccb --- /dev/null +++ b/js/pptx/smoke/api_master/remove_object.js @@ -0,0 +1,29 @@ +builder.CreateFile("pptx"); +var oPresentation = Api.GetPresentation(); +var oSlide = oPresentation.GetSlideByIndex(0); +oSlide.RemoveAllObjects(); +var oMaster0 = oPresentation.GetMaster(0); +var oMaster = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster); +oMaster0.Delete(); + +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 oImage = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000); +oMaster.AddObject(oImage); +oMaster.RemoveObject(0, 1); + +var aDrawings = oMaster.GetAllDrawings(); +var aImages = oMaster.GetAllImages(); +oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); +var oDocContent = oShape.GetDocContent(); +var oParagraph = oDocContent.GetElement(0); +oParagraph.AddText('Drawings count: ' + aDrawings.length + ', images count: ' + aImages.length); +oParagraph.SetHighlight("black"); +oSlide.AddObject(oShape); +builder.SaveFile("pptx", "RemoveObject.pptx"); +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/set_background.js b/js/pptx/smoke/api_master/set_background.js new file mode 100644 index 00000000..76f5cd25 --- /dev/null +++ b/js/pptx/smoke/api_master/set_background.js @@ -0,0 +1,11 @@ +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); +builder.SaveFile("pptx", "SetBackground.pptx"); +builder.CloseFile(); \ No newline at end of file diff --git a/spec/pptx/smoke/api_master_spec.rb b/spec/pptx/smoke/api_master_spec.rb index 4a67aabc..25513d69 100644 --- a/spec/pptx/smoke/api_master_spec.rb +++ b/spec/pptx/smoke/api_master_spec.rb @@ -15,9 +15,11 @@ # expect('').to eq('') # end - # it 'ApiMaster | ClearBackground method' do - # expect('').to eq('') - # end + it 'ApiMaster | ClearBackground method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/clear_background.js') + expect(pptx.slide_masters.size).to eq(1) + expect(pptx.slide_masters.first.common_slide_data.background.fill.color).to eq(:none) + end it 'ApiMaster | Copy method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/copy.js') @@ -72,28 +74,44 @@ end # it 'ApiMaster | GetLayout method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_layout.js') # expect('').to eq('') # end - # it 'ApiMaster | GetLayoutsCount method' do - # expect('').to eq('') - # end + it 'ApiMaster | GetLayoutsCount method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_layouts_count.js') + expect(pptx.slide_layouts.size).to eq(2) + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Layouts count: 2') + end - # it 'ApiMaster | GetTheme method' do - # expect('').to eq('') - # end + it 'ApiMaster | GetTheme method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_theme.js') + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Theme type: theme') + end - # it 'ApiMaster | RemoveLayout method' do - # expect('').to eq('') - # end + it 'ApiMaster | RemoveLayout method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/remove_layout.js') + expect(pptx.slide_layouts.size).to eq(4) + slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements + expect(slide_elements.first.text_body.paragraphs.first.runs.first.text).to eq('Layouts count before: 11 after: 4') + end # it 'ApiMaster | RemoveObject method' do + # pptx = builder.build_and_parse('js/pptx/smoke/api_master/remove_object.js') # expect('').to eq('') # end - # it 'ApiMaster | SetBackground method' do - # expect('').to eq('') - # end + it 'ApiMaster | SetBackground method' do + pptx = builder.build_and_parse('js/pptx/smoke/api_master/set_background.js') + expect(pptx.slide_masters.size).to eq(1) + background_color = pptx.slide_masters.first.common_slide_data.background.fill.color + expect(background_color.gradient_stops[0].color).to eq(OoxmlParser::Color.new(255, 213, 191)) + expect(background_color.gradient_stops[0].position).to eq(0) + expect(background_color.gradient_stops[1].color).to eq(OoxmlParser::Color.new(255, 111, 61)) + expect(background_color.gradient_stops[1].position).to eq(100) + end # it 'ApiMaster | SetTheme method' do # expect('').to eq('') @@ -102,4 +120,4 @@ # it 'ApiMaster | ToJSON method' do # expect('').to eq('') # end -end \ No newline at end of file +end From 877daa276efae1d87eec12e667d4b8ebf910c1fc Mon Sep 17 00:00:00 2001 From: lemonowl Date: Tue, 13 Aug 2024 13:35:23 +0300 Subject: [PATCH 3/6] fix tests --- js/pptx/smoke/api_master/add_layout.js | 3 +- js/pptx/smoke/api_master/add_object.js | 3 +- js/pptx/smoke/api_master/delete.js | 7 +- js/pptx/smoke/api_master/get_all_charts.js | 3 +- js/pptx/smoke/api_master/get_all_drawings.js | 23 +-- js/pptx/smoke/api_master/get_all_images.js | 3 +- .../smoke/api_master/get_all_ole_objects.js | 3 +- js/pptx/smoke/api_master/get_all_shapes.js | 3 +- js/pptx/smoke/api_master/get_class_type.js | 2 +- js/pptx/smoke/api_master/get_layout.js | 20 +-- js/pptx/smoke/api_master/get_layouts_count.js | 11 +- js/pptx/smoke/api_master/get_theme.js | 2 +- js/pptx/smoke/api_master/remove_object.js | 13 +- js/pptx/smoke/api_master/set_theme.js | 21 +++ js/pptx/smoke/api_master/to_json.js | 16 +++ spec/pptx/smoke/api_master_spec.rb | 131 ++++++++++++------ 16 files changed, 162 insertions(+), 102 deletions(-) create mode 100644 js/pptx/smoke/api_master/set_theme.js create mode 100644 js/pptx/smoke/api_master/to_json.js diff --git a/js/pptx/smoke/api_master/add_layout.js b/js/pptx/smoke/api_master/add_layout.js index 9574ac01..bff6043a 100644 --- a/js/pptx/smoke/api_master/add_layout.js +++ b/js/pptx/smoke/api_master/add_layout.js @@ -1,12 +1,11 @@ builder.CreateFile("pptx"); var oPresentation = Api.GetPresentation(); var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); oSlide.RemoveAllObjects(); -var oMaster0 = oPresentation.GetMaster(0); var oMaster = Api.CreateMaster(); oPresentation.AddMaster(1, oMaster); -oMaster0.Delete(); var nCountBefore = oMaster.GetLayoutsCount(); var oLayout = Api.CreateLayout(); oMaster.AddLayout(0, oLayout); diff --git a/js/pptx/smoke/api_master/add_object.js b/js/pptx/smoke/api_master/add_object.js index 2c6dd844..6e9979b4 100644 --- a/js/pptx/smoke/api_master/add_object.js +++ b/js/pptx/smoke/api_master/add_object.js @@ -1,11 +1,10 @@ builder.CreateFile("pptx"); var oPresentation = Api.GetPresentation(); var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); oSlide.RemoveAllObjects(); -var oMaster0 = oPresentation.GetMaster(0); var oMaster = Api.CreateMaster(); oPresentation.AddMaster(1, oMaster); -oMaster0.Delete(); var nCountBefore = oMaster.GetAllShapes().length; var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61)); diff --git a/js/pptx/smoke/api_master/delete.js b/js/pptx/smoke/api_master/delete.js index 5014f964..7afe5159 100644 --- a/js/pptx/smoke/api_master/delete.js +++ b/js/pptx/smoke/api_master/delete.js @@ -2,11 +2,12 @@ builder.CreateFile("pptx"); var oPresentation = Api.GetPresentation(); var oSlide = oPresentation.GetSlideByIndex(0); oSlide.RemoveAllObjects(); +var oMaster1 = oPresentation.GetMaster(0); -var oMaster = Api.CreateMaster(); -oPresentation.AddMaster(1, oMaster); +var oMaster2 = Api.CreateMaster(); +oPresentation.AddMaster(1, oMaster2); var nCountBefore = oPresentation.GetMastersCount(); -oMaster.Delete(); +oMaster2.Delete(); var nCountAfter = oPresentation.GetMastersCount(); var oShape = Api.CreateShape("rect", 100 * 36000, 50 * 36000); diff --git a/js/pptx/smoke/api_master/get_all_charts.js b/js/pptx/smoke/api_master/get_all_charts.js index d457bbd2..3c9ab796 100644 --- a/js/pptx/smoke/api_master/get_all_charts.js +++ b/js/pptx/smoke/api_master/get_all_charts.js @@ -1,11 +1,10 @@ builder.CreateFile("pptx"); var oPresentation = Api.GetPresentation(); var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); oSlide.RemoveAllObjects(); -var oMaster0 = oPresentation.GetMaster(0); var oMaster = Api.CreateMaster(); oPresentation.AddMaster(1, oMaster); -oMaster0.Delete(); var oChart = Api.CreateChart("bar3D", [ [200, 240, 280], diff --git a/js/pptx/smoke/api_master/get_all_drawings.js b/js/pptx/smoke/api_master/get_all_drawings.js index f1f06df9..11cfdf27 100644 --- a/js/pptx/smoke/api_master/get_all_drawings.js +++ b/js/pptx/smoke/api_master/get_all_drawings.js @@ -1,24 +1,29 @@ builder.CreateFile("pptx"); var oPresentation = Api.GetPresentation(); var oSlide = oPresentation.GetSlideByIndex(0); +// oPresentation.GetMaster(0).Delete(); oSlide.RemoveAllObjects(); -var oMaster0 = oPresentation.GetMaster(0); var oMaster = Api.CreateMaster(); oPresentation.AddMaster(1, oMaster); -oMaster0.Delete(); -var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61)); -var oStroke = Api.CreateStroke(0, Api.CreateNoFill()); -var oDrawing = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, oFill, oStroke); -oDrawing.SetPosition(608400, 1267200); -oDrawing.SetSize(300 * 36000, 130 * 36000); -oMaster.AddObject(oDrawing); +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 + ', type: ' + aDrawings[0].GetClassType()); +oParagraph.AddText('Drawings count: ' + aDrawings.length); +oParagraph.AddLineBreak(); +var aDrawingsTypes = [] +for (var i=0; i Date: Tue, 13 Aug 2024 16:43:56 +0300 Subject: [PATCH 4/6] fix --- js/pptx/smoke/api_master/clear_background.js | 2 +- js/pptx/smoke/api_master/set_background.js | 2 +- js/pptx/smoke/api_master/set_theme.js | 2 +- js/pptx/smoke/api_master/to_json.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/pptx/smoke/api_master/clear_background.js b/js/pptx/smoke/api_master/clear_background.js index b921f6fc..664b0e5f 100644 --- a/js/pptx/smoke/api_master/clear_background.js +++ b/js/pptx/smoke/api_master/clear_background.js @@ -9,4 +9,4 @@ var oFill = Api.CreateRadialGradientFill([oGs1, oGs2]); oMaster.SetBackground(oFill); oMaster.ClearBackground(); builder.SaveFile("pptx", "ClearBackground.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/set_background.js b/js/pptx/smoke/api_master/set_background.js index 76f5cd25..d34641c5 100644 --- a/js/pptx/smoke/api_master/set_background.js +++ b/js/pptx/smoke/api_master/set_background.js @@ -8,4 +8,4 @@ var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000); var oFill = Api.CreateRadialGradientFill([oGs1, oGs2]); oMaster.SetBackground(oFill); builder.SaveFile("pptx", "SetBackground.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/set_theme.js b/js/pptx/smoke/api_master/set_theme.js index af12a96c..a854a05c 100644 --- a/js/pptx/smoke/api_master/set_theme.js +++ b/js/pptx/smoke/api_master/set_theme.js @@ -18,4 +18,4 @@ oParagraph.AddText('Fonts: ' + oTheme.GetFontScheme().ToJSON()); oParagraph.SetHighlight("black"); oSlide.AddObject(oShape); builder.SaveFile("pptx", "SetTheme.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); diff --git a/js/pptx/smoke/api_master/to_json.js b/js/pptx/smoke/api_master/to_json.js index 8da60a97..3a83c0a4 100644 --- a/js/pptx/smoke/api_master/to_json.js +++ b/js/pptx/smoke/api_master/to_json.js @@ -13,4 +13,4 @@ var oParagraph = oDocContent.GetElement(0); oParagraph.AddText('sType: ' + sType); oSlide.AddObject(oShape); builder.SaveFile("pptx", "ToJSON.pptx"); -builder.CloseFile(); \ No newline at end of file +builder.CloseFile(); From 5b4a1ba3c5d3d0bd2a329c153c39d856e004fa80 Mon Sep 17 00:00:00 2001 From: lemonowl Date: Tue, 13 Aug 2024 17:06:32 +0300 Subject: [PATCH 5/6] fix codestyle --- spec/pptx/smoke/api_master_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/pptx/smoke/api_master_spec.rb b/spec/pptx/smoke/api_master_spec.rb index 472bf354..9741adb4 100644 --- a/spec/pptx/smoke/api_master_spec.rb +++ b/spec/pptx/smoke/api_master_spec.rb @@ -4,7 +4,7 @@ describe 'ApiMaster section tests' do it 'ApiMaster | AddLayout method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/add_layout.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) # expect(pptx.slide_layouts.size).to eq(1) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements @@ -13,7 +13,7 @@ it 'ApiMaster | AddObject method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/add_object.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) shape_element = pptx.slide_masters[1].common_slide_data.shape_tree.elements.first expect(shape_element.class).to eq(OoxmlParser::DocxShape) @@ -35,7 +35,7 @@ it 'ApiMaster | Delete method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/delete.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # заменить удаление второго мастера на первый expect(pptx.slide_masters.size).to eq(1) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements @@ -51,7 +51,7 @@ it 'ApiMaster | GetAllCharts method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_charts.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements.first.class).to eq(OoxmlParser::GraphicFrame) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements @@ -60,7 +60,7 @@ it 'ApiMaster | GetAllDrawings method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_drawings.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements.size).to eq(2) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements[0].class).to eq(OoxmlParser::DocxPicture) @@ -72,7 +72,7 @@ it 'ApiMaster | GetAllImages method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_images.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements.first.class).to eq(OoxmlParser::DocxPicture) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements @@ -81,7 +81,7 @@ it 'ApiMaster | GetAllOleObjects method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_ole_objects.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements.first.class).to eq(OoxmlParser::GraphicFrame) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements @@ -90,7 +90,7 @@ it 'ApiMaster | GetAllShapes method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/get_all_shapes.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements.first.class).to eq(OoxmlParser::DocxShape) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements @@ -131,7 +131,7 @@ it 'ApiMaster | RemoveObject method' do pptx = builder.build_and_parse('js/pptx/smoke/api_master/remove_object.js') - # TODO https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 + # TODO: https://bugzilla.onlyoffice.com/show_bug.cgi?id=69619 # expect(pptx.slide_masters.size).to eq(1) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements.size).to eq(1) expect(pptx.slide_masters[1].common_slide_data.shape_tree.elements.first.class).to eq(OoxmlParser::DocxPicture) From 9587630b40f7f76054e32841d3be86e02d1ddaf1 Mon Sep 17 00:00:00 2001 From: lemonowl Date: Wed, 14 Aug 2024 12:46:00 +0300 Subject: [PATCH 6/6] fix failed tests --- spec/pptx/smoke/api_master_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/pptx/smoke/api_master_spec.rb b/spec/pptx/smoke/api_master_spec.rb index 9741adb4..4f31e653 100644 --- a/spec/pptx/smoke/api_master_spec.rb +++ b/spec/pptx/smoke/api_master_spec.rb @@ -27,6 +27,7 @@ end it 'ApiMaster | Copy method' do + skip('Fixed since v8.1.1') if builder.semver <= Semantic::Version.new('8.1.0') pptx = builder.build_and_parse('js/pptx/smoke/api_master/copy.js') expect(pptx.slide_masters.size).to eq(2) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements @@ -43,6 +44,7 @@ end it 'ApiMaster | Duplicate method' do + skip('Fixed since v8.1.1') if builder.semver <= Semantic::Version.new('8.1.0') pptx = builder.build_and_parse('js/pptx/smoke/api_master/duplicate.js') expect(pptx.slide_masters.size).to eq(2) slide_elements = pptx.slides.first.common_slide_data.shape_tree.elements