sp-flowtext.cpp revision 41e6b2681e6a61f7e0b79f06787ad76d397bf0bd
/*
*/
#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 "display/nr-arena-glyphs.h"
static void sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_flowtext_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const *snapprefs);
static SPItemClass *parent_class;
sp_flowtext_get_type(void)
{
static GType group_type = 0;
if (!group_type) {
GTypeInfo group_info = {
sizeof(SPFlowtextClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof(SPFlowtext),
16, /* n_preallocs */
NULL, /* value_table */
};
}
return group_type;
}
static void
{
}
static void
{
group->par_indent = 0;
}
static void
{
}
static void
{
}
/* fixme: hide (Lauris) */
static void
{
}
static void
{
for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
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 {
}
}
}
group->rebuildLayout();
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
}
}
static void
{
// FIXME: the below stanza is copied over from sp_text_modified, consider factoring it out
if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
}
}
if (SP_IS_FLOWREGION(o)) {
region = o;
break;
}
}
if (!region) return;
}
}
static void
{
}
}
static void
{
switch (key) {
case SP_ATTR_LAYOUT_OPTIONS: {
// deprecated attribute, read for backward compatibility only
{
} 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.
} else {
}
}
break;
}
default:
}
break;
}
}
sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
if ( flags & SP_OBJECT_WRITE_BUILD ) {
for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child)) {
}
}
while ( l ) {
l = g_slist_remove(l, l->data);
}
} else {
for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child) ) {
}
}
}
return repr;
}
static void
sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
// Add stroke width
}
}
}
}
static void
{
if (!bbox_maybe) {
return;
}
}
{
char *trunc = "";
if (layout.inputTruncated()) {
trunc = _(" [truncated]");
}
return g_strdup_printf(ngettext("<b>Flowed text</b> (%d character%s)", "<b>Flowed text</b> (%d characters%s)", nChars), nChars, trunc);
else
return g_strdup_printf(ngettext("<b>Linked flowed text</b> (%d character%s)", "<b>Linked flowed text</b> (%d characters%s)", nChars), nChars, trunc);
}
static void sp_flowtext_snappoints(SPItem const *item, bool const target, SnapPointsWithType &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) {
int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE);
}
}
}
static NRArenaItem *
{
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
return flowed;
}
static void
{
}
/*
*
*/
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 {
}
}
for (SPObject *child = sp_object_first_child(root) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
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
}
}
}
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) ) {
continue;
} else
}
}
delete shape_temp;
return shape;
}
void SPFlowtext::rebuildLayout()
{
delete exclusion_shape;
//g_print(layout.dumpAsText().c_str());
}
{
}
}
{
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;
} 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;
}
}
bool past = false;
if (SP_IS_ITEM(o)) {
} else {
past = true;
}
}
}
}
} else {
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;
return ft_item;
}
/*
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 :