@@ -129,6 +129,20 @@ bool QgsComposerAttributeTable::getFeatureAttributes( QList<QgsAttributeMap>& at
129
129
if ( mComposerMap && mShowOnlyVisibleFeatures )
130
130
{
131
131
selectionRect = mComposerMap ->extent ();
132
+ if ( mVectorLayer && mComposerMap ->mapRenderer ()
133
+ && mComposerMap ->mapRenderer ()->hasCrsTransformEnabled () )
134
+ {
135
+ // transform back to layer CRS
136
+ QgsCoordinateTransform coordTransform ( mVectorLayer ->crs (), mComposerMap ->mapRenderer ()->destinationCrs () );
137
+ try
138
+ {
139
+ selectionRect = coordTransform.transformBoundingBox ( selectionRect, QgsCoordinateTransform::ReverseTransform );
140
+ }
141
+ catch ( QgsCsException &cse )
142
+ {
143
+ return false ;
144
+ }
145
+ }
132
146
}
133
147
134
148
if ( mDisplayAttributes .size () < 1 )
@@ -221,6 +235,7 @@ bool QgsComposerAttributeTable::writeXML( QDomElement& elem, QDomDocument & doc
221
235
{
222
236
QDomElement composerTableElem = doc.createElement ( " ComposerAttributeTable" );
223
237
composerTableElem.setAttribute ( " showOnlyVisibleFeatures" , mShowOnlyVisibleFeatures );
238
+ composerTableElem.setAttribute ( " maxFeatures" , mMaximumNumberOfFeatures );
224
239
225
240
if ( mComposerMap )
226
241
{
@@ -281,7 +296,6 @@ bool QgsComposerAttributeTable::readXML( const QDomElement& itemElem, const QDom
281
296
return false ;
282
297
}
283
298
284
- mMaximumNumberOfFeatures = itemElem.attribute ( " maxFeatures" , " 5" ).toInt ();
285
299
mShowOnlyVisibleFeatures = itemElem.attribute ( " showOnlyVisibleFeatures" , " 1" ).toInt ();
286
300
287
301
// composer map
@@ -364,6 +378,10 @@ bool QgsComposerAttributeTable::readXML( const QDomElement& itemElem, const QDom
364
378
}
365
379
}
366
380
bool success = tableReadXML ( itemElem, doc );
381
+
382
+ // must be done here because tableReadXML->setSceneRect changes mMaximumNumberOfFeatures
383
+ mMaximumNumberOfFeatures = itemElem.attribute ( " maxFeatures" , " 5" ).toInt ();
384
+
367
385
emit itemChanged ();
368
386
return success;
369
387
}
0 commit comments