incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ian Cunningham (JIRA)" <j...@apache.org>
Subject [jira] [Created] (ODFTOOLKIT-372) Simple API not setting heading style
Date Sun, 25 Aug 2013 11:18:51 GMT
Ian Cunningham created ODFTOOLKIT-372:
-----------------------------------------

             Summary: Simple API not setting heading style
                 Key: ODFTOOLKIT-372
                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-372
             Project: ODF Toolkit
          Issue Type: Bug
          Components: simple api
    Affects Versions: 0.7-incubating
            Reporter: Ian Cunningham


I created the following test in response to a recent email

public class TextPropertiesTest { ...

	@Test
	public void testTextGetSetName() {
		try {
			TextDocument document = TextDocument.newTextDocument();
			Paragraph firstPara = document.getParagraphByIndex(0, false);
			firstPara.setTextContent("I am alive and should be a heading");

			firstPara.applyHeading();
			firstPara.setStyleName("Heading_20_1");
			String styleName = firstPara.getStyleName();
			
			Assert.assertEquals("Heading_20_1", styleName);
			
			//save
			document.save(ResourceUtilities.newTestOutputFile("testGetSetStyleName.odt"));
			
			TextDocument loadedDocument =  TextDocument.loadDocument(ResourceUtilities.newTestOutputFile("testGetSetStyleName.odt"));
			Paragraph loadedFirstPara = loadedDocument.getParagraphByIndex(0, false);
			String loadedStyleName = loadedFirstPara.getStyleName();
			
			Assert.assertEquals("Heading_20_1", loadedStyleName);
			
		} catch (Exception e) {
			LOGGER.log(Level.SEVERE, e.getMessage(), e);
			Assert.fail(e.getMessage());
		}
	}


The Style Name returned is an empty string. 

But I don't really understand the design well enough to figure out a solution.... just yet.
I can see the style is left at Standard 
      <text:h text:outline-level="1" text:style-name="Standard">I am alive and should
be a heading</text:h>

A work around is to get the underlying ODFElement and change its style. But that kind of defeats
the purpose of the API?

--
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