public void NestedFormTest() { //Create a new text document TextDocument document = new TextDocument(); document.New(); // Create a main paragraph Paragraph p =new Paragraph(document); // Create a main form ODFForm main_form = new ODFForm(document, "mainform"); ODFForm child_form = new ODFForm(document, "childform"); main_form.Method = Method.Get; main_form.Method = Method.Get; // Create a frame ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm"); frm.Label = "Main form"; // Add the frame to the form control list main_form.Controls.Add (frm); // Create a button ODFButton butt = new ODFButton(main_form, p.Content, "butt", "1cm", "15mm", "4cm", "1cm"); butt.Label = "This is a main form"; // Add the button to the form control list main_form.Controls.Add (butt); // Add the forms to the main form! document.Forms.Add(main_form); // Add the paragraph to the content list document.Content.Add(p); // adding controls to the nested form ODFFrame frm_child = new ODFFrame(child_form, p.Content, "frm_child", "5mm", "35mm", "5cm", "3cm"); frm_child.Label = "Child form"; child_form.Controls.Add (frm_child); ODFButton butt_child = new ODFButton(child_form, p.Content, "butt_child", "1cm", "45mm", "4cm", "1cm"); butt_child.Label = "This is a child form"; child_form.Controls.Add (butt_child); main_form.ChildForms.Add(child_form); ODFButton b = document.FindControlById("butt_child") as ODFButton; Assert.IsNotNull(b, "Error! could not find the specified control"); b.Label = "Child form:)"; // Add the forms to the main form! document.Forms.Add(main_form); // Add the paragraph to the content list document.Content.Add(p); document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test.odt"); document.Load(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test.odt"); document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test2.odt"); }
public void SaveLoadTest() { //Create a new text document TextDocument document = new TextDocument(); document.New(); Paragraph p =new Paragraph(document); p.StyleName = "Standard"; ODFForm main_form = new ODFForm(document, "mainform"); main_form.Method = Method.Get; ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm"); frm.Label = "Save and Load test"; main_form.Controls.Add (frm); ODFButton butt = new ODFButton(main_form, p.Content, "butt", "1cm", "15mm", "4cm", "1cm"); butt.Label = "A simple button :)"; main_form.Controls.Add (butt); document.Forms.Add(main_form); document.Content.Add(p); document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"saveload.odt"); document.Load(AARunMeFirstAndOnce.outPutFolder+"saveload.odt"); ODFButton bt = document.FindControlById("butt") as ODFButton; Assert.IsNotNull(bt, "Could not find control with >butt< ID"); bt.Label = "This label has chanhed"; document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"saveload2.odt"); }