/* -*- 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 .
 */

#ifndef __com_sun_star_xml_wrapper_xxmldocumentwrapper_idl_
#define __com_sun_star_xml_wrapper_xxmldocumentwrapper_idl_

#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/uno/Exception.idl>
#include <com/sun/star/xml/sax/XDocumentHandler.idl>

module com { module sun { module star { module xml { module wrapper {

interface XXMLElementWrapper;

/**
 * Interface of XML Document Wrapper.
 * <p>
 * When converting SAX events into a DOM tree, this interface is
 * used to manipulate the DOM data in UNO perspective.
 * <p>
 * Every language has its own methods to manipulate its native DOM
 * data structure, this interface provides a common method set which
 * each language have to implement.
 * <p>
 * In another word, this interface wraps language dependent methods,
 * then other component can manipulate DOM data through UNO methods.
 */
interface XXMLDocumentWrapper : com::sun::star::uno::XInterface
{
    /**
     * Gets the current element.
     *
     * @return   the current element in the SAX event stream
     */
    XXMLElementWrapper getCurrentElement();

    /**
     * Sets the current element.
     * <p>
     * When the current element is replaced outside of this interface, then
     * uses this method can update the current element pointer.
     *
     * @param element   the new current element
     */
    void setCurrentElement([in] XXMLElementWrapper element);

    /**
     * Removes the current element.
     * <p>
     * When the current element is removed, then its parent element becomes
     * the new current element.
     */
    void removeCurrentElement();

    /**
     * Checks whether an element is the current element.
     *
     * @param node   the element to be checked
     * @return       <code>true</code> if the node is the current element,
     *               <code>false</code> otherwise
     */
    boolean isCurrent([in] XXMLElementWrapper node);

    /**
     * Checks whether the current element is empty.
     *
     * @return   <code>true</code> if the current element is empty,
     *           <code>false</code> otherwise
     */
    boolean isCurrentElementEmpty();

    /**
     * Gets the name of the element.
     *
     * @param node   the element whose name will be gotten
     * @return       the name of the element
     */
    string getNodeName([in] XXMLElementWrapper node);

    /**
     * Clears all useless element in a branch of the DOM tree along the
     * tree order.
     *
     * @param node                  the start point of the branch to clear
     * @param reservedDescendants   an array including all elements that
     *                              need to be reserved (along their
     *                              ancestor path)
     * @param stopAtNode            the stop element. The operation have
     *                              to interrupt when this element is met
     *                              during clearing
     */
    void clearUselessData(
        [in] XXMLElementWrapper node,
        [in] sequence< XXMLElementWrapper > reservedDescendants,
        [in] XXMLElementWrapper stopAtNode);

    /**
     * Collapses a tree path
     * <p>
     * Each element in the ancestor path of the node will be checked,
     * if this element is empty, then deletes it.
     *
     * @param node   the start point of the path from where the tree
     *               path will be collapsed
     */
    void collapse([in] XXMLElementWrapper node);

    /**
     * Converts a part of the DOM tree into SAX events.
     *
     * @param handler                 the document handler which will receive
     *                                generated SAX events
     * @param saxEventKeeperHandler   the SAXEventKeeper connecting with
     *                                this XMLDocumentHandler
     * @param startNode               the start point to generate SAX events
     * @param endNode                 the end point where to stop generating
     */
    void generateSAXEvents(
        [in] com::sun::star::xml::sax::XDocumentHandler handler,
        [in] com::sun::star::xml::sax::XDocumentHandler saxEventKeeperHandler,
        [in] XXMLElementWrapper startNode,
        [in] XXMLElementWrapper endNode)
        raises(  com::sun::star::xml::sax::SAXException );

    /**
     * Converts the whole DOM tree into a SAX event stream.
     *
     * @param handler   the document handler which will receive the SAX event
     *                  stream
     */
    void getTree([in] com::sun::star::xml::sax::XDocumentHandler handler)
        raises(  com::sun::star::xml::sax::SAXException );

    /**
     * Rebuild the ID attribute in the branch starting from the particular
     * element.
     *
     * @param node   the root element of the branch whose ID link will be
     *               built
     */
    void rebuildIDLink([in] XXMLElementWrapper node);
};

} ; } ; } ; } ; } ;

#endif

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