summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 177a787)
raw | patch | inline | side by side (parent: 177a787)
author | ishmal <ishmal@users.sourceforge.net> | |
Fri, 21 Apr 2006 09:17:10 +0000 (09:17 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Fri, 21 Apr 2006 09:17:10 +0000 (09:17 +0000) |
src/extension/internal/odf.cpp | patch | blob | history | |
src/extension/internal/odf.h | patch | blob | history |
index ff2946af0edc93837b4e5168176b49170184d917..f8884f4a7cd451ea71851e56d7dac113b683e7f7 100644 (file)
snprintf(buf, 15, "#%02x%02x%02x", r, g, b);
si.fillColor = buf;
si.fill = "solid";
- double opacityPercent = 100.0;
+ double opacityPercent = 100.0 *
+ (SP_SCALE24_TO_FLOAT(style->fill_opacity.value));
snprintf(buf, 15, "%.2f%%", opacityPercent);
si.fillOpacity = buf;
}
snprintf(buf, 15, "%.2fpt", style->stroke_width.value);
si.strokeWidth = buf;
si.stroke = "solid";
- double opacityPercent = 100.0;
+ double opacityPercent = 100.0 *
+ (SP_SCALE24_TO_FLOAT(style->stroke_opacity.value));
snprintf(buf, 15, "%.2f%%", opacityPercent);
si.strokeOpacity = buf;
}
//Look for existing identical style;
bool styleMatch = false;
- std::map<std::string, StyleInfo>::iterator iter;
+ std::vector<StyleInfo>::iterator iter;
for (iter=styleTable.begin() ; iter!=styleTable.end() ; iter++)
{
- if (si.equals(iter->second))
+ if (si.equals(*iter))
{
//map to existing styleTable entry
- std::string styleName = iter->first;
+ std::string styleName = iter->name;
//g_message("found duplicate style:%s", styleName.c_str());
styleLookupTable[id] = styleName;
styleMatch = true;
char buf[16];
snprintf(buf, 15, "style%d", styleTable.size());
std::string styleName = buf;
- styleTable[styleName] = si;
+ si.name = styleName;
+ styleTable.push_back(si);
styleLookupTable[id] = styleName;
}
}
- /*
- //Look for style values in the svg element
- Inkscape::Util::List<Inkscape::XML::AttributeRecord const> attr =
- node->attributeList();
- for ( ; attr ; ++attr)
- {
- if (!attr->key || !attr->value)
- {
- g_warning("null key or value in attribute");
- continue;
- }
- //g_message("key:%s value:%s", g_quark_to_string(attr->key),
- // g_quark_to_string(attr->value) );
-
- std::string attrName = (const char *)g_quark_to_string(attr->key);
- std::string attrValue = (const char *)attr->value;
- //g_message("tag:'%s' key:'%s' value:'%s'",
- // nodeName.c_str(), attrName.c_str(), attrValue.c_str() );
- if (attrName == "style")
- {
- StyleInfo si(attrName, attrValue);
- if (styleTable.find(attrValue) != styleTable.end())
- {
- //g_message("duplicate style");
- }
- else
- {
- char buf[16];
- snprintf(buf, 15, "style%d", styleTable.size());
- std::string attrName = buf;
- //Map from value-->name . Looks backwards, i know
- styleTable[attrValue] = si;
- //g_message("mapping '%s' to '%s'",
- // attrValue.c_str(), attrName.c_str());
- }
- }
- }
- */
-
for (Inkscape::XML::Node *child = node->firstChild() ;
child ; child = child->next())
bool OdfOutput::writeStyle(Writer &outs)
{
outs.printf("<office:automatic-styles>\n");
+ outs.printf("<!-- ####### 'Standard' styles ####### -->\n");
outs.printf("<style:style style:name=\"dp1\" style:family=\"drawing-page\"/>\n");
outs.printf("<style:style style:name=\"gr1\" style:family=\"graphic\" style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties draw:stroke=\"none\" draw:fill=\"none\"\n");
outs.printf("</style:style>\n");
//## Dump our style table
- std::map<std::string, StyleInfo>::iterator iter;
+ outs.printf("<!-- ####### Styles from Inkscape document ####### -->\n");
+ std::vector<StyleInfo>::iterator iter;
for (iter = styleTable.begin() ; iter != styleTable.end() ; iter++)
{
- outs.printf("<style:style style:name=\"%s\"", iter->first.c_str());
- StyleInfo s(iter->second);
+ outs.printf("<style:style style:name=\"%s\"", iter->name.c_str());
+ StyleInfo s(*iter);
outs.printf(" style:family=\"graphic\" style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties");
outs.printf(" draw:fill=\"%s\" ", s.fill.c_str());
std::string nodeName = node->name();
std::string id = getAttribute(node, "id");
- NR::Matrix tf = sp_item_i2d_affine(item);
- NR::Rect bbox = sp_item_bbox_desktop(item);
+ NR::Matrix tf = sp_item_i2d_affine(item);
+ NR::Rect bbox = sp_item_bbox_desktop(item);
//Flip Y into document coordinates
- double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT);
+ double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT);
NR::Matrix doc2dt_tf = NR::Matrix(NR::scale(1, -1));
- doc2dt_tf = doc2dt_tf * NR::Matrix(NR::translate(0, doc_height));
- //tf = tf * doc2dt_tf;
- //bbox = bbox * doc2dt_tf;
+ doc2dt_tf = doc2dt_tf * NR::Matrix(NR::translate(0, doc_height));
+ tf = tf * doc2dt_tf;
+ bbox = bbox * doc2dt_tf;
double x = pxToCm * bbox.min()[NR::X];
double y = pxToCm * bbox.min()[NR::Y];
}
std::string newName = iter->second;
-
outs.printf("<draw:frame ");
if (id.size() > 0)
outs.printf("id=\"%s\" ", id.c_str());
if (curve)
{
- //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 */
+ //### Default <path> output
outs.printf("<draw:path ");
if (id.size()>0)
outs.printf("<draw:page draw:name=\"page1\" draw:style-name=\"dp1\"\n");
outs.printf(" draw:master-page-name=\"Default\">\n");
outs.printf("\n");
- outs.printf("<draw:g draw:transform=\"scale(1,-1)\">\n");
outs.printf("\n");
if (!writeTree(outs, node))
}
outs.printf("\n");
- outs.printf("</draw:g>\n");
outs.printf("\n");
outs.printf("</draw:page>\n");
index 5b6a2bdde0d00be36b8747a5a775012ad31a41d0..437148873615e816923ea1e9ff16849acd29026d 100644 (file)
void assign(const StyleInfo &other)
{
+ name = other.name;
stroke = other.stroke;
strokeColor = other.strokeColor;
strokeWidth = other.strokeWidth;
void init()
{
+ name = "none";
stroke = "none";
strokeColor = "none";
strokeWidth = "none";
return true;
}
+ std::string name;
std::string stroke;
std::string strokeColor;
std::string strokeWidth;
//element id -> style entry name
std::map<std::string, std::string> styleLookupTable;
//style entry name -> style info
- std::map<std::string, StyleInfo> styleTable;
+ std::vector<StyleInfo> styleTable;
//for renaming image file names
std::map<std::string, std::string> imageTable;