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.

Declarations.java 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.fo;
  8. // FOP
  9. import org.apache.fop.fo.flow.*;
  10. import org.apache.fop.apps.FOPException;
  11. import java.util.ArrayList;
  12. import java.util.HashMap;
  13. import java.util.Iterator;
  14. /**
  15. * Declarations formatting object.
  16. * A declarations formatting object holds a set of color-profiles
  17. * and optionally additional non-XSL namespace elements.
  18. * The color-profiles are held in a hashmap for use with color-profile
  19. * references.
  20. */
  21. public class Declarations extends FObj {
  22. HashMap colorProfiles = null;
  23. ArrayList external = null;
  24. protected Declarations(FONode parent) {
  25. super(parent);
  26. }
  27. /**
  28. * At then end of this element sort out the child into
  29. * a hashmap of color profiles and a list of external xml.
  30. */
  31. public void end() {
  32. for(Iterator iter = children.iterator(); iter.hasNext(); ) {
  33. FONode node = (FONode)iter.next();
  34. if(node.getName().equals("fo:color-profile")) {
  35. ColorProfile cp = (ColorProfile)node;
  36. if(!"".equals(cp.getProfileName())) {
  37. if(colorProfiles == null) {
  38. colorProfiles = new HashMap();
  39. }
  40. if(colorProfiles.get(cp.getProfileName()) != null) {
  41. // duplicate names
  42. getLogger().warn("Duplicate fo:color-profile profile name : " + cp.getProfileName());
  43. }
  44. colorProfiles.put(cp.getProfileName(), cp);
  45. } else {
  46. getLogger().warn("color-profile-name required for color profile");
  47. }
  48. } else if(node instanceof XMLObj) {
  49. if(external == null) {
  50. external = new ArrayList();
  51. }
  52. external.add(node);
  53. } else {
  54. getLogger().warn("invalid element " + node.getName() + "inside declarations");
  55. }
  56. }
  57. children = null;
  58. }
  59. }