Ejemplo n.º 1
0
        internal DomParagraphElement CreateMergedParagrahp(bool includeSelectionOnly)
        {
            DomParagraphElement p = new DomParagraphElement();

            p.OwnerDocument = this.OwnerDocument;
            p.StyleIndex    = this.StyleIndex;
            DomStringElement myStr = new DomStringElement();

            myStr.OwnerDocument = this.OwnerDocument;
            //p.Elements.AddRaw( myStr );
            foreach (DomElement element in this.Elements)
            {
                if (includeSelectionOnly)
                {
                    if (this.OwnerDocument.IsSelected(element) == false)
                    {
                        continue;
                    }
                }
                if (element is DomCharElement)
                {
                    DomCharElement c = (DomCharElement)element;
                    if (myStr.CanMerge(c))
                    {
                        myStr.Merge(c);
                    }
                    else
                    {
                        if (myStr.HasContent)
                        {
                            p.Elements.AddRaw(myStr);
                            myStr = new DomStringElement();
                        }
                        myStr.OwnerDocument = this.OwnerDocument;
                        myStr.Merge(c);
                    }
                }
                else
                {
                    if (myStr.HasContent)
                    {
                        p.Elements.AddRaw(myStr);
                        myStr = new DomStringElement();
                    }
                    if (!(element is DomParagraphFlagElement))
                    {
                        p.Elements.AddRaw(element);
                    }
                }
            }
            if (myStr.HasContent)
            {
                p.Elements.AddRaw(myStr);
            }
            if (p.Elements.EOFElement != null)
            {
                p.Elements.EOFElement = null;
            }
            return(p);
        }
Ejemplo n.º 2
0
        //public override void AfterLoad(DocumentFormatStyle format)
        //{
        //    base.AfterLoad(format);
        //    if (format == DocumentFormatStyle.XML)
        //    {
        //        WriterUtils.SplitElements(this.Elements);
        //    }
        //}
//
//		/// <summary>
//		/// 删除子元素操作
//		/// </summary>
//		/// <param name="element">要删除的子元素</param>
//		/// <returns>是否删除元素</returns>
//		public override bool RemoveChild(XTextElement element)
//		{
//			if( element == this.myEOFElement )
//			{
//				if( this.NextElement is XTextParagraph )
//				{
//					XTextParagraph p = ( XTextParagraph ) this.NextElement ;
//					int pindex = myParent.Elements.IndexOf( p );
//					XTextElementList list = new XTextElementList();
//					list.AddRange( p.Elements );
//					list.RemoveAt( list.Count - 1 );
//					int index = myElements.Count - 1 ;
//					myElements.AddRange( list );
//					myParent.RemoveChild( p );
//					if( myOwnerDocument.CanLogUndo )
//					{
//						myOwnerDocument.UndoList.AddRemoveElement( myParent , pindex , p );
//						myOwnerDocument.UndoList.AddInsertElements( this , index , list );
//					}
//					myOwnerDocument.bolModifyParagraph = true ;
//					return true ;
//				}
//				return false;
//			}
//			myElements.Remove( element );
//			return true ;
//		}

        public override void WriteHTML(DCSoft.CSharpWriter.Html.WriterHtmlDocumentWriter writer)
        {
            DocumentContentStyle rs = this.RuntimeStyle;

            if (rs.NumberedList == false && rs.BulletedList == false)
            {
                writer.WriteStartElement("p");
            }
            else
            {
                writer.WriteStartElement("li");
            }
            writer.WriteDocumentContentStyle(this.RuntimeStyle, this);
            writer.WriteStyleItem("text-justify", "inter-ideograph");
            writer.WriteStyleItem(
                "margin-bottom",
                this.OwnerDocument.ToPixel(( int )rs.SpacingBeforeParagraph) + " px");
            //if( intListStyle == ParagraphListStyle.None && this.bolHeadIndent )

            if (rs.NumberedList == false &&
                rs.BulletedList == false &&
                rs.FirstLineIndent != 0)
            {
                writer.WriteStyleItem(
                    "margin-left",
                    this.OwnerDocument.ToPixel(( int )rs.FirstLineIndent) + " px");
            }
            writer.WriteEndStyle();
            if (this.Elements.Count > 1)
            {
                DomParagraphElement p = this.CreateMergedParagrahp(
                    writer.IncludeSelectionOndly);

                foreach (DomElement element in p.Elements)
                {
                    element.WriteHTML(writer);
                }
                //base.WriteContentHTML( writer );
            }
            else
            {
                writer.WriteText(" ");
            }
            writer.WriteEndElement();
        }