SVG line export, export defaults to all if none selected

[email protected] Sat, 2 Nov 2002 14:34:07 -0800
Newsgroups gmane.comp.lib.ivtools.patches
Message-ID <a04320415b9ea034cbf97@[12.236.206.76]>
Patch:    ivtools-021007-johnston-070
For:      ivtools-1.0.6
Author:   [email protected]
Subject:  SVG line export, export defaults to all if none selected
Requires:

This is an intermediate patch to ivtools-1.0.6.  To apply, cd to the
top-level directory of the ivtools source tree (the directory with src
and config subdirs), and apply like this:

         patch -p0 <ThisFile

Summary of Changes:

- for those interested in playing along at home, ivtools now supports
export of line graphics via SVG, with support for variable widths,
colors, and dash-patterns.

- the export dialog box now defaults to everything if nothing is selected
in the drawing editor.

Index: IVGlyph/exportchooser.c
diff -c IVGlyph/exportchooser.c:1.2 IVGlyph/exportchooser.c:1.3
*** IVGlyph/exportchooser.c:1.2 Thu Sep 26 17:56:16 2002
--- src/IVGlyph/exportchooser.c Mon Oct  7 13:01:21 2002
***************
*** 95,101 ****

   boolean ExportChooser::svg_format() {
       return ((ExportChooserImpl*)impl_)->_obse
!       ? 
strncmp(((ExportChooserImpl*)impl_)->_obse->labelvalue().string(), 
"XSVG", 3) == 0
         : false;
   }

--- 95,101 ----

   boolean ExportChooser::svg_format() {
       return ((ExportChooserImpl*)impl_)->_obse
!       ? 
strncmp(((ExportChooserImpl*)impl_)->_obse->labelvalue().string(), 
"SVG", 3) == 0
         : false;
   }

Index: OverlayUnidraw/ovarrow.c
diff -c OverlayUnidraw/ovarrow.c:1.2 OverlayUnidraw/ovarrow.c:1.3
*** OverlayUnidraw/ovarrow.c:1.2        Fri Sep 27 11:57:05 2002
--- src/OverlayUnidraw/ovarrow.c        Mon Oct  7 13:01:56 2002
***************
*** 344,361 ****
       head = comp->GetArrowLine()->Head();
       tail = comp->GetArrowLine()->Tail();

!     out << "arrowline(";
!     out << x0 << "," << y0 << "," << x1 << "," << y1;
!     if (arrow_scale != 1 )
         out << " :arrowscale " << arrow_scale;
!     if (head)
         out << " :head";
!     if (tail)
         out << " :tail";
!     MinGS(out);
!     Annotation(out);
!     Attributes(out);
!     out << ")";

       return out.good();
   }
--- 344,373 ----
       head = comp->GetArrowLine()->Head();
       tail = comp->GetArrowLine()->Tail();

!     if (!svg_format()) {
!
!       out << "arrowline(";
!       out << x0 << "," << y0 << "," << x1 << "," << y1;
!       if (arrow_scale != 1 )
         out << " :arrowscale " << arrow_scale;
!       if (head)
         out << " :head";
!       if (tail)
         out << " :tail";
!       MinGS(out);
!       Annotation(out);
!       Attributes(out);
!       out << ")";
!
!     } else {
!
!       out << "<line x1=\"" << x0 << "\" y1=\"" << y0 << "\" x2=\"" 
<< x1 << "\" y2=\"" << y1 << "\" ";
!       MinGS(out);
!       Annotation(out);
!       Attributes(out);
!       out << " />\n";
!     }
!

       return out.good();
   }
Index: OverlayUnidraw/ovexport.c
diff -c OverlayUnidraw/ovexport.c:1.2 OverlayUnidraw/ovexport.c:1.3
*** OverlayUnidraw/ovexport.c:1.2       Thu Sep 26 17:56:41 2002
--- src/OverlayUnidraw/ovexport.c       Mon Oct  7 13:01:56 2002
***************
*** 98,109 ****
--- 98,111 ----
   void OvExportCmd::Execute () {
       Editor* ed = GetEditor();

+ #if 0
       Selection* s = ed->GetSelection();
       if (s->IsEmpty()) {
         GAcknowledgeDialog::post
         (ed->GetWindow(), "Nothing selected for export", nil, "no selection");
         return;
       }
+ #endif

       Style* style;
       boolean reset_caption = false;
***************
*** 170,234 ****
       Selection* s = editor->GetSelection();
       OverlayIdrawComp* real_top = (OverlayIdrawComp*)editor->GetComponent();
       boolean ok = false;

!     if (!s->IsEmpty()) {
!       OverlayIdrawComp* false_top = new OverlayIdrawComp();
!       Iterator i;
!       s->First(i);
!       while (!s->Done(i)) {
!           if (chooser_->idraw_format() || chooser_->postscript_format())
!               false_top->Append(new 
OverlayComp(s->GetView(i)->GetGraphicComp()->GetGraphic()->Copy()));
!           else
! 
false_top->Append((OverlayComp*)s->GetView(i)->GetGraphicComp()->Copy());
!           s->Next(i);
!       }

!       OverlayPS* ovpsv;
!       if (chooser_->idraw_format() || chooser_->postscript_format())
!           ovpsv = (OverlayPS*) false_top->Create(POSTSCRIPT_VIEW);
!       else
!           ovpsv = (OverlayPS*) false_top->Create(SCRIPT_VIEW);
!         if (ovpsv != nil) {
!
!             filebuf fbuf;
!           char* tmpfilename;
!
!           if (chooser_->to_printer()) {
!               tmpfilename = tmpnam(nil);
!               false_top->SetPathName(tmpfilename);
!               ok = fbuf.open(tmpfilename, output) != 0;
!           } else {
!               ok = fbuf.open(pathname, output) != 0;
!           }
!
!             if (ok) {
!                 ostream out(&fbuf);
!                 false_top->Attach(ovpsv);
!               ovpsv->SetCommand(this);
!               if (!chooser_->idraw_format() && 
!chooser_->postscript_format())
! 
((OverlayIdrawScript*)ovpsv)->SetByPathnameFlag(chooser_->by_pathname_flag());
!                 ovpsv->Update();
!                 ok = ovpsv->Emit(out);
!               fbuf.close();
!
!               if (chooser_->to_printer()) {
!                   char cmd[CHARBUFSIZE];
!                   if (strstr(pathname, "%s")) {
!                       char buf[CHARBUFSIZE];
!                       sprintf(buf, pathname, tmpfilename);
!                       sprintf(cmd, "(%s;rm %s)&", buf, tmpfilename);
!                   } else
!                       sprintf(cmd, "(%s %s;rm %s)&", pathname, 
tmpfilename, tmpfilename);
!                   ok = system(cmd) == 0;
!               }
!             }
!             delete ovpsv;
         }
!
!       delete false_top;
       }
       return ok;
   }

   const char* OvExportCmd::format() { return chooser_->format(); }
   boolean OvExportCmd::idraw_format() { return chooser_->idraw_format(); }
--- 172,244 ----
       Selection* s = editor->GetSelection();
       OverlayIdrawComp* real_top = (OverlayIdrawComp*)editor->GetComponent();
       boolean ok = false;
+
+     boolean empty = s->IsEmpty();

!     OverlayIdrawComp* false_top = new OverlayIdrawComp();
!     Iterator i;
!     empty ? real_top->First(i) : s->First(i);
!     while (empty ? !real_top->Done(i) : !s->Done(i)) {
!       if (chooser_->idraw_format() || chooser_->postscript_format()) {
!       OverlayComp* oc = empty
!         ? new OverlayComp(real_top->GetComp(i)->GetGraphic()->Copy())
!         : new 
OverlayComp(s->GetView(i)->GetGraphicComp()->GetGraphic()->Copy());
!       false_top->Append(oc);
!       } else {
!       OverlayComp* oc = empty
!         ? (OverlayComp*)real_top->GetComp(i)->Copy()
!         : (OverlayComp*)s->GetView(i)->GetGraphicComp()->Copy();
!       false_top->Append(oc);
!       }
!       empty ? real_top->Next(i) : s->Next(i);
!     }
!
!     OverlayPS* ovpsv;
!     if (chooser_->idraw_format() || chooser_->postscript_format())
!       ovpsv = (OverlayPS*) false_top->Create(POSTSCRIPT_VIEW);
!     else
!       ovpsv = (OverlayPS*) false_top->Create(SCRIPT_VIEW);
!     if (ovpsv != nil) {
!
!       filebuf fbuf;
!       char* tmpfilename;
!
!       if (chooser_->to_printer()) {
!       tmpfilename = tmpnam(nil);
!       false_top->SetPathName(tmpfilename);
!       ok = fbuf.open(tmpfilename, output) != 0;
!       } else {
!       ok = fbuf.open(pathname, output) != 0;
!       }
!
!       if (ok) {
!       ostream out(&fbuf);
!       false_top->Attach(ovpsv);
!       ovpsv->SetCommand(this);
!       if (!chooser_->idraw_format() && !chooser_->postscript_format())
! 
((OverlayIdrawScript*)ovpsv)->SetByPathnameFlag(chooser_->by_pathname_flag());
!       ovpsv->Update();
!       ok = ovpsv->Emit(out);
!       fbuf.close();

!       if (chooser_->to_printer()) {
!         char cmd[CHARBUFSIZE];
!         if (strstr(pathname, "%s")) {
!           char buf[CHARBUFSIZE];
!           sprintf(buf, pathname, tmpfilename);
!           sprintf(cmd, "(%s;rm %s)&", buf, tmpfilename);
!         } else
!           sprintf(cmd, "(%s %s;rm %s)&", pathname, tmpfilename, tmpfilename);
!         ok = system(cmd) == 0;
         }
!       }
!       delete ovpsv;
       }
+
+     delete false_top;
       return ok;
   }

   const char* OvExportCmd::format() { return chooser_->format(); }
   boolean OvExportCmd::idraw_format() { return chooser_->idraw_format(); }
+ boolean OvExportCmd::svg_format() { return chooser_->svg_format(); }
Index: OverlayUnidraw/ovexport.h
diff -c OverlayUnidraw/ovexport.h:1.1 OverlayUnidraw/ovexport.h:1.2
*** OverlayUnidraw/ovexport.h:1.1       Fri Sep 13 09:51:22 2002
--- src/OverlayUnidraw/ovexport.h       Mon Oct  7 13:01:56 2002
***************
*** 57,62 ****
--- 57,64 ----
       // return string that indicates format: "drawtool" or "idraw".
       virtual boolean idraw_format();
       // true when format is "idraw".
+     virtual boolean svg_format();
+     // true when format is "svg".

   protected:
       ExportChooser* chooser_;
Index: OverlayUnidraw/ovpsview.c
diff -c OverlayUnidraw/ovpsview.c:1.2 OverlayUnidraw/ovpsview.c:1.3
*** OverlayUnidraw/ovpsview.c:1.2       Fri Sep 27 11:57:06 2002
--- src/OverlayUnidraw/ovpsview.c       Mon Oct  7 13:01:56 2002
***************
*** 27,32 ****
--- 27,34 ----
    */

   #include <OverlayUnidraw/ovclasses.h>
+ #include <OverlayUnidraw/ovexport.h>
+ #include <OverlayUnidraw/ovprint.h>
   #include <OverlayUnidraw/ovpsview.h>

   #include <UniIdraw/idarrows.h>
Index: OverlayUnidraw/ovpsview.h
diff -c OverlayUnidraw/ovpsview.h:1.2 OverlayUnidraw/ovpsview.h:1.3
*** OverlayUnidraw/ovpsview.h:1.2       Fri Sep 27 11:57:06 2002
--- src/OverlayUnidraw/ovpsview.h       Mon Oct  7 13:01:56 2002
***************
*** 63,70 ****
       virtual void Creator(ostream&);
       // output idraw as creator

!     boolean idraw_format();
!     void idraw_format(boolean);
   protected:
       OverlayPS(OverlayComp* = nil);
       static boolean _idraw_format;
--- 63,74 ----
       virtual void Creator(ostream&);
       // output idraw as creator

!     boolean idraw_format();
!     // true if exporting idraw EPS
!     void idraw_format(boolean);
!     // set flag for exporting idraw EPS
!     // can be overridden by flag associated with Command objects
!
   protected:
       OverlayPS(OverlayComp* = nil);
       static boolean _idraw_format;
Index: OverlayUnidraw/scriptview.c
diff -c OverlayUnidraw/scriptview.c:1.1 OverlayUnidraw/scriptview.c:1.2
*** OverlayUnidraw/scriptview.c:1.1     Fri Sep 13 09:51:26 2002
--- src/OverlayUnidraw/scriptview.c     Mon Oct  7 13:01:56 2002
***************
*** 1,5 ****
   /*
!  * Copyright (c) 1994-1998 Vectaport Inc.
    *
    * Permission to use, copy, modify, distribute, and sell this 
software and its
    * documentation for any purpose is hereby granted without fee, provided
--- 1,6 ----
   /*
!  * Copyright (C) 2002 Scott E. Johnston
!  * Copyright (C) 1994-1998 Vectaport Inc.
    *
    * Permission to use, copy, modify, distribute, and sell this 
software and its
    * documentation for any purpose is hereby granted without fee, provided
***************
*** 26,31 ****
--- 27,33 ----
   #include <OverlayUnidraw/scriptview.h>
   #include <OverlayUnidraw/ovcatalog.h>
   #include <OverlayUnidraw/ovclasses.h>
+ #include <OverlayUnidraw/ovexport.h>

   #include <ComTerp/parser.h>

***************
*** 66,71 ****
--- 68,74 ----
 
/*****************************************************************************/

   boolean OverlayScript::_ptlist_parens = true;
+ boolean OverlayScript::_svg_format = false;

   ClassId OverlayScript::GetClassId () { return OVERLAY_SCRIPT; }

***************
*** 81,88 ****
   }

   void OverlayScript::FillBg (ostream& out) {
!     int filled = GetOverlayComp()->GetGraphic()->BgFilled();
       out << " :fillbg " << filled;
   }

   void OverlayScript::Brush (ostream& out) {
--- 84,93 ----
   }

   void OverlayScript::FillBg (ostream& out) {
!   int filled = GetOverlayComp()->GetGraphic()->BgFilled();
!   if (!svg_format()) {
       out << " :fillbg " << filled;
+   }
   }

   void OverlayScript::Brush (ostream& out) {
***************
*** 90,106 ****

       if (brush != nil) {

!       if (brush->None()) {
!           out << " :nonebr";

         } else {
!           out << " :brush ";
!           int p = brush->GetLinePattern();
!           out << p << ",";

!           float w = brush->width();
!           out << w;
         }
       }
   }

--- 95,144 ----

       if (brush != nil) {

!       if (brush->None()) {
!
!       if (!svg_format()) {
!         out << " :nonebr";
!       }
!
!       } else {
!       int p = brush->GetLinePattern();
!       float w = brush->width();

+       if (!svg_format()) {
+         out << " :brush ";
+         out << p << ",";
+         out << w;
         } else {
!         out << "stroke-width: " << w << "; ";
!         out << "stroke-dasharray: ";
!
!         /* reverse dash bit field */
!         int reverse_p = 0;
!         for (int i=0; i<16; i++) {
!           reverse_p <<= 1;
!           reverse_p |= p & 0x1;
!           p >>= 1;
!         }

!         /* output count of on/off runs */
!         boolean lastbit=1;
!         int dashlen = 0;
!         for (int i=0; i<16; i++) {
!           boolean bit = reverse_p & 1;
!           if (lastbit==bit) dashlen++;
!           if (lastbit != bit || i==15)  {
!             out << dashlen;
!             if (i != 15 ) out << ", ";
!             dashlen=1;
!           }
!           lastbit = bit;
!           reverse_p >>= 1;
!         }
!         out << "; ";
         }
+
+       }
       }
   }

***************
*** 108,119 ****
       PSColor* fgcolor = (PSColor*) 
GetOverlayComp()->GetGraphic()->GetFgColor();

       if (fgcolor != nil) {
!       const char* name = fgcolor->GetName();
!       out << " :fgcolor \"" << name << "\"";

!       ColorIntensity r, g, b;
!       fgcolor->GetIntensities(r, g, b);
         out << "," << r << "," << g << "," << b;
       }
   }

--- 146,166 ----
       PSColor* fgcolor = (PSColor*) 
GetOverlayComp()->GetGraphic()->GetFgColor();

       if (fgcolor != nil) {
!
!       const char* name = fgcolor->GetName();
!       ColorIntensity r, g, b;
!       fgcolor->GetIntensities(r, g, b);

!       if (!svg_format()) {
!       out << " :fgcolor \"" << name << "\"";
         out << "," << r << "," << g << "," << b;
+       } else {
+       out << "stroke: rgb("
+           << (int)(r*100) << "%,"
+           << (int)(g*100) << "%,"
+           << (int)(b*100) << "%) ";
+       }
+
       }
   }

***************
*** 121,144 ****
       PSColor* bgcolor = (PSColor*) 
GetOverlayComp()->GetGraphic()->GetBgColor();

       if (bgcolor != nil) {
-       const char* name = bgcolor->GetName();
-       out << " :bgcolor \"" << name << "\"";

!       ColorIntensity r, g, b;
!       bgcolor->GetIntensities(r, g, b);
         out << "," << r << "," << g << "," << b;
       }
   }

   void OverlayScript::Font (ostream& out) {
       PSFont* font = (PSFont*) GetOverlayComp()->GetGraphic()->GetFont();
       if (font != nil) {
         const char* name = font->GetName();
-       out << " :font \"" << name << "\"" << ",";
         const char* pf = font->GetPrintFont();
-       out << "\"" << pf << "\"" << ",";
         const char* ps = font->GetPrintSize();
!       out << ps;
       }
   }

--- 168,200 ----
       PSColor* bgcolor = (PSColor*) 
GetOverlayComp()->GetGraphic()->GetBgColor();

       if (bgcolor != nil) {

!       const char* name = bgcolor->GetName();
!       ColorIntensity r, g, b;
!       bgcolor->GetIntensities(r, g, b);
!
!       if (!svg_format()) {
!       out << " :bgcolor \"" << name << "\"";
         out << "," << r << "," << g << "," << b;
+       }
+
       }
   }

   void OverlayScript::Font (ostream& out) {
       PSFont* font = (PSFont*) GetOverlayComp()->GetGraphic()->GetFont();
       if (font != nil) {
+
         const char* name = font->GetName();
         const char* pf = font->GetPrintFont();
         const char* ps = font->GetPrintSize();
!
!       if (!svg_format()) {
!         out << " :font \"" << name << "\"" << ",";
!         out << "\"" << pf << "\"" << ",";
!         out << ps;
!       }
!
       }
   }

***************
*** 146,202 ****
       PSPattern* pat = (PSPattern*) 
GetOverlayComp()->GetGraphic()->GetPattern();

       if (pat != nil) {


!       if (pat->None()) {
!           out << " :nonepat";
!       } else if (pat->GetSize() > 0) {
!           const int* data = pat->GetData();
!           int size = pat->GetSize();
!           char buf[BUFSIZ];
!           out << " :pattern ";
!
!           if (size <= 8) {
!               for (int i = 0; i < 8; i++) {
!                   sprintf(buf, "0x%02x", data[i] & 0xff);
!                   out << buf;
!                   if (i < 7 ) out << ",";
!               }
!
!           } else {
!               for (int i = 0; i < patternHeight; i++) {
!                   sprintf(buf, "0x%0*x", patternWidth/4, data[i]);
!                   if (i != patternHeight - 1) {
!                       out << buf << ",";
!                   } else {
!                       out << buf;
!                   }
!               }
             }
!
!       } else {
!           float graylevel = pat->GetGrayLevel();
!           out << " :graypat " << graylevel;
         }
       }
   }

   void OverlayScript::Transformation (ostream& out) {
!     Transformation(out, "transform");
! }
!
! void OverlayScript::Transformation (ostream& out, char* keyword, 
Graphic* gr) {
!     Transformer* t = gr ? gr->GetTransformer() : 
GetOverlayComp()->GetGraphic()->GetTransformer();
       Transformer identity;

       if (t != nil && *t != identity) {
!       char key[strlen(keyword)+4];
!       sprintf(key," :%s ",keyword);
!       float a00, a01, a10, a11, a20, a21;
!       t->GetEntries(a00, a01, a10, a11, a20, a21);
!       out << key;
         out << a00 << "," << a01 << "," << a10 << ",";
         out << a11 << "," << a20 << "," << a21;
       }
   }

--- 202,269 ----
       PSPattern* pat = (PSPattern*) 
GetOverlayComp()->GetGraphic()->GetPattern();

       if (pat != nil) {
+
+       if (pat->None()) {

+       if (!svg_format()) {
+         out << " :nonepat";
+       }

!       } else if (pat->GetSize() > 0) {
!
!       const int* data = pat->GetData();
!       int size = pat->GetSize();
!       char buf[BUFSIZ];
!
!       if (!svg_format()) {
!
!         out << " :pattern ";
!
!         if (size <= 8) {
!           for (int i = 0; i < 8; i++) {
!             sprintf(buf, "0x%02x", data[i] & 0xff);
!             out << buf;
!             if (i < 7 ) out << ",";
             }
!
!         } else {
!           for (int i = 0; i < patternHeight; i++) {
!             sprintf(buf, "0x%0*x", patternWidth/4, data[i]);
!             if (i != patternHeight - 1) {
!               out << buf << ",";
!             } else {
!               out << buf;
!             }
!           }
!         }
!       }
!
!       } else {
!       float graylevel = pat->GetGrayLevel();
!       if (!svg_format()) {
!         out << " :graypat " << graylevel;
         }
+       }
       }
   }

   void OverlayScript::Transformation (ostream& out) {
!     Graphic *gr = GetOverlayComp()->GetGraphic();
!     Transformer* t = gr ? gr->GetTransformer() : nil;
       Transformer identity;

       if (t != nil && *t != identity) {
!       float a00, a01, a10, a11, a20, a21;
!       t->GetEntries(a00, a01, a10, a11, a20, a21);
!       if (!svg_format()) {
!       out << " :transform ";
         out << a00 << "," << a01 << "," << a10 << ",";
         out << a11 << "," << a20 << "," << a21;
+       } else {
+       out << "transform=\"matrix(";
+       out << a00 << " " << a01 << " " << a10 << " ";
+       out << a11 << " " << a20 << " " << a21 << ")\"";
+       }
       }
   }

***************
*** 205,213 ****
       const char* anno = comp->GetAnnotation();
       if (!anno)
           return;
!     out << " :annotation " << "\n";
!     int indent = Indent(out);
!     ParamList::output_text(out, anno, indent);
   }

   OverlayScript* OverlayScript::CreateOverlayScript (OverlayComp* comp) {
--- 272,282 ----
       const char* anno = comp->GetAnnotation();
       if (!anno)
           return;
!     if (!svg_format()) {
!       out << " :annotation " << "\n";
!       int indent = Indent(out);
!       ParamList::output_text(out, anno, indent);
!     }
   }

   OverlayScript* OverlayScript::CreateOverlayScript (OverlayComp* comp) {
***************
*** 262,267 ****
--- 331,347 ----
     return true;
   }

+ boolean OverlayScript::svg_format() {
+     boolean format = OverlayScript::_svg_format;
+     Command* cmd = GetCommand();
+     if (cmd) {
+       if (GetCommand()->IsA(OV_EXPORT_CMD))
+       format = ((OvExportCmd*)GetCommand())->svg_format();
+     }
+     return format;
+ }
+
+ void OverlayScript::svg_format(boolean flag) { _svg_format = flag; }

 
/*****************************************************************************/

***************
*** 745,758 ****
   void OverlayScript::MinGS (ostream& out) {
       if (!DefaultGS()) {
         Clipboard* cb = GetGSList();
!       if (cb)
             out << " :gs " << MatchedGS(cb);
         else {
             FillBg(out);
             Brush(out);
             FgColor(out);
             BgColor(out);
             Pattern(out);
         }
       }
       Transformation(out);
--- 825,840 ----
   void OverlayScript::MinGS (ostream& out) {
       if (!DefaultGS()) {
         Clipboard* cb = GetGSList();
!       if (cb && !svg_format())
             out << " :gs " << MatchedGS(cb);
         else {
+           if (svg_format()) out << "style=\"";
             FillBg(out);
             Brush(out);
             FgColor(out);
             BgColor(out);
             Pattern(out);
+           if (svg_format()) out << "\" ";
         }
       }
       Transformation(out);
***************
*** 1164,1169 ****
--- 1246,1254 ----
   }

   boolean OverlayIdrawScript::Emit (ostream& out) {
+     if (svg_format())
+       return EmitSvg(out);
+
       out << "drawtool(";

       /* make list and output unique point lists */
***************
*** 1254,1257 ****
--- 1339,1386 ----
   boolean OverlayIdrawScript::GetByPathnameFlag() {
       return _by_pathname;
   }
+
+ boolean OverlayIdrawScript::EmitSvg (ostream& out) {
+   out << "<?xml version=\"1.0\"?>\n";
+   out << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0/EN\"\n";
+   out << " 
\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n";
+
+   Coord l, b, r, t;
+   GetBox(l, b, r, t);
+
+   Coord w = r - l;
+   Coord h = t - b;
+
+   out << "<svg width=\"" << w << "\" height=\"" << h << "\" >\n";
+   out << "<title>ivtools drawing</title>\n";
+   out << "<desc>ivtools drawing</desc>\n";
+
+   out << "<g transform=\"matrix(1 0 0 -1 " << -l << " " << t << ")\" >\n";
+
+   /* output graphic components */
+   boolean status = true;
+   Iterator i;
+   First(i);
+
+   static int readonly_symval = symbol_add("readonly");
+   for (; status && !Done(i); ) {
+     OverlayScript* ev = (OverlayScript*)GetView(i);
+     boolean readonly = false;
+     AttributeList *al;
+     if (al = ev->GetOverlayComp()->attrlist()) {
+       AttributeValue* av = al->find(readonly_symval);
+       if (av) readonly = av->is_true();
+     }
+     if (!readonly) {
+       Indent(out);
+       status = ev->Definition(out);
+     }
+     Next(i);
+   }
+
+   out << "</g>\n";
+   out << "</svg>\n";
+   return status;
+ }
+

Index: OverlayUnidraw/scriptview.h
diff -c OverlayUnidraw/scriptview.h:1.1 OverlayUnidraw/scriptview.h:1.2
*** OverlayUnidraw/scriptview.h:1.1     Fri Sep 13 09:51:26 2002
--- src/OverlayUnidraw/scriptview.h     Mon Oct  7 13:01:57 2002
***************
*** 1,5 ****
   /*
!  * Copyright (c) 1994-1997,1999 Vectaport Inc.
    *
    * Permission to use, copy, modify, distribute, and sell this 
software and its
    * documentation for any purpose is hereby granted without fee, provided
--- 1,6 ----
   /*
!  * Copyright (C) 2002 Scott E. Johnston
!  * Copyright (C) 1994-1997,1999 Vectaport Inc.
    *
    * Permission to use, copy, modify, distribute, and sell this 
software and its
    * documentation for any purpose is hereby granted without fee, provided
***************
*** 164,169 ****
--- 165,176 ----
       static void ptlist_parens(boolean flag) { _ptlist_parens = flag; }
       // set flag that indicates putting parens around pointlist's

+     boolean svg_format();
+     // true if exporting SVG
+     void svg_format(boolean);
+     // set flag for exporting SVG
+     // can be overridden by flag associated with Command objects
+
   protected:
       virtual void FillBg(ostream& out);
       virtual void Brush(ostream& out);
***************
*** 172,178 ****
       virtual void Font(ostream& out);
       virtual void Pattern(ostream& out);
       virtual void Transformation(ostream& out);
-     virtual void Transformation(ostream& out, char* keyword, 
Graphic* gr = nil);
       virtual void Annotation(ostream& out);

       void Attributes(ostream& out);
--- 179,184 ----
***************
*** 185,190 ****
--- 191,197 ----
       OverlayScript* _parent;

       static boolean _ptlist_parens;
+     static boolean _svg_format;
   };

   //: composite version of OverlayScript.
***************
*** 288,293 ****
--- 295,303 ----
       // return pointer to list of point lists that are stored in components.
       virtual Clipboard* GetPicList();
       // return pointer to list of composite graphics that are stored 
in components.
+
+     virtual boolean EmitSvg(ostream&);
+     // serialize entire document to ostream in SVG format.

       virtual ClassId GetClassId();
       virtual boolean IsA(ClassId);
*** /dev/null    Mon Oct 7 13:02:23 PDT 2002
--- patches/ivtools-021007-johnston-070
*************** patches/ivtools-021007-johnston-070
*** 0 ****
--- 1 ----
+ ivtools-021007-johnston-070


-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en