void fp_TOCContainer::clearScreen(void)
{
	if(getPage() == NULL)
	{
		return;
	}
	if(isThisBroken() && getContainer())
	{
		xxx_UT_DEBUGMSG(("Doing Clear Screen on Broken TOC %x \n",this));
		UT_sint32 iHeight = getHeight();
		UT_sint32 iWidth = getContainer()->getWidth();
		UT_sint32 srcX  = getX();
		UT_sint32 srcY = getY();
		if(getFirstBrokenTOC() == this)
		{
			srcY = getMasterTOC()->getY();
		}
		fp_Column * pCol = static_cast<fp_Column *>(getColumn());
		UT_sint32 x,y;
		getPage()->getScreenOffsets(pCol,x,y);
		x += srcX;
		y += srcY;
		getFillType().setWidthHeight(getGraphics(),iWidth,iHeight);
		getFillType().Fill(getGraphics(),srcX,srcY,x,y,iWidth,iHeight);
		xxx_UT_DEBUGMSG(("x %d y %d width %d height %d \n",x,y,iWidth,iHeight));
		return;
	}
	fp_Container * pCon = NULL;
	UT_sint32 i = 0;
	for(i=0; i< countCons(); i++)
	{
		pCon = static_cast<fp_Container *>(getNthCon(i));
		pCon->clearScreen();
	}
}
fp_TOCContainer * fp_TOCContainer::getFirstBrokenTOC(void) const
{
	if(isThisBroken())
	{
		return getMasterTOC()->getFirstBrokenTOC();
	}
	return m_pFirstBrokenTOC;
}
void fp_TOCContainer::setLastBrokenTOC(fp_TOCContainer * pBroke) 
{
	if(isThisBroken())
	{
		getMasterTOC()->setLastBrokenTOC(pBroke);
	}
	m_pLastBrokenTOC = pBroke;
}
/*!
 Draw container content
 \param pDA Draw arguments
 */
void fp_TOCContainer::draw(dg_DrawArgs* pDA)
{
	if(getPage() == NULL)
	{
		return;
	}
	if(!isThisBroken() && getFirstBrokenTOC())
	{
		getFirstBrokenTOC()->draw(pDA);
		return;
	}
	fp_TOCContainer * pMaster = this;
	if(getMasterTOC())
	{
		pMaster = getMasterTOC();
	}
	xxx_UT_DEBUGMSG(("TOC: Drawing broken TOC %x x %d, y %d width %d height %d \n",this,pDA->xoff,pDA->yoff,getWidth(),getHeight()));

//
// Only draw the lines in the clipping region.
//
	dg_DrawArgs da = *pDA;
	
	UT_uint32 count = pMaster->countCons();
	UT_sint32 iYStart = getYBreak();
	UT_sint32 iYBottom = getYBottom();
	xxx_UT_DEBUGMSG(("Drawing TOC, yBreak %d ybottom %d \n",iYStart,iYBottom));
	for (UT_uint32 i = 0; i<count; i++)
	{
		fp_ContainerObject* pContainer = static_cast<fp_ContainerObject*>(pMaster->getNthCon(i));
		if(pContainer->getY() < iYStart)
		{
			continue;
		}
		if(pContainer->getY() > iYBottom)
		{
			break;
		}
		da.xoff = pDA->xoff + pContainer->getX();
		da.yoff = pDA->yoff + pContainer->getY() - iYStart;
		pContainer->draw(&da);
	}
    _drawBoundaries(pDA);
}
void fp_TOCContainer::deleteBrokenAfter(bool bClearFirst)
{
	if (!isThisBroken())
	{
		if (getFirstBrokenTOC())
		{
			return getFirstBrokenTOC()->deleteBrokenAfter(bClearFirst);
		}
		return;
	}

	if (bClearFirst)
	{
		clearScreen();
		getMasterTOC()->clearBrokenContainers();
	}

	fp_TOCContainer * pBroke = static_cast<fp_TOCContainer *>(getNext());
	fp_TOCContainer * pNext = NULL;
	while(pBroke)
	{
		pNext = static_cast<fp_TOCContainer *> (pBroke->getNext());
		if (pBroke->getContainer())
		{
			UT_sint32 i = pBroke->getContainer()->findCon(pBroke);
			if (i >= 0)
			{
				pBroke->getContainer()->deleteNthCon(i);
				pBroke->setContainer(NULL);
			}
		}
		delete pBroke;
		pBroke = pNext;
	}

	setNext(NULL);
	if (!getPrev())
	{
		getMasterTOC()->setNext(NULL);
	}
	getMasterTOC()->setLastBrokenTOC(this);
	setYBottom(getTotalTOCHeight());
}
Ejemplo n.º 6
0
void fp_TOCContainer::setLastBrokenTOC(fp_TOCContainer * pBroke) 
{
	if(isThisBroken())
	{
		fp_TOCContainer * pMaster = getMasterTOC();
		pMaster->setLastBrokenTOC(pBroke);
		fp_TOCContainer * pNext = static_cast<fp_TOCContainer *>(pMaster);
		while(pNext)
		{
			pNext->setLastBrokenTOC( pBroke);
			pNext = static_cast<fp_TOCContainer *>(pNext->getNext());
		}
	}
	m_pLastBrokenTOC = pBroke;
}
Ejemplo n.º 7
0
void fp_TOCContainer::setFirstBrokenTOC(fp_TOCContainer * pBroke) 
{
	if(isThisBroken())
	{
		UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
		fp_TOCContainer * pMaster = getMasterTOC();
		pMaster->setFirstBrokenTOC(pBroke);
		fp_TOCContainer * pNext = static_cast<fp_TOCContainer *>(pMaster);
		while(pNext)
		{
			pNext->setFirstBrokenTOC( pBroke);
			pNext = static_cast<fp_TOCContainer *>(pNext->getNext());
		}
	}
	m_pFirstBrokenTOC = pBroke;

}
UT_sint32 fp_TOCContainer::getBrokenNumber(void)
{
	if(!isThisBroken())
	{
		return 0;
	}
	fp_TOCContainer * pTOC = getMasterTOC()->getFirstBrokenTOC();
	UT_sint32 i = 1;
	while(pTOC && pTOC != this)
	{
		pTOC = static_cast<fp_TOCContainer *>(pTOC->getNext());
		i++;
	}
	if(!pTOC)
	{
		return -1;
	}
	return i;
}
/*!
 * Overload the setY method
 */
void fp_TOCContainer::setY(UT_sint32 i)
{
	bool bIsFirstBroken = false;
	UT_sint32 iOldY = getY();
	xxx_UT_DEBUGMSG(("fp_TOCContainer: setY set to %d \n",i));
	if(isThisBroken())
	{
		xxx_UT_DEBUGMSG(("setY: getMasterTOC %x FirstBrokenTOC %x this %x \n",getMasterTOC(),getMasterTOC()->getFirstBrokenTOC(),this));
		//	if(getMasterTOC()->getFirstBrokenTOC() != this)
		{
			xxx_UT_DEBUGMSG(("setY: Later broken TOC set to %d \n",i));
			fp_VerticalContainer::setY(i);
			return;
		}
		bIsFirstBroken = true;
	}
//
// Create an initial broken TOC if none exists
//
	if(!bIsFirstBroken && (getFirstBrokenTOC() == NULL))
	{
		VBreakAt(0);
	}
	iOldY = getY();
	if(i == iOldY)
	{
		return;
	}
	clearScreen();
//
// FIXME: Do I need to force another breakSection or will happen 
// automatically?
//
	xxx_UT_DEBUGMSG(("Set Reformat 1 now from TOC %x in TOCLayout %x \n",this,getSectionLayout()));
	getSectionLayout()->setNeedsReformat(getSectionLayout());
	fp_VerticalContainer::setY(i);
	adjustBrokenTOCs();
}
Ejemplo n.º 10
0
/*!
 * The caller to this method requests a break at the vertical height
 * given. It returns the actual break height, which will always be
 * less than or equal to the requested height.
 */
UT_sint32 fp_TOCContainer::wantVBreakAt(UT_sint32 vpos)
{
	if(isThisBroken())
	{
		return getMasterTOC()->wantVBreakAt(vpos);
	}
	UT_sint32 count = countCons();
	UT_sint32 i =0;
	UT_sint32 iYBreak = vpos;
	fp_Line * pLine;
	for(i=0; i< count; i++)
	{
		pLine = static_cast<fp_Line *>(getNthCon(i));
		if((pLine->getY() <= vpos) && (pLine->getY() + pLine->getHeight() +pLine->getMarginAfter() > vpos))
		{
			//
			// Line overlaps break point. Find break here
			//
			iYBreak = pLine->getY();
		}
	}
	return iYBreak;
}
/*!
 * This method creates a new broken toccontainer, broken at the
 * offset given. 
 * If the new TOCcontainer is broken from a pre-existing 
 * broken TOC it is inserted into the holding vertical container after
 * the old broken TOC.
 * It also inserted into the linked list of containers in the vertical
 * container.
 * vpos is relative to the either the start of the TOC if it's the first
 * non-zero vpos or relative to the previous ybreak if it's further down.
 */
fp_ContainerObject * fp_TOCContainer::VBreakAt(UT_sint32 vpos)
{
//
// Do the case of creating the first broken TOC from the master TOC.
// 
	fp_TOCContainer * pBroke = NULL;
	if(!isThisBroken() && getLastBrokenTOC() == NULL)
	{
		if(getFirstBrokenTOC() != NULL)
		{
			UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
			return NULL;
		}
		pBroke = new fp_TOCContainer(getSectionLayout(),this);
		UT_DEBUGMSG(("SEVIOR:!!!!!!! First broken TOC %p \n",pBroke));
		pBroke->setYBreakHere(vpos);
		pBroke->setYBottom(fp_VerticalContainer::getHeight());
		// leave this in!		UT_ASSERT(pBroke->getHeight());
		setFirstBrokenTOC(pBroke);
		setLastBrokenTOC(pBroke);
		pBroke->setContainer(getContainer());
		static_cast<fp_VerticalContainer *>(pBroke)->setHeight(pBroke->getHeight());
		static_cast<fp_VerticalContainer *>(pBroke)->setY(getY());
		return pBroke;
	}
//
// Now do the case of breaking a Master TOC.
//
	if(getMasterTOC() == NULL)
	{
		return getLastBrokenTOC()->VBreakAt(vpos);
	}
	UT_sint32 iTotalHeight = getTotalTOCHeight();
	if (vpos >= iTotalHeight)
	{
		UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
		return NULL;
	}

	pBroke = new fp_TOCContainer(getSectionLayout(),getMasterTOC());
	getMasterTOC()->setLastBrokenTOC(pBroke);

	xxx_UT_DEBUGMSG(("SEVIOR!!!!!!!!!!!  New broken TOC %x \n",getLastBrokenTOC()));

//
// vpos is relative to the container that contains this height but we need
// to add in the height above it.
//
	setYBottom(getYBreak() + vpos -1);
	UT_ASSERT(getHeight() >0);
	pBroke->setYBreakHere(getYBreak()+vpos);
	pBroke->setYBottom(iTotalHeight);
	UT_ASSERT(pBroke->getHeight() > 0);
	UT_sint32 i = -1;
//
// The structure of TOC linked list is as follows.
// NULL <= Master <==> Next <==> Next => NULL
//          first 
// ie terminated by NULL's in the getNext getPrev list. The second
// broken TOC points and is pointed to by the Master TOC
// 
	pBroke->setPrev(this);
	fp_Container * pUpCon = NULL;
	if(getMasterTOC()->getFirstBrokenTOC() == this)
	{
		pUpCon = getMasterTOC()->getContainer();
		pBroke->setPrev(getMasterTOC());
		pBroke->setNext(NULL);
		getMasterTOC()->setNext(pBroke);
		setNext(pBroke);
		if (pUpCon)
		{
			i = pUpCon->findCon(getMasterTOC());
		}
	}
	else
	{
		pBroke->setNext(NULL);
		setNext(pBroke);
		if(getYBreak() == 0 )
		{
			UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
			pUpCon = getMasterTOC()->getContainer();
			if(pUpCon)
			{
				i = pUpCon->findCon(getMasterTOC());
			}
		}
		else
		{
			pUpCon = getContainer();
			if (pUpCon)
			{
				i = pUpCon->findCon(this);
			}
		}
	}
	if((i >= 0) && (i < pUpCon->countCons() -1))
	{
		pUpCon->insertConAt(pBroke,i+1);
	}
	else if((i >= 0) && (i == pUpCon->countCons() -1))
	{
		pUpCon->addCon(pBroke);
	}
	else
	{
		UT_DEBUGMSG(("Breaking a TOC that is not yet inserted\n"));
	}
	pBroke->setContainer(pUpCon);
	//
	// Now deal with issues from a container overlapping the top of the
	// of the new broken TOC.
	//
	// Skip this for now. Look at fp_TableContainer to see if it's needed later
	//
	static_cast<fp_VerticalContainer *>(pBroke)->setHeight(pBroke->getHeight());	
	return pBroke;
}