Skip to content

Commit d9a1654

Browse files
committed
dxf export: make encoding configurable (fixes #11578)
1 parent 957f1ac commit d9a1654

8 files changed

+259
-100
lines changed

python/core/dxf/qgsdxfexport.sip

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class QgsDxfExport
3232
~QgsDxfExport();
3333

3434
void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
35-
int writeToFile( QIODevice* d ); //maybe add progress dialog? //other parameters (e.g. scale, dpi)?
35+
int writeToFile( QIODevice *d, QString codec ); //maybe add progress dialog? other parameters (e.g. scale, dpi)?
3636

3737
void setSymbologyScaleDenominator( double d );
3838
double symbologyScaleDenominator() const;
@@ -43,7 +43,7 @@ class QgsDxfExport
4343
void setSymbologyExport( QgsDxfExport::SymbologyExport e );
4444
QgsDxfExport::SymbologyExport symbologyExport() const;
4545

46-
void setExtent( const QgsRectangle& r );
46+
void setExtent( const QgsRectangle &r );
4747
QgsRectangle extent() const;
4848

4949
//get closest entry in dxf palette
@@ -55,39 +55,39 @@ class QgsDxfExport
5555
void writeGroup( int code, int i ) /PyName=writeGroupInt/;
5656
//! @note available in python bindings as writeGroupDouble
5757
void writeGroup( int code, double d ) /PyName=writeGroupDouble/;
58-
void writeGroup( int code, const QString& s );
58+
void writeGroup( int code, const QString &s );
5959
void writeGroupCode( int code );
6060
void writeInt( int i );
6161
void writeDouble( double d );
62-
void writeString( const QString& s );
62+
void writeString( const QString &s );
6363
void writeGroup( int code, const QgsPoint &p, double z = 0.0, bool skipz = false ) /PyName=writeGroupPoint/;
6464
void writeGroup( QColor color, int exactMatch = 62, int rgbCode = 420, int transparencyCode = 440 );
6565

6666
int writeHandle( int code = 5, int handle = 0 );
6767

6868
//draw dxf primitives
69-
void writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color,
69+
void writePolyline( const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color,
7070
double width = -1, bool polygon = false );
7171

7272
void writePolygon( const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color );
7373

74-
void writeSolid( const QString& layer, QColor color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 );
74+
void writeSolid( const QString &layer, QColor color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4 );
7575

7676
//write line (as a polyline)
77-
void writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, QColor color, double width = -1 );
77+
void writeLine( const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, QColor color, double width = -1 );
7878

79-
void writePoint( const QString& layer, QColor color, const QgsPoint& pt );
79+
void writePoint( const QString &layer, QColor color, const QgsPoint &pt );
8080

8181
void writeFilledCircle( const QString &layer, QColor color, const QgsPoint &pt, double radius );
8282

83-
void writeCircle( const QString& layer, QColor color, const QgsPoint& pt, double radius, const QString &lineStyleName, double width );
83+
void writeCircle( const QString &layer, QColor color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width );
8484

85-
void writeText( const QString& layer, const QString& text, const QgsPoint& pt, double size, double angle, QColor color );
85+
void writeText( const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, QColor color );
8686

87-
void writeMText( const QString& layer, const QString& text, const QgsPoint& pt, double width, double angle, QColor color );
87+
void writeMText( const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, QColor color );
8888

8989
static double mapUnitScaleFactor( double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits );
9090

91-
static QString dxfLayerName( const QString& name );
91+
static QString dxfLayerName( const QString &name );
9292

9393
};

src/app/qgisapp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4180,7 +4180,7 @@ void QgisApp::dxfExport()
41804180
fileName += ".dxf";
41814181
QFile dxfFile( fileName );
41824182
QApplication::setOverrideCursor( Qt::BusyCursor );
4183-
if ( dxfExport.writeToFile( &dxfFile ) == 0 )
4183+
if ( dxfExport.writeToFile( &dxfFile, d.encoding() ) == 0 )
41844184
{
41854185
messageBar()->pushMessage( tr( "DXF export completed" ), QgsMessageBar::INFO, 4 );
41864186
}

src/app/qgsdxfexportdialog.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
408408

409409
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
410410
restoreGeometry( s.value( "/Windows/DxfExport/geometry" ).toByteArray() );
411+
mEncoding->addItems( QgsDxfExport::encodings() );
412+
mEncoding->setCurrentIndex( mEncoding->findText( s.value( "qgis/lastDxfEncoding", "CP1252" ).toString() ) );
411413
}
412414

413415

@@ -541,4 +543,10 @@ void QgsDxfExportDialog::saveSettings()
541543
s.setValue( "qgis/lastDxfSymbologyMode", mSymbologyModeComboBox->currentIndex() );
542544
s.setValue( "qgis/lastSymbologyExportScale", mScaleWidget->scale() );
543545
s.setValue( "qgis/lastDxfMapRectangle", mMapExtentCheckBox->isChecked() );
546+
s.setValue( "qgis/lastDxfEncoding", mEncoding->currentText() );
547+
}
548+
549+
QString QgsDxfExportDialog::encoding() const
550+
{
551+
return mEncoding->currentText();
544552
}

src/app/qgsdxfexportdialog.h

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
8585
QgsDxfExport::SymbologyExport symbologyMode() const;
8686
QString saveFile() const;
8787
bool exportMapExtent() const;
88+
QString encoding() const;
8889

8990
public slots:
9091
/** change the selection of layers in the list */

0 commit comments

Comments
 (0)