mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
overwrite translate in output ps file for portrait
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2983 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
17f1b5a0ae
commit
a3750ec37c
@ -34,6 +34,7 @@
|
||||
#include <qevent.h>
|
||||
#include <qvaluelist.h>
|
||||
#include <qsplitter.h>
|
||||
#include <qregexp.h>
|
||||
|
||||
#include "qgisapp.h"
|
||||
#include "qgsproject.h"
|
||||
@ -270,10 +271,10 @@ void QgsComposer::print(void)
|
||||
// reset the page
|
||||
mPrinter->setPageSize ( psize );
|
||||
|
||||
// Overwrite the bounding box
|
||||
QFile f(mPrinter->outputFileName());
|
||||
f.open( IO_ReadWrite );
|
||||
|
||||
// Overwrite the bounding box
|
||||
f.open( IO_ReadWrite );
|
||||
Q_LONG offset = 0;
|
||||
Q_LONG size;
|
||||
bool found = false;
|
||||
@ -322,8 +323,60 @@ void QgsComposer::print(void)
|
||||
} else {
|
||||
QMessageBox::warning(this,"Error in Print", "Cannot find BoundingBox");
|
||||
}
|
||||
|
||||
f.close();
|
||||
|
||||
// Overwrite translate
|
||||
if ( mPrinter->orientation() == QPrinter::Portrait ) {
|
||||
f.open( IO_ReadWrite );
|
||||
offset = 0;
|
||||
found = false;
|
||||
|
||||
//Example:
|
||||
//0 4008 translate 1 -1 scale/defM matrix CM d } d
|
||||
QRegExp rx ( "^0 [^ ]+ translate ([^ ]+ [^ ]+) scale/defM matrix CM d \\} d" );
|
||||
|
||||
while ( !f.atEnd() ) {
|
||||
size = f.readLine ( s, 100 );
|
||||
if ( rx.search( s ) != -1 ) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
offset += size;
|
||||
}
|
||||
|
||||
if ( found ) {
|
||||
int trans;
|
||||
|
||||
trans = (int) ( 72 * mComposition->paperHeight() / 25.4 );
|
||||
s.sprintf( "0 %d translate %s scale/defM matrix CM d } d", trans, rx.cap(1).ascii() );
|
||||
|
||||
if ( s.length() > size ) {
|
||||
QMessageBox::warning(this,"Error in Print", "Cannot format translate");
|
||||
} else {
|
||||
if ( ! f.at(offset) ) {
|
||||
QMessageBox::warning(this,"Error in Print", "Cannot seek");
|
||||
} else {
|
||||
/* Write spaces (for case the size > s.length() ) */
|
||||
QString es;
|
||||
es.fill(' ', size-1 );
|
||||
f.flush();
|
||||
if ( f.writeBlock ( es.ascii(), size-1 ) < size-1 ) {
|
||||
QMessageBox::warning(this,"Error in Print", "Cannot overwrite translate");
|
||||
}
|
||||
f.flush();
|
||||
f.at(offset);
|
||||
f.flush();
|
||||
if ( f.writeBlock ( s.ascii(), s.length() ) < s.length()-1 ) {
|
||||
QMessageBox::warning(this,"Error in Print", "Cannot overwrite translate");
|
||||
}
|
||||
f.flush();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(this,"Error in Print", "Cannot find translate");
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
bool print = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user