summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 193b44f)
raw | patch | inline | side by side (parent: 193b44f)
author | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 21 Feb 2010 15:54:04 +0000 (16:54 +0100) | ||
committer | Johan Engelen <goejendaagh@zonnet.nl> | |
Sun, 21 Feb 2010 15:54:04 +0000 (16:54 +0100) |
src/extension/internal/pdflatex-renderer.cpp | patch | blob | history |
diff --git a/src/extension/internal/pdflatex-renderer.cpp b/src/extension/internal/pdflatex-renderer.cpp
index 5377ae57cc4ba74129aecd7a30f5b63739782e8f..b70bac1075501bb68d0f3b388cae94d6aa81fab2 100644 (file)
static char const preamble[] =
"%% To include the image in your LaTeX document, write\n"
"%% \\setlength{\\unitlength}{<desired width>}\n"
-"%% \\input{filename.tex}\n"
+"%% \\input{<filename>.tex}\n"
"%% instead of\n"
-"%% \\includegraphics[width=<desired width>]{<filename.pdf>}\n"
+"%% \\includegraphics[width=<desired width>]{<filename>.pdf}\n"
"\n"
"\\begingroup \n"
" \\makeatletter \n"
push_transform(i2doc);
gchar *str = sp_te_get_string_multiline(item);
- Geom::Point pos = textobj->attributes.firstXY() * transform();
- gchar *alignment = "lb";
+
+ // get position and alignment
+ Geom::Point pos;
+ gchar *alignment = NULL;
+ Geom::OptRect bbox = item->getBounds(transform());
+ Geom::Interval bbox_x = (*bbox)[Geom::X];
+ Geom::Interval bbox_y = (*bbox)[Geom::Y];
+ SPStyle *style = SP_OBJECT_STYLE (SP_OBJECT(item));
+ switch (style->text_anchor.computed) {
+ case SP_CSS_TEXT_ANCHOR_START:
+ pos = Geom::Point( bbox_x.min() , bbox_y.middle() );
+ alignment = "[l]";
+ break;
+ case SP_CSS_TEXT_ANCHOR_END:
+ pos = Geom::Point( bbox_x.max() , bbox_y.middle() );
+ alignment = "[r]";
+ break;
+ case SP_CSS_TEXT_ANCHOR_MIDDLE:
+ default:
+ pos = bbox->midpoint();
+ alignment = "";
+ break;
+ }
// get rotation
Geom::Matrix wotransl = i2doc.without_translation();
double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis());
+ bool has_rotation = !Geom::are_near(degrees,0.);
pop_transform();
// os << "\\put(" << pos[Geom::X] << "," << pos[Geom::Y] << "){\\makebox(0,0)[" << alignment << "]{\\strut{}" << str << "}}%%\n";
os << " \\put(" << pos[Geom::X] << "," << pos[Geom::Y] << "){";
- if (!Geom::are_near(degrees,0.)) {
+ os << "\\makebox(0,0)" << alignment << "{";
+ if (has_rotation) {
os << "\\rotatebox{" << degrees << "}{";
}
os << str;
- if (!Geom::are_near(degrees,0.)) {
- os << "}";
+ if (has_rotation) {
+ os << "}"; // rotatebox end
}
- os << "}%\n";
+ os << "}"; //makebox end
+ os << "}%\n"; // put end
fprintf(_stream, "%s", os.str().c_str());
}