Ejemplo n.º 1
0
  /**
   * Counts the number of characters (text nodes) in this element excluding footnotes etc.
   *
   * @param node the node to count in
   * @return the number of characters
   */
  public static int getCharacterCount(Node node) {
    Node child = node.getFirstChild();
    int nCount = 0;
    while (child != null) {
      short nodeType = child.getNodeType();

      switch (nodeType) {
        case Node.TEXT_NODE:
          nCount += child.getNodeValue().length();
          break;

        case Node.ELEMENT_NODE:
          String sName = child.getNodeName();
          if (sName.equals(XMLString.TEXT_S)) {
            nCount += Misc.getPosInteger(Misc.getAttribute(child, XMLString.TEXT_C), 1);
          } else if (sName.equals(XMLString.TEXT_TAB_STOP)) {
            nCount++; // treat as single space
          } else if (sName.equals(XMLString.TEXT_TAB)) { // oasis
            nCount++; // treat as single space
          } else if (isNoteElement(child)) {
            // ignore
          } else if (isTextElement(child)) {
            nCount += getCharacterCount(child);
          }
      }
      child = child.getNextSibling();
    }
    return nCount;
  }
Ejemplo n.º 2
0
  private void handleListItem(Element node, LaTeXDocumentPortion ldp, Context oc) {
    // Are we ignoring this list?
    if (oc.isIgnoreLists()) {
      traverseBlockText(node, ldp, oc);
      return;
    }

    // Apply the style
    BeforeAfter ba = new BeforeAfter();
    palette
        .getListSc()
        .applyListItemStyle(
            oc.getListStyleName(),
            oc.getListLevel(),
            node.getNodeName().equals(XMLString.TEXT_LIST_HEADER),
            "true".equals(node.getAttribute(XMLString.TEXT_RESTART_NUMBERING)),
            Misc.getPosInteger(node.getAttribute(XMLString.TEXT_START_VALUE), 1) - 1,
            ba);

    // export the list item
    if (ba.getBefore().length() > 0) {
      ldp.append(ba.getBefore());
      if (config.formatting() >= LaTeXConfig.CONVERT_MOST) {
        ldp.nl();
      }
    }
    traverseBlockText(node, ldp, oc);
    if (ba.getAfter().length() > 0) {
      ldp.append(ba.getAfter()).nl();
    }
  }
 private String newItem(Set<String> suggestions) {
   XDialog xDialog = getDialog(getDialogLibraryName() + ".NewDialog");
   if (xDialog != null) {
     String[] sItems = Misc.sortStringSet(suggestions);
     DialogAccess ndlg = new DialogAccess(xDialog);
     ndlg.setListBoxStringItemList("Name", sItems);
     String sResult = null;
     if (xDialog.execute() == ExecutableDialogResults.OK) {
       DialogAccess dlg = new DialogAccess(xDialog);
       sResult = dlg.getTextFieldText("Name");
     }
     xDialog.endExecute();
     return sResult;
   }
   return null;
 }
    private void styleFamilyChange(DialogAccess dlg) {
      short nNewFamily = dlg.getListBoxSelectedItem("StyleFamily");
      if (nNewFamily > -1 && nNewFamily != nCurrentFamily) {
        // The user has changed the family; load and display the corresponding style names
        updateStyleMaps(dlg);
        nCurrentFamily = nNewFamily;
        sCurrentStyleName = null;

        String[] sStyleNames = Misc.sortStringSet(styleMap[nNewFamily].keySet());
        dlg.setListBoxStringItemList("StyleName", sStyleNames);
        if (sStyleNames.length > 0) {
          dlg.setListBoxSelectedItem("StyleName", (short) 0);
        } else {
          dlg.setListBoxSelectedItem("StyleName", (short) -1);
        }

        updateStyleControls(dlg);
        styleNameChange(dlg);
      }
    }
Ejemplo n.º 5
0
  private void loadStylesFromDOM(
      Document stylesDOM, Document contentDOM, boolean bAllParagraphsAreSoft) {
    // Flat xml: stylesDOM will be null and contentDOM contain everything
    // This is only the case for old versions of xmerge; newer versions
    // creates DOM for styles, content, meta and settings.
    NodeList list;

    // font declarations: Try old format first
    if (stylesDOM == null) {
      list = contentDOM.getElementsByTagName(XMLString.OFFICE_FONT_DECLS);
    } else {
      list = stylesDOM.getElementsByTagName(XMLString.OFFICE_FONT_DECLS);
    }
    // If that fails, try oasis format
    if (list.getLength() == 0) {
      if (stylesDOM == null) {
        list = contentDOM.getElementsByTagName(XMLString.OFFICE_FONT_FACE_DECLS);
      } else {
        list = stylesDOM.getElementsByTagName(XMLString.OFFICE_FONT_FACE_DECLS);
      }
    }

    if (list.getLength() != 0) {
      Node node = list.item(0);
      if (node.hasChildNodes()) {
        NodeList nl = node.getChildNodes();
        int nLen = nl.getLength();
        for (int i = 0; i < nLen; i++) {
          Node child = nl.item(i);
          if (child.getNodeType() == Node.ELEMENT_NODE) {
            if (child.getNodeName().equals(XMLString.STYLE_FONT_DECL)) {
              font.loadStyleFromDOM(child, false);
            } else if (child.getNodeName().equals(XMLString.STYLE_FONT_FACE)) {
              font.loadStyleFromDOM(child, false);
            }
          }
        }
      }
    }

    // soft formatting:
    if (stylesDOM == null) {
      list = contentDOM.getElementsByTagName(XMLString.OFFICE_STYLES);
    } else {
      list = stylesDOM.getElementsByTagName(XMLString.OFFICE_STYLES);
    }
    if (list.getLength() != 0) {
      loadStylesFromDOM(list.item(0), bAllParagraphsAreSoft);
    }

    // master styles:
    if (stylesDOM == null) {
      list = contentDOM.getElementsByTagName(XMLString.OFFICE_MASTER_STYLES);
    } else {
      list = stylesDOM.getElementsByTagName(XMLString.OFFICE_MASTER_STYLES);
    }
    if (list.getLength() != 0) {
      loadStylesFromDOM(list.item(0), bAllParagraphsAreSoft);
    }

    // hard formatting:
    // Load from styles.xml first. Problem: There may be name clashes
    // with automatic styles from content.xml
    if (stylesDOM != null) {
      list = stylesDOM.getElementsByTagName(XMLString.OFFICE_AUTOMATIC_STYLES);
      if (list.getLength() != 0) {
        loadStylesFromDOM(list.item(0), bAllParagraphsAreSoft);
      }
    }
    list = contentDOM.getElementsByTagName(XMLString.OFFICE_AUTOMATIC_STYLES);
    if (list.getLength() != 0) {
      loadStylesFromDOM(list.item(0), bAllParagraphsAreSoft);
    }

    // footnotes configuration:
    if (stylesDOM == null) {
      list = contentDOM.getElementsByTagName(XMLString.TEXT_FOOTNOTES_CONFIGURATION);
    } else {
      list = stylesDOM.getElementsByTagName(XMLString.TEXT_FOOTNOTES_CONFIGURATION);
    }
    if (list.getLength() != 0) {
      footnotes = new PropertySet();
      footnotes.loadFromDOM(list.item(0));
    }

    // endnotes configuration:
    if (stylesDOM == null) {
      list = contentDOM.getElementsByTagName(XMLString.TEXT_ENDNOTES_CONFIGURATION);
    } else {
      list = stylesDOM.getElementsByTagName(XMLString.TEXT_ENDNOTES_CONFIGURATION);
    }
    if (list.getLength() != 0) {
      endnotes = new PropertySet();
      endnotes.loadFromDOM(list.item(0));
    }

    // if it failed, try oasis format
    if (footnotes == null || endnotes == null) {
      if (stylesDOM == null) {
        list = contentDOM.getElementsByTagName(XMLString.TEXT_NOTES_CONFIGURATION);
      } else {
        list = stylesDOM.getElementsByTagName(XMLString.TEXT_NOTES_CONFIGURATION);
      }
      int nLen = list.getLength();
      for (int i = 0; i < nLen; i++) {
        String sClass = Misc.getAttribute(list.item(i), XMLString.TEXT_NOTE_CLASS);
        if ("endnote".equals(sClass)) {
          endnotes = new PropertySet();
          endnotes.loadFromDOM(list.item(i));
        } else {
          footnotes = new PropertySet();
          footnotes.loadFromDOM(list.item(i));
        }
      }
    }
  }
Ejemplo n.º 6
0
 private void loadStylesFromDOM(Node node, boolean bAllParagraphsAreSoft) {
   // node should be office:master-styles, office:styles or office:automatic-styles
   boolean bAutomatic = XMLString.OFFICE_AUTOMATIC_STYLES.equals(node.getNodeName());
   if (node.hasChildNodes()) {
     NodeList nl = node.getChildNodes();
     int nLen = nl.getLength();
     for (int i = 0; i < nLen; i++) {
       Node child = nl.item(i);
       if (child.getNodeType() == Node.ELEMENT_NODE) {
         if (child.getNodeName().equals(XMLString.STYLE_STYLE)) {
           String sFamily = Misc.getAttribute(child, XMLString.STYLE_FAMILY);
           if ("text".equals(sFamily)) {
             text.loadStyleFromDOM(child, bAutomatic);
           } else if ("paragraph".equals(sFamily)) {
             par.loadStyleFromDOM(child, bAutomatic && !bAllParagraphsAreSoft);
           } else if ("section".equals(sFamily)) {
             section.loadStyleFromDOM(child, bAutomatic);
           } else if ("table".equals(sFamily)) {
             table.loadStyleFromDOM(child, bAutomatic);
           } else if ("table-column".equals(sFamily)) {
             column.loadStyleFromDOM(child, bAutomatic);
           } else if ("table-row".equals(sFamily)) {
             row.loadStyleFromDOM(child, bAutomatic);
           } else if ("table-cell".equals(sFamily)) {
             cell.loadStyleFromDOM(child, bAutomatic);
           } else if ("graphics".equals(sFamily)) {
             frame.loadStyleFromDOM(child, bAutomatic);
           } else if ("graphic".equals(sFamily)) { // oasis
             frame.loadStyleFromDOM(child, bAutomatic);
           } else if ("presentation".equals(sFamily)) {
             presentation.loadStyleFromDOM(child, bAutomatic);
           } else if ("drawing-page".equals(sFamily)) {
             // Bug in OOo 1.x: The same name may be used for a real and an automatic style...
             if (drawingPage.getStyle(Misc.getAttribute(child, XMLString.STYLE_NAME)) == null) {
               drawingPage.loadStyleFromDOM(child, bAutomatic);
             }
           }
         } else if (child.getNodeName().equals(XMLString.STYLE_PAGE_MASTER)) { // old
           pageLayout.loadStyleFromDOM(child, bAutomatic);
         } else if (child.getNodeName().equals(XMLString.STYLE_PAGE_LAYOUT)) { // oasis
           pageLayout.loadStyleFromDOM(child, bAutomatic);
         } else if (child.getNodeName().equals(XMLString.STYLE_MASTER_PAGE)) {
           masterPage.loadStyleFromDOM(child, bAutomatic);
           if (firstMasterPage == null) {
             firstMasterPage =
                 (MasterPage) masterPage.getStyle(Misc.getAttribute(child, XMLString.STYLE_NAME));
           }
         } else if (child.getNodeName().equals(XMLString.TEXT_LIST_STYLE)) {
           list.loadStyleFromDOM(child, bAutomatic);
         } else if (child.getNodeName().equals(XMLString.TEXT_OUTLINE_STYLE)) {
           outline.loadStyleFromDOM(child);
         } else if (child.getNodeName().equals(XMLString.STYLE_DEFAULT_STYLE)) {
           String sFamily = Misc.getAttribute(child, XMLString.STYLE_FAMILY);
           if ("paragraph".equals(sFamily)) {
             StyleWithProperties defaultPar = new StyleWithProperties();
             defaultPar.loadStyleFromDOM(child);
             par.setDefaultStyle(defaultPar);
           } else if ("graphics".equals(sFamily) || "graphic".equals(sFamily)) { // oasis: no s
             StyleWithProperties defaultFrame = new StyleWithProperties();
             defaultFrame.loadStyleFromDOM(child);
             frame.setDefaultStyle(defaultFrame);
           } else if ("table-cell".equals(sFamily)) {
             StyleWithProperties defaultCell = new StyleWithProperties();
             defaultCell.loadStyleFromDOM(child);
             cell.setDefaultStyle(defaultCell);
           }
         }
       }
     }
   }
 }
Ejemplo n.º 7
0
  private void traverseContent(Element node) {
    // Handle this node first
    String sName = node.getTagName();
    if (sName.equals(XMLString.TEXT_P)) {
      // collectMasterPage(getParStyle(node.getAttribute(XMLString.TEXT_STYLE_NAME)));
    } else if (sName.equals(XMLString.TEXT_H)) {
      int nLevel;
      if (node.hasAttribute(XMLString.TEXT_OUTLINE_LEVEL)) {
        nLevel = Misc.getPosInteger(node.getAttribute(XMLString.TEXT_OUTLINE_LEVEL), 1);
      } else {
        nLevel = Misc.getPosInteger(node.getAttribute(XMLString.TEXT_LEVEL), 1);
      }
      StyleWithProperties style = getParStyle(node.getAttribute(XMLString.TEXT_STYLE_NAME));
      // collectMasterPage(style);
      if (1 <= nLevel && nLevel <= 10 && heading[nLevel] == null) {
        if (style != null && style.isAutomatic()) {
          heading[nLevel] = getParStyle(style.getParentName());
        } else {
          heading[nLevel] = style;
        }
      }
    } else if (sName.equals(XMLString.TEXT_SEQUENCE)) {
      String sSeqName = Misc.getAttribute(node, XMLString.TEXT_NAME);
      String sRefName = Misc.getAttribute(node, XMLString.TEXT_REF_NAME);
      if (sSeqName != null) {
        Element par = getParagraph(node);
        if (!sequenceNames.containsKey(par)) {
          // Only the first text:seqence should be registered as possible caption sequence
          sequenceNames.put(par, sSeqName);
        }
        if (sRefName != null) {
          seqrefNames.put(sRefName, sSeqName);
        }
      }
    } else if (sName.equals(XMLString.TEXT_FOOTNOTE_REF)) {
      collectRefName(footnoteRef, node);
    } else if (sName.equals(XMLString.TEXT_ENDNOTE_REF)) {
      collectRefName(endnoteRef, node);
    } else if (sName.equals(XMLString.TEXT_NOTE_REF)) { // oasis
      String sClass = Misc.getAttribute(node, XMLString.TEXT_NOTE_CLASS);
      if ("footnote".equals(sClass)) {
        collectRefName(footnoteRef, node);
      } else if ("endnote".equals(sClass)) {
        collectRefName(endnoteRef, node);
      }
    } else if (sName.equals(XMLString.TEXT_REFERENCE_MARK)) {
      collectMarkInHeading(referenceHeading, node);
    } else if (sName.equals(XMLString.TEXT_REFERENCE_MARK_START)) {
      collectMarkInHeading(referenceHeading, node);
    } else if (sName.equals(XMLString.TEXT_REFERENCE_REF)) {
      collectRefName(referenceRef, node);
    } else if (sName.equals(XMLString.TEXT_BOOKMARK)) {
      collectMarkInHeading(bookmarkHeading, node);
    } else if (sName.equals(XMLString.TEXT_BOOKMARK_START)) {
      collectMarkInHeading(bookmarkHeading, node);
    } else if (sName.equals(XMLString.TEXT_BOOKMARK_REF)) {
      collectRefName(bookmarkRef, node);
    } else if (sName.equals(XMLString.TEXT_SEQUENCE_REF)) {
      collectRefName(sequenceRef, node);
    } else if (sName.equals(XMLString.TEXT_A)) {
      String sHref = node.getAttribute(XMLString.XLINK_HREF);
      if (sHref != null && sHref.startsWith("#")) {
        links.add(sHref.substring(1));
      }
    } else if (sName.equals(XMLString.OFFICE_FORMS)) {
      forms.read(node);
    } else if (sName.equals(XMLString.TEXT_TABLE_OF_CONTENT)) {
      TocReader tocReader = new TocReader(node);
      indexes.put(node, tocReader);
      indexSourceStyles.addAll(tocReader.getIndexSourceStyles());
    } else if (sName.equals(XMLString.TEXT_TABLE_INDEX)
        || sName.equals(XMLString.TEXT_ILLUSTRATION_INDEX)) {
      LoftReader loftReader = new LoftReader(node);
      indexes.put(node, loftReader);
      if (loftReader.useCaption()) {
        if (loftReader.isTableIndex()) {
          tableSequenceNames.add(loftReader.getCaptionSequenceName());
        } else {
          figureSequenceNames.add(loftReader.getCaptionSequenceName());
        }
      }
    }
    // todo: other indexes

    // Traverse the children
    Node child = node.getFirstChild();
    while (child != null) {
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        traverseContent((Element) child);
      }
      child = child.getNextSibling();
    }

    // Collect automatic captions sequences
    // Use OOo defaults: Captions have style names Illustration and Table resp.
    if ((sAutoFigureSequenceName == null || sAutoTableSequenceName == null)
        && sName.equals(XMLString.TEXT_P)) {
      String sStyleName =
          getParStyles().getDisplayName(node.getAttribute(XMLString.TEXT_STYLE_NAME));
      if (sAutoFigureSequenceName == null) {
        if ("Illustration".equals(sStyleName)) {
          sAutoFigureSequenceName = getSequenceName(node);
        }
      }
      if (sAutoTableSequenceName == null) {
        if ("Table".equals(sStyleName)) {
          sAutoTableSequenceName = getSequenceName(node);
        }
      }
    }
  }
Ejemplo n.º 8
0
  private void loadContentFromDOM(Document contentDOM) {
    // Get the office:body element
    NodeList list = contentDOM.getElementsByTagName(XMLString.OFFICE_BODY);
    if (list.getLength() > 0) {
      // There may be several bodies, but the first one is the main body
      Element body = (Element) list.item(0);

      // Now get the content and identify the type of document
      content = Misc.getChildByTagName(body, XMLString.OFFICE_TEXT);
      if (content != null) { // OpenDocument Text
        bOpenDocument = true;
        bText = true;
      } else {
        content = Misc.getChildByTagName(body, XMLString.OFFICE_SPREADSHEET);
        if (content != null) { // OpenDocument Spreadsheet
          bOpenDocument = true;
          bSpreadsheet = true;
        } else {
          content = Misc.getChildByTagName(body, XMLString.OFFICE_PRESENTATION);
          if (content != null) { // OpenDocument Presentation
            bOpenDocument = true;
            bPresentation = true;
          } else {
            content = body;
            // OOo 1.x file format - look through content to determine genre
            bSpreadsheet = true;
            bPresentation = false;
            Node child = body.getFirstChild();
            while (child != null) {
              if (child.getNodeType() == Node.ELEMENT_NODE) {
                String sName = child.getNodeName();
                if (XMLString.TEXT_P.equals(sName)) {
                  bSpreadsheet = false;
                } else if (XMLString.TEXT_H.equals(sName)) {
                  bSpreadsheet = false;
                } else if (XMLString.TEXT_ORDERED_LIST.equals(sName)) {
                  bSpreadsheet = false;
                } else if (XMLString.TEXT_ORDERED_LIST.equals(sName)) {
                  bSpreadsheet = false;
                } else if (XMLString.TEXT_SECTION.equals(sName)) {
                  bSpreadsheet = false;
                } else if (XMLString.DRAW_PAGE.equals(sName)) {
                  bPresentation = true;
                  bSpreadsheet = false;
                } else if (XMLString.DRAW_PAGE.equals(sName)) {
                  bSpreadsheet = false;
                }
              }
              child = child.getNextSibling();
            }
            bText = !bSpreadsheet && !bPresentation;
          }
        }
      }

      traverseContent(body);

      if (sAutoFigureSequenceName != null) {
        addFigureSequenceName(sAutoFigureSequenceName);
      }
      if (sAutoTableSequenceName != null) {
        addTableSequenceName(sAutoTableSequenceName);
      }
    }

    /*if (firstMasterPage==null) {
        firstMasterPage = getMasterPage(sFirstMasterPageName);
    }*/
  }
Ejemplo n.º 9
0
  /**
   * Traverse block text (eg. content of body, section, list item). This is traversed in logical
   * order and dedicated handlers take care of each block element.
   *
   * <p>(Note: As a rule, all handling of block level elements should add a newline to the LaTeX
   * document at the end of the block)
   *
   * @param node The element containing the block text
   * @param ldp the <code>LaTeXDocumentPortion</code> to which LaTeX code should be added
   * @param oc the current context
   */
  public void traverseBlockText(Element node, LaTeXDocumentPortion ldp, Context oc) {
    Context ic = (Context) oc.clone();

    // The current paragraph block:
    StyleMap blockMap = config.getParBlockStyleMap();
    String sBlockName = null;

    if (node.hasChildNodes()) {
      NodeList list = node.getChildNodes();
      int nLen = list.getLength();

      for (int i = 0; i < nLen; i++) {
        Node childNode = list.item(i);

        if (childNode.getNodeType() == Node.ELEMENT_NODE) {
          Element child = (Element) childNode;
          String sTagName = child.getTagName();

          // Start/End a paragraph block (not in tables)
          if (!ic.isInTable()) {
            if (sTagName.equals(XMLString.TEXT_P)) {
              String sStyleName =
                  ofr.getParStyles().getDisplayName(child.getAttribute(XMLString.TEXT_STYLE_NAME));
              if (sBlockName != null && !blockMap.isNext(sBlockName, sStyleName)) {
                // end current block
                String sAfter = blockMap.getAfter(sBlockName);
                if (sAfter.length() > 0) ldp.append(sAfter).nl();
                sBlockName = null;
                ic.setVerbatim(false);
              }
              if (sBlockName == null && blockMap.contains(sStyleName)) {
                // start a new block
                sBlockName = sStyleName;
                String sBefore = blockMap.getBefore(sBlockName);
                if (sBefore.length() > 0) ldp.append(sBefore).nl();
                ic.setVerbatim(blockMap.getVerbatim(sStyleName));
              }
            } else if (sBlockName != null) {
              // non-paragraph: end current block
              String sAfter = blockMap.getAfter(sBlockName);
              if (sAfter.length() > 0) ldp.append(sAfter).nl();
              sBlockName = null;
              ic.setVerbatim(false);
            }
          }

          palette.getFieldCv().flushReferenceMarks(ldp, ic);
          palette.getIndexCv().flushIndexMarks(ldp, ic);

          palette.getInfo().addDebugInfo(child, ldp);

          // Basic block content; handle by this class
          if (sTagName.equals(XMLString.TEXT_P)) {
            // is this a caption?
            String sSequence = ofr.getSequenceName(child);
            if (ofr.isFigureSequenceName(sSequence)) {
              palette.getDrawCv().handleCaption(child, ldp, ic);
            } else if (ofr.isTableSequenceName(sSequence)) {
              // Next node *should* be a table
              if (i + 1 < nLen && Misc.isElement(list.item(i + 1), XMLString.TABLE_TABLE)) {
                // Found table with caption above
                palette.getTableCv().handleTable((Element) list.item(++i), child, true, ldp, ic);
              } else {
                // Found lonely caption
                palette.getTableCv().handleCaption(child, ldp, ic);
              }
            } else {
              palette.getParCv().handleParagraph(child, ldp, ic, i == nLen - 1);
            }
          } else if (sTagName.equals(XMLString.TEXT_H)) {
            palette.getHeadingCv().handleHeading(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_LIST)) { // oasis
            handleList(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_UNORDERED_LIST)) {
            handleList(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_ORDERED_LIST)) {
            handleList(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TABLE_TABLE)) {
            // Next node *could* be a caption
            if (i + 1 < nLen
                && Misc.isElement(list.item(i + 1), XMLString.TEXT_P)
                && ofr.isTableSequenceName(ofr.getSequenceName((Element) list.item(i + 1)))) {
              // Found table with caption below
              palette.getTableCv().handleTable(child, (Element) list.item(++i), false, ldp, oc);
            } else {
              // Found table without caption
              palette.getTableCv().handleTable(child, null, false, ldp, oc);
            }
          } else if (sTagName.equals(XMLString.TABLE_SUB_TABLE)) {
            palette.getTableCv().handleTable(child, null, true, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_SECTION)) {
            palette.getSectionCv().handleSection(child, ldp, ic);
          }

          // Draw elements may appear in block context if they are
          // anchored to page
          else if (sTagName.startsWith("draw:")) {
            palette.getDrawCv().handleDrawElement(child, ldp, ic);
          }

          // Indexes
          else if (sTagName.equals(XMLString.TEXT_TABLE_OF_CONTENT)) {
            palette.getIndexCv().handleTOC(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_ILLUSTRATION_INDEX)) {
            palette.getIndexCv().handleLOF(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_TABLE_INDEX)) {
            palette.getIndexCv().handleLOT(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_OBJECT_INDEX)) {
            palette.getIndexCv().handleObjectIndex(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_USER_INDEX)) {
            palette.getIndexCv().handleUserIndex(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_ALPHABETICAL_INDEX)) {
            palette.getIndexCv().handleAlphabeticalIndex(child, ldp, ic);
          } else if (sTagName.equals(XMLString.TEXT_BIBLIOGRAPHY)) {
            palette.getBibCv().handleBibliography(child, ldp, ic);
          }

          // Sequence declarations appear in the main text body (before the actual content)
          else if (sTagName.equals(XMLString.TEXT_SEQUENCE_DECLS)) {
            palette.getFieldCv().handleSequenceDecls(child);
          }
          // other tags are ignored
        }
      }
    }

    if (!oc.isInTable() && sBlockName != null) {
      // end current block
      String sAfter = blockMap.getAfter(sBlockName);
      if (sAfter.length() > 0) ldp.append(sAfter).nl();
      sBlockName = null;
    }
    palette.getFieldCv().flushReferenceMarks(ldp, ic);
    palette.getIndexCv().flushIndexMarks(ldp, ic);
  }