コード例 #1
0
        public async void butExport_Click(object sender, EventArgs e)
        {
            treeView.Nodes.Clear();
            exportParameters = GetExportParameters();

            PreExportProcess preExportProcess = new PreExportProcess(exportParameters, logger);
            bool             abort            = false;

            try
            {
                abort = AutosaveWarning();
                if (abort)
                {
                    return;
                }

                if (exportParameters.usePreExportProcess)
                {
                    Loader.Core.FileHold();
                    preExportProcess.ApplyPreExport();
                }
                await DoExport(singleExportItem);
            }
            catch (Exception ex)
            {
                logger.RaiseError(ex.Message);
            }
            finally
            {
                if (exportParameters.usePreExportProcess && !exportParameters.applyPreprocessToScene)
                {
                    ScriptsUtilities.ExecuteMaxScriptCommand("fetchMaxFile quiet:true");
                }
            }
        }
コード例 #2
0
        private async void butMultiExport_Click(object sender, EventArgs e)
        {
            treeView.Nodes.Clear();
            string outputFileExt = comboOutputFormat.SelectedItem.ToString();

            if (outputFileExt.Contains("binary babylon"))
            {
                outputFileExt = "babylon";
            }

            ExportItemList exportItemList = new ExportItemList(outputFileExt);

            exportItemList.LoadFromData();

            int numLoadedItems = exportItemList.Count;

            if (ModifierKeys == Keys.Shift)
            {
                MultiExportForm form = new MultiExportForm(exportItemList);
                form.ShowDialog(this);
            }
            else if (numLoadedItems > 0)
            {
                exportParameters = GetExportParameters();
                PreExportProcess preExportProcess = new PreExportProcess(exportParameters, logger);
                if (logger != null)
                {
                    preExportProcess.logger = logger;
                }
                bool abort = false;
                try
                {
                    abort = AutosaveWarning();
                    if (abort)
                    {
                        return;
                    }

                    if (exportParameters.usePreExportProcess)
                    {
                        Loader.Core.FileHold();
                        preExportProcess.ApplyPreExport();
                    }
                    await DoExport(exportItemList);
                }
                catch (Exception ex)
                {
                    logger.RaiseError(ex.Message);
                }
                finally
                {
                    if (exportParameters.usePreExportProcess && !exportParameters.applyPreprocessToScene)
                    {
                        ScriptsUtilities.ExecuteMaxScriptCommand("fetchMaxFile quiet:true");
                    }
                }
            }
        }
コード例 #3
0
ファイル: LOContentTest.cs プロジェクト: sillsdev/pathway
        private string GetStyleOutput(string file)
        {
            LOContent contentXML = new LOContent();
            LOStyles  stylesXML  = new LOStyles();
            string    fileOutput = _index > 0 ? file + _index + ".css" : file + ".css";

            //string input = FileInput(file + ".css");
            string input = FileInput(fileOutput);

            _projInfo.DefaultCssFileWithPath = input;
            _projInfo.TempOutputFolder       = _outputPath;

            Dictionary <string, Dictionary <string, string> > cssClass = new Dictionary <string, Dictionary <string, string> >();
            CssTree cssTree = new CssTree();

            cssClass = cssTree.CreateCssProperty(input, true);

            //StyleXML
            string styleOutput = FileOutput(file + _styleFile);
            Dictionary <string, Dictionary <string, string> > idAllClass = stylesXML.CreateStyles(_projInfo, cssClass, styleOutput);

            // ContentXML
            var pageSize = new Dictionary <string, string>();

            pageSize["height"] = cssClass["@page"]["page-height"];
            pageSize["width"]  = cssClass["@page"]["page-width"];
            _projInfo.DefaultXhtmlFileWithPath = FileInput(file + ".xhtml");
            _projInfo.TempOutputFolder         = FileOutput(file);
            _projInfo.HideSpaceVerseNumber     = stylesXML.HideSpaceVerseNumber;

            PreExportProcess preProcessor = new PreExportProcess(_projInfo);

            preProcessor.GetTempFolderPath();
            _projInfo.DefaultXhtmlFileWithPath = preProcessor.ProcessedXhtml;
            if (Param.HyphenEnable)
            {
                preProcessor.IncludeHyphenWordsOnXhtml(_projInfo.DefaultXhtmlFileWithPath);
            }

            AfterBeforeProcess afterBeforeProcess = new AfterBeforeProcess();

            afterBeforeProcess.RemoveAfterBefore(_projInfo, cssClass, cssTree.SpecificityClass, cssTree.CssClassOrder);

            contentXML.CreateStory(_projInfo, idAllClass, cssTree.SpecificityClass, cssTree.CssClassOrder, 325, pageSize);
            _projInfo.TempOutputFolder = _projInfo.TempOutputFolder + _contentFile;
            return(styleOutput);
        }
コード例 #4
0
ファイル: ExportPdfTest.cs プロジェクト: sillsdev/pathway
        public void CSSStyleForHeaderShowInPrincePdfTest()
        {
            _projInfo.ProjectInputType = "Scripture";
            const string file = "CSSStyleForHeaderShowInPrincePdf";

            ExportProcess(file);

            string outputCSSFile = Common.PathCombine(_outputPath, file + ".css");

            File.Copy(_projInfo.DefaultCssFileWithPath, outputCSSFile, true);

            PreExportProcess pdfObj = new PreExportProcess();

            pdfObj.InsertPropertyInCSS(outputCSSFile);

            FileCompare(file, ".css");
        }
コード例 #5
0
ファイル: Preview.cs プロジェクト: sillsdev/pathway
        /// <summary>
        /// Return the name of the preview html name in the link tag.
        /// </summary>
        /// <param name="xhtmlFile">XHTML File</param>
        /// <param name="cssFile">CSS File</param>
        /// <param name="outputFileName">Output File</param>
        /// <returns>Preview FilePath</returns>
        public static string CreatePreviewFile(string xhtmlFile, string cssFile, string outputFileName, bool excerptPreview)
        {
            PublicationInformation projInfo = new PublicationInformation();

            projInfo.DefaultXhtmlFileWithPath = xhtmlFile;
            projInfo.DefaultCssFileWithPath   = cssFile;
            if (!File.Exists(xhtmlFile))
            {
                return(string.Empty);
            }
            const int        stopAtLineNo = 100;
            PreExportProcess preProcessor = new PreExportProcess(projInfo);

            preProcessor.GetTempFolderPath();
            preProcessor.ImagePreprocess(false);
            xhtmlFile = preProcessor.ProcessedXhtml;
            string linkCss     = outputFileName + ".css";
            string previewPath = Path.GetDirectoryName(xhtmlFile);

            if (File.Exists(cssFile))
            {
                File.Copy(cssFile, Common.PathCombine(previewPath, linkCss), true);
            }
            string xhtmlPreviewFilePath = Common.PathCombine(previewPath, outputFileName + ".html");

            if (!excerptPreview)
            {
                Common.SetDefaultCSS(xhtmlPreviewFilePath, linkCss);
                return(xhtmlFile);
            }

            XmlTextReader reader;
            XmlTextWriter writer = new XmlTextWriter(xhtmlPreviewFilePath, null);

            try
            {
                reader = Common.DeclareXmlTextReader(xhtmlFile, true);
                writer.WriteStartDocument();
                int lineCount = 0;
                while (reader.Read())
                {
                    if (reader.IsEmptyElement)
                    {
                        writer.WriteStartElement(reader.Name);
                        string readName = reader.Name;
                        if (reader.HasAttributes)
                        {
                            for (int i = 0; i < reader.AttributeCount; i++)
                            {
                                reader.MoveToAttribute(i);
                                if (string.Compare(readName, "link", true) == 0 && reader.Name == "href")
                                {
                                    writer.WriteAttributeString(reader.Name, linkCss);
                                }
                                else
                                {
                                    writer.WriteAttributeString(reader.Name, reader.Value);
                                }
                            }
                        }
                        writer.WriteEndElement();
                        readName = "";
                        continue;
                    }
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        writer.WriteStartElement(reader.Name);

                        if (reader.HasAttributes)
                        {
                            for (int i = 0; i < reader.AttributeCount; i++)
                            {
                                reader.MoveToAttribute(i);
                                writer.WriteAttributeString(reader.Name, reader.Value);
                            }
                        }
                        break;

                    case XmlNodeType.EndElement:
                        writer.WriteEndElement();
                        break;

                    case XmlNodeType.Text:
                        writer.WriteString(reader.Value);
                        lineCount++;
                        break;
                    }
                    if (lineCount > stopAtLineNo)
                    {
                        break;
                    }
                }
                writer.Flush();
                writer.Close();
                reader.Close();
            }
            catch (XmlException e)
            {
                Console.WriteLine(e.Message);
            }
            return(xhtmlPreviewFilePath);
        }
コード例 #6
0
        /// <summary>
        /// Convert XHTML to ODT
        /// </summary>
        public bool Export(PublicationInformation projInfo)
        {
            PreExportProcess preProcessor = new PreExportProcess(projInfo);

            preProcessor.GetTempFolderPath();
            preProcessor.InsertEmptyHeadwordForReversal(preProcessor.ProcessedXhtml);
            MergeProcessInXHTMLforMasterPage(preProcessor.ProcessedXhtml);
            preProcessor.PreserveSpace();
            preProcessor.ImagePreprocess(true);
            preProcessor.ReplaceInvalidTagtoSpan("_AllComplexFormEntryBackRefs|LexEntryRef_PrimaryLexemes", "span");
            preProcessor.InsertHiddenChapterNumber();
            preProcessor.InsertHiddenVerseNumber();
            preProcessor.GetDefinitionLanguage();
            var    exportTitle = GetExportTitle();
            string fileName    = exportTitle.ToString();

            if (exportTitle.ToString() == string.Empty)
            {
                fileName = Path.GetFileNameWithoutExtension(projInfo.DefaultXhtmlFileWithPath);
            }
            projInfo.DefaultXhtmlFileWithPath = preProcessor.ProcessedXhtml;
            projInfo.DefaultCssFileWithPath   = preProcessor.ProcessedCss;
            projInfo.ProjectPath = Path.GetDirectoryName(preProcessor.ProcessedXhtml);

            Dictionary <string, Dictionary <string, string> > cssClass = new Dictionary <string, Dictionary <string, string> >();
            CssTree cssTree = new CssTree();

            cssClass = cssTree.CreateCssProperty(projInfo.DefaultCssFileWithPath, true);
            cssClass = MergeProcessInCSSforMasterPage(projInfo.DefaultCssFileWithPath, cssClass);
            preProcessor.InsertEmptyXHomographNumber(cssClass);

            //To insert the variable for macro use
            InInsertMacro insertMacro = new InInsertMacro();

            insertMacro.InsertMacroVariable(projInfo, cssClass);

            Dictionary <string, Dictionary <string, string> > idAllClass = new Dictionary <string, Dictionary <string, string> >();
            InStyles inStyles = new InStyles();

            idAllClass = inStyles.CreateIDStyles(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), cssClass);

            InGraphic inGraphic = new InGraphic();

            inGraphic.CreateIDGraphic(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), cssClass, cssTree.cssBorderColor);

            InStory inStory = new InStory();
            Dictionary <string, ArrayList> StyleName = inStory.CreateStory(projInfo, idAllClass, cssTree.SpecificityClass, cssTree.CssClassOrder);

            InMasterSpread inMasterSpread  = new InMasterSpread();
            ArrayList      masterPageNames = inMasterSpread.CreateIDMasterSpread(Common.PathCombine(projInfo.TempOutputFolder, "MasterSpreads"), idAllClass, StyleName["TextVariables"]);

            InSpread inSpread = new InSpread();

            inSpread.CreateIDSpread(Common.PathCombine(projInfo.TempOutputFolder, "Spreads"), idAllClass, StyleName["ColumnClass"]);

            InDesignMap inDesignMap = new InDesignMap();

            inDesignMap.CreateIDDesignMap(projInfo.TempOutputFolder, StyleName["ColumnClass"].Count, masterPageNames, StyleName["TextVariables"], StyleName["CrossRef"], projInfo.ProjectInputType);

            InMetaData inMetaData = new InMetaData();

            inMetaData.SetDateTimeinMetaDataXML(projInfo.TempOutputFolder);

            InPreferences inPreferences = new InPreferences();

            inPreferences.CreateIDPreferences(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), idAllClass);

            SubProcess.AfterProcess(projInfo.ProjectFileWithPath);
            fileName = Common.ReplaceSymbolToUnderline(fileName);
            string ldmlFullName = Common.PathCombine(projInfo.DictionaryPath, fileName + ".idml");

            Compress(projInfo.TempOutputFolder, ldmlFullName);

            Common.CleanupExportFolder(ldmlFullName, ".tmp,.de", "layout.css", String.Empty);

            CreateRAMP(projInfo);

            Common.CleanupExportFolder(ldmlFullName, ".css,.xhtml,.xml", String.Empty, String.Empty);

            if (projInfo.IsOpenOutput)
            {
                Launch(ldmlFullName);
            }


            return(true);
        }
コード例 #7
0
ファイル: ExportPdf.cs プロジェクト: sillsdev/pathway
        public bool Export(PublicationInformation projInfo)
        {
            bool success;
            bool isUnixOS = Common.UnixVersionCheck();
            //try
            //{
            var regPrinceKey = RegPrinceKey;

            if (regPrinceKey != null || isUnixOS)
            {
                var curdir = Environment.CurrentDirectory;
                projInfo.OutputExtension = "pdf";
                _pdfSymbols.Load(XmlReader.Create(Common.UsersXsl("PdfSymbols.xsl")));
                PreExportProcess preProcessor = new PreExportProcess(projInfo);
                if (isUnixOS)
                {
                    projInfo.DefaultXhtmlFileWithPath =
                        Common.RemoveDTDForLinuxProcess(projInfo.DefaultXhtmlFileWithPath, "pdfconvert");
                }
                Environment.CurrentDirectory = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath);

                preProcessor.IncludeHyphenWordsOnXhtml(preProcessor.ProcessedXhtml);
                preProcessor.GetTempFolderPath();
                preProcessor.ImagePreprocess(false, delegate(string s, string to) { ImageMods.ResizeImage(s, to, 1, 1); });
                preProcessor.ReplaceSlashToREVERSE_SOLIDUS();
                if (projInfo.SwapHeadword)
                {
                    preProcessor.SwapHeadWordAndReversalForm();
                }
                preProcessor.MovePictureAsLastChild(preProcessor.ProcessedXhtml);
                preProcessor.SetNonBreakInVerseNumber(preProcessor.ProcessedXhtml);
                preProcessor.ReplaceProcessForPrinceOutput(preProcessor.ProcessedXhtml);
                Common.ApplyXsltArgs = new XsltArgumentList();
                Common.ApplyXsltArgs.AddParam("avPath", string.Empty, new Uri(projInfo.ProjectPath).AbsoluteUri);
                Common.ApplyXslt(preProcessor.ProcessedXhtml, _pdfSymbols);
                Common.ApplyXsltArgs = null;
                RenameAudioVisual(projInfo.ProjectPath, Path.GetDirectoryName(preProcessor.ProcessedXhtml));

                preProcessor.MoveCallerToPrevText(preProcessor.ProcessedXhtml);
                string tempFolder = Path.GetDirectoryName(preProcessor.ProcessedXhtml);
                var    mc         = new MergeCss {
                    OutputLocation = tempFolder
                };

                if (projInfo.IsReversalExist && File.Exists(projInfo.DefaultRevCssFileWithPath))
                {
                    Common.CopyContent(projInfo.DefaultCssFileWithPath, projInfo.DefaultRevCssFileWithPath);
                }

                string mergedCSS = mc.Make(projInfo.DefaultCssFileWithPath, "Temp1.css");
                preProcessor.ReplaceStringInCss(mergedCSS);
                preProcessor.InsertPropertyInCSS(mergedCSS);
                preProcessor.RemoveDeclaration(mergedCSS, ".pictureRight > .picture");
                preProcessor.RemoveDeclaration(mergedCSS, "div.pictureLeft > img.picture");
                preProcessor.HandleNewFieldworksChangeInCss(mergedCSS);
                mergedCSS = preProcessor.RemoveTextIndent(mergedCSS);

                if (isUnixOS)
                {
                    Common.StreamReplaceInFile(mergedCSS, "Scheherazade Graphite Alpha", "Scheherazade");
                }

                Dictionary <string, Dictionary <string, string> > cssClass = new Dictionary <string, Dictionary <string, string> >();
                CssTree cssTree = new CssTree();
                cssTree.OutputType = Common.OutputType.PDF;
                cssClass           = cssTree.CreateCssProperty(mergedCSS, true);
                if (cssClass.ContainsKey("@page") && cssClass["@page"].ContainsKey("-ps-hide-versenumber-one"))
                {
                    string value = cssClass["@page"]["-ps-hide-versenumber-one"];
                    if (value.ToLower() == "true")
                    {
                        preProcessor.RemoveVerseNumberOne(preProcessor.ProcessedXhtml, mergedCSS);
                    }
                }
                if (cssClass.ContainsKey("@page:left-top-left") && cssClass["@page:left-top-left"].ContainsKey("-ps-referenceformat"))
                {
                    string value = cssClass["@page:left-top-left"]["-ps-referenceformat"];
                    if (value.ToLower().Contains("gen 1"))
                    {
                        ReplaceBookNametoBookCode(preProcessor.ProcessedXhtml);
                    }
                }

                string xhtmlFileName = Path.GetFileNameWithoutExtension(projInfo.DefaultXhtmlFileWithPath);
                string defaultCSS    = Path.GetFileName(mergedCSS);
                Common.SetDefaultCSS(preProcessor.ProcessedXhtml, defaultCSS);

                _processedXhtml = preProcessor.ProcessedXhtml;
                if (projInfo.IsReversalExist && projInfo.IsLexiconSectionExist)
                {
                    var reversalFile = Path.GetDirectoryName(_processedXhtml);
                    reversalFile = Common.PathCombine(reversalFile, "FlexRev.xhtml");
                    Common.SetDefaultCSS(reversalFile, defaultCSS);
                }

                if (!ExportPrince(projInfo, xhtmlFileName, isUnixOS, regPrinceKey, defaultCSS))
                {
                    return(false);
                }

                Environment.CurrentDirectory = curdir;
                if (!projInfo.DefaultXhtmlFileWithPath.ToLower().Contains("local"))
                {
                    //Copyright information added in PDF files
                        #pragma warning disable 168
                    Common.InsertCopyrightInPdf(Common.PathCombine(Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath), xhtmlFileName + ".pdf"), "Prince XML", projInfo.ProjectInputType);
                        #pragma warning restore 168
                }
                else
                {
                    string pdfFileName = xhtmlFileName + ".pdf";
                    pdfFileName = Common.PathCombine(Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath), pdfFileName);

                    if (!Common.Testing && File.Exists(pdfFileName))
                    {
                        // ReSharper disable RedundantAssignment
                        success = true;
                        // ReSharper restore RedundantAssignment
                        Process.Start(pdfFileName);
                    }
                }
                success = true;
            }
            else
            {
                success = false || Common.Testing;
            }
            //}
            //catch (Exception)
            //{
            //    success = false;
            //}
            return(success);
        }