odf.cpp revision bf855a45a363791d2820b6b3a8ed7b1363bbd55c
/**
* OpenDocument <drawing> input and output
*
* This is an an entry in the extensions mechanism to begin to enable
* the inputting and outputting of OpenDocument Format (ODF) files from
* within Inkscape. Although the initial implementations will be very lossy
* do to the differences in the models of SVG and ODF, they will hopefully
* improve greatly with time.
*
*
* Authors:
* Bob Jamison
*
* Copyright (C) 2006 Bob Jamison
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "odf.h"
#include "clear-n_.h"
#include "inkscape.h"
#include "sp-path.h"
#include <style.h>
#include "libnr/n-art-bpath.h"
#include "xml/attribute-record.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
#include <vector>
#include "dom/io/domstream.h"
#include "dom/io/bufferstream.h"
//# Shorthand notation
namespace Inkscape
{
namespace Extension
{
namespace Internal
{
//########################################################################
//# O U T P U T
//########################################################################
/**
* This function searches the Repr tree recursively from the given node,
* and adds refs to all nodes with the given name, to the result vector
*/
void
{
if (nodeName == "image")
{
if (hrefs)
{
{
char buf[16];
if (ze)
{
}
else
{
}
}
}
}
#if 0
//Look for style values in the svg element
node->attributeList();
{
/*
if (styleTable.find(styleValue) != styleTable.end())
{
g_message("duplicate style");
}
else
{
char buf[16];
snprintf(buf, 15, "style%d", styleIndex++);
std::string styleName = buf;
//Map from value-->name . Looks backwards, i know
styleTable[styleValue] = styleName;
g_message("mapping '%s' to '%s'",
styleValue.c_str(), styleName.c_str());
}
*/
}
#endif
}
/**
* This function searches the Repr tree recursively from the given node,
* and adds refs to all nodes with the given name, to the result vector
*/
void
{
styleTable.clear();
}
{
outs.printf("<!DOCTYPE manifest:manifest PUBLIC \"-//OpenOffice.org//DTD Manifest 1.0//EN\" \"Manifest.dtd\">\n");
outs.printf("<manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\">\n");
outs.printf(" <manifest:file-entry manifest:media-type=\"application/vnd.oasis.opendocument.graphics\" manifest:full-path=\"/\"/>\n");
outs.printf(" <manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"content.xml\"/>\n");
outs.printf(" <manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"meta.xml\"/>\n");
{
{
return false;
}
if (ext == ".gif")
else if (ext == ".png")
}
//Make our entry
return true;
}
{
outs.printf("<style:style style:name=\"grx1\" style:family=\"graphic\" style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties draw:stroke=\"none\" draw:fill=\"solid\" draw:textarea-horizontal-align=\"center\" draw:textarea-vertical-align=\"middle\" draw:color-mode=\"standard\" draw:luminance=\"0%\" draw:contrast=\"0%\" draw:gamma=\"100%\" draw:red=\"0%\" draw:green=\"0%\" draw:blue=\"0%\" fo:clip=\"rect(0cm 0cm 0cm 0cm)\" draw:image-opacity=\"100%\" style:mirror=\"none\"/>\n");
//## Dump our style table
/*
std::map<std::string, std::string>::iterator iter;
for (iter = styleTable.begin() ; iter != styleTable.end() ; iter++)
{
outs.printf("<style:style style:name=\"%s\"", iter->second);
outs.printf(" style:family=\"graphic\" style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties");
outs.printf(" draw:fill=\"" + s.getFill() + "\"");
if (!s.getFill().equals("none"))
outs.printf(" draw:fill-color=\"" + s.getFillColor() + "\"");
outs.printf(" draw:stroke=\"" + s.getStroke() + "\"");
if (!s.getStroke().equals("none"))
{
outs.printf(" svg:stroke-width=\"" + s.getStrokeWidth() + "\"");
outs.printf(" svg:stroke-color=\"" + s.getStrokeColor() + "\"");
}
outs.printf("/>\n");
outs.printf("</style:style>\n");
}
*/
return true;
}
{
//# Get the SPItem, if applicable
if (!reprobj)
return true;
if (!SP_IS_ITEM(reprobj))
{
return true;
}
//# Do our stuff
if (SP_IS_SHAPE(item))
{
}
{
}
if (!curve)
return false;
//Inkscape::XML::Node *repr = sp_repr_new("svg:path");
/* Transformation */
//repr->setAttribute("transform", SP_OBJECT_REPR(item)->attribute("transform"));
/* Rotation center */
//sp_repr_set_attr(repr, "inkscape:transform-center-x", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-x"));
//sp_repr_set_attr(repr, "inkscape:transform-center-y", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-y"));
/* Definition */
//# Iterate through the children
{
return false;
}
return true;
}
{
//if (!writeStyle(outs))
// return false;
//if (!writeTree(outs, node))
// return false;
//Make our entry
return true;
}
/**
* Descends into the SVG tree, mapping things to ODF when appropriate
*/
void
{
if (!writeManifest(zf))
{
g_warning("Failed to write manifest");
return;
}
{
g_warning("Failed to write content");
return;
}
{
return;
}
}
/**
* This is the definition of PovRay output. This function just
* calls the extension system with the memory allocated XML that
* describes the data.
*/
void
{
"<inkscape-extension>\n"
"<id>org.inkscape.output.odf</id>\n"
"<output>\n"
"<extension>.odg</extension>\n"
"<mimetype>text/x-povray-script</mimetype>\n"
"</output>\n"
"</inkscape-extension>",
new OdfOutput());
}
/**
* Make sure that we are in the database
*/
bool
{
/* We don't need a Key
if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_POV))
return FALSE;
*/
return TRUE;
}
//########################################################################
//# I N P U T
//########################################################################
} //namespace Internal
} //namespace Extension
} //namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :