git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196818 13f79535-47bb-0310-9956-ffa450edef68pull/30/head
@@ -58,7 +58,7 @@ import java.io.IOException; | |||
import org.apache.fop.area.AreaTree; | |||
import org.apache.fop.area.AreaTreeModel; | |||
import org.apache.fop.extensions.Bookmarks; | |||
import org.apache.fop.fo.FOTreeControl; | |||
import org.apache.fop.fo.FOTreeEvent; | |||
import org.apache.fop.fo.FOTreeListener; | |||
@@ -101,6 +101,8 @@ public class Document implements FOTreeControl, FOTreeListener { | |||
public AreaTree areaTree; | |||
public AreaTreeModel atModel; | |||
private Bookmarks bookmarks; | |||
/** | |||
* Main constructor | |||
* @param driver the Driver object that is the "parent" of this Document | |||
@@ -348,5 +350,13 @@ public class Document implements FOTreeControl, FOTreeListener { | |||
return areaTree; | |||
} | |||
public void setBookmarks(Bookmarks bookmarks) { | |||
this.bookmarks = bookmarks; | |||
} | |||
public Bookmarks getBookmarks() { | |||
return bookmarks; | |||
} | |||
} | |||
@@ -579,7 +579,7 @@ public class Driver implements LogEnabled { | |||
/** LayoutStrategy is hard-wired for now, but needs to be made | |||
accessible through the API and/or configuration */ | |||
if (foInputHandler instanceof FOTreeHandler) { | |||
currentDocument.setLayoutStrategy(new LayoutManagerLS()); | |||
currentDocument.setLayoutStrategy(new LayoutManagerLS(currentDocument)); | |||
} | |||
treeBuilder.foTreeControl = currentDocument; | |||
try { |
@@ -50,11 +50,8 @@ | |||
*/ | |||
package org.apache.fop.extensions; | |||
import org.apache.fop.fo.FOTreeHandler; | |||
import org.apache.fop.fo.FONode; | |||
import org.apache.fop.fo.FOTreeVisitor; | |||
import org.apache.fop.area.AreaTree; | |||
import org.apache.fop.apps.Document; | |||
import java.util.ArrayList; | |||
@@ -65,7 +62,6 @@ import java.util.ArrayList; | |||
*/ | |||
public class Bookmarks extends ExtensionObj { | |||
private ArrayList outlines = new ArrayList(); | |||
private BookmarkData data; | |||
/** | |||
* Create a new Bookmarks object. | |||
@@ -88,40 +84,21 @@ public class Bookmarks extends ExtensionObj { | |||
} | |||
} | |||
/** | |||
* Get the data created for this bookmark. | |||
* | |||
* @return the bookmark data | |||
*/ | |||
public BookmarkData getData() { | |||
return data; | |||
} | |||
/** | |||
* When this element is finished then it can create | |||
* the bookmark data from the child elements and add | |||
* the extension to the area tree. | |||
*/ | |||
public void end() { | |||
getLogger().debug("adding bookmarks to area tree"); | |||
data = new BookmarkData(); | |||
for (int count = 0; count < outlines.size(); count++) { | |||
Outline out = (Outline)outlines.get(count); | |||
data.addSubData(out.getData()); | |||
} | |||
// add data to area tree for resolving and handling | |||
if (foInputHandler instanceof FOTreeHandler) { | |||
FOTreeHandler foth = (FOTreeHandler)foInputHandler; | |||
Document doc = (Document)foth.foTreeControl; | |||
AreaTree at = doc.getAreaTree(); | |||
at.addTreeExtension(data); | |||
data.setAreaTree(at); | |||
} | |||
getFOTreeControl().setBookmarks(this); | |||
} | |||
public void acceptVisitor(FOTreeVisitor fotv) { | |||
fotv.serveVisitor(this); | |||
} | |||
} | |||
public ArrayList getOutlines() { | |||
return outlines; | |||
} | |||
} |
@@ -55,6 +55,7 @@ package org.apache.fop.fo; | |||
import java.util.Map; | |||
// FOP | |||
import org.apache.fop.extensions.Bookmarks; | |||
import org.apache.fop.fonts.FontMetrics; | |||
/** | |||
@@ -77,4 +78,8 @@ public interface FOTreeControl { | |||
public Map getFonts(); | |||
public void setBookmarks(Bookmarks bookmarks); | |||
public Bookmarks getBookmarks(); | |||
} |
@@ -260,6 +260,10 @@ public class FObj extends FONode { | |||
foInputHandler = foih; | |||
} | |||
public FOInputHandler getFOInputHandler() { | |||
return foInputHandler; | |||
} | |||
/** | |||
* lets outside sources access the property list | |||
* first used by PageNumberCitation to find the "id" property |
@@ -51,6 +51,7 @@ | |||
package org.apache.fop.layout; | |||
import org.apache.fop.apps.Document; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.area.AreaTree; | |||
import org.apache.fop.fo.pagination.PageSequence; | |||
@@ -63,6 +64,11 @@ import org.apache.fop.fo.pagination.PageSequence; | |||
public abstract class LayoutStrategy { | |||
private String name = "undefined"; | |||
public Document document; | |||
public LayoutStrategy(Document document) { | |||
this.document = document; | |||
} | |||
/** | |||
* Returns the name of this LayoutStrategy. |
@@ -50,11 +50,15 @@ | |||
*/ | |||
package org.apache.fop.layoutmgr; | |||
import org.apache.fop.extensions.BookmarkData; | |||
import org.apache.fop.extensions.Outline; | |||
import org.apache.fop.apps.Document; | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.layout.LayoutStrategy; | |||
import org.apache.fop.area.AreaTree; | |||
import org.apache.fop.area.Title; | |||
import org.apache.fop.fo.pagination.PageSequence; | |||
import org.apache.fop.fo.FOTreeHandler; | |||
/** | |||
* The implementation of LayoutStrategy for the "redesign" or second generation | |||
@@ -64,6 +68,10 @@ public class LayoutManagerLS extends LayoutStrategy { | |||
private static String name = "layoutmgr"; | |||
public LayoutManagerLS(Document document) { | |||
super(document); | |||
} | |||
/** | |||
* Runs the formatting of this page sequence into the given area tree | |||
* | |||
@@ -86,6 +94,8 @@ public class LayoutManagerLS extends LayoutStrategy { | |||
return; | |||
} | |||
addBookmarksToAreaTree(); | |||
// Initialize if already used? | |||
// this.layoutMasterSet.resetPageMasters(); | |||
if (pageSeq.getPageSequenceMaster() != null) { | |||
@@ -121,4 +131,26 @@ public class LayoutManagerLS extends LayoutStrategy { | |||
pageSeq.getRoot().setRunningPageNumberCounter(pageSeq.getCurrentPageNumber()); | |||
} | |||
/** | |||
* When this element is finished then it can create | |||
* the bookmark data from the child elements and add | |||
* the extension to the area tree. | |||
*/ | |||
public void addBookmarksToAreaTree() { | |||
document.getDriver().getLogger().debug("adding bookmarks to area tree"); | |||
BookmarkData data = new BookmarkData(); | |||
for (int count = 0; count < document.getBookmarks().getOutlines().size(); count++) { | |||
Outline out = (Outline)(document.getBookmarks().getOutlines()).get(count); | |||
data.addSubData(out.getData()); | |||
} | |||
// add data to area tree for resolving and handling | |||
if (document.getBookmarks().getFOInputHandler() instanceof FOTreeHandler) { | |||
FOTreeHandler foth = (FOTreeHandler)document.getBookmarks().getFOInputHandler(); | |||
Document doc = (Document)foth.foTreeControl; | |||
AreaTree at = doc.getAreaTree(); | |||
at.addTreeExtension(data); | |||
data.setAreaTree(at); | |||
} | |||
} | |||
} |