Exemple #1
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));
                    }
        }
Exemple #2
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);
        }