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.

MainMaster.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.hslf.record;
  16. import java.io.IOException;
  17. import java.io.OutputStream;
  18. import java.util.ArrayList;
  19. /**
  20. * Master slide
  21. *
  22. * @author Yegor Kozlov
  23. */
  24. public final class MainMaster extends SheetContainer {
  25. private byte[] _header;
  26. private static long _type = 1016;
  27. // Links to our more interesting children
  28. private SlideAtom slideAtom;
  29. private PPDrawing ppDrawing;
  30. private TxMasterStyleAtom[] txmasters;
  31. private ColorSchemeAtom[] clrscheme;
  32. private ColorSchemeAtom _colorScheme;
  33. /**
  34. * Returns the SlideAtom of this Slide
  35. */
  36. public SlideAtom getSlideAtom() { return slideAtom; }
  37. /**
  38. * Returns the PPDrawing of this Slide, which has all the
  39. * interesting data in it
  40. */
  41. public PPDrawing getPPDrawing() { return ppDrawing; }
  42. public TxMasterStyleAtom[] getTxMasterStyleAtoms() { return txmasters; }
  43. public ColorSchemeAtom[] getColorSchemeAtoms() { return clrscheme; }
  44. /**
  45. * Set things up, and find our more interesting children
  46. */
  47. protected MainMaster(byte[] source, int start, int len) {
  48. // Grab the header
  49. _header = new byte[8];
  50. System.arraycopy(source,start,_header,0,8);
  51. // Find our children
  52. _children = Record.findChildRecords(source,start+8,len-8);
  53. ArrayList<TxMasterStyleAtom> tx = new ArrayList<>();
  54. ArrayList<ColorSchemeAtom> clr = new ArrayList<>();
  55. // Find the interesting ones in there
  56. for(int i=0; i<_children.length; i++) {
  57. if(_children[i] instanceof SlideAtom) {
  58. slideAtom = (SlideAtom)_children[i];
  59. } else if(_children[i] instanceof PPDrawing) {
  60. ppDrawing = (PPDrawing)_children[i];
  61. } else if(_children[i] instanceof TxMasterStyleAtom) {
  62. tx.add( (TxMasterStyleAtom)_children[i] );
  63. } else if(_children[i] instanceof ColorSchemeAtom) {
  64. clr.add( (ColorSchemeAtom)_children[i] );
  65. }
  66. if(ppDrawing != null && _children[i] instanceof ColorSchemeAtom) {
  67. _colorScheme = (ColorSchemeAtom)_children[i];
  68. }
  69. }
  70. txmasters = tx.toArray(new TxMasterStyleAtom[0]);
  71. clrscheme = clr.toArray(new ColorSchemeAtom[0]);
  72. }
  73. /**
  74. * We are of type 1016
  75. */
  76. public long getRecordType() { return _type; }
  77. /**
  78. * Write the contents of the record back, so it can be written
  79. * to disk
  80. */
  81. public void writeOut(OutputStream out) throws IOException {
  82. writeOut(_header[0],_header[1],_type,_children,out);
  83. }
  84. public ColorSchemeAtom getColorScheme(){
  85. return _colorScheme;
  86. }
  87. }