Roberto João Lopes Garcia wrote:
Hellow


The com.sun.star.text.TextGraphicObject 's property ActualSize is set 0 in both 
Height and Width when accessed whith a Basic Program in OpenOffice 2.2. (Images 
in an .odt Writer document)

This does not happen in OpenOffice 2.1

I search for a issue but did not found any. Has any one see this behavior or 
register any issue like this?
Roberto, "actual size" is something who is computed by information "stored" in de orginal imagefile, I never trusted the way het is done by OO and you must now that this things are very low on the priorrity list of the OO-coders( even when it is one of the major weaknesses of OO) so in the maen teim i found out some work arounds

i never uses the graphictextobjects to get informations as pixelsize etc... use a com.sun.star.comp.graphic.Graphic object what is kind of a representation of the orginal imagefile
2 way's to optain this object :
- the graphic is "linked":
then uses this function:
function getGraphFromUrl(sFileUrl as String) as Object
 oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
 Dim oPropsIN(0)as new com.sun.star.beans.PropertyValue
 oPropsIN(0).Name  = "URL"
 oPropsIN(0).Value = sFileUrl
 getGraphFromUrl = oProvider.queryGraphic(oPropsIN())
end function
- the graphic is embeded:
then uses this function:
function getGraphFromStream(oInputStream as Object) as Object
 oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
 Dim oPropsIN(0)as new com.sun.star.beans.PropertyValue
 oPropsIN(0).Name  = "InputStream"
 oPropsIN(0).Value = oInputStream
 getGraphFromStream = oProvider.queryGraphic(oPropsIN())
end function
the inpustream can be obtained like:
If InStr(1, sGraphicURL, "vnd.sun.star.GraphicObject:", 0) = 1 Then ' ist a embeded graphic
           ' get the picture name (comes without the extension)
           sGraphicURL = Mid(sGraphicURL, 28, Len(sGraphicURL))
' so search all files in pictures folder for the current picture ...
       For j = 0 to oGraphics.getcount-1
               If InStr(1, mFiles(j), sGraphicURL, 0) Then
                   ' create new name with extension ...
sGraphicName = oGraphic.getName() & Mid(mFiles(j), Len(sGraphicURL)+1, Len(mFiles(j)) oPreviewGraph = getGraphFromStream(oPictures.getByName(mFiles(j)).getInputStream())
              xray oPreviewGraph

exit for else
             end if
next else
    oPreviewGraph  = getGraphFromUrl(sGraphicUrl)
endif do a xray on the founded object an you will see that ist conatisn al the information you need to proper using th grpahic


fernand
Please see code bellow

Thank you

Roberto

 Sub rob_images()
   Dim oDocument As Object
   Dim oText As Object
   Dim oImages As Object
   Dim lista
   Dim oImg As Object
   Dim n As Integer
   Dim rsz_x As Long
   Dim rsz_y As Long
   Dim url As String

   oDocument = ThisComponent
   oText = oDocument.Text
   oImages=oDocument.getGraphicObjects
   lista=oImages.getElementNames()
   tot=UBound(lista)
sMsg="Total: " + tot + " "
   For n = 0 To tot
      sMsg=sMsg + lista(n) + " "
      oImg=oImages.getByIndex(n)
rsz_y=oImg.ActualSize.Height
      rsz_x=oImg.ActualSize.Width
      t_y=oImg.Height
      t_x=oImg.Width
      url=oImg.GraphicURL
      Msgbox "Tamanho Real(" + n + ") " + rsz_x + "   " + rsz_y + " oImg.Height=" + t_y  + " 
oImg.Width=" + t_x + " de " + lista(n) + " URL: " + url
   Next n
MsgBox sMsg,0,"Imagens" End Sub
---------------------------------------------------------------------
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