Основной сайт хуманэмулятор.рф  |  Демо  |  Купить  |  API  |  Wiki



System / libreoffice



get_list_text_block_by_index_odt

get_list_text_block_by_index_odt($file_path,$list_index,$timeout=300); - Получить текст списка по порядковому номеру (отсчет с 0)

Функция на вход принимает параметры:

  • $file_path – Путь к файлу
  • $list_index – Индекс списка (отсчет с 0)
  • $timeout – Таймаут на исполнение операции, сек

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • результат – Текст списка или пустая строка, если индекс вне диапазона
  • пусто / null – ошибка

    Пример использования
    <?php
    // Scenario: Extract list text by index from an ODT document
    
    $xhe_host = getenv("RPABOT_HOST_URL");
    
    // подключим функциональные объекты, если еще не подключен
    if (!isset($path)){
        // Path to the init.php file for connecting to the XHE API
        $path = "../../../Templates/init.php";
        // Including init.php grants access to all classes and functionality for working with the XHE API
        require($path);
    }
    
    echo "\n<span >libreOffice->".basename (__FILE__)."</span>\n";
    
    // Example 1: Get the first list from a document
    echo "\n\nExample 1: Getting the first list from a document\n";
    $filePath = "test/test_style.odt";
    $listIndex = 0;
    $listText = SYSTEM::$libreOffice->get_list_text_block_by_index_odt($filePath, $listIndex);
    
    if (!empty($listText)) {
        echo "List $listIndex:\n$listText\n";
    } else {
        echo "No list found at index {$listIndex} or error occurred.\n";
    }
    
    // Example 2: Get the second list from a document
    echo "\n\nExample 2: Getting the second list from a document\n";
    $filePath = "test/test_style.odt";
    $listIndex = 1;
    $listText = SYSTEM::$libreOffice->get_list_text_block_by_index_odt($filePath, $listIndex);
    
    if (!empty($listText)) {
        echo "List $listIndex:\n$listText\n";
    } else {
        echo "No list found at index {$listIndex} or error occurred.\n";
    }
    
    // Quit the application
    WINDOW::$app->quit();
    
    ?>
    # Example for get_list_by_index_odt function
    # 
    # This example demonstrates how to extract list text by index from an ODT file
    # using the XHELibreOffice class.
    
    import sys
    # подключим функциональные объекты, если еще не подключен
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7013"
    from xweb_human_emulator import libreOffice, app, echo
    
    # начало
    echo("<hr><font color=blue>libreOffice->get_list_text_block_by_index_odt</font><hr>")
    
    # Example 1: Get the first list from a document
    echo("Example 1: Getting the first list from a document\n");
    filePath = "test/test_style.odt";
    listIndex = 0;
    listText = libreOffice.get_list_text_block_by_index_odt(filePath, listIndex);
    
    if listText:
        echo(f"List #{listIndex}:\nlistText\n");
    else:
        echo(f"No list found at index #{listIndex} or error occurred.\n");
    
    # Quit
    app.quit()
    using System;
    
    /**
     * Example for get_list_by_index_odt function
     *
     * This example demonstrates how to extract list text by index from an ODT file
     * using the XHELibreOffice class.
     */
    
    // Scenario: Extract list text by index from an ODT document
    
    namespace XHELibreOfficeExamples
    {
        class GetListTextBlockByIndexOdtExample
        {
            static void Main(string[] args)
            {
                string xheHost = "127.0.0.1:7010";
    
                // Initialize XHE API connection
                // In C#, you would initialize the XHE API client here
                // This is equivalent to including init.php in PHP
    
                Console.WriteLine("\nlibreOffice->get_list_text_block_by_index_odt.cs");
    
                // Example 1: Get the first list from a document
                Console.WriteLine("\n\nExample 1: Getting the first list from a document");
                string filePath = "test/test_style.odt";
                int listIndex = 0;
                string listText = libreOffice.get_list_text_block_by_index_odt(filePath, listIndex);
    
                if (!string.IsNullOrEmpty(listText))
                {
                    Console.WriteLine($"List {listIndex}:\n{listText}");
                }
                else
                {
                    Console.WriteLine($"No list found at index {listIndex} or error occurred.");
                }
    
                // Example 2: Get the second list from a document
                Console.WriteLine("\n\nExample 2: Getting the second list from a document");
                filePath = "test/test_style.odt";
                listIndex = 1;
                listText = libreOffice.get_list_text_block_by_index_odt(filePath, listIndex);
    
                if (!string.IsNullOrEmpty(listText))
                {
                    Console.WriteLine($"List {listIndex}:\n{listText}");
                }
                else
                {
                    Console.WriteLine($"No list found at index {listIndex} or error occurred.");
                }
    
                // Quit the application
                app.quit();
            }
        }
    }
    /**
     * Example for get_list_by_index_odt function
     * 
     * This example demonstrates how to extract list text by index from an ODT file
     * using the XHELibreOffice class.
     */
    
    xhe_host = "127.0.0.1:7013";
    
    // подключим функциональные объекты, если еще не подключен
    echo = require("../../../Templates JS/init.js");
    
    
    // Example 1: Get the first list from a document
    echo("Example 1: Getting the first list from a document\n");
    let filePath = "test/test_style.odt";
    let listIndex = 0;
    let listText = libreOffice.get_list_text_block_by_index_odt(filePath, listIndex);
    
    if (listText) {
        echo("List listIndex:\n" + listText + "\n");
    } else {
        echo("No list found at index " + listIndex + " or error occurred.\n");
    }
    
    // Example 2: Get the second list from a document
    echo("Example 2: Getting the second list from a document\n");
    filePath = "test/test_style.odt";
    listIndex = 1;
    listText = libreOffice.get_list_text_block_by_index_odt(filePath, listIndex);
    
    if (listText) {
        echo("List listIndex:\n" + listText + "\n");
    } else {
        echo("No list found at index " + listIndex + " or error occurred.\n");
    }
    
    // Quit
    app.quit();

    =============================================
    libreoffice    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .