wpg-input.cpp revision 51dcbfb8ad170dd928a3abbd436899181d12971d
/* libwpg
* Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
* Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
*
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For further information visit http://libwpg.sourceforge.net
*/
/* "This product is not manufactured, approved, or supported by
* Corel Corporation or Corel Corporation Limited."
*/
#include <stdio.h>
#include "libwpg/WPGStreamImplementation.h"
using namespace libwpg;
public:
void endDocument();
void startLayer(unsigned int id);
private:
int m_gradientIndex;
void writeStyle();
};
{
}
{
printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
printf("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"");
printf("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ");
printf("xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
m_gradientIndex = 1;
}
void InkscapePainter::endDocument()
{
printf("</svg>\n");
}
{
}
{
{
printf("<defs>\n");
{
// round to nearest percentage
printf(" <stop offset=\"%d%%\" stop-color=\"#%02x%02x%02x\" />\n",
}
printf(" </linearGradient>\n");
// not a simple horizontal gradient
if(angle != -90.0)
{
printf("x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\" ");
printf("gradientUnits=\"objectBoundingBox\" >\n");
printf(" </linearGradient>\n");
}
printf("</defs>\n");
}
}
{
m_fillRule = rule;
}
{
}
void InkscapePainter::endLayer(unsigned int)
{
printf("</g>\n");
}
{
printf("<rect ");
writeStyle();
printf("/>\n");
}
{
printf("<ellipse ");
writeStyle();
printf("/>\n");
}
{
return;
{
printf("<line ");
writeStyle();
printf("/>\n");
}
else
{
printf("<polyline ");
printf("points=\"");
{
}
printf("\"\n");
writeStyle();
printf("/>\n");
}
}
{
printf("<path d=\"");
{
{
case WPGPathElement::MoveToElement:
break;
case WPGPathElement::LineToElement:
break;
case WPGPathElement::CurveToElement:
printf("C");
break;
default:
break;
}
}
printf("\" \n");
writeStyle();
printf("/>\n");
}
// create "style" attribute based on current pen and brush
void InkscapePainter::writeStyle()
{
printf("style=\"");
{
// alpha = 0 means opacity = 1.0, alpha = 256 means opacity = 0
}
{
printf("stroke-dasharray: ");
{
printf(", ");
}
printf("; ");
}
printf("fill: none; ");
printf("fill-rule: nonzero; ");
printf("fill-rule: evenodd; ");
}
{
if (argc < 2)
{
printf("usage: wpg2svg <WordPerfect Graphic>\n");
return -1;
}
{
if (olestream)
{
delete input;
}
}
{
return 1;
}
return 0;
}