home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / flash078.zip / flashsource-r0_7_8.zip / FShape.cpp < prev    next >
C/C++ Source or Header  |  2001-08-02  |  16KB  |  743 lines

  1. #include <iostream>
  2. #include <strstream>
  3. #include "FShape.h"
  4.  
  5. std::ostream &operator<< (std::ostream &out, FlashFillStyle &data)
  6. {
  7.     data.Write(out);
  8.     return out;
  9. }
  10. std::istream &operator>> (std::istream &in,  FlashFillStyle &data)
  11. {
  12.     data.Read(in);
  13.     return in;
  14. }
  15.  
  16. void FlashFillStyleSolid::Write(std::ostream &out) 
  17. {
  18.     out.put((char)0);
  19.     if(GetTagVersion() > 2) r1.SetAlphaWriteMode(true);
  20.     else                    r1.SetAlphaWriteMode(false);
  21.     out << r1;
  22. }
  23. void FlashFillStyleSolid::Read(std::istream &in) 
  24. {
  25.     int c = in.get();
  26.     if(c==EOF || c != 0)
  27.     {
  28.         //throw
  29.     }
  30.     if(GetTagVersion() > 2) r1.SetAlphaWriteMode(true);
  31.     else                    r1.SetAlphaWriteMode(false);
  32.     in >> r1;
  33. }
  34. void FlashFillStyleBitmap::Write(std::ostream &out) 
  35. {
  36.     if(tiled) out.put((char)0x40);
  37.     else      out.put((char)0x41);
  38.     WRITE_UWORD(bitmapID);
  39.     out << matrix;
  40.  
  41. }
  42. void FlashFillStyleBitmap::Read(std::istream &in) 
  43. {
  44.     int c = in.get();
  45.     if(c == EOF)
  46.     {
  47.         //throw
  48.     }
  49.     else if(c == 0x40)
  50.     {
  51.         tiled = true;
  52.         type = 0x40;
  53.     }
  54.     else if(c == 0x41)
  55.     {
  56.         tiled = false;
  57.         type = 0x41;
  58.     }
  59.     else
  60.     {
  61.         //throw
  62.     }
  63.     READ_UWORD(bitmapID);
  64.  
  65.     in >> matrix;
  66. }
  67.  
  68.  
  69. std::ostream &operator<< (std::ostream &out, FlashGradientRecord &data)
  70. {
  71.     out.put(data.ratios.size());
  72.     for(unsigned int i = 0; i < data.ratios.size(); i++)
  73.     {
  74.         out.put(data.ratios[i]);
  75.         
  76.         if(data.GetTagVersion() > 2) data.colors[i].SetAlphaWriteMode(true);
  77.         else                         data.colors[i].SetAlphaWriteMode(false);
  78.  
  79.         out << data.colors[i];
  80.     }
  81.     return out;
  82. }
  83.  
  84. std::istream &operator>> (std::istream &in,  FlashGradientRecord &data)
  85. {
  86.     int c = in.get();
  87.     //if(i == EOF) throw;
  88.     for(int i = 0; i < c; i++)
  89.     {
  90.         int c2 = in.get();
  91.         //if(c2 == EOF) throw;
  92.  
  93.         data.ratios.push_back(c2);
  94.         data.colors.push_back(FlashRGB(0,0,0));
  95.  
  96.         if(data.GetTagVersion() > 2) data.colors[i].SetAlphaWriteMode(true);
  97.         else                         data.colors[i].SetAlphaWriteMode(false);
  98.  
  99.         in >> data.colors[i];
  100.     }
  101.     return in;
  102. }
  103.  
  104.  
  105. void FlashFillStyleGradient::Write(std::ostream &out)
  106. {
  107.     out.put((char)type);
  108.     gradient.SetTagVersion(GetTagVersion());
  109.     out << matrix;
  110.     out << gradient;
  111. }
  112.  
  113. void FlashFillStyleGradient::Read(std::istream &in)
  114. {
  115.     int c = in.get();
  116.     //if(c == EOF) throw;
  117.     //if(c != 0x10 || c != 0x12) throw;
  118.     
  119.     type = c;
  120.     
  121.     gradient.SetTagVersion(GetTagVersion());
  122.     in >> matrix;
  123.     in >> gradient;
  124. }
  125.  
  126. std::ostream &operator<< (std::ostream &out, FlashFillStyleArray &data)
  127. {
  128.     out.put((unsigned char)data.styles.size());
  129.     for(std::vector<FlashFillStyle*>::iterator i=data.styles.begin(); i!=data.styles.end(); i++)
  130.     {
  131.         (**i).SetTagVersion(data.GetTagVersion());
  132.         out << **i;
  133.     }
  134.     return out;
  135. }
  136. std::istream &operator>> (std::istream &in,  FlashFillStyleArray &data)
  137. {
  138.     SWORD c2 = in.get();
  139.     if((c2 == 0xff) && (data.GetTagVersion() > 1))
  140.     {
  141.         READ_SWORD(c2);        
  142.     }
  143.     //if(c == EOF) throw;
  144.     for(int i = 0; i < c2; i++)
  145.     {
  146.         //if(c == EOF) throw;
  147.         int c = in.get();    
  148.         /* FILL TYPES
  149.         0x00 - solid
  150.         0x10 - linear gradient
  151.         0x12 - radial gradient
  152.         0x40 - tiled bitmap
  153.         0x41 - clipped bitmap
  154.         */
  155.         FlashFillStyle *style;
  156.         if(c == 0x00)
  157.         {
  158.             in.putback(c);
  159.             FlashFillStyleSolid *tmp = new FlashFillStyleSolid();
  160.             data.gc.push_back(tmp);
  161.             tmp->SetTagVersion(data.GetTagVersion());
  162.             in >> *tmp;
  163.             style = tmp;
  164.  
  165.         }
  166.         else if(c == 0x10 || c == 0x12)
  167.         {
  168.             in.putback(c);
  169.             FlashFillStyleGradient *tmp = new FlashFillStyleGradient();
  170.             data.gc.push_back(tmp);
  171.             tmp->SetTagVersion(data.GetTagVersion());
  172.             in >> *tmp;
  173.             style = tmp;
  174.         }
  175.         else if(c == 0x40 || c == 0x41)
  176.         {            
  177.             in.putback(c);
  178.             FlashFillStyleBitmap *tmp = new FlashFillStyleBitmap();
  179.             data.gc.push_back(tmp);
  180.             tmp->SetTagVersion(data.GetTagVersion());
  181.             in >> *tmp;
  182.             style = tmp;
  183.         }
  184.         else
  185.         {
  186.             //throw
  187.         }
  188.         data.styles.push_back(style);
  189.     
  190.     }
  191.     return in;
  192. }
  193.  
  194. int FlashFillStyleArray::GetNBits()
  195. {
  196.     return GetBitSize(styles.size());
  197. }
  198.  
  199. std::ostream &operator<< (std::ostream &out, FlashLineStyle &data)
  200. {
  201.     WRITE_UWORD(data.width);
  202.  
  203.     if(data.GetTagVersion() > 2) data.color.SetAlphaWriteMode(true);
  204.     else                    data.color.SetAlphaWriteMode(false);
  205.  
  206.     out << data.color;
  207.     return out;
  208. }
  209. std::istream &operator>> (std::istream &in,  FlashLineStyle &data)
  210. {
  211.     READ_UWORD(data.width);
  212.  
  213.     if(data.GetTagVersion() > 2) data.color.SetAlphaWriteMode(true);
  214.     else                         data.color.SetAlphaWriteMode(false);
  215.  
  216.     
  217.     in >> data.color;
  218.     return in;
  219. }
  220.  
  221. int FlashLineStyleArray::GetNBits()
  222. {
  223.     return GetBitSize(styles.size());
  224. }
  225. std::ostream &operator<< (std::ostream &out, FlashLineStyleArray &data)
  226. {
  227.     out.put((char)data.styles.size());
  228.     for(std::vector<FlashLineStyle*>::iterator i=data.styles.begin(); i!=data.styles.end(); i++)
  229.     {
  230.         (**i).SetTagVersion(data.GetTagVersion());
  231.         out << **i;
  232.     }
  233.     return out;
  234. }
  235. std::istream &operator>> (std::istream &in,  FlashLineStyleArray &data)
  236. {
  237.     int c = in.get();
  238.     //if(c == EOF) throw;
  239.     for(int i = 0; i < c; i++)
  240.     {
  241.         FlashLineStyle *style = new FlashLineStyle();
  242.         data.gc.push_back(style);
  243.         style->SetTagVersion(data.GetTagVersion());        
  244.         in >> *style;
  245.         data.styles.push_back(style);        
  246.     }
  247.     return in;
  248. }
  249.  
  250.  
  251. void FlashShapeRecordStraight::Write(BitBuffer &out, FlashShapeCommon &data)
  252. {
  253.     int bits = max(GetBitSizeSigned(dx),GetBitSizeSigned(dy))-2;
  254.     if(bits < 1) bits = 1;
  255.     
  256.     BitBuffer &b=out;
  257.     b.Write(1,1);
  258.     b.Write(1,1);
  259.     
  260.     b.Write(bits,4);
  261.     if(dx==0)
  262.     {
  263.         b.Write(0,1);
  264.         b.Write(1,1);
  265.         b.Write(PackBitsSigned(dy),bits+2);
  266.     }
  267.     else if(dy==0)
  268.     {
  269.         b.Write(0,1);
  270.         b.Write(0,1);
  271.         b.Write(PackBitsSigned(dx),bits+2);
  272.     }
  273.     else
  274.     {
  275.         b.Write(1,1);
  276.         b.Write(PackBitsSigned(dx),bits+2);
  277.         b.Write(PackBitsSigned(dy),bits+2);
  278.     }
  279. }
  280. void FlashShapeRecordStraight::Read(BitStreamIn &in, FlashShapeCommon &data)
  281. {
  282.     int bits;    
  283.     in.Read(bits,4);
  284.  
  285.     bits+=2;
  286.  
  287.     int type;
  288.     in.Read(type, 1);
  289.     if(type == 0)
  290.     {
  291.         int type2;
  292.         in.Read(type2, 1);
  293.  
  294.         if(type2 == 1)
  295.         {
  296.             in.Read(dy,bits);
  297.             dy = UnPackBitsSigned(dy, bits);
  298.             dx = 0;
  299.         }
  300.         else if(type2 == 0)
  301.         {
  302.             in.Read(dx,bits);
  303.             dx = UnPackBitsSigned(dx, bits);
  304.             dy = 0;
  305.         }
  306.     }
  307.     else
  308.     {
  309.         in.Read(dx,bits);
  310.         dx = UnPackBitsSigned(dx, bits);
  311.         in.Read(dy,bits);
  312.         dy = UnPackBitsSigned(dy, bits);
  313.     }
  314. }
  315.  
  316. void FlashShapeRecordCurved::Write(BitBuffer &out, FlashShapeCommon &data)
  317. {
  318.     BitBuffer &b=out;
  319.     int bits = (max(max(GetBitSizeSigned(dxa),GetBitSizeSigned(dya)), 
  320.                     max(GetBitSizeSigned(dxc),GetBitSizeSigned(dyc))
  321.                     )
  322.                 )-2;
  323.     if(bits < 1) bits = 1;
  324.  
  325.  
  326.     b.Write(1,1);
  327.     b.Write(0,1);
  328.     
  329.     b.Write(bits,4);
  330.     b.Write(PackBitsSigned(dxc),bits+2);
  331.     b.Write(PackBitsSigned(dyc),bits+2);
  332.     b.Write(PackBitsSigned(dxa),bits+2);
  333.     b.Write(PackBitsSigned(dya),bits+2);
  334. }
  335. void FlashShapeRecordCurved::Read(BitStreamIn &in, FlashShapeCommon &data)
  336. {
  337.     BitStreamIn &b=in;
  338.     int bits;
  339.     b.Read(bits,4);
  340.     b.Read(dxc,bits+2);
  341.     dxc = UnPackBitsSigned(dxc, bits+2);
  342.     b.Read(dyc,bits+2);
  343.     dyc = UnPackBitsSigned(dyc, bits+2);
  344.     b.Read(dxa,bits+2);
  345.     dxa = UnPackBitsSigned(dxa, bits+2);
  346.     b.Read(dya,bits+2);
  347.     dya = UnPackBitsSigned(dya, bits+2);
  348. }
  349. FlashShapeRecordChange::FlashShapeRecordChange()
  350. {
  351.     newstyles=false;
  352.     linestyle=false;
  353.     fillstyle1=false;
  354.     fillstyle0=false;
  355.     moveto=false;
  356. }
  357.  
  358. FlashShapeRecordChange::FlashShapeRecordChange(SDWORD _dx, SDWORD _dy)
  359. {
  360.     newstyles=false;
  361.     linestyle=false;
  362.     fillstyle1=false;
  363.     fillstyle0=false; 
  364.     moveto=true;
  365.  
  366.     dx=_dx;
  367.     dy=_dy;
  368. }
  369.     
  370. void FlashShapeRecordChange::NewFillStyles(FlashFillStyleArray &a, FlashLineStyleArray &c)
  371. {
  372.     newstyles=true;
  373.     fillstyles=a;
  374.     linestyles=c;
  375. }
  376.  
  377. void FlashShapeRecordChange::ChangeFillStyle1(UWORD style)
  378. {
  379.     fillstyle1=true;
  380.     stylefill1=style;
  381. }
  382. void FlashShapeRecordChange::ChangeFillStyle0(UWORD style)
  383. {
  384.     fillstyle0=true;
  385.     stylefill0=style;
  386. }
  387.  
  388. void FlashShapeRecordChange::ChangeLineStyle(UWORD style)
  389. {
  390.     linestyle=true;
  391.     styleline=style;
  392. }
  393. void FlashShapeRecordChange::Write(BitBuffer &out, FlashShapeCommon &data)
  394. {
  395.     BitBuffer &b=out;
  396.     b.Write(0,1);
  397.     b.Write(newstyles,1);
  398.     b.Write(linestyle,1);
  399.     b.Write(fillstyle1,1);
  400.     b.Write(fillstyle0,1);
  401.     b.Write(moveto,1);
  402.     if(moveto)
  403.     {
  404.         int m = max(GetBitSizeSigned(dx),GetBitSizeSigned(dy));
  405.         b.Write(m,5);
  406.         b.Write(PackBitsSigned(dx),m);
  407.         b.Write(PackBitsSigned(dy),m);
  408.     }
  409.     if(fillstyle0)
  410.     {
  411.         b.Write(stylefill0, data.NBitsFillStyle);
  412.     }
  413.     if(fillstyle1)
  414.     {
  415.         b.Write(stylefill1, data.NBitsFillStyle);
  416.     }
  417.     if(linestyle)
  418.     {
  419.         b.Write(styleline,  data.NBitsLineStyle);
  420.     }
  421.     if(newstyles)
  422.     {
  423.         std::ostrstream str;
  424.         fillstyles.SetTagVersion(GetTagVersion());
  425.         linestyles.SetTagVersion(GetTagVersion());
  426.         str << fillstyles;
  427.         str << linestyles;
  428.         BitBuffer b2;
  429.         b2.Write(fillstyles.GetNBits(),4);
  430.         b2.Write(linestyles.GetNBits(),4);
  431.         str << b2;
  432.                 
  433.         b.Align();
  434.         b.WriteBytes(str.rdbuf()->str(),str.pcount());
  435.         
  436.         data.NBitsFillStyle = fillstyles.GetNBits();
  437.         data.NBitsLineStyle = linestyles.GetNBits();        
  438.     }
  439. }
  440. void FlashShapeRecordChange::Read(BitStreamIn &in, FlashShapeCommon &data)
  441. {
  442.     BitStreamIn &b=in;
  443.  
  444.     
  445.     newstyles = (data.flags & 16) == 16;
  446.     linestyle = (data.flags & 8) == 8;
  447.     fillstyle1 = (data.flags & 4) == 4;
  448.     fillstyle0 = (data.flags & 2) == 2;
  449.     moveto = (data.flags & 1) == 1;
  450.  
  451.     if(moveto)
  452.     {
  453.         int m;
  454.         b.Read(m,5);
  455.         b.Read(dx,m);
  456.         dx = UnPackBitsSigned(dx,m);
  457.         b.Read(dy,m);
  458.         dy = UnPackBitsSigned(dy,m);
  459.     }
  460.     if(fillstyle0)
  461.     {
  462.         b.Read(stylefill0, data.NBitsFillStyle);
  463.     }
  464.     if(fillstyle1)
  465.     {
  466.         b.Read(stylefill1, data.NBitsFillStyle);
  467.     }
  468.     if(linestyle)
  469.     {
  470.         b.Read(styleline,  data.NBitsLineStyle);
  471.     }
  472.     if(newstyles)
  473.     {
  474.         b.Align();
  475.         
  476.         fillstyles.SetTagVersion(GetTagVersion());
  477.         linestyles.SetTagVersion(GetTagVersion());
  478.  
  479.         b.GetStream() >> fillstyles;
  480.         b.GetStream() >> linestyles;
  481.                 
  482.         b.Read(data.NBitsFillStyle,4);
  483.         b.Read(data.NBitsLineStyle,4);        
  484.     }
  485.  
  486. }
  487.  
  488. void FlashShapeRecordEnd::Write(BitBuffer &out, FlashShapeCommon &data)
  489. {
  490.     BitBuffer &b=out;
  491.     b.Write(0,1);
  492.     b.Write(0,5);
  493. }
  494. void FlashShapeRecordEnd::Read(BitStreamIn &in, FlashShapeCommon &data)
  495. {
  496. }
  497.  
  498. FlashRect FlashShape::GetBounds()
  499. {
  500.         FlashRect prep;
  501.     SDWORD curx=0;
  502.     SDWORD cury=0;
  503.     
  504.     std::vector<flash_pair<SDWORD, SDWORD> > coords;
  505.     
  506.     for(std::vector<flash_pair<int,long> >::iterator i = record_sequencer.begin(); i != record_sequencer.end(); i++)
  507.     {
  508.         if((*i).first==0)
  509.         {
  510.             FlashShapeRecordChange &rec = record_change[(*i).second];
  511.             if(rec.moveto)
  512.             {
  513.                 coords.push_back(flash_pair<SDWORD,SDWORD>(rec.dx,rec.dy));
  514.                 curx = rec.dx;
  515.                 cury = rec.dy;                
  516.             }
  517.  
  518.         }
  519.         else if((*i).first==1)
  520.         {
  521.             FlashShapeRecordStraight &rec =record_straight[(*i).second];
  522.             curx+=rec.dx;
  523.             cury+=rec.dy;
  524.             coords.push_back(flash_pair<SDWORD,SDWORD>(curx, cury));
  525.  
  526.         }
  527.         else if((*i).first==2)
  528.         {
  529.             FlashShapeRecordCurved &rec =record_curved[(*i).second];
  530.             curx+=rec.dxc;
  531.             cury+=rec.dyc;
  532.             coords.push_back(flash_pair<SDWORD,SDWORD>(curx, cury));
  533.             curx+=rec.dxa;
  534.             cury+=rec.dya;
  535.             coords.push_back(flash_pair<SDWORD,SDWORD>(curx, cury));
  536.         }
  537.     }
  538.     
  539.     if(coords.size() > 0)
  540.     {
  541.         prep=FlashRect(coords[0].first,coords[0].second, coords[0].first, coords[0].second);
  542.         for(std::vector<flash_pair< SDWORD, SDWORD> >::iterator i=coords.begin(); i != coords.end(); i++)
  543.         {
  544.             prep.BoundWith(FlashRect((*i).first,(*i).second,(*i).first,(*i).second));
  545.         }
  546.     }
  547.     
  548.     return prep;
  549. }
  550. std::ostream &operator<< (std::ostream &out,  FlashShape &data)
  551. {
  552.     BitBuffer b;
  553.     FlashShapeCommon c;
  554.     c.NBitsFillStyle = 1;
  555.     c.NBitsLineStyle = 1;
  556.     b.Write(1,4);
  557.     b.Write(1,4);
  558.     for(std::vector<flash_pair<int,long> >::iterator i = data.record_sequencer.begin(); i != data.record_sequencer.end(); i++)
  559.     {
  560.         if((*i).first==0)
  561.         {
  562.             data.record_change[(*i).second].Write(b,c);
  563.         }
  564.         else if((*i).first==1)
  565.         {
  566.             data.record_straight[(*i).second].Write(b,c);
  567.         }
  568.         else if((*i).first==2)
  569.         {
  570.             data.record_curved[(*i).second].Write(b,c);
  571.         }
  572.     }
  573.     FlashShapeRecordEnd e;
  574.     e.Write(b,c);
  575.     out << b;
  576.     return out;
  577. }
  578. std::istream &operator>> (std::istream &in,   FlashShape &data)
  579. {
  580.     BitStreamIn b(&in);
  581.     FlashShapeCommon c;
  582.     c.NBitsFillStyle = 1;
  583.     c.NBitsLineStyle = 1;
  584.     int tmp;
  585.     b.Read(tmp,4);
  586.     b.Read(tmp,4);
  587.     
  588.     for(;;)
  589.     {
  590.         int type;
  591.         b.Read(type,1);
  592.         if(type == 0)
  593.         {
  594.             int flags;
  595.             b.Read(flags,5);
  596.             if(flags == 0)
  597.                 break;
  598.             else
  599.             {
  600.                 FlashShapeRecordChange r;
  601.                 c.flags = flags;
  602.                 r.Read(b, c);
  603.                 data.AddRecord(r);
  604.             }
  605.         }
  606.         if(type == 1)
  607.         {
  608.             int type2;
  609.             b.Read(type2,1);
  610.             if(type2 == 1)
  611.             {
  612.                 FlashShapeRecordStraight r;
  613.                 r.Read(b, c);
  614.                 data.AddRecord(r);
  615.             }
  616.             if(type2 == 0)
  617.             {
  618.                 FlashShapeRecordCurved r;
  619.                 r.Read(b, c);
  620.                 data.AddRecord(r);
  621.             }            
  622.         }
  623.     }
  624.     return in;
  625. }
  626.  
  627. std::ostream &operator<< (std::ostream &out,  FlashShapeWithStyle &data)
  628. {
  629.     data.fillstyles.SetTagVersion(data.GetTagVersion());
  630.     data.linestyles.SetTagVersion(data.GetTagVersion());
  631.     out << data.fillstyles;
  632.     out << data.linestyles;
  633.     BitBuffer b;
  634.     data.fillstyles.SetTagVersion(data.GetTagVersion());
  635.     b.Write(data.fillstyles.GetNBits(),4);
  636.     b.Write(data.linestyles.GetNBits(),4);
  637.     FlashShapeCommon c;
  638.     c.NBitsFillStyle = data.fillstyles.GetNBits();
  639.     c.NBitsLineStyle = data.linestyles.GetNBits();
  640.     c.DefineTagVersion = data.GetTagVersion();
  641.     for(std::vector<flash_pair<int,long> >::iterator i = data.record_sequencer.begin(); i != data.record_sequencer.end(); i++)
  642.     {
  643.         if((*i).first==0)
  644.         {            
  645.             data.record_change[(*i).second].SetTagVersion(data.GetTagVersion());
  646.             data.record_change[(*i).second].Write(b,c);
  647.         }
  648.         else if((*i).first==1)
  649.         {
  650.             data.record_straight[(*i).second].SetTagVersion(data.GetTagVersion());
  651.             data.record_straight[(*i).second].Write(b,c);
  652.         }
  653.         else if((*i).first==2)
  654.         {
  655.             data.record_curved[(*i).second].SetTagVersion(data.GetTagVersion());
  656.             data.record_curved[(*i).second].Write(b,c);
  657.         }
  658.     }
  659.     FlashShapeRecordEnd e;
  660.     e.Write(b,c);
  661.     out << b;
  662.     return out;
  663. }
  664. std::istream &operator>> (std::istream &in, FlashShapeWithStyle  &data)
  665. {
  666.     
  667.     data.fillstyles.SetTagVersion(data.GetTagVersion());
  668.     data.linestyles.SetTagVersion(data.GetTagVersion());
  669.     in >> data.fillstyles;
  670.     in >> data.linestyles;
  671.     BitStreamIn b(&in);
  672.     FlashShapeCommon c;
  673.     b.Read(c.NBitsFillStyle,4);
  674.     b.Read(c.NBitsLineStyle,4);
  675.  
  676.     c.DefineTagVersion = data.GetTagVersion();
  677.     
  678.     for(;;)
  679.     {
  680.         int type;
  681.         b.Read(type,1);
  682.         if(type == 0)
  683.         {
  684.             int flags;
  685.             b.Read(flags,5);
  686.             
  687.             if(flags == 0)
  688.             {
  689.                 break;
  690.             }
  691.             else
  692.             {
  693.                 FlashShapeRecordChange r;
  694.                 c.flags = flags;
  695.                 r.SetTagVersion(data.GetTagVersion());
  696.                 r.Read(b, c);
  697.                 data.AddRecord(r);
  698.             }
  699.         }
  700.         if(type == 1)
  701.         {
  702.             int type2;
  703.             b.Read(type2,1);
  704.             if(type2 == 1)
  705.             {
  706.                 FlashShapeRecordStraight r;
  707.                 r.SetTagVersion(data.GetTagVersion());
  708.                 r.Read(b, c);                
  709.                 data.AddRecord(r);
  710.             }
  711.             else if(type2 == 0)
  712.             {
  713.                 FlashShapeRecordCurved r;
  714.                 r.SetTagVersion(data.GetTagVersion());
  715.                 r.Read(b, c);
  716.                 data.AddRecord(r);
  717.             }            
  718.         }
  719.     }
  720.     return in;
  721. }
  722. std::ostream &operator<< (std::ostream &out, FlashTagDefineShapeBase &data)
  723. {
  724.     std::ostrstream str;
  725.     WRITE_UWORD2(data.GetID(),str);
  726.     str << data.shapes.GetBounds();
  727.     data.shapes.SetTagVersion(data.version);
  728.     str << data.shapes;
  729.     out << FlashTagHeader(data.header,str.pcount());
  730.     out.write(str.rdbuf()->str(),str.pcount());
  731.     return out;
  732. }
  733. std::istream &operator>> (std::istream &in,  FlashTagDefineShapeBase &data)
  734. {
  735.     UWORD id;
  736.     READ_UWORD(id);
  737.     data.SetID(id);    
  738.     in >> data.rimport;
  739.     data.shapes.SetTagVersion(data.version);
  740.     in >> data.shapes;
  741.     return in;
  742. }
  743.