Пример #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;
        }
Пример #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);
        }
Пример #3
0
        public void AdjustScrollRange_GrowFirstDivOnPage_NoElements()
        {
            DummyVwLayoutStream stream = new DummyVwLayoutStream();

            using (GoofyDivision divMgr = new GoofyDivision(stream))
                using (DummyPublication pubCtrl = new DummyPublication(null, divMgr, DateTime.Now))
                {
                    pubCtrl.PageHeight      = 72000 * 6;
                    divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels;
                    pubCtrl.CreatePages();
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(0, pubCtrl.Pages[0].PageElements.Count);
                    Assert.AreEqual(0, pubCtrl.Pages[1].PageElements.Count);
                    Point origScrollPos  = pubCtrl.ScrollPosition;
                    Size  origScrollSize = pubCtrl.AutoScrollMinSize;
                    pubCtrl.AdjustScrollRange(stream, 0, 0, 300, 0);
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                    Assert.AreEqual(origScrollSize, pubCtrl.AutoScrollMinSize);
                    Assert.AreEqual(0, pubCtrl.Pages[0].PageElements.Count);
                    Assert.AreEqual(0, pubCtrl.Pages[1].PageElements.Count);
                    Assert.IsTrue(pubCtrl.Pages[0].NeedsLayout);
                    Assert.IsTrue(pubCtrl.Pages[1].NeedsLayout);
                }
        }
Пример #4
0
        public void AdjustScrollRange_GrowFootnoteStream()
        {
            DummyVwLayoutStream stream         = new DummyVwLayoutStream();
            DummyVwLayoutStream footnoteStream = new DummyVwLayoutStream();

            using (GoofyDivision divMgr = new GoofyDivision(stream))
                using (DummyPublication pubCtrl = new DummyPublication(null, divMgr, DateTime.Now))
                {
                    pubCtrl.PageHeight      = 72000 * 6;
                    divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels;
                    pubCtrl.CreatePages();
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    divMgr.CallAddElement(pubCtrl.Pages[0], divMgr.m_overrideHeight - 100,
                                          1, 1, divMgr.InsideMarginInPrinterPixels, 20, divMgr.AvailablePageHeightInPrinterPixels);
                    int origTopOfPageTwo = divMgr.m_overrideHeight - 100;
                    ((DummyPage)pubCtrl.Pages[0]).CallAddPageElement(divMgr, footnoteStream, false,
                                                                     new Rectangle(divMgr.InsideMarginInPrinterPixels, divMgr.m_overrideHeight - 100, divMgr.AvailablePageWidthInPrinterPixels, 100),
                                                                     0, false, 1, 1, 0, 100, false, true);
                    divMgr.CallAddElement(pubCtrl.Pages[1], 100, 1, 1, divMgr.OutsideMarginInPrinterPixels,
                                          origTopOfPageTwo, divMgr.AvailablePageHeightInPrinterPixels);
                    ((DummyPage)pubCtrl.Pages[1]).CallAddPageElement(divMgr, footnoteStream, false,
                                                                     new Rectangle(divMgr.InsideMarginInPrinterPixels, divMgr.m_overrideHeight - 100, divMgr.AvailablePageWidthInPrinterPixels, 100),
                                                                     101, false, 1, 1, 0, 100, false, true);
                    Point origScrollPos  = pubCtrl.ScrollPosition;
                    Size  origScrollSize = pubCtrl.AutoScrollMinSize;
                    pubCtrl.AdjustScrollRange(footnoteStream, 0, 0, 300, 95);
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                    Assert.AreEqual(origScrollSize, pubCtrl.AutoScrollMinSize);
                    Assert.AreEqual(0, pubCtrl.Pages[0].PageElements[1].OffsetToTopPageBoundary);
                    Assert.AreEqual(401, pubCtrl.Pages[1].PageElements[1].OffsetToTopPageBoundary);
                    Assert.AreEqual(20, pubCtrl.Pages[0].OffsetFromTopOfDiv(divMgr));
                    Assert.AreEqual(origTopOfPageTwo, pubCtrl.Pages[1].OffsetFromTopOfDiv(divMgr));
                }
        }
Пример #5
0
        public void AdjustScrollRange_GrowFirstDivOnPage()
        {
            DummyVwLayoutStream stream = new DummyVwLayoutStream();

            using (GoofyDivision divMgr = new GoofyDivision(stream))
                using (DummyPublication pubCtrl = new DummyPublication(null, divMgr, DateTime.Now))
                {
                    pubCtrl.PageHeight      = 72000 * 6;
                    divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels;
                    pubCtrl.CreatePages();
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    divMgr.CallAddElement(pubCtrl.Pages[0], divMgr.m_overrideHeight - 20,
                                          1, 1, divMgr.InsideMarginInPrinterPixels, 20, divMgr.AvailablePageHeightInPrinterPixels);
                    int origTopOfPageTwo = divMgr.m_overrideHeight - 20;
                    divMgr.CallAddElement(pubCtrl.Pages[1], 20, 1, 1, divMgr.OutsideMarginInPrinterPixels,
                                          origTopOfPageTwo, divMgr.AvailablePageHeightInPrinterPixels);
                    Point origScrollPos  = pubCtrl.ScrollPosition;
                    Size  origScrollSize = pubCtrl.AutoScrollMinSize;
                    pubCtrl.AdjustScrollRange(stream, 0, 0, 300, origTopOfPageTwo - 2000);
                    Assert.AreEqual(2, pubCtrl.PageCount);
                    Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                    Assert.AreEqual(origScrollSize, pubCtrl.AutoScrollMinSize);
                    Assert.AreEqual(20, pubCtrl.Pages[0].PageElements[0].OffsetToTopPageBoundary);
                    Assert.AreEqual(origTopOfPageTwo + 300, pubCtrl.Pages[1].PageElements[0].OffsetToTopPageBoundary);
                    Assert.IsFalse(pubCtrl.Pages[0].NeedsLayout);
                    Assert.IsTrue(pubCtrl.Pages[1].NeedsLayout);
                }
        }
Пример #6
0
        public void GetLastElement_OneElement()
        {
            IVwLayoutStream stream = VwLayoutStreamClass.Create();

            using (DummyDivisionMgr division = new DummyDivisionMgr(stream, false))
            {
                using (DummyPublication dummyPub = new DummyPublication(null, division, DateTime.Now))
                {
                    using (DummyPage page = new DummyPage(dummyPub))
                    {
                        PageElement element = new PageElement(division, stream, false,
                                                              new Rectangle(720, 1440, (int)(6.5 * 720), (int)(9 * 1440)),
                                                              0, true, 1, 1, 0, 9 * 1440, 0, false);
                        page.PageElements.Add(element);

                        int         xd;
                        PageElement lastElement = page.CallGetLastElement(division, out xd);
                        Assert.AreEqual(element.LocationOnPage.Right, xd);
                        Debug.WriteLine("GetLastElement_OneElement xd: " + xd);

                        Assert.AreEqual(element, lastElement);
                    }
                }
            }
        }
Пример #7
0
        public void GetLastElement_TwoElementsRtoLStandard()
        {
            IVwLayoutStream stream = VwLayoutStreamClass.Create();

            using (DummyDivisionMgr division = new DummyDivisionMgr(stream, true))
                using (DummyPublication dummyPub = new DummyPublication(null, division, DateTime.Now))
                    using (DummyPage page = new DummyPage(dummyPub))
                    {
                        PageElement leftColumnElement = new PageElement(division, stream, false,
                                                                        new Rectangle(0, 1440, (int)(3 * 720), (int)(5 * 1440)),
                                                                        0, true, 1, 2, 0, 5 * 1440, 0, true);
                        PageElement rightColumnElement = new PageElement(division, stream, false,
                                                                         new Rectangle(3 * 720 + 360, 1440, (int)(3 * 720), (int)(9 * 1440)),
                                                                         0, true, 2, 2, 0, 9 * 1440, 0, true);

                        page.PageElements.Add(leftColumnElement);
                        page.PageElements.Add(rightColumnElement);

                        int         xd;
                        PageElement lastElement = page.CallGetLastElement(division, out xd);
                        Debug.WriteLine("GetLastElement_TwoElementsRtoLStandard xd: " + xd);

                        Assert.AreEqual(leftColumnElement, lastElement,
                                        "The left-most column should be the last element in a right-to-left writing system");
                        Assert.AreEqual(0, xd);
                    }
        }
		/// ------------------------------------------------------------------------------------
		/// <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>
 /// Shuts down the FDO cache
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public override void FixtureTeardown()
 {
     // Make sure we close all the rootboxes
     if (m_pub != null)
     {
         m_pub.Dispose();
     }
     m_pub = null;
     base.FixtureTeardown();
 }
Пример #10
0
        public void AdjustScrollRange_GrowSecondDivOnPageTwo()
        {
            DummyVwLayoutStream stream1 = new DummyVwLayoutStream();
            DummyVwLayoutStream stream2 = new DummyVwLayoutStream();

            using (GoofyDivision divMgr1 = new GoofyDivision(stream1))
                using (GoofyDivision divMgr2 = new GoofyDivision(stream2))
                    using (DummyPublication pubCtrl = new DummyPublication(null, divMgr1, DateTime.Now))
                    {
                        pubCtrl.PageHeight = 72000 * 6;
                        pubCtrl.AddDivision(divMgr2);
                        divMgr1.m_overrideHeight = divMgr1.AvailablePageHeightInPrinterPixels;
                        divMgr2.m_overrideHeight = divMgr2.AvailablePageHeightInPrinterPixels;
                        divMgr2.StartAt          = DivisionStartOption.Continuous;
                        pubCtrl.CreatePages();
                        Assert.AreEqual(3, pubCtrl.PageCount);
                        divMgr1.CallAddElement(pubCtrl.Pages[0], divMgr1.m_overrideHeight - 20, 1, 1,
                                               divMgr1.InsideMarginInPrinterPixels, 20, divMgr1.AvailablePageHeightInPrinterPixels);
                        int origTopOfPageTwoDiv1 = divMgr1.m_overrideHeight - 20;
                        divMgr1.CallAddElement(pubCtrl.Pages[1], 20, 1, 1, divMgr1.OutsideMarginInPrinterPixels,
                                               origTopOfPageTwoDiv1, divMgr1.AvailablePageHeightInPrinterPixels);
                        Page  origPg3 = pubCtrl.Pages[2];
                        int   origTopOfPageThreeDiv2 = origPg3.OffsetFromTopOfDiv(divMgr2);
                        Point origScrollPos          = pubCtrl.ScrollPosition;
                        Size  origScrollSize         = pubCtrl.AutoScrollMinSize;
                        pubCtrl.AdjustScrollRange(stream2, 0, 0, divMgr2.AvailablePageHeightInPrinterPixels, 0);
                        Assert.AreEqual(4, pubCtrl.PageCount);
                        Assert.IsFalse(pubCtrl.Pages[0].NeedsLayout);
                        Assert.IsFalse(pubCtrl.Pages[1].NeedsLayout,
                                       "This test simulates a call to AdjustScrollRange that happens in the middle of laying out this page, so it should not get flagged as needing layout.");
                        Assert.IsTrue(pubCtrl.Pages[2].NeedsLayout);
                        Assert.IsTrue(pubCtrl.Pages[3].NeedsLayout);
                        Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
                        Assert.AreEqual(origScrollSize.Height * 4 / 3, pubCtrl.AutoScrollMinSize.Height);
                        Assert.AreEqual(1, pubCtrl.Pages[0].PageElements.Count);
                        Assert.AreEqual(20, pubCtrl.Pages[0].PageElements[0].OffsetToTopPageBoundary);
                        Assert.AreEqual(1, pubCtrl.Pages[1].PageElements.Count);
                        Assert.AreEqual(origTopOfPageTwoDiv1, pubCtrl.Pages[1].OffsetFromTopOfDiv(divMgr1));
                        Assert.AreEqual(0, pubCtrl.Pages[1].OffsetFromTopOfDiv(divMgr2));
                        Assert.AreEqual(origPg3, pubCtrl.Pages[3],
                                        "A page should have been inserted between the original page 2 and page 3.");
                        Assert.AreEqual(0, pubCtrl.Pages[2].PageElements.Count);
                        Assert.AreEqual(divMgr2.AvailablePageHeightInPrinterPixels,
                                        pubCtrl.Pages[2].OffsetFromTopOfDiv(divMgr2),
                                        "Inserted page's offset from top of division 2 should be one ideal page from the top.");
                        Assert.AreEqual(0, pubCtrl.Pages[3].PageElements.Count);
                        Assert.AreEqual(origTopOfPageThreeDiv2 + divMgr2.AvailablePageHeightInPrinterPixels,
                                        pubCtrl.Pages[3].OffsetFromTopOfDiv(divMgr2));
                    }
        }
Пример #11
0
        public void AdjustScrollRange_ShrinkFirstDivOnPage()
        {
            DummyVwLayoutStream stream  = new DummyVwLayoutStream();
            GoofyDivision       divMgr  = new GoofyDivision(stream);
            DummyPublication    pubCtrl = new DummyPublication(null, divMgr, DateTime.Now);

            pubCtrl.PageHeight      = 72000 * 6;
            divMgr.m_overrideHeight = divMgr.AvailablePageHeightInPrinterPixels * 2;
            pubCtrl.CreatePages();
            Assert.AreEqual(3, pubCtrl.PageCount);
            Page pg1 = pubCtrl.Pages[0];
            Page pg2 = pubCtrl.Pages[1];
            Page pg3 = pubCtrl.Pages[2];

            divMgr.CallAddElement(pg1, divMgr.AvailablePageHeightInPrinterPixels - 20,
                                  1, 1, divMgr.InsideMarginInPrinterPixels, 20, divMgr.AvailablePageHeightInPrinterPixels);
            int origTopOfPageTwo = divMgr.AvailablePageHeightInPrinterPixels - 40;

            divMgr.CallAddElement(pg2, divMgr.AvailablePageHeightInPrinterPixels - 20,
                                  1, 1, divMgr.OutsideMarginInPrinterPixels, origTopOfPageTwo, divMgr.AvailablePageHeightInPrinterPixels);
            int origTopOfPageThree = divMgr.m_overrideHeight - 60;

            divMgr.CallAddElement(pg3, 40, 1, 1, divMgr.InsideMarginInPrinterPixels,
                                  origTopOfPageThree, divMgr.AvailablePageHeightInPrinterPixels);
            foreach (Page pg in pubCtrl.Pages)
            {
                Assert.AreEqual(pg.PageElements[0].OffsetToTopPageBoundary, pg.OffsetFromTopOfDiv(divMgr));
            }
            Point origScrollPos  = pubCtrl.ScrollPosition;
            Size  origScrollSize = pubCtrl.AutoScrollMinSize;

            // The following should cause the original page 2 to be deleted and adjust the top of
            // the original page 3 (now page 2) to be the same as the original top of page 2.
            pubCtrl.AdjustScrollRange(stream, 0, 0, -divMgr.AvailablePageHeightInPrinterPixels,
                                      origTopOfPageTwo - 2000);
            Assert.AreEqual(2, pubCtrl.PageCount);
            Assert.AreEqual(origScrollPos, pubCtrl.ScrollPosition);
            Assert.AreEqual(origScrollSize.Height * 2 / 3, pubCtrl.AutoScrollMinSize.Height);
            Assert.AreEqual(20, pg1.PageElements[0].OffsetToTopPageBoundary);
            Assert.AreEqual(pg3, pubCtrl.Pages[1]);
            Assert.AreEqual(origTopOfPageThree - divMgr.AvailablePageHeightInPrinterPixels,
                            pg3.PageElements[0].OffsetToTopPageBoundary);
            Assert.AreEqual(40, pg3.PageElements[0].LocationOnPage.Height);
            Assert.IsFalse(pg1.NeedsLayout);
            Assert.IsTrue(pg3.NeedsLayout);
        }
        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();
        }
Пример #13
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);
        }
Пример #14
0
        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();
        }