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.

FObjMixed.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. import org.apache.fop.layout.Area;
  9. import org.apache.fop.layout.FontState;
  10. import org.apache.fop.layout.FontInfo;
  11. import org.apache.fop.apps.FOPException;
  12. import org.apache.fop.apps.StreamRenderer;
  13. import org.apache.fop.datatypes.ColorType;
  14. import java.util.List;
  15. /**
  16. * base class for representation of mixed content formatting objects
  17. * and their processing
  18. */
  19. public class FObjMixed extends FObj {
  20. TextInfo textInfo = null;
  21. protected FontInfo fontInfo = null;
  22. public FObjMixed(FONode parent) {
  23. super(parent);
  24. }
  25. public void setStreamRenderer(StreamRenderer st) {
  26. fontInfo = st.getFontInfo();
  27. }
  28. public void addLayoutManager(List lms) {
  29. // set start and end properties for this element, id, etc.
  30. int numChildren = this.children.size();
  31. for (int i = 0; i < numChildren; i++) {
  32. Object o = children.get(i);
  33. if (o instanceof FObj) {
  34. FObj fo = (FObj) o;
  35. fo.addLayoutManager(lms);
  36. }
  37. }
  38. }
  39. protected void addCharacters(char data[], int start, int length) {
  40. if(textInfo == null) {
  41. // Really only need one of these, but need to get fontInfo
  42. // stored in propMgr for later use.
  43. propMgr.setFontInfo(fontInfo);
  44. textInfo = propMgr.getTextLayoutProps(fontInfo);
  45. }
  46. FOText ft = new FOText(data, start, length, textInfo);
  47. ft.setLogger(log);
  48. addChild(ft);
  49. }
  50. public Status layout(Area area) throws FOPException {
  51. if (this.properties != null) {
  52. Property prop = this.properties.get("id");
  53. if (prop != null) {
  54. String id = prop.getString();
  55. if (this.marker == START) {
  56. if (area.getIDReferences() != null)
  57. area.getIDReferences().createID(id);
  58. this.marker = 0;
  59. }
  60. if (this.marker == 0) {
  61. if (area.getIDReferences() != null)
  62. area.getIDReferences().configureID(id, area);
  63. }
  64. }
  65. }
  66. int numChildren = this.children.size();
  67. for (int i = this.marker; i < numChildren; i++) {
  68. FONode fo = (FONode) children.get(i);
  69. Status status;
  70. if ((status = fo.layout(area)).isIncomplete()) {
  71. this.marker = i;
  72. return status;
  73. }
  74. }
  75. return new Status(Status.OK);
  76. }
  77. public CharIterator charIterator() {
  78. return new RecursiveCharIterator(this);
  79. }
  80. }