You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Jan Tosovsky <j....@email.cz> on 2020/11/04 23:08:29 UTC

Inserting index-keys into document

Dear All,

in a typical LayoutManager there are several operations needed for proper
handling of ID attribute. For index processing it is necessary do similar
operations also for index-key attribute.

These are snippets from WrapperLayoutManager:

(A) Linking ID to a specific page:

protected void addId() {
   getPSLM().addIDToPage(fobj.getId());
}

(B) Ensure area exists so ID can be cross referenced
    public void addAreas(PositionIterator posIter, LayoutContext context) {
        if (fobj.hasId()) {
            addId();
            InlineArea area = getEffectiveArea(context);
            parentLayoutManager.addChildArea(area);
        }
        ...
    }

(C) Set producerID trait

    public InlineArea get(LayoutContext context) {
        InlineArea area = new InlineArea();
        if (fobj.hasId()) {
            TraitSetter.setProducerID(area, fobj.getId());
        }
        return area;
    }

So, for index-key:
(A) Is it Ok to reuse this method for linking the index-key?

protected void addIndexKey() {
   getPSLM().addIDToPage(fobj.getIndexKey());
}

so I could then easily retrieve the page via 
int ordinalPageNumber = getPSLM().getFirstPVWithID(indexKey).getPageIndex();

(B) Is it Ok to modify 
    public void addAreas(PositionIterator posIter, LayoutContext context) {
        if (fobj.hasId() || fobj.hasIndexKey()) {
            if (fobj.hasId()) {
                addId();
            }
            if (fobj.hasIndexKey()) {
                addIndexKey();
            }
            InlineArea area = getEffectiveArea(context);
            parentLayoutManager.addChildArea(area);
        }

(C) Not sure what is the purpose of this trait, i.e. what does 'This can be
used to track back the generating FO node.' mean, but is this Ok?

    public InlineArea get(LayoutContext context) {
        InlineArea area = new InlineArea();
        if (fobj.hasId()) {
            TraitSetter.setProducerID(area, fobj.getId());
        } else if (fobj.hasIndexKey()) {
            TraitSetter.setProducerID(area, fobj.getIndexKey());
        }
        return area;
    }

These changes needs to be applied to all LMs for FO objects supporting
index-key attribute, so I am asking in advance. (I'll start just with few
LMs for initial experiments, so I can keep it now this way and update
afterwards).

Thanks,

Jan