i've done the following function in VB.NET to insert an embedded image. it
works fine, still has a problem. When i try to save the document in DOC
format the image is resized to a height of 0% :( so is not showed. Any
ideias????



Private Sub InsertImage(ByVal aDocument As XTextDocument, ByVal
strImgFileName As String, ByVal aRange As XTextRange, ByVal SizeWidth As
Integer, ByVal SizeHeight As Integer, Optional ByVal strImageName As String
= "")
       Dim MyLTextRange As XTextRange
       MyLTextRange = aRange

       Dim MyBitMapContainer As
unoidl.com.sun.star.container.XNameContainer

       MyBitMapContainer = DirectCast(aDocument,
XMultiServiceFactory).createInstance("com.sun.star.drawing.BitmapTable")

       Dim MyImage As XTextContent

       MyImage = DirectCast(aDocument,
XMultiServiceFactory).createInstance("com.sun.star.text.TextGraphicObject")

       Dim MyPropSet As XPropertySet

       MyPropSet = DirectCast(MyImage, XPropertySet)

       MyBitMapContainer.insertByName(strImageName, New uno.Any
(strImgFileName))

       Dim strInternalURL As String

       strInternalURL = MyBitMapContainer.getByName(strImageName).Value

       MyPropSet.setPropertyValue("AnchorType", New uno.Any(
TextContentAnchorType.AS_CHARACTER))
       MyPropSet.setPropertyValue("GraphicURL", New uno.Any
(strInternalURL))
       MyPropSet.setPropertyValue("Width", New uno.Any(SizeWidth))
       MyPropSet.setPropertyValue("Height", New uno.Any(SizeHeight))

       MyLTextRange.getText.insertTextContent(MyLTextRange, MyImage, False)
       MyBitMapContainer.removeByName(strImageName)


   End Sub

--
__________________________________________________________
"O único lugar onde o sucesso vem antes que o trabalho é no dicionário"

Reply via email to