本文整理汇总了C#中AODL.Document.TextDocuments.TextDocument类的典型用法代码示例。如果您正苦于以下问题:C# TextDocument类的具体用法?C# TextDocument怎么用?C# TextDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextDocument类属于AODL.Document.TextDocuments命名空间,在下文中一共展示了TextDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNewDocumentAndDoAPrintOut
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);
}
示例2: MetaDataDisplay
public void MetaDataDisplay()
{
TextDocument document = null;
document = new TextDocument();
document.Load(AARunMeFirstAndOnce.inPutFolder+"ProgrammaticControlOfMenuAndToolbarItems.odt");
Console.WriteLine(document.DocumentMetadata.InitialCreator);
Console.WriteLine(document.DocumentMetadata.LastModified);
Console.WriteLine(document.DocumentMetadata.CreationDate);
Console.WriteLine(document.DocumentMetadata.CharacterCount);
Console.WriteLine(document.DocumentMetadata.ImageCount);
Console.WriteLine(document.DocumentMetadata.Keywords);
Console.WriteLine(document.DocumentMetadata.Language);
Console.WriteLine(document.DocumentMetadata.ObjectCount);
Console.WriteLine(document.DocumentMetadata.PageCount);
Console.WriteLine(document.DocumentMetadata.ParagraphCount);
Console.WriteLine(document.DocumentMetadata.Subject);
Console.WriteLine(document.DocumentMetadata.TableCount);
Console.WriteLine(document.DocumentMetadata.Title);
Console.WriteLine(document.DocumentMetadata.WordCount);
document.DocumentMetadata.SetUserDefinedInfo(UserDefinedInfo.Info1, "Nothing");
Console.WriteLine(document.DocumentMetadata.GetUserDefinedInfo(UserDefinedInfo.Info1));
}
示例3: DrawTextBox
public void DrawTextBox()
{
//New TextDocument
TextDocument textdocument = new TextDocument();
textdocument.New();
//Standard Paragraph
Paragraph paragraphOuter = new Paragraph(textdocument, ParentStyles.Standard.ToString());
//Create Frame for DrawTextBox
Frame frameOuter = new Frame(textdocument, "frame1");
//Create DrawTextBox
DrawTextBox drawTextBox = new DrawTextBox(textdocument);
//Create a paragraph for the drawing frame
Paragraph paragraphInner = new Paragraph(textdocument, ParentStyles.Standard.ToString());
//Create the frame with the Illustration resp. Graphic
Frame frameIllustration = new Frame(textdocument, "frame2", "graphic1", _imagefile);
//Add Illustration frame to the inner Paragraph
paragraphInner.Content.Add(frameIllustration);
//Add inner Paragraph to the DrawTextBox
drawTextBox.Content.Add(paragraphInner);
//Add the DrawTextBox to the outer Frame
frameOuter.Content.Add(drawTextBox);
//Add the outer Frame to the outer Paragraph
paragraphOuter.Content.Add(frameOuter);
//Add the outer Paragraph to the TextDocument
textdocument.Content.Add(paragraphOuter);
//Save the document
textdocument.SaveTo(_framefile2);
}
示例4: ODFFrameTest
public void ODFFrameTest()
{
//Create a new text document
TextDocument document = new TextDocument();
document.New();
// Create a main paragraph
Paragraph p =new Paragraph(document);
// Create a main form
ODFForm main_form = new ODFForm(document, "mainform");
main_form.Method = Method.Get;
// Create a frame
ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm");
frm.Label = "ODFFrame test";
// Add the frame to the form control list
main_form.Controls.Add (frm);
// Create a button
ODFButton butt = new ODFButton(main_form, p.Content, "butt", "1cm", "15mm", "4cm", "1cm");
butt.Label = "A simple button :)";
// Add the button to the form control list
main_form.Controls.Add (butt);
// Add the forms to the document!
document.Forms.Add(main_form);
// Add the paragraph to the content list
document.Content.Add(p);
document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"frame_test.odt");
document.Load(AARunMeFirstAndOnce.outPutFolder+"frame_test.odt");
document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"frame_test2.odt");
}
示例5: FrameWriteTest
public void FrameWriteTest()
{
TextDocument textdocument = new TextDocument();
textdocument.New();
// Create a frame incl. graphic file
Frame frame = FrameBuilder.BuildStandardGraphicFrame(
textdocument, "frame1", "graphic1", _imagefile);
// Create some event listeners (using OpenOffice friendly syntax).
EventListener script1 = new EventListener(textdocument,
"dom:mouseover", "javascript",
"vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
EventListener script2 = new EventListener(textdocument,
"dom:mouseout", "javascript",
"vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
EventListeners listeners = new EventListeners(textdocument, new EventListener[] { script1, script2 });
// Create and add some area rectangles
DrawAreaRectangle[] rects = new DrawAreaRectangle[2];
rects[0] = new DrawAreaRectangle(textdocument, "4cm", "4cm", "2cm", "2cm");
rects[0].Href = @"http://www.eduworks.com";
rects[1] = new DrawAreaRectangle(textdocument, "1cm", "1cm", "2cm", "2cm", listeners);
// Create and add an image map, referencing the area rectangles
ImageMap map = new ImageMap(textdocument, rects);
frame.Content.Add(map);
// Add the frame to the text document
textdocument.Content.Add(frame);
// Save the document
textdocument.SaveTo(_framefile3);
textdocument.Dispose();
}
示例6: PlaceholderTest
public void PlaceholderTest()
{
// Create a new text document
TextDocument td = new TextDocument();
td.New();
// Add paragraph 1 with a text placeholder in it
Paragraph p1 = new Paragraph(td);
p1.TextContent.Add(new SimpleText(td, "Insert text here: "));
Placeholder plch1 = new Placeholder(td, PlaceholderType.Text, "A text placeholder");
plch1.Value = "Text";
p1.Content.Add(plch1);
td.Content.Add(p1);
// Add paragraph 2 with a text-box placeholder in it
Paragraph p2 = new Paragraph(td);
p2.TextContent.Add(new SimpleText(td, "Insert text-box here: "));
Placeholder plch2 = new Placeholder(td, PlaceholderType.TextBox, "A text-box placeholder");
plch2.Value = "Text-Box";
p2.Content.Add(plch2);
td.Content.Add(p2);
// Add paragraph 3 with a table placeholder in it
Paragraph p3 = new Paragraph(td);
p3.TextContent.Add(new SimpleText(td, "Insert table here: "));
Placeholder plch3 = new Placeholder(td, PlaceholderType.Table, "A table placeholder");
plch3.Value = "Table";
p3.Content.Add(plch3);
td.Content.Add(p3);
// Add paragraph 4 with an object placeholder in it
Paragraph p4 = new Paragraph(td);
p4.TextContent.Add(new SimpleText(td, "Insert object here: "));
Placeholder plch4 = new Placeholder(td, PlaceholderType.Object, "An object placeholder");
plch4.Value = "Object";
p4.Content.Add(plch4);
td.Content.Add(p4);
// Add paragraph 5 with an image placeholder in it
Paragraph p5 = new Paragraph(td);
p5.TextContent.Add(new SimpleText(td, "Insert image here: "));
Placeholder plch5 = new Placeholder(td, PlaceholderType.Image, "An image placeholder");
plch5.Value = "Image";
p5.Content.Add(plch5);
td.Content.Add(p5);
// test save/load
td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "placeholder.odt");
// find a field in the fields collection and change its value
td.Fields.FindFieldByValue("Image").Value = "There should be an image here";
// test html export!
td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "placeholder.html");
td.Load(AARunMeFirstAndOnce.outPutFolder + "placeholder.odt");
// resave it
td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "placeholder2.odt");
}
示例7: EmptyDocument
public void EmptyDocument()
{
//Create a new text document
var document = new TextDocument();
document.New();
//Save empty
document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"empty.odt");
}
示例8: ImportTest1
public void ImportTest1 ()
{
string file = AARunMeFirstAndOnce.inPutFolder+"pagestyles.odt";
TextDocument textDocument = new TextDocument();
textDocument.Load(file);
TextMasterPage txtMP = textDocument.TextMasterPageCollection.GetDefaultMasterPage();
Assert.IsNotNull(txtMP, "The default text mast page style must exists.");
}
示例9: NestedFormTest
public void NestedFormTest()
{
//Create a new text document
TextDocument document = new TextDocument();
document.New();
// Create a main paragraph
Paragraph p =new Paragraph(document);
// Create a main form
ODFForm main_form = new ODFForm(document, "mainform");
ODFForm child_form = new ODFForm(document, "childform");
main_form.Method = Method.Get;
main_form.Method = Method.Get;
// Create a frame
ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm");
frm.Label = "Main form";
// Add the frame to the form control list
main_form.Controls.Add (frm);
// Create a button
ODFButton butt = new ODFButton(main_form, p.Content, "butt", "1cm", "15mm", "4cm", "1cm");
butt.Label = "This is a main form";
// Add the button to the form control list
main_form.Controls.Add (butt);
// Add the forms to the main form!
document.Forms.Add(main_form);
// Add the paragraph to the content list
document.Content.Add(p);
// adding controls to the nested form
ODFFrame frm_child = new ODFFrame(child_form, p.Content, "frm_child", "5mm", "35mm", "5cm", "3cm");
frm_child.Label = "Child form";
child_form.Controls.Add (frm_child);
ODFButton butt_child = new ODFButton(child_form, p.Content, "butt_child", "1cm", "45mm", "4cm", "1cm");
butt_child.Label = "This is a child form";
child_form.Controls.Add (butt_child);
main_form.ChildForms.Add(child_form);
ODFButton b = document.FindControlById("butt_child") as ODFButton;
Assert.IsNotNull(b, "Error! could not find the specified control");
b.Label = "Child form:)";
// Add the forms to the main form!
document.Forms.Add(main_form);
// Add the paragraph to the content list
document.Content.Add(p);
document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test.odt");
document.Load(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test.odt");
document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test2.odt");
}
示例10: GetStyleByName_Null
public void GetStyleByName_Null()
{
TextDocument document = new TextDocument();
document.New();
StyleCollection collection = new StyleCollection();
IStyle nullStyle = new TableStyle(document, string.Empty);
collection.Add(nullStyle);
Assert.AreEqual(nullStyle, collection.GetStyleByName(null));
}
示例11: HTMLExportTest2
public void HTMLExportTest2()
{
string file = [email protected]"OpenOffice.net.odt";
FileInfo fInfo = new FileInfo(file);
//Load a text document
TextDocument textDocument = new TextDocument();
textDocument.Load(file);
//Save it back again
textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".html");
}
示例12: FooterContentsTest
public void FooterContentsTest()
{
string file = AARunMeFirstAndOnce.inPutFolder+"pagestyles.odt";
TextDocument textDocument = new TextDocument();
textDocument.Load(file);
TextMasterPage txtMP = textDocument.TextMasterPageCollection.GetDefaultMasterPage();
Assert.IsNotNull(txtMP.TextPageFooter, "The page header must exist.");
Assert.IsNotNull(txtMP.TextPageFooter.ContentCollection, "Content collection must exist.");
Assert.IsTrue(txtMP.TextPageFooter.ContentCollection.Count > 0, "There must be content in the page footers content collection.");
}
示例13: SimpleTocLoadTest
public void SimpleTocLoadTest()
{
string file = [email protected]"simple_toc.odt";
FileInfo fInfo = new FileInfo(file);
//Load a text document
TextDocument textDocument = new TextDocument();
textDocument.Load(file);
//Save it back again
textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".rel.odt");
}
示例14: GraphicsTest
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");
}
示例15: LoadDocument_With_PageBreak
public void LoadDocument_With_PageBreak()
{
string file = AARunMeFirstAndOnce.inPutFolder + @"paragraph_with_page_break.odt";
TextDocument textDocument = new TextDocument();
textDocument.Load(file);
Assert.AreEqual(3, textDocument.Content.Count);
Paragraph paragraph = textDocument.Content[2] as Paragraph;
Assert.IsNotNull(paragraph);
Assert.AreEqual("page", paragraph.ParagraphStyle.ParagraphProperties.BreakBefore );
}