Example #1
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;
        }
Example #2
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);
        }
		/// ------------------------------------------------------------------------------------
		/// <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
		}
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
Example #5
0
        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);
        }