index 48e217bd83cf7d56f3ea0fd45720eecd97146f4d..58d19be325fa79740dee78654349ec22e983febf 100644 (file)
* Authors:
* Bob Jamison
*
- * Copyright (C) 2006 Bob Jamison
+ * Copyright (C) 2006, 2007 Bob Jamison
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/**
* Get the value of a node/attribute pair
*/
-static Glib::ustring getAttribute( Inkscape::XML::Node *node, char *attrName)
+static Glib::ustring getAttribute( Inkscape::XML::Node *node, char const *attrName)
{
Glib::ustring val;
- char *valstr = (char *)node->attribute(attrName);
+ char const *valstr = node->attribute(attrName);
if (valstr)
- val = (const char *)valstr;
+ val = valstr;
return val;
}
{
Glib::ustring ext;
- unsigned int pos = fname.rfind('.');
+ std::string::size_type pos = fname.rfind('.');
if (pos == fname.npos)
{
ext = "";
* Get the bounding box of an item, as mapped onto
* an ODF document, in cm.
*/
-static NR::Rect getODFBoundingBox(const SPItem *item)
+static NR::Maybe<NR::Rect> getODFBoundingBox(const SPItem *item)
{
- NR::Rect bbox = sp_item_bbox_desktop((SPItem *)item);
- double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT);
- NR::Matrix doc2dt_tf = NR::Matrix(NR::scale(1.0, -1.0));
- doc2dt_tf = doc2dt_tf * NR::Matrix(NR::translate(0, doc_height));
- bbox = bbox * doc2dt_tf;
- bbox = bbox * NR::Matrix(NR::scale(pxToCm));
+ NR::Maybe<NR::Rect> bbox = sp_item_bbox_desktop((SPItem *)item);
+ if (bbox) {
+ double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT);
+ NR::Matrix doc2dt_tf = NR::Matrix(NR::scale(1.0, -1.0));
+ doc2dt_tf = doc2dt_tf * NR::Matrix(NR::translate(0, doc_height));
+ bbox = *bbox * doc2dt_tf;
+ bbox = *bbox * NR::Matrix(NR::scale(pxToCm));
+ }
return bbox;
}
else if (ext == ".jpg")
outs.printf("image/jpeg");
outs.printf("\" manifest:full-path=\"");
- outs.printf((char *)newName.c_str());
+ outs.printf(newName.c_str());
outs.printf("\"/>\n");
}
outs.printf("</manifest:manifest>\n");
StyleInfo si;
//## FILL
- if (style->fill.type == SP_PAINT_TYPE_COLOR)
+ if (style->fill.isColor())
{
- guint32 fillCol =
- sp_color_get_rgba32_ualpha(&style->fill.value.color, 0);
+ guint32 fillCol = style->fill.value.color.toRGBA32( 0 );
char buf[16];
int r = (fillCol >> 24) & 0xff;
int g = (fillCol >> 16) & 0xff;
}
//## STROKE
- if (style->stroke.type == SP_PAINT_TYPE_COLOR)
+ if (style->stroke.isColor())
{
- guint32 strokeCol =
- sp_color_get_rgba32_ualpha(&style->stroke.value.color, 0);
+ guint32 strokeCol = style->stroke.value.color.toRGBA32( 0 );
char buf[16];
int r = (strokeCol >> 24) & 0xff;
int g = (strokeCol >> 16) & 0xff;
bool OdfOutput::processGradient(Writer &outs, SPItem *item,
const Glib::ustring &id, NR::Matrix &tf)
{
+ if (!item)
+ return false;
+
SPStyle *style = item->style;
+ if (!style)
+ return false;
+
+ if (!style->fill.isPaintserver())
+ return false;
+
//## Gradient. Look in writeStyle() below to see what info
// we need to read into GradientInfo.
if (!SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)))
NR::Matrix tf = getODFTransform(item);
//### Get ODF bounding box params for item
- NR::Rect bbox = getODFBoundingBox(item);
- double bbox_x = bbox.min()[NR::X];
- double bbox_y = bbox.min()[NR::Y];
- double bbox_width = bbox.max()[NR::X] - bbox.min()[NR::X];
- double bbox_height = bbox.max()[NR::Y] - bbox.min()[NR::Y];
+ NR::Maybe<NR::Rect> bbox = getODFBoundingBox(item);
+ if (!bbox) {
+ return true;
+ }
+
+ double bbox_x = bbox->min()[NR::X];
+ double bbox_y = bbox->min()[NR::Y];
+ double bbox_width = bbox->extent(NR::X);
+ double bbox_height = bbox->extent(NR::Y);
double rotate;
double xskew;