hosted by sflogo.jpg

Italicize words using OpenOffice.org

From Bibus

Currently, Bibus provides no way to italicize individual words in a field (such as may be needed for a scientifc species name in the title). Here is a workaround for users of OpenOffice.org.

1. Use the html tags <i> and </i> in Bibus to demarcate words to be italicized.

2. After finalizing, do the following two part search and replace operation in OpenOffice.org. Make sure to select the option for "Regular Expressions" available through the "More Options" feature!

Search: <i>[^><]*</i>
Replace: & (formatting = italic)

Search: <[/]*i>
Replace:

or ...

The following macros italicize the words automatically:

1: for openoffice (modified from different macros from http://www.pitonyak.org/AndrewMacro.odt , documentation under public license http://www.openoffice.org/licenses/pdl.pdf):


 Sub ItaliqueBibus
   Dim vOpenSearch, vCloseSearch 'Open and Close descriptors
   Dim vOpenFound, vCloseFound 'Open and Close find objects
   ' Create descriptors from the searchable document.
   vOpenSearch = ThisComponent.createSearchDescriptor()
   vCloseSearch = ThisComponent.createSearchDescriptor()
   ' Set the text for which to search and other
   vOpenSearch.SearchString = "<i>"
   vCloseSearch.SearchString = "</i>"
   ' Find the first open delimiter
   vOpenFound = ThisComponent.findFirst(vOpenSearch)
   Do While Not IsNull(vOpenFound)
     'Search for the closing delimiter starting from the open delimiter
     vCloseFound = ThisComponent.findNext( vOpenFound.End, vCloseSearch)
     If IsNull(vCloseFound) Then
       Print "Found an opening bracket but no closing bracket!"
       Exit Do
     Else
       ' Clear the open bracket, if I do not do this, then I end up
       ' with only the text inside the brackets
       vOpenFound.setString("")
       ' select the text inside the brackets
       vOpenFound.gotoRange(vCloseFound, True)
       ' Print "Found " & vOpenFound.getString()
       ' clear the text inside the brackets
       vOpenFound.CharPosture=com.sun.star.awt.FontSlant.ITALIC
       ' Clear the close bracket
       vCloseFound.setString("")
       ' Do you really want to delete ALL of the spaces?
       ' If so, then do it here!
       vOpenFound = ThisComponent.findNext( vOpenFound.End, vOpenSearch)
     End If
   Loop
 End Sub
 
 

2: for Microsoft Word:

 Sub bibus()
     ActiveDocument.Select
     Selection.Find.ClearFormatting
     With Selection.Find
         .Text = "<i>"
         .Replacement.Text = ""
         .Forward = True
         .Wrap = wdFindStop
         .Format = False
         .MatchCase = False
         .MatchWholeWord = False
         .MatchWildcards = False
         .MatchSoundsLike = False
         .MatchAllWordForms = False
     End With
     While Selection.Find.Execute = True
         With Selection
             .MoveEndUntil Cset:="</i>", Count:=wdForward
             .MoveRight Unit:=wdCharacter, Count:=4, Extend:=wdExtend
         End With
         Selection.Font.Italic = wdToggle
         With Selection
             .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
         End With
     Wend
     Selection.Find.ClearFormatting
     Selection.Find.Replacement.ClearFormatting
     With Selection.Find
         .Text = "<i>"
         .Replacement.Text = ""
         .Forward = True
         .Wrap = wdFindContinue
         .Format = False
         .MatchCase = False
         .MatchWholeWord = False
         .MatchWildcards = False
         .MatchSoundsLike = False
         .MatchAllWordForms = False
     End With
     Selection.Find.Execute Replace:=wdReplaceAll
     With Selection.Find
         .Text = "</i>"
         .Replacement.Text = ""
         .Forward = True
         .Wrap = wdFindContinue
         .Format = False
         .MatchCase = False
         .MatchWholeWord = False
         .MatchWildcards = False
         .MatchSoundsLike = False
         .MatchAllWordForms = False
     End With
     Selection.Find.Execute Replace:=wdReplaceAll
 
 End Sub
Personal tools