You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XSLFRelation.java 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 java.util.HashMap;
  17. import java.util.Map;
  18. import org.apache.poi.ooxml.POIXMLDocument;
  19. import org.apache.poi.ooxml.POIXMLDocumentPart;
  20. import org.apache.poi.ooxml.POIXMLRelation;
  21. import org.apache.poi.sl.usermodel.PictureData.PictureType;
  22. import org.apache.poi.util.Beta;
  23. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  24. @Beta
  25. public class XSLFRelation extends POIXMLRelation {
  26. /**
  27. * A map to lookup POIXMLRelation by its relation type
  28. */
  29. private static final Map<String, XSLFRelation> _table = new HashMap<>();
  30. public static final XSLFRelation MAIN = new XSLFRelation(
  31. "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml",
  32. null, null, null
  33. );
  34. public static final XSLFRelation MACRO = new XSLFRelation(
  35. "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml",
  36. null, null, null
  37. );
  38. public static final XSLFRelation MACRO_TEMPLATE = new XSLFRelation(
  39. "application/vnd.ms-powerpoint.template.macroEnabled.main+xml",
  40. null, null, null
  41. );
  42. public static final XSLFRelation PRESENTATIONML = new XSLFRelation(
  43. "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml",
  44. null, null, null
  45. );
  46. public static final XSLFRelation PRESENTATIONML_TEMPLATE = new XSLFRelation(
  47. "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml",
  48. null, null, null
  49. );
  50. public static final XSLFRelation PRESENTATION_MACRO = new XSLFRelation(
  51. "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml",
  52. null, null, null
  53. );
  54. public static final XSLFRelation THEME_MANAGER = new XSLFRelation(
  55. "application/vnd.openxmlformats-officedocument.themeManager+xml",
  56. null, null, null
  57. );
  58. public static final XSLFRelation NOTES = new XSLFRelation(
  59. "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml",
  60. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
  61. "/ppt/notesSlides/notesSlide#.xml",
  62. XSLFNotes.class
  63. );
  64. public static final XSLFRelation SLIDE = new XSLFRelation(
  65. "application/vnd.openxmlformats-officedocument.presentationml.slide+xml",
  66. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
  67. "/ppt/slides/slide#.xml",
  68. XSLFSlide.class
  69. );
  70. public static final XSLFRelation SLIDE_LAYOUT = new XSLFRelation(
  71. "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml",
  72. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
  73. "/ppt/slideLayouts/slideLayout#.xml",
  74. XSLFSlideLayout.class
  75. );
  76. public static final XSLFRelation SLIDE_MASTER = new XSLFRelation(
  77. "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml",
  78. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
  79. "/ppt/slideMasters/slideMaster#.xml",
  80. XSLFSlideMaster.class
  81. );
  82. public static final XSLFRelation NOTES_MASTER = new XSLFRelation(
  83. "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml",
  84. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
  85. "/ppt/notesMasters/notesMaster#.xml",
  86. XSLFNotesMaster.class
  87. );
  88. public static final XSLFRelation COMMENTS = new XSLFRelation(
  89. "application/vnd.openxmlformats-officedocument.presentationml.comments+xml",
  90. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
  91. "/ppt/comments/comment#.xml",
  92. XSLFComments.class
  93. );
  94. public static final XSLFRelation COMMENT_AUTHORS = new XSLFRelation(
  95. "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml",
  96. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors",
  97. "/ppt/commentAuthors.xml",
  98. XSLFCommentAuthors.class
  99. );
  100. public static final XSLFRelation HYPERLINK = new XSLFRelation(
  101. null,
  102. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
  103. null,
  104. null
  105. );
  106. public static final XSLFRelation THEME = new XSLFRelation(
  107. "application/vnd.openxmlformats-officedocument.theme+xml",
  108. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
  109. "/ppt/theme/theme#.xml",
  110. XSLFTheme.class
  111. );
  112. public static final XSLFRelation VML_DRAWING = new XSLFRelation(
  113. "application/vnd.openxmlformats-officedocument.vmlDrawing",
  114. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
  115. "/ppt/drawings/vmlDrawing#.vml",
  116. null
  117. );
  118. // this is not the same as in XSSFRelation.WORKBOOK, as it is usually used by embedded charts
  119. // referencing the original embedded excel workbook
  120. public static final XSLFRelation WORKBOOK = new XSLFRelation(
  121. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
  122. POIXMLDocument.PACK_OBJECT_REL_TYPE,
  123. "/ppt/embeddings/Microsoft_Excel_Worksheet#.xlsx",
  124. XSSFWorkbook.class
  125. );
  126. public static final XSLFRelation CHART = new XSLFRelation(
  127. "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
  128. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
  129. "/ppt/charts/chart#.xml",
  130. XSLFChart.class
  131. );
  132. public static final XSLFRelation IMAGE_EMF = new XSLFRelation(
  133. PictureType.EMF.contentType,
  134. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  135. "/ppt/media/image#.emf",
  136. XSLFPictureData.class
  137. );
  138. public static final XSLFRelation IMAGE_WMF = new XSLFRelation(
  139. PictureType.WMF.contentType,
  140. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  141. "/ppt/media/image#.wmf",
  142. XSLFPictureData.class
  143. );
  144. public static final XSLFRelation IMAGE_PICT = new XSLFRelation(
  145. PictureType.PICT.contentType,
  146. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  147. "/ppt/media/image#.pict",
  148. XSLFPictureData.class
  149. );
  150. public static final XSLFRelation IMAGE_JPEG = new XSLFRelation(
  151. PictureType.JPEG.contentType,
  152. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  153. "/ppt/media/image#.jpeg",
  154. XSLFPictureData.class
  155. );
  156. public static final XSLFRelation IMAGE_PNG = new XSLFRelation(
  157. PictureType.PNG.contentType,
  158. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  159. "/ppt/media/image#.png",
  160. XSLFPictureData.class
  161. );
  162. public static final XSLFRelation IMAGE_DIB = new XSLFRelation(
  163. PictureType.DIB.contentType,
  164. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  165. "/ppt/media/image#.dib",
  166. XSLFPictureData.class
  167. );
  168. public static final XSLFRelation IMAGE_GIF = new XSLFRelation(
  169. PictureType.GIF.contentType,
  170. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  171. "/ppt/media/image#.gif",
  172. XSLFPictureData.class
  173. );
  174. public static final XSLFRelation IMAGE_TIFF = new XSLFRelation(
  175. PictureType.TIFF.contentType,
  176. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  177. "/ppt/media/image#.tiff",
  178. XSLFPictureData.class
  179. );
  180. public static final XSLFRelation IMAGE_EPS = new XSLFRelation(
  181. PictureType.EPS.contentType,
  182. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  183. "/ppt/media/image#.eps",
  184. XSLFPictureData.class
  185. );
  186. public static final XSLFRelation IMAGE_BMP = new XSLFRelation(
  187. PictureType.BMP.contentType,
  188. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  189. "/ppt/media/image#.bmp",
  190. XSLFPictureData.class
  191. );
  192. public static final XSLFRelation IMAGE_WPG = new XSLFRelation(
  193. PictureType.WPG.contentType,
  194. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  195. "/ppt/media/image#.wpg",
  196. XSLFPictureData.class
  197. );
  198. public static final XSLFRelation IMAGE_WDP = new XSLFRelation(
  199. PictureType.WDP.contentType,
  200. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  201. "/ppt/media/image#.wdp",
  202. XSLFPictureData.class
  203. );
  204. public static final XSLFRelation IMAGES = new XSLFRelation(
  205. null,
  206. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
  207. null,
  208. XSLFPictureData.class
  209. );
  210. public static final XSLFRelation TABLE_STYLES = new XSLFRelation(
  211. "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml",
  212. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles",
  213. "/ppt/tableStyles.xml",
  214. XSLFTableStyles.class
  215. );
  216. public static final XSLFRelation OLE_OBJECT = new XSLFRelation(
  217. "application/vnd.openxmlformats-officedocument.oleObject",
  218. "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",
  219. "/ppt/embeddings/oleObject#.bin",
  220. XSLFObjectData.class
  221. );
  222. private XSLFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
  223. super(type, rel, defaultName, cls);
  224. _table.put(rel, this);
  225. }
  226. /**
  227. * Get POIXMLRelation by relation type
  228. *
  229. * @param rel relation type, for example,
  230. * <code>http://schemas.openxmlformats.org/officeDocument/2006/relationships/image</code>
  231. * @return registered POIXMLRelation or null if not found
  232. */
  233. public static XSLFRelation getInstance(String rel) {
  234. return _table.get(rel);
  235. }
  236. }