List Info

Thread: Extracting/Handling embedded objects




Extracting/Handling embedded objects
user name
2007-06-27 06:10:06
Hi,

I am working on an export filter for writing accessible
html. I currently
use OOo to export the loaded doc as an html file in order to
handle embedded
objects and graphics. I then parse the OOo generated html to
obtain the
image info. This is not a great approach for handling
certain types of
embedded objects. For example, excel objects embedded in a
word document are
currently saved as an image. I would like to extract the
embedded excel
object and process it in Calc. This would allow me to write
out the embedded
spreadsheet as an html data table. 

Similarly, I would like to extract embedded images and any
associated values
such as brightness etc. I understand this information (ie.
calc objects,
original images etc. are available within the odt file).
However, we need to
do this programmatically without saving the odt or html
etc.

Is this possible via the SDK or would it require an
extension of the core?.

Any thoughts or alternative suggestions are much
appreciated.
-- 
View this message in context: http://www.nabble.com/Extract
ing-Handling-embedded-objects-tf3987670.html#a11322422
Sent from the openoffice - api dev mailing list archive at
Nabble.com.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Extracting/Handling embedded objects
user name
2007-06-27 09:53:05
ian_mcr123 schrieb:

> Hi,
> 
> I am working on an export filter for writing accessible
html. I currently
> use OOo to export the loaded doc as an html file in
order to handle embedded
> objects and graphics. I then parse the OOo generated
html to obtain the
> image info. This is not a great approach for handling
certain types of
> embedded objects. For example, excel objects embedded
in a word document are
> currently saved as an image. I would like to extract
the embedded excel
> object and process it in Calc. This would allow me to
write out the embedded
> spreadsheet as an html data table. 
> 
> Similarly, I would like to extract embedded images and
any associated values
> such as brightness etc. I understand this information
(ie. calc objects,
> original images etc. are available within the odt
file). However, we need to
> do this programmatically without saving the odt or html
etc.
> 
> Is this possible via the SDK or would it require an
extension of the core?.

If you mean "is it possible to get access to the
document representation
behind an OLE object via API" then yes. Details depend
on where you start.

As an example, if you take the collection of embedded
objects in Writer
you can get access to each and every embedded objecht. You
can retrieve
the component (document) behind such an object as a property
of the it
and proceed with documents' API, e.g. the Calc API if the
component is a
Calc document. If you are processing an Excel object in a
Word document
you must make sure that the object is converted to Calc when
the
document is loaded (Tools-Options-Load/Save-MSOffice).

I can't judge whether the Calc API gives you everything you
need but I
assume it does.

I can't say anything about the images. AFAIK ambedded images
are stored
"as is" with no further associated information.

Ciao,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/Gu
llFOSS
Please don't reply to "nospamformbagmx.de".
I use it for the OOo lists and only rarely read other mails
sent to it.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


Re: Extracting/Handling embedded objects
user name
2007-06-27 12:20:06
ian_mcr123 wrote:
> Hi,
>
> I am working on an export filter for writing accessible
html.
First I have to mention that there is already a very exelent
export 
filter available: Henrik Just's Writer2latex

http://fc.hj-gym.dk/~hj

Henrik is currently also working on extracting images etc..

  I currently
> use OOo to export the loaded doc as an html file in
order to handle embedded
> objects and graphics. I then parse the OOo generated
html to obtain the
> image info. This is not a great approach for handling
certain types of
> embedded objects. For example, excel objects embedded
in a word document are
> currently saved as an image. I would like to extract
the embedded excel
> object and process it in Calc. This would allow me to
write out the embedded
> spreadsheet as an html data table. 
>
> Similarly, I would like to extract embedded images and
any associated values
>   
with the basic code below you have a general idee how we
handle this problem
we extrated the images to a external directory while chaging
 the URL's 
to the new location
then we using writer2latex to generate the HTML code who
produces the 
correct links to the exported images

SUB SaveGraphicsToPmgServer()
    Dim oAllGraphics As Object
    Dim oGraphic As Object
    oAllGraphics = oDocument.getGraphicObjects
    Dim n As Integer
        sName = FileNameOutOfPath(sfile)
    sName = removeExtension(sName)
 
    FOR n = 0 to oAllGraphics.Count - 1
        oGraphic = oAllGraphics(n)
          if Lcase(left(oGraphic.GraphicURL,18)) = "http://foto.pmg.be"
 
then
              else   
                'sFName = sName + "F" +
Format(Cstr(n+1), "00") + ".jpg"
            sFName = sName + "F" +
Format(Cstr(mid(oGraphic.name,9,3)), 
"00") + ".jpg"
          
ExportGraphicTo(oGraphic,convertToURL("\pmg-web-cpqfo
to.pmg.be" + 
LEFT(sFName,3) + "" + sFName), 96)
        ChangeLink(oGraphic, n+1)
        endif
    NEXT
 END SUB
'-----------------------------------------------------------
-------

SUB ExportGraphicTo(Graphic As SwXTextGraphicObject,
sURLImageResized As 
String, iPixels As Integer)
    Dim mFileProperties(0) As New
com.sun.star.beans.PropertyValue      
    mFileProperties(0).Name= "Hidden"             
                    
    mFileProperties(0).Value= True                          
           
    Dim oDrawDoc, oDrawPage, oDrawGraphic As Object
    oDrawDoc = 
oDesktop.LoadComponentFromURL("private:factory/sdraw&qu
ot;,"_blank",0,mFileProperties())
    oDrawPage = oDrawDoc.DrawPages(0)
    oDrawGraphic = 
oDrawDoc.createInstance("com.sun.star.drawing.GraphicOb
jectShape")
    Dim SelSize As New com.sun.star.awt.Size
    SelSize = oGraphic.Size
    oDrawGraphic.GraphicURL = oGraphic.GraphicURL
    oDrawGraphic.Size = SelSize
    oDrawPage.add(oDrawGraphic)
    oDrawGraphic.GraphicCrop = oGraphic.GraphicCrop
    oDrawPage.Width = oGraphic.Size.Width
    oDrawPage.Height =  oGraphic.Size.Height
    Dim aFilterData (1) As new
com.sun.star.beans.PropertyValue
    aFilterData(0).Name  = "PixelWidth"        '
    aFilterData(0).Value = oDrawPage.Width/100 * iPixels /
25.40
    aFilterData(1).Name  = "PixelHeight"
    aFilterData(1).Value = oDrawPage.Height/100 * iPixels /
25.40
    Export( oDrawPage, sURLImageResized , aFilterData() )
    On error resume Next
    oDrawDoc.Close(True)
    On error goto 0
END SUB

'-----------------------------------------------------------
--------

SUB Export( xObject, sFileUrl As String, aFilterData )
    Dim xExporter As Object
    xExporter = createUnoService( 
"com.sun.star.drawing.GraphicExportFilter" )
    xExporter.SetSourceDocument( xObject )
    Dim aArgs (2) As new com.sun.star.beans.PropertyValue
    'sFileURL = ConvertToURL(sFileURL)
    aArgs(0).Name  = "FilterName"
    aArgs(0).Value = "jpg"
    aArgs(1).Name  = "URL"
    aArgs(1).Value = sFileURL
    'print sFileURL
    aArgs(2).Name  = "FilterData"
    aArgs(2).Value = aFilterData
    xExporter.filter( aArgs() )
END SUB

'-----------------------------------------------------------
--------

SUB changeLink(oGraphic As Object, index As Integer)

    oGraphic.setPropertyValue("GraphicURL",
"http://foto.pmg.be/" + 
LEFT(sFName,3) + "/" + sFName)
Dim aCrop As New com.sun.star.text.GraphicCrop
    oGraphic.GraphicCrop = aCrop

END SUB

'-----------------------------------------------------------
--------

 
Hope it helps

Fernand

> such as brightness etc. I understand this information
(ie. calc objects,
> original images etc. are available within the odt
file). However, we need to
> do this programmatically without saving the odt or html
etc.
>
> Is this possible via the SDK or would it require an
extension of the core?.
>
> Any thoughts or alternative suggestions are much
appreciated.
>   

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )