I have to parse .odt document to html manualy.
I have to save default format of each paragraph and each text portion in it.
In the document I parse, sometimes I meet something like that:
some text IMAGE some text.
So I need to get that image, get its size, and save it.
All images anchor type is char.
Parsing looks like(written in C#):
Code: Select all
OOo.container.XEnumerationAccess xEnumerationAccess =
(OOo.container.XEnumerationAccess )currentDoc.getText();
OOo.container.XEnumeration xParagraphEnumeration =
xEnumerationAccess.createEnumeration();
while (xParagraphEnumeration.hasMoreElements())
{
uno.Any element = xParagraphEnumeration.nextElement();
XServiceInfo xinfo = (XServiceInfo)element.Value;
OOo.text.XTextContent xTextElement = (OOo.text.XTextContent)element.Value;
OOo.container.XEnumerationAccess xParaEnumerationAccess =
(OOo.container.XEnumerationAccess)xTextElement;
// create text portion enum
OOo.container.XEnumeration xTextPortionEnum =
xParaEnumerationAccess.createEnumeration();
//for each text portion
while (xTextPortionEnum.hasMoreElements())
{
uno.Any content = xTextPortionEnum.nextElement();
OOo.text.XTextRange xTextPortion =
(OOo.text.XTextRange)content.Value;
OOo.beans.XPropertySet xTextProps = (OOo.beans.XPropertySet)xTextPortion;
if (xTextProps.getPropertyValue("CharWeight").Value.ToString() == OOo.awt.FontWeight.BOLD.ToString())
{
isBold = true;
}
if (xTextProps.getPropertyValue("CharPosture").Value.ToString() == OOo.awt.FontSlant.ITALIC.ToString())
{
isItalic = true;
}
portionString = xTextPortion.getString();
if (portionString == "")
{
// Is an Image there?
}
if (isBold)
portionString = "<b>" + portionString + "</b>";
if (isItalic)
portionString = "<i>" + portionString + "</i>";
HtmlString += portionString;
}
How to get an image from range?
Thanks.