/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// ------------------------------------------------------------------------------------ public void ConfigurePublication() { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", "TestLangProj"); m_fdoCache = FdoCache.Create(cacheOptions); // Make sure we don't call InstallLanguage during tests. m_fdoCache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; if (m_pub != null) { m_pub.Dispose(); } m_division = new DummyDivision(new DummyHFPrintConfigurer(m_fdoCache), 1); Publication pub = new Publication(m_fdoCache, m_fdoCache.LangProject.TranslatedScriptureOA.PublicationsOC.HvoArray[0]); m_pub = new DummyPublication(pub, m_division, DateTime.Now); m_pub.Configure(); // Check initial state Assert.AreEqual(m_division, m_pub.Divisions[0]); IVwLayoutStream layoutStream = m_division.MainLayoutStream; Assert.IsNotNull(layoutStream); }
public override void TestTearDown() { if (m_division != null) { if (m_division.Configurer != null) { var disposable = m_division.Configurer.DependentRootVc as IDisposable; if (disposable != null) { disposable.Dispose(); } } m_division.m_hPagesBroken.Clear(); m_division.Dispose(); m_division = null; } // Make sure we close all the rootboxes if (m_ScrPubCtrl != null) { m_ScrPubCtrl.Dispose(); m_ScrPubCtrl = null; } base.TestTearDown(); }
public void PublicationFontAndLineHeightUsed() { m_pub.BaseFontSize = 9000; m_pub.BaseLineSpacing = -11000; FwStyleSheet stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, Cache.LangProject.TranslatedScriptureOA.Hvo, ScriptureTags.kflidStyles); using (DummyDivision divLayoutMgr = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1)) { using (ReallyStupidPubCtrl pubControl = new ReallyStupidPubCtrl(m_pub, stylesheet, divLayoutMgr, DateTime.Now, true)) { ITsTextProps normalProps = pubControl.PrintLayoutStylesheet.GetStyleRgch(-1, "Normal"); Assert.IsNotNull(normalProps); int var; Assert.AreEqual(9000, normalProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); Assert.AreEqual(-11000, normalProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// <param name="fAddSubStream">if set to <c>true</c> add subordinate stream.</param> /// ------------------------------------------------------------------------------------ private void ConfigurePublication(bool fAddSubStream) { // When called for test setup, they will be null. // When called from within as test if (m_pub != null) { m_pub.Dispose(); } if (m_division != null) { m_division.Dispose(); } m_division = new DummyDivision(new DummyLazyPrintConfigurer(Cache, fAddSubStream), 1); Publication pub = new Publication(Cache, Cache.LangProject.TranslatedScriptureOA.PublicationsOC.HvoArray[0]); m_pub = new DummyPublication(pub, m_division, DateTime.Now); m_pub.Configure(); // Check initial state Assert.AreEqual(m_division, m_pub.Divisions[0]); Assert.IsNotNull(m_division.MainVc as DummyMainLazyViewVc); IVwLayoutStream layoutStream = m_division.MainLayoutStream; Assert.IsNotNull(layoutStream); m_pub.IsLeftBound = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// <param name="fAddSubStream">if set to <c>true</c> add subordinate stream.</param> /// <param name="fAddContent">if set to <c>true</c> add real content, otherwise add /// rectangle for paragraph.</param> /// ------------------------------------------------------------------------------------ private void ConfigurePublication(bool fAddSubStream, bool fAddContent) { // When called for test setup, they will be null. // When called from within as test if (m_pub != null) m_pub.Dispose(); if (m_division != null) m_division.Dispose(); m_division = new DummyDivision(new DummyLazyPrintConfigurer(Cache, fAddSubStream, fAddContent), 2); IPublication pub = Cache.LangProject.TranslatedScriptureOA.PublicationsOC.ToArray()[0]; m_pub = new DummyPublication(pub, m_division, DateTime.Now); m_pub.Configure(); // Check initial state Assert.AreEqual(m_division, m_pub.Divisions[0]); Assert.IsNotNull(m_division.MainVc as DummyMainLazyViewVc); IVwLayoutStream layoutStream = m_division.MainLayoutStream; Assert.IsNotNull(layoutStream); m_pub.IsLeftBound = true; // Set up the publication m_pub.PageHeight = 72000 * 11; // 11 inches m_pub.PageWidth = (int)(72000 * 8.5); // 8.5 inches m_division.TopMargin = 36000; // Half inch m_division.BottomMargin = 18000; // Quarter inch m_division.InsideMargin = 9000; // 1/8 inch m_division.OutsideMargin = 4500; // 1/16 inch DummyMainLazyViewVc vc = m_division.MainVc as DummyMainLazyViewVc; vc.m_estBookHeight = 2000; vc.m_estSectionHeight = 2000; m_pub.Width = 3 * 96; // represents a window that is 3" wide at 96 DPI }
public void DefaultFontAndLineHeightUsed() { m_pub.BaseFontSize = 0; m_pub.BaseLineSpacing = 0; m_inMemoryCache.CreateDefaultLangProjStyles(); FwStyleSheet stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, Cache.LangProject.Hvo, (int)LangProject.LangProjectTags.kflidStyles); DummyDivision divLayoutMgr = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1); ReallyStupidPubCtrl pubControl = new ReallyStupidPubCtrl(m_pub, stylesheet, divLayoutMgr, DateTime.Now, true); ITsTextProps normalProps = pubControl.PrintLayoutStylesheet.GetStyleRgch(-1, "Normal"); Assert.IsNotNull(normalProps); int var; Assert.AreEqual(pubControl.DefaultFontSize, normalProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); Assert.AreEqual(pubControl.DefaultLineHeight, normalProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); }
public virtual void TearDown() { if (m_fdoCache != null) { UndoResult ures = 0; while (m_fdoCache.CanUndo) { m_fdoCache.Undo(out ures); if (ures == UndoResult.kuresFailed || ures == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures.ToString()); } } } if (m_division != null) { m_division.m_hPagesBroken.Clear(); m_division.Dispose(); m_division = null; } // Make sure we close all the rootboxes if (m_ScrPubCtrl != null) { m_ScrPubCtrl.Dispose(); m_ScrPubCtrl = null; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// <param name="fAddSubStream">if set to <c>true</c> add subordinate stream.</param> /// <param name="fAddContent">if set to <c>true</c> add real content, otherwise add /// rectangle for paragraph.</param> /// ------------------------------------------------------------------------------------ private void ConfigurePublication(bool fAddSubStream, bool fAddContent) { // When called for test setup, they will be null. // When called from within as test if (m_ScrPubCtrl != null) { m_ScrPubCtrl.Dispose(); } if (m_division != null) { m_division.Dispose(); } m_division = new DummyDivision(new DummyLazyPrintConfigurer(Cache, fAddSubStream, fAddContent), 1); FwStyleSheet styleSheet = new FwStyleSheet(); styleSheet.Init(Cache, Cache.LangProject.TranslatedScriptureOA.Hvo, ScriptureTags.kflidStyles); FootnoteVc footnoteVc = new FootnoteVc(TeStVc.LayoutViewTarget.targetPrint, -1); footnoteVc.Cache = Cache; footnoteVc.Stylesheet = styleSheet; DummyPrintConfigurer configurer = m_division.Configurer as DummyPrintConfigurer; configurer.RootOnEachPage = true; configurer.DependentRootFrag = (int)FootnoteFrags.kfrRootInPageSeq; configurer.DependentRootTag = ScrBookTags.kflidFootnotes; configurer.StyleSheet = styleSheet; configurer.DependentRootVc = footnoteVc; m_dbPub = Cache.LangProject.TranslatedScriptureOA.PublicationsOC.ToArray()[0]; m_dbPub.BaseFontSize = 12000; m_dbPub.BaseLineSpacing = 15; IPubDivision pubDiv = Cache.ServiceLocator.GetInstance <IPubDivisionFactory>().Create(); m_dbPub.DivisionsOS.Add(pubDiv); pubDiv.PageLayoutOA = Cache.ServiceLocator.GetInstance <IPubPageLayoutFactory>().Create(); pubDiv.NumColumns = 1; pubDiv.StartAt = DivisionStartOption.NewPage; m_ScrPubCtrl = new DummyScripturePublicationNoDb(m_dbPub, styleSheet, m_division, DateTime.Now, m_filterInstance); m_ScrPubCtrl.IsLeftBound = true; // Set up the publication m_ScrPubCtrl.PageHeight = 72000 * 11; // 11 inches m_ScrPubCtrl.PageWidth = (int)(72000 * 8.5); // 8.5 inches m_division.TopMargin = 36000; // Half inch m_division.BottomMargin = 18000; // Quarter inch m_division.InsideMargin = 9000; // 1/8 inch m_division.OutsideMargin = 4500; // 1/16 inch m_ScrPubCtrl.Width = 3 * 96; // represents a window that is 3" wide at 96 DPI m_ScrPubCtrl.Configure(); }
public void GutterNotIncludedInPrintLayout_TopBound() { m_pub.PageWidth = 0; m_pub.PageHeight = 0; m_pub.PaperHeight = 6 * MiscUtils.kdzmpInch; // 2 inches m_pub.PaperWidth = 8 * MiscUtils.kdzmpInch; // 8 inches m_pub.GutterMargin = 3 * MiscUtils.kdzmpInch; // 3 inch gutter m_pub.BindingEdge = BindingSide.Top; DummyDivision divLayoutMgr = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1); ReallyStupidPubCtrl pubControl = new ReallyStupidPubCtrl(m_pub, null, divLayoutMgr, DateTime.Now, false); Assert.AreEqual(8 * MiscUtils.kdzmpInch, pubControl.PageWidth); Assert.AreEqual(3 * MiscUtils.kdzmpInch, pubControl.PageHeight); }
public override void Exit() { if (m_division != null) { m_division.m_hPagesBroken.Clear(); m_division.Dispose(); m_division = null; } // Make sure we close all the rootboxes if (m_ScrPubCtrl != null) { m_ScrPubCtrl.Dispose(); m_ScrPubCtrl = null; } base.Exit(); }
public override void TestTearDown() { if (m_division != null) { m_division.m_hPagesBroken.Clear(); m_division.Dispose(); m_division = null; } // Make sure we close all the rootboxes if (m_pub != null) { m_pub.Dispose(); m_pub = null; } base.TestTearDown(); }
public virtual void TearDown() { if (m_division != null) { m_division.m_hPagesBroken.Clear(); m_division.Dispose(); m_division = null; } // Make sure we close all the rootboxes if (m_ScrPubCtrl != null) { m_ScrPubCtrl.Dispose(); m_ScrPubCtrl = null; } base.TestTearDown(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// ------------------------------------------------------------------------------------ public void ConfigurePublication() { if (m_pub != null) { m_pub.Dispose(); } m_division = new DummyDivision(new DummyHFPrintConfigurer(Cache), 1); IPublication pub = Cache.LangProject.TranslatedScriptureOA.PublicationsOC.ToArray()[0]; m_pub = new DummyPublication(pub, m_division, DateTime.Now); m_pub.Configure(); // Check initial state Assert.AreEqual(m_division, m_pub.Divisions[0]); IVwLayoutStream layoutStream = m_division.MainLayoutStream; Assert.IsNotNull(layoutStream); }
public override void Exit() { CheckDisposed(); if (m_division != null) { m_division.m_hPagesBroken.Clear(); m_division.Dispose(); m_division = null; } // Make sure we close all the rootboxes if (m_pub != null) { m_pub.Dispose(); m_pub = null; } base.Exit(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// ------------------------------------------------------------------------------------ public void ConfigurePublication() { if (m_division != null) { m_division.Dispose(); } if (m_ScrPubCtrl != null) { m_ScrPubCtrl.Dispose(); } m_division = new DummyDivision(new DummyPrintConfigurer(m_fdoCache, null), 1); Publication pub = new Publication(m_fdoCache, m_fdoCache.LangProject.TranslatedScriptureOA.PublicationsOC.HvoArray[0]); m_ScrPubCtrl = new TeDummyPublication(pub, m_division, DateTime.Now); m_ScrPubCtrl.Configure(); // Check initial state Assert.AreEqual(m_division, m_ScrPubCtrl.Divisions[0]); Assert.IsNotNull(m_division.MainVc as StVc); IVwLayoutStream layoutStream = m_division.MainLayoutStream; Assert.IsNotNull(layoutStream); Assert.AreEqual(layoutStream, m_division.MainLayoutStream, "MainLayoutStream should not contruct a new stream each time"); IVwRootBox rootbox = layoutStream as IVwRootBox; Assert.IsNotNull(rootbox); IVwSelection sel = rootbox.Selection; Assert.IsNotNull(sel); int ich, hvo, tag, ws; // dummies bool fAssocPrev; ITsString tss; sel.TextSelInfo(false, out tss, out ich, out fAssocPrev, out hvo, out tag, out ws); Assert.AreEqual("14", tss.Text.Substring(0, 2)); }
public void PageElementsDontOverlap_FootnotesInTwoDivisions() { IScripture scr = Cache.LangProject.TranslatedScriptureOA; // delete all books scr.ScriptureBooksOS.RemoveAll(); IScrSection dummySection; IScrBook genesis = CreateSmallBook(1, "Genesis", out dummySection); // Add a footnote in the first book, first section, first paragraph IScrSection section = genesis.SectionsOS[0]; StFootnote footnote = m_scrInMemoryCache.AddFootnote(genesis, (StTxtPara)section.ContentOA.ParagraphsOS[0], 2); StTxtPara para = m_scrInMemoryCache.AddParaToMockedText(footnote.Hvo, ScrStyleNames.NormalFootnoteParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "Another footnote", 0); // Add a footnote in the first book, last section, 1st paragraph section = genesis.SectionsOS[genesis.SectionsOS.Count - 1]; footnote = m_scrInMemoryCache.AddFootnote(genesis, (StTxtPara)section.ContentOA.ParagraphsOS[0], 1); para = m_scrInMemoryCache.AddParaToMockedText(footnote.Hvo, ScrStyleNames.NormalFootnoteParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "This is the footnote", 0); ConfigurePublication(true, true); m_pub.PageHeight = 72000 * 3; // 3 inches m_pub.PageWidth = 72000 * 4; // 4 inches // Add a second division (that displays the same as the first) DummyDivision secondDiv = new DummyDivision(new DummyLazyPrintConfigurer(Cache, false, true), 2); secondDiv.TopMargin = m_division.TopMargin; secondDiv.BottomMargin = m_division.BottomMargin; secondDiv.InsideMargin = m_division.InsideMargin; secondDiv.OutsideMargin = m_division.OutsideMargin; m_pub.AddDivision(secondDiv); m_pub.Configure(); m_pub.CreatePages(); m_pub.PrepareToDrawPages(0, m_pub.AutoScrollMinSize.Height * 2); Assert.GreaterOrEqual(m_pub.Pages.Count, 2); Page firstPage = m_pub.Pages[0]; int cFoonotesOnThisPage = m_division.m_testPageFootnoteInfo[firstPage.Handle] + secondDiv.m_testPageFootnoteInfo[firstPage.Handle]; Assert.AreEqual(3, cFoonotesOnThisPage, "Should display three footnotes on first page"); // None of the page elements on the first page should intersect CheckThatPageElementsDontOverlap(firstPage); // PageElement 0: first column of first division; 2: first column of second division; // 4: footnotes Assert.AreEqual(m_pub.PageHeightInPrinterPixels - m_division.TopMarginInPrinterPixels - m_division.BottomMarginInPrinterPixels, firstPage.PageElements[0].ColumnHeight + firstPage.PageElements[2].ColumnHeight + firstPage.PageElements[4].ColumnHeight + firstPage.FreeSpace.Height); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// <param name="fAddSubStream">if set to <c>true</c> add subordinate stream.</param> /// <param name="fAddContent">if set to <c>true</c> add real content, otherwise add /// rectangle for paragraph.</param> /// ------------------------------------------------------------------------------------ private void ConfigurePublication(bool fAddSubStream, bool fAddContent) { // When called for test setup, they will be null. // When called from within as test if (m_ScrPubCtrl != null) { m_ScrPubCtrl.Dispose(); } if (m_division != null) { m_division.Dispose(); } m_division = new DummyDivision(new DummyLazyPrintConfigurer(Cache, fAddSubStream, fAddContent), 1); FwStyleSheet styleSheet = new FwStyleSheet(); styleSheet.Init(Cache, Cache.LangProject.TranslatedScriptureOAHvo, (int)Scripture.ScriptureTags.kflidStyles); FootnoteVc footnoteVc = new FootnoteVc(-1, TeStVc.LayoutViewTarget.targetPrint, Cache.DefaultVernWs); footnoteVc.Cache = Cache; footnoteVc.Stylesheet = styleSheet; DummyPrintConfigurer configurer = m_division.Configurer as DummyPrintConfigurer; configurer.RootOnEachPage = true; configurer.DependentRootFrag = (int)FootnoteFrags.kfrRootInPageSeq; configurer.DependentRootTag = DummyVirtualHandler.InstallDummyHandler(Cache.VwCacheDaAccessor, "Scripture", "FootnotesOnPage", (int)CellarModuleDefns.kcptReferenceSequence).Tag; configurer.StyleSheet = styleSheet; configurer.DependentRootVc = footnoteVc; m_dbPub = new Publication(Cache, Cache.LangProject.TranslatedScriptureOA.PublicationsOC.HvoArray[0]); m_dbPub.BaseFontSize = 12; m_dbPub.BaseLineSpacing = 15; PubDivision pubDiv = new PubDivision(); m_dbPub.DivisionsOS.Append(pubDiv); pubDiv.PageLayoutOA = new PubPageLayout(); pubDiv.NumColumns = 1; pubDiv.StartAt = DivisionStartOption.NewPage; m_ScrPubCtrl = new DummyScripturePublicationNoDb(m_dbPub, styleSheet, m_division, DateTime.Now, m_filterInstance); m_ScrPubCtrl.IsLeftBound = true; // Set up the publication m_ScrPubCtrl.PageHeight = 72000 * 11; // 11 inches m_ScrPubCtrl.PageWidth = (int)(72000 * 8.5); // 8.5 inches m_division.TopMargin = 36000; // Half inch m_division.BottomMargin = 18000; // Quarter inch m_division.InsideMargin = 9000; // 1/8 inch m_division.OutsideMargin = 4500; // 1/16 inch m_ScrPubCtrl.Width = 3 * 96; // represents a window that is 3" wide at 96 DPI m_ScrPubCtrl.Configure(); }