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.

XSLFNotesMaster.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
  17. import java.io.IOException;
  18. import java.io.InputStream;
  19. import org.apache.poi.POIXMLDocumentPart;
  20. import org.apache.poi.POIXMLException;
  21. import org.apache.poi.openxml4j.opc.PackagePart;
  22. import org.apache.poi.sl.usermodel.MasterSheet;
  23. import org.apache.poi.util.Beta;
  24. import org.apache.xmlbeans.XmlException;
  25. import org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping;
  26. import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMaster;
  27. import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
  28. /**
  29. * Notes master object associated with this layout.
  30. * <p>
  31. * Within a notes master slide are contained all elements
  32. * that describe the objects and their corresponding formatting
  33. * for within a presentation slide.
  34. * </p>
  35. * <p>
  36. * Within a nodes master slide are two main elements.
  37. * The cSld element specifies the common slide elements such as shapes and
  38. * their attached text bodies. Then the notesStyles element specifies the
  39. * formatting for the text within each of these shapes.
  40. * </p>
  41. *
  42. * @author Yegor Kozlov
  43. */
  44. @Beta
  45. public class XSLFNotesMaster extends XSLFSheet
  46. implements MasterSheet<XSLFShape,XSLFTextParagraph> {
  47. private CTNotesMaster _slide;
  48. XSLFNotesMaster() {
  49. super();
  50. _slide = prototype();
  51. }
  52. /**
  53. * @since POI 3.14-Beta1
  54. */
  55. protected XSLFNotesMaster(PackagePart part) throws IOException, XmlException {
  56. super(part);
  57. NotesMasterDocument doc =
  58. NotesMasterDocument.Factory.parse(getPackagePart().getInputStream(), DEFAULT_XML_OPTIONS);
  59. _slide = doc.getNotesMaster();
  60. }
  61. private static CTNotesMaster prototype() {
  62. InputStream is = XSLFNotesMaster.class.getResourceAsStream("notesMaster.xml");
  63. if (is == null) {
  64. throw new POIXMLException("Missing resource 'notesMaster.xml'");
  65. }
  66. try {
  67. try {
  68. NotesMasterDocument doc = NotesMasterDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
  69. return doc.getNotesMaster();
  70. } finally {
  71. is.close();
  72. }
  73. } catch (Exception e) {
  74. throw new POIXMLException("Can't initialize NotesMaster", e);
  75. }
  76. }
  77. @Override
  78. public CTNotesMaster getXmlObject() {
  79. return _slide;
  80. }
  81. @Override
  82. protected String getRootElementName(){
  83. return "notesMaster";
  84. }
  85. @Override
  86. public MasterSheet<XSLFShape,XSLFTextParagraph> getMasterSheet() {
  87. return null;
  88. }
  89. @Override
  90. boolean isSupportTheme() {
  91. return true;
  92. }
  93. @Override
  94. CTColorMapping getColorMapping() {
  95. return _slide.getClrMap();
  96. }
  97. }