sp-flowtext.cpp revision 769ffccf82114363ffa36cd764ab229318ec02e4
/*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cstring>
#include <string>
#include "attributes.h"
#include "style.h"
#include "inkscape.h"
#include "document.h"
#include "selection.h"
#include "desktop-handles.h"
#include "desktop.h"
#include "sp-flowdiv.h"
#include "sp-flowregion.h"
#include "sp-flowtext.h"
#include "sp-string.h"
#include "sp-use.h"
#include "sp-rect.h"
#include "text-tag-attributes.h"
#include "text-chemistry.h"
#include "text-editing.h"
#include "sp-text.h"
#include "display/drawing-text.h"
#include "sp-factory.h"
namespace {
SPObject* createFlowtext() {
return new SPFlowtext();
}
}
this->par_indent = 0;
//new (&this->layout) Inkscape::Text::Layout();
}
SPFlowtext::~SPFlowtext() {
//this->layout.~Layout();
}
}
/* fixme: hide (Lauris) */
}
l = g_slist_prepend(l, child);
}
l = g_slist_reverse(l);
while (l) {
l = g_slist_remove(l, child);
if (SP_IS_ITEM(child)) {
} else {
}
}
}
this->rebuildLayout();
this->_clearFlow(g);
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
}
}
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
// FIXME: the below stanza is copied over from sp_text_modified, consider factoring it out
if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
text->_clearFlow(g);
}
}
if (SP_IS_FLOWREGION(o)) {
region = o;
break;
}
}
if (region) {
}
}
}
}
switch (key) {
case SP_ATTR_LAYOUT_OPTIONS: {
// deprecated attribute, read for backward compatibility only
//XML Tree being directly used while it shouldn't be.
{
} else {
}
}
}
/* no equivalent css attribute for these two (yet)
{
gchar const *val = sp_repr_css_property(opts, "layoutAlgo", NULL);
if ( val == NULL ) {
group->algo = 0;
} else {
if ( strcmp(val, "better") == 0 ) { // knuth-plass, never worked for general cases
group->algo = 2;
} else if ( strcmp(val, "simple") == 0 ) { // greedy, but allowed lines to be compressed by up to 20% if it would make them fit
group->algo = 1;
} else if ( strcmp(val, "default") == 0 ) { // the same one we use, a standard greedy
group->algo = 0;
}
}
}
*/
{ // This would probably translate to padding-left, if SPStyle had it.
this->par_indent = 0.0;
} else {
}
}
break;
}
default:
break;
}
}
Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) {
if ( flags & SP_OBJECT_WRITE_BUILD ) {
}
if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child)) {
}
if ( c_repr ) {
l = g_slist_prepend(l, c_repr);
}
}
while ( l ) {
l = g_slist_remove(l, l->data);
}
} else {
if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child) ) {
}
}
}
return repr;
}
// Add stroke width
// FIXME this code is incorrect
}
return bbox;
}
pbox = this->geometricBounds();
bbox = this->desktopVisualBounds();
}
const char* SPFlowtext::displayName() {
if (SP_FLOWTEXT(this)->has_internal_frame()) {
return _("Flowed Text");
} else {
return _("Linked Flowed Text");
}
}
return g_strdup_printf(ngettext(_("(%d character%s)"), _("(%d characters%s)"), nChars), nChars, trunc);
}
void SPFlowtext::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) {
// Choose a point on the baseline for snapping from or to, with the horizontal position
// of this point depending on the text alignment (left vs. right)
if (pt) {
p.push_back(Inkscape::SnapCandidatePoint((*pt) * this->i2dt_affine(), Inkscape::SNAPSOURCE_TEXT_ANCHOR, Inkscape::SNAPTARGET_TEXT_ANCHOR));
}
}
}
}
Inkscape::DrawingItem* SPFlowtext::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) {
flowed->setPickChildren(false);
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
return flowed;
}
}
/*
*
*/
void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, std::list<Shape> *shapes, SPObject **pending_line_break_object)
{
bool with_indent = false;
if (SP_IS_FLOWPARA(root)) {
// emulate par-indent with the first char's kern
if (SP_IS_FLOWTEXT(t)) {
if (indent != 0) {
with_indent = true;
}
}
}
if (*pending_line_break_object) {
} else {
}
}
if (SP_IS_STRING(child)) {
if (*pending_line_break_object) {
else {
}
}
if (with_indent) {
} else {
}
} else if (SP_IS_FLOWREGION(child)) {
if (exclusion_shape->hasEdges()) {
} else {
}
}
}
//XML Tree is being directly used while it shouldn't be.
}
}
if (SP_IS_FLOWDIV(root) || SP_IS_FLOWPARA(root) || SP_IS_FLOWREGIONBREAK(root) || SP_IS_FLOWLINE(root)) {
if (!root->hasChildren())
}
}
{
// RH: is it right that this shouldn't be recursive?
if ( SP_IS_FLOWREGIONEXCLUDE(child) ) {
} else {
}
}
}
}
delete shape_temp;
return shape;
}
void SPFlowtext::rebuildLayout()
{
delete exclusion_shape;
//g_print(layout.dumpAsText().c_str());
}
{
}
{
if (!this->layout.outputExists()) {
return NULL;
}
while (it != it_line_end) {
// use kerning to simulate justification and whatnot
// set x,y attributes only when we need to
bool set_x = false;
bool set_y = false;
if (!this->transform.isIdentity()) {
} else {
if (it == it_chunk_start) {
set_x = true;
// don't set y so linespacing adjustments and things will still work
}
if (it == it_shape_start)
set_y = true;
}
if (set_x)
sp_repr_set_svg_double(span_tspan, "x", anchor_point[Geom::X]); // FIXME: this will pick up the wrong end of counter-directional runs
if (set_y)
if (line_tspan->childCount() == 0) {
sp_repr_set_svg_double(line_tspan, "x", anchor_point[Geom::X]); // FIXME: this will pick up the wrong end of counter-directional runs
}
SPObject *source_obj = 0;
void *rawptr = 0;
gchar *style_text = sp_style_write_difference((SP_IS_STRING(source_obj) ? source_obj->parent : source_obj)->style, this->style);
if (style_text && *style_text) {
}
if (SP_IS_STRING(source_obj)) {
SPObject *span_end_obj = 0;
void *rawptr = 0;
if (span_end_obj != source_obj) {
for (int i = this->layout.iteratorToCharIndex(it_span_end) - this->layout.iteratorToCharIndex(it) ; i ; --i)
} else
}
if (span_text_start_iter != span_text_end_iter) {
while (span_text_start_iter != span_text_end_iter)
}
}
it = it_span_end;
}
}
return repr;
}
{
if (SP_IS_FLOWREGION(o)) {
region = o;
break;
}
}
if (region) {
bool past = false;
if (SP_IS_ITEM(o)) {
} else {
past = true;
}
}
}
}
}
}
return frame;
}
bool SPFlowtext::has_internal_frame()
{
}
{
root_repr->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create
Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect"); // FIXME: use path!!! after rects are converted to use path
using Geom::X;
using Geom::Y;
rect->updateRepr();
return ft_item;
}
{
this->_optimizeScaledText = false;
return xform;
}
this->_optimizeScaledText = false;
if (ex == 0) {
return xform;
}
// Adjust font size
// Adjust stroke width
this->adjust_stroke_width_recursive (ex);
// Adjust pattern fill
// Adjust gradient fill
return ret;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :