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

oo Basic program

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
gianfmal
Guest





PostPosted: Wed Oct 29, 2003 2:05 pm    Post subject: oo Basic program Reply with quote

Would like to test the Basic version of Open Office but do not know how to find both the program and its documentation.

Please help me - regrds

Gianfmal
Back to top
dpeach
OOo Advocate
OOo Advocate


Joined: 06 Oct 2003
Posts: 397
Location: Mérida, Yucatán, México

PostPosted: Wed Oct 29, 2003 2:34 pm    Post subject: Reply with quote

Are you just talking about downloading a trying OpenOffice.org? If so, you can go to www.openoffice.org and see all the information about downloading and documentation there.

dpeach
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Oct 30, 2003 3:42 am    Post subject: Reply with quote

Hi, dpeach

Thanks for your replay
My request was not clear (the term "basic" is misleading).

I already installed OO 1.1, and also downloaded the source file to see if the "Basic programming development system" (the competitor of MS VB) was there.

I couldn't find it but it is said to be included in OO.

Any help?
Regards
Back to top
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Thu Oct 30, 2003 7:12 am    Post subject: Reply with quote

This question should be over in the Macros and API section.

You can get into the Basic IDE as follows.
* Open a document -- any kind.
* Tools --> Macros --> Macro...
this brings up the Macro dialog box.

Macros are organized as follows.
Macros can be under a document, or as part of the office and therefore available to any document.
Under either soffice or a document, macros are organized into Libraries. Within a library, macros are organized into Modules. There are two kinds of modules, Basic modules and Dialog modules.

Once you are in the Macro dialog, simply create a new module under the Standard library of your new document. Scroll down, and you'll see your document Untitled1, with a Standard library underneath it. Click on Standard so it is hilighted. Then click the New button to create a module. The New Module dialog appears asking you to name your module. You don't need to name it. Just click OK. Now you're in the Basic IDE.

You will see a stub routine like this...

Code:
Sub Main

End Sub


Put in this code instead.

Code:
Sub Main
   ' First create a drawing document.
   oDrawDoc = MakeNewDrawDoc()
   
   ' Get the first page
   Dim oPage As Object
   oPage = oDrawDoc.drawPages( 0 )
   
   ' Get the usable area of the page.
   ' The width, for example, would be the page width, but removing the
   '  left and right margins i.e. BorderLeft and BorderRight.
   nUsableWidth = oPage.Width - oPage.BorderLeft - oPage.BorderRight
   nUsableHeight = oPage.Height - oPage.BorderTop - oPage.BorderBottom
   
   ' Get access to the layers of this draw document.
   Dim oLayerManager As Object
   oLayerManager = oDrawDoc.getLayerManager()
   
   ' Get the number of layers currently on the page.
   nNumLayers = oLayerManager.getCount()
   
   ' Insert a new layer to hold Ellipse objects.
   Dim oCircleLayer As Object
   oCircleLayer = oLayerManager.insertNewByIndex( nNumLayers )
   ' Give the new layer a name.
   oCircleLayer.Name = "Circles"
   ' You can see the circles, but you can't print them as this
   '  would violate the DMCA.
   oCircleLayer.IsVisible = TRUE
   oCircleLayer.IsPrintable = FALSE
   
   
   Dim oShape As Object
   Dim oPoint As Object
   Dim oSize As Object
   
   ' Now make 100 random shapes
   For i = 1 To 100
      ' What is the object's size?
      ' Let's let the object have a maximum dimension of 4 centimeters,
      '  and minimum of 0.5 cm.
      oSize = MakeSize( RND()*3500+500, RND()*3500+500 )
      ' The object can be positioned anywhere on the page, but
      '  must not extend off the usable area of the page.
      oPoint = MakePoint( RND()*(nUsableWidth-oSize.Width)+oPage.BorderLeft,_
                     RND()*(nUsableHeight-oSize.Height)+oPage.BorderTop )
      
      ' Make a random color for the shape.
      nColor = RGB( RND()*128+127, RND()*128+127, RND()*128+127 )
      
      ' 50/50 chance of making Ellipse or Rectangle.
      If Rnd() > 0.5 Then
         oShape = MakeRectangleShape( oDrawDoc, oPoint, oSize )
         oShape.FillColor = nColor
         oPage.add( oShape )
      Else
         oShape = MakeEllipseShape( oDrawDoc, oPoint, oSize )
         oShape.FillColor = nColor
         oPage.add( oShape )
         
         ' Ellipse shapes go onto the Circle layer
         oLayerManager.attachShapeToLayer( oShape, oCircleLayer )
      EndIf
   Next
End Sub




'------------------------------------------------------------
'      Create and return a new empty Draw document.
'
'      Call this with no parameters.
'      It returns a Draw document.
'------------------------------------------------------------
Function MakeNewDrawDoc() As Object
   Dim oDesktop As Object
   Dim oDocument As Object
   
   Dim mNoArgs()
   Dim sUrl As String
   
   oDesktop = createUnoService( "com.sun.star.frame.Desktop" )
   sUrl = "private:factory/sdraw"
   oDocument = oDesktop.LoadComponentFromURL( sUrl, "_blank", 0, mNoArgs() )
   
   MakeNewDrawDoc() = oDocument
End Function


'------------------------------------------------------------
'      Create and return a new Point object.
'
'      This is syntax sugar to make it easy to
'       create a com.sun.star.awt.Point object.
'------------------------------------------------------------
Function MakePoint( x As Long, y As Long ) As com.sun.star.awt.Point
   Dim aPoint As New com.sun.star.awt.Point
   aPoint.x = x
   aPoint.y = y
   MakePoint() = aPoint
End Function


'------------------------------------------------------------
'      Create and return a new Size object.
'
'      This is syntax sugar to make it easy to
'       create a com.sun.star.awt.Size object.
'------------------------------------------------------------
Function MakeSize( width As Long, height As Long ) As com.sun.star.awt.Size
   Dim aSize As New com.sun.star.awt.Size
   aSize.width = width
   aSize.height = height
   MakeSize() = aSize
End Function


'------------------------------------------------------------
'      Create and return a RectangleShape object.
'
'      After you create the shape object, you can manipulate
'       its properties to alter its appearance, including
'       its size and location.
'
'      You must pass the document object.
'      (Call MakeNewDrawDoc() above to obtain an empty
'       draw document.)
'      Optionally, you may also pass in a location and size.
'      If you do not, then the new object has size (0,0)
'       and location (0,0), which is the extreme upper left.
'       In other words, the object is squished way up in the
'       upper left corner, and has no size, therefore cannot be seen.
'------------------------------------------------------------
Function MakeRectangleShape( oDoc As Object,_
               Optional position As com.sun.star.awt.Point,_
               Optional size As com.sun.star.awt.Size )
'   If IsMissing( position ) Then
'      position = MakePoint( 1000, 1000 )
'   EndIf
'   If IsMissing( size ) Then
'      size = MakeSize( 500, 500 )
'   EndIf
   MakeRectangleShape() = MakeShape( oDoc, "com.sun.star.drawing.RectangleShape", position, size )
End Function


'------------------------------------------------------------
'      Create and return a EllipseShape object.
'
'      After you create the shape object, you can manipulate
'       its properties to alter its appearance, including
'       its size and location.
'
'      You must pass the document object.
'      (Call MakeNewDrawDoc() above to obtain an empty
'       draw document.)
'      Optionally, you may also pass in a location and size.
'      If you do not, then the new object has size (0,0)
'       and location (0,0), which is the extreme upper left.
'       In other words, the object is squished way up in the
'       upper left corner, and has no size, therefore cannot be seen.
'------------------------------------------------------------
Function MakeEllipseShape( oDoc As Object,_
               Optional position As com.sun.star.awt.Point,_
               Optional size As com.sun.star.awt.Size )
   MakeEllipseShape() = MakeShape( oDoc, "com.sun.star.drawing.EllipseShape", position, size )
End Function


'------------------------------------------------------------
'      Create and return a TextShape object.
'
'      After you create the shape object, you can manipulate
'       its properties to alter its appearance, including
'       its size and location.
'
'      You must pass the document object.
'      (Call MakeNewDrawDoc() above to obtain an empty
'       draw document.)
'      Optionally, you may also pass in a location and size.
'      If you do not, then the new object has size (0,0)
'       and location (0,0), which is the extreme upper left.
'       In other words, the object is squished way up in the
'       upper left corner, and has no size, therefore cannot be seen.
'------------------------------------------------------------
Function MakeTextShape( oDoc As Object,_
               Optional position As com.sun.star.awt.Point,_
               Optional size As com.sun.star.awt.Size )
   MakeTextShape() = MakeShape( oDoc, "com.sun.star.drawing.TextShape", position, size )
End Function


'------------------------------------------------------------
'      Create and return a LineShape object.
'
'      After you create the shape object, you can manipulate
'       its properties to alter its appearance, including
'       its size and location.
'
'      You must pass the document object.
'      (Call MakeNewDrawDoc() above to obtain an empty
'       draw document.)
'      Optionally, you may also pass in a location and size.
'      If you do not, then the new object has size (0,0)
'       and location (0,0), which is the extreme upper left.
'       In other words, the object is squished way up in the
'       upper left corner, and has no size, therefore cannot be seen.
'------------------------------------------------------------
Function MakeLineShape( oDoc As Object,_
               Optional position As com.sun.star.awt.Point,_
               Optional size As com.sun.star.awt.Size )
   MakeLineShape() = MakeShape( oDoc, "com.sun.star.drawing.LineShape", position, size )
End Function


'------------------------------------------------------------
'      Create and return a Shape object.
'
'      You might prefer to call the other MakeXXXShape()
'       functions (see above).
'      This function creates any kind of shape, but you
'       need to know the class name of the shape.
'------------------------------------------------------------
Function MakeShape( oDoc As Object, cShapeClassName As String,_
               Optional position As com.sun.star.awt.Point,_
               Optional size As com.sun.star.awt.Size )
   Dim oShape As Object
   oShape = oDoc.createInstance( cShapeClassName )
   If Not IsMissing( position ) Then
      oShape.Position = position
   EndIf
   If Not IsMissing( size ) Then
      oShape.Size = size
   EndIf
   MakeShape() = oShape
End Function


'------------------------------------------------------------
'      Given a drawing page, find and return a
'       names shape on that page.
'------------------------------------------------------------

Function FindShapeByName( oPage As Object, cShapeName As String )
   nNumShapes = oPage.getCount()
   For i = 0 To nNumShapes - 1
      oShape = oPage.getByIndex( i )
      If oShape.getName() = cShapeName Then
         FindShapeByName = oShape
         Exit Function
      EndIf
   Next
End Function


One annoying thing that yo've got to be careful of. Copying code from OOoForum into the Basic IDE usually introduces spaces at the end of every single line. If any lines end with an underscore _, then you need to make sure that the underscore is the last character of the line without a trailing space. Just one of the hazards of copying and pasting code from OOoForum.

Now click the Run button. See the toolbar at the top of the window? At the extreme left it has a dropdown menu combo box? See a row of buttons to the right of this. The second button from the left is the Run button. Click it. This will produce a new drawing of some shapes.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
dpeach
OOo Advocate
OOo Advocate


Joined: 06 Oct 2003
Posts: 397
Location: Mérida, Yucatán, México

PostPosted: Thu Oct 30, 2003 7:50 pm    Post subject: Reply with quote

I thought you might be talking about the BASIC programming in OOo, but I was not sure.

Glad you got your help.

dpeach
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Oct 31, 2003 9:55 am    Post subject: Reply with quote

I wasn't clear on the original question either. So I waited until someone else answered first. Smile

Especially since the question was in the Writer forum, not the Macros and API forum.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer 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