public void TestCloning() { TextDocument document = new TextDocument(); document.New(); Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); paragraph.TextContent.Add(new SimpleText(document, "Some text")); Paragraph paragraphClone = (Paragraph)paragraph.Clone(); Assert.AreNotSame(paragraph.Node, paragraphClone.Node, "Should be cloned and not equal."); Assert.AreEqual(paragraph.TextContent[0].GetType(), paragraphClone.TextContent[0].GetType(), "Should be cloned and equal."); ParagraphStyle paragraphStyle = new ParagraphStyle(document, "P1"); paragraphStyle.TextProperties.Bold = "bold"; //Add paragraph style to the document, //only automaticaly created styles will be added also automaticaly document.Styles.Add(paragraphStyle); paragraphClone.ParagraphStyle = paragraphStyle; //Clone the clone Paragraph paragraphClone2 = (Paragraph)paragraphClone.Clone(); Assert.AreNotSame(paragraphClone2.Node, paragraphClone.Node, "Should be cloned and not equal."); Assert.AreEqual(paragraphClone2.TextContent[0].GetType(), paragraphClone.TextContent[0].GetType(), "Should be cloned and equal."); //Cloning of styles isn't supported! Assert.AreSame(paragraphClone2.ParagraphStyle, paragraphClone.ParagraphStyle, "Must be same style object. Styles have to be cloned explicitly."); document.Content.Add(paragraph); document.Content.Add(paragraphClone); document.Content.Add(paragraphClone2); document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "clonedParagraphs.odt"); }
public void SimpleTableWithRowHeaderAndBorder() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a table for a text document using the TableBuilder Table table = TableBuilder.CreateTextDocumentTable( document, "table1", "table1", 3, 3, 16.99, true, true); //Create a standard paragraph for the row header Paragraph paragraph1 = ParagraphBuilder.CreateStandardTextParagraph(document); paragraph1.TextContent.Add(new SimpleText(document, "Table row header")); table.RowHeader.RowCollection[0].CellCollection[0].Content.Add(paragraph1); //Create a standard paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some cell text")); //Insert paragraph into the first cell table.RowCollection[0].CellCollection[0].Content.Add(paragraph); //Add table to the document document.Content.Add(table); //Save the document document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "simpleTableWithBorderRowheader.odt"); }
public void ImageMapTest() { string imagePath = @"D:\OpenDocument\AODL\AODLTest\bin\Debug\Files\Eclipse_add_new_Class.jpg"; TextDocument document = new TextDocument(); document.New(); //Create standard paragraph Paragraph paragraphOuter = ParagraphBuilder.CreateStandardTextParagraph(document); //Create the frame with graphic Frame frame = new Frame(document, "frame1", "graphic1", imagePath); //Create a Draw Area Rectangle DrawAreaRectangle drawAreaRec = new DrawAreaRectangle( document, "0cm", "0cm", "1.5cm", "2.5cm", null); drawAreaRec.Href = "http://OpenDocument4all.com"; //Create a Draw Area Circle DrawAreaCircle drawAreaCircle = new DrawAreaCircle( document, "4cm", "4cm", "1.5cm", null); drawAreaCircle.Href = "http://AODL.OpenDocument4all.com"; DrawArea[] drawArea = new DrawArea[2] { drawAreaRec, drawAreaCircle }; //Create a Image Map ImageMap imageMap = new ImageMap(document, drawArea); //Add Image Map to the frame frame.Content.Add(imageMap); //Add frame to paragraph paragraphOuter.Content.Add(frame); //Add paragraph to document document.Content.Add(paragraphOuter); //Save the document document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "simpleImageMap.odt"); }
public void CreateNewDocumentAndDoAPrintOut() { string fileToPrint = AARunMeFirstAndOnce.outPutFolder + "fileToPrint.odt"; //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some simple text!")); //Add the paragraph to the document document.Content.Add(paragraph); //Save empty document.SaveTo(fileToPrint); //Now print the new document via the OpenOfficeLib //Get the Component Context XComponentContext xComponentContext = Connector.GetComponentContext(); //Get a MultiServiceFactory XMultiServiceFactory xMultiServiceFactory = Connector.GetMultiServiceFactory(xComponentContext); //Get a Dektop instance XDesktop xDesktop = Connector.GetDesktop(xMultiServiceFactory); //Convert a windows path to an OpenOffice one fileToPrint = Component.PathConverter(fileToPrint); //Load the document you want to print XComponent xComponent = Component.LoadDocument( (XComponentLoader)xDesktop, fileToPrint, "_blank"); //Print the XComponent Printer.Print(xComponent); }
public void SimpleTable() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a table for a text document using the TableBuilder Table table = TableBuilder.CreateTextDocumentTable( document, "table1", "table1", 3, 3, 16.99, false, false); //Create a standard paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some cell text")); //Insert paragraph into the first cell table.Rows[0].Cells[0].Content.Add(paragraph); //Add table to the document document.Content.Add(table); //Save the document using (IPackageWriter writer = new OnDiskPackageWriter()) { document.Save(AARunMeFirstAndOnce.outPutFolder + "simpleTable.odt", new OpenDocumentTextExporter(writer)); } }
public void DrawTextBoxTest() { TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph pOuter = ParagraphBuilder.CreateStandardTextParagraph(textdocument); DrawTextBox drawTextBox = new DrawTextBox(textdocument); Frame frameTextBox = new Frame(textdocument, "fr_txt_box"); frameTextBox.DrawName = "fr_txt_box"; frameTextBox.ZIndex = "0"; // Paragraph pTextBox = ParagraphBuilder.CreateStandardTextParagraph(textdocument); // pTextBox.StyleName = "Illustration"; Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); p.StyleName = "Illustration"; Frame frame = new Frame(textdocument, "frame1", "graphic1", new DiskFile(_imagefile)); frame.ZIndex = "1"; p.Content.Add(frame); p.TextContent.Add(new SimpleText(textdocument, "Illustration")); drawTextBox.Content.Add(p); frameTextBox.SvgWidth = frame.SvgWidth; drawTextBox.MinWidth = frame.SvgWidth; drawTextBox.MinHeight = frame.SvgHeight; frameTextBox.Content.Add(drawTextBox); pOuter.Content.Add(frameTextBox); textdocument.Content.Add(pOuter); using (IPackageWriter writer = new OnDiskPackageWriter()) { textdocument.Save(AARunMeFirstAndOnce.outPutFolder + "drawTextbox.odt", new OpenDocumentTextExporter(writer)); } }
public void CreateIllustrationUsingTheFrameBuilder() { TextDocument document = new TextDocument(); document.New(); //Create a standard pargraph for the illustration Paragraph paragraphStandard = ParagraphBuilder.CreateStandardTextParagraph(document); //Create Illustration Frame using the FrameBuilder Frame frameIllustration = FrameBuilder.BuildIllustrationFrame( document, "illustration_frame_1", "graphic1", new DiskFile(_imagefile), "This is a Illustration", 1); //Add the Illustration Frame to the Paragraph paragraphStandard.Content.Add(frameIllustration); Assert.IsTrue(frameIllustration.Content[0] is DrawTextBox, "Must be a DrawTextBox!"); Assert.IsTrue(((DrawTextBox)frameIllustration.Content[0]).Content[0] is Paragraph, "Must be a Paragraph!"); Paragraph paragraph = ((DrawTextBox)frameIllustration.Content[0]).Content[0] as Paragraph; Assert.IsTrue(paragraph.TextContent[1] is TextSequence, "Must be a TextSequence!"); //Add Paragraph to the document document.Content.Add(paragraphStandard); //Save the document using (IPackageWriter writer = new OnDiskPackageWriter()) { document.Save(AARunMeFirstAndOnce.outPutFolder + "illustration.odt", new OpenDocumentTextExporter(writer)); } }
public void ListItemTest() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a numbered list List li = new List(document, "L1", ListStyles.Bullet, "L1P1"); //Create a new list item ListItem lit = new ListItem(li); Assert.IsNotNull(lit.Content, "Content object must exist!"); //Create a paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some text paragraph.TextContent.Add(new SimpleText(document, "First item")); //Add paragraph to the list item lit.Content.Add(paragraph); //Add the list item li.Content.Add(lit); //Add the list document.Content.Add(li); //Save document document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "list.odt"); }
private void blank_zakaza_firm(string id_prodaja, string id_kosmetika, string name_kosmetika, string count, string date) { TextDocument document = new TextDocument(); document.New(); AODL.Document.Content.Text.Paragraph p1 = ParagraphBuilder.CreateStandardTextParagraph(document); p1.TextContent.Add(new SimpleText(document, "Бланк Заказa. Сетевая косметическая фирма «Бьюти» \n\r")); document.Content.Add(p1); AODL.Document.Content.Text.Paragraph p2 = ParagraphBuilder.CreateStandardTextParagraph(document); p2.TextContent.Add(new SimpleText(document, "Филиал: Ульяновский")); document.Content.Add(p2); AODL.Document.Content.Text.Paragraph p3 = ParagraphBuilder.CreateStandardTextParagraph(document); p3.TextContent.Add(new SimpleText(document, "Номер товара: " + id_kosmetika)); document.Content.Add(p3); AODL.Document.Content.Text.Paragraph p4 = ParagraphBuilder.CreateStandardTextParagraph(document); p4.TextContent.Add(new SimpleText(document, "Название товара:" + name_kosmetika)); document.Content.Add(p4); AODL.Document.Content.Text.Paragraph p5 = ParagraphBuilder.CreateStandardTextParagraph(document); p5.TextContent.Add(new SimpleText(document, "Количество:" + count)); document.Content.Add(p5); AODL.Document.Content.Text.Paragraph p6 = ParagraphBuilder.CreateStandardTextParagraph(document); p6.TextContent.Add(new SimpleText(document, "Дата заказа: " + date)); document.Content.Add(p6); document.SaveTo(id_kosmetika + ".blank_zakaza_firm.odt"); }
/// <summary> /// Creates a simple text content and adds it to the provided content collection. /// </summary> /// <param name="doc"></param> /// <param name="content"></param> /// <param name="value">The value to write. May be null.</param> protected static void CreateAddSimpleText(IDocument doc, IContentCollection content, object value) { Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(doc); p.TextContent.Add(new SimpleText(doc, Convert.ToString(value ?? string.Empty))); content.Add(p); }
public void TableOfContentsTest() { //Create new Document TextDocument textDocument = new TextDocument(); textDocument.New(); //Create a new Table of contents TableOfContents tableOfContents = new TableOfContents( textDocument, "Table_Of_Contents", false, false, "Table of Contents"); //Add the toc textDocument.Content.Add(tableOfContents); //Create a new heading, there's no need of the chapter number string sHeading = "A first headline"; //The corresponding text entry, here you need to set the //chapter number string sTocEntry = "1. A first headline"; Header header = new Header( textDocument, Headings.Heading_20_1); header.OutLineLevel = "1"; header.TextContent.Add(new SimpleText(textDocument, sHeading)); //add the header to the content textDocument.Content.Add(header); //add the toc entry text as entry to the Table of contents tableOfContents.InsertEntry(sTocEntry, 1); //Add some text to this chapter Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument); paragraph.TextContent.Add(new SimpleText(textDocument, "I'm the text for the first chapter!")); textDocument.Content.Add(paragraph); //Add a sub header to the first chapter //Create a new heading, there's no need of the chapter number sHeading = "A first sub headline"; //The corresponding text entry, here you need to set the //chapter number sTocEntry = "1.1. A first sub headline"; header = new Header( textDocument, Headings.Heading_20_2); header.OutLineLevel = "2"; header.TextContent.Add(new SimpleText(textDocument, sHeading)); //add the header to the content textDocument.Content.Add(header); //add the toc entry text as entry to the Table of contents tableOfContents.InsertEntry(sTocEntry, 2); //Add some text to this sub chapter paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument); paragraph.TextContent.Add(new SimpleText(textDocument, "I'm the text for the subchapter chapter!")); textDocument.Content.Add(paragraph); // ListStyle listStyle = new ListStyle(textDocument, "TOC_LIST"); // listStyle.AutomaticAddListLevelStyles(ListStyles.Number); // textDocument.Styles.Add(listStyle); //Save it using (IPackageWriter writer = new OnDiskPackageWriter()) { textDocument.Save(AARunMeFirstAndOnce.outPutFolder + "toc.odt", new OpenDocumentTextExporter(writer)); } }
public void NestedTable() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a table for a text document using the TableBuilder Table table = TableBuilder.CreateTextDocumentTable( document, "table1", "table1", 3, 3, 16.99, false, false); //Create a standard paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some cell text")); Assert.IsNotNull(table.Rows, "Must exist."); Assert.IsTrue(table.Rows.Count == 3, "There must be 3 rows."); //Insert paragraph into the second cell table.Rows[0].Cells[1].Content.Add(paragraph); //Get width of the nested table double nestedTableWidth = SizeConverter.GetDoubleFromAnOfficeSizeValue( table.ColumnCollection[0].ColumnStyle.ColumnProperties.Width); //Create another table using the TableBuilder Table nestedTable = TableBuilder.CreateTextDocumentTable( document, "table1", "table1", 2, 2, nestedTableWidth, false, false); //Create a new standard paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some cell text inside the nested table")); Assert.IsNotNull(nestedTable.Rows, "Must exist."); Assert.IsTrue(nestedTable.Rows.Count == 2, "There must be 3 rows."); //Insert paragraph into the first cell nestedTable.Rows[0].Cells[0].Content.Add(paragraph); //Insert the nested table into the first row and first cell table.Rows[0].Cells[0].Content.Add(nestedTable); Assert.IsTrue(table.Rows[0].Cells[0].Content[0] is Table, "Must be the nested table."); //Add table to the document document.Content.Add(table); //Save the document using (IPackageWriter writer = new OnDiskPackageWriter()) { document.Save(AARunMeFirstAndOnce.outPutFolder + "nestedTable.odt", new OpenDocumentTextExporter(writer)); } }
public void CloneTable() { // with 100 columns and 5000 rows should execute in less than 29 sec // with 100 columns and 1000 rows should execute in less than 6.5 sec TextDocument docuemnt = new TextDocument(); docuemnt.New(); Table table = new Table(docuemnt, "table name", "table style"); int numberOfColumns = 100; int numberOfRows = 1000; // prepare data // add columns for (int i = 0; i < numberOfColumns; i++) { table.ColumnCollection.Add(new Column(table, "style name " + i)); } Row row = null; // Add rows for (int i = 0; i < 2; i++) { row = new Row(table); for (int i1 = 0; i1 < numberOfColumns; i1++) { Paragraph par = ParagraphBuilder.CreateStandardTextParagraph(docuemnt); par.TextContent.AddRange(TextBuilder.BuildTextCollection(docuemnt, (i * numberOfColumns).ToString() + i1)); row.Cells.Add(new Cell(table.Document, "cell style " + i)); //row.Cells.Add(new Cell(table.Document)); row.Cells[i1].Content.Add(par); } table.Rows.Insert(0, row); } // clone many rows row = table.Rows[0]; using (IPerformanceCounter counter = new PerformanceCounter()) { for (int i = 0; i < numberOfRows; i++) { Row newRow = new Row(table, row.StyleName); foreach (Cell rowCell in row.Cells) { Cell cell = new ContentMocker().CloneAny(rowCell) as Cell; newRow.Cells.Add(cell); } } Console.WriteLine(string.Format( "Test executed in {0} seconds", counter.GetSeconds())); } }
/// <summary> /// Writes the index of the customer at. /// </summary> /// <param name="billingDoc">The billing doc.</param> /// <param name="index">The index.</param> private void WriteCustomerAtIndex(TextDocument billingDoc, int index) { Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(billingDoc); p.TextContent.Add(new SimpleText(billingDoc, this._mainForm.Street)); billingDoc.Content.Insert(index + 1, p); p = ParagraphBuilder.CreateStandardTextParagraph(billingDoc); p.TextContent.Add(new SimpleText(billingDoc, this._mainForm.City)); billingDoc.Content.Insert(index + 2, p); p = ParagraphBuilder.CreateStandardTextParagraph(billingDoc); p.TextContent.Add(new SimpleText(billingDoc, "Account ID: " + this._mainForm.AccountID)); billingDoc.Content.Insert(index + 3, p); }
public void TestParagraphCloning() { TextDocument document = new TextDocument(); document.New(); Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); paragraph.TextContent.Add(new SimpleText(document, "Some text")); Paragraph paragraphClone = (Paragraph)paragraph.Clone(); Assert.AreNotEqual(paragraph.Node, paragraphClone.Node, "Should be cloned and not equal."); Assert.AreEqual(paragraph.TextContent[0].GetType(), paragraphClone.TextContent[0].GetType(), "Should be cloned and equal."); }
public void GraphicsTest() { TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame = new Frame(textdocument, "frame1", "graphic1", _imagefile); p.Content.Add(frame); textdocument.Content.Add(p); textdocument.SaveTo(AARunMeFirstAndOnce.outPutFolder + "grapic.odt"); }
public void HeaderContentsTest1() { string file = AARunMeFirstAndOnce.inPutFolder + "pagestyles.odt"; TextDocument textDocument = new TextDocument(); using (IPackageReader reader = new OnDiskPackageReader()) { textDocument.Load(file, new OpenDocumentImporter(reader)); 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"); using (IPackageWriter writer = new OnDiskPackageWriter()) { textDocument.Save(AARunMeFirstAndOnce.outPutFolder + "pagestyles_changed.odt", new OpenDocumentTextExporter(writer)); } } }
/// <summary> /// Creates sublists for nested lists. /// </summary> /// <param name="firstItem">The item to start the list with.</param> /// <param name="document">The document to which the sublist belongs.</param> /// <param name="currentIndex">The index of the item.</param> /// <returns>An ODF list</returns> protected AODL.Document.Content.Text.List GetODFSublist(ListItem firstItem, IDocument document, AODL.Document.Content.Text.List parentList, ref int currentIndex) { //Create a list AODL.Document.Content.Text.List list = new AODL.Document.Content.Text.List(document, parentList); //Set the level of the list int currentLevel = firstItem.Level; //Create a new list item AODL.Document.Content.Text.ListItem listItem = null; //Loop through the items while (currentIndex < Items.Count) { if (Items[currentIndex].Level > currentLevel) { //Start a new list and append items. listItem.Content.Add(GetODFSublist(Items[currentIndex], document, list, ref currentIndex)); continue; } if (Items[currentIndex].Level < currentLevel) { //Stop this list. break; } if (Items[currentIndex].Level == currentLevel) { //Create a new list item listItem = new AODL.Document.Content.Text.ListItem(document); //Create a paragraph var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add the text foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(document, Items[currentIndex].Text)) { paragraph.TextContent.Add(formatedText); } //Add paragraph to the list item listItem.Content.Add(paragraph); //Add the list item list.Content.Add(listItem); currentIndex++; } } return(list); }
public void GraphicsTest() { TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame = new Frame(textdocument, "frame1", "graphic1", new DiskFile(_imagefile)); p.Content.Add(frame); textdocument.Content.Add(p); using (IPackageWriter writer = new OnDiskPackageWriter()) { textdocument.Save(AARunMeFirstAndOnce.outPutFolder + "grapic.odt", new OpenDocumentTextExporter(writer)); } }
public void ParagraphSimpleText() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some simple text!")); //Add the paragraph to the document document.Content.Add(paragraph); //Save empty document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "simple.odt"); }
/// <summary> /// Creates a ODF table row. /// </summary> /// <param name="row">The row in the ODF document.</param> /// <returns>The filled ODF row.</returns> internal AODL.Document.Content.Tables.Row GetODF(AODL.Document.Content.Tables.Row row) { foreach (string s in _values) { //Create a standard paragraph var paragraph = ParagraphBuilder.CreateStandardTextParagraph(row.Document); //Add the text foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(row.Document, s)) { paragraph.TextContent.Add(formatedText); } //Add the content to the cell //row.Cells[_values.IndexOf(s)].Content.Add(paragraph); } return(row); }
/// <summary> /// Gets a list in ODF format. /// </summary> /// <param name="document">The document to which the list belongs.</param> /// <returns>The list as an IContent document</returns> public override IContent GetODFList(IDocument document) { //Create a list AODL.Document.Content.Text.List list = new AODL.Document.Content.Text.List(document, "NL1", ListStyles.Number, "NL1P1"); //Set the list level to 0 as this is the top of the list int currentLevel = 0; //Create a new list item AODL.Document.Content.Text.ListItem listItem = null; //Loop through the items for (int currentIndex = 0; currentIndex < Items.Count; currentIndex++) { if (Items[currentIndex].Level > currentLevel) { //Start a new list and append items. if (listItem == null) { listItem = new AODL.Document.Content.Text.ListItem(document); } listItem.Content.Add(GetODFSublist(Items[currentIndex], document, list, ref currentIndex)); currentIndex--; //Skip the rest of the routine continue; } if (Items[currentIndex].Level == currentLevel) { //Create a new list item listItem = new AODL.Document.Content.Text.ListItem(document); //Create a paragraph var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add the text foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(document, Items[currentIndex].Text)) { paragraph.TextContent.Add(formatedText); } //Add paragraph to the list item listItem.Content.Add(paragraph); //Add the list item list.Content.Add(listItem); } } return(list); }
public void FootnoteText() { //Create new TextDocument TextDocument document = new TextDocument(); document.New(); //Create a new Paragph Paragraph para = ParagraphBuilder.CreateStandardTextParagraph(document); //Create some simple Text para.TextContent.Add(new SimpleText(document, "Some simple text. And I have a footnode")); //Create a Footnote para.TextContent.Add(new Footnote(document, "Footer Text", "1", FootnoteType.footnode)); //Add the paragraph document.Content.Add(para); //Save document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "footnote.odt"); }
public void ParagraphFormatedText() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some formated text FormatedText formText = new FormatedText(document, "T1", "Some formated text!"); formText.TextStyle.TextProperties.Bold = "bold"; paragraph.TextContent.Add(formText); //Add the paragraph to the document document.Content.Add(paragraph); //Save empty document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "formated.odt"); }
public void ParagraphSimpleText() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some simple text!")); //Add the paragraph to the document document.Content.Add(paragraph); //Save empty using (IPackageWriter writer = new OnDiskPackageWriter()) { document.Save(AARunMeFirstAndOnce.outPutFolder + "simple.odt", new OpenDocumentTextExporter(writer)); } }
public void InsertAndRemoveTest() { //Create a new document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Create some simple text SimpleText 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."); }
private void button5_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(); KURS.allDataSet kursDataSet = new KURS.allDataSet(); KURS.allDataSetTableAdapters.TovarTableAdapter TovarTableAdapter = new KURS.allDataSetTableAdapters.TovarTableAdapter(); TovarTableAdapter.Fill(kursDataSet.Tovar); TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph headerText1 = ParagraphBuilder.CreateStandardTextParagraph(textdocument); headerText1.TextContent.Add(new SimpleText(textdocument, "firma kosmetics")); textdocument.Content.Add(headerText1); Paragraph headerText2 = ParagraphBuilder.CreateStandardTextParagraph(textdocument); headerText2.TextContent.Add(new SimpleText(textdocument, "Ulyanovsk, Russian Federation")); textdocument.Content.Add(headerText2); Paragraph headerText3 = ParagraphBuilder.CreateStandardTextParagraph(textdocument); headerText3.TextContent.Add(new SimpleText(textdocument, "Кому: " + listBox1.Text)); textdocument.Content.Add(headerText3); var d = from price in kursDataSet.Tovar.AsEnumerable() where price.kolvo == 0 select price; Paragraph maintext = ParagraphBuilder.CreateStandardTextParagraph(textdocument); maintext.TextContent.Add(new SimpleText(textdocument, "ID--name--srok--price" + Environment.NewLine)); textdocument.Content.Add(maintext); foreach (var obj in d) { Paragraph maintext2 = ParagraphBuilder.CreateStandardTextParagraph(textdocument); maintext2.TextContent.Add(new SimpleText(textdocument, obj.id.ToString() + "--" + obj.name.ToString() + "--" + obj.srok.ToString() + "--" + obj.price.ToString() + Environment.NewLine)); textdocument.Content.Add(maintext2); } Paragraph footerText = ParagraphBuilder.CreateStandardTextParagraph(textdocument); footerText.TextContent.Add(new SimpleText(textdocument, "Подпись продавца:_____________")); textdocument.Content.Add(footerText); textdocument.SaveTo(saveFileDialog1.FileName); }
public void CreateFreePositionGraphic() { TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame = FrameBuilder.BuildStandardGraphicFrame(textdocument, "frame1", "graphic1", _imagefile); //Setps to set a graphic free with x and y frame.SvgX = "1.75cm"; frame.SvgY = "1.75cm"; ((FrameStyle)frame.Style).GraphicProperties.HorizontalPosition = "from-left"; ((FrameStyle)frame.Style).GraphicProperties.VerticalPosition = "from-top"; ((FrameStyle)frame.Style).GraphicProperties.HorizontalRelative = "paragraph"; ((FrameStyle)frame.Style).GraphicProperties.VerticalRelative = "paragraph"; p.Content.Add(frame); textdocument.Content.Add(p); textdocument.SaveTo(AARunMeFirstAndOnce.outPutFolder + "grapic_free_xy.odt"); }
public void HeaderAndFooterCreateTest() { TextDocument document = new TextDocument(); document.New(); // get default mast page layout TextMasterPage txtMP = document.TextMasterPageCollection.GetDefaultMasterPage(); // IMPORTANT: activating header and footer usage // has to be called before setting there layout properties! txtMP.ActivatePageHeaderAndFooter(); Console.WriteLine(txtMP.TextPageHeader.MarginLeft); // set page header layout // txtMP.TextPageHeader.MarginLeft = "4cm"; // // set text page layout // txtMP.TextPageLayout.MarginLeft = "6cm"; // // create a paragraph for the header Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); // add some formated text // TODO: FIXME there is a bug with the text styles for header and footer! FormatedText formText = new FormatedText(document, "T1", "Some formated text in the page header ..."); formText.TextStyle.TextProperties.Bold = "bold"; paragraph.TextContent.Add(formText); // add this paragraph to the page header txtMP.TextPageHeader.ContentCollection.Add(paragraph); // create a paragraph collection with some text for the document // ParagraphCollection pColl = AODL.Document.Content.Text.ParagraphBuilder.CreateParagraphCollection( // document, // "Some text in here ... \n\n... with a modified master page :)", // true, // ParagraphBuilder.ParagraphSeperator); // // add the paragraphs // foreach(AODL.Document.Content.Text.Paragraph p in pColl) // document.Content.Add(p); // save the document using (IPackageWriter writer = new OnDiskPackageWriter()) { document.Save(AARunMeFirstAndOnce.outPutFolder + "text_master_page_1.odt", new OpenDocumentTextExporter(writer)); } }
/// <summary> /// Builds the illustration frame. /// </summary> /// <param name="document">The document.</param> /// <param name="frameStyleName">Name of the frame style.</param> /// <param name="graphicName">Name of the graphic.</param> /// <param name="pathToGraphic">The path to graphic.</param> /// <param name="illustrationText">The illustration text.</param> /// <param name="illustrationNumber">The illustration number.</param> /// <returns> /// A new Frame object containing a DrawTextBox which contains the /// illustration Graphic object and a text sequence representing /// the displayed illustration text. /// </returns> public static Frame BuildIllustrationFrame(IDocument document, string frameStyleName, string graphicName, string pathToGraphic, string illustrationText, int illustrationNumber) { DrawTextBox drawTextBox = new DrawTextBox(document); Frame frameTextBox = new Frame(document, frameStyleName); frameTextBox.DrawName = frameStyleName + "_" + graphicName; frameTextBox.ZIndex = "0"; Paragraph pIllustration = ParagraphBuilder.CreateStandardTextParagraph(document); pIllustration.StyleName = "Illustration"; Frame frame = new Frame(document, "InnerFrame_" + frameStyleName, graphicName, pathToGraphic); frame.ZIndex = "1"; pIllustration.Content.Add(frame); //add Illustration as text pIllustration.TextContent.Add(new SimpleText(document, "Illustration")); //add TextSequence TextSequence textSequence = new TextSequence(document); textSequence.Name = "Illustration"; textSequence.NumFormat = "1"; textSequence.RefName = "refIllustration" + illustrationNumber.ToString(); textSequence.Formula = "ooow:Illustration+1"; textSequence.TextContent.Add(new SimpleText(document, illustrationNumber.ToString())); pIllustration.TextContent.Add(textSequence); //add the ilustration text pIllustration.TextContent.Add(new SimpleText(document, illustrationText)); //add the Paragraph to the DrawTextBox drawTextBox.Content.Add(pIllustration); frameTextBox.SvgWidth = frame.SvgWidth; drawTextBox.MinWidth = frame.SvgWidth; drawTextBox.MinHeight = frame.SvgHeight; frameTextBox.Content.Add(drawTextBox); return(frameTextBox); }