Пример #1
0
int InsertFromFormula( CFormulaNode *pFormulaNode, SelectNode &sn, int fUpCalc )
{
	if( pFormulaNode == NULL ) return -1;

	if( sn.GetNode()->GetType() == NODE_PLANETEXT ) BreakPlaneText( sn, 0 );

	Q_ASSERT( sn.GetNode()->GetType() == NODE_LINE );

	((CLineNode*) sn.GetNode())->InsertChild( sn.GetPosition(), pFormulaNode );

	pFormulaNode->RecalculateSize( fUpCalc );

	return 0;
}
Пример #2
0
int InsertFromText( CPlaneText *pPlaneText, SelectNode &sn, int fUpCalc )
{
	if( pPlaneText == NULL ) return -1;

	if( sn.GetNode()->GetType() == NODE_PLANETEXT ) BreakPlaneText( sn, 0 );

	Q_ASSERT( sn.GetNode()->GetType() == NODE_LINE );

	CNode *pPrev, *pNext;
	GetPrevNextInLine( sn, pPrev, pNext );

	((CLineNode*) sn.GetNode())->InsertChild( sn.GetPosition(), pPlaneText );

	sn.SetPosition( sn.GetPosition() + 1 );

	GlueText( sn, pPrev, 0 );
	if( pNext != NULL && (pPrev == NULL || pPrev->GetParent()->GetChildIndex( pNext ) != -1) )
		GlueText( sn, pNext->GetPrev(), 0 );

	sn.GetNode()->RecalculateSize( fUpCalc );

	return 0;
}
Пример #3
0
int InsertFromFrame( CFrameNode *pFrameNode, SelectNode &sn, int fUpCalc, SelectInfo *psi )
{
	if( pFrameNode == NULL ) return -1;

	if( pFrameNode->GetChildCount() == 1 )
	{
		Q_ASSERT( pFrameNode->GetFirstChild()->GetType() == NODE_LINE );
		return ::InsertFromLine( (CLineNode*) pFrameNode->GetChild( 0 ), sn, fUpCalc, psi );
	}
	else
	{
		Q_ASSERT( pFrameNode->GetChildCount() > 0 );

		BreakLine( sn, 0 );

		CNode *pPrev = sn.GetNode()->GetPrev();
		CNode *pNext = sn.GetNode();
		Q_ASSERT( pPrev );
		Q_ASSERT( pNext );

		CParentNode *pParentNode = sn.GetNode()->GetParent();

		int fRecalculateFull = (pFrameNode->GetLevel() != pParentNode->GetLevel());
		
		QVector<CNode*> children;
		pFrameNode->RecalculateSizeFull();
		pFrameNode->RemoveOrCopyChildren( children );

		if( psi )
		{
			psi->GetBegin().SetNode( children[ 0 ] );
			psi->GetBegin().SetPosition( 0 );
			psi->GetEnd() = sn;
		}

		pParentNode->InsertChildren( children, 
			pParentNode->GetChildIndex( sn.GetNode() ) );

		if( pNext->GetPrev() == pPrev )
		{
			Q_ASSERT( 0 );
		}
		else
		{
			if( GlueLine( sn, pNext->GetPrev(), 0, NULL ) == 0 )
				if( psi ) 
					psi->GetEnd() = sn;
			if( GlueLine( sn, pPrev, 0, NULL ) == 0 )
				if( psi ) 
					psi->GetBegin() = sn;
		}

		if( fRecalculateFull )
			pParentNode->RecalculateSizeFull();
		else
			pParentNode->RecalculateSize( 0 );

		if( pParentNode->GetParent() )
			pParentNode->GetParent()->RecalculateSize( fUpCalc );
		return 0;
	}
}
Пример #4
0
int InsertFromLine( CLineNode *pLineNode, SelectNode &sn, int fUpCalc, SelectInfo *psi )
{
	if( pLineNode == NULL ) return -1;

	if( sn.GetNode()->GetType() == NODE_PLANETEXT ) BreakPlaneText( sn, -1, NULL );

	Q_ASSERT( sn.GetNode()->GetType() == NODE_LINE );
	CLineNode *pLineTo = ((CLineNode*) sn.GetNode());

	CNode *pPrev, *pNext;
	GetPrevNextInLine( sn, pPrev, pNext );

	long nCount = pLineNode->GetChildCount();

	int fRecalculateFull = (pLineNode->GetLevel() != pLineTo->GetLevel());

	QVector<CNode*> children;
	pLineNode->RecalculateSizeFull();
	pLineNode->RemoveOrCopyChildren( children );

	if( psi )  psi->GetBegin() = sn;

	pLineTo->InsertChildren( children, sn.GetPosition() );

	sn.SetPosition( sn.GetPosition() + nCount );
	if( psi )  psi->GetEnd() = sn;

	int nRet = GlueText( sn, pPrev, 1, (psi ? &psi->GetBegin() : NULL));

	if( psi )
	{
		if( nRet == 0 )
		{
			psi->GetBegin() = sn;
		}
		else if( pPrev )
		{
			psi->GetBegin().SetNode( pPrev->GetParent() );
			psi->GetBegin().SetPosition( pPrev->GetParent()->GetChildIndex( pPrev ) + 1 );
		}
	}

	if( pPrev && pPrev->GetParent()->GetChildIndex( pNext ) != -1 )
	{
		nRet = GlueText( sn, pNext->GetPrev(), (nRet == -1), (psi ? &psi->GetEnd() : NULL) );

		if( psi )
		{
			if( nRet == 0 )
			{
				psi->GetEnd() = sn;
			}
			else 
			{
				psi->GetEnd().SetNode( pNext->GetParent() );
				psi->GetEnd().SetPosition( pNext->GetParent()->GetChildIndex( pNext ) );
			}
		}
	}

	if( fRecalculateFull )
		pLineTo->RecalculateSizeFull();
	else
		pLineTo->RecalculateSize( 1 );

	if( pLineTo->GetParent() )
		pLineTo->GetParent()->RecalculateSize( fUpCalc );

	return 0;
}
Пример #5
0
void CLRBracketSelection::notifyNodeOnCreateBracket( const SelectNode& sn, int isLeft )
{
	if( sn.GetNode() != 0 )
		sn.GetNode()->notifyNodeOnCreateBracket( sn.GetPosition(), isLeft );
}
Пример #6
0
void CLRBracketSelection::notifyNodeOnRemoveBracket( const SelectNode& sn )
{
	if( sn.GetNode() != NULL && m_rootNode.haveChild( sn.GetNode() ) )
		sn.GetNode()->notifyNodeOnRemoveBracket( sn.GetPosition() );
}