Esempio n. 1
0
        protected ODFFormControl(ODFForm parentForm, XElement node)
        {
            _document  = parentForm.Document;
            ParentForm = parentForm;
            Node       = node;

            _contentCollection = null;
            _controlRef        = null;

            Properties           = new FormPropertyCollection();
            Properties.Inserted += PropertyCollection_Inserted;
            Properties.Removed  += PropertyCollection_Removed;
        }
Esempio n. 2
0
        protected ODFFormControl(ODFForm ParentForm, XmlNode node)
        {
            _document   = ParentForm.Document;
            _parentForm = ParentForm;
            Node        = node;

            _contentCollection = null;
            _controlRef        = null;

            _properties           = new FormPropertyCollection();
            _properties.Inserted += PropertyCollection_Inserted;
            _properties.Removed  += PropertyCollection_Removed;
        }
Esempio n. 3
0
        protected ODFFormControl(ODFForm ParentForm, ContentCollection contentCollection, string id, string x, string y, string width, string height)         //: base (document, ContentCollection, id, x, y, width, height)
        {
            _document          = ParentForm.Document;
            _parentForm        = ParentForm;
            Node               = ParentForm.Node;
            _contentCollection = contentCollection;
            CreateBasicNode();
            ID          = id;
            _controlRef = new ODFControlRef(_document, id, x, y, width, height);

            _properties           = new FormPropertyCollection();
            _properties.Inserted += PropertyCollection_Inserted;
            _properties.Removed  += PropertyCollection_Removed;
        }
Esempio n. 4
0
        protected ODFFormControl(ODFForm parentForm, ContentCollection contentCollection, string id)
        {
            _document          = parentForm.Document;
            ParentForm         = parentForm;
            Node               = parentForm.Node;
            _contentCollection = contentCollection;
            CreateBasicNode();
            Id = id;
            ControlImplementation = "ooo:com.sun.star.form.component.TextField";
            _controlRef           = new ODFControlRef(_document, id);

            Properties           = new FormPropertyCollection();
            Properties.Inserted += PropertyCollection_Inserted;
            Properties.Removed  += PropertyCollection_Removed;
        }
		/// <summary>
		/// Creates the frame.
		/// </summary>
		/// <param name="frameNode">The framenode.</param>
		/// <returns>The Frame object.</returns>
		public ODFControlRef CreateControlRef(XmlNode refNode)
		{
			try
			{
				ODFControlRef controlRef = new ODFControlRef(this._document, refNode);
				return controlRef;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a Control Reference.", ex);
			}
		}
		/// <summary>
		/// Gets a ODFControlRef as HTML.
		/// </summary>
		/// <param name="list">The control reference.</param>
		/// <returns></returns>
		public string GetODFControlAsHtml(ODFControlRef reference)
		{
			if (reference.Document is TextDocument)
			{
				string html = "";
				try
				{
				
					if (reference == null) return "";
					TextDocument td = reference.Document as TextDocument;
					if (td == null)
						return "";

					ODFFormControl control = td.FindControlById(reference.DrawControl);
				
					if (control is ODFButton)
					{
						html	+= "<form ";
						ODFButton butt = control as ODFButton;
						if (butt.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (butt.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", butt.ParentForm.Href);
						if (butt.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", butt.ParentForm.Name);
					

						html +=String.Format("<input type='submit' style='float: left; width: {0}; height: {1};'", butt.Width, butt.Height);
						if (butt.Name!="")
							html +=String.Format("name='{0}' ", butt.Name);
						if (butt.Label!="")
							html +=String.Format("value='{0}' ", butt.Label);
						html +="/>\n</form>\n";
					}
				
					if (control is ODFCheckBox)
					{
						html	+= "<form ";
						ODFCheckBox cb = control as ODFCheckBox;
						if (cb.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (cb.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", cb.ParentForm.Href);
						if (cb.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", cb.ParentForm.Name);
					
						string is_checked = "";
						if (cb.CurrentState == State.Checked) is_checked = " checked ";
						html +=String.Format("<input type='checkbox' style='float: left; margin: 0px; width: {0}; height: {1};'", cb.Width, cb.Height);
						if (cb.Name!="")
							html +=String.Format("name='{0}' ", cb.Name);
						if (cb.Value!="")
							html +=String.Format("value='{0}' ", cb.Value);
						html +=is_checked;
						html +="/>\n</form>\n";
					}

					if (control is ODFListBox)
					{
						html	+= "<form ";
						ODFListBox lb = control as ODFListBox;
						if (lb.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (lb.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", lb.ParentForm.Href);
						if (lb.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", lb.ParentForm.Name);
					
						html +=String.Format("<select style='float: left; margin: 0px; width: {0}; height: {1};'", lb.Width, lb.Height);
						if (lb.Name!="")
							html +=String.Format("name='{0}' ", lb.Name);
						if (lb.Size!=0)
							html +=String.Format("size='{0}' ",lb.Size);
						html +="/>\n";
						foreach (ODFOption o in lb.Options)
						{
							string selected = "";
							if (o.Selected == XmlBoolean.True) selected = " selected";
							html += String.Format("<option{0}>{1}</option>", selected, o.Label);
						}
						
						html+="</form>\n";
					}

					if (control is ODFComboBox)
					{
						html	+= "<form ";
						ODFComboBox lb = control as ODFComboBox;
						if (lb.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (lb.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", lb.ParentForm.Href);
						if (lb.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", lb.ParentForm.Name);
					
						html +=String.Format("<select style='float: left; margin: 0px; width: {0}; height: {1};'", lb.Width, lb.Height);
						if (lb.Name!="")
							html +=String.Format("name='{0}' ", lb.Name);
						if (lb.Size!=0)
							html +=String.Format("size='{0}' ",lb.Size);
						html +="/>\n";
						foreach (ODFItem o in lb.Items)
						{
							string selected = "";
							if (o.Label == lb.CurrentValue) selected = " selected";
							html += String.Format("<option{0}>{1}</option>", selected, o.Label);
						}
						
						html+="</form>\n";
					}

					if (control is ODFFile)
					{
						html	+= "<form ";
						ODFFile file = control as ODFFile;
						if (file.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (file.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", file.ParentForm.Href);
						if (file.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", file.ParentForm.Name);
					

						html +=String.Format("<input type='file' style='float: left; width: {0}; height: {1};'", file.Width, file.Height);
						if (file.Name!="")
							html +=String.Format("name='{0}' ", file.Name);
						if (file.CurrentValue!="")
							html +=String.Format("value='{0}' ", file.CurrentValue);
						html +="/>\n</form>\n";
					}

					if (control is ODFHidden)
					{
						html	+= "<form ";
						ODFHidden hid = control as ODFHidden;
						if (hid.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (hid.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", hid.ParentForm.Href);
						if (hid.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", hid.ParentForm.Name);
					

						html +=String.Format("<input type='file' style='float: left; width: {0}; height: {1};'", hid.Width, hid.Height);
						if (hid.Name!="")
							html +=String.Format("name='{0}' ", hid.Name);
						if (hid.Value!="")
							html +=String.Format("value='{0}' ", hid.Value);
						html +="/>\n</form>\n";
					}

					if (control is ODFFormattedText)
					{
						html	+= "<form ";
						ODFFormattedText ft = control as ODFFormattedText;
						if (ft.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (ft.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", ft.ParentForm.Href);
						if (ft.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", ft.ParentForm.Name);
					

						html +=String.Format("<input type='text' style='float: left; width: {0}; height: {1};'", ft.Width, ft.Height);
						if (ft.Name!="")
							html +=String.Format("name='{0}' ", ft.Name);
						if (ft.CurrentValue!="")
							html +=String.Format("value='{0}' ", ft.CurrentValue);
						html +="/>\n</form>\n";
					}

					if (control is ODFTextArea)
					{
						html	+= "<form ";
						ODFTextArea ta = control as ODFTextArea;
						if (ta.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (ta.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", ta.ParentForm.Href);
						if (ta.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", ta.ParentForm.Name);
					

						html +=String.Format("<textarea style='float: left; width: {0}; height: {1};'", ta.Width, ta.Height);
						if (ta.Name!="")
							html +=String.Format("name='{0}' ", ta.Name);
						html +="/>";
						html+= ta.CurrentValue;
						html+= "\n</form>\n";
					}
		
				}

				catch(Exception ex)
				{
					throw new AODLException("Exception while trying to build a HTML string from an ODF Form.", ex);
				}
				return html;
			}
			else return "";
		}
		protected ODFFormControl(ODFForm ParentForm, ContentCollection contentCollection, string id, string x, string y, string width, string height) //: base (document, ContentCollection, id, x, y, width, height)
		{
			_document = ParentForm.Document;
			_parentForm = ParentForm;
			Node = ParentForm.Node;
			_contentCollection = contentCollection;
			CreateBasicNode();
			ID = id;
			_controlRef = new ODFControlRef(_document, id, x, y, width, height);

			_properties = new FormPropertyCollection();
			_properties.Inserted += PropertyCollection_Inserted;
			_properties.Removed += PropertyCollection_Removed;
		}
		protected ODFFormControl(ODFForm ParentForm, ContentCollection contentCollection, string id)
		{
			_document = ParentForm.Document;
			_parentForm = ParentForm;
			Node = ParentForm.Node;
			_contentCollection = contentCollection;
			CreateBasicNode();
			ID = id;
			this.ControlImplementation = "ooo:com.sun.star.form.component.TextField";
			_controlRef = new ODFControlRef(_document, id);

			_properties = new FormPropertyCollection();
			_properties.Inserted += PropertyCollection_Inserted;
			_properties.Removed += PropertyCollection_Removed;
			
		}
		protected ODFFormControl(ODFForm ParentForm, XmlNode node)
		{
			_document = ParentForm.Document;
			_parentForm = ParentForm;
			Node = node;

			_contentCollection = null; 
			_controlRef = null;

			_properties = new FormPropertyCollection();
			_properties.Inserted += PropertyCollection_Inserted;
			_properties.Removed += PropertyCollection_Removed;
		}