Thanks. Below are some relevant code snippets. This might be related to my
message titled: "macro only works when there is a breakpoint". I haven't been
able to reproduce this bug with a breakpoint and stepping over the code. When I
step over the code, I switch between the macro window and the document window
to see the behavior. I wonder if this causes some sort of a refresh that is
lacking in my code?
thanks
doug
sub x
iCount = oPage.getCount
For i = 0 to iCount - 1
oShape = oPage.getByIndex( i )
ShapeName = oShape.getName
if ...
elseIf ( ShapeName = "ClientLogoBBCover" ) then
SizeAndPlaceGraphic( oShape, oPage, "ClientLogoCover" )
elseIf ( ShapeName = "ClientLogoBBSpine1" ) then
SizeAndPlaceGraphic( oShape, oPage, "ClientLogoSpine1" )
elseIf ( ShapeName = "ClientLogoBBSpine2" ) then
SizeAndPlaceGraphic( oShape, oPage, "ClientLogoSpine2" )
elseIf ( ShapeName = "ClientLogoBBSpine3" ) then
SizeAndPlaceGraphic( oShape, oPage, "ClientLogoSpine3" )
end if
Next
end sub
sub SizeAndPlaceGraphic( BoundingBox as SvxShapeText, oPage as SdDrawPage,
GraphicName )
Dim oSize As New com.sun.star.awt.Size
Dim oPos As New com.sun.star.awt.Point
dim oGraphic
iCount = oPage.getCount
For i = 0 to iCount - 1
oShape = oPage.getByIndex( i )
ShapeName = oShape.getName
if (ShapeName = GraphicName) then
oGraphic = oShape
end if
next
if isEmpty( oGraphic ) then
oGraphic = ThisComponent.createInstance(
"com.sun.star.drawing.GraphicObjectShape" )
oGraphic.Name = GraphicName
oPage.add(oGraphic)
end if
cUrl = ConvertToUrl( oDialog.GetControl( "FileControl1" ).Text )
if ( cUrl = "" ) then
rem No client logo selected
oSize.height = 0
oSize.width = 0
oGraphic.setSize( oSize )
else
maxW = BoundingBox.size.width
maxH = BoundingBox.size.height
oGraphic.SetPosition( BoundingBox.position )
oGraphic.GraphicURL = cUrl
OriginalAspectRatio = oGraphic.Graphic.SizePixel.width /
oGraphic.Graphic.SizePixel.height
oSize.height=maxH
oSize.width= OriginalAspectRatio * oSize.height
if ( oSize.width > maxW ) then
Shrink = maxW / oSize.width
oSize.width = maxW
oSize.height = oSize.height * Shrink
end if
oGraphic.setSize(oSize)
end if
end sub
> Douglas Staas wrote:
>
> >Attached is my newest binder cover Draw file. It prompts the user for a
> >"client
> >logo" and it displays the image in 4 locations. Sometimes all 4 locations
> >are
> >updated, sometimes 1, sometimes 2, 3 or ever zero. When less then 4
> >locations
> >are updated, you can save the file, close it, reopen it and magically all 4
> >locations show the correct image. What's going on here? I'm running the same
> code with the same input and getting different results.
> >
> >... actually, it looks like the attachment is too large for this list.
> >
> >
> In general, attachements are highly discouraged. Assume that I add a 1MB
> attachemt and send my email. Many people will recieve this one MB
> attachement. The majority do not care to see the attachement. Many of
> the people use a dial-up connection. So, most mailing lists
> automatically remove attachements. The preferred method is for you to
> host the document somewhere and then provide a link to it.
>
> That said, there are many possible reasons for this particular problem.
> Sometimes, I have found that making some very simple rediculous change
> causes the problem to go away. Without looking at the macro, this is
> very difficult to say. I can think of a few things off hand that MIGHT
> cause the problem.
>
> You create the object in such a way that the SAME object (or some shared
> portion is the same) is used in all places. When you save the document,
> only a reference is saved, and on opening, an entirely new copy is
> properly created for each object. I had this really strange problem
> while using arrays and strings. It turned out that I was storing a
> reference to a string each time that I added it to the array . When I
> was finished, every instance had the same value because they all
> referenced the same variable instance. It was very strange indeed.
>
> If possible, create the smallest simplest macro that demonstrates the
> problem, and then if the macro is short, simply add it here. If not,
> then create it in a document such that it can demonstrate the problem
> and then post the document and send a link to the list.
>
> --
> Andrew Pitonyak
> My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
> My Book: http://www.hentzenwerke.com/catalog/oome.htm
> Info: http://www.pitonyak.org/oo.php
> See Also: http://documentation.openoffice.org/HOW_TO/index.html
>
>
> ---------------------------------------------------------------------
> 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]