incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Svante Schubert (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (ODFTOOLKIT-344) NullPointerException in DefaultStyleHandler.getTextPropertiesForWrite().setFontColor()
Date Tue, 30 Oct 2012 10:44:13 GMT

    [ https://issues.apache.org/jira/browse/ODFTOOLKIT-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486787#comment-13486787
] 

Svante Schubert edited comment on ODFTOOLKIT-344 at 10/30/12 10:44 AM:
-----------------------------------------------------------------------

Incidentally I fixed this issue last week-end, going to push it back now (had in mind to do
it next Monday on the Apache Conference lab)..

There is one line 
mAutomaticStyle = automatic_styles.getStyle(getStyleName(), getStyleFamily());

missing in the following method

	public StyleStyleElement getOrCreateUnqiueAutomaticStyle() {
		if ((mAutomaticStyle == null)
				|| (mAutomaticStyle.getStyleUserCount() > 1)) {
			// we need a new automatic style
			OdfOfficeAutomaticStyles automatic_styles = getAutomaticStyles();
			if (automatic_styles != null) {
				StyleNameRef sParentStyleName = null;
				mAutomaticStyle = automatic_styles.getStyle(getStyleName(), getStyleFamily());				
				if (mAutomaticStyle == null) {

See the panultimate line above. Will move it into a fresh source, test and push it.

PS: Perhaps you have an idea of a regresion test?

Best regards,
Svante
                
      was (Author: svanteschubert):
    Incidentally I fixed this issue last week-end, going to push it back now (had in mind
to do it next Monday on the Apache Conference lab)..

There is one line 
mAutomaticStyle = automatic_styles.getStyle(getStyleName(), getStyleFamily());

missing in the following method

	public StyleStyleElement getOrCreateUnqiueAutomaticStyle() {
		if ((mAutomaticStyle == null)
				|| (mAutomaticStyle.getStyleUserCount() > 1)) {
			// we need a new automatic style
			OdfOfficeAutomaticStyles automatic_styles = getAutomaticStyles();
			if (automatic_styles != null) {
				StyleNameRef sParentStyleName = null;
				mAutomaticStyle = automatic_styles.getStyle(getStyleName(), getStyleFamily());				
				if (mAutomaticStyle == null) {

See the panultimate line above. Will move it into a fresh source, test and push it.

Best regards,
Svante
                  
> NullPointerException in DefaultStyleHandler.getTextPropertiesForWrite().setFontColor()
> --------------------------------------------------------------------------------------
>
>                 Key: ODFTOOLKIT-344
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-344
>             Project: ODF Toolkit
>          Issue Type: Bug
>          Components: simple api
>    Affects Versions: 0.7
>            Reporter: Marc Schreiber
>
> I'm trying to change to font color of a certain word in a Open Document Textfile. I used
the example for changing the style of a span from here: http://incubator.apache.org/odftoolkit/simple/document/cookbook/Text%20Document.html#Span
> This is my code:
>         TextNavigation navigation = new TextNavigation("Word I'm looking for", document);
>         if (navigation.hasNext()) {
>             TextSelection selection = (TextSelection) navigation.nextSelection();
>             Span span = Span.newSpan(selection);
>             DefaultStyleHandler style = span.getStyleHandler();
>             style.getTextPropertiesForWrite().setFontColor(Color.GREEN);
>         }
> But the last line in the if block throws an NullPointerException. Here is the stack trace:
> Exception in thread "main" java.lang.NullPointerException
> 	at org.odftoolkit.simple.style.DefaultStyleHandler.getWritableStyleElementByName(DefaultStyleHandler.java:528)
> 	at org.odftoolkit.simple.style.DefaultStyleHandler.getStyleElementForWrite(DefaultStyleHandler.java:598)
> 	at org.odftoolkit.simple.style.DefaultStyleHandler.getTextPropertiesForWrite(DefaultStyleHandler.java:214)
> 	at etl.squared.informationextraction.Annotator.annotate(Annotator.java:124)
> 	at etl.squared.informationextraction.Annotator.main(Annotator.java:143)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message