Everyone, especially Pitonyak,

Thanks again, your version was much more efficient than mine.  I have a new
question in relation to this, now.  I've run the script, and at first it was
running VERY slowly because I hadn't turned-off the automatic spell checker,
and now that I've turned it off, I get it running faster.  The problem is
that the script seems to die after a set amount of hard time, meaning actual
seconds or minutes.  I have about 4,000+ fonts on my system and I want to
print them all out in a couple columns and see them all on paper to pick out
the ones I like best.

Without the spell checker, it gets to around the 1900'th line(font) and then
stops.  Before that it was getting to around the 1300'th line.  I don't get
any errors to report, the cursor just sort of sits at the end of the
document blinking rapidly, as if it were processing, the script seems to
execute for another 10 seconds without any actual output and then finally
quits.

Is there a hard-coded time limit build into OOo Basic scripts? It stops at
around the same font (at the same font?) every time, but two different fonts
for when I do and don't have auto spell check on, so I don't think it's any
specific font fouling it up.  OOo recognizes all of my fonts, and I can pick
them all manually in the menu bar, but this is what I really want.  Just to
remind anyone reading this, I'm using OOo 1.9.79 on Windows XP SP1. I have
512MB Ram and a P4-M at 2.2GHz.

Thank you,
Rob Moore
------------------------------------------------
"The legitimate powers of government extend only to such acts as are
injurious to others. But it does me no injury for my neighbor to say there
are 20 gods, or no God. It neither picks my pocket nor breaks my leg."
     -Thomas Jefferson


----- Original Message ----- 
From: "Andrew Douglas Pitonyak" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, March 09, 2005 12:42 AM
Subject: Re: [users] Font demo in Writer



Robert Moore wrote:

>I believe I solved my own problem.  I modified a bunch of code supplied by
>the wonderful Andrew Pitonyak in his macro demo as well as some of his
forum
>postings and came up with the following.  Probably really inefficient, but
>it suits my purposes.  I'm going to export the resultant Writer file as a
>PDF and then use that for my purposes.
>
>Thanks Pitonyak!
>
>Dim s$
>Dim tempString$
>Dim mySelection As Object
>
>Sub ListFonts
>Dim oWindow 'The container window supports the awt XDevice interface.
>Dim oDescript 'Array of awt FontDescriptor structures
>Dim i% 'General index variable
>oWindow =
>ThisComponent.getCurrentController().getFrame().getContainerWindow()
>oDescript = oWindow.getFontDescriptors()
>
>For i = LBound(oDescript) to UBound(oDescript)
>tempString = oDescript(i).Name
>s = "My Demo Text - "
>s = s & tempString
>InsertSimpleText
>Next
>End Sub
>
>Sub InsertSimpleText
>Dim oDocument As Object
>Dim oText As Object
>Dim oViewCursor As Object
>Dim oTextCursor As Object
>oDocument = ThisComponent
>oText = oDocument.Text
>oViewCursor = oDocument.CurrentController.getViewCursor()
>oTextCursor = oText.createTextCursorByRange(oViewCursor.getStart())
>' Place the text to insert here
>oTextCursor.charFontName=tempString
>oTextCursor.CharHeight="14"
>oText.insertString(oTextCursor, s, FALSE)
>oText.insertControlCharacter(oTextCursor,
>com.sun.star.text.ControlCharacter.LINE_BREAK, False)
>End Sub
>
>Rob Moore
>------------------------------------------------
>"The legitimate powers of government extend only to such acts as are
>injurious to others. But it does me no injury for my neighbor to say there
>are 20 gods, or no God. It neither picks my pocket nor breaks my leg."
>     -Thomas Jefferson
>
>
>----- Original Message ----- 
>From: "Robert Moore" <[EMAIL PROTECTED]>
>To: <[email protected]>
>Sent: Tuesday, March 08, 2005 10:32 PM
>Subject: [users] Font demo in Writer
>
>
>Hello all,
>
>I would like to first introduce myself as this is my first question to the
>community.  My name is Rob Moore, I'm a 4th year undergraduate student in
CS
>at Seton Hall University in New Jersey.  I've been using OOo for about 2
>years now in lieu of M$ Office.
>
>My question concerns using fonts and demoing them similar to what is done
in
>the Font drop-down box.  I would like to create a Macro that displays some
>constant text in every font available on a machine.  I need the Macro to
>work in either Writer or Calc as these are the most familiar for me.
>
>In case it matters, I am running Windows XP SP1, using OOo version 1.1.4 or
>1.9.x (beta).  Either version would be acceptable, and I appreciate any
help
>in response to this request.
>
>Gratefully,
>
>Rob Moore
>------------------------------------------------
>"The legitimate powers of government extend only to such acts as are
>injurious to others. But it does me no injury for my neighbor to say there
>are 20 gods, or no God. It neither picks my pocket nor breaks my leg."
>     -Thomas Jefferson
>
>
Thank you for your kind words.... I made a few changes to your macro.

1) Always use "Option Explicit".
2) Try to NOT use global variables.
3) I did not insert the text if the font was just used.

Perhaps (3) makes no difference on your system, but it is HUGE
difference on my Linux computer.
Neat macro! I will probably add it to my macro document.....


Option Explicit


Sub ListFonts
  Dim oWindow      'The container window supports the awt XDevice interface.
  Dim oDescript    'Array of awt FontDescriptor structures.
  Dim i%           'General index variable.
  Dim s$           'General string variable.
  Dim sFontName$   'Name of one font.
  Dim sLastFont$

  oWindow =
ThisComponent.getCurrentController().getFrame().getContainerWindow()
  oDescript = oWindow.getFontDescriptors()

  For i = LBound(oDescript) to UBound(oDescript)
    sFontName = oDescript(i).Name
    If sFontName <> sLastFont Then
      sLastFont = sFontName
      s = "My Demo Text - " & sFontName
      InsertSimpleText(s, sFontName)
    End If
  Next
End Sub

Sub InsertSimpleText(s$, sFontName$)
  Dim oText As Object
  Dim oViewCursor As Object
  Dim oTextCursor As Object

  oText = ThisComponent.getText()
  oViewCursor = ThisComponent.CurrentController.getViewCursor()
  oTextCursor = oText.createTextCursorByRange(oViewCursor.getStart())
  ' Place the text to insert here
  oTextCursor.charFontName=sFontName
  oTextCursor.CharHeight="14"
  oText.insertString(oTextCursor, s, FALSE)
  oText.insertControlCharacter(oTextCursor, _
        com.sun.star.text.ControlCharacter.LINE_BREAK, False)
End Sub

-- 
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm
Free Info:  http://www.pitonyak.org/oo.php


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to