// methods implementing the IDocListener interface /// <summary> /// Adds an Element to the Document. /// </summary> /// <param name="element">the Element to add</param> /// <returns>true if the element was added, false if not</returns> public virtual bool Add(IElement element) { if (close) { throw new DocumentException("The document has been closed. You can't add any Elements."); } if (!open && element.IsContent()) { throw new DocumentException("The document is not open yet; you can only add Meta information."); } bool success = false; if (element is ChapterAutoNumber) { chapternumber = ((ChapterAutoNumber)element).SetAutomaticNumber(chapternumber); } foreach (IDocListener listener in listeners) { success |= listener.Add(element); } if (element is ILargeElement) { ILargeElement e = (ILargeElement)element; if (!e.ElementComplete) { e.FlushContent(); } } return(success); }
// methods implementing the IDocListener interface /// <summary> /// Adds an Element to the Document. /// </summary> /// <param name="element">the Element to add</param> /// <returns>true if the element was added, false if not</returns> public virtual bool Add(IElement element) { if (close) { throw new DocumentException(MessageLocalization.GetComposedMessage("the.document.has.been.closed.you.can.t.add.any.elements")); } if (!open && element.IsContent()) { throw new DocumentException(MessageLocalization.GetComposedMessage("the.document.is.not.open.yet.you.can.only.add.meta.information")); } bool success = false; if (element is ChapterAutoNumber) { chapternumber = ((ChapterAutoNumber)element).SetAutomaticNumber(chapternumber); } foreach (IDocListener listener in listeners) { success |= listener.Add(element); } if (element is ILargeElement) { ILargeElement e = (ILargeElement)element; if (!e.ElementComplete) { e.FlushContent(); } } return(success); }
/// <summary> /// Adds an Element to the Document. /// </summary> /// <param name="element">the Element to add</param> /// <returns>true if the element was added, false if not</returns> public virtual bool Add(IElement element) { if (IsDocumentClose) { throw new DocumentException("The document has been closed. You can't add any Elements."); } if (!IsDocumentOpen && element.IsContent()) { throw new DocumentException("The document is not open yet; you can only add Meta information."); } bool success = false; var number = element as ChapterAutoNumber; if (number != null) { Chapternumber = number.SetAutomaticNumber(Chapternumber); } foreach (IDocListener listener in _listeners) { success |= listener.Add(element); } var largeElement = element as ILargeElement; if (largeElement != null) { ILargeElement e = largeElement; if (!e.ElementComplete) { e.FlushContent(); } } return(success); }