/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef __com_sun_star_drawing_framework_XResourceId_idl__
#define __com_sun_star_drawing_framework_XResourceId_idl__

#ifndef __com_sun_star_uno_XInterface_idl__
#include <com/sun/star/uno/XInterface.idl>
#endif
#ifndef __com_sun_star_drawing_framework_AnchorBindingMode_idl__
#include <com/sun/star/drawing/framework/AnchorBindingMode.idl>
#endif
#ifndef __com_sun_star_util_URL_idl__
#include <com/sun/star/util/URL.idl>
#endif

module com { module sun { module star { module drawing { module framework {

/** A resource id uses a set of URLs to unambiguously specify a resource of
    the drawing framework.
    <p>Resources of the drawing framework are panes, views, tool bars, and
    command groups.  One URL describes the type of the actual resource.  A
    sequence of URLs (typically one, sometimes two) specifies its anchor,
    the resource it is bound to.  The anchor typically is a pane (for
    views), or it is empty (for panes).</p>
    <p>The resource URL may be empty.  In this case the anchor is empty,
    too.  Such an empty resource id does not describe a resource but rather
    the absence of one.  Instead of an empty <type>XResourceId</type> object
    an empty reference can be used in many places.</p>
    <p>The resource URL may have arguments that are passed to the factory
    method on its creation.  Arguments are only available through the
    getFullResourceURL().  The getResourceURL() method strips them away.</p>
*/
interface XResourceId
{
    /** Return the URL of the resource.  Arguments supplied on creation are
        stripped away.  Use getFullResourceURL() to access them.
    */
    string getResourceURL ();

    /** Return an URL object of the resource URL that may contain arguments.
    */
    com::sun::star::util::URL getFullResourceURL ();

    /** Return whether there is a non-empty anchor URL.  When this method
        returns <FALSE/> then getAnchorURLs() will return an empty list.
    */
    boolean hasAnchor ();

    /** Return a new XResourceId that represents the anchor resource.
    */
    XResourceId getAnchor ();

    /** Return the, possibly empty, list of anchor URLs.  The URLs are
        ordered so that the one in position 0 is the direct anchor of the
        resource, while the one in position i+1 is the direct anchor of the
        one in position i.
    */
    sequence<string> getAnchorURLs ();

    /** Return the type prefix of the resource URL.  This includes all up to
        and including the second slash.
    */
    string getResourceTypePrefix ();

    /** Compare the called <type>XResourceId</type> object with the given
        one.
        <p>The two resource ids A and B are compared so that if A<B (return
        value is -1) then either A and B are unrelated or A is a direct or
        indirect anchor of B.</p>
        <p>The algorithm for this comparison is quite simple. It uses a
        double lexicographic ordering.  On the lower level individual URLs
        are compared via the lexicographic order defined on strings.  On the
        higher level two resource ids are compared via a lexicographic order
        defined on the URLS.  So when there are two resource ids A1.A2
        (A1 being the anchor of A2) and B1.B2 then A1.A2<B1.B2 when A1<B1 or
        A1==B1 and A2<B2.  Resource ids may have different lengths: A1 <
        B1.B2 when A1<B1 or A1==B1 (anchors first then resources linked to them.</p>
        @param xId
            The resource id to which the called resource id is compared.
        @return
            Returns <const>0</const> when the called resource id is
            equivalent to the given resource id. Returns <code>-1</code> or
            <code>+1</code> when the two compared resource ids differ.
    */
    short compareTo (
        [in] XResourceId xId);

    /** Return whether the anchor of the called resource id object
        represents the same resource as the given object.
        <p>Note that not only the anchor of the given object is taken into
        account. The whole object, including the resource URL, is
        interpreted as anchor resource.</p>
        @param xAnchor
            The resource id of the anchor.
        @param eMode
            This mode specifies how the called resource has to be bound to
            the given anchor in order to have this function return <TRUE/>.
            <p>If eMode is <const>DIRECT</const> then the anchor of the called resource id
            has to be identical to the given anchor. If eMode is
            <const>INDIRECT</const> then the given anchor has to be a part
            of the anchor of the called resource.
    */
    boolean isBoundTo (
        [in] XResourceId xId,
        [in] AnchorBindingMode eMode);

    /** Return whether the anchor of the called resource id object
        represents the same resource as the given anchor URL. This is a
        convenience variant of the <member>isBoundTo()</member> function
        that can also be seen as an optimization for the case that the
        anchor consists of exactly one URL.
        @param xAnchor
            The resource URL of the anchor.
        @param eMode
            This mode specifies how the called resource has to be bound to
            the given anchor in order to have this function return. See the
            description of <member>isBoundTo()</member> for more
            information.
    */
    boolean isBoundToURL (
        [in] string sAnchorURL,
        [in] AnchorBindingMode eMode);

    /** Return a copy of the called resource id.  The caller becomes the
        owner of the new object.
    */
    XResourceId clone ();
};

}; }; }; }; }; // ::com::sun::star::drawing::framework

#endif
