Wait for 1 sec after document load as events doesn't work well.
This commit is contained in:
parent
e929de14f0
commit
31ae769470
2 changed files with 48 additions and 4 deletions
|
@ -1,9 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
||||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub mark74
|
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Clean" script:language="StarBasic">Sub mark75
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Dim DocumentLoaded as Boolean
|
||||||
|
|
||||||
Sub cleanButton
|
Sub cleanButton
|
||||||
Dim config As Object
|
Dim config As Object
|
||||||
config = initRedactionConfiguration()
|
config = initRedactionConfiguration()
|
||||||
|
@ -160,7 +162,7 @@ End Sub
|
||||||
Private Sub quietCleaning
|
Private Sub quietCleaning
|
||||||
Dim description As String
|
Dim description As String
|
||||||
Dim statusIndicator As Object
|
Dim statusIndicator As Object
|
||||||
|
DocumentLoaded = false
|
||||||
saveDocument
|
saveDocument
|
||||||
saveAsDocAndBackToODT
|
saveAsDocAndBackToODT
|
||||||
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
statusIndicator = ThisComponent.getCurrentController.statusIndicator
|
||||||
|
@ -205,6 +207,20 @@ Private Sub quietCleaning
|
||||||
MsgBox getTranslation("cleaningFinished")
|
MsgBox getTranslation("cleaningFinished")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
'Sub RegisterListener (ThisComponent)
|
||||||
|
' oListener = CreateUnoListener( "DocumentListener_","com.sun.star.document.XEventListener" )
|
||||||
|
' ThisComponent.com_sun_star_document_XEventBroadcaster_addEventListener( oListener )
|
||||||
|
'End Sub
|
||||||
|
|
||||||
|
'Sub DocumentListener_notifyEvent( o as object )
|
||||||
|
' If o.EventName = "OnLoad" Then
|
||||||
|
' DocumentLoaded = true
|
||||||
|
' EndIf
|
||||||
|
'end sub
|
||||||
|
|
||||||
|
'Sub DocumentListener_disposing()
|
||||||
|
'End Sub
|
||||||
|
|
||||||
Private Sub removeFirstElementPageBreak
|
Private Sub removeFirstElementPageBreak
|
||||||
Dim enum1 As Object
|
Dim enum1 As Object
|
||||||
Dim enum1Element As Object
|
Dim enum1Element As Object
|
||||||
|
@ -715,11 +731,24 @@ End Sub
|
||||||
Private Sub saveAndreload()
|
Private Sub saveAndreload()
|
||||||
Dim document As Object
|
Dim document As Object
|
||||||
Dim dispatcher As Object
|
Dim dispatcher As Object
|
||||||
|
'Dim timeOut As Long
|
||||||
|
'timeOut = 0
|
||||||
|
'DocumentLoaded = false
|
||||||
document = ThisComponent.CurrentController.Frame
|
document = ThisComponent.CurrentController.Frame
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
|
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
|
||||||
dispatcher.executeDispatch(document, ".uno:Reload", "", 0, Array())
|
dispatcher.executeDispatch(document, ".uno:Reload", "", 0, Array())
|
||||||
|
Wait 1000
|
||||||
|
'RegisterListener (ThisComponent)
|
||||||
|
'Do while DocumentLoaded = false
|
||||||
|
' Wait 300
|
||||||
|
' timeOut = timeOut + 300
|
||||||
|
' If timeOut > 30000 Then
|
||||||
|
' MsgBox "Time out"
|
||||||
|
' Exit sub
|
||||||
|
' EndIf
|
||||||
|
'Loop
|
||||||
|
'DocumentLoaded = false
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
@ -1810,6 +1839,10 @@ sub saveAsDocAndBackToODT
|
||||||
Dim path As String
|
Dim path As String
|
||||||
Dim tmpName As String
|
Dim tmpName As String
|
||||||
Dim oldName As String
|
Dim oldName As String
|
||||||
|
'Dim timeOut As Long
|
||||||
|
'timeOut = 0
|
||||||
|
'DocumentLoaded = false
|
||||||
|
|
||||||
document = ThisComponent.CurrentController.Frame
|
document = ThisComponent.CurrentController.Frame
|
||||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||||
oldName = ThisComponent.getURL()
|
oldName = ThisComponent.getURL()
|
||||||
|
@ -1825,6 +1858,17 @@ sub saveAsDocAndBackToODT
|
||||||
args1(1).Value = "writer8"
|
args1(1).Value = "writer8"
|
||||||
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
|
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
|
||||||
dispatcher.executeDispatch(document, ".uno:Reload", "", 0, Array())
|
dispatcher.executeDispatch(document, ".uno:Reload", "", 0, Array())
|
||||||
|
'RegisterListener (ThisComponent)
|
||||||
|
'Do while DocumentLoaded = false
|
||||||
|
' Wait 300
|
||||||
|
' timeOut = timeOut + 300
|
||||||
|
' If timeOut > 30000 Then
|
||||||
|
' MsgBox "Time out"
|
||||||
|
' Exit sub
|
||||||
|
' EndIf
|
||||||
|
'Loop
|
||||||
|
'DocumentLoaded = false
|
||||||
|
|
||||||
If FileExists(tmpName) Then
|
If FileExists(tmpName) Then
|
||||||
Kill(tmpName)
|
Kill(tmpName)
|
||||||
End If
|
End If
|
||||||
|
|
Loading…
Add table
Reference in a new issue