修改LibreOffice Draw中定义的样式名称
2015-08-22 00:59
603 查看
目前我使用的是LibreOffice 4.2.4.2。经过以往的测试和使用经验,这是诸多版本中较为稳定和bug相对较少的。今天无意中发现该版本的LibreOffice Draw存在一个问题:样式名称修改后无法保存。于是,我便想到,既然在图形界面无法保存修改后的样式名称,那么能否用LibreOffice Basic宏命令试试看。事实证明,使用下面的代码则可以实现该功能。该函数会让用户依次指定欲修改样式所属的类别(Family)、样式名称、新的样式名称。由此也可以看出,LibreOffice也许在图形界面上存在一些bug,但是若通过宏命令直接调用底层的API,则可以有效地作用于文档,对相应的bug也是一个弥补。
' Change a style name with a new name. This solves the problem of changed style name in Draw cannot be saved. Sub ChangeStyleNames Dim style_family_name As String Dim style_name As String Dim style_new_name As String 'Names of styles. Array of string Dim oStyles 'Styles is interface com.sun.star.container.XNameAccess Dim oStyle style_family_name = InputBox("Style family name: ") If style_family_name <> "" Then If ThisComponent.StyleFamilies.hasByName(style_family_name) Then oStyles = ThisComponent.StyleFamilies.getByName(style_family_name) style_name = InputBox("Style name: ") If style_name <> "" Then If oStyles.hasByName(style_name) Then oStyle = oStyles.getByName(style_name) style_new_name = InputBox("New style name: ") If style_new_name <> "" And style_new_name <> style_name Then oStyle.setName(style_new_name) Else MsgBox "Please specify a new style name!", 0, "Warning" End If Else MsgBox "Cannot find the style: " + "test", 0, "Warning" End If Else MsgBox "Please specify a style name!", 0, "Warning" End If Else MsgBox "Style family name is invalid!", 0, "Error" End if Else MsgBox "Please specify a style family name!", 0, "Warning" End if End Sub
相关文章推荐
- table表格css样式
- CSS优先级
- [HTML] CSS 下拉列表菜单
- WEB基础之:CSS
- Qt鼠标事件 我的鼠标样式
- css3背景颜色渐变
- NumberPicker 样式设置
- CSS中行高line-height属性的一些使用技巧
- CSS学习笔记之定位
- css position
- css3 transform transition 实现照片墙效果
- CSS3:绘制图形
- CSS实现绝对底部一个完美解决方案
- HTML简介(css简单的样式)
- 网页样式(css+js)tab自动切换的minisite
- css3 display:box
- CSS 3层嵌套居中布局
- CSS float 父元素高度自适应
- css3选择器
- RunJS推荐用于个人使用(使用方便JS、css实时预览、编辑、管理等功能)