/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the settings from a byte array or gets the settings into a byte array. /// </summary> /// ------------------------------------------------------------------------------------ private byte[] GetParatextSettingsArray(ArrayList vernMappingList, ArrayList backMappingList, ArrayList notesMappingList, string vernProj, string backProj, string notesProj) { BinarySettings blob = new BinarySettings("PTProject"); // Mapping set count (3 sets for vern, back, and notes) blob.AddInt(3); // We store the mappings in three different parts of the blob because the source P6 project // often determines the domain. It's possible for users to use the same markers in different // projects to mean different things. The domain + the marker serve as the "key". OutputMappings(blob, true, vernMappingList); OutputMappings(blob, true, backMappingList); OutputMappings(blob, true, notesMappingList); blob.AddString(vernProj); blob.AddString(backProj); blob.AddString(notesProj); return blob.Finalize(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Output a list of mappings to the blob /// </summary> /// <param name="blob">The settings blob</param> /// <param name="fParatext">true if this is for Paratext</param> /// <param name="mappings">A collection of mappings that belong together in the blob (there /// are three such globs in a well-formed blob)</param> /// ------------------------------------------------------------------------------------ private void OutputMappings(BinarySettings blob, bool fParatext, ArrayList mappings) { if (mappings == null) { blob.AddInt(0); return; } blob.AddInt(mappings.Count); foreach (MappingInfo mapping in mappings) { blob.AddString(mapping.beginMarker); blob.AddString(mapping.endMarker); blob.AddIntShort(mapping.isInline ? 1 : 0); // inline blob.AddString(string.Empty); // marker encoding blob.AddString(mapping.dataEncoding); blob.AddIntShort((int)mapping.domain); blob.AddString(mapping.styleName); blob.AddString(mapping.ws); // writing system blob.AddIntShort(1); // confirmed // Looks like we accidentally got these two parameters in opposite order for // Paratext and ECProject - ugh! if (fParatext) { blob.AddIntShort((int)mapping.mappingTarget); blob.AddIntShort(mapping.isExcluded ? 1 : 0); } else { blob.AddIntShort(mapping.isExcluded ? 1 : 0); blob.AddIntShort((int)mapping.mappingTarget); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Return a binary blob representing "ECProject" values /// </summary> /// <returns>a byte array containing the settings</returns> /// ------------------------------------------------------------------------------------ private byte[] GetEcProjectSettingsArray(ArrayList mappingList, ArrayList fileList) { BinarySettings blob = new BinarySettings("ECProject"); // stuff at the start of the file blob.AddString(@"\id"); blob.AddString(string.Empty); // data encoding blob.AddString(string.Empty); // marker encoding blob.AddString(string.Empty); // binary directory blob.AddString(string.Empty); // SSF file name blob.AddString(string.Empty); // STY file name // Marker mappings OutputMappings(blob, false, mappingList); // file list blob.AddInt(fileList.Count); foreach (string fileName in fileList) { blob.AddString(fileName); blob.AddIntShort(1); // file encoding (dummy value) blob.AddIntShort(1); // file encoding source (dummy value) blob.AddIntShort(100); // percent certain } return blob.Finalize(); }