summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2006-02-03 03:04:05 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2006-02-03 03:04:05 +0000
commitece3aaf1c63e09ac8689ad3f50c0c0df61287846 (patch)
treeca2c787ffc846d6667f0634dae8fa49639738790
parentfurther fix: remember is paintservers were hreffed in a flag, fixes undo crash (diff)
downloadinkscape-ece3aaf1c63e09ac8689ad3f50c0c0df61287846.tar.gz
inkscape-ece3aaf1c63e09ac8689ad3f50c0c0df61287846.zip
implement par_indent in flowtext, no ui yet, done via first character's dx
(bzr r67)
-rw-r--r--src/sp-flowtext.cpp35
-rw-r--r--src/sp-flowtext.h2
2 files changed, 32 insertions, 5 deletions
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index fbf0efabd..900a3dffc 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -103,6 +103,7 @@ sp_flowtext_class_init(SPFlowtextClass *klass)
static void
sp_flowtext_init(SPFlowtext *group)
{
+ group->par_indent = 0;
new (&group->layout) Inkscape::Text::Layout();
}
@@ -252,6 +253,7 @@ sp_flowtext_set(SPObject *object, unsigned key, gchar const *value)
}
}
}
+ */
{ // This would probably translate to padding-left, if SPStyle had it.
gchar const *val = sp_repr_css_property(opts, "par-indent", NULL);
if ( val == NULL ) {
@@ -260,7 +262,6 @@ sp_flowtext_set(SPObject *object, unsigned key, gchar const *value)
sp_repr_get_double((Inkscape::XML::Node*)opts, "par-indent", &group->par_indent);
}
}
- */
sp_repr_css_attr_unref(opts);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
@@ -371,11 +372,31 @@ sp_flowtext_hide(SPItem *item, unsigned int key)
void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, std::list<Shape> *shapes, SPObject **pending_line_break_object)
{
+ Inkscape::Text::Layout::OptionalTextTagAttrs pi;
+ bool with_indent = false;
+
+ if (SP_IS_FLOWPARA(root)) {
+ // emulate par-indent with the first char's kern
+ SPObject *t = root;
+ for ( ; t != NULL && !SP_IS_FLOWTEXT(t); t = SP_OBJECT_PARENT(t));
+ if (SP_IS_FLOWTEXT(t)) {
+ double indent = SP_FLOWTEXT(t)->par_indent;
+ if (indent != 0) {
+ with_indent = true;
+ SVGLength sl;
+ sl.value = sl.computed = indent;
+ sl._set = true;
+ pi.dx.push_back(sl);
+ }
+ }
+ }
+
if (*pending_line_break_object) {
- if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object))
+ if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object)) {
layout.appendControlCode(Inkscape::Text::Layout::SHAPE_BREAK, *pending_line_break_object);
- else
+ } else {
layout.appendControlCode(Inkscape::Text::Layout::PARAGRAPH_BREAK, *pending_line_break_object);
+ }
*pending_line_break_object = NULL;
}
@@ -384,11 +405,15 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
if (*pending_line_break_object) {
if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object))
layout.appendControlCode(Inkscape::Text::Layout::SHAPE_BREAK, *pending_line_break_object);
- else
+ else {
layout.appendControlCode(Inkscape::Text::Layout::PARAGRAPH_BREAK, *pending_line_break_object);
+ }
*pending_line_break_object = NULL;
}
- layout.appendText(SP_STRING(child)->string, root->style, child);
+ if (with_indent)
+ layout.appendText(SP_STRING(child)->string, root->style, child, &pi);
+ else
+ layout.appendText(SP_STRING(child)->string, root->style, child);
} else if (SP_IS_FLOWREGION(child)) {
std::vector<Shape*> const &computed = SP_FLOWREGION(child)->computed;
for (std::vector<Shape*>::const_iterator it = computed.begin() ; it != computed.end() ; it++) {
diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h
index 9e6d711fa..39f443440 100644
--- a/src/sp-flowtext.h
+++ b/src/sp-flowtext.h
@@ -35,6 +35,8 @@ struct SPFlowtext : public SPItem {
/** discards the NRArena objects representing this text. */
void _clearFlow(NRArenaGroup* in_arena);
+ double par_indent;
+
private:
/** Recursively walks the xml tree adding tags and their contents. */
void _buildLayoutInput(SPObject *root, Shape const *exclusion_shape, std::list<Shape> *shapes, SPObject **pending_line_break_object);