Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bold text losing format #73

Open
vexmenon opened this issue Apr 15, 2019 · 16 comments
Open

Bold text losing format #73

vexmenon opened this issue Apr 15, 2019 · 16 comments

Comments

@vexmenon
Copy link

Hi,
The bold text after replacing the word is losing its format. Can anyone please help with it ?.

@ImanGharib
Copy link

I tried to fix this in Bugfix_69. Have you tried with this branch?

@vexmenon
Copy link
Author

Hi Imran,
Ive run the test ExpressionReplacementWithDifferentStyleInParagraphFormattingTest in the bug fix above and the italic text retains its formatting but not the bold text. Can you please suggest what is to be done ?...ive checked out the commit on my local and i am testing the above change

Thanks !!

@ImanGharib
Copy link

Hi vexmenon,
actually you should see the ExpressionReplacementWithFormattingTest class and the ExpressionReplacementWithFormattingTest.docx file. ExpressionReplacementWithDifferentStyleInParagraphFormattingTest is not there any more! Or I am messing with git!!
I just tested the italic in a bold, italic font and added a bold placeholder at the end. It worked just fine.

@ImanGharib
Copy link

test:
layout

and result:
result

@vexmenon
Copy link
Author

vexmenon commented May 27, 2019

Hi Iman,
The text styling is not lost but im getting a run time errror. Stack trace is below :
The error below does not occur on master branch.
Exception message :

Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walkParagraph(CoordinatesWalker.java:96)
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walkContent(CoordinatesWalker.java:71)
at java.util.ArrayList.get(ArrayList.java:433)
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walk(CoordinatesWalker.java:39)
at org.wickedsource.docxstamper.replace.PlaceholderReplacer.resolveExpressionsForParagraph(PlaceholderReplacer.java:107)
at org.wickedsource.docxstamper.replace.PlaceholderReplacer.resolveExpressions(PlaceholderReplacer.java:88)
at org.wickedsource.docxstamper.replace.PlaceholderReplacer$1.onParagraph(PlaceholderReplacer.java:85)
at org.wickedsource.docxstamper.DocxStamper.replaceExpressions(DocxStamper.java:166)
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walkParagraph(CoordinatesWalker.java:96)
at org.wickedsource.docxstamper.DocxStamper.stamp(DocxStamper.java:140)
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walkContent(CoordinatesWalker.java:71)
... 8 common frames omitted
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walk(CoordinatesWalker.java:39)
null
at org.wickedsource.docxstamper.replace.PlaceholderReplacer.resolveExpressions(PlaceholderReplacer.java:88)
at org.wickedsource.docxstamper.DocxStamper.replaceExpressions(DocxStamper.java:166)
at org.wickedsource.docxstamper.DocxStamper.stamp(DocxStamper.java:140)

@vexmenon vexmenon reopened this May 27, 2019
@ImanGharib
Copy link

yes, I am trying to fix it as soon as possible. It happens if a paragraph has no style. It has been already mentioned in #69 by @nor-deen

@ImanGharib
Copy link

Hi @vexmenon ,
i just fixed the problem. It happened if placeholder where in the same run. Tests are O.K. too. Would be glad if you could check it as well.

@vexmenon
Copy link
Author

Hi Iman,
Still getting the same issue. I have modified the NameContext and added three more parameters and added the respective values in ExpressionReplacementWithFormattingTest.docx.
Stack trace of issue :
Attached the file for testing.

ExpressionReplacementWithFormattingTest.docx

org.wickedsource.docxstamper.api.DocxStamperException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

at org.wickedsource.docxstamper.DocxStamper.stamp(DocxStamper.java:147)
at org.wickedsource.docxstamper.DocxStamper.stamp(DocxStamper.java:120)
at org.wickedsource.docxstamper.ExpressionReplacementWithFormattingTest.test(ExpressionReplacementWithFormattingTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at org.wickedsource.docxstamper.replace.PlaceholderReplacer.resolveExpressionsForParagraph(PlaceholderReplacer.java:107)
at org.wickedsource.docxstamper.replace.PlaceholderReplacer$1.onParagraph(PlaceholderReplacer.java:85)
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walkParagraph(CoordinatesWalker.java:96)
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walkContent(CoordinatesWalker.java:71)
at org.wickedsource.docxstamper.util.walk.CoordinatesWalker.walk(CoordinatesWalker.java:39)
at org.wickedsource.docxstamper.replace.PlaceholderReplacer.resolveExpressions(PlaceholderReplacer.java:88)
at org.wickedsource.docxstamper.DocxStamper.replaceExpressions(DocxStamper.java:166)
at org.wickedsource.docxstamper.DocxStamper.stamp(DocxStamper.java:140)

@ImanGharib
Copy link

ok. it takes more time as I supposed :( . I will try to fix that. Till then I withdraw the pull request

@trampolinetech
Copy link

ok. it takes more time as I supposed :( . I will try to fix that. Till then I withdraw the pull request

Hey Iman,
Any luck with the issue mentioned above ?.

Thanks & Regards

@vexmenon
Copy link
Author

Hey Iman,
Any luck with the issue mentioned above ?.

Thanks & Regards

@ImanGharib
Copy link

Hi, I was really busy. I will try to fix it this week.
Regards Iman

@vexmenon
Copy link
Author

vexmenon commented Aug 1, 2019 via email

@feller
Copy link

feller commented Mar 31, 2020

Hi! Any update on this? I'm getting the same issue, thanks!

@montoyaedu
Copy link

This is an interesting problem to solve.

@caring-coder
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants