You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2008/06/24 16:39:10 UTC

DO NOT REPLY [Bug 45269] New: but at replaceText function - String index out of range: -5

https://issues.apache.org/bugzilla/show_bug.cgi?id=45269

           Summary: but at replaceText function -  String index out of
                    range: -5
           Product: POI
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: critical
          Priority: P2
         Component: HWPF
        AssignedTo: dev@poi.apache.org
        ReportedBy: fabioebner@hotmail.com


Created an attachment (id=22168)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22168)
.java and .doc file

when i try to replace some text, sometimes the funciont dont got the all text
in paragraph, i do one loop to got all text in paragraph but i got that error:

 at java.lang.StringBuffer.substring(StringBuffer.java:416)
Paragraph Text: 14as
offset - > -1
X = 14
String index out of range: -5
+ + + + + Word Dokument bearbeitet + + + + +
        at org.apache.poi.hwpf.usermodel.Range.text(Range.java:270)
        at org.apache.poi.hwpf.usermodel.HWPF.work(HWPF.java:84)
        at org.apache.poi.hwpf.usermodel.HWPF.<init>(HWPF.java:25)
        at testeword.Main.main(Main.java:51)



look at line Paragraph Text: 14as when te all text are 14asdasd  and other
bug..


when i have some big text that continue in another line, she got like another
paragraph but is not, because i dont press ENTER the line end and continue at
line down


sorry my english


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45269] but at replaceText function - String index out of range: -5

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45269


Piotr Gawron <pi...@cs.put.poznan.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |piotr.gawron@cs.put.poznan.
                   |                            |pl




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45269] but at replaceText function - String index out of range: -5

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45269





--- Comment #1 from Piotr Gawron <pi...@cs.put.poznan.pl>  2009-04-01 06:16:20 PST ---
Created an attachment (id=23433)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23433)
Patch to this bug

Changes:
scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
now the modification of size of Range during text replacement is changed
recursively to upper levels

scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java
test case to this bug was added

scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java
there was one error in this test case - after replacing text with new, longer
text number of paragraphs in section changed (5->4), but it shouldn't

This patch need also the *.doc file which was attached before as
scratchpad\testcases\org\apache\poi\hwpf\data\Bug45269.doc

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45269] but at replaceText function - String index out of range: -5

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45269

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #2 from Nick Burch <ni...@alfresco.com> 2010-06-04 13:20:02 EDT ---
Thanks for this patch. Applied with slight tweaks in r951498.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: DO NOT REPLY [Bug 45269] but at replaceText function - String index out of range: -5

Posted by "N. Hira" <nh...@cognocys.com>.
Fabio,

The current version of replaceText() forces you to re-create your  
range after every replacement (using HWPFDocument.getRange() or  
whatever).

I tested this using a slightly modified version of the HWPF.java file  
you attached and it works if I just add the following to your replace  
code:
	para.replaceText("campo1", " foi porraaaaa ", offset);
+	// rebuild the range...
+	range = doc.getRange();

There is another patch attached to bug 45252 that will allow you to  
work without rebuilding the range.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45252

In short:
1.  You can rebuild the range as a work-around
2.  You can use the patch and it will simplify your loop to one  
statement

-h

On 24-Jun-2008, at 9:39 AM, bugzilla@apache.org wrote:

> https://issues.apache.org/bugzilla/show_bug.cgi?id=45269
>
>
> Fabio Ebner <fa...@hotmail.com> changed:
>
>            What    |Removed                     |Added
> ---------------------------------------------------------------------- 
> ------
>                  CC|                            | 
> fabioebner@hotmail.com
>
>
>
>
> -- 
> Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi? 
> tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
>





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 45269] but at replaceText function - String index out of range: -5

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45269


Fabio Ebner <fa...@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fabioebner@hotmail.com




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org