Access to protected properties of Redline objects

A Redline is the UNO way of tracking changes to a text (reference). I am working on a macro that loops over the redlines in a Writer document and changes their authorship.

Reading the redlines is quite easy:

sub getRedlines
	oRedlines = ThisComponent.Redlines
	for i=0 to oRedlines.Count() - 1
		oRedline = oRedlines.getByIndex(i)
		author = oRedline.RedlineAuthor
	next
end sub

However, the redline object’s properties are all protected and cannot be written to.
oRedline.setProperty(RedlineAuthor, "newautor") raises an IllegalArgument Exception.

Is there any way to change the properites?

[Edit]: reading more docs I have the suspicion I need to use XRedlinesSupplier interface with method getRedlines() for better access. How would I do this?

Authorship of a change can not be changed using UNO. It is by design. If you want it, you need to do it on the document file level, e.g. ODF: open the package (likely, ZIP, unless you saved as FODT), parse the XML, do the necessary replacements. It would be a low-level procedure.

OK, I surrender. Thanks for making this so clear and sorry for being so insisting.

Redline change-tracking information is not meant to be changed, the css::text::RedlinePortion properties are readonly as indicated. You’d have to modify document file content to accomplish that.

Btw, with ThisComponent.Redlines you are using css::document::XRedlinesSupplier::getRedlines() and your oRedLines is the css::container::XEnumerationAccess returned by that and can be accessed as css::container::XIndexAccess which you do with getByIndex().

I see.

Going through a test document with the development tools on it seems I’d have to loop over every paragraph and every TextPortion inside. Those portions that have the RedlineAuthor property set to something meaningful will be of interest.

It’s just that the RedlineAuthor property here is also protected. Do I have to delete the text portion and create a new one withe the right author set?

[Edit]

Here is my code for looping over the TextPortions:

sub textloop
    Dim oDoc as Object
    Dim oText as object
    Dim oPar as object
    
    oDoc = ThisComponent
    oText = oDoc.getText()
    
    oParEnum = oText.createEnumeration()
	Do While oParEnum.hasMoreElements()
		oPar = oParEnum.nextElement()
		If oPar.supportsService("com.sun.star.text.Paragraph") Then
			Enum2 = oPar.createEnumeration
			do while Enum2.hasMoreElements
				oTextPortion = Enum2.nextElement
				if oTextPortion.TextPortionType = "Redline" then
					oTextPortion.RedlineAuthor = "Somebody Else" ' can't be done here either
				end if
			loop
		end if
	loop

end sub

I notice that if I try to access the RedlineAuthor property more formal with

oTextPortion.setPropertyValue("RedlineAuthor", "somebody else") 

an Exception from a veotableChangeListener is raised. I have tried to remove the listener via oPar.removeVetoableChangeListener() but so far could not figure out its name. Unfortunately the Macro language does not support outputting the call stack upon an Exception.

I don’t know why you still insist. As pointed out, the property is readonly and can not be modified. Period.