Hello ODF community,

I would really appreciate if I can get a guidance with my question.
My task is to programmatically remove any pictures within the odt document
using java. The only time when it fails to remove the pictures is when an
ODF document (like the one attached) has a picture anchored to a paragraph
as a background image (that seems to be attached to a header).

When trying to solve this particular case, I unzipped the odt and the only
reference to the Pictures was in style.xml, where Mfr1 is within the
office:automatic-styles tag:

> <style:style style:name="Mfr1" style:family="graphic"
> style:parent-style-name="Frame"><style:graphic-properties fo:margin-left=
> "0.1252in" fo:margin-right="0.1252in" fo:margin-top="0in"
> fo:margin-bottom="0in" style:run-through="background" style:wrap=
> "run-through" style:number-wrapped-paragraphs="no-limit"
> style:vertical-pos="middle" style:vertical-rel="paragraph"
> style:horizontal-pos="center" style:horizontal-rel="page-content"
> fo:background-color="#ffffff" style:background-transparency="100%"
> fo:padding="0in" fo:border="none" style:mirror="none" fo:clip="rect(0in,
> 0in, 0in, 0in)" draw:luminance="0%" draw:contrast="0%" draw:red="0%"
> draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion=
> "false" draw:image-opacity="100%" draw:color-mode="standard"
> style:flow-with-text="false" draw:wrap-influence-on-position=
> "once-successive"><style:background-image/>
> </style:graphic-properties></style:style>
>
<style:page-layout style:name="Mpm1"><style:page-layout-properties
> fo:page-width="8.5in" fo:page-height="11in" style:num-format="1"
> style:print-orientation="portrait" fo:margin-top="0.5in" fo:margin-bottom=
> "0.5in" fo:margin-left="1in" fo:margin-right="1in" fo:border="none"
> fo:padding="0in" style:writing-mode="lr-tb" style:footnote-max-height=
> "0in"><style:footnote-sep style:width="0.0071in"
> style:distance-before-sep="0.0398in" style:distance-after-sep="0.0398in"
> style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
> </style:page-layout-properties><style:header-style>
> <style:header-footer-properties fo:min-height="0.5in" fo:margin-bottom=
> "0.461in" style:dynamic-spacing="true"/>
> </style:header-style><style:footer-style><style:header-footer-properties
> fo:min-height="0.5in" fo:margin-top="0.461in" style:dynamic-spacing="true"
> /></style:footer-style></style:page-layout>
>
And fr1 style is referenced in content.xml:

> <style:style style:name="fr1" style:family="graphic"
> style:parent-style-name="Frame">
> <style:graphic-properties fo:margin-left="0.1252in" fo:margin-right=
> "0.1252in" fo:margin-top="0in" fo:margin-bottom="0in" style:run-through=
> "background" style:wrap="run-through" style:number-wrapped-paragraphs=
> "no-limit" style:vertical-pos="middle" style:vertical-rel="paragraph"
> style:horizontal-pos="center" style:horizontal-rel="page-content"
> fo:background-color="#ffffff" style:background-transparency="100%"
> fo:padding="0in" fo:border="none" style:mirror="none" fo:clip="rect(0in,
> 0in, 0in, 0in)" draw:luminance="0%" draw:contrast="0%" draw:red="0%"
> draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion=
> "false" draw:image-opacity="100%" draw:color-mode="standard"
> style:flow-with-text="false" draw:wrap-influence-on-position=
> "once-successive">
> <style:background-image/>
> </style:graphic-properties>
> </style:style>




 I tried using ODFDOM to find ChildNodes for masterStyles like this:

textDocument = OdfTextDocument.newTextDocument();
> OdfOfficeMasterStyles masterStyles = textDocument.getOfficeMasterStyles();
> OdfStyleMasterPage masterPage = masterStyles.getMasterPage("Standard");


but NodeList is empty. Similarly for 'par', when i use this method:

XPath xpath = XPathFactory.newInstance().newXPath();
>   xpath.setNamespaceContext(new OdfNamespace());
>   OdfOfficeStyles  par = (OdfOfficeStyles) xpath.evaluate(
> "//style:graphic-properties", textDocument.getOfficeMasterStyles(),
> XPathConstants.NODE);


I also can't reach down to draw:image elements when i traverse using
getElementsByTagName("*") on textDocument.getDocumentStyles(),
textDocument.getOfficeBody()
and textDocument.getContentDom()


Perhaps, there is a way to access the image node in that document that i am
not aware of. Would really appreciate any help!

-- 
Elena Sergienko
Green Filing, LLC

Web: www.greenfiling.com
Phone: (801) 448-7268
Cell: (765) 277-3173

Attachment: imageExample.odt
Description: application/vnd.oasis.opendocument.text

Reply via email to