@@ -1939,52 +1939,52 @@ QDomDocument QgsProjectParser::getStyle( const QString& styleName, const QString
1939
1939
1940
1940
QDomDocument QgsProjectParser::getStyles ( QStringList& layerList ) const
1941
1941
{
1942
- QDomDocument myDocument = QDomDocument ();
1943
-
1944
- QDomNode header = myDocument.createProcessingInstruction ( " xml" , " version=\" 1.0\" encoding=\" UTF-8\" " );
1945
- myDocument.appendChild ( header );
1946
-
1947
- // Create the root element
1948
- QDomElement root = myDocument.createElementNS ( " http://www.opengis.net/sld" , " StyledLayerDescriptor" );
1949
- root.setAttribute ( " version" , " 1.1.0" );
1950
- root.setAttribute ( " xsi:schemaLocation" , " http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1951
- root.setAttribute ( " xmlns:ogc" , " http://www.opengis.net/ogc" );
1952
- root.setAttribute ( " xmlns:se" , " http://www.opengis.net/se" );
1953
- root.setAttribute ( " xmlns:xlink" , " http://www.w3.org/1999/xlink" );
1954
- root.setAttribute ( " xmlns:xsi" , " http://www.w3.org/2001/XMLSchema-instance" );
1955
- myDocument.appendChild ( root );
1956
-
1957
- for ( int i = 0 ; i < layerList.size (); i++)
1942
+ QDomDocument myDocument = QDomDocument ();
1943
+
1944
+ QDomNode header = myDocument.createProcessingInstruction ( " xml" , " version=\" 1.0\" encoding=\" UTF-8\" " );
1945
+ myDocument.appendChild ( header );
1946
+
1947
+ // Create the root element
1948
+ QDomElement root = myDocument.createElementNS ( " http://www.opengis.net/sld" , " StyledLayerDescriptor" );
1949
+ root.setAttribute ( " version" , " 1.1.0" );
1950
+ root.setAttribute ( " xsi:schemaLocation" , " http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
1951
+ root.setAttribute ( " xmlns:ogc" , " http://www.opengis.net/ogc" );
1952
+ root.setAttribute ( " xmlns:se" , " http://www.opengis.net/se" );
1953
+ root.setAttribute ( " xmlns:xlink" , " http://www.w3.org/1999/xlink" );
1954
+ root.setAttribute ( " xmlns:xsi" , " http://www.w3.org/2001/XMLSchema-instance" );
1955
+ myDocument.appendChild ( root );
1956
+
1957
+ for ( int i = 0 ; i < layerList.size (); i++ )
1958
+ {
1959
+ QString layerName;
1960
+ QString typeName;
1961
+ layerName = layerList.at ( i );
1962
+ typeName = layerName.replace ( " " , " _" );
1963
+ QList<QgsMapLayer*> currentLayerList = mapLayerFromTypeName ( typeName );
1964
+ if ( currentLayerList.size () < 1 )
1965
+ {
1966
+ throw QgsMapServiceException ( " Error" , QString ( " The layer for the TypeName '%1' is not found" ).arg ( layerName ) );
1967
+ }
1968
+ for ( int j = 0 ; j < currentLayerList.size (); j++ )
1958
1969
{
1959
- QString layerName;
1960
- QString typeName;
1961
- layerName = layerList.at ( i );
1962
- typeName = layerName.replace (" " , " _" );
1963
- QList<QgsMapLayer*> currentLayerList = mapLayerFromTypeName ( typeName );
1964
- if ( currentLayerList.size () < 1 )
1970
+ QgsMapLayer* currentLayer = currentLayerList.at ( j );
1971
+ QgsVectorLayer* layer = dynamic_cast <QgsVectorLayer*>( currentLayer );
1972
+ if ( !layer )
1965
1973
{
1966
- throw QgsMapServiceException ( " Error" , QString ( " The layer for the TypeName '%1' is not found " ).arg ( layerName ) );
1974
+ throw QgsMapServiceException ( " Error" , QString ( " Could not get style because: \n %1 " ).arg ( " Non-vector layers not supported yet " ) );
1967
1975
}
1968
- for ( int j = 0 ; j < currentLayerList.size (); j++)
1969
- {
1970
- QgsMapLayer* currentLayer = currentLayerList.at ( j );
1971
- QgsVectorLayer* layer = dynamic_cast <QgsVectorLayer*>( currentLayer );
1972
- if ( !layer )
1973
- {
1974
- throw QgsMapServiceException ( " Error" , QString ( " Could not get style because:\n %1" ).arg ( " Non-vector layers not supported yet" ) );
1975
- }
1976
- // Create the NamedLayer element
1977
- QDomElement namedLayerNode = myDocument.createElement ( " NamedLayer" );
1978
- root.appendChild ( namedLayerNode );
1976
+ // Create the NamedLayer element
1977
+ QDomElement namedLayerNode = myDocument.createElement ( " NamedLayer" );
1978
+ root.appendChild ( namedLayerNode );
1979
1979
1980
- QString errorMsg;
1981
- if ( !layer->writeSld ( namedLayerNode, myDocument, errorMsg ) )
1982
- {
1983
- throw QgsMapServiceException ( " Error" , QString ( " Could not get style because:\n %1" ).arg ( errorMsg ) );
1984
- }
1980
+ QString errorMsg;
1981
+ if ( !layer->writeSld ( namedLayerNode, myDocument, errorMsg ) )
1982
+ {
1983
+ throw QgsMapServiceException ( " Error" , QString ( " Could not get style because:\n %1" ).arg ( errorMsg ) );
1985
1984
}
1986
1985
}
1987
- return myDocument;
1986
+ }
1987
+ return myDocument;
1988
1988
}
1989
1989
1990
1990
0 commit comments