如何在LibreOffice Writer状态栏添加并显示文档模板名称?
在LibreOffice Writer状态栏显示模板名称的问题
需求:在LibreOffice Writer的状态栏中,像显示样式名称那样显示当前文档的模板名称。
尝试1:修改statusbar.xml
- 从系统路径
\share\config\soffice.cfg\modules\swriter\statusbar获取statusbar.xml中样式名称状态栏项的代码片段:
<statusbar:statusbaritem xlink:href=".uno:PageStyleName" statusbar:align="left" statusbar:autosize="true" statusbar:width="79"/>
- 将该文件复制到用户目录
\config\soffice.cfg\modules\swriter\statusbar,并添加自定义状态栏项代码,试图通过调用文档属性获取模板名称:
<statusbar:statusbaritem xlink:href=".uno:ThisComponent.getDocumentProperties().TemplateName" statusbar:align="left" statusbar:autosize="true" statusbar:width="79"/>
结果:仅生成79像素宽度的状态栏区域,未成功显示模板名称。
尝试2:使用宏代码
从《Useful Macro Information For OpenOffice.org By Andrew Pitonyak》中获取以下宏代码:
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
结果:宏可以正常显示模板名称,但会隐藏状态栏的其他项目,无法实现“在样式名称旁显示”的需求。
内容的提问来源于stack exchange,提问作者shantanuo
相关产品推荐
相关产品推荐

