エクステンション/soplayer
出典: OOoJa
Windows をお使いの方は、VBScript 版 VBScript/soplayer もお試しください。
[編集] soplayer 0.2 (OpenOffice.org BASIC 版)
OpenOffice.org のImpressファイルを開き、自動的にプレゼンテーションを開始し、そして終了後に自動的に閉じるエクステンションです。
[編集] 概要
OpenOffice.org だけでも -show オプションを使った以下のような手順
soffice -show "C:\Documents and Settings\Administrator\My Documents\example.odp"でImpressのファイルを開いて自動的にプレゼンテーションを開始できますが、その手順では、プレゼンテーション終了後にImpressのファイルが開いたまま残ります。これでは、複数のプレゼン資料を連続してお客様などへお見せするときなど、Impressのファイルをいちいち閉じなければいけませんので、あまりスマートとはいえません。
このエクステンション soplayer を使うと、いちいち閉じなくても、自動的に閉じてくれます。
[編集] 背景
このエクステンションは、yamaさんのご要望 スライドショーから始めたいがきっかけとなり、OpenOffice.org 1.1.x 用にまず開発されました。soplayer-macro-0.1.txt
最近になって、yamaさんからのご報告 スライドショーで で、2.3.1 ではうまく動作しないことがわかりました。
Impress のファイルを開くときにImpressファイルの表示を隠すために "Hidden" (隠す) 属性を True (真) に設定していました。そのようにしていると、OpenOffice.org 2.3 では、Impressファイルの表示が隠されるだけでなく、プレゼンそのものも隠されてしまい、プレゼンそのものが開始しないようです。OpenOffice.org 1.1.x のときは、Impressファイルの表示は隠されますが、プレゼンは表示されていました。
プレゼンが表示されないのではそもそも意味がありませんので、Impressファイルの内容が表示されてしまってもしかたがないとあきらめ、2.0 系用には、"Hidden" 属性を設定しないように変更してみました。
さらに、2.0 から機能追加された「エクステンション」というファイル形式にし、簡単にインストールできるようにしてみました。
名称 soplayer は、OpenOffice.org の前身である StarOffice に付属していた soplayer (StarOffice Player) の名前を踏襲してみました。
[編集] ダウンロード
soplayer-0.2.oxt
[編集] インストール方法
- OpenOffice.org 2.x がインストールされている Windows マシンを用意します。
- soplayer-0.2.oxt をダウンロードし、ディスク上に保存します。
- soplayer-0.2.oxt をダブルクリックします。すると「機能拡張マネージャー」が起動します。
- 「マイ拡張機能」に「soplayer-0.2.oxt」がインストールされたことを確認し、[閉じる]ボタンを押します。
[編集] 使い方
以下のような内容のテキストファイルを「メモ帳」などで作成します。保存する時にファイル名の拡張子を .bat とします。C: PATH=C:\Program Files\OpenOffice.org 2.3\program;%PATH% soffice -nologo macro:///soplayer.main.play("C:\Documents and Settings\Administrator\My Documents\example.odp")※1: C:\Program Files\OpenOffice.org 2.3\program の部分は、実際にインストールされている OpenOffice.org のパス名に置き換えてください。
※2: C:\Documents and Settings\Administrator\My Documents\example.odp の部分は、プレゼンするImpressのファイル名に置き換えてください。そのファイルをダブルクリックすると、プレゼンが始まります。
[編集] アンインストール方法
- OpenOffice.org を起動します。
- 「ツール」「機能拡張マネージャー」メニューを選びます。
- 「マイ拡張機能」の「+」マークをクリックし、「soplayer-0.2.oxt」をクリックします。
- [削除]ボタンを押します。
- 削除されたことを確認し、[閉じる]ボタンを押します。
[編集] ソースコード
参考までに、soplayer-0.2.oxt 内に保存されている OpenOffice.org BASIC プログラムのソースコードを以下に示します。
REM ***** BASIC *****
'
' soplayer - StarOffice Presentation Player
'
' Version 0.2 - December 13, 2007 by Takamichi Akiyama <tora@openoffice.org>
' Version 0.1 - July 30, 2004 by Takamichi Akiyama <tora@openoffice.org>
' License: GNU LGPL
'
' This extension loads an Impress file and starts presentation.
' When the presentation is finished, the document will be automatically closed.
'
' Usage
' PATH=C:\Program Files\OpenOffice.org 2.3\program;%PATH%
' soffice -nologo macro:///soplayer.main.play("C:\Documents and Settings\Administrator\My Documents\example.odp")
'
Option Explicit
Sub Test
play("C:\Documents and Settings\Administrator\My Documents\example.odp")
End Sub
Sub play(sFilename As String)
Dim oDoc As Object
Dim sUrl As String
'Dim Args(0) As New com.sun.star.beans.PropertyValue
'MsgBox sFilename
If (Not FileExists(sFilename)) Then
MsgBox sFilename & " does not exist."
Exit Sub
End If
sUrl = ConvertToURL(sFilename)
'Args(0).Name = "Hidden"
'Args(0).Value = True
'oDoc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, Args())
oDoc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, Array())
if HasUnoInterfaces(oDoc, "com.sun.star.presentation.XPresentationSupplier") Then
'debug oDoc
StartPresentation(oDoc)
'msgbox oDoc.Presentation.IsFullScreen
if (oDoc.Presentation.IsFullScreen) Then
do
Wait 1000
'MsgBox isOnGoing(oDoc)
loop While (isOnGoing(oDoc))
'msgbox "Finished"
oDoc.close(True)
End If
Else
MsgBox sFilename & " is not an Impress file."
End If
End Sub
Function isOnGoing(oDoc As Object) As Boolean
Dim xController As Object
Dim sTitle As String
Dim oDesktop As Object
Dim oComponents As Object
Dim nCount As Integer
Dim oEnumeration As Object
Dim oElement As Object
Dim xFrame As Object
xController = oDoc.getCurrentController()
sTitle = xController.getFrame().Title
'msgbox sTitle
nCount = 0
oDesktop = CreateUnoService("com.sun.star.frame.Desktop")
oComponents = oDesktop.getComponents()
if oComponents.hasElements() Then
oEnumeration = oComponents.createEnumeration()
do while (oEnumeration.hasMoreElements())
oElement = oEnumeration.nextElement()
if HasUnoInterfaces(oElement, "com.sun.star.presentation.XPresentationSupplier") Then
'debug oElement
xController = oElement.getCurrentController()
'debug xController
xFrame = xController.getFrame()
'debug xFrame
If xFrame.Title = sTitle Then
nCount = nCount + 1
End If
end if
loop
End If
isOnGoing = (nCount >= 2)
End Function
Sub StartPresentation(oDoc As Object)
Dim oPresentation As Object
oPresentation = oDoc.Presentation
'debug oPresentation
' http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/Presentation.html
oPresentation.AllowAnimations = True
oPresentation.CustomShow = ""
oPresentation.FirstPage = ""
oPresentation.IsAlwaysOnTop = True
oPresentation.IsAutomatic = False
oPresentation.IsEndless = False
oPresentation.IsFullScreen = True
'oPresentation.IsLivePresentation =
oPresentation.IsMouseVisible = True
'oPresentation.IsShowAll = True
oPresentation.IsTransitionOnClick = True
oPresentation.IsShowLogo = False
oPresentation.Pause = 1
oPresentation.StartWithNavigator = False
oPresentation.UsePen = True
oPresentation.Start()
End Sub
Sub debug(oObject as Object)
msgBox(oObject.dbg_properties)
Dim oProperties As Object
Dim sName As String
Dim oValue As Any
Dim sBuffer As String
Dim i As Integer
oProperties = oObject.getPropertySetInfo().getProperties()
if isEmpty(oProperties) Then
msgbox "This object has no Property"
else
for i = LBound(oProperties) To UBound(oProperties)
sName = oProperties(i).Name
oValue = oObject.getPropertyValue(sName)
'msgbox sName
if isObject(oValue) Then
sBuffer = sBuffer + sName + " is an object" + Chr(13)
'msgbox oValue.dbg_methods
elseif isEmpty(oValue) Then
sBuffer = sBuffer + sName + " is Empty" + Chr(13)
elseif isNull(oValue) Then
sBuffer = sBuffer + sName + " is Null" + Chr(13)
else
sBuffer = sBuffer + sName + "=" & Cstr(oValue) + Chr(13)
end if
next i
msgbox sBuffer
end if
msgBox(oObject.dbg_methods)
msgBox(oObject.dbg_supportedInterfaces)
end sub
