dim sTempDir as String dim iFile as Integer dim bMakeVisible as Boolean dim bTryClose as Boolean dim bTrySaving as Boolean Sub Main '************************************************************ ' These variables can be adjusted for own purposes. ' Please edit these lines only! sTempDir = "d:\temp\" ' system path to local temp dir with(!) trailing path seperator! bMakeVisible = false ' tries to show all (may be hidden) frames bTryClose = false ' tries to close all frames explicitly like Desktop.terminate() it does bTrySaving = false ' tries to save every open document into temp. directory using a generated file name '************************************************************ sFile = sTempDir+"shutdown.log" if FileExists(sFile) then Kill sFile endif iFile = FreeFile open sFile for output as #iFile dumpFrameList(StarDesktop.getFrames()) close #iFile End Sub Sub dumpFrameList( xFrameContainer as com.sun.star.frame.XFrames ) if isNull(xFrameContainer) then Print #iFile, "frame list does not exist!" else nCount = xFrameContainer.getCount() dim lFrames(nCount) as Object Print #iFile, "open frames = "+nCount for i=0 to nCount-1 step 1 lFrames(i) = xFrameContainer.getByIndex(i) next i for i=0 to nCount-1 step 1 xFrame = lFrames(i) Print #iFile, "************************************************" Print #iFile, "frame["+i+"]" dumpFrame(xFrame) if (bTrySaving=true) then bSaved = saveFrame(xFrame,i) if (bSaved=true) then Print #iFile, "could be saved" else Print #iFile, "could not be saved" endif endif if (bTryClose=true) then closeFrame(xFrame) endif next i endif End Sub Sub dumpFrame( xFrame as Object ) Print #iFile, "name = '"+xFrame.getName()+"'" Print #iFile, "title = '"+xFrame.Title +"'" xContainerWindow = xFrame.getContainerWindow() xComponentWindow = xFrame.getComponentWindow() xController = xFrame.getController() if not isNull(xController) then xModel = xController.getModel() else xModel = null endif if not isNull(xContainerWindow) then Print #iFile, "container window" if (bMakeVisible) then xContainerWindow.setVisible(true) endif endif if not isNull(xComponentWindow) then Print #iFile, "component window" if (bMakeVisible) then xComponentWindow.setVisible(true) endif endif if not isNull(xController) then Print #iFile, "controller" endif if not isNull(xModel) then Print #iFile, "model" Print #iFile, "url = '"+xModel.getURL() +"'" Print #iFile, "modified = '"+xModel.isModified() +"'" Print #iFile, "readonly = '"+xModel.isReadOnly() +"'" Print #iFile, "has location = '"+xModel.hasLocation()+"'" Print #iFile, "location = '"+xModel.getLocation()+"'" lArgs() = xModel.getArgs() dumpArgs(lArgs()) endif End Sub Sub dumpArgs( lArgs() as new com.sun.star.beans.PropertyValue ) nCount = uBound(lArgs()) for i=0 to nCount-1 step 1 Print #iFile, "Arg["+i+"].Name = '"+lArgs(i).Name +"'" if isObject(lArgs(i).Value) then if isNull(lArgs(i).Value) then Print #iFile, "Arg["+i+"].Value = null" else Print #iFile, "Arg["+i+"].Value = a valid object" endif else Print #iFile, "Arg["+i+"].Value = '"+lArgs(i).Value+"'"+chr(13) endif next i End Sub Sub closeFrame( xFrame as Object ) bClosed = false on local error resume next bClosed = xFrame.close(false) if bClosed=true then Print #iFile, "could be closed" else Print #iFile, "could not be closed" endif End Sub Function saveFrame( xFrame as Object, nNr as Integer ) as Boolean xController = xFrame.getController() if isNull(xController) then saveFrame = false else xModel = xController.getModel() if isNull(xModel) then saveFrame = false else sURL = ConvertToURL(sTempDir) sURL = sURL+nNr+".dat" dim lProps() as new com.sun.star.beans.PropertyValue xModel.storeAsURL(sURL,lProps()) saveFrame = true endif endif End Function