Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

StorePagesModel.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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;
  18. // Java
  19. import java.util.List;
  20. // XML
  21. import org.xml.sax.SAXException;
  22. /**
  23. * This class stores all the pages in the document
  24. * for interactive agents.
  25. * The pages are stored and can be retrieved in any order.
  26. */
  27. public class StorePagesModel extends AreaTreeModel {
  28. private List pageSequence = null;
  29. private List currSequence;
  30. private List extensions = new java.util.ArrayList();
  31. /**
  32. * Create a new store pages model
  33. */
  34. public StorePagesModel() {
  35. }
  36. /**
  37. * Start a new page sequence.
  38. * This creates a new list for the pages in the new page sequence.
  39. * @param title the title of the page sequence.
  40. */
  41. public void startPageSequence(LineArea title) {
  42. if (pageSequence == null) {
  43. pageSequence = new java.util.ArrayList();
  44. }
  45. currSequence = new java.util.ArrayList();
  46. pageSequence.add(currSequence);
  47. }
  48. /**
  49. * Add a page.
  50. * @param page the page to add to the current page sequence
  51. */
  52. public void addPage(PageViewport page) {
  53. currSequence.add(page);
  54. }
  55. /**
  56. * Get the page sequence count.
  57. * @return the number of page sequences in the document.
  58. */
  59. public int getPageSequenceCount() {
  60. return pageSequence.size();
  61. }
  62. /**
  63. * Get the page count.
  64. * @param seq the page sequence to count.
  65. * @return returns the number of pages in a page sequence
  66. */
  67. public int getPageCount(int seq) {
  68. List sequence = (List) pageSequence.get(seq - 1);
  69. return sequence.size();
  70. }
  71. /**
  72. * Get the page for a position in the document.
  73. * @param seq the page sequence number
  74. * @param count the page count in the sequence
  75. * @return the PageViewport for the particular page
  76. */
  77. public PageViewport getPage(int seq, int count) {
  78. List sequence = (List) pageSequence.get(seq - 1);
  79. return (PageViewport) sequence.get(count);
  80. }
  81. /**
  82. * @see org.apache.fop.area.AreaTreeModel#handleExtension(TreeExt, int)
  83. */
  84. public void handleExtension(TreeExt ext, int when) {
  85. int seq, page;
  86. switch(when) {
  87. case TreeExt.IMMEDIATELY:
  88. seq = pageSequence == null ? 0 : pageSequence.size();
  89. page = currSequence == null ? 0 : currSequence.size();
  90. break;
  91. case TreeExt.AFTER_PAGE:
  92. break;
  93. case TreeExt.END_OF_DOC:
  94. break;
  95. }
  96. extensions.add(ext);
  97. }
  98. /**
  99. * Get the list of extensions that apply at a particular
  100. * position in the document.
  101. * @param seq the page sequence number
  102. * @param count the page count in the sequence
  103. * @return the list of extensions
  104. */
  105. public List getExtensions(int seq, int count) {
  106. return null;
  107. }
  108. /**
  109. * Get the end of document extensions for this stroe pages model.
  110. * @return the list of end extensions
  111. */
  112. public List getEndExtensions() {
  113. return extensions;
  114. }
  115. /**
  116. * End document, do nothing.
  117. */
  118. public void endDocument() throws SAXException {
  119. }
  120. }