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