No answers here, to this question asked a few times over the years, and also on the forums:

How to use a macro to accept or reject individual changes (redlines). I opted to document as much as I could. I demonstrate here how to enumerate redlines, and a "cheat" method to delete them, but not how to accept them, and this is certainly not the correct method!


************************

While recording changes, they are saved as “redlines”. Although you can easily enumerate the redlines, I have not found a way to do anything useful with them. Specifically, I am not able to obtain the text, or move a cursor to the redline, even though I can obtain the “start” and “end” of the redline.

Listing 7.67: Enumerate redlines.
oEnum = ThisComponent.redlines.createEnumeration()
Do While oEnum.hasMoreElements()
oRedLine = oEnum.nextElement()
'oRedLine.RedlineType
'oredline.redlineauthor
'oredline.redlinecomment
loop
I am, however, able to do some work by enumerating the text content (see Listing 7.53). The following simple macro ignores things such as tables and frames, but it provides some insight into how to deal with redlines.
Sub EnumerateRedlineContent
REM Author: Andrew Pitonyak
Dim oParEnum 'Enumerator used to enumerate the paragraphs
Dim oPar 'The enumerated paragraph
Dim oSectionEnum 'Enumerator used to enumerate the text sections
Dim oSection 'The enumerated text section
Dim oCurs 'Track the redlines.
Dim oText

oParEnum = ThisComponent.getText().createEnumeration()
Do While oParEnum.hasMoreElements()
oPar = oParEnum.nextElement()
If oPar.supportsService("com.sun.star.text.Paragraph") Then
oSectionEnum = oPar.createEnumeration()
Do While oSectionEnum.hasMoreElements()
oSection = oSectionEnum.nextElement()
If oSection.TextPortionType = "Redline" Then
If oSection.IsStart Then
'At a start, so create the text cursor.
oText = oSection.getText()
oCurs = oText.createTextCursorByRange(oSection.getStart())
Else
'Move cursor to the end of the redline.
oCurs.gotoRange(oSection.getEnd(), True)
Print oSection.RedlineType & " " & oCurs.getString()
End If
End If
Loop
End If
Loop
End Sub

A quick test, that did not check things such as formatting changes, seemed to indicate that I can delete a section by setting the string to an empty string.

If oSection.RedlineType = "Delete" Then
'Delete the range!
oCurs.setString("")
End If
I have not, however, found any other method to remove a redline using a macro. I have also not found a method to accept an individual redline.




--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to