create a new page, using OOoSF/Memo as a template.
Front page
Search
掲示板
Reload
Help
Browse Log
掲示板の使い方
OOo 掲示板3
OOo 掲示板2
OOo 掲示板
掲示板
雑談掲示板
New
List of pages
Recent changes
Backup
簡単ヘルプ
整形ルール
Start:
* スクリプティングフレームワークメモ [#n42bad03]
#contents
** コマンドライン引数 [#tf1fd21e]
コマンドラインから soffice を起動してマクロを実行すること...
OOo Basic のマクロでは次のようにして引数を与えて実行でき...
soffice "macro:///Standard.Module1.Test(Arg1,Arg2)"
スクリプティングフレームワークが実装されてからはマクロの...
vnd.sun.star.script:Library1.Macro1.bsh?language=BeanShe...
しかし、この形式の URL では独自の引数を渡すことができない...
macro:/// の形式で実行できる Basic のマクロから実行したい...
単純にマクロを引数を渡して invoke します。
以下のような形式の URI を指定すると Java、BeanShell、Java...
~/opt/ooo-dev3/program/soffice ~/Desktop/js.odt \
"vnd.sun.star.script:Library1.Macro1.js?language=JavaScr...
** ドキュメントにスクリプトを保存する [#j8db162d]
スクリプトプロバイダはマクロの実行方法は提供してくれます...
また、現在の python スクリプトプロバイダはドキュメント内...
ドキュメント内へのファイルのスクリプト書き込みは次のよう...
#code(basic){{
sub WriteDocumentScripts
' to get internal identifier of the document model
oTddcf = CreateUnoService( _
"com.sun.star.frame.TransientDocumentsDocumentContent...
oContent = oTddcf.createDocumentContent(ThisComponent)
oId = oContent.getIdentifier()
sId = oId.getContentIdentifier() ' vnd.sun.star.tdoc:/ID
'msgbox sId
oSfa = CreateUnoService("com.sun.star.ucb.SimpleFileAcc...
' check Scripts dir
sScriptsDir = sId & "/Scripts"
If NOT oSfa.exists(sScriptsDir) AND NOT oSfa.isFolder(s...
oSfa.createFolder(sScriptsDir)
End If
If NOT oSfa.exists(sScriptsDir) Then
msgbox "failed to create Scripts directory."
Exit Sub
End If
' get python directory
sPythonDir = sScriptsDir & "/python"
If NOT oSfa.exists(sPythonDir) AND NOT oSfa.isFolder(sP...
oSfa.createFolder(sPythonDir)
End If
If NOT oSfa.exists(sPythonDir) Then
msgbox "failed to create python directory."
Exit Sub
End If
sPythonDir = sPythonDir & "/"
' write script file
sScriptPath = sPythonDir & "hello.py"
If oSfa.exists(sScriptPath) Then
oSfa.kill(sScriptPath)
End If
'oIn = oSfa.openFileWrite(sScriptPath)
'oIn.closeInput()
' write script file
oPipe = CreateUnoService("com.sun.star.io.Pipe")
oTextOut = CreateUnoService("com.sun.star.io.TextOutput...
oTextOut.setOutputStream(oPipe)
' script
slf = chr(10)
sScript = "def hello():" & slf & _
" print('hello2')"
oTextOut.writeString(sScript)
oTextOut.flush()
oTextOut.closeOutput()
oSfa.writeFile(sScriptPath, oPipe)
oPipe.closeInput()
end sub
}}
End:
* スクリプティングフレームワークメモ [#n42bad03]
#contents
** コマンドライン引数 [#tf1fd21e]
コマンドラインから soffice を起動してマクロを実行すること...
OOo Basic のマクロでは次のようにして引数を与えて実行でき...
soffice "macro:///Standard.Module1.Test(Arg1,Arg2)"
スクリプティングフレームワークが実装されてからはマクロの...
vnd.sun.star.script:Library1.Macro1.bsh?language=BeanShe...
しかし、この形式の URL では独自の引数を渡すことができない...
macro:/// の形式で実行できる Basic のマクロから実行したい...
単純にマクロを引数を渡して invoke します。
以下のような形式の URI を指定すると Java、BeanShell、Java...
~/opt/ooo-dev3/program/soffice ~/Desktop/js.odt \
"vnd.sun.star.script:Library1.Macro1.js?language=JavaScr...
** ドキュメントにスクリプトを保存する [#j8db162d]
スクリプトプロバイダはマクロの実行方法は提供してくれます...
また、現在の python スクリプトプロバイダはドキュメント内...
ドキュメント内へのファイルのスクリプト書き込みは次のよう...
#code(basic){{
sub WriteDocumentScripts
' to get internal identifier of the document model
oTddcf = CreateUnoService( _
"com.sun.star.frame.TransientDocumentsDocumentContent...
oContent = oTddcf.createDocumentContent(ThisComponent)
oId = oContent.getIdentifier()
sId = oId.getContentIdentifier() ' vnd.sun.star.tdoc:/ID
'msgbox sId
oSfa = CreateUnoService("com.sun.star.ucb.SimpleFileAcc...
' check Scripts dir
sScriptsDir = sId & "/Scripts"
If NOT oSfa.exists(sScriptsDir) AND NOT oSfa.isFolder(s...
oSfa.createFolder(sScriptsDir)
End If
If NOT oSfa.exists(sScriptsDir) Then
msgbox "failed to create Scripts directory."
Exit Sub
End If
' get python directory
sPythonDir = sScriptsDir & "/python"
If NOT oSfa.exists(sPythonDir) AND NOT oSfa.isFolder(sP...
oSfa.createFolder(sPythonDir)
End If
If NOT oSfa.exists(sPythonDir) Then
msgbox "failed to create python directory."
Exit Sub
End If
sPythonDir = sPythonDir & "/"
' write script file
sScriptPath = sPythonDir & "hello.py"
If oSfa.exists(sScriptPath) Then
oSfa.kill(sScriptPath)
End If
'oIn = oSfa.openFileWrite(sScriptPath)
'oIn.closeInput()
' write script file
oPipe = CreateUnoService("com.sun.star.io.Pipe")
oTextOut = CreateUnoService("com.sun.star.io.TextOutput...
oTextOut.setOutputStream(oPipe)
' script
slf = chr(10)
sScript = "def hello():" & slf & _
" print('hello2')"
oTextOut.writeString(sScript)
oTextOut.flush()
oTextOut.closeOutput()
oSfa.writeFile(sScriptPath, oPipe)
oPipe.closeInput()
end sub
}}
Page: