Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

XSLFRelation.java 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xslf.usermodel;
  16. import static org.apache.poi.openxml4j.opc.PackageRelationshipTypes.HDPHOTO_PART;
  17. import static org.apache.poi.openxml4j.opc.PackageRelationshipTypes.IMAGE_PART;
  18. import java.util.HashMap;
  19. import java.util.Map;
  20. import org.apache.poi.ooxml.POIXMLDocument;
  21. import org.apache.poi.ooxml.POIXMLRelation;
  22. import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
  23. import org.apache.poi.sl.usermodel.PictureData.PictureType;
  24. import org.apache.poi.util.Beta;
  25. import org.apache.poi.xssf.usermodel.XSSFRelation;
  26. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  27. @SuppressWarnings({"unused", "WeakerAccess"})
  28. @Beta
  29. public final class XSLFRelation extends POIXMLRelation {
  30. /* package */ static final String NS_DRAWINGML = XSSFRelation.NS_DRAWINGML;
  31. /**
  32. * A map to lookup POIXMLRelation by its relation type
  33. */
  34. private static final Map<String, XSLFRelation> _table = new HashMap<>();
  35. public static final XSLFRelation MAIN = new XSLFRelation(
  36. "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"
  37. );
  38. public static final XSLFRelation MACRO = new XSLFRelation(
  39. "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml"
  40. );
  41. public static final XSLFRelation MACRO_TEMPLATE = new XSLFRelation(
  42. "application/vnd.ms-powerpoint.template.macroEnabled.main+xml"
  43. );
  44. public static final XSLFRelation PRESENTATIONML = new XSLFRelation(
  45. "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"
  46. );
  47. public static final XSLFRelation PRESENTATIONML_TEMPLATE = new XSLFRelation(
  48. "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml"
  49. );
  50. public static final XSLFRelation PRESENTATION_MACRO = new XSLFRelation(
  51. "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml"
  52. );
  53. public static final XSLFRelation THEME_MANAGER = new XSLFRelation(
  54. "application/vnd.openxmlformats-officedocument.themeManager+xml"
  55. );
  56. public static final XSLFRelation NOTES = new XSLFRelation(
  57. "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml",
  58. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
  59. "/ppt/notesSlides/notesSlide#.xml",
  60. XSLFNotes::new, XSLFNotes::new
  61. );
  62. public static final XSLFRelation SLIDE = new XSLFRelation(
  63. "application/vnd.openxmlformats-officedocument.presentationml.slide+xml",
  64. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
  65. "/ppt/slides/slide#.xml",
  66. XSLFSlide::new, XSLFSlide::new
  67. );
  68. public static final XSLFRelation SLIDE_LAYOUT = new XSLFRelation(
  69. "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml",
  70. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
  71. "/ppt/slideLayouts/slideLayout#.xml",
  72. null, XSLFSlideLayout::new
  73. );
  74. public static final XSLFRelation SLIDE_MASTER = new XSLFRelation(
  75. "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml",
  76. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
  77. "/ppt/slideMasters/slideMaster#.xml",
  78. null, XSLFSlideMaster::new
  79. );
  80. public static final XSLFRelation NOTES_MASTER = new XSLFRelation(
  81. "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml",
  82. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
  83. "/ppt/notesMasters/notesMaster#.xml",
  84. XSLFNotesMaster::new, XSLFNotesMaster::new
  85. );
  86. public static final XSLFRelation COMMENTS = new XSLFRelation(
  87. "application/vnd.openxmlformats-officedocument.presentationml.comments+xml",
  88. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
  89. "/ppt/comments/comment#.xml",
  90. XSLFComments::new, XSLFComments::new
  91. );
  92. public static final XSLFRelation COMMENT_AUTHORS = new XSLFRelation(
  93. "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml",
  94. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors",
  95. "/ppt/commentAuthors.xml",
  96. XSLFCommentAuthors::new, XSLFCommentAuthors::new
  97. );
  98. public static final XSLFRelation HYPERLINK = new XSLFRelation(
  99. null,
  100. PackageRelationshipTypes.HYPERLINK_PART,
  101. null
  102. );
  103. public static final XSLFRelation THEME = new XSLFRelation(
  104. "application/vnd.openxmlformats-officedocument.theme+xml",
  105. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
  106. "/ppt/theme/theme#.xml",
  107. XSLFTheme::new, XSLFTheme::new
  108. );
  109. public static final XSLFRelation VML_DRAWING = new XSLFRelation(
  110. "application/vnd.openxmlformats-officedocument.vmlDrawing",
  111. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
  112. "/ppt/drawings/vmlDrawing#.vml"
  113. );
  114. // this is not the same as in XSSFRelation.WORKBOOK, as it is usually used by embedded charts
  115. // referencing the original embedded excel workbook
  116. public static final XSLFRelation WORKBOOK = new XSLFRelation(
  117. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  118. POIXMLDocument.PACK_OBJECT_REL_TYPE,
  119. "/ppt/embeddings/Microsoft_Excel_Worksheet#.xlsx",
  120. XSSFWorkbook::new, XSSFWorkbook::new
  121. );
  122. public static final XSLFRelation CHART = new XSLFRelation(
  123. "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
  124. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
  125. "/ppt/charts/chart#.xml",
  126. XSLFChart::new, XSLFChart::new
  127. );
  128. public static final XSLFRelation DIAGRAM_DRAWING = new XSLFRelation(
  129. "application/vnd.ms-office.drawingml.diagramDrawing+xml",
  130. "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing",
  131. "/ppt/diagrams/drawing#.xml",
  132. XSLFDiagramDrawing::new, XSLFDiagramDrawing::new
  133. );
  134. public static final XSLFRelation IMAGE_EMF = new XSLFRelation(
  135. PictureType.EMF.contentType,
  136. IMAGE_PART,
  137. "/ppt/media/image#.emf",
  138. XSLFPictureData::new, XSLFPictureData::new
  139. );
  140. public static final XSLFRelation IMAGE_WMF = new XSLFRelation(
  141. PictureType.WMF.contentType,
  142. IMAGE_PART,
  143. "/ppt/media/image#.wmf",
  144. XSLFPictureData::new, XSLFPictureData::new
  145. );
  146. public static final XSLFRelation IMAGE_PICT = new XSLFRelation(
  147. PictureType.PICT.contentType,
  148. IMAGE_PART,
  149. "/ppt/media/image#.pict",
  150. XSLFPictureData::new, XSLFPictureData::new
  151. );
  152. public static final XSLFRelation IMAGE_JPEG = new XSLFRelation(
  153. PictureType.JPEG.contentType,
  154. IMAGE_PART,
  155. "/ppt/media/image#.jpeg",
  156. XSLFPictureData::new, XSLFPictureData::new
  157. );
  158. public static final XSLFRelation IMAGE_PNG = new XSLFRelation(
  159. PictureType.PNG.contentType,
  160. IMAGE_PART,
  161. "/ppt/media/image#.png",
  162. XSLFPictureData::new, XSLFPictureData::new
  163. );
  164. public static final XSLFRelation IMAGE_DIB = new XSLFRelation(
  165. PictureType.DIB.contentType,
  166. IMAGE_PART,
  167. "/ppt/media/image#.dib",
  168. XSLFPictureData::new, XSLFPictureData::new
  169. );
  170. public static final XSLFRelation IMAGE_GIF = new XSLFRelation(
  171. PictureType.GIF.contentType,
  172. IMAGE_PART,
  173. "/ppt/media/image#.gif",
  174. XSLFPictureData::new, XSLFPictureData::new
  175. );
  176. public static final XSLFRelation IMAGE_TIFF = new XSLFRelation(
  177. PictureType.TIFF.contentType,
  178. IMAGE_PART,
  179. "/ppt/media/image#.tiff",
  180. XSLFPictureData::new, XSLFPictureData::new
  181. );
  182. public static final XSLFRelation IMAGE_EPS = new XSLFRelation(
  183. PictureType.EPS.contentType,
  184. IMAGE_PART,
  185. "/ppt/media/image#.eps",
  186. XSLFPictureData::new, XSLFPictureData::new
  187. );
  188. public static final XSLFRelation IMAGE_BMP = new XSLFRelation(
  189. PictureType.BMP.contentType,
  190. IMAGE_PART,
  191. "/ppt/media/image#.bmp",
  192. XSLFPictureData::new, XSLFPictureData::new
  193. );
  194. public static final XSLFRelation IMAGE_WPG = new XSLFRelation(
  195. PictureType.WPG.contentType,
  196. IMAGE_PART,
  197. "/ppt/media/image#.wpg",
  198. XSLFPictureData::new, XSLFPictureData::new
  199. );
  200. public static final XSLFRelation IMAGE_WDP = new XSLFRelation(
  201. PictureType.WDP.contentType,
  202. IMAGE_PART,
  203. "/ppt/media/image#.wdp",
  204. XSLFPictureData::new, XSLFPictureData::new
  205. );
  206. public static final XSLFRelation HDPHOTO_WDP = new XSLFRelation(
  207. PictureType.WDP.contentType,
  208. HDPHOTO_PART,
  209. "/ppt/media/hdphoto#.wdp",
  210. XSLFPictureData::new, XSLFPictureData::new
  211. );
  212. public static final XSLFRelation IMAGE_SVG = new XSLFRelation(
  213. PictureType.SVG.contentType,
  214. IMAGE_PART,
  215. "/ppt/media/image#.svg",
  216. XSLFPictureData::new, XSLFPictureData::new
  217. );
  218. public static final XSLFRelation IMAGES = new XSLFRelation(
  219. null,
  220. IMAGE_PART,
  221. null,
  222. XSLFPictureData::new, XSLFPictureData::new
  223. );
  224. public static final XSLFRelation TABLE_STYLES = new XSLFRelation(
  225. "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml",
  226. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles",
  227. "/ppt/tableStyles.xml",
  228. XSLFTableStyles::new, XSLFTableStyles::new
  229. );
  230. public static final XSLFRelation OLE_OBJECT = new XSLFRelation(
  231. "application/vnd.openxmlformats-officedocument.oleObject",
  232. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",
  233. "/ppt/embeddings/oleObject#.bin",
  234. XSLFObjectData::new, XSLFObjectData::new
  235. );
  236. public static final XSLFRelation FONT = new XSLFRelation(
  237. "application/x-fontdata",
  238. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font",
  239. "/ppt/fonts/font#.fntdata",
  240. XSLFFontData::new, XSLFFontData::new
  241. );
  242. private XSLFRelation(String type) {
  243. this(type, null, null, null, null);
  244. }
  245. private XSLFRelation(String type, String rel, String defaultName) {
  246. this(type, rel, defaultName, null, null);
  247. }
  248. private XSLFRelation(String type, String rel, String defaultName,
  249. NoArgConstructor noArgConstructor,
  250. PackagePartConstructor packagePartConstructor) {
  251. super(type, rel, defaultName, noArgConstructor, packagePartConstructor, null);
  252. _table.put(rel, this);
  253. }
  254. /**
  255. * Get POIXMLRelation by relation type
  256. *
  257. * @param rel relation type, for example,
  258. * <code>http://schemas.openxmlformats.org/officeDocument/2006/relationships/image</code>
  259. * @return registered POIXMLRelation or null if not found
  260. */
  261. public static XSLFRelation getInstance(String rel) {
  262. return _table.get(rel);
  263. }
  264. }