diff --git a/Redaction/Clean.xba b/Redaction/Clean.xba index 14aa76a..d5d0768 100644 --- a/Redaction/Clean.xba +++ b/Redaction/Clean.xba @@ -1,9 +1,11 @@ -Sub mark74 +Sub mark75 End Sub +Dim DocumentLoaded as Boolean + Sub cleanButton Dim config As Object config = initRedactionConfiguration() @@ -160,7 +162,7 @@ End Sub Private Sub quietCleaning Dim description As String Dim statusIndicator As Object - + DocumentLoaded = false saveDocument saveAsDocAndBackToODT statusIndicator = ThisComponent.getCurrentController.statusIndicator @@ -205,6 +207,20 @@ Private Sub quietCleaning MsgBox getTranslation("cleaningFinished") 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 Dim enum1 As Object Dim enum1Element As Object @@ -715,11 +731,24 @@ End Sub Private Sub saveAndreload() Dim document As Object Dim dispatcher As Object + 'Dim timeOut As Long + 'timeOut = 0 + 'DocumentLoaded = false document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") dispatcher.executeDispatch(document, ".uno:Save", "", 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 @@ -1810,6 +1839,10 @@ sub saveAsDocAndBackToODT Dim path As String Dim tmpName As String Dim oldName As String + 'Dim timeOut As Long + 'timeOut = 0 + 'DocumentLoaded = false + document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") oldName = ThisComponent.getURL() @@ -1825,6 +1858,17 @@ sub saveAsDocAndBackToODT args1(1).Value = "writer8" dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1()) 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 Kill(tmpName) End If diff --git a/Redaction/Configuration.xba b/Redaction/Configuration.xba index 56a3cb3..c3fcc55 100644 --- a/Redaction/Configuration.xba +++ b/Redaction/Configuration.xba @@ -199,4 +199,4 @@ End Sub End If getFileURLDialog = "" End Function - + \ No newline at end of file