/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

module com { module sun { module star { module xml { module crypto { module sax {

/**
 * Interface of SAX Event Keeper.
 * <p>
 * This interface is used to manipulate element marks in a SAX event stream.
 * <p>
 * There are two kinds of element mark, one is element collector, which is
 * used to collect a particular element from the SAX event stream; the other
 * is blocker, which is used to block the SAX event stream.
 */
interface XSAXEventKeeper : com::sun::star::uno::XInterface
{
    /**
     * Adds a new element collector on the next element in the SAX event
     * stream.
     *
     * @return   the keeper id of the new element collector
     */
    long addElementCollector();

    /**
     * Removes an element collector.
     *
     * @param id   the keeper id of the element collector to be removed
     */
    void removeElementCollector([in] long id);

    /**
     * Adds a new blocker on the next element in the SAX event stream.
     * <p>
     * No SAX event starting from the next element will be forwarded until
     * this blocker is removed.
     *
     * @return   the keeper id of the new blocker
     */
    long addBlocker();

    /**
     * Removes a blocker
     *
     * @param id   the keeper id of the blocker to be removed
     */
    void removeBlocker([in] long id);

    /**
     * Checks whether the SAX event stream is blocking.
     *
     * @return   <code>true</code> if blocking, <code>false</code> otherwise
     */
    boolean isBlocking();

    /**
     * Gets the element of an element mark.
     *
     * @param id   the keeper id of the element mark, it can be an element
     *             collector or a blocker
     */
    com::sun::star::xml::wrapper::XXMLElementWrapper getElement([in] long id);

    /**
     * Sets the element of an element mark.
     * <p>
     * When an element is replaced outside of this interface, then uses this method
     * can restore the link between an element mark and its working element.
     *
     * @param id         the keeper id of the element mark to be set
     * @param aElement   the new element for this element mark.
     */
    void setElement(
        [in] long id,
        [in] com::sun::star::xml::wrapper::XXMLElementWrapper aElement);

    /**
     * Sets the next document handler in the SAX chain.
     * <p>
     * This handler will receive SAX events forwarded by the SAXEventKeeper.
     *
     * @param nextHandler   the next handler in the SAX chain
     * @return              the old next handler
     */
    com::sun::star::xml::sax::XDocumentHandler setNextHandler(
        [in] com::sun::star::xml::sax::XDocumentHandler nextHandler);

    /**
     * Prints information about all buffered elements.
     *
     * @return   a tree-style string including all buffer information
     */
    string printBufferNodeTree();

    /**
     * Gets the element which current blocking happens.
     * <p>
     * This element is the working element of the first blocker in tree order.
     *
     * @return   the current blocking element
     */
    com::sun::star::xml::wrapper::XXMLElementWrapper getCurrentBlockingNode();
};

} ; } ; } ; } ; } ; } ;

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
