Last post here: Time to move;

April 10, 2008

This is the last post on this blog, time to move on and get all my stuffs on one blog. From now on, all things on ‘odf4j’ will be available at this link

See you!


Style Tree Implementation

October 5, 2007

/*
* StyleTree.java
*
* Created on 28 Sep, 2007, 2:43:06 PM
*
*
*/

package org.openoffice.odf.style;

/**
*
* @author amitksaha <amitksaha@openoffice.org>
*/
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Enumeration;

/*
* Implementation of the Style Hierarchy in ODF documents
* EXPERIMENTAL CODE
*/

public class StyleTree {
private DefaultMutableTreeNode top;

public void getStyle(String style_name) {

//Create the nodes.
top = new DefaultMutableTreeNode(“ODT Style Families”);

createNodes(top);
search(style_name);
}

private void createNodes(DefaultMutableTreeNode top) {
DefaultMutableTreeNode style_family = null;
DefaultMutableTreeNode parent_style = null;
DefaultMutableTreeNode style_name_1 = null;
DefaultMutableTreeNode style_name_2 = null;
DefaultMutableTreeNode style_name_3 = null;

style_family = new DefaultMutableTreeNode(“graphic”);
top.add(style_family);

style_family = new DefaultMutableTreeNode(“Paragraph”);
top.add(style_family);

parent_style = new DefaultMutableTreeNode(“standard”);
style_family.add(parent_style);

style_name_1 = new DefaultMutableTreeNode(“index”);
parent_style.add(style_name_1);

style_name_2 = new DefaultMutableTreeNode(“Text_20_body”);
parent_style.add(style_name_2);

style_name_1 = new DefaultMutableTreeNode(“P1″);
style_name_2.add(style_name_1);

style_name_1 = new DefaultMutableTreeNode(“P2″);
style_name_2.add(style_name_1);

style_name_1 = new DefaultMutableTreeNode(“Heading”);
style_name_2.add(style_name_1);

style_name_1 = new DefaultMutableTreeNode(“List”);
style_name_2.add(style_name_1);

style_name_3 = new DefaultMutableTreeNode(“caption”);
parent_style.add(style_name_3);

style_family = new DefaultMutableTreeNode(“table”);
top.add(style_family);

style_family = new DefaultMutableTreeNode(“table_row”);
top.add(style_family);

}

private void search(String item){

Enumeration res = top.depthFirstEnumeration();

for (; res.hasMoreElements() ;) {
Object obj = res.nextElement();

//trivial typecast

DefaultMutableTreeNode node = (DefaultMutableTreeNode)obj;

if(item.equals(node.toString())){

//traverse up the tree for the style information

System.out.println(“Style Information for: ” + item);
System.out.println(“Style Family: ” + node.getParent().getParent().getParent().toString());
System.out.println(“Parent Style: ” + node.getParent().getParent().toString());
System.out.println(“Previous Higher Style Category: ” + node.getParent().toString());

}

}

}

}


Style Hierarchy in ODT documents

September 4, 2007

I have identified a hierarchical relationship among the way Style information is stored in “style.xml” file. Based on my findings I have represented them in a Style tree.
Style Tree

Now, using this Style tree we can retrieve style information associated with each style, like the Parent-style, Style family, etc by using the style-name which are the leaves of the tree. This will save us from parsing the “style.xml” everytime.


Updates

June 16, 2007

After a fortnight of coding inactivity, I am currently working on Style Handling in ODT documents.

In the meantime,my role has also been upgraded to a developer.