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



System / libreoffice



set_list_item_prefix

set_list_item_prefix($list_item_prefix,$timeout=300); - Задать префикс для элементов списка

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

  • $list_item_prefix – Префикс для элементов списка
  • $timeout – Таймаут на исполнение операции, сек

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

    Пример использования
    <?php
    /**
     * Example for set_list_item_prefix function
     *
     * This example demonstrates how to set the prefix used for list items
     * when extracting list content from ODT files using the XHELibreOffice class.
     */
    
    // Scenario: Set the prefix used for list items when extracting list content from ODT files
    
    $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: Set a bullet point prefix
    echo "\n\nExample 1: Setting a bullet point prefix\n";
    $prefix = "• ";
    $result = SYSTEM::$libreOffice->set_list_item_prefix($prefix);
    
    if ($result) {
        echo "Successfully set list item prefix to: $prefix'\n";
    } else {
        echo "Error: Failed to set list item prefix.\n";
    }
    
    // Example 2: Test the prefix by extracting list content
    echo "\n\nExample 2: Testing the prefix by extracting list content\n";
    $filePath = "test/test_style.odt";
    $listCount = SYSTEM::$libreOffice->get_list_text_blocks_count_odt($filePath);
    
    if ($listCount > 0) {
        echo "Found $listCount lists. Extracting first list with bullet prefix:\n";
        
        $listText = SYSTEM::$libreOffice->get_list_text_block_by_index_odt($filePath, 0);
        if (!empty($listText)) {
            echo $listText . "\n";
        }
    } else if ($listCount == 0) {
        echo "No lists found in the document.\n";
    } else {
        echo "Error: Failed to count lists.\n";
    }
    
    // Quit the application
    WINDOW::$app->quit();
    
    ?>
    # Example for set_list_item_prefix function
    # 
    # This example demonstrates how to set the prefix used for list items
    # when extracting list content from ODT files 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.set_list_item_prefix</font><hr>")
    
    # Example 1: Set a bullet point prefix
    echo("Example 1: Setting a bullet point prefix\n");
    prefix = "• ";
    result = libreOffice.set_list_item_prefix(prefix);
    
    if result:
        echo("Successfully set list item prefix to: prefix'\n");
    else:
        echo("Error: Failed to set list item prefix.\n");
    
    
    # Example 2: Test the prefix by extracting list content
    echo("\nExample 2: Testing the prefix by extracting list content\n");
    filePath = "test/test_style.odt";
    listCount = libreOffice.get_list_text_blocks_count_odt(filePath);
    listCount = int(listCount)
    
    if listCount > 0:
        echo(f"Found {listCount} lists. Extracting first list with bullet prefix:\n");
        
        listText = libreOffice.get_list_text_block_by_index_odt(filePath, 0);
        if listText:
            echo(f"{listText} \n");
    elif listCount == 0:
        echo("No lists found in the document.\n");
    else:
        echo("Error: Failed to count lists.\n");
    
    # Quit
    app.quit()
    using System;
    
    /**
     * Example for set_list_item_prefix function
     *
     * This example demonstrates how to set the prefix used for list items
     * when extracting list content from ODT files using the XHELibreOffice class.
     */
    
    // Scenario: Set the prefix used for list items when extracting list content from ODT files
    
    namespace XHELibreOfficeExamples
    {
        class SetListItemPrefixExample
        {
            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->set_list_item_prefix.cs");
    
                // Example 1: Set a bullet point prefix
                Console.WriteLine("\n\nExample 1: Setting a bullet point prefix");
                string prefix = "• ";
                bool result = libreOffice.set_list_item_prefix(prefix);
    
                if (result)
                {
                    Console.WriteLine($"Successfully set list item prefix to: {prefix}'");
                }
                else
                {
                    Console.WriteLine("Error: Failed to set list item prefix.");
                }
    
                // Example 2: Test the prefix by extracting list content
                Console.WriteLine("\n\nExample 2: Testing the prefix by extracting list content");
                string filePath = "test/test_style.odt";
                int listCount = libreOffice.get_list_text_blocks_count_odt(filePath);
    
                if (listCount > 0)
                {
                    Console.WriteLine($"Found {listCount} lists. Extracting first list with bullet prefix:");
    
                    string listText = libreOffice.get_list_text_block_by_index_odt(filePath, 0);
                    if (!string.IsNullOrEmpty(listText))
                    {
                        Console.WriteLine(listText);
                    }
                }
                else if (listCount == 0)
                {
                    Console.WriteLine("No lists found in the document.");
                }
                else
                {
                    Console.WriteLine("Error: Failed to count lists.");
                }
    
                // Quit the application
                app.quit();
            }
        }
    }
    /**
     * Example for set_list_item_prefix function
     * 
     * This example demonstrates how to set the prefix used for list items
     * when extracting list content from ODT files using the XHELibreOffice class.
     */
    
    xhe_host = "127.0.0.1:7013";
    
    // подключим функциональные объекты, если еще не подключен
    require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>libreOffice.set_list_item_prefix</font><hr>");
    
    // Example 1: Set a bullet point prefix
    echo("Example 1: Setting a bullet point prefix\n");
    const prefix = "• ";
    const result = libreOffice.set_list_item_prefix(prefix);
    
    if (result) {
        echo("Successfully set list item prefix to: prefix'\n");
    } else {
        echo("Error: Failed to set list item prefix.\n");
    }
    
    // Example 2: Test the prefix by extracting list content
    echo("\nExample 2: Testing the prefix by extracting list content\n");
    const filePath = "test/test_style.odt";
    const listCount = libreOffice.get_list_text_blocks_count_odt(filePath);
    
    if (listCount > 0) {
        echo("Found " + listCount + " lists. Extracting first list with bullet prefix:\n");
        
        const listText = libreOffice.get_list_text_block_by_index_odt(filePath, 0);
        if (listText) {
            echo(listText + "\n");
        }
    } else if (listCount === 0) {
        echo("No lists found in the document.\n");
    } else {
        echo("Error: Failed to count lists.\n");
    }
    
    // Quit
    app.quit();

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