OpenOffice Basic

OpenOffice Basic (ранее известный как StarOffice Basic или StarBasic или OOoBasic) — это диалект языка программирования BASIC, впервые появившийся в офисном пакете StarOffice и получивший распространение с пакетом OpenOffice.org, а также с производными от него, такими как LibreOffice (в котором он известен как LibreOffice Basic).

Пример

Хотя OpenOffice Basic сам по себе похож на другие диалекты BASIC, такие как Microsoft VBA, его API сильно отличается, как показано в примере макроса ниже. В то время как есть гораздо более простой способ получить свойство документа «счётчик абзацев», в примере показан основной последовательный метод доступа к каждому абзацу текстового документа.

Sub ParaCount
'
' Подсчитать количество абзацев в текстовом документе
'
    Dim Doc As Object, Enum As Object, TextEl As Object, Count As Long
    Doc = ThisComponent
' Это текстовый документ?
    If Not Doc.SupportsService("com.sun.star.text.TextDocument") Then
        MsgBox "This macro must be run from a text document", 64, "Error"
        Exit Sub
    End If
    Count = 0
' Проверить каждый компонент: абзац или таблица?
    Enum = Doc.Text.CreateEnumeration
    While Enum.HasMoreElements
        TextEl = Enum.NextElement
' Является ли компонент абзацем?
        If TextEl.SupportsService("com.sun.star.text.Paragraph") Then
            Count = Count + 1
        End If
    Wend
'Display result
    MsgBox Count, 0, "Paragraph Count"
End Sub

Ссылки

BASIC Macros

OpenOffice.org API

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.