Download StarOffice™ Programmer`s Tutorial

Transcript
oPage.Add(oOldLeavingLine)
Else
bStartUpRun = FALSE
End If
5.3.1.4
Connecting to the including item
Now we have to connect the current entry with the vertical line descending from the
current directory. If the current level is 0 (as indicated by nActLevel)), we simply
set the SBNEWENDX and SBNEWENDY parts in mLevelPos to the SBNEWSTARTX entry
and the current text position (oActText.Position.Y), respectively. This sets up
mLevelPos so that the next DrawLine( ) call will create a vertical line
(oOldLeavingLine). If the current level is not 0, we have to add a horizontal line
connecting the text box to the descending line from the previous level’s vertical line.
This is achieved in the first part of the second If statement above by creating
oOldArrivingLine.
Horizontal and/or vertical lines are only drawn if bStartUpRun is FALSE, which is
the case for every entry but the very first one. If bStartUpRun is TRUE, it is simply
set to FALSE.
mLevelPos(nActLevel,SBNEWSTARTX) =_
mLevelPos(nActLevel,SBBASEX) + 0.5 * oActText.Size.Width
mLevelPos(nActLevel,SBNEWSTARTY) =_
mLevelPos(nActLevel,SBBASEY) + oActText.Size.Height
nOldHeight = oActText.Size.Height
nOldX = oActText.Position.X
nOldWidth = oActText.Size.Width
nOldLevel = nActLevel
Wend
Close #nFileHandle
Exit Sub
The rest of the main part updates two entries in mLevelPos and a couple of global
variables to reflect the positions of the text and line(s) just drawn. The first two
assignments to mLevelPos update the start coordinates of the line leaving from the
current entry.
5.3.1.5
Utility functions
Some functions take care of repetitive tasks like drawing the actual text and
calculating the current X position.
Function CreateText()
Dim oText As Object
aSize.Width = SBBASEWIDTH
aSize.Height = SBBASEHEIGHT
aPoint.x = CalculateXPoint()
aPoint.y = nOldY + SBRELDIST * nOldHeight
nOldY = aPoint.y
oText = oDocument.createInstance("com.sun.star.drawing.TextShape")
oText.Size = aSize
114
StarOffice Programmer’s Tutorial ♦ May 2000