#include "HXmlElement.h" #ifdef COMPUTE_RTF_STRING # include #endif HXmlElement* HXmlElement::add_element( const char* pcText) { HXmlElement* psElement = new HXmlElement(pcText); this->LinkEndChild( psElement); return psElement; } HXmlElement* HXmlElement::add_element_with_id( const char* pcText, const char* pcTextId) { HXmlElement* psElement = new HXmlElement(pcText); this->LinkEndChild( psElement); psElement->SetAttribute("id", pcTextId); return psElement; } HXmlElement* HXmlElement::add_header( const char* pcText) { HXmlElement* psElementHeader = this->add_element("h2"); psElementHeader->LinkEndChild( new TiXmlText(pcText)); return psElementHeader; } #ifdef COMPUTE_RTF_STRING void HXmlElement::add_value( const char* pcValue, bool bRTF) { if(bRTF == false) { LinkEndChild( new TiXmlText(pcValue)); } char acAttributValue[1024]; //A3DVoid* pRTFData = NULL; A3DUTF8Char* pRTFString = (A3DUTF8Char*)pcValue; A3DMkpRTFField* pRTF = NULL; if (A3DMkpRTFFieldCreate(pRTFString, &pRTF) == A3D_SUCCESS) { A3DMkpRTFFieldData sRTFFieldData; A3D_INITIALIZE_DATA(A3DRTFFieldData, sRTFFieldData); //add_element( "rtf - "); while (A3DMkpRTFFieldGet(pRTF, &sRTFFieldData) == A3D_SUCCESS) { if(sRTFFieldData.m_pcFamilyName) sprintf(acAttributValue, "font-family:%s;", sRTFFieldData.m_pcFamilyName); SetAttribute("style", acAttributValue); LinkEndChild(new TiXmlText(sRTFFieldData.m_pcText)); A3DMkpRTFFieldGet(NULL, &sRTFFieldData); } //add_element( " -"); A3DMkpRTFFieldDelete(pRTF); } } #else // ifdef COMPUTE_RTF_STRING void HXmlElement::add_value( const char* pcValue, bool /*bRTF*/) { this->LinkEndChild( new TiXmlText(pcValue)); } #endif // ifdef COMPUTE_RTF_STRING void HXmlElement::add_value(double dValue, int idecimal) { char acValue[1024]; snprintf(acValue,sizeof(acValue), "%.*f", idecimal, dValue); return add_value(acValue); } void HXmlElement::add_value(int iValue) { char acValue[1024]; snprintf(acValue, sizeof(acValue), " %d", iValue); return add_value(acValue); } HXmlElement* HXmlElement::add_element_and_value( char* pcText, const char* pcValue, bool bRTF) { HXmlElement* psElement = new HXmlElement(pcText); psElement->add_value( pcValue, bRTF); //psElement->LinkEndChild( new TiXmlText(pcValue)); this->LinkEndChild( psElement); return psElement; } HXmlElement* HXmlElement::add_element_and_value( char* pcText, double dValue) { char acValue[1024]; snprintf(acValue, sizeof(acValue), "%f", dValue); return add_element_and_value( pcText, acValue); } HXmlElement* HXmlElement::add_element_and_value( char* pcText, int iValue) { char acValue[1024]; snprintf(acValue, sizeof(acValue), "%d", iValue); return add_element_and_value( pcText, acValue); } HXmlElement* HXmlElement::add_element_and_value( char* pcText, double dValue, int idecimal) { char acValue[1024]; snprintf(acValue, sizeof(acValue), "%.*f", idecimal, dValue); return add_element_and_value( pcText, acValue); } void HXmlTableRow::add_cell( const char* pcText, int span_count) { TiXmlElement* psCell = add_element( "TD"); psCell->LinkEndChild( new TiXmlText(pcText)); char acValue[1024]; if(span_count>0) { snprintf(acValue, sizeof(acValue), "%d", span_count); psCell->SetAttribute("rowspan", acValue); } else if(span_count<0) { snprintf(acValue, sizeof(acValue), "%d", -1*span_count); psCell->SetAttribute("colspan", acValue); } } void HXmlTableRow::add_cell( const char* pcText, int row_span, int col_span) { TiXmlElement* psCell = add_element( "TD"); psCell->LinkEndChild( new TiXmlText(pcText)); char acValue[1024]; snprintf(acValue, sizeof(acValue), "%d", row_span); psCell->SetAttribute("rowspan", acValue); snprintf(acValue, sizeof(acValue), "%d", col_span); psCell->SetAttribute("colspan", acValue); } void HXmlTableRow::add_cell_double( double dValue, int span_count) { char acValue[1024]; snprintf(acValue, sizeof(acValue), "%f", dValue); add_cell( acValue, span_count); } void HXmlTableRow::add_cell_int( int iValue, int span_count) { char acValue[1024]; snprintf(acValue, sizeof(acValue), "%d", iValue); add_cell( acValue, span_count); } void HXmlTableRow::add_cell_double_formated( double dValue, int idecimal, int span_count) { char acValue[1024]; snprintf(acValue, sizeof(acValue), "%.*f", idecimal, dValue); add_cell( acValue, span_count); } void HXmlTableRow::add_rtf_cell( char* /*pcText*/, int span_count) { add_cell( "rtf", span_count); }