public TextBlockBuilder(ushort wTextBlockId, Serializer.CharacterMapper charMapper) { m_wTextBlockId = wTextBlockId; m_CharMapper = charMapper; Debug.Assert(wTextBlockId >= 32); AddBeginPage(); }
public bool SaveDocument(BindingParams bindingParameters, TocEntry tocEntries, BBeBLib.Serializer.CharacterMapper charMapper, HtmlDocument document) { bool ret = false; string filename = bindingParameters.MetaData.BookInfo.Author + " - " + bindingParameters.MetaData.BookInfo.Title; SaveFileDialog dialog = new SaveFileDialog(); dialog.FileName = filename; dialog.Filter = "BBeB/LRF Files (*.lrf)|*.lrf"; if (dialog.ShowDialog() == DialogResult.OK) { Host.Status("Converting...."); Application.DoEvents(); HTMLToBbebTransform transformer = new HTMLToBbebTransform(charMapper); BBeB book = transformer.ParseHTML(document, bindingParameters, tocEntries); Host.Status("Saving...."); Application.DoEvents(); // Save book now File.Delete(dialog.FileName); BBeBLib.Serializer.BBeBSerializer serializer = new BBeBLib.Serializer.BBeBSerializer(); FileStream newLrfStream = File.OpenWrite(dialog.FileName); try { serializer.Serialize(newLrfStream, book); } catch (Exception ex) { // TODO Need to get these strings from a resource for localization purposes string msg = string.Format("Couldn't save file {0}\n{1}", dialog.FileName, ex.ToString()); MessageBox.Show(msg, "Error saving file!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { newLrfStream.Close(); } Host.Status("Finished."); } return(ret); }
public void LoadCharacterMap() { m_CharMapper = new CharacterMapper(); string filename = GetCharMapFile(); if (filename != null) { StreamReader reader = new StreamReader(filename, Encoding.Unicode); string line; while ((line = reader.ReadLine()) != null) { if (line.Length == 3 && line[0] != '#' && line[1] == ':') { m_CharMapper.Add(line[0], line[2]); } } } else { MessageBox.Show("The Character Mapping file (charmap.txt) is missing!\n"); } }
public HTMLToBbebTransform(BBeBLib.Serializer.CharacterMapper charMapper) { m_CharMapper = charMapper; }