示例#1
0
        private void ExportProcess(string file)
        {
            string input = FileInput(file + ".xhtml");
            _projInfo.DefaultXhtmlFileWithPath = input;
            _langFontCodeandName = new Dictionary<string, string>();
            GetXhtmlFileFontCodeandFontName(_projInfo.DefaultXhtmlFileWithPath);
            input = FileInput(file + ".css");
            _projInfo.DefaultCssFileWithPath = input;

            _projInfo.TempOutputFolder = _outputPath;
            _projInfo.OutputExtension = ".tex";

            Dictionary<string, Dictionary<string, string>> cssClass = new Dictionary<string, Dictionary<string, string>>();
            CssTree cssTree = new CssTree();
            cssTree.OutputType = Common.OutputType.XELATEX;
            cssClass = cssTree.CreateCssProperty(input, true);
            int pageWidth = Common.GetPictureWidth(cssClass, _projInfo.ProjectInputType);

            string xetexFullFile = Common.PathCombine(_outputPath, file + ".tex");
            StreamWriter xetexFile = new StreamWriter(xetexFullFile);

            XeLaTexStyles styles = new XeLaTexStyles();
            _classInlineStyle = styles.CreateXeTexStyles(_projInfo, xetexFile, cssClass);

            XeLaTexContent content = new XeLaTexContent();
            Dictionary<string, List<string>> classInlineText = styles._classInlineText;
            Dictionary<string, Dictionary<string, string>> newProperty = content.CreateContent(_projInfo, cssClass, xetexFile, _classInlineStyle, cssTree.SpecificityClass, cssTree.CssClassOrder, classInlineText, pageWidth);

            CloseFile(xetexFile);

            ModifyXeLaTexStyles modifyXeTexStyles = new ModifyXeLaTexStyles();
            modifyXeTexStyles.ModifyStylesXML(_projInfo.ProjectPath, xetexFile, newProperty, cssClass, xetexFullFile, string.Empty, _langFontCodeandName,true);

        }
        public bool ExportCopyright(PublicationInformation projInfo, string mainXhtmlFileWithPath)
        {
            if (_copyrightInformation)
            {
                var preProcess = new PreExportProcess(projInfo);
                var processFolder = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath);
                preProcess.CopyCopyrightPage(processFolder);
                string copyRightFilePath = Common.PathCombine(processFolder, "File2Cpy.xhtml");

                if (copyRightFilePath.Trim().Length <= 0 && !File.Exists(copyRightFilePath))
                {
                    return false;
                }
                if (File.Exists(copyRightFilePath))
                {
                    if (Common.UnixVersionCheck())
                    {
                        string draftTempFileName = Path.GetFileName(copyRightFilePath);
                        draftTempFileName = Common.PathCombine(Path.GetTempPath(), draftTempFileName);
                        if (!File.Exists(draftTempFileName))
                        {
                            File.Copy(copyRightFilePath, draftTempFileName, true);
                            Common.RemoveDTDForLinuxProcess(draftTempFileName, "xelatex");
                        }
                        projInfo.DefaultXhtmlFileWithPath = draftTempFileName;
                        copyRightFilePath = draftTempFileName;
                    }
                    else
                    {
                        projInfo.DefaultXhtmlFileWithPath = copyRightFilePath;
                    }
                }
                else
                {
                    return false;
                }

                string filepath = Path.GetFullPath(copyRightFilePath);

                Dictionary<string, Dictionary<string, string>> cssClass =
                    new Dictionary<string, Dictionary<string, string>>();
                CssTree cssTree = new CssTree();
                cssTree.OutputType = Common.OutputType.XELATEX;
                cssClass = cssTree.CreateCssProperty(Common.PathCombine(filepath, "copy.css"), true);
                string fileNameXhtml = Path.GetFileNameWithoutExtension(copyRightFilePath);
                string xeLatexCopyrightFile = Common.PathCombine(projInfo.ProjectPath, fileNameXhtml + ".tex");
                _copyrightTexFileName = xeLatexCopyrightFile;
                int pageWidth = Common.GetPictureWidth(cssClass, projInfo.ProjectInputType);

                StreamWriter xeLatexFile = new StreamWriter(xeLatexCopyrightFile);
                Dictionary<string, List<string>> classInlineStyle = new Dictionary<string, List<string>>();
                XeLaTexStyles xeLaTexStyles = new XeLaTexStyles();
                xeLaTexStyles.LangFontDictionary = _langFontCodeandName;
                classInlineStyle = xeLaTexStyles.CreateXeTexStyles(projInfo, xeLatexFile, cssClass);

                XeLaTexContent xeLaTexContent = new XeLaTexContent();
                xeLaTexContent.IsUnix = _isUnixOs;
                Dictionary<string, List<string>> classInlineText = xeLaTexStyles._classInlineText;
                xeLaTexContent.CreateContent(projInfo, cssClass, xeLatexFile, classInlineStyle, cssTree.SpecificityClass, cssTree.CssClassOrder, classInlineText, pageWidth);

                _xelatexDocumentOpenClosedRequired = true; //Don't change the place.
                CloseDocument(xeLatexFile, false, string.Empty);
                ModifyXeLaTexStyles modifyXeLaTexStyles = new ModifyXeLaTexStyles();
                modifyXeLaTexStyles.XelatexDocumentOpenClosedRequired = true;
                modifyXeLaTexStyles.ProjectType = projInfo.ProjectInputType;

                string copyright = GetLanguageInfo(mainXhtmlFileWithPath, projInfo);
                InsertInFile(xeLatexCopyrightFile, "copyright information", copyright);

                return true;
            }
            return false;
        }
        public bool ExportReversalIndex(PublicationInformation projInfo)
        {

            if (projInfo.IsReversalExist)
            {
                var revFile = Common.PathCombine(projInfo.ProjectPath, "FlexRev.xhtml");
                if (!File.Exists(revFile))
                {
                    return false;
                }

                if (File.Exists(revFile))
                {
                    if (Common.UnixVersionCheck())
                    {
                        Common.RemoveDTDForLinuxProcess(revFile, "xelatex");
                    }
                }

                projInfo.DefaultXhtmlFileWithPath = revFile;
                PreExportProcess preProcessor = new PreExportProcess(projInfo);
                preProcessor.SetLangforLetter(projInfo.DefaultXhtmlFileWithPath);

                CheckFontFamilyAvailable(projInfo.DefaultRevCssFileWithPath);

                Dictionary<string, Dictionary<string, string>> cssClass =
                    new Dictionary<string, Dictionary<string, string>>();
                CssTree cssTree = new CssTree();
                cssTree.OutputType = Common.OutputType.XELATEX;
                cssClass = cssTree.CreateCssProperty(projInfo.DefaultRevCssFileWithPath, true);
                string fileNameXhtml = Path.GetFileNameWithoutExtension(revFile);
                string xeLatexRevesalIndexFile = Common.PathCombine(projInfo.ProjectPath, fileNameXhtml + ".tex");
                _reversalIndexTexFileName = xeLatexRevesalIndexFile;
                StreamWriter xeLatexFile = new StreamWriter(xeLatexRevesalIndexFile);
                Dictionary<string, List<string>> classInlineStyle = new Dictionary<string, List<string>>();
                XeLaTexStyles xeLaTexStyles = new XeLaTexStyles();
                xeLaTexStyles.LangFontDictionary = _langFontCodeandName;
                classInlineStyle = xeLaTexStyles.CreateXeTexStyles(projInfo, xeLatexFile, cssClass);
                int pageWidth = Common.GetPictureWidth(cssClass, projInfo.ProjectInputType);

                XeLaTexContent xeLaTexContent = new XeLaTexContent();
                xeLaTexContent.IsUnix = _isUnixOs;
                Dictionary<string, List<string>> classInlineText = xeLaTexStyles._classInlineText;
                Dictionary<string, Dictionary<string, string>> newProperty = xeLaTexContent.CreateContent(projInfo,
                                                                                                          cssClass,
                                                                                                          xeLatexFile,
                                                                                                          classInlineStyle,
                                                                                                          cssTree
                                                                                                              .SpecificityClass,
                                                                                                          cssTree
                                                                                                              .CssClassOrder,
                                                                                                          classInlineText,
                                                                                                          pageWidth);

                _xelatexDocumentOpenClosedRequired = true; //Don't change the place.
                CloseDocument(xeLatexFile, false, string.Empty);
                string include = xeLaTexStyles.PageStyle.ToString();
                ModifyXeLaTexStyles modifyXeLaTexStyles = new ModifyXeLaTexStyles();
                modifyXeLaTexStyles.XelatexDocumentOpenClosedRequired = true;
                modifyXeLaTexStyles.ProjectType = projInfo.ProjectInputType;
	            bool createPageNumber = false;
	            if (projInfo.DefaultXhtmlFileWithPath.IndexOf("PreserveFlexRev.xhtml") > 0)
		            createPageNumber = true;

                modifyXeLaTexStyles.ModifyStylesXML(projInfo.ProjectPath, xeLatexFile, newProperty, cssClass,
													xeLatexRevesalIndexFile, include, _langFontCodeandName, createPageNumber);
                _xeLaTexPropertyFullFontStyleList = modifyXeLaTexStyles.XeLaTexPropertyFontStyleList;

                if (newProperty.ContainsKey("TableofContent") && newProperty["TableofContent"].Count > 0)
                {
                    foreach (var tocSection in newProperty["TableofContent"])
                    {
                        if (tocSection.Key.Contains("PageStock"))
                        {
                            _tocPropertyList.Add(tocSection.Key, tocSection.Value);
                        }
                    }
                }
                return true;
            }
            return false;
        }
        private Dictionary<string, Dictionary<string, string>> WrittingTexFile(PublicationInformation projInfo, string fileName, out string xeLatexFullFile,
                                           out StreamWriter xeLatexFile, out XeLaTexStyles xeLaTexStyles,
                                           out Dictionary<string, Dictionary<string, string>> newProperty)
        {
            CheckFontFamilyAvailable(projInfo.DefaultCssFileWithPath);

            Dictionary<string, Dictionary<string, string>> cssClass = new Dictionary<string, Dictionary<string, string>>();
            CssTree cssTree = new CssTree();
            cssTree.OutputType = Common.OutputType.XELATEX;
            cssClass = cssTree.CreateCssProperty(projInfo.DefaultCssFileWithPath, true);
            int pageWidth = Common.GetPictureWidth(cssClass, projInfo.ProjectInputType);

            xeLatexFullFile = Common.PathCombine(projInfo.ProjectPath, fileName + ".tex");
            xeLatexFile = new StreamWriter(xeLatexFullFile);

            Dictionary<string, List<string>> classInlineStyle = new Dictionary<string, List<string>>();
            xeLaTexStyles = new XeLaTexStyles();
            xeLaTexStyles.LangFontDictionary = _langFontCodeandName;
            classInlineStyle = xeLaTexStyles.CreateXeTexStyles(projInfo, xeLatexFile, cssClass);

            XeLaTexContent xeLaTexContent = new XeLaTexContent();
            xeLaTexContent.IsUnix = _isUnixOs;
            Dictionary<string, List<string>> classInlineText = xeLaTexStyles._classInlineText;
            newProperty = xeLaTexContent.CreateContent(projInfo, cssClass, xeLatexFile, classInlineStyle,
                                                       cssTree.SpecificityClass, cssTree.CssClassOrder, classInlineText,
                                                       pageWidth);

            if (projInfo.IsReversalExist)
            {
                var revFile = Common.PathCombine(Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath), "FlexRev.xhtml");
                string fileNameXhtml = Path.GetFileNameWithoutExtension(revFile);
                string reversalFileName = fileNameXhtml + ".tex";

                CloseDocument(xeLatexFile, true, reversalFileName);
            }
            else
            {
                CloseDocument(xeLatexFile, false, string.Empty);
            }
            return cssClass;
        }