/* -*- 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 accessibility {

/** Implement this interface to provide a mapping between text index
    and line numbers.

    <p>This interface is typically used in conjunction with the
    XAccessibleText interface and extends it with a notion
    of line numbers</p>

    @since OOo 3.0
*/

interface XAccessibleMultiLineText
    : ::com::sun::star::accessibility::XAccessibleText
{
    /** Returns the line number at the specified index.

        <p>For a text object that is spread over multiple lines, this method
        provides a mapping from a text index to the corresponding line number.
        </p>

        @param nIndex
            Index for which the line number should be returned.
            The valid range is 0..length.

        @return
            Returns the line number of the specified text index.

        @throws ::com::sun::star::lang::IndexOutOfBoundsException
            if the index is invalid.
    */
    long getLineNumberAtIndex([in] long nIndex)
        raises (::com::sun::star::lang::IndexOutOfBoundsException);

    /** Returns the text of the specified line.

        <p>Returns the substring of text that makes up the specified line
        number.</p>

        <p>The number of lines can be obtained by calling
        XAccessibleMultiLineText::getLineNumberAtIndex()
        with the index of the last character. In a loop, the last line
        has been reached when TextSegment::SegmentEnd
        of the returned value is equal to the index of the last
        character of the text.</p>

        @param nLineNo
            The number of the line to return the substring from.
            The valid range is 0..getLineNumberAtIndex(getCharacterCount()).

        @return
            Returns the requested text portion.  This portion may be empty
            or invalid when no appropriate text portion is found.

        @throws ::com::sun::star::lang::IndexOutOfBoundsException
            if the line number is invalid
    */

    TextSegment getTextAtLineNumber([in] long nLineNo)
        raises (::com::sun::star::lang::IndexOutOfBoundsException);

    /** Returns the text of the line in which the caret is located.

        <p>The substring returned will most of the time be identical to
        calling XAccessibleText::getTextAtIndex() with
        the index returned by XAccessibleText::getCaretPosition()
        and type AccessibleTextType::LINE beside the
        following special case:</p>

        <p>Some text implementations place the caret at the end of the current
        line when the <b>End</b> key gets pressed. Since the index of this position
        is identical to the one of the first character of the following line,
        XAccessibleMultiLineText::getLineNumberAtIndex() will
        return the line following the current one in this case.</p>

        @return
            Returns the requested text portion. This portion may be empty
            or invalid if the paragraph object does not have a valid caret
            position.
    */

    TextSegment getTextAtLineWithCaret();

    /** Returns the number of the line in which the caret is located.

        <p>The line number returned will most of the time be identical to
        calling XAccessibleMultiLineText::getLineNumberAtIndex()
        with the index returned by XAccessibleText::getCaretPosition()
        beside the following special case:</p>

        <p>Some text implementations place the caret at the end of the current
        line when the <b>End</b> key gets pressed. Since the index of this position
        is identical to the one of the first character of the following line,
        XAccessibleMultiLineText::getLineNumberAtIndex() will
        return the line following the current one in this case.</p>

        @return
            Returns the index of the line in which the caret is located or -1
            if the paragraph does not have a valid caret position.
    */

    long getNumberOfLineWithCaret();
};

}; }; }; };

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