Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

StandardStructureTypes.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.pdf;
  19. import java.util.HashMap;
  20. import java.util.Map;
  21. /**
  22. * Standard structure types, as defined in section 10.7.4 of the PDF Reference, Fourth Edition (PDF 1.5).
  23. */
  24. public final class StandardStructureTypes {
  25. public static final class Grouping {
  26. public static final StructureType DOCUMENT = new StructureTypeImpl("Document");
  27. public static final StructureType PART = new StructureTypeImpl("Part");
  28. public static final StructureType ART = new StructureTypeImpl("Art");
  29. public static final StructureType SECT = new StructureTypeImpl("Sect");
  30. public static final StructureType DIV = new StructureTypeImpl("Div");
  31. public static final StructureType BLOCK_QUOTE = new StructureTypeImpl("BlockQuote");
  32. public static final StructureType CAPTION = new StructureTypeImpl("Caption");
  33. public static final StructureType TOC = new StructureTypeImpl("TOC");
  34. public static final StructureType TOCI = new StructureTypeImpl("TOCI");
  35. public static final StructureType INDEX = new StructureTypeImpl("Index");
  36. public static final StructureType NON_STRUCT = new StructureTypeImpl("NonStruct");
  37. public static final StructureType PRIVATE = new StructureTypeImpl("Private");
  38. }
  39. public static final class Paragraphlike {
  40. public static final StructureType H = new StructureTypeImpl("H");
  41. public static final StructureType H1 = new StructureTypeImpl("H1");
  42. public static final StructureType H2 = new StructureTypeImpl("H2");
  43. public static final StructureType H3 = new StructureTypeImpl("H3");
  44. public static final StructureType H4 = new StructureTypeImpl("H4");
  45. public static final StructureType H5 = new StructureTypeImpl("H5");
  46. public static final StructureType H6 = new StructureTypeImpl("H6");
  47. public static final StructureType P = new StructureTypeImpl("P");
  48. }
  49. public static final class List {
  50. public static final StructureType L = new StructureTypeImpl("L");
  51. public static final StructureType LI = new StructureTypeImpl("LI");
  52. public static final StructureType LBL = new StructureTypeImpl("Lbl");
  53. public static final StructureType LBODY = new StructureTypeImpl("LBody");
  54. }
  55. public static final class Table {
  56. public static final StructureType TABLE = new StructureTypeImpl("Table");
  57. public static final StructureType TR = new StructureTypeImpl("TR");
  58. public static final StructureType TH = new StructureTypeImpl("TH");
  59. public static final StructureType TD = new StructureTypeImpl("TD");
  60. public static final StructureType THEAD = new StructureTypeImpl("THead");
  61. public static final StructureType TBODY = new StructureTypeImpl("TBody");
  62. public static final StructureType TFOOT = new StructureTypeImpl("TFoot");
  63. }
  64. public static final class InlineLevelStructure {
  65. public static final StructureType SPAN = new StructureTypeImpl("Span");
  66. public static final StructureType QUOTE = new StructureTypeImpl("Quote");
  67. public static final StructureType NOTE = new StructureTypeImpl("Note");
  68. public static final StructureType REFERENCE = new StructureTypeImpl("Reference");
  69. public static final StructureType BIB_ENTRY = new StructureTypeImpl("BibEntry");
  70. public static final StructureType CODE = new StructureTypeImpl("Code");
  71. public static final StructureType LINK = new StructureTypeImpl("Link");
  72. public static final StructureType ANNOT = new StructureTypeImpl("Annot");
  73. }
  74. public static final class RubyOrWarichu {
  75. public static final StructureType RUBY = new StructureTypeImpl("Ruby");
  76. public static final StructureType RB = new StructureTypeImpl("RB");
  77. public static final StructureType RT = new StructureTypeImpl("RT");
  78. public static final StructureType RP = new StructureTypeImpl("RP");
  79. public static final StructureType WARICHU = new StructureTypeImpl("Warichu");
  80. public static final StructureType WT = new StructureTypeImpl("WT");
  81. public static final StructureType WP = new StructureTypeImpl("WP");
  82. }
  83. public static final class Illustration {
  84. public static final StructureType FIGURE = new StructureTypeImpl("Figure");
  85. public static final StructureType FORMULA = new StructureTypeImpl("Formula");
  86. public static final StructureType FORM = new StructureTypeImpl("Form");
  87. }
  88. private static class StructureTypeImpl implements StructureType {
  89. private final PDFName name;
  90. protected StructureTypeImpl(String name) {
  91. this.name = new PDFName(name);
  92. StandardStructureTypes.STRUCTURE_TYPES.put(name, this);
  93. }
  94. public PDFName getName() {
  95. return name;
  96. }
  97. @Override
  98. public String toString() {
  99. return name.toString().substring(1);
  100. }
  101. }
  102. private static final Map<String, StructureType> STRUCTURE_TYPES = new HashMap<String, StructureType>();
  103. private StandardStructureTypes() { }
  104. /**
  105. * Returns the standard structure type of the given name.
  106. *
  107. * @param name the name of a structure type, case sensitive. For example, Document,
  108. * Sect, H1, etc.
  109. * @return the corresponding {@code StructureType} instance, or {@code null} if the given
  110. * name does not correspond to a standard structure type
  111. */
  112. public static StructureType get(String name) {
  113. return STRUCTURE_TYPES.get(name);
  114. }
  115. }