[Tutorial] Comments feature: default font & size

Forum rules
No question in this section please
For any question related to a topic, create a new thread in the relevant section.
Post Reply
gtilma
Posts: 1
Joined: Wed Dec 08, 2010 5:03 am

[Tutorial] Comments feature: default font & size

Post by gtilma »

This tutorial describes a workaround to change the default font & font size in the Insert --> Comments feature in Ooo 3.2 Writer (feature formerly known as Notes).

(Context: I'm a writing instructor and occasionally have to use this feature to comment on emailed submissions of essays written in Microsoft Word. The default font & size is the system's default font (Ubuntu for me) in 10pt, but I wanted the comments to imitate Word's default, which is 9pt Calibri. After searching around, there didn't seem to be an easy solution, so I figured out this quick workaround.)

First, since I wanted to use Calibri, which is the default for Word since 2007, I followed the instructions here.

That done, I went through the following steps to record a macro of inserting a comment and changing the font & size:
  1. Tools --> Macros --> Record Macro
  2. Insert --> Comment (or Ctrl + Alt + N)
  3. Change font and font size as you wish
  4. Stop recording. Save the macro as whatever (should be in My Macros/Standard/Module1). I called mine 'note_calibri9'.
There's one catch: if you try to run it now, all it will do is change the font & size without inserting a comment first. To fix this, do the following:
  1. Tools --> Macros --> Organize Macros --> OpenOffice.org Basic...
  2. Find the macro you just recorded and press 'Edit'.
  3. You should see something very close to the following code. Take note of the line below the third dashed line:

    Code: Select all

    sub note_calibri9
    rem ----------------------------------------------------------------------
    rem define variables
    dim document   as object
    dim dispatcher as object
    rem ----------------------------------------------------------------------
    rem get access to the document
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
    
    rem ----------------------------------------------------------------------
    rem dispatcher.executeDispatch(document, ".uno:InsertAnnotation", "", 0, Array())
    
    rem ----------------------------------------------------------------------
    dim args2(4) as new com.sun.star.beans.PropertyValue
    args2(0).Name = "CharFontName.StyleName"
    args2(0).Value = ""
    args2(1).Name = "CharFontName.Pitch"
    args2(1).Value = 2
    args2(2).Name = "CharFontName.CharSet"
    args2(2).Value = -1
    args2(3).Name = "CharFontName.Family"
    args2(3).Value = 5
    args2(4).Name = "CharFontName.FamilyName"
    args2(4).Value = "Calibri"
    
    dispatcher.executeDispatch(document, ".uno:CharFontName", "", 0, args2())
    
    rem ----------------------------------------------------------------------
    dim args3(2) as new com.sun.star.beans.PropertyValue
    args3(0).Name = "FontHeight.Height"
    args3(0).Value = 9
    args3(1).Name = "FontHeight.Prop"
    args3(1).Value = 100
    args3(2).Name = "FontHeight.Diff"
    args3(2).Value = 0
    
    dispatcher.executeDispatch(document, ".uno:FontHeight", "", 0, args3())
    
    
    end sub
    
  4. Remove the 'rem ' from the beginning of the line that mentions 'InsertAnnotation' -- it should look like this:

    Code: Select all

    rem ----------------------------------------------------------------------
    dispatcher.executeDispatch(document, ".uno:InsertAnnotation", "", 0, Array())
    
    That 'rem' stands for 'remark', just like the <!-- ... --> in HTML or the % in LaTeX. For some reason, Ooo's macro recorder registers inserting a comment but disregards it by commenting it out in the code.
Now the macro should run fine. All that's left is to reassign the Ctrl + Alt + N keystroke to the macro:
  1. Tools --> Customize..., find Keyboard tab
  2. Find the macro module in the Category box at the bottom (OpenOffice.org Macros/user/Standard/Module1), then find your new macro in the Function box just to the right and select it.
  3. Back up in the Shortcut Keys box, select Ctrl + Alt + N (or any other keystroke you want) and press 'Modify' on the right. Click OK to exit the dialog.
That should do it.

NOTE: I discovered recently that Ooo does not save comments or inserted OLE objects when editing a Word XML (.docx) file. This is probably a bug (not sure if known), but for now I'm reverting all of these files to the older .doc.
Post Reply