SemanticAwareDrawingCanvas.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using QuestPDF.Drawing;
  2. using QuestPDF.Infrastructure;
  3. using QuestPDF.Skia;
  4. using QuestPDF.Skia.Text;
  5. namespace QuestPDF.ConformanceTests.TestEngine;
  6. internal class SemanticAwareDocumentCanvas : IDocumentCanvas
  7. {
  8. internal SemanticTreeNode? SemanticTree { get; private set; }
  9. private SemanticAwareDrawingCanvas DrawingCanvas { get; } = new();
  10. public void SetSemanticTree(SemanticTreeNode? semanticTree)
  11. {
  12. SemanticTree = semanticTree;
  13. }
  14. public void BeginDocument()
  15. {
  16. }
  17. public void EndDocument()
  18. {
  19. }
  20. public void BeginPage(Size size)
  21. {
  22. }
  23. public void EndPage()
  24. {
  25. }
  26. public IDrawingCanvas GetDrawingCanvas()
  27. {
  28. return DrawingCanvas;
  29. }
  30. }
  31. internal class SemanticAwareDrawingCanvas : IDrawingCanvas
  32. {
  33. private int CurrentSemanticNodeId { get; set; }
  34. public DocumentPageSnapshot GetSnapshot()
  35. {
  36. return new DocumentPageSnapshot();
  37. }
  38. public void DrawSnapshot(DocumentPageSnapshot snapshot)
  39. {
  40. }
  41. public void Save()
  42. {
  43. }
  44. public void Restore()
  45. {
  46. }
  47. public void SetZIndex(int index)
  48. {
  49. }
  50. public int GetZIndex()
  51. {
  52. return 0;
  53. }
  54. public SkCanvasMatrix GetCurrentMatrix()
  55. {
  56. return SkCanvasMatrix.Identity;
  57. }
  58. public void SetMatrix(SkCanvasMatrix matrix)
  59. {
  60. }
  61. public void Translate(Position vector)
  62. {
  63. }
  64. public void Scale(float scaleX, float scaleY)
  65. {
  66. }
  67. public void Rotate(float angle)
  68. {
  69. }
  70. public void DrawLine(Position start, Position end, SkPaint paint)
  71. {
  72. if (CurrentSemanticNodeId != SkSemanticNodeSpecialId.LayoutArtifact)
  73. Assert.Fail("Detected a line drawing operation outside of layout artifact");
  74. }
  75. public void DrawRectangle(Position vector, Size size, SkPaint paint)
  76. {
  77. if (CurrentSemanticNodeId is not (SkSemanticNodeSpecialId.BackgroundArtifact or SkSemanticNodeSpecialId.LayoutArtifact))
  78. Assert.Fail("Detected a rectangle drawing operation outside of layout artifact");
  79. }
  80. public void DrawComplexBorder(SkRoundedRect innerRect, SkRoundedRect outerRect, SkPaint paint)
  81. {
  82. if (CurrentSemanticNodeId != SkSemanticNodeSpecialId.LayoutArtifact)
  83. Assert.Fail("Detected a complex-border drawing operation outside of layout artifact");
  84. }
  85. public void DrawShadow(SkRoundedRect shadowRect, SkBoxShadow shadow)
  86. {
  87. if (CurrentSemanticNodeId != SkSemanticNodeSpecialId.BackgroundArtifact)
  88. Assert.Fail("Detected a shadow drawing operation outside of background artifact");
  89. }
  90. public void DrawParagraph(SkParagraph paragraph, int lineFrom, int lineTo)
  91. {
  92. }
  93. public void DrawImage(SkImage image, Size size)
  94. {
  95. }
  96. public void DrawPicture(SkPicture picture)
  97. {
  98. }
  99. public void DrawSvgPath(string path, Color color)
  100. {
  101. }
  102. public void DrawSvg(SkSvgImage svgImage, Size size)
  103. {
  104. }
  105. public void DrawOverflowArea(SkRect area)
  106. {
  107. }
  108. public void ClipOverflowArea(SkRect availableSpace, SkRect requiredSpace)
  109. {
  110. }
  111. public void ClipRectangle(SkRect clipArea)
  112. {
  113. }
  114. public void ClipRoundedRectangle(SkRoundedRect clipArea)
  115. {
  116. }
  117. public void DrawHyperlink(Size size, string url, string? description)
  118. {
  119. }
  120. public void DrawSectionLink(Size size, string sectionName, string? description)
  121. {
  122. }
  123. public void DrawSection(string sectionName)
  124. {
  125. }
  126. public void SetSemanticNodeId(int nodeId)
  127. {
  128. CurrentSemanticNodeId = nodeId;
  129. }
  130. }