Exemple #1
0
// Load and save to an XML file
void CDrawPower::SaveXML(CXMLWriter &xml)
{
	xml.addTag(GetXMLTag());

	xml.addAttribute(_T("pos"), CDPoint(m_point_a));
	xml.addAttribute(_T("which"), which);
	xml.addAttribute(_T("direction"), dir);
	xml.addChildData(str);

	xml.closeTag();
}
//-------------------------------------------------------------------------
void CTinyCadDoc::SaveXML(CXMLWriter &xml, drawingCollection &drawing, BOOL Details, BOOL SaveSelect, BOOL SaveResources )
{
  // Write the objects to the file
  try
  {  
	xml.addTag(GetXMLTag());

	// If necessary write the header stamp
	if (Details) 
	{
		xml.addTag(_T("NAME"));
		xml.addChildData( m_sheet_name );
		xml.closeTag();

		xml.addTag(_T("DETAILS"));
		m_oDetails.WriteXML( xml );
		m_snap.SaveXML( xml );
		xml.closeTag();
	}

	if (SaveResources)
	{
		// Find out which resources are in use
		
		for( drawingIterator i = drawing.begin(); i != drawing.end(); i++ )
		{
			(*i)->TagResources();
		}

		// Save the resource details details
		theOptions.SaveFontsXML(xml);
		theOptions.SaveStylesXML(xml);
		theOptions.SaveFillStylesXML(xml);
		theOptions.SaveMetaFilesXML(xml);
	}

	// Only save the symbols if we are not saving
	// to a library or the header...
	if (Details)
	{
		theOptions.SaveSymbolsXML(xml);
	}

	if (Details)
	{
		theOptions.WriteXML( xml) ;
	}

	for( drawingIterator i = drawing.begin(); i != drawing.end(); i++ )
	{
		CDrawingObject* obj = *i;

		if (obj->GetType() != xError
			&& 	(Details || !obj->IsConstruction()) 
			&&  (!SaveSelect || IsSelected( obj )) )
		{

			// Now save the actual object data
			obj->SaveXML(xml);
		}
	}

	xml.closeTag();

  }
  catch ( CException *e) 
  {
	// Could not save the file properly
    e->ReportError();
    e->Delete();
  }
}