incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian C <...@amham.net>
Subject Re: Getting bold text from Paragraph
Date Sun, 20 Jan 2013 04:11:20 GMT
Hi Yago,

appologies for the delay in replying. Time gets away from us all ...

I'm afraid I cannot give you a direct answer to your issue.
However, if you look at the code in the TextNavigationTest and the
other navigation tests you may get an idea of how to step through the
document getting what you want.

The tests there refer to the classes in the common.navigation package.

Hope that helps,

On Tue, Jan 15, 2013 at 8:30 PM, Yago Quiñoy Lobariñas
<yquinoy@indenova.com> wrote:
> Hi again Ian.
>
> I'm sorry if my explanation wasnt clear. I'll try again.
>
> Here is my question:
>
> I have a odt file text document that contains just one paragraph with text.
>
> This paragraph just contains plain text. In this text, there's one word with
> bold style.
>
> Then, i open this odt text file wit SimpleApi library and i get the only one
> existing paragraph.
>
> When i want to get the paragraph's text, i use getTextContent() function.
>
> The text i get from this function is the correct one but for the bold text.
> It isn't within this string.
>
> Ok, so, your answer was to use "TextExtractor" and that worked, but i need
> to get every paragraph's portion to check his properties and even change
> them.
>
> How can i get the paragraph's portion for editing them?
>
> Regards. Yago.
>
>
>
>
> El 08/01/2013 15:09, Ian C escribió:
>>
>> Hi,
>>
>>
>> check out the TextExtractor class it uses the visitor pattern to grab the
>> text from child elements.
>>
>> I seem to remember a example in the cookbook.
>>
>> I think your bold text may be ignored because it is in a span element
>> within a paragraph, so your code will not see it.
>>
>> Cheers,
>>
>> Ian
>>
>>
>> On Tuesday, January 8, 2013, Yago Quiñoy Lobariñas <yquinoy@indenova.com>
>> wrote:
>>>
>>> Hi.
>>>
>>> I've loaded a odt file in my Java code and im trying to get all document
>>
>> text with SimpleApi.
>>>
>>> The problem comes when some middle text is marked as bold text. SimpleApi
>>
>> ignores it and just shows the rest of the paragraph's text.
>>>
>>> Here is the code:
>>>
>>> {CODE}
>>> String allText = "";
>>>          try {
>>>              TextDocument odt = TextDocument.loadDocument(docPath);
>>>
>>>              Iterator<Paragraph> ip = odt.getParagraphIterator();
>>>
>>>              while (ip.hasNext()) {
>>>
>>>                  Paragraph paragraph = ip.next();
>>>
>>>                  //All text in paragraph
>>>                  allText = paragraph.getTextContent();
>>>                  System.out.println(allText);
>>>
>>>                  //I'm checking paragraph to ensure that there is my bold
>>
>> text.
>>>
>>>                  TextParagraphElementBase domp =
>>> paragraph.getOdfElement();
>>>                  System.out.println(domp.toString());
>>>
>>>              }
>>>
>>>          } catch (Exception ex) {
>>>              ex.printStackTrace();
>>>          }
>>> {CODE:END}
>>>
>>> An here is the output.
>>>
>>> aaaaaaaaaaaaaacccccccccccccc
>>> <text:p text:style-name="Standard">aaaaaaaaaaaaaa<text:span
>>
>> text:style-name="T1">bbbbbbbbbbbbbbbbb</text:span>cccccccccccccc</text:p>
>>>
>>> Thanks
>>> --
>>> Yago Quiñoy Lobariñas
>>> Área de desarrollo
>>> INDENOVA S.L.
>>> P.I. Vara de Quart
>>> C/Dels Traginers 14, 2º planta izq.
>>> 46014 Valencia
>>> Tel.(34) 96 381 99 47
>>>
>>> yquinoy@indenova.com <mailto:yquinoy@indenova.com>
>>> www.indenova.com <http://www.indenova.com/>
>>>
>>> *RESPETEMOS EL MEDIO AMBIENTE*:¿Necesita realmente imprimir este email?
>>> *PLEASE RESPECT THE ENVIRONMENT*: Do you really need to print this email?
>>> *CONFIDENCIALIDAD*: Este email es confidencial y para uso exclusivo de su
>>
>> destinatario.
>>>
>>> *CONFIDENTIALITY*: This email is confidential and for the exclusive use
>>
>> of its addressee.
>>>
>>>
>>
>> ---------------------------------------------------------------------------------------------------
>>>
>>> Descargue el visor gratuito de archivos firmados electrónicamente eSigna
>>
>> Viewer:
>>>
>>> http://www.indenova.com/eSignaViewer.php
>>>
>>
>> ---------------------------------------------------------------------------------------------------
>>>
>>>
>>>
>
>
> --
> Yago Quiñoy Lobariñas
> Área de desarrollo
> INDENOVA S.L.
> P.I. Vara de Quart
> C/Dels Traginers 14, 2º planta izq.
> 46014 Valencia
> Tel.(34) 96 381 99 47
>
> yquinoy@indenova.com <mailto:yquinoy@indenova.com>
> www.indenova.com <http://www.indenova.com/>
>
> *RESPETEMOS EL MEDIO AMBIENTE*:¿Necesita realmente imprimir este email?
> *PLEASE RESPECT THE ENVIRONMENT*: Do you really need to print this email?
> *CONFIDENCIALIDAD*: Este email es confidencial y para uso exclusivo de su
> destinatario.
> *CONFIDENTIALITY*: This email is confidential and for the exclusive use of
> its addressee.
>
> ---------------------------------------------------------------------------------------------------
> Descargue el visor gratuito de archivos firmados electrónicamente eSigna
> Viewer:
> http://www.indenova.com/eSignaViewer.php
> ---------------------------------------------------------------------------------------------------
>
>



-- 
Cheers,

Ian C

Mime
View raw message