index 0e68ae130a368c3013d97c0f56a2bf666f4d55de..67f9354d8cac97085e57fc87b6f18d90cbc29df8 100644 (file)
-#define __SP_CAIRO_RENDERER_C__
-
/** \file
* Rendering with Cairo.
*/
/*
* Author:
* Miklos Erdelyi <erdelyim@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006 Miklos Erdelyi
*
namespace Internal {
CairoRenderer::CairoRenderer(void)
+ : _omitText(false)
{}
CairoRenderer::~CairoRenderer(void)
if (!shape->curve) return;
- sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
+ item->invoke_bbox( &pbox, Geom::identity(), TRUE);
SPStyle* style = SP_OBJECT_STYLE (item);
Geom::PathVector const & pathv = shape->curve->get_pathvector();
+ if (pathv.empty()) return;
ctx->renderPathVector(pathv, style, &pbox);
// Get the bounding box of the selection in document coordinates.
Geom::OptRect bbox =
- item->getBounds(sp_item_i2d_affine(item), SPItem::RENDERING_BBOX);
+ item->getBounds(item->i2d_affine(), SPItem::RENDERING_BBOX);
if (!bbox) // no bbox, e.g. empty group
return;
(Geom::Matrix)(Geom::Translate (shift_x, shift_y));
// ctx matrix already includes item transformation. We must substract.
- Geom::Matrix t_item = sp_item_i2d_affine (item);
+ Geom::Matrix t_item = item->i2d_affine ();
Geom::Matrix t = t_on_document * t_item.inverse();
// Do the export
void
CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item)
{
+ if ( _omitText && (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) ) {
+ // skip text if _omitText is true
+ return;
+ }
+
ctx->pushState();
setStateForItem(ctx, item);
bool
CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base)
{
+// PLEASE note when making changes to the boundingbox and transform calculation, corresponding changes should be made to PDFLaTeXRenderer::setupDocument !!!
+
g_assert( ctx != NULL );
- if (!base)
- base = SP_ITEM(sp_document_root(doc));
+ if (!base) {
+ base = SP_ITEM(doc->getRoot());
+ }
NRRect d;
if (pageBoundingBox) {
d.x0 = d.y0 = 0;
- d.x1 = ceil(sp_document_width(doc));
- d.y1 = ceil(sp_document_height(doc));
+ d.x1 = doc->getWidth();
+ d.y1 = doc->getHeight();
} else {
- sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
+ base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
}
if (ctx->_vector_based_target) {
@@ -623,7 +633,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ret && !pageBoundingBox)
{
- double high = sp_document_height(doc);
+ double high = doc->getHeight();
if (ctx->_vector_based_target)
high *= PT_PER_PX;
TRACE(("BEGIN clip\n"));
SPObject *co = SP_OBJECT(cp);
- for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
SPItem *item = SP_ITEM(child);
TRACE(("BEGIN mask\n"));
SPObject *co = SP_OBJECT(mask);
- for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
SPItem *item = SP_ITEM(child);
renderItem(ctx, item);
@@ -804,4 +814,4 @@ calculatePreserveAspectRatio(unsigned int aspect_align, unsigned int aspect_clip
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :