libreoffice Writer Python脚本以设置查看布局列

发布于 2025-02-10 01:50:30 字数 1104 浏览 1 评论 0原文

对于Lo Writer中的文本文档,我希望一个快捷方式可以在1和2列之间切换视图。为此,我录制了两个宏 - 没有效果 - 所以我正在尝试使用Python。

Writer Menu.View.Zoom.Zoom菜单项打开Zoom并查看布局对话框。该对话框提供了两个面板: Zoom 查看布局

在Python脚本中,我们可以访问Current_controller.view_settings.zoomvalue... ZoomType,但我找不到查看布局值的方法。

在lo用户配置文件registrymodifications.xcu中,我们有这三行:

 <item oor:path="/org.openoffice.Office.Writer/Layout/Zoom"><prop oor:name="Type" oor:op="fuse"><value>0</value></prop></item>
 <item oor:path="/org.openoffice.Office.Writer/Layout/Zoom"><prop oor:name="Value" oor:op="fuse"><value>120</value></prop></item>
 
 <item oor:path="/org.openoffice.Office.Writer/Layout/ViewLayout"><prop oor:name="Columns" oor:op="fuse"><value>1</value></prop></item>

请注意,在layout下,两个缩放值直接通过view_settings访问(请参阅多于)。在同一级别上,我们有ViewLayout,但是在脚本中,我找不到访问我想成为的内容view_settings.viewlayout或view_settings.getProperty(...)

For text documents in LO writer I want a shortcut to toggle the view between 1 and 2 columns. To that end, I recorded two macros -- which had no effect -- so I'm trying with Python.

The Writer Menu.View.Zoom.Zoom menu item opens the Zoom and View Layout dialog. That dialog offers two panels: Zoom and View Layout

In a Python script we can access current_controller.view_settings.ZoomValue and ...ZoomType but I don't find a way to the View Layout values.

In the LO user config file registrymodifications.xcu we have these three lines:

 <item oor:path="/org.openoffice.Office.Writer/Layout/Zoom"><prop oor:name="Type" oor:op="fuse"><value>0</value></prop></item>
 <item oor:path="/org.openoffice.Office.Writer/Layout/Zoom"><prop oor:name="Value" oor:op="fuse"><value>120</value></prop></item>
 
 <item oor:path="/org.openoffice.Office.Writer/Layout/ViewLayout"><prop oor:name="Columns" oor:op="fuse"><value>1</value></prop></item>

Notice that the two zoom values are at the same level under Layout accessed in script directly through view_settings (see above). At that same level we have ViewLayout but in a script I have found no way of accessing what I would like to be view_settings.ViewLayout or view_settings.getProperty(...)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2025-02-17 01:50:30

我还没有学会使用Python来控制LO,但是应该可以致电调度员。我录制了一个宏,但没有发现正在修改的ViewLayout。查看您提供的信息,我想到了这一点,它努力更改为3列。

sub ViewLayout_3Col
    rem -----------------------------------------------
    rem define variables
    dim document   as object
    dim dispatcher as object
    rem -----------------------------------------------
    rem get access to the document
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    
    rem ----------------------------------------------
    dim args2(0) as new com.sun.star.beans.PropertyValue
    args2(0).Name = "ViewLayout.Columns"
    args2(0).Value = 3
    
    dispatcher.executeDispatch(document, ".uno:ViewLayout", "", 0, args2())
end sub

I haven't learned to use Python to control LO, but it should be possible to call the Dispatcher. I recorded a macro, but didn't find the ViewLayout being modified. Looking at information you provided, I came up with this, which worked to change to 3 columns.

sub ViewLayout_3Col
    rem -----------------------------------------------
    rem define variables
    dim document   as object
    dim dispatcher as object
    rem -----------------------------------------------
    rem get access to the document
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    
    rem ----------------------------------------------
    dim args2(0) as new com.sun.star.beans.PropertyValue
    args2(0).Name = "ViewLayout.Columns"
    args2(0).Value = 3
    
    dispatcher.executeDispatch(document, ".uno:ViewLayout", "", 0, args2())
end sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文