菜单

merge PPT by openoffice

2011年03月27日 - windows

below the only solution I can imagine for Impress slides. Maybe somebody else can come up with something simplier … seems OO API is quite complex here.

Sub Main

oDocOrig = StarDesktop.LoadComponentFromUrl(ConvertToUrl(“/home/fossie/orig.ppt”),”_default”,0,Array())

cSourceFolder = “/home/fossie/ppts/”
‘ This folder contains different ppt files, one slide in each file
‘———-

‘ Convert from pathname into a URL.
cSourceFolderUrl = ConvertToUrl( cSourceFolder )

oSimpleFileAccess = createUnoService( “com.sun.star.ucb.SimpleFileAccess” )
If Not oSimpleFileAccess.isFolder( cSourceFolderUrl ) Then
MsgBox( “You must specify a folder to convert, not a file.” )
Exit Sub
EndIf

‘ from another example, loops folder with subfolders, when file, process
‘ All sub-folders are also processed, so beware of passing
‘ oDocOrig = target file
DoFolder( oSimpleFileAccess, cSourceFolderUrl, oDocOrig  )

‘ oDocOrig ==> storeToUrl
End Sub

Sub DoFolder( oSimpleFileAccess, cFolderUrl, oDocOrig )

‘ Get an array of the names of items in this folder.
aFolderItems = oSimpleFileAccess.getFolderContents( cFolderUrl, True )

‘ Now iterate over each item in this folder.
For i = LBound( aFolderItems ) To UBound( aFolderItems )
‘ Get the name of an item in this cFolderUrl.
cFolderItemUrl = aFolderItems( i )

‘ Is this item a sub folder?
If oSimpleFileAccess.isFolder( cFolderItemUrl ) Then
‘ Process a sub-folder
DoFolder( oSimpleFileAccess, cFolderItemUrl, oDocOrig )
Else
‘ Process a file.
‘ maybe this check is not necessary
If oSimpleFileAccess.exists( cFolderItemUrl ) Then
‘ print the filename
‘ MsgBox( cFolderItemUrl )
‘ process the file
DoAFile( cFolderItemUrl, oDocOrig )
EndIf
EndIf
Next
End Sub

Sub DoAFile( cSourceDocUrl, oDocOrig )

‘ oList      = createUnoListener(“TopW_”, “com.sun.star.awt.XTopWindowListener”)

‘ oToolkit   = oDocOrig.CurrentController.Frame.ContainerWindow.Toolkit
‘ oToolkit.addTopWindowListener(oList)
MsgBox( cSourceDocUrl )
‘ oToolkit.removeTopWindowListener(oList)

oDoc1         = StarDesktop.LoadComponentFromUrl(cSourceDocUrl,”_default”,0,Array())
wait(500) ‘unsafe solution … unfortunately, OO has no reliable method to find out if LCFU is finished
oResIdP = createUnoService(“com.sun.star.drawing.framework.ResourceId”)
oResIdP.initialize(Array(“private:resource/floater/LeftImpressPane”))

dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)
oLeftPane1    = oDoc1.CurrentController.getPaneController().getPane(oResIdP)
oacSlideView1 = oLeftPane1.Window.AccessibleContext.getAccessibleChild(0)

oacSlideView1.grabFocus
oacSlideView1.clearAccessibleSelection()
oacSlideView1.selectAccessibleChild(0) ‘We want to copy slide #1…
oacSlideView1.getAccessibleChild(0).grabFocus

dispatcher.executeDispatch(oDoc1.CurrentController.Frame, “.uno:Copy”, “”, 0, Array())
oDoc1.dispose() ‘ close(true)

oLeftPane     = oDocOrig.CurrentController.getPaneController().getPane(oResIdP)
oacSlideView  = oLeftPane.Window.AccessibleContext.getAccessibleChild(0)

oacSlideView.grabFocus
oacSlideView.clearAccessibleSelection()
nLast = oacSlideView.AccessibleChildCount-1
oacSlideView.selectAccessibleChild(nLast)
oacSlideView.getAccessibleChild(nLast).grabFocus
oDoc1.dispose() ‘ close without saving

‘ cannot make it work to auto press the keys
‘ oList      = createUnoListener(“TopW_”, “com.sun.star.awt.XTopWindowListener”)
‘ oToolkit   = oDocOrig.CurrentController.Frame.ContainerWindow.Toolkit
‘ oToolkit.addTopWindowListener(oList)
dispatcher.executeDispatch(oDocOrig.CurrentController.Frame, “.uno:Paste”, “”, 0, Array())
wait(500)
‘ oToolkit.removeTopWindowListener(oList)

End Sub

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( “com.sun.star.beans.PropertyValue” )
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue = oPropertyValue
End Function

sub TopW_windowOpened(e as Object)
oACWin = e.source.AccessibleContext

for k=0 to oACWin.AccessibleChildCount-1
oACChild = oACWin.getAccessibleChild(k).AccessibleContext
‘ MsgBox( oACChild.AccessibleName )
if oACChild.AccessibleName = “OK” then
oACOK = oACChild
endif
if oACChild.AccessibleName = “Before” then
oACBefore = oACChild
endif
if oACChild.AccessibleName = “After” then
oACAfter = oACChild
endif
next k

‘oACBefore.doAccessibleAction(0)
oACAfter.doAccessibleAction(0)
oACOK.doAccessibleAction(0)
end sub

sub TopW_windowClosing(e as Object)
end sub

sub TopW_windowClosed(e as Object)
end sub

sub TopW_windowMinimized(e as Object)
end sub

sub TopW_windowNormalized(e as Object)
end sub

sub TopW_windowActivated(e as Object)
end sub

sub TopW_windowDeactivated(e as Object)
end sub

 

kiwano wrote:
Whatever it is, I’ve noticed that getPaneController seems to call just fine in OOo 2.4, but doesn’t work in OOo 3.0 (on Debian at least).

发表评论

电子邮件地址不会被公开。 必填项已用*标注