sp-flowtext.cpp revision b883766535496d22dfb76e5428fbf8ef9300520a
/*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "attributes.h"
#include "style.h"
#include "inkscape.h"
#include "document.h"
#include "selection.h"
#include "desktop-handles.h"
#include "desktop.h"
#include "desktop-affine.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 "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::Node *repr, guint flags);
static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
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;
}
}
{
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, NR::Matrix const &transform, unsigned const /*flags*/)
{
// Add stroke width
}
}
}
}
static void
{
}
{
return g_strdup_printf(ngettext("<b>Flowed text</b> (%d character)", "<b>Flowed text</b> (%d characters)", nChars), nChars);
else
return g_strdup_printf(ngettext("<b>Linked flowed text</b> (%d character)", "<b>Linked flowed text</b> (%d characters)", nChars), nChars);
}
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
}
}
else if (!SP_IS_FLOWREGIONEXCLUDE(child))
}
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());
}
{
}
}
void SPFlowtext::convert_to_text()
{
if (!SP_IS_FLOWTEXT(item)) return;
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[NR::X]); // FIXME: this will pick up the wrong end of counter-directional runs
if (set_y)
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, group->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 = group->layout.iteratorToCharIndex(it_span_end) - group->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;
}
}
item->deleteObject();
_("Convert flowed text to text"));
}
{
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 = sp_repr_new("svg:rect"); // FIXME: use path!!! after rects are converted to use path
using NR::X;
using NR::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 :