/// ------------------------------------------------------------------------------------ /// <summary> /// Creates 2 fake HF sets for use in testing /// </summary> /// <returns>the created publication</returns> /// ------------------------------------------------------------------------------------ private IPublication CreateFakeHFSets() { // create a publication IPublication pub = new Publication(); Cache.LangProject.LexDbOA.PublicationsOC.Add(pub); IPubDivision pubDiv = new PubDivision(); pub.DivisionsOS.Append(pubDiv); // create the current HF set for the publication pubDiv.HFSetOA = new PubHFSet(); pubDiv.HFSetOA.DefaultHeaderOA = new PubHeader(); pubDiv.HFSetOA.DefaultFooterOA = new PubHeader(); pubDiv.HFSetOA.FirstHeaderOA = new PubHeader(); pubDiv.HFSetOA.FirstFooterOA = new PubHeader(); pubDiv.HFSetOA.EvenHeaderOA = new PubHeader(); pubDiv.HFSetOA.EvenFooterOA = new PubHeader(); pubDiv.HFSetOA.Name = "Test HF Set of Matthew printed in Tabaluga"; // create a dummy HF set IPubHFSet hfset = new PubHFSet(); m_hfSets.Add(hfset); hfset.Name = "Test HF Set created today"; hfset.Description.Text = "This is a test HF set"; hfset.DefaultHeaderOA = new PubHeader(); hfset.DefaultFooterOA = new PubHeader(); hfset.EvenHeaderOA = new PubHeader(); hfset.EvenFooterOA = new PubHeader(); hfset.FirstFooterOA = new PubHeader(); hfset.FirstHeaderOA = new PubHeader(); hfset.DefaultFooterOA.OutsideAlignedText.Text = "outside text"; hfset.DefaultFooterOA.CenteredText.Text = "Song of songs"; hfset.EvenHeaderOA.CenteredText.Text = "Song even pages"; hfset.EvenHeaderOA.InsideAlignedText.Text = "Inside text"; hfset.FirstFooterOA.InsideAlignedText.Text = "Inside text"; // create another dummy HF set IPubHFSet hfset2 = new PubHFSet(); m_hfSets.Add(hfset2); hfset2.Name = "Test HF Set of Matthew printed in Tabaluga"; hfset2.Description.Text = "This is another test HF set"; hfset2.DefaultHeaderOA = new PubHeader(); hfset2.DefaultFooterOA = new PubHeader(); hfset2.EvenHeaderOA = new PubHeader(); hfset2.EvenFooterOA = new PubHeader(); hfset2.FirstFooterOA = new PubHeader(); hfset2.FirstHeaderOA = new PubHeader(); hfset2.DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString = StringUtils.CreateOrcFromGuid(HeaderFooterVc.PageNumberGuid, FwObjDataTypes.kodtContextString, Cache.DefaultUserWs); hfset2.DefaultFooterOA.CenteredText.Text = "Matthew"; hfset2.EvenFooterOA.CenteredText.Text = "From Reference"; hfset2.EvenHeaderOA.InsideAlignedText.Text = "nothing"; hfset2.FirstFooterOA.InsideAlignedText.Text = "Inside text"; return(pub); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Copy the details from the given pub H/F set to this one. /// </summary> /// <param name="copyFrom">The set to clone</param> /// ------------------------------------------------------------------------------------ public void CloneDetails(IPubHFSet copyFrom) { Description.UnderlyingTsString = copyFrom.Description.UnderlyingTsString; Name = copyFrom.Name; // if the header and the footer were null (if they are missing in the database) // then create them if (DefaultHeaderOA == null) DefaultHeaderOA = new PubHeader(); if (DefaultFooterOA == null) DefaultFooterOA = new PubHeader(); DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString = copyFrom.DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString; DefaultHeaderOA.CenteredText.UnderlyingTsString = copyFrom.DefaultHeaderOA.CenteredText.UnderlyingTsString; DefaultHeaderOA.InsideAlignedText.UnderlyingTsString = copyFrom.DefaultHeaderOA.InsideAlignedText.UnderlyingTsString; DefaultFooterOA.OutsideAlignedText.UnderlyingTsString = copyFrom.DefaultFooterOA.OutsideAlignedText.UnderlyingTsString; DefaultFooterOA.CenteredText.UnderlyingTsString = copyFrom.DefaultFooterOA.CenteredText.UnderlyingTsString; DefaultFooterOA.InsideAlignedText.UnderlyingTsString = copyFrom.DefaultFooterOA.InsideAlignedText.UnderlyingTsString; PubDivision owningDiv = new PubDivision(Cache, OwnerHVO); if (owningDiv.DifferentFirstHF) { // if the header and the footer were null (if they are the same as the odd page) // then create them if (FirstHeaderOA == null) FirstHeaderOA = new PubHeader(); if (FirstFooterOA == null) FirstFooterOA = new PubHeader(); FirstHeaderOA.OutsideAlignedText.UnderlyingTsString = copyFrom.FirstHeaderOA.OutsideAlignedText.UnderlyingTsString; FirstHeaderOA.CenteredText.UnderlyingTsString = copyFrom.FirstHeaderOA.CenteredText.UnderlyingTsString; FirstHeaderOA.InsideAlignedText.UnderlyingTsString = copyFrom.FirstHeaderOA.InsideAlignedText.UnderlyingTsString; FirstFooterOA.OutsideAlignedText.UnderlyingTsString = copyFrom.FirstFooterOA.OutsideAlignedText.UnderlyingTsString; FirstFooterOA.CenteredText.UnderlyingTsString = copyFrom.FirstFooterOA.CenteredText.UnderlyingTsString; FirstFooterOA.InsideAlignedText.UnderlyingTsString = copyFrom.FirstFooterOA.InsideAlignedText.UnderlyingTsString; } else { FirstHeaderOA = null; FirstFooterOA = null; } if (owningDiv.DifferentEvenHF) { // if the header and the footer were null (if they are the same as the odd page) // then create them if (EvenHeaderOA == null) EvenHeaderOA = new PubHeader(); if (EvenFooterOA == null) EvenFooterOA = new PubHeader(); EvenHeaderOA.OutsideAlignedText.UnderlyingTsString = copyFrom.EvenHeaderOA.OutsideAlignedText.UnderlyingTsString; EvenHeaderOA.CenteredText.UnderlyingTsString = copyFrom.EvenHeaderOA.CenteredText.UnderlyingTsString; EvenHeaderOA.InsideAlignedText.UnderlyingTsString = copyFrom.EvenHeaderOA.InsideAlignedText.UnderlyingTsString; EvenFooterOA.OutsideAlignedText.UnderlyingTsString = copyFrom.EvenFooterOA.OutsideAlignedText.UnderlyingTsString; EvenFooterOA.CenteredText.UnderlyingTsString = copyFrom.EvenFooterOA.CenteredText.UnderlyingTsString; EvenFooterOA.InsideAlignedText.UnderlyingTsString = copyFrom.EvenFooterOA.InsideAlignedText.UnderlyingTsString; } else { EvenHeaderOA = null; EvenFooterOA = 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.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(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates 2 fake HF sets for use in testing /// </summary> /// <returns>the created publication</returns> /// ------------------------------------------------------------------------------------ private IPublication CreateFakeHFSets() { // create a publication IPublication pub = new Publication(); Cache.LangProject.LexDbOA.PublicationsOC.Add(pub); IPubDivision pubDiv = new PubDivision(); pub.DivisionsOS.Append(pubDiv); // create the current HF set for the publication pubDiv.HFSetOA = new PubHFSet(); pubDiv.HFSetOA.DefaultHeaderOA = new PubHeader(); pubDiv.HFSetOA.DefaultFooterOA = new PubHeader(); pubDiv.HFSetOA.FirstHeaderOA = new PubHeader(); pubDiv.HFSetOA.FirstFooterOA = new PubHeader(); pubDiv.HFSetOA.EvenHeaderOA = new PubHeader(); pubDiv.HFSetOA.EvenFooterOA = new PubHeader(); pubDiv.HFSetOA.Name = "Test HF Set of Matthew printed in Tabaluga"; // create a dummy HF set IPubHFSet hfset = new PubHFSet(); m_hfSets.Add(hfset); hfset.Name = "Test HF Set created today"; hfset.Description.Text = "This is a test HF set"; hfset.DefaultHeaderOA = new PubHeader(); hfset.DefaultFooterOA = new PubHeader(); hfset.EvenHeaderOA = new PubHeader(); hfset.EvenFooterOA = new PubHeader(); hfset.FirstFooterOA = new PubHeader(); hfset.FirstHeaderOA = new PubHeader(); hfset.DefaultFooterOA.OutsideAlignedText.Text = "outside text"; hfset.DefaultFooterOA.CenteredText.Text = "Song of songs"; hfset.EvenHeaderOA.CenteredText.Text = "Song even pages"; hfset.EvenHeaderOA.InsideAlignedText.Text = "Inside text"; hfset.FirstFooterOA.InsideAlignedText.Text = "Inside text"; // create another dummy HF set IPubHFSet hfset2 = new PubHFSet(); m_hfSets.Add(hfset2); hfset2.Name = "Test HF Set of Matthew printed in Tabaluga"; hfset2.Description.Text = "This is another test HF set"; hfset2.DefaultHeaderOA = new PubHeader(); hfset2.DefaultFooterOA = new PubHeader(); hfset2.EvenHeaderOA = new PubHeader(); hfset2.EvenFooterOA = new PubHeader(); hfset2.FirstFooterOA = new PubHeader(); hfset2.FirstHeaderOA = new PubHeader(); hfset2.DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString = StringUtils.CreateOrcFromGuid(HeaderFooterVc.PageNumberGuid, FwObjDataTypes.kodtContextString, Cache.DefaultUserWs); hfset2.DefaultFooterOA.CenteredText.Text = "Matthew"; hfset2.EvenFooterOA.CenteredText.Text = "From Reference"; hfset2.EvenHeaderOA.InsideAlignedText.Text = "nothing"; hfset2.FirstFooterOA.InsideAlignedText.Text = "Inside text"; return pub; }
/// ------------------------------------------------------------------------------------ /// <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(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configures the publication. /// </summary> /// ------------------------------------------------------------------------------------ protected void ConfigurePublication() { m_division = new DummyDivision(new DummyLazyPrintConfigurer(Cache, false, true), 1); Publication pub = new Publication(Cache, Cache.LangProject.TranslatedScriptureOA.PublicationsOC.HvoArray[0]); pub.BaseFontSize = 12; pub.BaseLineSpacing = 15; PubDivision pubDiv = new PubDivision(); pub.DivisionsOS.Append(pubDiv); pubDiv.PageLayoutOA = new PubPageLayout(); pubDiv.NumColumns = 1; pubDiv.StartAt = DivisionStartOption.NewPage; FwStyleSheet styleSheet = new FwStyleSheet(); styleSheet.Init(Cache, Cache.LangProject.TranslatedScriptureOAHvo, (int)Scripture.ScriptureTags.kflidStyles); m_pubCtrl = new DummyScripturePublicationNoDb(pub, styleSheet, m_division, DateTime.Now, m_filterInstance); m_pubCtrl.Configure(); m_pubCtrl.BookHvo = m_genesis.Hvo; m_pageInfo = new DummyPageInfo(); m_pageInfo.m_publication = m_pubCtrl; int filterInstance = 123456789; FilteredScrBooks bookFilter = new FilteredScrBooks(Cache, filterInstance); m_vc = new TeHeaderFooterVc(Cache, m_pageInfo, Cache.DefaultVernWs, DateTime.Now, filterInstance, (int)ScrBook.ScrBookTags.kflidSections); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Sets up a publication for OnPageSetup. /// </summary> /// <param name="publication">A publication to use for page setup.</param> /// <param name="division">Publication Division for pub</param> /// <param name="pageLayout">A publication page layout for pub</param> /// <returns>returns <c>false</c> if there is no current publication</returns> /// <remarks>This was the top half of OnPageSetup originally. /// It was refactored to avoid duplicating code in an override of /// OnPageSetup in TeMainWind.</remarks> /// ------------------------------------------------------------------------------------ protected bool PageSetupPreparePublication(out IPublication publication, out IPubDivision division, out IPubPageLayout pageLayout) { publication = null; division = null; pageLayout = null; // Get a publication to use for page setup. publication = CurrentPublication; if (publication == null) return false; // Get a publication division for given publication. If none, create one. int chvoDiv = publication.DivisionsOS.Count; int hvoDiv; if (chvoDiv < 1) { hvoDiv = m_cache.CreateObject(PubDivision.kClassId, publication.Hvo, (int)Publication.PublicationTags.kflidDivisions, 0); division = new PubDivision(m_cache, hvoDiv, true, true); division.StartAt = DivisionStartOption.NewPage; division.DifferentEvenHF = false; division.DifferentFirstHF = false; } else { hvoDiv = publication.DivisionsOS.HvoArray[0]; division = new PubDivision(m_cache, hvoDiv, true, true); } // Get publication page layout for given division. If none create one. int hvoPgl; if (division.PageLayoutOAHvo == 0) { hvoPgl = m_cache.CreateObject(PubPageLayout.kClassId, hvoDiv, (int)PubDivision.PubDivisionTags.kflidPageLayout, 0); pageLayout = division.PageLayoutOA; pageLayout.MarginTop = 72000; pageLayout.MarginBottom = 72000; pageLayout.MarginInside = 72000; pageLayout.MarginOutside = 72000; pageLayout.PosHeader = 36000; pageLayout.PosFooter = 36000; } else { pageLayout = division.PageLayoutOA; } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the division to the publication. /// </summary> /// <param name="pub">The publication where the division will be added.</param> /// <param name="fDifferentFirstHF">if set to <c>true</c> publication has a different /// first header/footer].</param> /// <param name="fDifferentEvenHF">if set to <c>true</c> publication has a different even /// header/footer.</param> /// <param name="startAt">Enumeration of options for where the content of the division /// begins</param> /// <returns>the new division</returns> /// ------------------------------------------------------------------------------------ public IPubDivision AddDivisionToPub(IPublication pub, bool fDifferentFirstHF, bool fDifferentEvenHF, DivisionStartOption startAt) { PubDivision div = new PubDivision(); pub.DivisionsOS.Append(div); div.DifferentFirstHF = fDifferentFirstHF; div.DifferentEvenHF = fDifferentEvenHF; div.StartAt = startAt; return (IPubDivision)div; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Copy the details from the given pub H/F set to this one. /// </summary> /// <param name="copyFrom">The set to clone</param> /// ------------------------------------------------------------------------------------ public void CloneDetails(IPubHFSet copyFrom) { Description.UnderlyingTsString = copyFrom.Description.UnderlyingTsString; Name = copyFrom.Name; // if the header and the footer were null (if they are missing in the database) // then create them if (DefaultHeaderOA == null) { DefaultHeaderOA = new PubHeader(); } if (DefaultFooterOA == null) { DefaultFooterOA = new PubHeader(); } DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString = copyFrom.DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString; DefaultHeaderOA.CenteredText.UnderlyingTsString = copyFrom.DefaultHeaderOA.CenteredText.UnderlyingTsString; DefaultHeaderOA.InsideAlignedText.UnderlyingTsString = copyFrom.DefaultHeaderOA.InsideAlignedText.UnderlyingTsString; DefaultFooterOA.OutsideAlignedText.UnderlyingTsString = copyFrom.DefaultFooterOA.OutsideAlignedText.UnderlyingTsString; DefaultFooterOA.CenteredText.UnderlyingTsString = copyFrom.DefaultFooterOA.CenteredText.UnderlyingTsString; DefaultFooterOA.InsideAlignedText.UnderlyingTsString = copyFrom.DefaultFooterOA.InsideAlignedText.UnderlyingTsString; PubDivision owningDiv = new PubDivision(Cache, OwnerHVO); if (owningDiv.DifferentFirstHF) { // if the header and the footer were null (if they are the same as the odd page) // then create them if (FirstHeaderOA == null) { FirstHeaderOA = new PubHeader(); } if (FirstFooterOA == null) { FirstFooterOA = new PubHeader(); } FirstHeaderOA.OutsideAlignedText.UnderlyingTsString = copyFrom.FirstHeaderOA.OutsideAlignedText.UnderlyingTsString; FirstHeaderOA.CenteredText.UnderlyingTsString = copyFrom.FirstHeaderOA.CenteredText.UnderlyingTsString; FirstHeaderOA.InsideAlignedText.UnderlyingTsString = copyFrom.FirstHeaderOA.InsideAlignedText.UnderlyingTsString; FirstFooterOA.OutsideAlignedText.UnderlyingTsString = copyFrom.FirstFooterOA.OutsideAlignedText.UnderlyingTsString; FirstFooterOA.CenteredText.UnderlyingTsString = copyFrom.FirstFooterOA.CenteredText.UnderlyingTsString; FirstFooterOA.InsideAlignedText.UnderlyingTsString = copyFrom.FirstFooterOA.InsideAlignedText.UnderlyingTsString; } else { FirstHeaderOA = null; FirstFooterOA = null; } if (owningDiv.DifferentEvenHF) { // if the header and the footer were null (if they are the same as the odd page) // then create them if (EvenHeaderOA == null) { EvenHeaderOA = new PubHeader(); } if (EvenFooterOA == null) { EvenFooterOA = new PubHeader(); } EvenHeaderOA.OutsideAlignedText.UnderlyingTsString = copyFrom.EvenHeaderOA.OutsideAlignedText.UnderlyingTsString; EvenHeaderOA.CenteredText.UnderlyingTsString = copyFrom.EvenHeaderOA.CenteredText.UnderlyingTsString; EvenHeaderOA.InsideAlignedText.UnderlyingTsString = copyFrom.EvenHeaderOA.InsideAlignedText.UnderlyingTsString; EvenFooterOA.OutsideAlignedText.UnderlyingTsString = copyFrom.EvenFooterOA.OutsideAlignedText.UnderlyingTsString; EvenFooterOA.CenteredText.UnderlyingTsString = copyFrom.EvenFooterOA.CenteredText.UnderlyingTsString; EvenFooterOA.InsideAlignedText.UnderlyingTsString = copyFrom.EvenFooterOA.InsideAlignedText.UnderlyingTsString; } else { EvenHeaderOA = null; EvenFooterOA = null; } }