Thursday, April 26, 2007

I have decided to resolve the synchronization between the draw:control in the contents nodes and the appropriate form:form element in the following way:

A new auxiliary class AODL.Document.Forms.Controls.OOControlRef will be added; this is an internal AODL class that stands for draw:control tag. It will have such properties as ID, X,Y,Width,Height,AnchorType, AnchorPageNumber,StyleName,TextStyleName and others that reflect draw:control attributes. And, of course, it will have a set of common properties such as Node.

OOFormControl will be a basic class for all form controls. All specific controls such as Button will derive from it.OOFormControl will have an internal variable _controlRef (OOControlRef) that represents its reference; all the public properties of _controlRef will be accessible through public OOFormControl properties.

OOFormControl will have a constructor taking parent form, content container and ID string as obligatory parameters. Of course, there will be other handy overloaded constructors with more parameters.

OOForm's controls collection will have Inserted and Removed events to implement the synchronization:
private void ControlsCollection_Inserted(int index, object value)
{
OOFormControl ctrl = value as OOFormControl;
this._FNode.AppendChild(ctrl.Node);
ctrl._contentCollection.Add(ctrl._controlRef);
}

private void ControlsCollection_Removed(int index, object value)
{
OOFormControl ctrl = value as OOFormControl;
this._FNode.RemoveChild(ctrl.Node);
ctrl._contentCollection.Remove(ctrl._controlRef);
}

I'll also add appropriate deletion of control in form:form tag when the reference is deleted.

Wednesday, April 25, 2007

I've come down with the flu. Sore throat + fever :(
Hope to recover soon.

Sunday, April 22, 2007

Today I've been playing a little bit with the AODL library, investigating its inner structure.
I've also created a basic core of Forms support. Of course, there are very few features available now, but they seem to work correctly.
Gonna have more fun with it today :)

Saturday, April 21, 2007

At present time I'm thinking of main architectural features of Forms implementation.
The following ideas are just "pre-alpha" ideas :)

Here is the way I see it:
  • The main classes for Forms support are located in the AODL.Document.Forms namespace.
  • Each form is represented by the OOForm class; this class should contain such properties as Href, TargetFrame, Method and others (which are the attributes of a form:form tag). It should implement the IHtml interface (however, we'll need to think more about exporting nested forms to HTML)
  • Those properties that have several possible values should have an enum type.
  • Properties listed in form:properties tag should be reflected in a FormProperties property of OOForm (these properties are application-specific). It should be some kind of a collection descending from the CollectionWithEvents class.
  • Each form should have a collection of child controls (ControlList); ControlList will be a class derived from CollectionWithEvents.
  • Everything connected with controls will be located in AODL.Document.Forms.Controls
  • A separate class will stand for each control type (such as Text, TextArea, Button, CheckBox etc.). I'm also thinking of introducing a base interface for all controls (IOOFormControl with such properties as Id, Type and, perhaps, Node).
  • OOForm will have methods that help to search for any child controls (for example, FindControlById).
  • Each form has a property that represents child (one level below) forms. We should also remember that top-level form is situated in office:forms tag (unlike for those that are nested)
  • TextDocument class will have a series of smart methods that provide search for any form/control in the entire document (using BFS on the nested forms tree).
  • TextDocument and, perhaps, OpenDocumentTextExporter and OpenDocumentImporter should be expanded to handle forms correctly while saving/loading a document.
  • ..... and, of course, there are tonns of other things that must be listed here, but I've forgotten to mention them ;)))
One more thing that I ponder now is synchronizing draw:control and form:id. Inserting draw:control tags won't be a problem; however, I'm not yet sure about the way I'll handle deleting controls from forms that have their references in draw:control tags.
I see three basic ways:
  • No synchronization. The easiest and the most flexible way. While adding new draw:control, you can arbitrary reference any control, including non-existing ones (just passing their id as a string). And when you delete a control reference from a form's control list, nothing extra happens. The contras of this approach are obvious.
  • Basic synchronization: the same as above, but while deleting some control all tags that reference it are deleted.
  • You cannot reference non-existent controls. When you delete some control all tags that reference it are deleted.
That's it :) Of course, I'm going to extend these ideas a lot in the future...
Hi folks,
This blog will be dedicated to my participation in Google Summer of Code program.
I will be working on the AODL project. AODL is an open source C# library that allows you to create, load and manipulate OpenOffice documents (currently *.odt and *.ods are supported) directly (no instance of installed OO is required). You can read the project wiki to learn the details:
http://wiki.services.openoffice.org/wiki/AODL

My responsibilities within GSoC are to create full support for forms (and, perhaps, the XForm model) and fields. I will be posting messages about my progress here in this blog and on a special wiki page:
http://wiki.services.openoffice.org/wiki/.net_Module_AODL:_Forms_and_Fields_implementation

Cheers!