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

No comments: