void OGRLIBKMLLayer::SetStyleTableDirectly( OGRStyleTable * poStyleTable ) { if( !bUpdate || m_poKmlLayer == NULL ) return; KmlFactory *poKmlFactory = m_poOgrDS->GetKmlFactory(); if( m_poStyleTable ) delete m_poStyleTable; m_poStyleTable = poStyleTable; if( m_poKmlLayer->IsA( kmldom::Type_Document ) ) { /***** delete all the styles *****/ DocumentPtr poKmlDocument = AsDocument( m_poKmlLayer ); const int nKmlStyles = static_cast<int>(poKmlDocument->get_schema_array_size()); for( int iKmlStyle = nKmlStyles - 1; iKmlStyle >= 0; iKmlStyle-- ) { poKmlDocument->DeleteStyleSelectorAt( iKmlStyle ); } /***** add the new style table to the document *****/ styletable2kml( poStyleTable, poKmlFactory, AsContainer( poKmlDocument ) ); } /***** mark the layer as updated *****/ bUpdated = true; m_poOgrDS->Updated(); }