@@ -1898,43 +1898,9 @@ int QgsProjectParser::layersAndStyles( QStringList& layers, QStringList& styles
1898
1898
1899
1899
QDomDocument QgsProjectParser::getStyle ( const QString& styleName, const QString& layerName ) const
1900
1900
{
1901
- QDomDocument myDocument = QDomDocument ();
1902
-
1903
- QDomNode header = myDocument.createProcessingInstruction ( " xml" , " version=\" 1.0\" encoding=\" UTF-8\" " );
1904
- myDocument.appendChild ( header );
1905
-
1906
- // Create the root element
1907
- QDomElement root = myDocument.createElementNS ( " http://www.opengis.net/sld" , " StyledLayerDescriptor" );
1908
- root.setAttribute ( " version" , " 1.1.0" );
1909
- root.setAttribute ( " xsi:schemaLocation" , " http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1910
- root.setAttribute ( " xmlns:ogc" , " http://www.opengis.net/ogc" );
1911
- root.setAttribute ( " xmlns:se" , " http://www.opengis.net/se" );
1912
- root.setAttribute ( " xmlns:xlink" , " http://www.w3.org/1999/xlink" );
1913
- root.setAttribute ( " xmlns:xsi" , " http://www.w3.org/2001/XMLSchema-instance" );
1914
- myDocument.appendChild ( root );
1915
-
1916
- QList<QgsMapLayer*> layerList = mapLayerFromStyle ( layerName, styleName );
1917
- if ( layerList.size () < 1 )
1918
- {
1919
- throw QgsMapServiceException ( " Error" , QString ( " The layer for the TypeName '%1' is not found" ).arg ( layerName ) );
1920
- }
1921
-
1922
- QgsMapLayer* currentLayer = layerList.at ( 0 );
1923
- QgsVectorLayer* layer = dynamic_cast <QgsVectorLayer*>( currentLayer );
1924
- if ( !layer )
1925
- {
1926
- throw QgsMapServiceException ( " Error" , QString ( " Could not get style because:\n %1" ).arg ( " Non-vector layers not supported yet" ) );
1927
- }
1928
- // Create the NamedLayer element
1929
- QDomElement namedLayerNode = myDocument.createElement ( " NamedLayer" );
1930
- root.appendChild ( namedLayerNode );
1931
-
1932
- QString errorMsg;
1933
- if ( !layer->writeSld ( namedLayerNode, myDocument, errorMsg ) )
1934
- {
1935
- throw QgsMapServiceException ( " Error" , QString ( " Could not get style because:\n %1" ).arg ( errorMsg ) );
1936
- }
1937
- return myDocument;
1901
+ QStringList layerList;
1902
+ layerList.append ( layerName );
1903
+ return getStyles ( layerList );
1938
1904
}
1939
1905
1940
1906
QDomDocument QgsProjectParser::getStyles ( QStringList& layerList ) const
0 commit comments