LibreOffice宏显示简单的TextBox形状 [英] LibreOffice macro showing simple TextBox shape

查看:84
本文介绍了LibreOffice宏显示简单的TextBox形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚(或找不到示例)如何在LibreOffice Calc 6.2中执行以下简单操作:

我在工作表(称为ShapeA)中具有图形形状(例如,简单的矩形),在另一工作表(称为TextboxB)中具有文本框形状.我要执行以下操作:当我单击ShapeA时,TextboxB必须出现在屏幕上(而不更改当前工作表,也许在对话框中),然后用鼠标单击将其关闭.

我想与ShapeA关联的宏可能看起来像这样:

  Sub MainoDrawPage = ThisComponent.getDrawPage()oTb = oDrawPage.getByName("TextBoxB")oTb.show()结束子 

有人可以建议我在此宏中添加什么以完成所描述的任务吗?

更新:我想完成的工作(回复吉姆·K.).

我的图表非常混乱,形状很多.每个形状都有一些与之相关的文本信息.每个形状或其周围没有足够的空间来包含此信息.因此,必须有一种方法可以显示有关每种形状的信息.此外,此信息还应该以预格式化的方式显示(它包含代码和其他结构化信息).

我的计划是为每个图表形状创建一个具有相关信息的文本框,将这些文本框放置在其他工作表中,并在查看图表时可以单击任何形状并在弹出的文本框中查看相关信息,而无需离开图表,然后通过简单的操作(例如,通过单击它)关闭文本框.

用LO的形状和宏来实现此任务听起来可行吗?

解决方案

如何:将所有内容放在同一张纸上,但在需要时隐藏文本框.

使用以下代码改编自

  1. 单击 ShapeA .(要再次关闭它,请单击 ShapeA TextBoxA ). ShapeB 的功能类似.

  1. 还可以同时显示两者.

I cannot figure out (or find an example) how to perform the following simple thing in the LibreOffice Calc 6.2:

I have a drawing shape (e.g. a simple rectangle) in a sheet (call it ShapeA) and a textbox shape in another sheet (call it TextboxB). I want to do the following: when I click on the ShapeA, the TextboxB must appear on the screen (without changing the current sheet, maybe in a dialog box) and then be closed with a mouse click.

I guess the macro associated with ShapeA could look something like this:

Sub Main
oDrawPage = ThisComponent.getDrawPage()
oTb = oDrawPage.getByName("TextBoxB")
oTb.show()
End Sub

Could someone advise what I should put into this macro to accomplish the described task?

UPDATE: What I want to accomplish ( in reply to Jim K.).

I have a very cluttered diagram with many shapes. Each shape has some textual information associated with it. There is not enough space on each shape or around it to contain this info. So there is must be a way to display this info about each shape. Also this information should be displayed in a preformatted way (it contains code and other structured info).

My plan is to create a textbox with the relevant information for each diagram shape, place these textboxes in other sheet and have a possibility, when viewing diagram, to click on any shape and view the associated info in the poped up textbox without leaving the diagram, and then close the textbox with a simple action (e.g. by clicking on it).

Does this task sound feasible to be realized with the LO's shapes and macros?

解决方案

How about this: Put everything on the same sheet but keep the text boxes hidden until needed.

Use the following code adapted from https://ask.libreoffice.org/en/question/93050/how-can-i-hideshow-a-shape-of-my-spreadsheet-using-a-macro/.

Sub ShapeClickedA
    ShowHideShape("TextBoxA")
End Sub
Sub ShapeClickedB
    ShowHideShape("TextBoxB")
End Sub

Sub ShowHideShape(shapeName As String)
    oDrawPage = ThisComponent.getSheets().getByName("Sheet1").getDrawPage()
    For iShape = 0 To oDrawPage.Count - 1
        oShape = oDrawPage.getByIndex(iShape)
        If oShape.Name = shapeName Then
            If oShape.Visible Then
                oShape.Visible = 0  'Not Visible
            Else
                oShape.Visible = 1  'Visible
            End If
        End If
    Next iShape
End Sub

If you haven't yet, set the names of the text boxes by right-clicking and choosing Name... Then right click on both ShapeA and TextBoxA and assign the macro ShapeClickedA. Do likewise for other pairs of shapes. The result works like this:

  1. Before anything is clicked.

  1. Click on ShapeA. (To close it again, click on either ShapeA or TextBoxA). ShapeB functions similarly.

  1. It's also possible to display both at the same time.

这篇关于LibreOffice宏显示简单的TextBox形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆