Embedded Image

View: New views
7 Messages — Rating Filter:   Alert me  

Embedded Image

by Emilio Cano - Tecnotur 3000 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello!
I am a spanish programmer and I have a problem.
I am doing an export to openoffice and try to insert a picture just makes me
so linked, and need to be embedded, how can I do that?
Using Delphi 7.0

The code I use for this is:

 

  Imagen := Document.createInstance('com.sun.star.text.GraphicObject');

 

  Imagen.GraphicURL := ConvertirAURL(archivo);

  Imagen.Width := 3000;

  Imagen.Height := 3000;

 

  Imagen.setPropertyValue('GraphicURL',ConvertirAURL(archivo));

 

  oText.InsertTextContent( oCursor, Imagen, false);

 

Thanks and best regards!


Re: Embedded Image

by Ariel Constenla-Haile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Emilio,

On Tuesday 16 June 2009, 08:24, Emilio Cano - Tecnotur 3000 wrote:
> Hello!
> I am a spanish programmer and I have a problem.
> I am doing an export to openoffice and try to insert a picture just makes
> me so linked, and need to be embedded, how can I do that?


http://api.openoffice.org/servlets/BrowseList?list=dev&by=thread&from=2205233
spec. http://api.openoffice.org/servlets/ReadMsg?list=dev&msgNo=20940 and next

(you could have googled it http://www.google.com/search?q=openoffice+embed+image 
and find it in the first result page; or search this mailing list archive
http://api.openoffice.org/servlets/SearchList?list=dev&searchText=embed+image&defaultField=body&Search=Search
you get the answer in the first result line, then follow "Browse this thread")

Regards
--
Ariel Constenla-Haile
La Plata, Argentina

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Embedded Image

by Fernand Vanrie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Emilio ,

you need first a shape who has a internal URL and then use these
internal URL for your embedded Graphic

us code like:

GraphicURL := ConvertirAURL(archivo);

 oOriginalGraph  = getGraphFromUrl(sGraphicURL)
 oShape =
oDocument.createInstance("com.sun.star.drawing.GraphicObjectShape")
  oGraphic1 = oDocument.createInstance("com.sun.star.text.GraphicObject")
  oDocument.getDrawPage().add(oShape)
  oShape.Graphic = oOriginalGraph

   oGraphic1.GraphicUrl = oShape.GraphicUrl
   ' Insert at the current cursor location
 
oText.insertTextContent(oDocument.getCurrentController().getViewCursor(),
oGraphic1, false)
  'We no longer require the shape object.
      oDocument.getDrawPage().reMove(oShape)
   

> Hello!
> I am a spanish programmer and I have a problem.
> I am doing an export to openoffice and try to insert a picture just makes me
> so linked, and need to be embedded, how can I do that?
> Using Delphi 7.0
>
> The code I use for this is:
>
>  
>
>   Imagen := Document.createInstance('com.sun.star.text.GraphicObject');
>
>  
>
>   Imagen.GraphicURL := ConvertirAURL(archivo);
>
>   Imagen.Width := 3000;
>
>   Imagen.Height := 3000;
>
>  
>
>   Imagen.setPropertyValue('GraphicURL',ConvertirAURL(archivo));
>
>  
>
>   oText.InsertTextContent( oCursor, Imagen, false);
>
>  
>
> Thanks and best regards!
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Embedded Image

by Ariel Constenla-Haile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Fernand,

On Tuesday 16 June 2009, 09:48, Fernand Vanrie wrote:

> Emilio ,
>
> you need first a shape who has a internal URL and then use these
> internal URL for your embedded Graphic
>
> us code like:
>
> GraphicURL := ConvertirAURL(archivo);
>
>  oOriginalGraph  = getGraphFromUrl(sGraphicURL)
>  oShape =
> oDocument.createInstance("com.sun.star.drawing.GraphicObjectShape")
>   oGraphic1 = oDocument.createInstance("com.sun.star.text.GraphicObject")
>   oDocument.getDrawPage().add(oShape)
>   oShape.Graphic = oOriginalGraph
>
>    oGraphic1.GraphicUrl = oShape.GraphicUrl
>    ' Insert at the current cursor location
>
> oText.insertTextContent(oDocument.getCurrentController().getViewCursor(),
> oGraphic1, false)
>   'We no longer require the shape object.
>       oDocument.getDrawPage().reMove(oShape)

this is what I'd call the the old work-around/bad way
http://api.openoffice.org/servlets/ReadMsg?list=dev&msgNo=20941
Now just use the Graphic property, instead of the GraphicURL.

Regards
--
Ariel Constenla-Haile
La Plata, Argentina

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Embedded Image

by Fernand Vanrie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hallo Ariel ,

the opengrok link is not working, maybe you can write it down in basic? :-)

Thanks

Fernand

> Hello Fernand,
>
> On Tuesday 16 June 2009, 09:48, Fernand Vanrie wrote:
>  
>> Emilio ,
>>
>> you need first a shape who has a internal URL and then use these
>> internal URL for your embedded Graphic
>>
>> us code like:
>>
>> GraphicURL := ConvertirAURL(archivo);
>>
>>  oOriginalGraph  = getGraphFromUrl(sGraphicURL)
>>  oShape =
>> oDocument.createInstance("com.sun.star.drawing.GraphicObjectShape")
>>   oGraphic1 = oDocument.createInstance("com.sun.star.text.GraphicObject")
>>   oDocument.getDrawPage().add(oShape)
>>   oShape.Graphic = oOriginalGraph
>>
>>    oGraphic1.GraphicUrl = oShape.GraphicUrl
>>    ' Insert at the current cursor location
>>
>> oText.insertTextContent(oDocument.getCurrentController().getViewCursor(),
>> oGraphic1, false)
>>   'We no longer require the shape object.
>>       oDocument.getDrawPage().reMove(oShape)
>>    
>
> this is what I'd call the the old work-around/bad way
> http://api.openoffice.org/servlets/ReadMsg?list=dev&msgNo=20941
> Now just use the Graphic property, instead of the GraphicURL.
>
> Regards
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Embedded Image

by Ariel Constenla-Haile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Fernand,

On Tuesday 16 June 2009, 10:13, Fernand Vanrie wrote:
> Hallo Ariel ,
>
> the opengrok link is not working,

change DEV300_m** by the most recent, like DEV300_m50
http://svn.services.openoffice.org/opengrok/xref/DEV300_m50/odk/examples/java/Text/GraphicsInserter.java#155

> maybe you can write it down in basic? :-)

here you have it :-)

REM  *****  BASIC  *****

Option Explicit


Sub Writer_Demo
        Dim oDoc as Object
        oDoc = CreateNewDoc("writer")
       
        Dim sImage$
        sImage = getGalleryPath() & "/www-back/aqua.jpg"
        Dim oImage as Object
        oImage = CreateEmbeddedGraphicObject(oDoc, sImage)
        oImage.Width = 5000
        oImage.Height = 5000
       
        Dim oText as Object, oCursor as Object
        oText = oDoc.getText()
        oCursor = oText.createTextCursorByRange(oText.getStart())
        oText.insertTextContent(oCursor, oImage, False)
End Sub

Sub Draw_Demo
        Dim oDoc as Object
        oDoc = CreateNewDoc("draw")
       
        Dim oDrawPage as Object
        oDrawPage = oDoc.getDrawPages().getByIndex(0)
       
        Dim sImage$
        sImage = getGalleryPath() & "/www-back/aqua.jpg"
        Dim oImage as Object
        oImage = CreateEmbeddedGraphicObject(oDoc, sImage)
       
        Dim aSize as New com.sun.star.awt.Size
        aSize.Width = 5000
        aSize.Height = 5000
        Dim aPos as New com.sun.star.awt.Point
        aPos.X = CInt(oDrawPage.Width/2 - aSize.Width/2)
        aPos.Y = CInt(oDrawPage.Height/2 - aSize.Height/2)
       
        oImage.setSize(aSize)
        oImage.setPosition(aPos)

        oDrawPage.add(oImage)
End Sub


Function CreateNewDoc( sDocType as String, _
                                                Optional MediaDescriptor(), _
                                                Optional sFrame as String ) as Object
        On Error Resume Next
        If IsMissing(MediaDescriptor()) then MediaDescriptor() = Array()
        If IsMissing(sFrame) then sFrame = "_default"
        CreateNewDoc = StarDesktop.loadComponentFromURL(_
                                        "private:factory/s" & sDocType , _
                                        sFrame, 0, MediaDescriptor())
End Function


Function CreateEmbeddedGraphicObject( oDoc as Object, sURL as String ) as
Object
        On Error Resume Next
        Dim sService as String
        If oDoc.supportsService("com.sun.star.text.TextDocument") Then
                sService = "com.sun.star.text.TextGraphicObject"
        Else
                sService = "com.sun.star.drawing.GraphicObjectShape"
        End If
       
        Dim oGraphicObject as Object
        oGraphicObject = oDoc.createInstance(sService)
        oGraphicObject.setPropertyValue("Graphic", getGraphicFromURL(sURL))
       
        CreateEmbeddedGraphicObject = oGraphicObject
End Function


Function getGraphicFromURL( sURL as String) as com.sun.star.graphic.XGraphic
        On Error Resume Next
        Dim oGraphicProvider as Object
        oGraphicProvider = createUnoservice("com.sun.star.graphic.GraphicProvider")
       
        Dim aMediaProperties(0) as New com.sun.star.beans.PropertyValue
        aMediaProperties(0).Name = "URL"
        aMediaProperties(0).Value = sURL

        getGraphicFromURL = oGraphicProvider.queryGraphic(aMediaProperties)
End Function


Function getGalleryPath() as String
        On Error Resume Next
        Dim oPathSettings as Object
        oPathSettings = createUNOService("com.sun.star.util.PathSettings")
       
        Dim sPath$
        sPath = oPathSettings.getPropertyValue("Gallery")
        If InStr(sPath, ";") Then
                Dim sPaths()
                sPaths = Split(sPath, ";")
                sPath = sPaths(0)
        End If
        getGalleryPath = sPath
End Function


Regards
--
Ariel Constenla-Haile
La Plata, Argentina

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Embedded Image

by Fernand Vanrie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ariel ,

You are a hero , it works like a charme
thanks for all  your time spended to make us (dummy's) smarter  ,)

Greetz Fernand

> Hello Fernand,
>
> On Tuesday 16 June 2009, 10:13, Fernand Vanrie wrote:
>  
>> Hallo Ariel ,
>>
>> the opengrok link is not working,
>>    
>
> change DEV300_m** by the most recent, like DEV300_m50
> http://svn.services.openoffice.org/opengrok/xref/DEV300_m50/odk/examples/java/Text/GraphicsInserter.java#155
>
>  
>> maybe you can write it down in basic? :-)
>>    
>
> here you have it :-)
>
> REM  *****  BASIC  *****
>
> Option Explicit
>
>
> Sub Writer_Demo
> Dim oDoc as Object
> oDoc = CreateNewDoc("writer")
>
> Dim sImage$
> sImage = getGalleryPath() & "/www-back/aqua.jpg"
> Dim oImage as Object
> oImage = CreateEmbeddedGraphicObject(oDoc, sImage)
> oImage.Width = 5000
> oImage.Height = 5000
>
> Dim oText as Object, oCursor as Object
> oText = oDoc.getText()
> oCursor = oText.createTextCursorByRange(oText.getStart())
> oText.insertTextContent(oCursor, oImage, False)
> End Sub
>
> Sub Draw_Demo
> Dim oDoc as Object
> oDoc = CreateNewDoc("draw")
>
> Dim oDrawPage as Object
> oDrawPage = oDoc.getDrawPages().getByIndex(0)
>
> Dim sImage$
> sImage = getGalleryPath() & "/www-back/aqua.jpg"
> Dim oImage as Object
> oImage = CreateEmbeddedGraphicObject(oDoc, sImage)
>
> Dim aSize as New com.sun.star.awt.Size
> aSize.Width = 5000
> aSize.Height = 5000
> Dim aPos as New com.sun.star.awt.Point
> aPos.X = CInt(oDrawPage.Width/2 - aSize.Width/2)
> aPos.Y = CInt(oDrawPage.Height/2 - aSize.Height/2)
>
> oImage.setSize(aSize)
> oImage.setPosition(aPos)
>
> oDrawPage.add(oImage)
> End Sub
>
>
> Function CreateNewDoc( sDocType as String, _
> Optional MediaDescriptor(), _
> Optional sFrame as String ) as Object
> On Error Resume Next
> If IsMissing(MediaDescriptor()) then MediaDescriptor() = Array()
> If IsMissing(sFrame) then sFrame = "_default"
> CreateNewDoc = StarDesktop.loadComponentFromURL(_
> "private:factory/s" & sDocType , _
> sFrame, 0, MediaDescriptor())
> End Function
>
>
> Function CreateEmbeddedGraphicObject( oDoc as Object, sURL as String ) as
> Object
> On Error Resume Next
> Dim sService as String
> If oDoc.supportsService("com.sun.star.text.TextDocument") Then
> sService = "com.sun.star.text.TextGraphicObject"
> Else
> sService = "com.sun.star.drawing.GraphicObjectShape"
> End If
>
> Dim oGraphicObject as Object
> oGraphicObject = oDoc.createInstance(sService)
> oGraphicObject.setPropertyValue("Graphic", getGraphicFromURL(sURL))
>
> CreateEmbeddedGraphicObject = oGraphicObject
> End Function
>
>
> Function getGraphicFromURL( sURL as String) as com.sun.star.graphic.XGraphic
> On Error Resume Next
> Dim oGraphicProvider as Object
> oGraphicProvider = createUnoservice("com.sun.star.graphic.GraphicProvider")
>
> Dim aMediaProperties(0) as New com.sun.star.beans.PropertyValue
> aMediaProperties(0).Name = "URL"
> aMediaProperties(0).Value = sURL
>
> getGraphicFromURL = oGraphicProvider.queryGraphic(aMediaProperties)
> End Function
>
>
> Function getGalleryPath() as String
> On Error Resume Next
> Dim oPathSettings as Object
> oPathSettings = createUNOService("com.sun.star.util.PathSettings")
>
> Dim sPath$
> sPath = oPathSettings.getPropertyValue("Gallery")
> If InStr(sPath, ";") Then
> Dim sPaths()
> sPaths = Split(sPath, ";")
> sPath = sPaths(0)
> End If
> getGalleryPath = sPath
> End Function
>
>
> Regards
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...