public void MultiLangHeader3() { _inputXHTML = Common.DirectoryPathReplace(_testFolderPath + "/input/MultiLangHeader3.xhtml"); _inputCSS = Common.DirectoryPathReplace(_testFolderPath + "/input/MultiLangHeader3.css"); PublicationInformation projInfo = new PublicationInformation(); projInfo.ProjectPath = Path.GetDirectoryName(_inputXHTML); projInfo.DefaultXhtmlFileWithPath = _inputXHTML; projInfo.DefaultCssFileWithPath = _inputCSS; PreExportProcess preProcessor = new PreExportProcess(projInfo); preProcessor.GetTempFolderPath(); preProcessor.ImagePreprocess(false); preProcessor.ReplaceInvalidTagtoSpan("_AllComplexFormEntryBackRefs|LexEntryRef_PrimaryLexemes", "span"); preProcessor.InsertHiddenChapterNumber(); preProcessor.InsertHiddenVerseNumber(); preProcessor.GetDefinitionLanguage(); projInfo.DefaultXhtmlFileWithPath = preProcessor.ProcessedXhtml; projInfo.DefaultCssFileWithPath = preProcessor.ProcessedCss; Dictionary<string, Dictionary<string, string>> cssClass = new Dictionary<string, Dictionary<string, string>>(); CssTree cssTree = new CssTree(); cssClass = cssTree.CreateCssProperty(projInfo.DefaultCssFileWithPath, true); preProcessor.InsertEmptyXHomographNumber(cssClass); Dictionary<string, Dictionary<string, string>> idAllClass = new Dictionary<string, Dictionary<string, string>>(); InStyles inStyles = new InStyles(); projInfo.TempOutputFolder = _outputPath; idAllClass = inStyles.CreateIDStyles(Common.PathCombine(_outputPath, "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"], string.Empty); InPreferences inPreferences = new InPreferences(); inPreferences.CreateIDPreferences(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), idAllClass); string classname = "dTextVariablenFirst1"; string output = Common.PathCombine(projInfo.TempOutputFolder, "designmap.xml"); string xPath = "//TextVariable[@Self = \"" + classname + "\"]"; XmlNode node = Common.GetXmlNodeInDesignNamespace(output, xPath); string result = node.InnerXml; string expected = "<MatchCharacterStylePreference TextBefore=\"\" TextAfter=\"\" AppliedCharacterStyle=\"CharacterStyle/headword\" SearchStrategy=\"FirstOnPage\" ChangeCase=\"None\" DeleteEndPunctuation=\"false\" />"; Assert.AreEqual(expected, result, "MultiLangHeader1 test failed"); classname = "dTextVariablenLast1"; output = Common.PathCombine(projInfo.TempOutputFolder, "designmap.xml"); xPath = "//TextVariable[@Self = \"" + classname + "\"]"; node = Common.GetXmlNodeInDesignNamespace(output, xPath); result = node.InnerXml; expected = "<MatchCharacterStylePreference TextBefore=\"\" TextAfter=\"\" AppliedCharacterStyle=\"CharacterStyle/headword\" SearchStrategy=\"LastOnPage\" ChangeCase=\"None\" DeleteEndPunctuation=\"false\" />"; Assert.AreEqual(expected, result, "MultiLangHeader1 test failed"); }
/// <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); }
/// <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; }
public void FileComparisionTest(string fileName, string fileNo) { PublicationInformation projInfo = new PublicationInformation(); projInfo.ProjectPath = Path.GetDirectoryName(_inputXHTML); projInfo.DefaultXhtmlFileWithPath = _inputXHTML; projInfo.DefaultCssFileWithPath = _inputCSS; projInfo.ProjectInputType = "Scripture"; PreExportProcess preProcessor = new PreExportProcess(projInfo); preProcessor.GetTempFolderPath(); preProcessor.ImagePreprocess(false); preProcessor.InsertHiddenChapterNumber(); preProcessor.InsertHiddenVerseNumber(); projInfo.DefaultXhtmlFileWithPath = preProcessor.ProcessedXhtml; projInfo.DefaultCssFileWithPath = preProcessor.ProcessedCss; Dictionary<string, Dictionary<string, string>> cssClass = new Dictionary<string, Dictionary<string, string>>(); CssTree cssTree = new CssTree(); cssClass = cssTree.CreateCssProperty(projInfo.DefaultCssFileWithPath, true); preProcessor.InsertEmptyXHomographNumber(cssClass); Dictionary<string, Dictionary<string, string>> idAllClass = new Dictionary<string, Dictionary<string, string>>(); InStyles inStyles = new InStyles(); projInfo.TempOutputFolder = _outputPath; idAllClass = inStyles.CreateIDStyles(Common.PathCombine(_outputPath, "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, headwordStyles); 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"], string.Empty); InPreferences inPreferences = new InPreferences(); inPreferences.CreateIDPreferences(Common.PathCombine(projInfo.TempOutputFolder, "Resources"), idAllClass); // Compare files string expectedFolder = Common.PathCombine(_testFolderPath, "Expected\\" + fileName); string output = Common.PathCombine(projInfo.TempOutputFolder, "Stories\\Story_" + fileNo + ".xml"); string expected = Common.PathCombine(expectedFolder, "Stories\\Story_" + fileNo + ".xml"); XmlAssert.AreEqual(output, expected, " Story_"+ fileNo + ".xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "Resources\\styles.xml"); expected = Common.PathCombine(expectedFolder, "Resources\\styles.xml"); XmlAssert.AreEqual(output, expected, " styles.xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "Resources\\Graphic.xml"); expected = Common.PathCombine(expectedFolder, "Resources\\Graphic.xml"); XmlAssert.AreEqual(output, expected, " Graphic.xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "Resources\\Preferences.xml"); expected = Common.PathCombine(expectedFolder, "Resources\\Preferences.xml"); XmlAssert.AreEqual(output, expected, " Preferences.xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "Spreads\\Spread_1.xml"); expected = Common.PathCombine(expectedFolder, "Spreads\\Spread_1.xml"); XmlAssert.AreEqual(output, expected, " Spread_1.xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "Spreads\\Spread_2.xml"); expected = Common.PathCombine(expectedFolder, "Spreads\\Spread_2.xml"); XmlAssert.AreEqual(output, expected, " Spread_2.xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "Spreads\\Spread_3.xml"); expected = Common.PathCombine(expectedFolder, "Spreads\\Spread_3.xml"); XmlAssert.AreEqual(output, expected, " Spread_3.xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "MasterSpreads\\MasterSpread_All.xml"); expected = Common.PathCombine(expectedFolder, "MasterSpreads\\MasterSpread_All.xml"); XmlAssert.AreEqual(output, expected, " MasterSpread_All.xml is not matching"); output = Common.PathCombine(projInfo.TempOutputFolder, "MasterSpreads\\MasterSpread_First.xml"); expected = Common.PathCombine(expectedFolder, "MasterSpreads\\MasterSpread_First.xml"); XmlAssert.AreEqual(output, expected, " MasterSpread_First.xml is not matching"); }
public void ColumnGapEm() { ClearFiles(); _spreadXML = new InSpread(); _inputXHTML = Common.DirectoryPathReplace(_testFolderPath + "/input/ColumnGap2.xhtml"); _inputCSS = Common.DirectoryPathReplace(_testFolderPath + "/input/ColumnGap2.css"); _cssProperty = _cssTree.CreateCssProperty(_inputCSS, true); _idAllClass = _stylesXML.CreateIDStyles(_outputStyles, _cssProperty); projInfo.DefaultXhtmlFileWithPath = _inputXHTML; Dictionary<string, ArrayList> stylename = _storyXML.CreateStory(projInfo, _idAllClass, _cssTree.SpecificityClass, _cssTree.CssClassOrder); _spreadXML.CreateIDSpread(_outputSpread, _idAllClass, stylename["ColumnClass"]); _xPath = "//TextFrame[@Self=\"TF2\"]/TextFramePreference"; _fileNameWithPath = Common.PathCombine(_outputSpread, "Spread_1.xml"); nodesList = Common.GetXmlNodeListInDesignNamespace(_fileNameWithPath, _xPath); XmlNode node = nodesList[0]; XmlAttributeCollection attrb = node.Attributes; string result = attrb["TextColumnGutter"].Value; Assert.AreEqual(result, "15", _methodName); }
public void SpreadListTest1() { ClearFiles(); _spreadXML = new InSpread(); _methodName = "SpreadListTest1"; _cssProperty = _cssTree.CreateCssProperty(_inputCSS1, true); _idAllClass = _stylesXML.CreateIDStyles(_outputStyles, _cssProperty); _spreadXML.CreateIDSpread(_outputSpread, _idAllClass, _columnClass); for (int i = 0; i < _facingPages.Count; i++) { string fileWithPath = Common.PathCombine(_outputSpread, _facingPages[i].ToString()); bool result = File.Exists(fileWithPath); Assert.IsTrue(result, fileWithPath + " is missing"); } }
public void PathPointTypeTest2() { ClearFiles(); _spreadXML = new InSpread(); _methodName = "PathPointTypeTest2"; _cssProperty = _cssTree.CreateCssProperty(_inputCSS2, true); _idAllClass = _stylesXML.CreateIDStyles(_outputStyles, _cssProperty); _spreadXML.CreateIDSpread(_outputSpread, _idAllClass, _columnClass); _xPath = "//TextFrame[@Self=\"TF2\"]/Properties/PathGeometry/GeometryPathType/PathPointArray/PathPointType"; _fileNameWithPath = Common.PathCombine(_outputSpread, "Spread_1.xml"); nodesList = Common.GetXmlNodeListInDesignNamespace(_fileNameWithPath, _xPath); XmlNode node = nodesList[0]; XmlAttributeCollection attrb = node.Attributes; string result = attrb["Anchor"].Value; // "-198 -324" Assert.AreEqual(result, "-270 -360", _methodName + " failed for Anchor"); result = attrb["LeftDirection"].Value; Assert.AreEqual(result, "-270 -360", _methodName + " failed for LeftDirection"); result = attrb["RightDirection"].Value; Assert.AreEqual(result, "-270 -360", _methodName + " failed for RightDirection"); }
public void PathPointTypeTest1() { ClearFiles(); _spreadXML = new InSpread(); _methodName = "PathPointTypeTest1"; _cssProperty = _cssTree.CreateCssProperty(_inputCSS2, true); _idAllClass = _stylesXML.CreateIDStyles(_outputStyles, _cssProperty); _spreadXML.CreateIDSpread(_outputSpread, _idAllClass, _columnClass); _xPath = "//TextFrame[@Self=\"TF2\"]/Properties/PathGeometry/GeometryPathType/PathPointArray/PathPointType"; _fileNameWithPath = Common.PathCombine(_outputSpread, "Spread_1.xml"); nodesList = Common.GetXmlNodeListInDesignNamespace(_fileNameWithPath, _xPath); Assert.IsTrue(nodesList.Count == 4, _methodName + " failed"); }
public void PageCountTest() { ClearFiles(); _spreadXML = new InSpread(); _methodName = "PageCountTest"; _cssProperty = _cssTree.CreateCssProperty(_inputCSS2, true); _idAllClass = _stylesXML.CreateIDStyles(_outputStyles, _cssProperty); _spreadXML.CreateIDSpread(_outputSpread, _idAllClass, _columnClass); _xPath = "//Page"; _fileNameWithPath = Common.PathCombine(_outputSpread, "Spread_2.xml"); nodesList = Common.GetXmlNodeListInDesignNamespace(_fileNameWithPath, _xPath); Assert.IsTrue(nodesList.Count == 2, _methodName + " failed"); }
public void MarginPreferenceTest() { ClearFiles(); _spreadXML = new InSpread(); _methodName = "MarginPreferenceTest"; _cssProperty = _cssTree.CreateCssProperty(_inputCSS2, true); _idAllClass = _stylesXML.CreateIDStyles(_outputStyles, _cssProperty); _spreadXML.CreateIDSpread(_outputSpread, _idAllClass, _columnClass); _xPath = "//MarginPreference"; _fileNameWithPath = Common.PathCombine(_outputSpread, "Spread_2.xml"); XmlNode node = Common.GetXmlNodeInDesignNamespace(_fileNameWithPath, _xPath); XmlAttributeCollection attrb = node.Attributes; string result = attrb["Top"].Value; Assert.AreEqual(result, "71", _methodName + " failed for Margin_Top"); result = attrb["Right"].Value; Assert.AreEqual(result, "72", _methodName + " failed for Margin_Top"); result = attrb["Bottom"].Value; Assert.AreEqual(result, "108", _methodName + " failed for Margin_Top"); result = attrb["Left"].Value; Assert.AreEqual(result, "144", _methodName + " failed for Margin_Top"); }
public void TextFrameNameTest() { ClearFiles(); _spreadXML = new InSpread(); _methodName = "TextFrameNameTest"; _cssProperty = _cssTree.CreateCssProperty(_inputCSS1, true); _idAllClass = _stylesXML.CreateIDStyles(_outputStyles, _cssProperty); _spreadXML.CreateIDSpread(_outputSpread, _idAllClass, _columnClass); _xPath = "//TextFrame"; _fileNameWithPath = Common.PathCombine(_outputSpread, "Spread_1.xml"); XmlNode node = Common.GetXmlNodeInDesignNamespace(_fileNameWithPath, _xPath); XmlAttributeCollection attrb = node.Attributes; string result = attrb["Self"].Value; Assert.AreEqual(result, "TF1", _methodName + " failed"); }