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.

AbstractIFDocumentHandler.java 3.2KB

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