void CLineNode::InsertMML_CM_apply__read_op( 
	AST_TXML_Tag *_item_node, QString _item_str, int readonly, long form )
{
	if( _item_node )
	{
		CLineNode *lbuf = new CLineNode();
		lbuf->read_mathml( _item_node );
		if( readonly )
			lbuf->iterateNodeTree( setRecursiveReadOnly_n_IgnoreContent, 0 );
		else if( form == __APPLY_RENDER_FORM_OP )
		{
			CNode *pNode = lbuf->GetFirstChild();
			while( pNode )
			{
				pNode->to_mathml_data.is_content = 
					CONTENT_MATHML_CONVERTION2__APPLY_OPERATOR_RECURSIVE_TREE;
				pNode = pNode->GetNext();
			}
		}
		PumpLine2Line( lbuf );
		delete lbuf;
	}
	else if( _item_str.length() )
		InsertMML_CM_create_markup_rigid_token( FBL_TAG_mo, _item_str );
}
Esempio n. 2
0
CNode* CParentNode::RemoveChild( long no )
{
	CNode *pNode = GetChild( no );

	if( pNode )
	{
		if( pNode->GetPrev() )
			pNode->GetPrev()->SetNext( pNode->GetNext() );
		if( pNode->GetNext() )
			pNode->GetNext()->SetPrev( pNode->GetPrev() );
		pNode->SetNext( NULL );
		pNode->SetPrev( NULL );
		pNode->SetParent( NULL );

		m_children.remove( no );
	}

	return pNode;
}
Esempio n. 3
0
int CFormulaNode::RunCalc()
{
	if( !getCalc() )
	{
		if( getCalcButtonID().length() )
			setMissButton();
		return 0;
	}
	if( !getCalc()->isPositionRunExist() ) return 0;

	QVector<RealFde> frames_ltrb;
	frames_ltrb.fill( 0.0, 4 * GetChildCount() );
	QVector<RealFde> frames_margin_ltrb;
	frames_margin_ltrb.fill( 0.0, 4 * GetChildCount() );
	QVector<RealFde> primitive_ltrb;
	primitive_ltrb.fill( 0.0, 4 * GetChildCount() );

	long i;
	CNode *pCurNode = GetFirstChild();
	if( pCurNode->GetType() != NODE_FRAME ) return 0;
	for( i = 0; i < GetChildCount() && pCurNode; pCurNode = pCurNode->GetNext(), i++ )
	{
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] = pCurNode->GetPosition().x();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] = pCurNode->GetPosition().y();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] = pCurNode->GetPosition().x() + pCurNode->GetSize().width();
		frames_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] = pCurNode->GetPosition().y() + pCurNode->GetSize().height();

		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] = ((CFrameNode*) pCurNode)->getLeftIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] = ((CFrameNode*) pCurNode)->getTopIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] = ((CFrameNode*) pCurNode)->getRightIndent();
		frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] = ((CFrameNode*) pCurNode)->getBottomIndent();
	}

	for( i = 0; i < getGraphPrimNumber(); i++ )
	{
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 0 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 1 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 2 ) );
		primitive_ltrb.push_back( getGraphPrimitivePositionCoord( i, 3 ) );
	}

	UseBtnCalc_InitByThisSize( *getCalc() );
	int ret = getCalc()->PositionRun( frames_ltrb, frames_margin_ltrb, primitive_ltrb );

	// reset parent margins
	UseBtnCalc_ChangeThisMargin( *getCalc() );

	for( i = 0; i < getGraphPrimNumber(); i++ )
	{
		if( getCalc()->isFormulaTypeGraphics( i ) )
		{
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Left,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Top,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Right,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] );
			setGraphPrimitivePositionCoord( 
				i, SVG_NodeTemplate_Parameter_Bottom,
				primitive_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] );
		}
	}

	if( ret )
	{
		pCurNode = GetFirstChild();
		i = 0;
		while( pCurNode )
		{
			((CFrameNode*) pCurNode)->setLeftIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Left ] );
			((CFrameNode*) pCurNode)->setTopIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Top ] );
			((CFrameNode*) pCurNode)->setRightIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Right ] );
			((CFrameNode*) pCurNode)->setBottomIndent( frames_margin_ltrb[ i * 4 + SVG_NodeTemplate_Parameter_Bottom ] );
			pCurNode = pCurNode->GetNext();
			i++;
		}
		RecalculateSizeChild();
	}

	return ret;
}
CFormulaNode* CLineNode::InsertMMLFormulaNode_MTABLE( AST_TXML_Tag *node )
{
	FXmlBtn *ptrFXmlBtn = 0;
	long _toolbar_no = -1, _button_no = -1, cb = 0;
	CFormulaNode *new_node = 0;
	CFrameNode *pFrameNode = 0;
	//CLineNode *parent_line = 0;
	CNode *pCurNode = 0;

	std::vector<long> line_length;
	AST_TXML_Compound *stmt = 0;

	if( ::mml_is_table_tag_correct( node, line_length ) )
	{
		long i, j, nColumn = 0, nRow = (long) line_length.size();
		for( i = 0; i < nRow; i++ )
			if( line_length[ i ] > nColumn ) nColumn = line_length[ i ];
		if( nRow <= 0 && nColumn <= 0 )
			return 0; // error: Internal error

		if( ::getCurrentToolBarSet()->getButtonCoordByID( QString(HF_BTNID_DEFAULT_TABLE_ASK_X_ASK), _toolbar_no, _button_no ) == -1 )
			return 0; // error: Error encountered: HF table formula is absent
		ptrFXmlBtn = ::getCurrentToolBarSet()->getButtonCalc( _toolbar_no, _button_no );
		if( !ptrFXmlBtn )
			return 0; // error: Internal error
		if( ptrFXmlBtn->getNodeType() != NODE_FORMULA )
			return 0; // error: Error encountered: HF table formula has a wrong format
		if( ptrFXmlBtn->isPropertyInput( FBL_ATTR_rows ) )
			ptrFXmlBtn->setRows( nRow );
		if( ptrFXmlBtn->isPropertyInput( FBL_ATTR_columns ) )
			ptrFXmlBtn->setColumns( nColumn );
		new_node = CreateFormulaNode( *ptrFXmlBtn );
		if( !new_node || new_node->GetChildCount() != nRow * nColumn )
			return 0; // error: Internal error
		pFrameNode = (CFrameNode*)GetFrameNode();
		if( pFrameNode ) new_node->SetLevel( pFrameNode->GetLevel() );

		// read attributes
		InsertMMLFormulaNode_MTABLE_readAttr( node, new_node );

		AddChild( new_node );
		pCurNode = new_node->GetFirstChild();
		cb = 0;
		for( i = 0; i < nRow; i++ )
		{
			for( j = 0; j < nColumn; j++ )
			{
				if( !pCurNode ) return 0; // error: Internal error
				if( pCurNode->GetType() == NODE_FRAME )
				{
					stmt = mml_get_table_tag_cell( node, i, j );
					pCurNode->read_mathml( stmt );
					if( ((CFrameNode*)pCurNode)->GetChildCount() > 1 &&
						((CFrameNode*)pCurNode)->GetFirstChild() )
						((CFrameNode*)pCurNode)->DeleteChild( ((CFrameNode*)pCurNode)->GetFirstChild() );
				}
				pCurNode = pCurNode->GetNext();
			}
		}
	}
	return new_node;
}
CFormulaNode* CLineNode::InsertMMLFormulaNode_OTHERS( FXmlBtn *ptrFXmlBtn, AST_TXML_Tag *node, int is_hidden )
{
	long cb = 0;
	CFormulaNode *new_node = 0/*, *box_node = 0, *child_node = 0*/;
	CFrameNode *pFrameNode = 0;
	//CLineNode *parent_line = 0;
	CNode *pCurNode = 0;

	if( !ptrFXmlBtn )
		return NULL; // error: Internal error

//	if( !node->getTags() || node->getTags()->getChildNumber() == 0 )
//		return NULL;	//error: Error encountered and repaired: Too few Child node->getTagName() in node

	if( ptrFXmlBtn->getNodeType() == NODE_FORMULA )
	{
		new_node = CreateFormulaNode( *ptrFXmlBtn );
		if( !new_node ) return NULL; // error: Internal error

		AST_TXML_Attribute *colorAttr = node->getAttribute( FBL_ATTR_color );
		QColor grPrimColor = QColor(0, 0, 0);
		if( colorAttr &&
			::mml_mathcolor2color( colorAttr->getStringValue(), grPrimColor, QColor(0, 0, 0) ) == 0 )
		{
			new_node->setLineColor( grPrimColor );
		}

		pFrameNode = (CFrameNode *)GetFrameNode();
		if( pFrameNode ) new_node->SetLevel( pFrameNode->GetLevel() );
		AddChild( new_node );

		if( node->getTags() && node->getTags()->getChildNumber() > 0 )
		{
			if( new_node->GetChildCount() < node->getTags()->getChildNumber() )
			{	//error: Error encountered and repaired: Too many Child node->getTagName() in node
				//delete new_node;
				//return;
				if( xml_strcmp( node->getTagName(), FBL_TAG_merror ) )
				{
					QString mess = _T("Too many children in ") + node->getTagName();
					InsertMMLFormulaNode_MERROR( mess );
				}
			}

			if( new_node->GetChildCount() > node->getTags()->getChildNumber() )
			{	//error: Error encountered and repaired: Too few Child node->getTagName() in node
				//delete new_node;
				//return;
				if( xml_strcmp( node->getTagName(), FBL_TAG_merror ) )
				{
					QString mess = _T("Too few children in ") + node->getTagName();
					InsertMMLFormulaNode_MERROR( mess );
				}
			}

			pCurNode = new_node->GetFirstChild();
			cb = 0;
			while( pCurNode && cb < new_node->GetChildCount() && cb < node->getTags()->getChildNumber() )
			{
				if( pCurNode->GetType() == NODE_FRAME && 
					node->getTags()->getChild( cb ) &&
					node->getTags()->getChild( cb )->getNodeType() == ASTT_TXML_Tag )
				{
					
					if( ((CFrameNode*)pCurNode)->GetFirstChild() )
						((CFrameNode*)pCurNode)->DeleteChild( ((CFrameNode*)pCurNode)->GetFirstChild() );
					pCurNode->read_mathml( (AST_TXML_Tag*)node->getTags()->getChild( cb ) );
				}
				pCurNode = pCurNode->GetNext();
				cb++;
			}
		}
	}
	if( new_node && is_hidden )
		new_node->setHidden();
	return new_node;
}