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.

UnresolvedPageNumber.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.area.inline;
  18. import org.apache.fop.area.PageViewport;
  19. import org.apache.fop.area.Resolveable;
  20. import java.util.List;
  21. /**
  22. * Unresolveable page number area.
  23. * This is a word area that resolves itself to a page number
  24. * from an id reference.
  25. */
  26. public class UnresolvedPageNumber extends TextArea implements Resolveable {
  27. private boolean resolved = false;
  28. private String pageRefId;
  29. /**
  30. * Create a new unresolveable page number.
  31. *
  32. * @param id the id reference for resolving this
  33. */
  34. public UnresolvedPageNumber(String id) {
  35. pageRefId = id;
  36. text = "?";
  37. }
  38. /**
  39. * Get the id references for this area.
  40. *
  41. * @return the id reference for this unresolved page number
  42. */
  43. public String[] getIDs() {
  44. return new String[] {pageRefId};
  45. }
  46. /**
  47. * Resolve this page number reference.
  48. * This resolves the reference by getting the page number
  49. * string from the first page in the list of pages that apply
  50. * for the id reference. The word string is then set to the
  51. * page number string.
  52. *
  53. * @param id the id reference being resolved
  54. * @param pages the list of pages for the id reference
  55. */
  56. public void resolve(String id, List pages) {
  57. resolved = true;
  58. if (pages != null) {
  59. PageViewport page = (PageViewport)pages.get(0);
  60. String str = page.getPageNumber();
  61. text = str;
  62. /**@todo Update IPD ??? */
  63. }
  64. }
  65. /**
  66. * Check if this is resolved.
  67. *
  68. * @return true when this has been resolved
  69. */
  70. public boolean isResolved() {
  71. return resolved;
  72. }
  73. }