Skip to content

Commit c4778b5

Browse files
committed
Autoport ApiExamples 24.10
1 parent b094a6b commit c4778b5

File tree

6 files changed

+167
-10
lines changed

6 files changed

+167
-10
lines changed

Examples/ApiExamples/JavaPorting/ExCharts.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,5 +2323,60 @@ public void tickLabelsOrientationRotation() throws Exception
23232323
doc.save(getArtifactsDir() + "Charts.TickLabelsOrientationRotation.docx");
23242324
//ExEnd:TickLabelsOrientationRotation
23252325
}
2326+
2327+
@Test
2328+
public void doughnutChart() throws Exception
2329+
{
2330+
//ExStart:DoughnutChart
2331+
//GistId:bb594993b5fe48692541e16f4d354ac2
2332+
//ExFor:ChartSeriesGroup.DoughnutHoleSize
2333+
//ExFor:ChartSeriesGroup.FirstSliceAngle
2334+
//ExSummary:Shows how to create and format Doughnut chart.
2335+
Document doc = new Document();
2336+
DocumentBuilder builder = new DocumentBuilder(doc);
2337+
2338+
Shape shape = builder.insertChart(ChartType.DOUGHNUT, 400.0, 400.0);
2339+
Chart chart = shape.getChart();
2340+
// Delete the default generated series.
2341+
chart.getSeries().clear();
2342+
2343+
String[] categories = new String[] { "Category 1", "Category 2", "Category 3" };
2344+
chart.getSeries().add("Series 1", categories, new double[] { 4.0, 2.0, 5.0 });
2345+
2346+
// Format the Doughnut chart.
2347+
ChartSeriesGroup seriesGroup = chart.getSeriesGroups().get(0);
2348+
seriesGroup.setDoughnutHoleSize(10);
2349+
seriesGroup.setFirstSliceAngle(270);
2350+
2351+
doc.save(getArtifactsDir() + "Charts.DoughnutChart.docx");
2352+
//ExEnd:DoughnutChart
2353+
}
2354+
2355+
@Test
2356+
public void pieOfPieChart() throws Exception
2357+
{
2358+
//ExStart:PieOfPieChart
2359+
//GistId:bb594993b5fe48692541e16f4d354ac2
2360+
//ExFor:ChartSeriesGroup.SecondSectionSize
2361+
//ExSummary:Shows how to create and format pie of Pie chart.
2362+
Document doc = new Document();
2363+
DocumentBuilder builder = new DocumentBuilder(doc);
2364+
2365+
Shape shape = builder.insertChart(ChartType.PIE_OF_PIE, 440.0, 300.0);
2366+
Chart chart = shape.getChart();
2367+
// Delete the default generated series.
2368+
chart.getSeries().clear();
2369+
2370+
String[] categories = new String[] { "Category 1", "Category 2", "Category 3", "Category 4" };
2371+
chart.getSeries().add("Series 1", categories, new double[] { 11.0, 8.0, 4.0, 3.0 });
2372+
2373+
// Format the Pie of Pie chart.
2374+
ChartSeriesGroup seriesGroup = chart.getSeriesGroups().get(0);
2375+
seriesGroup.setGapWidth(10);
2376+
seriesGroup.setSecondSectionSize(77);
2377+
2378+
doc.save(getArtifactsDir() + "Charts.PieOfPieChart.docx");
2379+
//ExEnd:PieOfPieChart
2380+
}
23262381
}
23272382

Examples/ApiExamples/JavaPorting/ExHtmlSaveOptions.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,24 +1000,24 @@ public void epubHeadings() throws Exception
10001000
//ExEnd
10011001

10021002
TestUtil.docPackageFileContainsString("<navLabel><text>Heading #1</text></navLabel>",
1003-
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "HtmlSaveOptions.EpubHeadings.ncx");
1003+
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "toc.ncx");
10041004
TestUtil.docPackageFileContainsString("<navLabel><text>Heading #2</text></navLabel>",
1005-
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "HtmlSaveOptions.EpubHeadings.ncx");
1005+
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "toc.ncx");
10061006
TestUtil.docPackageFileContainsString("<navLabel><text>Heading #4</text></navLabel>",
1007-
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "HtmlSaveOptions.EpubHeadings.ncx");
1007+
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "toc.ncx");
10081008
TestUtil.docPackageFileContainsString("<navLabel><text>Heading #5</text></navLabel>",
1009-
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "HtmlSaveOptions.EpubHeadings.ncx");
1009+
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "toc.ncx");
10101010

10111011
Assert.<AssertionError>Throws(() =>
10121012
{
10131013
TestUtil.docPackageFileContainsString("<navLabel><text>Heading #3</text></navLabel>",
1014-
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "HtmlSaveOptions.EpubHeadings.ncx");
1014+
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "toc.ncx");
10151015
});
10161016

10171017
Assert.<AssertionError>Throws(() =>
10181018
{
10191019
TestUtil.docPackageFileContainsString("<navLabel><text>Heading #6</text></navLabel>",
1020-
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "HtmlSaveOptions.EpubHeadings.ncx");
1020+
getArtifactsDir() + "HtmlSaveOptions.EpubHeadings.epub", "toc.ncx");
10211021
});
10221022
}
10231023

Examples/ApiExamples/JavaPorting/ExMarkdownSaveOptions.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.aspose.words.Underline;
2424
import com.aspose.words.ShapeType;
2525
import com.aspose.words.MarkdownLinkExportMode;
26+
import com.aspose.words.MarkdownExportAsHtml;
2627
import org.testng.annotations.DataProvider;
2728

2829

@@ -288,6 +289,42 @@ public void linkExportMode() throws Exception
288289
String outDocContents = File.readAllText(getArtifactsDir() + "MarkdownSaveOptions.LinkExportMode.Inline.md");
289290
Assert.assertEquals("![](MarkdownSaveOptions.LinkExportMode.Inline.001.png)", outDocContents.trim());
290291
}
292+
293+
@Test
294+
public void exportTableAsHtml() throws Exception
295+
{
296+
//ExStart:ExportTableAsHtml
297+
//GistId:bb594993b5fe48692541e16f4d354ac2
298+
//ExFor:MarkdownExportAsHtml
299+
//ExFor:MarkdownSaveOptions.ExportAsHtml
300+
//ExSummary:Shows how to export a table to Markdown as raw HTML.
301+
Document doc = new Document();
302+
DocumentBuilder builder = new DocumentBuilder(doc);
303+
304+
builder.writeln("Sample table:");
305+
306+
// Create table.
307+
builder.insertCell();
308+
builder.getParagraphFormat().setAlignment(ParagraphAlignment.RIGHT);
309+
builder.write("Cell1");
310+
builder.insertCell();
311+
builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
312+
builder.write("Cell2");
313+
314+
MarkdownSaveOptions saveOptions = new MarkdownSaveOptions();
315+
saveOptions.setExportAsHtml(MarkdownExportAsHtml.TABLES);
316+
317+
doc.save(getArtifactsDir() + "MarkdownSaveOptions.ExportTableAsHtml.md", saveOptions);
318+
//ExEnd:ExportTableAsHtml
319+
320+
String outDocContents = File.readAllText(getArtifactsDir() + "MarkdownSaveOptions.ExportTableAsHtml.md");
321+
Assert.assertEquals("Sample table:\r\n<table cellspacing=\"0\" cellpadding=\"0\" style=\"width:100%; border:0.75pt solid #000000; border-collapse:collapse\">" +
322+
"<tr><td style=\"border-right-style:solid; border-right-width:0.75pt; padding-right:5.03pt; padding-left:5.03pt; vertical-align:top\">" +
323+
"<p style=\"margin-top:0pt; margin-bottom:0pt; text-align:right; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">Cell1</span></p>" +
324+
"</td><td style=\"border-left-style:solid; border-left-width:0.75pt; padding-right:5.03pt; padding-left:5.03pt; vertical-align:top\">" +
325+
"<p style=\"margin-top:0pt; margin-bottom:0pt; text-align:center; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">Cell2</span></p>" +
326+
"</td></tr></table>", outDocContents.trim());
327+
}
291328
}
292329

293330

Examples/ApiExamples/JavaPorting/ExPdfSaveOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public void usePdfDocumentForCompliance(/*PdfCompliance*/int pdfCompliance) thro
671671
Assert.AreEqual("2.0", pdfDocument.Version);
672672
break;
673673
case PdfCompliance.PDF_A_4:
674-
Assert.AreEqual(PdfFormat.v_2_0, pdfDocument.PdfFormat);
674+
Assert.AreEqual(PdfFormat.PDF_A_4, pdfDocument.PdfFormat);
675675
Assert.AreEqual("2.0", pdfDocument.Version);
676676
break;
677677
case PdfCompliance.PDF_A_4_UA_2:

Examples/ApiExamples/JavaPorting/ExShape.java

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
import com.aspose.words.ShadowFormat;
109109
import com.aspose.words.OptionButtonControl;
110110
import com.aspose.words.CheckBoxControl;
111+
import com.aspose.words.CommandButtonControl;
111112
import org.testng.annotations.DataProvider;
112113

113114

@@ -3554,8 +3555,8 @@ public void insertGroupShape() throws Exception
35543555
{
35553556
//ExStart:InsertGroupShape
35563557
//GistId:e06aa7a168b57907a5598e823a22bf0a
3557-
//ExFor:DocumentBuilder.InsertGroupShape(double, double, double, double, Shape[])
3558-
//ExFor:DocumentBuilder.InsertGroupShape(Shape[])
3558+
//ExFor:DocumentBuilder.InsertGroupShape(double, double, double, double, ShapeBase[])
3559+
//ExFor:DocumentBuilder.InsertGroupShape(ShapeBase[])
35593560
//ExSummary:Shows how to insert DML group shape.
35603561
Document doc = new Document();
35613562
DocumentBuilder builder = new DocumentBuilder(doc);
@@ -3585,5 +3586,69 @@ public void insertGroupShape() throws Exception
35853586
doc.save(getArtifactsDir() + "Shape.InsertGroupShape.docx");
35863587
//ExEnd:InsertGroupShape
35873588
}
3589+
3590+
@Test
3591+
public void combineGroupShape() throws Exception
3592+
{
3593+
//ExStart:CombineGroupShape
3594+
//GistId:bb594993b5fe48692541e16f4d354ac2
3595+
//ExFor:DocumentBuilder.InsertGroupShape(ShapeBase[])
3596+
//ExSummary:Shows how to combine group shape with the shape.
3597+
Document doc = new Document();
3598+
DocumentBuilder builder = new DocumentBuilder(doc);
3599+
3600+
Shape shape1 = builder.insertShape(ShapeType.RECTANGLE, 200.0, 250.0);
3601+
shape1.setLeft(20.0);
3602+
shape1.setTop(20.0);
3603+
shape1.getStroke().setColor(Color.RED);
3604+
3605+
Shape shape2 = builder.insertShape(ShapeType.ELLIPSE, 150.0, 200.0);
3606+
shape2.setLeft(40.0);
3607+
shape2.setTop(50.0);
3608+
shape2.getStroke().setColor(msColor.getGreen());
3609+
3610+
// Combine shapes into a GroupShape node which is inserted into the specified position.
3611+
GroupShape groupShape1 = builder.insertGroupShape(shape1, shape2);
3612+
3613+
// Combine Shape and GroupShape nodes.
3614+
Shape shape3 = (Shape)shape1.deepClone(true);
3615+
GroupShape groupShape2 = builder.insertGroupShape(groupShape1, shape3);
3616+
3617+
doc.save(getArtifactsDir() + "Shape.CombineGroupShape.docx");
3618+
//ExEnd:CombineGroupShape
3619+
}
3620+
3621+
@Test
3622+
public void insertCommandButton() throws Exception
3623+
{
3624+
//ExStart:InsertCommandButton
3625+
//GistId:bb594993b5fe48692541e16f4d354ac2
3626+
//ExFor:CommandButtonControl
3627+
//ExFor:DocumentBuilder.InsertForms2OleControl(Forms2OleControl)
3628+
//ExSummary:Shows how to insert ActiveX control.
3629+
DocumentBuilder builder = new DocumentBuilder();
3630+
3631+
CommandButtonControl button1 = new CommandButtonControl();
3632+
Shape shape = builder.insertForms2OleControl(button1);
3633+
Assert.assertEquals(Forms2OleControlType.COMMAND_BUTTON, ((Forms2OleControl)shape.getOleFormat().getOleControl()).getType());
3634+
//ExEnd:InsertCommandButton
3635+
}
3636+
3637+
@Test
3638+
public void hidden() throws Exception
3639+
{
3640+
//ExStart:Hidden
3641+
//GistId:bb594993b5fe48692541e16f4d354ac2
3642+
//ExFor:ShapeBase.Hidden
3643+
//ExSummary:Shows how to hide the shape.
3644+
Document doc = new Document(getMyDir() + "Shadow color.docx");
3645+
3646+
Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
3647+
if (!shape.getHidden())
3648+
shape.setHidden(true);
3649+
3650+
doc.save(getArtifactsDir() + "Shape.Hidden.docx");
3651+
//ExEnd:Hidden
3652+
}
35883653
}
35893654

Examples/ApiExamples/JavaPorting/TestUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void imageContainsTransparency(String filename)
9595
finally { if (bitmap != null) bitmap.close(); }
9696

9797
Assert.fail($"The image from \"{filename}\" does not contain any transparency.");
98-
}private VerifyWebResponseStatusCodeAsyncverifyWebResponseStatusCodeAsync(/*HttpStatusCode*/int expectedHttpStatusCode, String webAddress)
98+
}private VerifyWebResponseStatusCodeAsyncverifyWebResponseStatusCodeAsync(int expectedHttpStatusCode, String webAddress)
9999
{
100100
var myClient = new System.Net.Http.HttpClient();
101101
var response = await myClient.GetAsync(webAddress);

0 commit comments

Comments
 (0)