示例#1
0
 public void Howto_special_char()
 {
     TextDocument document		= new TextDocument();
     document.Load("Howto_special_char.odt");
     document.SaveTo("Howto_special_char.html");
     document.Dispose();
 }
示例#2
0
 public void Howto_special_charInch()
 {
     TextDocument document		= new TextDocument();
     document.Load(@"F:\odtFiles\Howto_special_char.odt");
     document.SaveTo(@"F:\odtFiles\Howto_special_char.html");
     document.Dispose();
 }
示例#3
0
        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!");
        }
示例#4
0
        public void Howto_special_char()
        {
            TextDocument document = new TextDocument();

            document.Load("Howto_special_char.odt");
            document.SaveTo("Howto_special_char.html");
            document.Dispose();
        }
示例#5
0
        public void Howto_special_charInch()
        {
            TextDocument document = new TextDocument();

            document.Load(@"F:\odtFiles\Howto_special_char.odt");
            document.SaveTo(@"F:\odtFiles\Howto_special_char.html");
            document.Dispose();
        }
示例#6
0
        public void ReloadTableOfContents()
        {
            TextDocument doc = new TextDocument();

            doc.Load("OpenOffice.net.odt");
            doc.SaveTo("OpenOffice.net.Reloaded.odt");
            doc.Dispose();
        }
示例#7
0
        public void TableOfContentsHtmlExport()
        {
            TextDocument doc = new TextDocument();

            doc.Load("OpenOffice.net.odt");
            doc.SaveTo("OpenOffice.net.html");
            doc.Dispose();
        }
示例#8
0
        public void SaveAsHtmlWithTable()
        {
            TextDocument document = new TextDocument();

            document.Load("tablewithList.odt");
            document.SaveTo("tablewithList.html");
            document.Dispose();
        }
示例#9
0
        public void ComplexTable()
        {
            TableTest tableTest	= new TableTest();
            tableTest.MergeCellsTest();

            TextDocument doc	= new TextDocument();
            doc.Load("tablemergedcell.odt");
            doc.SaveTo("tablemergedcellReloaded.odt");
            doc.Dispose();
        }
示例#10
0
		public void ReloadHeader()
		{
			TestClass test		= new TestClass();
			test.HeadingsTest();

			TextDocument doc	= new TextDocument();
			doc.Load("Heading.odt");
			doc.SaveTo("HeadingReloaded.odt");
			doc.Dispose();
		}
示例#11
0
 public void ProgrammaticControl()
 {
     TextDocument document		= new TextDocument();
     document.Load("ProgrammaticControlOfMenuAndToolbarItems.odt");
     document.SaveTo("ProgrammaticControlOfMenuAndToolbarItems.html");
     //			document.Load("AndrewMacroPart.odt");
     //			document.SaveTo("AndrewMacro.html");
     //			document.Load("OfferLongVersion.odt");
     //			document.SaveTo("OfferLongVersion.html");
     document.Dispose();
 }
示例#12
0
        public void ReloadXlink()
        {
            TestClass test = new TestClass();

            test.XLinkTest();

            TextDocument doc = new TextDocument();

            doc.Load("Xlink.odt");
            doc.SaveTo("XlinkReloaded.odt");
            doc.Dispose();
        }
示例#13
0
        public void ReloadHeader()
        {
            TestClass test = new TestClass();

            test.HeadingsTest();

            TextDocument doc = new TextDocument();

            doc.Load("Heading.odt");
            doc.SaveTo("HeadingReloaded.odt");
            doc.Dispose();
        }
示例#14
0
        public void ComplexTable()
        {
            TableTest tableTest = new TableTest();

            tableTest.MergeCellsTest();

            TextDocument doc = new TextDocument();

            doc.Load("tablemergedcell.odt");
            doc.SaveTo("tablemergedcellReloaded.odt");
            doc.Dispose();
        }
示例#15
0
        public void ProgrammaticControl()
        {
            TextDocument document = new TextDocument();

            document.Load("ProgrammaticControlOfMenuAndToolbarItems.odt");
            document.SaveTo("ProgrammaticControlOfMenuAndToolbarItems.html");
//			document.Load("AndrewMacroPart.odt");
//			document.SaveTo("AndrewMacro.html");
//			document.Load("OfferLongVersion.odt");
//			document.SaveTo("OfferLongVersion.html");
            document.Dispose();
        }
示例#16
0
        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);
            }
        }
示例#17
0
        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);
            }
        }
示例#18
0
        private async Task <string[]> readODT(string path)
        {
            string[] ret = new string[] { "" };

            var sb = new StringBuilder();


            using (var doc = new TextDocument())
            {
                try
                {
                    doc.Load(path);

                    //Main content
                    var mainPart = doc.Content.Cast <IContent>();
                    var mainText = String.Join("\r\n", mainPart.Select(x => x.Node.InnerText));

                    //Append both text variables

                    sb.Append(mainText);
                    //}
                    string fullText = sb.ToString();
                    ret = formatOddFileLayout(fullText);
                }
                catch (System.IO.IOException)
                {
                    loops++;
                    Console.WriteLine(_fileName + " is waiting in que for the " + loops + " time...");
                    //wait 2 sec and try again
                    System.Threading.Thread.Sleep(4000);
                    /*try { */ ret = Task.Run(() => readODT(path)).Result;/* }*/
                    //catch (System.IO.IOException) { }
                }
                Console.WriteLine(_fileName + " has been read and the reader will now Dispose of itself");
                doc.Dispose();
            }
            //replace with odt text readout

            return(ret);
        }
示例#19
0
        protected override void OnDispose()
        {
            if (isDisposed)
            {
                return;
            }

            isDisposed = true;

            textBufferRegistration?.Dispose();
            textBufferRegistration = null;

            // Parity behavior with the old editor
            if (autoSaveTask != null)
            {
                autoSaveTask.Wait(TimeSpan.FromSeconds(5));
            }
            RemoveAutoSaveTimer();
            if (!string.IsNullOrEmpty(FilePath))
            {
                AutoSave.RemoveAutoSaveFile(FilePath);
            }

            UnsubscribeFromEvents();
            TextDocument?.Dispose();

            if (policyContainer != null)
            {
                policyContainer.PolicyChanged -= PolicyChanged;
            }
            if (editorConfigContext != null)
            {
                editorConfigContext.CodingConventionsChangedAsync -= UpdateOptionsFromEditorConfigAsync;
                EditorConfigService.RemoveEditConfigContext(FilePath).Ignore();
            }

            base.OnDispose();
        }
示例#20
0
        public void ReloadXlink()
        {
            TestClass test		= new TestClass();
            test.XLinkTest();

            TextDocument doc	= new TextDocument();
            doc.Load("Xlink.odt");
            doc.SaveTo("XlinkReloaded.odt");
            doc.Dispose();
        }
示例#21
0
 public void SaveAsHtmlWithTable()
 {
     TextDocument document		= new TextDocument();
     document.Load("tablewithList.odt");
     document.SaveTo("tablewithList.html");
     document.Dispose();
 }
示例#22
0
 public void TableOfContentsHtmlExport()
 {
     TextDocument doc	= new TextDocument();
     doc.Load("OpenOffice.net.odt");
     doc.SaveTo("OpenOffice.net.html");
     doc.Dispose();
 }
示例#23
0
 public void ReloadTableOfContents()
 {
     TextDocument doc	= new TextDocument();
     doc.Load("OpenOffice.net.odt");
     doc.SaveTo("OpenOffice.net.Reloaded.odt");
     doc.Dispose();
 }