简体   繁体   English

如何将模板名称添加到 libreoffice writer 的状态栏?

[英]How do I add template name to status bar of libreoffice writer?

Here is a line from the file statusbar.xml from \share\config\soffice.cfg\modules\swriter\statusbar这是\share\config\soffice.cfg\modules\swriter\statusbar文件 statusbar.xml 中的一行

<statusbar:statusbaritem xlink:href=".uno:PageStyleName" statusbar:align="left" statusbar:autosize="true" statusbar:width="79"/>

I copied the file to user directory: \config\soffice.cfg\modules\swriter\statusbar我将文件复制到用户目录: \config\soffice.cfg\modules\swriter\statusbar

I just need to display Template Name from document properties.我只需要显示文档属性中的模板名称。 for eg ThisComponent.getDocumentProperties().TemplateName例如ThisComponent.getDocumentProperties().TemplateName

But adding this line does not work as expected.但是添加这一行并没有像预期的那样工作。 It creates a width of 79 pixels but does not show template name.它创建一个 79 像素的宽度,但不显示模板名称。

<statusbar:statusbaritem xlink:href=".uno:ThisComponent.getDocumentProperties().TemplateName" statusbar:align="left" statusbar:autosize="true" statusbar:width="79"/>

The purpose is to show current document's template name in status bar just like style name.目的是像样式名称一样在状态栏中显示当前文档的模板名称。


Update:更新:

I got this code from "Useful Macro Information For OpenOffice.org By Andrew Pitonyak".我从“Andrew Pitonyak 的 OpenOffice.org 的有用宏信息”中获得了这段代码。 It is working as expected.它按预期工作。 But it does not show any other items on status bar.但它不会在状态栏上显示任何其他项目。 I need TemplateName next to style name.我需要样式名称旁边的模板名称。

Function ProgressBar
  ProgressBar = ThisComponent.CurrentController.StatusIndicator
End Function

Sub StatusText()
  Dim sInformation 
  Dim iLen as Integer
  Dim iRest As Integer
  sInformation = ThisComponent.getDocumentProperties().TemplateName
  iLen=Len(sInformation)
  iRest=350-iLen
  ProgressBar.start(sInformation+SPACE(iRest),0)
End Sub

Those are UNO dispatcher commands, not Basic code.这些是 UNO 调度程序命令,而不是基本代码。 It looks like there are only a few that would work, such as .uno:CharFontName or .uno:FrameName .看起来只有少数可行,例如.uno:CharFontName.uno:FrameName Most UNO commands perform an action rather than getting information.大多数 UNO 命令执行操作而不是获取信息。

At https://forum.openoffice.org/en/forum/viewtopic.php?t=10104 , there is Basic macro code to set the status indicator:https://forum.openoffice.org/en/forum/viewtopic.php?t=10104 ,有设置状态指示器的基本宏代码:

ThisComponent.CurrentController.StatusIndicator.Start(vStatusBarText,0)

If it's possible to call a macro from statusbar.xml, then the syntax would be like this:如果可以从 statusbar.xml 调用宏,则语法如下所示:

xlink:href="vnd.sun.star.script:pythonSamples|TableSample.py$createTable?language=Python&amp;location=share" \
xlink:type="simple"

EDIT :编辑

Here is a Basic call example, from https://ask.libreoffice.org/t/how-to-translate-the-toolbar-into-multiple-languages/42404 :这是来自https://ask.libreoffice.org/t/how-to-translate-the-toolbar-into-multiple-languages/42404的基本调用示例:

xlink:href="vnd.sun.star.script:Standard.Module6.gerer_cadre_image1?language=Basic&amp;location=application"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM