Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

XSLFNotesMaster.java 3.7KB

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