The class SimpleText represent simple unformatted text that could be used within the spreadsheet cell content.
상속: IText, ICloneable
예제 #1
0
        /// <summary>
        /// Create a deep clone of this SimpleText object.
        /// </summary>
        /// <remarks>A possible Attached Style wouldn't be cloned!</remarks>
        /// <returns>
        /// A clone of this object.
        /// </returns>
        public object Clone()
        {
            SimpleText simpleTextClone = null;

            if (this.Document != null && this.Node != null)
            {
                TextContentProcessor tcp = new TextContentProcessor();
                simpleTextClone = (SimpleText)tcp.CreateTextObject(
                    this.Document, this.Node.CloneNode(true));
            }

            return(simpleTextClone);
        }
예제 #2
0
        /// <summary>
        /// Create a deep clone of this SimpleText object.
        /// </summary>
        /// <remarks>A possible Attached Style wouldn't be cloned!</remarks>
        /// <returns>
        /// A clone of this object.
        /// </returns>
        public object Clone()
        {
            SimpleText simpleTextClone = null;

            if (Document != null && Node != null)
            {
                TextContentProcessor tcp = new TextContentProcessor();
                simpleTextClone = (SimpleText)tcp.CreateTextObject(
                    Document, new XText(Node));
            }

            return(simpleTextClone);
        }
예제 #3
0
 public override void Export(IEnumerable<List<CellInfo>> exportInfo)
 {
     SpreadsheetDocument spreadsheetDocument = new SpreadsheetDocument();
     spreadsheetDocument.New();
     Table table = new Table(spreadsheetDocument, "DataGrid", string.Empty);
     int rowIndex = 0;
     foreach (List<CellInfo> cellInfos in exportInfo)
     {
         for (int columnIndex = 0; columnIndex < cellInfos.Count; columnIndex++)
         {
             CellInfo cellInfo = cellInfos[columnIndex];
             Cell cell = table.CreateCell();
             Paragraph paragraph = ParagraphBuilder.CreateSpreadsheetParagraph(spreadsheetDocument);
             SimpleText fText = new SimpleText(spreadsheetDocument, (cellInfo.Value ?? string.Empty).ToString());
             paragraph.TextContent.Add(fText);
             cell.Content.Add(paragraph);
             table.InsertCellAt(rowIndex, columnIndex, cell);
         }
         rowIndex++;
     }
     spreadsheetDocument.TableCollection.Add(table);
     Save(spreadsheetDocument);
 }
예제 #4
0
 public void XLinkTest()
 {
     //Create new TextDocument
     var document		= new TextDocument();
     document.New();
     //Create a new Paragraph
     var para				= new Paragraph(document, "P1");
     //Create some simple text
     var stext			= new SimpleText(document, "Some simple text ");
     //Create a XLink
     var xlink					= new XLink(document, "http://www.sourceforge.net", "Sourceforge");
     //Add the textcontent
     para.TextContent.Add(stext);
     para.TextContent.Add(xlink);
     //Add paragraph to the document content
     document.Content.Add(para);
     //Save
     document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"XLink.odt");
 }
예제 #5
0
 public void InsertAndRemoveTest()
 {
     //Create a new document
     var document				= new TextDocument();
     document.New();
     //Create a standard paragraph
     var paragraph					= ParagraphBuilder.CreateStandardTextParagraph(document);
     //Create some simple text
     var simpleText				= new SimpleText(document, "Some simple text");
     //Add the text
     paragraph.TextContent.Add(simpleText);
     Assert.IsNotEmpty(paragraph.TextContent, "Must be contain one element.");
     //Remove the simple text
     paragraph.TextContent.Remove(simpleText);
     Assert.IsEmpty(paragraph.TextContent, "Must be empty");
     Assert.IsTrue(paragraph.Node.InnerXml.Length == 0, "Node from simple text must be removed.");
 }
예제 #6
0
		public void HeaderContentsTest1()
		{
			string file = AARunMeFirstAndOnce.inPutFolder+"pagestyles.odt";
			TextDocument textDocument = new TextDocument();
			textDocument.Load(file);
			TextMasterPage txtMP = textDocument.TextMasterPageCollection.GetDefaultMasterPage();
			txtMP.ActivatePageHeaderAndFooter();
			txtMP.TextPageHeader.MarginLeft = "4cm";
			foreach(IContent iContent in txtMP.TextPageHeader.ContentCollection)
			{
				if (iContent is Paragraph)
				{
					Assert.IsNotNull(((Paragraph)iContent).MixedContent, "Must be mixed content available.");
					Assert.IsTrue(((Paragraph)iContent).MixedContent.Count > 0, "Must be mixed contents object inside.");
					Assert.IsTrue(((Paragraph)iContent).MixedContent[0] is SimpleText, "First IContent has to be type of SimpleText.");
					Assert.IsTrue(((Paragraph)iContent).MixedContent[1] is FormatedText, "Second IContent has to be type of FormatedText.");
					// Change the simple text
					string changeText = "Has changed ";
					SimpleText simpleText = ((Paragraph)iContent).MixedContent[0] as SimpleText;
					simpleText.Text = changeText;
				}
				else
				{
					Console.WriteLine(iContent.GetType().FullName);
				}
			}

			Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument);
			// add one extra Paragraph
			SimpleText extraText =  new SimpleText(textDocument, "Some extra text...");
			paragraph.TextContent.Add(extraText);
			txtMP.TextPageHeader.ContentCollection.Add(paragraph);

			textDocument.DocumentStyles.Styles.Save(AARunMeFirstAndOnce.outPutFolder + "pagestyles_changed.xml");

			textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder + "pagestyles_changed.odt");
		}