• 修改LibreOffice Draw中定义的样式名称


    目前我使用的是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
    
  • 相关阅读:
    apue学习笔记(第一章UNIX基础知识)
    批处理之发布新版本
    在Vista或Windows 7系统上安装Sharepoint 2007
    SharePoint Server 2007 简体中文下载
    sql连接字符串的方法
    共享本地的无线网络
    FastReport报表
    C# 语音识别(文字to语音、语音to文字)
    C#调用脚本语言(三)-- IronJS 与 IronLua 简单方法性能比较
    VS2010中出现无法嵌入互操作类型
  • 原文地址:https://www.cnblogs.com/quantumman/p/4749412.html
Copyright © 2020-2023  润新知