index 48e217bd83cf7d56f3ea0fd45720eecd97146f4d..f67800ca56db66b11f85ae68f2b108aed4f16d36 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
{
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;
}
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.type != SP_PAINT_TYPE_PAINTSERVER)
+ 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;