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.

AbstractIFDocumentHandler.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.render.intermediate;
  19. import java.util.Locale;
  20. import org.apache.fop.accessibility.DummyStructureTreeEventHandler;
  21. import org.apache.fop.accessibility.StructureTreeEventHandler;
  22. import org.apache.fop.apps.FOUserAgent;
  23. /**
  24. * Abstract base class for {@link IFDocumentHandler} implementations.
  25. */
  26. public abstract class AbstractIFDocumentHandler implements IFDocumentHandler {
  27. private final IFContext ifContext;
  28. /**
  29. * Default constructor.
  30. */
  31. protected AbstractIFDocumentHandler(IFContext context) {
  32. this.ifContext = context;
  33. }
  34. /** {@inheritDoc} */
  35. public IFContext getContext() {
  36. return this.ifContext;
  37. }
  38. /**
  39. * Returns the associated user agent.
  40. * @return the user agent
  41. */
  42. public FOUserAgent getUserAgent() {
  43. return getContext().getUserAgent();
  44. }
  45. /** {@inheritDoc} */
  46. public StructureTreeEventHandler getStructureTreeEventHandler() {
  47. return DummyStructureTreeEventHandler.INSTANCE;
  48. }
  49. /** {@inheritDoc} */
  50. public IFDocumentNavigationHandler getDocumentNavigationHandler() {
  51. return null; //By default, this is not supported
  52. }
  53. /** {@inheritDoc} */
  54. public void startDocument() throws IFException {
  55. if (getUserAgent() == null) {
  56. throw new IllegalStateException(
  57. "User agent must be set before starting document generation");
  58. }
  59. }
  60. /** {@inheritDoc} */
  61. public void setDocumentLocale(Locale locale) {
  62. }
  63. /** {@inheritDoc} */
  64. public void startDocumentHeader() throws IFException {
  65. //nop
  66. }
  67. /** {@inheritDoc} */
  68. public void endDocumentHeader() throws IFException {
  69. //nop
  70. }
  71. /** {@inheritDoc} */
  72. public void startDocumentTrailer() throws IFException {
  73. //nop
  74. }
  75. /** {@inheritDoc} */
  76. public void endDocumentTrailer() throws IFException {
  77. //nop
  78. }
  79. /** {@inheritDoc} */
  80. public void startPageHeader() throws IFException {
  81. //nop
  82. }
  83. /** {@inheritDoc} */
  84. public void endPageHeader() throws IFException {
  85. //nop
  86. }
  87. /** {@inheritDoc} */
  88. public void startPageTrailer() throws IFException {
  89. //nop
  90. }
  91. /** {@inheritDoc} */
  92. public void endPageTrailer() throws IFException {
  93. //nop
  94. }
  95. }