Top > OOobbs2 > 49

OOobbs2/49 Edit

  • サマリ: Writerの「マクロの記録」で作成したマクロをWriter/Webの「HTMLソーステキスト」で使いたい
  • 環境: Writer
  • 状態: 未解決
  • 投稿者: アポロ?
  • 投稿日: 2007-07-19 (木) 18:50:47

質問 Edit

Writerで「マクロの記録」でHTMLのルビを作成するマクロを作成したのですが、このマクロをWriter/Webの「HTMLソーステキスト」で実行してもうまく動作しませんでした。表示を「Webレイアウト」にしているときにはうまく動作します。「HTMLソーステキスト」でも使えるようにするには、どのようにすればいいのでしょうか? 以下に作成したソースをコピーしておきます。

Sub ruby

rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Text"
args2(0).Value = "<ruby><rb>"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args2())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Text"
args4(0).Value = "</rp><ruby>"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args4())

rem ----------------------------------------------------------------------
dim args5(18) as new com.sun.star.beans.PropertyValue
args5(0).Name = "SearchItem.StyleFamily"
args5(0).Value = 2
args5(1).Name = "SearchItem.CellType"
args5(1).Value = 0
args5(2).Name = "SearchItem.RowDirection"
args5(2).Value = true
args5(3).Name = "SearchItem.AllTables"
args5(3).Value = false
args5(4).Name = "SearchItem.Backward"
args5(4).Value = true
args5(5).Name = "SearchItem.Pattern"
args5(5).Value = false
args5(6).Name = "SearchItem.Content"
args5(6).Value = false
args5(7).Name = "SearchItem.AsianOptions"
args5(7).Value = false
args5(8).Name = "SearchItem.AlgorithmType"
args5(8).Value = 0
args5(9).Name = "SearchItem.SearchFlags"
args5(9).Value = 65536
args5(10).Name = "SearchItem.SearchString"
args5(10).Value = "<rb>"
args5(11).Name = "SearchItem.ReplaceString"
args5(11).Value = ""
args5(12).Name = "SearchItem.Locale"
args5(12).Value = 255
args5(13).Name = "SearchItem.ChangedChars"
args5(13).Value = 2
args5(14).Name = "SearchItem.DeletedChars"
args5(14).Value = 2
args5(15).Name = "SearchItem.InsertedChars"
args5(15).Value = 2
args5(16).Name = "SearchItem.TransliterateFlags"
args5(16).Value = 1280
args5(17).Name = "SearchItem.Command"
args5(17).Value = 0
args5(18).Name = "Quiet"
args5(18).Value = true

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args5())

rem ----------------------------------------------------------------------
dim args6(18) as new com.sun.star.beans.PropertyValue
args6(0).Name = "SearchItem.StyleFamily"
args6(0).Value = 2
args6(1).Name = "SearchItem.CellType"
args6(1).Value = 0
args6(2).Name = "SearchItem.RowDirection"
args6(2).Value = true
args6(3).Name = "SearchItem.AllTables"
args6(3).Value = false
args6(4).Name = "SearchItem.Backward"
args6(4).Value = false
args6(5).Name = "SearchItem.Pattern"
args6(5).Value = false
args6(6).Name = "SearchItem.Content"
args6(6).Value = false
args6(7).Name = "SearchItem.AsianOptions"
args6(7).Value = false
args6(8).Name = "SearchItem.AlgorithmType"
args6(8).Value = 1
args6(9).Name = "SearchItem.SearchFlags"
args6(9).Value = 65536
args6(10).Name = "SearchItem.SearchString"
args6(10).Value = "[((]"
args6(11).Name = "SearchItem.ReplaceString"
args6(11).Value = ""
args6(12).Name = "SearchItem.Locale"
args6(12).Value = 255
args6(13).Name = "SearchItem.ChangedChars"
args6(13).Value = 2
args6(14).Name = "SearchItem.DeletedChars"
args6(14).Value = 2
args6(15).Name = "SearchItem.InsertedChars"
args6(15).Value = 2
args6(16).Name = "SearchItem.TransliterateFlags"
args6(16).Value = 1280
args6(17).Name = "SearchItem.Command"
args6(17).Value = 0
args6(18).Name = "Quiet"
args6(18).Value = true

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args6())

rem ----------------------------------------------------------------------
dim args7(1) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Count"
args7(0).Value = 1
args7(1).Name = "Select"
args7(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args7())

rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "Text"
args8(0).Value = "</rb><rp>"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args8())

rem ----------------------------------------------------------------------
dim args9(1) as new com.sun.star.beans.PropertyValue
args9(0).Name = "Count"
args9(0).Value = 1
args9(1).Name = "Select"
args9(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args9())

rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Text"
args10(0).Value = "</rp><rt>"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args10())

rem ----------------------------------------------------------------------
dim args11(18) as new com.sun.star.beans.PropertyValue
args11(0).Name = "SearchItem.StyleFamily"
args11(0).Value = 2
args11(1).Name = "SearchItem.CellType"
args11(1).Value = 0
args11(2).Name = "SearchItem.RowDirection"
args11(2).Value = true
args11(3).Name = "SearchItem.AllTables"
args11(3).Value = false
args11(4).Name = "SearchItem.Backward"
args11(4).Value = false
args11(5).Name = "SearchItem.Pattern"
args11(5).Value = false
args11(6).Name = "SearchItem.Content"
args11(6).Value = false
args11(7).Name = "SearchItem.AsianOptions"
args11(7).Value = false
args11(8).Name = "SearchItem.AlgorithmType"
args11(8).Value = 1
args11(9).Name = "SearchItem.SearchFlags"
args11(9).Value = 65536
args11(10).Name = "SearchItem.SearchString"
args11(10).Value = "[))]"
args11(11).Name = "SearchItem.ReplaceString"
args11(11).Value = ""
args11(12).Name = "SearchItem.Locale"
args11(12).Value = 255
args11(13).Name = "SearchItem.ChangedChars"
args11(13).Value = 2
args11(14).Name = "SearchItem.DeletedChars"
args11(14).Value = 2
args11(15).Name = "SearchItem.InsertedChars"
args11(15).Value = 2
args11(16).Name = "SearchItem.TransliterateFlags"
args11(16).Value = 1280
args11(17).Name = "SearchItem.Command"
args11(17).Value = 0
args11(18).Name = "Quiet"
args11(18).Value = true

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args11())

rem ----------------------------------------------------------------------
dim args12(1) as new com.sun.star.beans.PropertyValue
args12(0).Name = "Count"
args12(0).Value = 1
args12(1).Name = "Select"
args12(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args12())

rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "Text"
args13(0).Value = "</rt><rp>"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args13())

End Sub

回答 Edit

  • .uno:InsertText が動いてないみたいなので無理です。また、CurrentController からビューカーソルが使えないのに加えて、ThisComponent からテキストオブジェクトを取得すると Web レイアウトのテキストインターフェースが戻ってきているので、マクロで文字列を挿入するのはどちらにしろ無理なようです。 -- はにゃ?? 2007-07-19 (木) 21:30:50

感想,コメント,メモ Edit



Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes