オープンオフィスのドキュメントをマイクロソフトオフィスのファイルに変換するとき、いちいちファイルに開けて、名前をつけて保存をするのが面倒なので、マクロを作りました。

使い方は下のコードを参照してください。




' OpenOfficeドキュメントをPDFに変換するマクロ
'
' バッチ処理用
'
' 使用例 : Unix の場合
'
' $ for i in `find . -type f -name *.doc -exec realpath {} \; `; \
' do ooffice -invisible macro:///Standard.ConvertToMacros.ConvertToPDF\($i\); \
' done
'
'
' @param strFile 入力ファイル名
'
' @author Osachan
' @version 1.0.0
' @since 1.0.0

Sub ConvertToPDF(strFile as string)
Dim oDoc as Object
Dim strFilterSubName as String

strUrl = ConvertToUrl( strFile )
oDoc = StarDesktop.loadComponentFromURL( strUrl, "_blank", 0, array(MakePropertyValue("Hidden",true)))

If not IsNull(oDoc) Then
strFilterSubName = ""
' select appropriate filter
If oDoc.SupportsService("com.sun.star.presentation.PresentationDocument") Then
strFilterSubName = "impress_pdf_Export"
ElseIf oDoc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then
strFilterSubName = "calc_pdf_Export"
ElseIf oDoc.SupportsService("com.sun.star.text.WebDocument") Then
strFilterSubName = "writer_web_pdf_Export"
ElseIf oDoc.SupportsService("com.sun.star.text.GlobalDocument") Then
strFilterSubName = "writer_globaldocument_pdf_Export"
ElseIf oDoc.SupportsService("com.sun.star.text.TextDocument") Then
strFilterSubName = "writer_pdf_Export"
ElseIf oDoc.SupportsService("com.sun.star.drawing.DrawingDocument") Then
strFilterSubName = "draw_pdf_Export"
ElseIf oDoc.SupportsService("com.sun.star.formula.FormulaProperties") Then
strFilterSubName = "math_pdf_Export"
ElseIf oDoc.SupportsService("com.sun.star.chart.ChartDocument") Then
strFilterSubName = "chart_pdf_Export"
Else
'
EndIf
EndIf

If Len(strFilterSubName) > 0 Then
oDoc.storeToUrl( ConvertToUrl( strFile & ".pdf" ), array(MakePropertyValue("FilterName", strFilterSubName ),MakePropertyValue("CompressMode", "1" )))
EndIf

oDoc.close(True)
End Sub

' Microsoft OfficeのドキュメントをOpen Office用ドキュメントに変換するマクロ
'
' バッチ処理用
'
' 使用例 : Unix の場合
'
' $ for i in `find . -type f -name *.doc -exec realpath {} \; `; \
' do ooffice -invisible macro:///Standard.ConvertToMacros.ConvertToOOO\($i\); \
' done
'
'
' @param strFile 入力ファイル名
'
' @author Osachan
' @version 1.0.0
' @since 1.0.0

Sub ConvertToOOO( strFile )
Dim oDoc as Object
Dim strFileExt as String
Dim strURL as String

strUrl = ConvertToUrl( strFile )
oDoc = StarDesktop.loadComponentFromURL( strUrl, "_blank", 0, array(MakePropertyValue("Hidden",true)))

If not IsNull(oDoc) Then
strFileExt = ""
' select appropriate filter
If oDoc.SupportsService("com.sun.star.presentation.PresentationDocument") Then
strFileExt = "odp"
ElseIf oDoc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then
strFileExt = "ods"
ElseIf oDoc.SupportsService("com.sun.star.text.GlobalDocument") Then
strFileExt = "odt"
ElseIf oDoc.SupportsService("com.sun.star.text.TextDocument") Then
strFileExt = "odt"
Else
'
EndIf
EndIf

If Len(strFileExt) > 0 Then

strURL = ConvertToURL( Left( strFile, Len( strFile ) - 3 ) & strFileExt )
oDoc.storeAsURL( strURL, Array() )

EndIf

oDoc.close( True )

End Sub

' Open Office用ドキュメントをMicrosoft Officeのドキュメントに変換するマクロ
'
' バッチ処理用
'
' 使用例 : Unix の場合
'
' $ for i in `find . -type f -name *.ods -exec realpath {} \; `; \
' do ooffice -invisible macro:///Standard.ConvertToMacros.ConvertToMS\($i\); \
' done
'
'
' @param strFile 入力ファイル名
'
' @author Osachan
' @version 1.0.0
' @since 1.0.0

Sub ConvertToMS( strFile )
Dim oDoc as Object
Dim strFileExt as String
Dim strURL as String
Dim strMsExtType as String

strUrl = ConvertToUrl( strFile )
oDoc = StarDesktop.loadComponentFromURL( strUrl, "_blank", 0, array(MakePropertyValue("Hidden",true)))

If not IsNull(oDoc) Then
strFilterSubName = ""
' select appropriate filter
If oDoc.SupportsService("com.sun.star.presentation.PresentationDocument") Then
strFileExt = "ppt"
strMsExtType = "MS Powerpoint 97"
ElseIf oDoc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then
strFileExt = "xls"
strMsExtType = "MS Excel 97"
ElseIf oDoc.SupportsService("com.sun.star.text.GlobalDocument") Then
strFileExt = "doc"
strMsExtType = "MS Word 97"
ElseIf oDoc.SupportsService("com.sun.star.text.TextDocument") Then
strFileExt = "doc"
strMsExtType = "MS Word 97"
Else
'
EndIf
EndIf

If Len(strFileExt) > 0 Then
strURL = ConvertToURL( Left( strFile, Len( strFile ) - 3 ) & strFileExt )
oDoc.storeAsURL( strURL, Array(_
MakePropertyValue( "FilterName", strMsExtType ),)
EndIf

oDoc.close( True )

End Sub


Function MakePropertyValue( Optional strName As String, Optional strValue ) As com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
If Not IsMissing( strName ) Then
oPropertyValue.Name = strName
EndIf
If Not IsMissing( strValue ) Then
oPropertyValue.Value = strValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
busyboxを入れて、次にスワップ領域を作成します。



# free
total used free shared buffers
Mem: 189916 175452 14464 0 4664
Swap: 0 0 0
Total: 189916 175452 14464
# dd if=/dev/zero of=/data/swap.swp count=32168
32168+0 records in
32168+0 records out
# dd if=/dev/zero of=/data/swap.swp count=32168
32168+0 records in
32168+0 records out
# losetup /dev/block/loop0 /data/swap.swp
# mkswap /dev/block/loop0
Setting up swapspace version 1, size = 16465920 bytes
UUID=89a6f846-5f41-4106-a97f-38782af06283
# swapon /dev/block/loop0
# free
total used free shared buffers
Mem: 189916 186920 2996 0 4620
Swap: 16076 0 16076
Total: 205992 186920 19072
#


気持ち早くなります。
ROOT化した恩恵の一つにマーケットへパッチをあてることにより、ローケルの変更ができます。
つまり世界中のアプリを手に入れることができます。

$とある五反田の取締役日記
手順は

(1)ここからまず、パッチを充てたバージョンのマーケットを手に入れます。

(2)次に以下のように、remount して /system以下を書き込み可能にし、ダウンロードしたファイルを /sysmte/app/Vending.apk にコピーします。

(3)再起動します




$ sudo adb shell
# mount -o remount,rw /dev/block/mtdblock3 /system
#
# mount
rootfs on / type rootfs (ro)
tmpfs on /dev type tmpfs (rw,mode=755)
devpts on /dev/pts type devpts (rw,mode=600)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /sqlite_stmt_journals type tmpfs (rw,size=4096k)
/dev/block/mtdblock3 on /system type yaffs2 (rw)
/dev/block/mtdblock5 on /data type yaffs2 (rw,nosuid,nodev)
/dev/block/mtdblock4 on /cache type yaffs2 (rw,nosuid,nodev)
/dev/block//vold/179:1 on /sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=1015,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8)
# exit
$
$ sudo adb push Vending-Tattoo-patched.apk /system/app/Vending.apk
1238 KB/s (1185434 bytes in 0.934s)
$ sudo adb reboot

再起動後にマーケットをチェックすると、起動に異常に時間がかかりますが、アプリケーションがたくさん増えているのに感動します。