Ejemplo n.º 1
0
		protected int CreatePagesForDiv(DivisionLayoutMgr div, int iDiv,
			int spaceLeftFromPrevDiv)
		{
			lock (m_pages)
			{
				int pageNumber = m_pages.Count + 1;
				Debug.WriteLine(string.Format("Creating page {0} for division {1}, spaceLeftFromPrevDiv={2}", pageNumber, iDiv, spaceLeftFromPrevDiv));

				int dxpLayoutWidth = div.AvailableMainStreamColumWidthInPrinterPixels;
				int dypHeightOfDiv = div.EstimateHeight(dxpLayoutWidth);

				// If a division wants to start on a new page or if it doesn't share the
				// (footnote) substream then we have to start at the top of the new page.
				// REVIEW (EberhardB): This might not work if we have any other kind of
				// substream.
				if (div.StartAt != DivisionStartOption.Continuous || div.HasOwnedSubStreams)
					spaceLeftFromPrevDiv = 0;

				int dypLayoutHeight = div.AvailablePageHeightInPrinterPixels;
				int numberOfPages = PagesPerDiv(dypHeightOfDiv - spaceLeftFromPrevDiv, dypLayoutHeight);
				Debug.WriteLine(string.Format("dxpLayoutWidth={0}, dypHeightOfDiv={1}", dxpLayoutWidth, dypHeightOfDiv));
				Debug.WriteLine(string.Format("spaceLeftFromPrevDiv={0}, dypLayoutHeight={1}", spaceLeftFromPrevDiv, dypLayoutHeight));
				Debug.WriteLine(string.Format("numberOfPages={0}", numberOfPages));
				Debug.WriteLine(string.Format("div.TopMargin={0}, div.BottomMargin={1}", div.TopMarginInPrinterPixels, div.BottomMarginInPrinterPixels));
				for (int i = 0; i < numberOfPages; i++)
					m_pages.Add(CreatePage(this, iDiv, spaceLeftFromPrevDiv + i * dypLayoutHeight,
						pageNumber++, div.TopMarginInPrinterPixels, div.BottomMarginInPrinterPixels));

				return SpaceLeftOnLastPageForDiv(dypHeightOfDiv, dypLayoutHeight);
			}
		}