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/"
a> +
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-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|