Bug 39324

Summary: RichTextRun.setBold and RichTextRun.setItalic corrupt the underlying StyleTextPropAtom.
Product: POI Reporter: Yegor Kozlov <yegor>
Component: HSLFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: test case which demonstrates the bug
Test which confirms that the problem exists

Description Yegor Kozlov 2006-04-17 15:47:39 UTC
Hi Nick

It seems something is wrong with RichTextRun class.

setBold or setItalic operations corrupt the underlying StyleTextPropAtom.
To see the problem run the attached TestShapes.testTextBoxWrite.

The problems is only with flag values (bold, italic, underline). 
If I set only font size everything is OK. I save the file, read it again and see
the correct font size.
But if I call setBold or setItalic things go wrong and after save font
size = 0.

I did work in the past. I guess you missed something after when
refactored this class lately.

Regards, Yegor Kozlov
Comment 1 Yegor Kozlov 2006-04-17 15:48:58 UTC
Created attachment 18113 [details]
test case which demonstrates the bug
Comment 2 Nick Burch 2006-04-19 10:00:31 UTC
Bah. There had been a bug in how the mask textprops wrote themselves out. I
guess I didn't quite get it right when I tried to fix it :(
Comment 3 Nick Burch 2006-04-19 11:42:21 UTC
This is odd. I've just run your test, and it passes just fine for me....

Can you do a svn update, then an ant clean, then try your test again? Quite odd
that it passes for me but not for you.
Comment 4 Yegor Kozlov 2006-04-19 15:54:54 UTC
(In reply to comment #3)
> This is odd. I've just run your test, and it passes just fine for me....
> 
> Can you do a svn update, then an ant clean, then try your test again? Quite odd
> that it passes for me but not for you.

this is really odd!
When I run tests  in IntelliJ Idea 4.0 I got errors! When I run them by ant they
pass! Probably something is wrong with my IDE. I need to investigate it in details.
Comment 5 Nick Burch 2006-04-19 16:19:47 UTC
I've had similar problems with Eclipse, when its idea of where to build class
files to differred from ant's

Glad it's all fixed though :)
Comment 6 Yegor Kozlov 2006-04-20 12:42:25 UTC
Nick,

It seems the order in which tests are running is important. 

Comment all tests in TestShapes but testTextBoxWrite, recompile, run and get
this error!

In our case JUnit first runs testTextBoxRead() and then testTextBoxWrite(). It
looks like
the first test affects the others!
 To make sure I created a standalone program with main() and confirmed that the
error exists.

I attached the new test case.

Look at the line 45:
new SlideShow(new HSLFSlideShow(filename));

With this line test succeeds. Comment it and the test fails! 

I debugged it a little bit. It seems some static initializes are not set properly.
When test fails Variable subPropMasks in BitMaskTextProp.setSubValue
is filled with 0, otherwise there are some values.

Please check it.

Yegor


Comment 7 Yegor Kozlov 2006-04-20 12:44:36 UTC
Created attachment 18146 [details]
Test which confirms that the problem exists

Forgot to mention:
 It fails in both cases: under Ant and in IntelliJ Idea.
Comment 8 Nick Burch 2006-04-21 11:33:56 UTC
Oww oww, this bug hurts my head....

You weren't resetting sl after the load, which wasn't helping. However, I've now
got my hands on the real data that gets written out for the StyleTextPropAtom,
now to figure out why it's not correct!
Comment 9 Nick Burch 2006-04-21 13:47:08 UTC
OK, I've found two bugs (and a fault in the test....)

Firstly, there was a bug with the flag type TextProps, when created from
scratch, which was biting us. This should be fixed, and should allow everything
to behave properly. Due to a clone, we were seeing different behaviour on the
first call

Then, there was the bug in the test (which has been committed, working)

Finally, after adding new TextBoxes, they weren't being registered with the
PPDrawing, so they weren't always being correctly updated on write out. That's
been fixed.

Hopefully it now all works :)