OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Changing author names on changes & comments

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Owen Watson
General User
General User


Joined: 20 Apr 2005
Posts: 5

PostPosted: Wed Apr 20, 2005 2:58 am    Post subject: Changing author names on changes & comments Reply with quote

We have documents containing marked changes and comments from several referees, and we want to send the documents back to the author with the referee's names changed; to something like Referee1, etc. Is there any way this can be done in OOo?

I tried to get it done in Word but there were problems, so this is the next stop!
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Wed Apr 20, 2005 6:27 am    Post subject: Reply with quote

Certainly you can change the author on an annotation using the API:
Code:
Sub ChangeNotesAuthors
  Dim oEnum
  Dim oField
  oEnum = ThisComponent.getTextFields().createEnumeration()
  Do While oEnum.hasMoreElements()
    oField = oEnum.nextElement()
    If oField.supportsService("com.sun.star.text.TextField.Annotation") Then
      'Inspect(oField)
      If oField.Author = "ADP" Then
        oField.Author = "MWP"
      Else
        oField.Author = "ADP"
      End If
    End If
  Loop
End Sub

_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Wed Apr 20, 2005 6:54 am    Post subject: Reply with quote

You can not directly change the author of a change, but if you could, this is the macro that you would use.
Code:
Sub HandleRedLines
  Dim oEnumT, oEnumP
  Dim oPar
  Dim oPropSetInfo
  Dim x
  Dim s$
  oEnumT = ThisComponent.getText().createEnumeration()
  Do While oEnumT.hasMoreElements()
    oPar = oEnumT.nextElement()
    oEnumP = oPar.createEnumeration()
    Do While oEnumP.hasMoreElements()
      x = oEnumP.nextElement()
      If x.getPropertySetInfo().hasPropertyByName("RedlineAuthor") Then
        If x.RedlineAuthor = "Andrew Pitonyak" Then
          REM This fails because the property is read only!
          'x.RedlineAuthor = "Billy"
        End If
      End If
    Loop
  Loop
End Sub

Changes are added inline. I did change the name, however Smile

0) Backup your file.
1) change the file extension to zip.
2) unzip the files (including directories).
3) Edit content.xml and change references to the "changer"
4) Re-zip the contents
5) Change the name to have the proper extension.

So, yes, you can do this.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Owen Watson
General User
General User


Joined: 20 Apr 2005
Posts: 5

PostPosted: Wed Apr 20, 2005 8:55 pm    Post subject: Reply with quote

Wow! I didn't realise how OO documents were constructed.
Can it be automated from within OO? (ie press button on menu bar, first change author's name gets replaced by Referee1, 2nd by Referee2, etc etc?
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Thu Apr 21, 2005 2:16 am    Post subject: Reply with quote

Most certainly.
Automating OpenOffice can be done for a huge amount of aspects in the office suite, thanks to its API and Universal Component Model.

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
Owen Watson
General User
General User


Joined: 20 Apr 2005
Posts: 5

PostPosted: Thu Apr 21, 2005 3:46 am    Post subject: Reply with quote

mmm. . . just tried it. Find & replace in contents.xml, then zipping up the entire folder and changining extension: unfortunately OOo doesn't like the result, saying there's a dud character at a particular place in the file. I used PsPad to edit the file, which I don't think does any mangling of the text, so is it a checksum or other problem?
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Thu Apr 21, 2005 8:06 pm    Post subject: Reply with quote

I have never had a problem.... Make certain that your text editor, or what ever program you use, does not do something silly like change the line endings.... Also, you can configure OOo to save the document as "pretty", or "not pretty". I do not remember the word that they use, but it really means.... Should OOo save the text in one huge line of text, or as an easy to read in a text editor document.

You must preserve all directories.
I have only done this usig the command line tool pkzip.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group