当前位置: 首页>>代码示例>>C#>>正文


C# TextDocument.Dispose方法代码示例

本文整理汇总了C#中AODL.Document.TextDocuments.TextDocument.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.Dispose方法的具体用法?C# TextDocument.Dispose怎么用?C# TextDocument.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AODL.Document.TextDocuments.TextDocument的用法示例。


在下文中一共展示了TextDocument.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadFileDeleteGraphic

		public void LoadFileDeleteGraphic()
		{
			string fileName					= "hallo_rem_graphic.odt";
			string graphicFile				= "";
			TextDocument document			= new TextDocument();
			document.Load(AARunMeFirstAndOnce.inPutFolder+"hallo.odt");
			foreach(IContent iContent in document.Content)
			{
				if (iContent is Paragraph && ((Paragraph)iContent).Content.Count > 0
					&& ((Paragraph)iContent).Content[0] is Frame)
				{
					Frame frame				= ((Paragraph)iContent).Content[0] as Frame;
					Assert.IsTrue(frame.Content[0] is Graphic, "Must be a graphic!");
					Graphic graphic			= frame.Content[0] as Graphic;
					//now access the full qualified graphic path
					Assert.IsNotNull(graphic.GraphicRealPath, "The graphic real path must exist!");
					Assert.IsTrue(File.Exists(graphic.GraphicRealPath));
					graphicFile				= graphic.GraphicRealPath;
					//Delete the graphic
					frame.Content.Remove(graphic);
				}
			}
			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+fileName);
			//Special case, only for this test neccessary
			document.Dispose();
			//Load file again
			TextDocument documentRel		= new TextDocument();
			documentRel.Load(AARunMeFirstAndOnce.outPutFolder+fileName);
			Assert.IsFalse(File.Exists(graphicFile), "This file must be removed from this file!");
		}
开发者ID:rabidbob,项目名称:aodl-reloaded,代码行数:30,代码来源:GraphicTest.cs

示例2: PrintSelected_Click


//.........这里部分代码省略.........
                    "table1",
                    selectedRows.Count + 1,
                    columns.Count,
                    16.99,
                    false,
                    true);

                //Fill the cells
                int columnIndex = 0, rowIndex = 0;
                foreach (GridColumn column in columns)
                {
                    Cell cell = table.RowCollection[0].CellCollection[columnIndex];
                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    paragraph.TextContent.Add(new SimpleText(document, column.Name));
                    cell.Content.Add(paragraph);
                    columnIndex++;
                }
                rowIndex++;

                foreach (DataRow row in data.Rows)
                {
                    Guid rodId = row.Field<Guid>("ConfigurationID");
                    if (!selectedRows.Contains(rodId)) continue;

                    columnIndex = 0;
                    foreach (GridColumn column in columns)
                    {
                        if (!row.IsNull(column.DataItem))
                        {
                            try
                            {
                                Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                string value = row.Field<string>(column.DataItem);
                                paragraph.TextContent.Add(new SimpleText(document, value));
                                cell.Content.Add(paragraph);
                            }
                            catch (System.Exception)
                            {
                                try
                                {
                                    Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                    int value = row.Field<int>(column.DataItem);
                                    paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                    cell.Content.Add(paragraph);
                                }
                                catch (System.Exception)
                                {
                                    try
                                    {
                                        Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                        Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                        decimal value = row.Field<decimal>(column.DataItem);
                                        paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                        cell.Content.Add(paragraph);
                                    }
                                    catch (System.Exception)
                                    {

                                    }
                                }
                            }
                        }
                        columnIndex++;
                    }
                    rowIndex++;
                }

            }

            //Merge some cells. Notice this is only available in text documents!
            // table.RowCollection[1].MergeCells(document, 1, 2, true);
            //Add table to the document
            document.Content.Add(table);
            //Save the document
            String fs_guid = Server.MapPath(String.Format("/tmp/{0}.odt", Guid.NewGuid().ToString()));
            document.SaveTo(fs_guid);
            document.Dispose();

            // Copy file to Response stream
            FileStream fs = new FileStream(fs_guid, FileMode.Open);

            int bufferSize = 4096;
            byte[] buffer = new byte[bufferSize];
            while (true)
            {
                int read = fs.Read(buffer, 0, buffer.Length);
                if (read <= 0)
                {
                    break;
                }
                Response.OutputStream.Write(buffer, 0, read);
            }

            fs.Close(); //закрываем writer
            File.Delete(fs_guid);
            Response.End(); //заканчиваем ответ сервера, иначе после этого вставится весь контент страницы
            return;
        }
开发者ID:vahtel65,项目名称:Aspect_loc,代码行数:101,代码来源:EditReadOnly.aspx.cs

示例3: EventListenerTest

        public void EventListenerTest()
        {
            try
            {
                TextDocument textdocument = new TextDocument();
                textdocument.New();

                // Create a frame (GraphicName == name property of frame)
                Frame frame						= new Frame(textdocument, "frame1", "img1", _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; reuse event listeners
                DrawAreaRectangle[] rects = new DrawAreaRectangle[2];
                rects[0] = new DrawAreaRectangle(textdocument, "4cm", "4cm", "2cm", "2cm", listeners);
                //Reuse a clone of the EventListener
                rects[1] = new DrawAreaRectangle(textdocument, "1cm", "1cm", "2cm", "2cm", (EventListeners)listeners.Clone());

                // 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(_framefile);
                textdocument.Dispose();
            }
            catch (Exception ex)
            {
                //Console.Write(ex.Message);
            }
        }
开发者ID:stuzzicadenti,项目名称:aodl,代码行数:41,代码来源:FrameTest.cs

示例4: PrintSelected_Click


//.........这里部分代码省略.........

                //Fill the cells
                int columnIndex = 0, rowIndex = 0;
                foreach (GridColumn column in columns)
                {
                    Cell cell = table.RowCollection[0].CellCollection[columnIndex];
                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    paragraph.TextContent.Add(new SimpleText(document, column.Name));
                    cell.Content.Add(paragraph);
                    columnIndex++;
                }
                rowIndex++;

                foreach (DataRow row in data.Tables[0].Rows)
                {
                    Guid rodId = row.Field<Guid>("ID");
                    if (!selectedRows.Contains(rodId)) continue;

                    columnIndex = 0;
                    foreach (GridColumn column in columns)
                    {
                        if (!row.IsNull(column.DataItem))
                        {
                            try
                            {
                                Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                string value = row.Field<string>(column.DataItem);
                                paragraph.TextContent.Add(new SimpleText(document, value));
                                cell.Content.Add(paragraph);
                            }
                            catch (System.Exception)
                            {
                                try
                                {
                                    Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                    Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                    int value = row.Field<int>(column.DataItem);
                                    paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                    cell.Content.Add(paragraph);
                                }
                                catch (System.Exception)
                                {
                                    try
                                    {
                                        Cell cell = table.RowCollection[rowIndex].CellCollection[columnIndex];
                                        Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                                        decimal value = row.Field<decimal>(column.DataItem);
                                        paragraph.TextContent.Add(new SimpleText(document, value.ToString()));
                                        cell.Content.Add(paragraph);
                                    }
                                    catch (System.Exception)
                                    {

                                    }
                                }
                            }
                        }
                        columnIndex++;
                    }
                    rowIndex++;
                }

            }

            //Add table to the document
            document.Content.Add(table);
            //Save the document
            string tmpCurrentDitectory = Environment.CurrentDirectory;
            Environment.CurrentDirectory = Server.MapPath("~/tmp").ToString();
            String fs_guid = Server.MapPath(String.Format("~/tmp/{0}.odt", Guid.NewGuid().ToString()));
            document.SaveTo(fs_guid);
            document.Dispose();
            Environment.CurrentDirectory = tmpCurrentDitectory;

            Response.Clear();
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
            Response.ContentType = "application/octet-stream";

            // Copy file to Response stream
            FileStream fs = new FileStream(fs_guid, FileMode.Open);
            Response.AddHeader("Content-Length", fs.Length.ToString());

            int bufferSize = 4096;
            byte[] buffer = new byte[bufferSize];
            while (true)
            {
                int read = fs.Read(buffer, 0, buffer.Length);
                if (read <= 0)
                {
                    break;
                }
                Response.OutputStream.Write(buffer, 0, read);
            }

            fs.Close(); //закрываем writer
            File.Delete(fs_guid);
            Response.End(); //заканчиваем ответ сервера, иначе после этого вставится весь контент страницы
            return;
        }
开发者ID:vahtel65,项目名称:testrepo,代码行数:101,代码来源:Grid.aspx.cs

示例5: FrameWriteTest

        public void FrameWriteTest()
        {
            try
            {
                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();
            }
            catch (Exception ex)
            {
                //Console.Write(ex.Message);
            }
        }
开发者ID:stuzzicadenti,项目名称:aodl,代码行数:42,代码来源:FrameTest.cs


注:本文中的AODL.Document.TextDocuments.TextDocument.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。