InjectXMatter() public method

public InjectXMatter ( string>.Dictionary writingSystemCodes, Layout layout ) : void
writingSystemCodes string>.Dictionary
layout Layout
return void
Ejemplo n.º 1
0
        private void InjectXMatter(string initialPath, BookStorage storage, Layout sizeAndOrientation)
        {
            //now add in the xmatter from the currently selected xmatter pack
            if (!TestingSoSkipAddingXMatter)
            {
                var data = new DataSet();
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language1Iso639Code));
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language2Iso639Code));
                data.WritingSystemAliases.Add("V", _collectionSettings.Language1Iso639Code);
                data.WritingSystemAliases.Add("N1", _collectionSettings.Language2Iso639Code);
                data.WritingSystemAliases.Add("N2", _collectionSettings.Language3Iso639Code);

                var helper = new XMatterHelper(storage.Dom, _collectionSettings.XMatterPackName, _fileLocator);
                helper.FolderPathForCopyingXMatterFiles = storage.FolderPath;
                helper.InjectXMatter(data.WritingSystemAliases, sizeAndOrientation, _collectionSettings.BrandingProjectKey, storage.FolderPath);
                //TranslationGroupManager.PrepareDataBookTranslationGroups(storage.Dom,languages);
            }
        }
Ejemplo n.º 2
0
        private void InjectXMatter(string initialPath, BookStorage storage, Layout sizeAndOrientation)
        {
//now add in the xmatter from the currently selected xmatter pack
            if (!TestingSoSkipAddingXMatter)
            {
                var data = new DataSet();
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language1Iso639Code));
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language2Iso639Code));
                data.WritingSystemAliases.Add("V", _collectionSettings.Language1Iso639Code);
                data.WritingSystemAliases.Add("N1", _collectionSettings.Language2Iso639Code);
                data.WritingSystemAliases.Add("N2", _collectionSettings.Language3Iso639Code);


                //by default, this comes from the collection, but the book can select one, inlucing "null" to select the factory-supplied empty xmatter
                var xmatterName = storage.Dom.GetMetaValue("xmatter", _collectionSettings.XMatterPackName);

                var helper = new XMatterHelper(storage.Dom, xmatterName, _fileLocator);
                helper.FolderPathForCopyingXMatterFiles = storage.FolderPath;
                helper.InjectXMatter(data.WritingSystemAliases, sizeAndOrientation);
            }
        }
Ejemplo n.º 3
0
        private void InjectXMatter(string initialPath, BookStorage storage, Layout sizeAndOrientation)
        {
            //now add in the xmatter from the currently selected xmatter pack
            if (!TestingSoSkipAddingXMatter)
            {
                var data = new Dictionary <string, string>();
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language1.Iso639Code));
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language2.Iso639Code));
                // Review: this sort of duplicates the knowledge in BookData.WritingSystemAliases
                // Is it worth creating a BookData here? Since we're just starting the new book, it can't
                // yet have any language settings different from the collection.
                data.Add("V", _collectionSettings.Language1.Iso639Code);
                data.Add("N1", _collectionSettings.Language2.Iso639Code);
                data.Add("N2", _collectionSettings.Language3.Iso639Code);

                var helper = new XMatterHelper(storage.Dom, _collectionSettings.XMatterPackName, _fileLocator);
                helper.FolderPathForCopyingXMatterFiles = storage.FolderPath;
                helper.InjectXMatter(data, sizeAndOrientation, false, _collectionSettings.Language2.Iso639Code);
                //TranslationGroupManager.PrepareDataBookTranslationGroups(storage.Dom,languages);
            }
        }
Ejemplo n.º 4
0
        private void InjectXMatter(string initialPath, BookStorage storage, Layout sizeAndOrientation)
        {
            //now add in the xmatter from the currently selected xmatter pack
            if (!TestingSoSkipAddingXMatter)
            {
                var data = new DataSet();
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language1Iso639Code));
                Debug.Assert(!string.IsNullOrEmpty(_collectionSettings.Language2Iso639Code));
                data.WritingSystemCodes.Add("V", _collectionSettings.Language1Iso639Code);
                data.WritingSystemCodes.Add("N1", _collectionSettings.Language2Iso639Code);
                data.WritingSystemCodes.Add("N2", _collectionSettings.Language3Iso639Code);

                //by default, this comes from the collection, but the book can select one, inlucing "null" to select the factory-supplied empty xmatter
                var xmatterName = storage.Dom.GetMetaValue("xmatter", _collectionSettings.XMatterPackName);

                var helper = new XMatterHelper(storage.Dom, xmatterName, _fileLocator);
                helper.FolderPathForCopyingXMatterFiles = storage.FolderPath;
                helper.InjectXMatter(data.WritingSystemCodes, sizeAndOrientation);
            }
        }
Ejemplo n.º 5
0
        private void BringXmatterHtmlUpToDate(HtmlDom bookDOM)
        {
            //by default, this comes from the collection, but the book can select one, including "null" to select the factory-supplied empty xmatter
            var nameOfXMatterPack = OurHtmlDom.GetMetaValue("xMatter", _collectionSettings.XMatterPackName);
            nameOfXMatterPack = Storage.HandleRetiredXMatterPacks(OurHtmlDom, nameOfXMatterPack);
            var helper = new XMatterHelper(bookDOM, nameOfXMatterPack, _storage.GetFileLocator());
            //note, we determine this before removing xmatter to fix the situation where there is *only* xmatter, no content, so if
            //we wait until we've removed the xmatter, we no how no way of knowing what size/orientation they had before the update.
            Layout layout = Layout.FromDom(bookDOM, Layout.A5Portrait);
            XMatterHelper.RemoveExistingXMatter(bookDOM);
            layout = Layout.FromDom(bookDOM, layout);
                //this says, if you can't figure out the page size, use the one we got before we removed the xmatter
            helper.InjectXMatter(_bookData.GetWritingSystemCodes(), layout);

            var dataBookLangs = bookDOM.GatherDataBookLanguages();
            TranslationGroupManager.PrepareDataBookTranslationGroups(RawDom, dataBookLangs);
        }
Ejemplo n.º 6
0
        private void BringBookUpToDate(HtmlDom bookDOM /* may be a 'preview' version*/, IProgress progress)
        {
            progress.WriteStatus("Gathering Data...");

            //by default, this comes from the collection, but the book can select one, including "null" to select the factory-supplied empty xmatter
            var nameOfXMatterPack = OurHtmlDom.GetMetaValue("xMatter", _collectionSettings.XMatterPackName);

            var helper = new XMatterHelper(bookDOM, nameOfXMatterPack, _storage.GetFileLocator());
            XMatterHelper.RemoveExistingXMatter(bookDOM);
            Layout layout = Layout.FromDom(bookDOM, Layout.A5Portrait);			//enhance... this is currently just for the whole book. would be better page-by-page, somehow...
            progress.WriteStatus("Injecting XMatter...");

            helper.InjectXMatter(_bookData.GetWritingSystemCodes(), layout);
            TranslationGroupManager.PrepareElementsInPageOrDocument(bookDOM.RawDom, _collectionSettings);
            progress.WriteStatus("Updating Data...");

            //hack
            if(bookDOM == OurHtmlDom)//we already have a data for this
            {
                _bookData.SynchronizeDataItemsThroughoutDOM();

                // I think we should only mess with tags if we are updating the book for real.
                var oldTagsPath = Path.Combine(_storage.FolderPath, "tags.txt");
                if (File.Exists(oldTagsPath))
                {
                    ConvertTagsToMetaData(oldTagsPath, BookInfo);
                    File.Delete(oldTagsPath);
                }
            }
            else //used for making a preview dom
            {
                var bd = new BookData(bookDOM, _collectionSettings, UpdateImageMetadataAttributes);
                bd.SynchronizeDataItemsThroughoutDOM();
            }

            bookDOM.RemoveMetaElement("bloomBookLineage", () => BookInfo.BookLineage, val => BookInfo.BookLineage = val);
            bookDOM.RemoveMetaElement("bookLineage", () => BookInfo.BookLineage, val => BookInfo.BookLineage = val);
            // BookInfo will always have an ID, the constructor makes one even if there is no json file.
            // To allow migration, pretend it has no ID if there is not yet a meta.json.
            bookDOM.RemoveMetaElement("bloomBookId", () => (File.Exists(BookInfo.MetaDataPath) ? BookInfo.Id : null), val => BookInfo.Id = val);

            // Title should be replicated in json
            //if (!string.IsNullOrWhiteSpace(Title)) // check just in case we somehow have more useful info in json.
            //    bookDOM.Title = Title;
            // Bit of a kludge, but there's no way to tell whether a boolean is already set in the JSON, so we fake that it is not,
            // thus ensuring that if something is in the metadata we use it.
            bookDOM.RemoveMetaElement("SuitableForMakingShells", () => null, val => BookInfo.IsSuitableForMakingShells = val == "yes" || val == "definitely");
            // If there is nothing there the default of true will survive.
            bookDOM.RemoveMetaElement("SuitableForMakingVernacularBooks", () => null, val => BookInfo.IsSuitableForVernacularLibrary = val == "yes" || val == "definitely");
        }
Ejemplo n.º 7
0
        private void BringBookUpToDate(HtmlDom bookDOM /* may be a 'preview' version*/, IProgress progress)
        {
            progress.WriteStatus("Gathering Data...");

            //by default, this comes from the collection, but the book can select one, inlucing "null" to select the factory-supplied empty xmatter
            var nameOfXMatterPack = OurHtmlDom.GetMetaValue("xMatter", _collectionSettings.XMatterPackName);

            var helper = new XMatterHelper(bookDOM, nameOfXMatterPack, _storage.GetFileLocator());
            XMatterHelper.RemoveExistingXMatter(bookDOM);
            Layout layout = Layout.FromDom(bookDOM, Layout.A5Portrait);			//enhance... this is currently just for the whole book. would be better page-by-page, somehow...
            progress.WriteStatus("Injecting XMatter...");

            helper.InjectXMatter(_bookData.GetWritingSystemCodes(), layout);
            TranslationGroupManager.PrepareElementsInPageOrDocument(bookDOM.RawDom, _collectionSettings);
            progress.WriteStatus("Updating Data...");

            //hack
            if(bookDOM == OurHtmlDom)//we already have a data for this
            {
                _bookData.SynchronizeDataItemsThroughoutDOM();
            }
            else //used for making a preview dom
            {
                var bd = new BookData(bookDOM, _collectionSettings, UpdateImageMetadataAttributes);
                bd.SynchronizeDataItemsThroughoutDOM();
            }

            bookDOM.RenameMetaElement("bookLineage", "bloomBookLineage");
        }