public XMatterHelper(HtmlDom bookDom, string nameOfXMatterPack, IFileLocator fileLocator)
{
_bookDom = bookDom;
_nameOfXMatterPack = nameOfXMatterPack;
string directoryName = nameOfXMatterPack + "-XMatter";
string directoryPath;
try
{
directoryPath = fileLocator.LocateDirectoryWithThrow(directoryName);
}
catch(ApplicationException error)
{
var errorTemplate = LocalizationManager.GetString("Errors.XMatterNotFound",
"This Book called for Front/Back Matter pack named '{0}', but Bloom couldn't find that on this computer. You can either install a Bloom Pack that will give you '{0}', or go to Settings:Book Making and change to another Front/Back Matter Pack.");
var msg = string.Format(errorTemplate, nameOfXMatterPack);
ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), msg);
//NB: we don't want to put up a dialog for each one; one failure here often means 20 more are coming as the other books are loaded!
throw new ApplicationException(msg);
}
var htmName = nameOfXMatterPack + "-XMatter.html";
PathToXMatterHtml = directoryPath.CombineForPath(htmName);
if(!RobustFile.Exists(PathToXMatterHtml))
{
htmName = nameOfXMatterPack + "-XMatter.htm"; // pre- Bloom 3.7
PathToXMatterHtml = directoryPath.CombineForPath(htmName);
}
if (!RobustFile.Exists(PathToXMatterHtml))
{
ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), "Could not locate the file {0} in {1} (also checked .html)", htmName, directoryPath);
throw new ApplicationException();
}
PathToStyleSheetForPaperAndOrientation = directoryPath.CombineForPath(GetStyleSheetFileName());
if (!RobustFile.Exists(PathToXMatterHtml))
{
ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), "Could not locate the file {0} in {1}", GetStyleSheetFileName(), directoryPath);
throw new ApplicationException();
}
XMatterDom = XmlHtmlConverter.GetXmlDomFromHtmlFile(PathToXMatterHtml, false);
}