redlines - tracked/recorded changes

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
rich
Posts: 12
Joined: Mon May 05, 2008 5:10 pm

redlines - tracked/recorded changes

Post by rich »

How can I extract the changes made in a document to generate a new document that contains those changes :?:
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: redlines - tracked/recorded changes

Post by JohnV »

We are going to need more help from you and others who might program. I have some code below but it needs work that is beyond me. I was curious about how OOo handled changes so I went digging around with the Xray utility and found them in a text portion enumeration.

From you we need to know what part of recorded changes you need. Deletes? Inserts? Format changes? Do you need the whole paragraph in which a change occurs or just the words involved?

The problem with my code that was designed to find items inserted as a changes is that if a change involves the insertion of a new paragraph then I don't know how to process it. This code is lightly tested at best.

Code: Select all

Sub Main
On Error goto EH
oDoc = ThisComponent
Enum =oDoc.Text.CreateEnumeration 'Start a paragraph enumeration.
While enum.hasMoreElements
 thisPara = enum.nextElement
 enum1 = thisPara.createEnumeration 'Start enumeration of text portions within paragraph.
 While enum1.hasMoreElements
  thisPortion = enum1.nextElement
  If thisPortion.textPortionType = "Redline" then
  ' Print thisPortion.RedlineType
   If thisPortion.RedlineType = "Insert" or thisPortion.RedlineType = "Format" then
    'This portion marks the beginning.
    If enum1.hasMoreElements then 'This If avoids an error in the next line when
                                  'a change consists of a new paragraph. 
     thisPortion = enum1.NextElement 'This portion has the text.
     c = c+1
     s = s & thisPortion.String & Chr(13)
     thisPortion = enum1.NextElement 'This portion marks the end.
    EndIf
   EndIf
  EndIf  
 Wend
Wend  
EH:
MsgBox "Total inserts = " & c & Chr(13) & Chr(13) & s
End Sub
rich
Posts: 12
Joined: Mon May 05, 2008 5:10 pm

Re: redlines - tracked/recorded changes

Post by rich »

JohnV wrote:We are going to need more help from you and others who might program. I have some code below but it needs work that is beyond me. I was curious about how OOo handled changes so I went digging around with the Xray utility and found them in a text portion enumeration.

From you we need to know what part of recorded changes you need. Deletes? Inserts? Format changes? Do you need the whole paragraph in which a change occurs or just the words involved?

The problem with my code that was designed to find items inserted as a changes is that if a change involves the insertion of a new paragraph then I don't know how to process it. This code is lightly tested at best.

Code: Select all

Sub Main
On Error goto EH
oDoc = ThisComponent
Enum =oDoc.Text.CreateEnumeration 'Start a paragraph enumeration.
While enum.hasMoreElements
 thisPara = enum.nextElement
 enum1 = thisPara.createEnumeration 'Start enumeration of text portions within paragraph.
 While enum1.hasMoreElements
  thisPortion = enum1.nextElement
  If thisPortion.textPortionType = "Redline" then
  ' Print thisPortion.RedlineType
   If thisPortion.RedlineType = "Insert" or thisPortion.RedlineType = "Format" then
    'This portion marks the beginning.
    If enum1.hasMoreElements then 'This If avoids an error in the next line when
                                  'a change consists of a new paragraph. 
     thisPortion = enum1.NextElement 'This portion has the text.
     c = c+1
     s = s & thisPortion.String & Chr(13)
     thisPortion = enum1.NextElement 'This portion marks the end.
    EndIf
   EndIf
  EndIf  
 Wend
Wend  
EH:
MsgBox "Total inserts = " & c & Chr(13) & Chr(13) & s
End Sub

I need deletions, insertions, changes/modifications, the whole paragraph that the change occured in and also the paragraph before and after the change. i need it for paragraphs, charts, tables, you name it.
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: redlines - tracked/recorded changes

Post by JohnV »

Hope someone else can help because you're out of my league.
rich
Posts: 12
Joined: Mon May 05, 2008 5:10 pm

Re: redlines - tracked/recorded changes

Post by rich »

I should be able to use your code to get there. If i can identify each type of change, then there should be a way to access the sibling paragraphs to do the before and after paragraphs. I really just needed some sort of starting point. I hope i can get to B from A. :D
Post Reply