LibreOffice Draw - 根据查询添加超链接 table

LibreOffice Draw -add hyperlinks based on query table

我正在使用绘图来标记 pdf 格式的索引图。所以在网格 99 中,文本超链接到 map99.pdf

有 1000 个网格单元 - 有没有办法让(宏)扫描 sheet 中的文本,就像

Text in File | Link to add
99|file:///c:/maps/map99.pdf
100|file:///c:/maps/map100.pdf

并在找到文本时添加指向相关文件的链接(99,100 等)。

我不太使用 libre,但很乐意实施任何程序化解决方案。

好的,使用游标后xray to drill through enumerated content, I finally have the answer. The code needs to create a text field。这是一个完整的工作解决方案:

Sub AddLinks
    Dim oDocument As Object
    Dim vDescriptor, vFound
    Dim numText As String, tryNumText As Integer
    Dim oDrawPages, oDrawPage
    Dim oField, oCurs
    Dim numChanged As Integer

    oDocument = ThisComponent
    oDrawPages = oDocument.getDrawPages()
    oDrawPage = oDrawPages.getByIndex(0)
    numChanged = 0
    For tryNumText = 1 to 1000
        vDescriptor = oDrawPage.createSearchDescriptor
        With vDescriptor
            '.SearchString = "[:digit:]+"  'Patterns work in search box but not here?
            .SearchString = tryNumText
        End With
        vFound = oDrawPage.findFirst(vDescriptor)
        If Not IsNull(vFound) Then
            numText = vFound.getString()
            oField = ThisComponent.createInstance("com.sun.star.text.TextField.URL") 
            oField.Representation = numText
            oField.URL = numText & ".pdf"
            vFound.setString("")
            oCurs = vFound.getText().createTextCursorByRange(vFound)
            oCurs.getText().insertTextContent(oCurs, oField, False)
            numChanged = numChanged + 1 
        End If
    Next tryNumText
    MsgBox("Added " & numChanged & " links.")
End Sub

要保存相关链接,请转至 File -> Export as PDF -> Links 并选中 Export URLs relative to file system.

我上传了一个有效的示例文件 here。出于某种原因,您的示例文件挂在我的系统上 -- 可能它太大了。

在 Writer 中用链接替换文本比在 Draw 中容易得多。但是 Writer 无法打开 PDF 文件。

https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=1401处有一些相关代码。