예제 #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		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_pubCtrl != null)
			{
				m_pubCtrl.Dispose();
				m_pubCtrl = 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();
		}
예제 #3
0
		//private Form m_form;
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates the division and publication.
		/// </summary>
		/// <param name="columns">The number of columns.</param>
		/// <param name="fSharedSubStreams">if set to <c>true</c> configure the print layout
		/// view using shared sub streams; otherwise, each division will create an owned
		/// substream.</param>
		/// ------------------------------------------------------------------------------------
		private void CreateDivisionAndPublication(int columns, bool fSharedSubStreams)
		{
			if (m_firstDivision != null)
				m_firstDivision.Dispose();
			if (m_pub != null)
				m_pub.Dispose();
			m_subStream = null;
			if (fSharedSubStreams)
				m_subStream = VwLayoutStreamClass.Create();
			m_firstDivision = new DummyDivision(new DummyPrintConfigurer(Cache, m_subStream),
				columns);
			IPublication pub =
				Cache.LangProject.TranslatedScriptureOA.PublicationsOC.ToArray()[0];
			m_pub = new DummyPublication(pub, m_firstDivision, DateTime.Now);
			if (fSharedSubStreams)
			{
				m_subViewVc = new DummyFirstSubViewVc();
				int hvoScr = Cache.LangProject.TranslatedScriptureOA.Hvo;
				IVwRootBox rootbox = (IVwRootBox)m_subStream;
				rootbox.DataAccess = Cache.MainCacheAccessor;
				rootbox.SetRootObject(hvoScr, m_subViewVc,
					DummyFirstSubViewVc.kfragScrFootnotes, null);

				m_pub.AddSharedSubstream(m_subStream);
			}

		}
예제 #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Shuts down the FDO cache
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void TestTearDown()
		{
			if (m_firstDivision != null)
			{
				m_firstDivision.m_hPagesBroken.Clear();
				m_firstDivision.Dispose();
				m_firstDivision = null;
			}

			// Make sure we close all the rootboxes
			if (m_pub != null)
			{
				m_pub.Dispose();
				m_pub = null;
			}

			m_subViewVc = null;
			m_subStream = null;

			base.TestTearDown();
		}
예제 #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Configures the publication.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void ConfigurePublication()
		{
			m_division = new DummyDivision(new DummyLazyPrintConfigurer(Cache, false,
				true), 1);
			IPublication pub = Cache.LangProject.TranslatedScriptureOA.PublicationsOC.ToArray()[0];
			pub.BaseFontSize = 12000;
			pub.BaseLineSpacing = 15;
			IPubDivision pubDiv = Cache.ServiceLocator.GetInstance<IPubDivisionFactory>().Create();
			pub.DivisionsOS.Add(pubDiv);
			pubDiv.PageLayoutOA = Cache.ServiceLocator.GetInstance<IPubPageLayoutFactory>().Create();
			pubDiv.NumColumns = 1;
			pubDiv.StartAt = DivisionStartOption.NewPage;

			FwStyleSheet styleSheet = new FwStyleSheet();
			styleSheet.Init(Cache, Cache.LangProject.TranslatedScriptureOA.Hvo,
				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;
			Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(m_filterInstance);  // this creates the book filter!
			m_vc = new TeHeaderFooterVc(Cache, m_pageInfo, Cache.DefaultVernWs,
				DateTime.Now, m_filterInstance);
		}
		/// ------------------------------------------------------------------------------------
		/// <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 PageElementsDontOverlap_FootnotesInTwoDivisions()
		{
			IScripture scr = Cache.LangProject.TranslatedScriptureOA;

			// delete all books
			scr.ScriptureBooksOS.Clear();

			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];
			IStFootnote footnote = AddFootnote(genesis,
				(IStTxtPara)section.ContentOA.ParagraphsOS[0], 2);
			IStTxtPara para = AddParaToMockedText(footnote,
							ScrStyleNames.NormalFootnoteParagraph);
			AddRunToMockedPara(para, "Another footnote", para.Cache.DefaultVernWs);

			// Add a footnote in the first book, last section, 1st paragraph
			section = genesis.SectionsOS[genesis.SectionsOS.Count - 1];
			footnote = AddFootnote(genesis,
				(IStTxtPara)section.ContentOA.ParagraphsOS[0], 1);
			para = AddParaToMockedText(footnote,
				ScrStyleNames.NormalFootnoteParagraph);
			AddRunToMockedPara(para, "This is the footnote", para.Cache.DefaultVernWs);

			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);
		}
예제 #8
0
		/// ------------------------------------------------------------------------------------
		/// <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));
		}
예제 #9
0
		public void PublicationFontAndLineHeightUsed()
		{
			m_pub.BaseFontSize = 9000;
			m_pub.BaseLineSpacing = -11000;
			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(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);
		}
예제 #10
0
		public void CreatePages_MultiDivContinuous()
		{
			m_firstDivision.StartAt = DivisionStartOption.Continuous;
			DummyDivision secondDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream, 1), 1);
			secondDiv.StartAt = DivisionStartOption.Continuous;
			m_pub.AddDivision(secondDiv);

			m_pub.PageHeight = 72000 * 7; // 7 inches
			m_pub.PageWidth = 72000 * 8; // 8 inches
			secondDiv.TopMargin = m_firstDivision.TopMargin = 36000; // Half inch
			secondDiv.BottomMargin = m_firstDivision.BottomMargin = 36000; // 1/2 inch
			secondDiv.InsideMargin = m_firstDivision.InsideMargin = 18000; // 1/4 inch
			secondDiv.OutsideMargin = m_firstDivision.OutsideMargin = 36000; // 1/2 inch
			m_pub.CreatePages();
			Assert.AreEqual(4, m_pub.Pages.Count);
			Assert.AreEqual(0, m_pub.Pages[0].FirstDivOnPage);
			Assert.AreEqual(0, m_pub.Pages[0].OffsetFromTopOfDiv(m_firstDivision));
			Assert.AreEqual(1, m_pub.Pages[2].FirstDivOnPage);
			Assert.Greater(m_pub.Pages[2].OffsetFromTopOfDiv(secondDiv), 0);
		}
예제 #11
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
예제 #12
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
예제 #13
0
		/// ------------------------------------------------------------------------------------
		/// <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();
		}
예제 #14
0
		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();
		}
예제 #15
0
		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();
		}
예제 #16
0
		public void DefaultFontAndLineHeightUsed()
		{
			m_pub.BaseFontSize = 0;
			m_pub.BaseLineSpacing = 0;
			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(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);
				}
			}
		}
예제 #17
0
		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);
		}
예제 #18
0
		public void CreatePages_MultiDivNewPage()
		{
			m_firstDivision.StartAt = DivisionStartOption.NewPage;
			DummyDivision secondDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream, 1), 1);
			secondDiv.StartAt = DivisionStartOption.NewPage;
			m_pub.AddDivision(secondDiv);

			m_pub.PageHeight = 72000 * 12; // 12 inches
			m_pub.PageWidth = 72000 * 8; // 8 inches
			secondDiv.TopMargin = m_firstDivision.TopMargin = 36000; // Half inch
			secondDiv.BottomMargin = m_firstDivision.BottomMargin = 36000; // 1/2 inch
			secondDiv.InsideMargin = m_firstDivision.InsideMargin = 18000; // 1/4 inch
			secondDiv.OutsideMargin = m_firstDivision.OutsideMargin = 36000; // 1/2 inch

			// If div height is greater than page - then this unit test is wrong.
			int estimatedHeightInPrinterPixels = m_firstDivision.EstimateHeight(
				m_firstDivision.AvailableMainStreamColumWidthInPrinterPixels) +
				m_firstDivision.BottomMarginInPrinterPixels + m_firstDivision.TopMarginInPrinterPixels;
			Assert.That(estimatedHeightInPrinterPixels, Is.LessThan(m_pub.PageHeightInPrinterPixels),
				"Div height on this system means this test is invalid. Consider increasing page Height.");

			m_pub.CreatePages();
			Assert.AreEqual(2, m_pub.Pages.Count);
			Assert.AreEqual(0, m_pub.Pages[0].FirstDivOnPage);
			Assert.AreEqual(0, m_pub.Pages[0].OffsetFromTopOfDiv(m_firstDivision));
			Assert.AreEqual(1, m_pub.Pages[1].FirstDivOnPage);
			Assert.AreEqual(0, m_pub.Pages[1].OffsetFromTopOfDiv(secondDiv));
		}
예제 #19
0
		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;
			}
		}
예제 #20
0
		public void Pub_ThreeDivisions_EachDivStartsNewPage()
		{
			DummyDivision secondDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream), 2);
			DummyDivision thirdDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream), 1);
			thirdDiv.StartAt = secondDiv.StartAt = m_firstDivision.StartAt = DivisionStartOption.NewPage;
			m_pub.AddDivision(secondDiv);
			m_pub.AddDivision(thirdDiv);

			m_pub.PageHeight = 72000 * 11; // 11 inches
			m_pub.PageWidth = 72000 * 8; // 8 inches
			thirdDiv.TopMargin = m_firstDivision.TopMargin = 36000; // Half inch
			thirdDiv.BottomMargin = m_firstDivision.BottomMargin = 18000; // Quarter inch
			thirdDiv.InsideMargin = m_firstDivision.InsideMargin = 9000; // 1/8 inch
			thirdDiv.OutsideMargin = m_firstDivision.OutsideMargin = 4500; // 1/16 inch
			m_pub.CreatePages();
			Assert.AreEqual(4, m_pub.Pages.Count);
			Page firstPage = m_pub.Pages[0];
			Assert.AreEqual(m_firstDivision, m_pub.Divisions[firstPage.FirstDivOnPage]);
			Page origPage2 = m_pub.PageAfter(firstPage);
			Assert.AreEqual(m_pub.Pages[1], origPage2);
			Assert.AreEqual(secondDiv, m_pub.Divisions[origPage2.FirstDivOnPage]);
			Assert.AreEqual(0, m_pub.IndexOfPage(firstPage));
			Page lastPage = m_pub.Pages[3];
			Assert.AreEqual(thirdDiv, m_pub.Divisions[lastPage.FirstDivOnPage]);
			Assert.AreEqual(3, m_pub.IndexOfPage(lastPage),
				"IndexOfPage returned wrong value for last page");
			Page extraPage = new Page(m_pub, 1, 0, 2,
				m_firstDivision.TopMarginInPrinterPixels, m_firstDivision.BottomMarginInPrinterPixels);
			m_pub.InsertPageAfter(firstPage, extraPage);
			Assert.AreEqual(m_pub.Pages[1], extraPage);
			Assert.AreEqual(m_pub.Pages[2], origPage2);
			Assert.AreEqual(m_pub.Pages[4], lastPage);
			Assert.AreEqual(firstPage, m_pub.FindPage(firstPage.Handle));
			Assert.AreEqual(extraPage, m_pub.FindPage(extraPage.Handle));
			Assert.AreEqual(origPage2, m_pub.FindPage(origPage2.Handle));
			Assert.AreEqual(lastPage, m_pub.FindPage(lastPage.Handle));
			m_pub.DeletePage(extraPage);
			Assert.AreEqual(m_pub.Pages[1], origPage2);
			Assert.IsNull(m_pub.PageAfter(lastPage));

			m_pub.PrepareToDrawPages(0, 99999);
			Assert.AreEqual(7, m_pub.Pages.Count);
			Assert.AreEqual(2, firstPage.PageElements.Count);
			Assert.AreEqual(3, origPage2.PageElements.Count, "Should have one element per column, plus one for footnotes.");
			Assert.AreEqual(2, lastPage.PageElements.Count);

			Assert.AreEqual(m_firstDivision.MainRootBox.Height, thirdDiv.MainRootBox.Height);
			Assert.AreNotEqual(m_firstDivision.MainRootBox.Height, secondDiv.MainRootBox.Height);
		}
예제 #21
0
		/// ------------------------------------------------------------------------------------
		/// <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();
		}
예제 #22
0
		public void Pub_ThreeDivisions_Continuous_WithSeparateFootnoteStreams()
		{
			CreateDivisionAndPublication(1, false);

			m_firstDivision.StartAt = DivisionStartOption.Continuous;
			DummyDivision secondDiv = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1);
			secondDiv.StartAt = DivisionStartOption.Continuous;
			DummyDivision thirdDiv = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1);
			thirdDiv.StartAt = DivisionStartOption.Continuous;
			m_pub.AddDivision(secondDiv);
			m_pub.AddDivision(thirdDiv);

			m_pub.PageHeight = 72000 * 9; // 9 inches
			m_pub.PageWidth = 72000 * 7; // 7 inches
			thirdDiv.TopMargin = secondDiv.TopMargin = m_firstDivision.TopMargin = 36000; // Half inch
			thirdDiv.BottomMargin = secondDiv.BottomMargin = m_firstDivision.BottomMargin = 36000; // 1/2 inch
			thirdDiv.InsideMargin = secondDiv.InsideMargin = m_firstDivision.InsideMargin = 18000; // 1/4 inch
			thirdDiv.OutsideMargin = secondDiv.OutsideMargin = m_firstDivision.OutsideMargin = 36000; // 1/2 inch
			m_pub.Configure();
			m_pub.CreatePages();
			Assert.AreEqual(6, m_pub.Pages.Count); // this is just an estimate

			m_pub.PrepareToDrawPages(0, 99999);
			Assert.AreEqual(9, m_pub.Pages.Count);

			Page firstPage = m_pub.Pages[0];
			Assert.AreEqual(0, m_pub.IndexOfPage(firstPage));
			Assert.AreEqual(m_firstDivision, m_pub.Divisions[firstPage.FirstDivOnPage]);
			Assert.AreEqual(2, firstPage.PageElements.Count);

			Page secondPage = m_pub.PageAfter(firstPage);
			Assert.AreEqual(m_pub.Pages[1], secondPage);
			Assert.AreEqual(m_firstDivision, m_pub.Divisions[secondPage.FirstDivOnPage]);
			Assert.AreEqual(2, secondPage.PageElements.Count);

			Page lastPage = m_pub.Pages[8];
			Assert.AreEqual(thirdDiv, m_pub.Divisions[lastPage.FirstDivOnPage]);
			Assert.AreEqual(8, m_pub.IndexOfPage(lastPage),
				"IndexOfPage returned wrong value for last page");
			Assert.AreEqual(2, lastPage.PageElements.Count);

			Assert.AreEqual(m_firstDivision.MainRootBox.Height, thirdDiv.MainRootBox.Height);
			Assert.AreEqual(m_firstDivision.MainRootBox.Height, secondDiv.MainRootBox.Height);
		}
예제 #23
0
		public void Pub_ThreeDivisions_Continuous_SharedFootnoteStream_RepeatedOrcs()
		{
			m_firstDivision.StartAt = DivisionStartOption.Continuous;
			DummyDivision secondDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream), 1);
			secondDiv.StartAt = DivisionStartOption.Continuous;
			DummyDivision thirdDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream), 1);
			thirdDiv.StartAt = DivisionStartOption.Continuous;
			m_pub.AddDivision(secondDiv);
			m_pub.AddDivision(thirdDiv);

			m_pub.PageHeight = 72000 * 12; // 12 inches
			m_pub.PageWidth = 72000 * 9; // 9 inches
			thirdDiv.TopMargin = secondDiv.TopMargin = m_firstDivision.TopMargin = 36000; // Half inch
			thirdDiv.BottomMargin = secondDiv.BottomMargin = m_firstDivision.BottomMargin = 36000; // 1/2 inch
			thirdDiv.InsideMargin = secondDiv.InsideMargin = m_firstDivision.InsideMargin = 18000; // 1/4 inch
			thirdDiv.OutsideMargin = secondDiv.OutsideMargin = m_firstDivision.OutsideMargin = 36000; // 1/2 inch
			m_pub.CreatePages();
			Assert.AreEqual(3, m_pub.Pages.Count); // this is just an estimate

			m_pub.PrepareToDrawPages(0, 99999);
			Assert.AreEqual(3, m_pub.Pages.Count);
			Page firstPage = m_pub.Pages[0];
			Page secondPage = m_pub.PageAfter(firstPage);
			Assert.AreEqual(m_pub.Pages[1], secondPage);
			Assert.AreEqual(2, firstPage.PageElements.Count, "Should have one element per division, plus one for the footnotes");
			Assert.AreEqual(3, secondPage.PageElements.Count);
			Assert.AreEqual(m_firstDivision, m_pub.Divisions[firstPage.FirstDivOnPage]);
			Assert.AreEqual(m_firstDivision, m_pub.Divisions[secondPage.FirstDivOnPage]);

			Assert.AreEqual(m_firstDivision.MainRootBox.Height, thirdDiv.MainRootBox.Height);
			Assert.AreEqual(m_firstDivision.MainRootBox.Height, secondDiv.MainRootBox.Height);
		}
예제 #24
0
		public void Pub_ThreeDivisions_Continuous_SharedFootnoteStream()
		{
			m_firstDivision.StartAt = DivisionStartOption.Continuous;
			DummyDivision secondDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream, 1), 1);
			secondDiv.StartAt = DivisionStartOption.Continuous;
			DummyDivision thirdDiv = new DummyDivision(
				new DummyPrintConfigurer(Cache, m_subStream, 2), 1);
			thirdDiv.StartAt = DivisionStartOption.Continuous;
			m_pub.AddDivision(secondDiv);
			m_pub.AddDivision(thirdDiv);

			m_pub.PageHeight = 72000 * 12; // 12 inches
			m_pub.PageWidth = 72000 * 8; // 8 inches
			thirdDiv.TopMargin = secondDiv.TopMargin = m_firstDivision.TopMargin = 36000; // Half inch
			thirdDiv.BottomMargin = secondDiv.BottomMargin = m_firstDivision.BottomMargin = 36000; // 1/2 inch
			thirdDiv.InsideMargin = secondDiv.InsideMargin = m_firstDivision.InsideMargin = 18000; // 1/4 inch
			thirdDiv.OutsideMargin = secondDiv.OutsideMargin = m_firstDivision.OutsideMargin = 36000; // 1/2 inch

			// If div height is greater than page - then this unit test is wrong.
			int estimatedHeightInPrinterPixels = m_firstDivision.EstimateHeight(
				m_firstDivision.AvailableMainStreamColumWidthInPrinterPixels) +
				m_firstDivision.BottomMarginInPrinterPixels + m_firstDivision.TopMarginInPrinterPixels;
			Assert.That(estimatedHeightInPrinterPixels, Is.LessThan(m_pub.PageHeightInPrinterPixels),
				"Div height on this system means this test is invalid. Consider increasing page Height.");

			m_pub.CreatePages();
			Assert.AreEqual(3, m_pub.Pages.Count); // this is just an estimate

			m_pub.PrepareToDrawPages(0, 99999);
			Assert.AreEqual(4, m_pub.Pages.Count);
			Page firstPage = m_pub.Pages[0];
			Page secondPage = m_pub.PageAfter(firstPage);
			Assert.AreEqual(m_pub.Pages[1], secondPage);
			Assert.AreEqual(2, firstPage.PageElements.Count, "Should have one element per division, plus one for the footnotes");
			Assert.AreEqual(3, secondPage.PageElements.Count);
			Assert.AreEqual(m_firstDivision, m_pub.Divisions[firstPage.FirstDivOnPage]);
			Assert.AreEqual(m_firstDivision, m_pub.Divisions[secondPage.FirstDivOnPage]);
			Assert.AreEqual(0,
				firstPage.PageElements[firstPage.PageElements.Count - 2].OffsetToTopPageBoundary);
			Assert.AreEqual(0,
				secondPage.PageElements[secondPage.PageElements.Count - 2].OffsetToTopPageBoundary);

			Assert.Greater(m_firstDivision.MainRootBox.Height, 0);
			Assert.Greater(secondDiv.MainRootBox.Height, 0);
			Assert.Greater(thirdDiv.MainRootBox.Height, 0);
		}
예제 #25
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}
예제 #26
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}