Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2109)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2110)
@@ -1,3 +1,10 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/05/12: Thomas Bretz
+
+   * mmain/MStatusDisplay.[h,cc]:
+     - implemented UpdatePSHeader
+
+
 
  2003/05/10: Thomas Bretz
Index: /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2109)
+++ /trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2110)
@@ -61,5 +61,5 @@
 #include "MStatusDisplay.h"
 
-#include <iostream.h>
+#include <fstream.h>              // fstream
 
 #include <TLine.h>                // TLine
@@ -1338,4 +1338,54 @@
 // --------------------------------------------------------------------------
 //
+// Insert the following two lines into the postscript header:
+//
+//   %%DocumentPaperSizes: a4
+//   %%Orientation: Landscape
+//
+void MStatusDisplay::UpdatePSHeader(const TString &name) const
+{
+    const TString newstr("%%DocumentPaperSizes: a4\n%%Orientation: Landscape");
+
+    fstream f(name, ios::in|ios::out|ios::nocreate);
+
+    TString str;
+    f >> str;
+
+    streampos p = f.tellg()+1;
+
+    char *c1 = new char[newstr.Length()];
+    char *c2 = new char[newstr.Length()];
+
+    f.read(c1, newstr.Length());
+
+    f.seekp(p);
+
+    f << newstr;
+
+    while (1)
+    {
+        streampos p1 = f.tellg();
+        f.read(c2, newstr.Length());
+        streampos p2 = f.tellg();
+        f.seekp(p1);
+        if (f)
+        {
+            f.write(c1, newstr.Length());
+            memcpy(c1, c2, newstr.Length());
+            continue;
+        }
+
+        f.clear();
+        f.write(c1, newstr.Length());
+        f.write(c2, p2-p1);
+        break;
+    }
+
+    delete c2;
+    delete c1;
+}
+
+// --------------------------------------------------------------------------
+//
 // In case of num<0 all tabs are written into the PS file. If num>0
 // the canvas in the corresponding tab is written to the file.
@@ -1367,8 +1417,4 @@
     TPostScript ps(name, 112);
     ps.SetBit(TPad::kPrintingPS);
-
-    //%%DocumentPaperSizes: a4
-    //%%Orientation: Portrait
-
     ps.PrintFast(13, "/nan {1} def ");
 
@@ -1479,4 +1525,5 @@
 
     ps.Close();
+    UpdatePSHeader(name);
 
     gVirtualPS = psave;
@@ -1749,2 +1796,3 @@
     return TGMainFrame::HandleEvent(event);
 }
+
Index: /trunk/MagicSoft/Mars/mmain/MStatusDisplay.h
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2109)
+++ /trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2110)
@@ -98,4 +98,6 @@
     void AddExtension(TString &name, const TString &ext, Int_t num) const;
 
+    void UpdatePSHeader(const TString &name) const;
+
     enum {
         kIsLocked = BIT(14)
