summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
authorJabiertxof <jabier.arraiza@marker.es>2019-09-13 20:09:42 +0000
committerJabiertxof <jabier.arraiza@marker.es>2019-09-13 20:09:42 +0000
commitbf052b6e7cb79317c4f38ff144a77b6f9e49421e (patch)
tree8b5235b21eeac68e495ad60a51065aaeed4aff33 /src/object
parentRefactor of prepare inner and some comments (diff)
downloadinkscape-bf052b6e7cb79317c4f38ff144a77b6f9e49421e.tar.gz
inkscape-bf052b6e7cb79317c4f38ff144a77b6f9e49421e.zip
Allow to paste paragraphs in SVG2 Flow then paste overflow the shape
Diffstat (limited to 'src/object')
-rw-r--r--src/object/sp-text.cpp32
-rw-r--r--src/object/sp-text.h9
2 files changed, 38 insertions, 3 deletions
diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp
index 91ca65170..4dd5a9ff1 100644
--- a/src/object/sp-text.cpp
+++ b/src/object/sp-text.cpp
@@ -63,7 +63,12 @@
SPText::SPText() : SPItem() {
}
-SPText::~SPText() = default;
+SPText::~SPText()
+{
+ if (css) {
+ sp_repr_css_attr_unref(css);
+ }
+};
void SPText::build(SPDocument *doc, Inkscape::XML::Node *repr) {
this->readAttr( "x" );
@@ -76,7 +81,7 @@ void SPText::build(SPDocument *doc, Inkscape::XML::Node *repr) {
this->readAttr( "textLength" );
this->readAttr( "lengthAdjust" );
SPItem::build(doc, repr);
-
+ css = nullptr;
this->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read
}
@@ -383,6 +388,29 @@ void SPText::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::
}
}
+void SPText::hide_shape_inside()
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ SPStyle *item_style = this->style;
+ if (item_style && prefs->getBool("/tools/text/use_svg2") && item_style->shape_inside.set) {
+ SPCSSAttr *css_unset = sp_css_attr_from_style(item_style, SP_STYLE_FLAG_IFSET);
+ css = sp_css_attr_from_style(item_style, SP_STYLE_FLAG_IFSET);
+ sp_repr_css_unset_property(css_unset, "shape-inside");
+ sp_repr_css_attr_unref(css_unset);
+ this->changeCSS(css_unset, "style");
+ } else {
+ css = nullptr;
+ }
+}
+
+void SPText::show_shape_inside()
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/text/use_svg2") && css) {
+ this->changeCSS(css, "style");
+ }
+}
+
Geom::Affine SPText::set_transform(Geom::Affine const &xform) {
// See if 'shape-inside' has rectangle
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
diff --git a/src/object/sp-text.h b/src/object/sp-text.h
index 3b7880a88..e058bd6e7 100644
--- a/src/object/sp-text.h
+++ b/src/object/sp-text.h
@@ -59,6 +59,12 @@ public:
completely specified by transformations. */
static void _adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double ex, bool is_root = true);
static void _adjustFontsizeRecursive(SPItem *item, double ex, bool is_root = true);
+ /**
+ This two functions are useful because layout calculations need text visible for example
+ Calculating a invisible char position object or pasting text with paragraps that overflow
+ shape defined. I have doubts abot trransform into a toggle function*/
+ void show_shape_inside();
+ void hide_shape_inside();
/** discards the drawing objects representing this text. */
void _clearFlow(Inkscape::DrawingGroup *in_arena);
@@ -83,8 +89,9 @@ private:
/** Find first x/y values which may be in a descendent element. */
SVGLength* _getFirstXLength();
SVGLength* _getFirstYLength();
+ SPCSSAttr *css;
-public:
+ public:
/** Optimize textpath text on next set_transform. */
void optimizeTextpathText() {_optimizeTextpathText = true;}