Ejemplo n.º 1
0
        public void Launch(Form parentForm, ProjectInfo projectInfo)
        {
            if (!Available)
            {
                throw new ConfigurationException(
                          "WeSay could not find LibreOffice 3.4 or newer.  Make sure you have installed it.");
            }
            if (!CheckUserCliConfigDir())
            {
                throw new ConfigurationException(
                          "WeSay could not configure LibreOffice 3.4 or newer.  Make sure you have installed it.");
            }


            OpenOfficeAddin odtAddin = new OpenOfficeAddin();

            OdtFile = Path.Combine(projectInfo.PathToExportDirectory, projectInfo.Name + ".odt");
            odtAddin.LaunchAfterExport = false;
            odtAddin.Launch(parentForm, projectInfo);

            bool succeeded = ((File.Exists(OdtFile)) && (new FileInfo(OdtFile).Length > 0));

            if (succeeded)
            {
                using (ProgressDialog dlg = new ProgressDialog())
                {
                    dlg.BarStyle = ProgressBarStyle.Marquee;             //we have no idea how much progress we've made

                    dlg.Overview = "Creating PDF Dictionary";
                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork              += OnDoWork;
                    dlg.BackgroundWorker        = worker;
                    dlg.CanCancel               = true;
                    dlg.ProgressState.Arguments = projectInfo;

                    dlg.ShowDialog();
                    if (dlg.ProgressStateResult != null &&
                        dlg.ProgressStateResult.ExceptionThatWasEncountered != null)
                    {
                        ErrorReport.ReportNonFatalException(
                            dlg.ProgressStateResult.ExceptionThatWasEncountered);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void TestOpenDocumentExport()
        {
            using (var e = new EnvironmentForTest())
            {
                var addin = new OpenOfficeAddin();
                addin.LaunchAfterExport = false;

                addin.Launch(null, e.ProjectInfo);
                Assert.IsTrue(File.Exists(e.OdtFile));
                bool succeeded = (new FileInfo(e.OdtFile).Length > 0);
                Assert.IsTrue(succeeded);

                var nsManager = new XmlNamespaceManager(new NameTable());
                nsManager.AddNamespace("text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
                nsManager.AddNamespace("style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
                AssertThatXmlIn.File(e.OdtContent).HasAtLeastOneMatchForXpath("//text:p", nsManager);
                AssertThatXmlIn.File(e.OdtStyles).HasAtLeastOneMatchForXpath("//style:font-face", nsManager);

                var      odtZip   = new ZipFile(e.OdtFile);
                ZipEntry manifest = odtZip.GetEntry("META-INF/manifest.xml");
                Assert.IsNotNull(manifest);
                odtZip.Close();
            }
        }