summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-02-23 23:55:35 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-02-23 23:55:35 +0000
commit3188b55dce3d9e82aacb9088622aa762d836d18b (patch)
tree5e2b6a37db48a55bfa6b5f1dd1c4f0874836ea14 /src
parentupdate to trunk (diff)
parentFix for selcue settings. (diff)
downloadinkscape-3188b55dce3d9e82aacb9088622aa762d836d18b.tar.gz
inkscape-3188b55dce3d9e82aacb9088622aa762d836d18b.zip
update to trunk
(bzr r11950.1.255)
Diffstat (limited to 'src')
-rw-r--r--src/document.cpp16
-rw-r--r--src/extension/internal/emf-inout.cpp2
-rw-r--r--src/extension/internal/emf-print.cpp10
-rw-r--r--src/extension/internal/wmf-inout.cpp10
-rw-r--r--src/extension/internal/wmf-print.cpp16
-rw-r--r--src/id-clash.cpp39
-rw-r--r--src/sp-image.cpp42
-rw-r--r--src/sp-switch.cpp14
-rw-r--r--src/ui/dialog/document-properties.cpp8
-rw-r--r--src/ui/dialog/symbols.cpp4
-rw-r--r--src/ui/tools/dropper-tool.cpp2
-rw-r--r--src/ui/tools/freehand-base.cpp2
-rw-r--r--src/ui/tools/measure-tool.cpp2
-rw-r--r--src/ui/tools/text-tool.cpp2
-rw-r--r--src/ui/tools/zoom-tool.cpp2
-rw-r--r--src/uri-test.h90
16 files changed, 187 insertions, 74 deletions
diff --git a/src/document.cpp b/src/document.cpp
index 470d0cc5a..112503320 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -1544,15 +1544,13 @@ void SPDocument::importDefs(SPDocument *source)
// Prevent duplicates of solid swatches by checking if equivalent swatch already exists
if (src && SP_IS_GRADIENT(src)) {
SPGradient *gr = SP_GRADIENT(src);
- if (gr->isSolid() || gr->getVector()->isSolid()) {
- for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
- if (trg && SP_IS_GRADIENT(trg) && src != trg) {
- if (gr->isEquivalent(SP_GRADIENT(trg))) {
- // Change object references to the existing equivalent gradient
- change_def_references(src, trg);
- duplicate = true;
- break;
- }
+ for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
+ if (trg && SP_IS_GRADIENT(trg) && src != trg) {
+ if (gr->isEquivalent(SP_GRADIENT(trg))) {
+ // Change object references to the existing equivalent gradient
+ change_def_references(src, trg);
+ duplicate = true;
+ break;
}
}
}
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index 276dee362..b73c5e9e5 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -554,6 +554,7 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint
else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; }
*(d->defs) += base64String;
*(d->defs) += "\"\n";
+ *(d->defs) += " preserveAspectRatio=\"none\"\n";
*(d->defs) += " />\n";
@@ -1531,6 +1532,7 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr,
tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n";
tmp_image << " transform=" << current_matrix(d, dx, dy, 1); // calculate appropriate offset
+ tmp_image << " preserveAspectRatio=\"none\"\n";
tmp_image << "/> \n";
*(d->outsvg) += tmp_image.str().c_str();
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 6d5bb6f4b..c103100b3 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -1562,7 +1562,7 @@ unsigned int PrintEmf::image(
unsigned int w, /** width of bitmap */
unsigned int h, /** height of bitmap */
unsigned int rs, /** row stride (normally w*4) */
- Geom::Affine const &/*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */
+ Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */
SPStyle const *style) /** provides indirect link to image object */
{
double x1, y1, dw, dh;
@@ -1574,10 +1574,10 @@ unsigned int PrintEmf::image(
g_error("Fatal programming error in PrintEmf::image at EMRHEADER");
}
- x1 = atof(style->object->getAttribute("x"));
- y1 = atof(style->object->getAttribute("y"));
- dw = atof(style->object->getAttribute("width"));
- dh = atof(style->object->getAttribute("height"));
+ x1 = tf_rect[4];
+ y1 = tf_rect[5];
+ dw = ((double) w) * tf_rect[0];
+ dh = ((double) h) * tf_rect[3];
Geom::Point pLL(x1, y1);
Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index fc54350df..3c348f5c4 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -525,6 +525,7 @@ uint32_t Wmf::add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsa
else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; }
*(d->defs) += base64String;
*(d->defs) += "\"\n";
+ *(d->defs) += " preserveAspectRatio=\"none\"\n";
*(d->defs) += " />\n";
@@ -619,6 +620,7 @@ uint32_t Wmf::add_bm16_image(PWMF_CALLBACK_DATA d, U_BITMAP16 Bm16, const char *
*(d->defs) += " xlink:href=\"data:image/png;base64,";
*(d->defs) += base64String;
*(d->defs) += "\"\n";
+ *(d->defs) += " preserveAspectRatio=\"none\"\n";
*(d->defs) += " />\n";
@@ -1269,6 +1271,7 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib,
SVGOStringStream tmp_image;
int dibparams;
+ tmp_image << "\n\t <image\n";
tmp_image << " y=\"" << dy << "\"\n x=\"" << dx <<"\"\n ";
// The image ID is filled in much later when tmp_image is converted
@@ -1355,12 +1358,11 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib,
}
tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n";
-
tmp_image << " transform=" << current_matrix(d, 0.0, 0.0, 0); // returns an identity matrix, no offsets.
- *(d->outsvg) += "\n\t <image\n";
- *(d->outsvg) += tmp_image.str().c_str();
+ tmp_image << " preserveAspectRatio=\"none\"\n";
+ tmp_image << "/> \n";
- *(d->outsvg) += "/> \n";
+ *(d->outsvg) += tmp_image.str().c_str();
*(d->path) = "";
}
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 1c7b42c82..32c7ac0bd 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -1103,7 +1103,7 @@ unsigned int PrintWmf::image(
unsigned int w, /** width of bitmap */
unsigned int h, /** height of bitmap */
unsigned int rs, /** row stride (normally w*4) */
- Geom::Affine const & /*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */
+ Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */
SPStyle const *style) /** provides indirect link to image object */
{
double x1, y1, dw, dh;
@@ -1115,15 +1115,19 @@ unsigned int PrintWmf::image(
g_error("Fatal programming error in PrintWmf::image at EMRHEADER");
}
- x1 = g_ascii_strtod(style->object->getAttribute("x"), NULL);
- y1 = g_ascii_strtod(style->object->getAttribute("y"), NULL);
- dw = g_ascii_strtod(style->object->getAttribute("width"), NULL);
- dh = g_ascii_strtod(style->object->getAttribute("height"), NULL);
+ x1 = tf_rect[4];
+ y1 = tf_rect[5];
+ dw = ((double) w) * tf_rect[0];
+ dh = ((double) h) * tf_rect[3];
Geom::Point pLL(x1, y1);
Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates
+ /* adjust scale of w and h. This works properly when there is no rotation. The values are
+ a bit strange when there is rotation, but since WMF cannot handle rotation in any case, all
+ answers are equally wrong.
+ */
Geom::Point pWH(dw, dh);
- Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale
+ Geom::Point pWH2 = pWH * tf.withoutTranslation();
char *px;
uint32_t cbPx;
diff --git a/src/id-clash.cpp b/src/id-clash.cpp
index c8eacfe02..76b8e6ff8 100644
--- a/src/id-clash.cpp
+++ b/src/id-clash.cpp
@@ -203,27 +203,44 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc,
id_changelist_type *id_changes)
{
const gchar *id = elem->getId();
+ bool fix_clashing_ids = true;
if (id && current_doc->getObjectById(id)) {
// Choose a new ID.
// To try to preserve any meaningfulness that the original ID
// may have had, the new ID is the old ID followed by a hyphen
// and one or more digits.
- std::string old_id(id);
- std::string new_id(old_id + '-');
- for (;;) {
- new_id += "0123456789"[std::rand() % 10];
- const char *str = new_id.c_str();
- if (current_doc->getObjectById(str) == NULL &&
- imported_doc->getObjectById(str) == NULL) break;
+
+ if (SP_IS_GRADIENT(elem)) {
+ SPObject *cd_obj = current_doc->getObjectById(id);
+
+ if (cd_obj && SP_IS_GRADIENT(cd_obj)) {
+ SPGradient *cd_gr = SP_GRADIENT(cd_obj);
+ if (cd_gr->isEquivalent(SP_GRADIENT(elem))) {
+ fix_clashing_ids = false;
+ }
+ }
}
- // Change to the new ID
- elem->getRepr()->setAttribute("id", new_id.c_str());
- // Make a note of this change, if we need to fix up refs to it
- if (refmap->find(old_id) != refmap->end())
+
+ if (fix_clashing_ids) {
+ std::string old_id(id);
+ std::string new_id(old_id + '-');
+ for (;;) {
+ new_id += "0123456789"[std::rand() % 10];
+ const char *str = new_id.c_str();
+ if (current_doc->getObjectById(str) == NULL &&
+ imported_doc->getObjectById(str) == NULL) break;
+ }
+ // Change to the new ID
+
+ elem->getRepr()->setAttribute("id", new_id.c_str());
+ // Make a note of this change, if we need to fix up refs to it
+ if (refmap->find(old_id) != refmap->end())
id_changes->push_back(id_changeitem_type(elem, old_id));
+ }
}
+
// recurse
for (SPObject *child = elem->firstChild(); child; child = child->getNext() )
{
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 5f630f7b7..2c20331a9 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -500,39 +500,15 @@ void SPImage::print(SPPrintContext *ctx) {
int w = pb->width();
int h = pb->height();
int rs = pb->rowstride();
- //int pixskip = gdk_pixbuf_get_n_channels(pb) * gdk_pixbuf_get_bits_per_sample(pb) / 8;
- int pixskip = 4;
-
- if (this->aspect_align == SP_ASPECT_NONE) {
- Geom::Affine t;
- Geom::Translate tp(this->x.computed, this->y.computed);
- Geom::Scale s(this->width.computed, -this->height.computed);
- Geom::Translate ti(0.0, -1.0);
- t = s * tp;
- t = ti * t;
- sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style);
- } else { // preserveAspectRatio
- double vw = this->width.computed / this->sx;
- double vh = this->height.computed / this->sy;
-
- int trimwidth = std::min<int>(w, ceil(this->width.computed / vw * w));
- int trimheight = std::min<int>(h, ceil(this->height.computed / vh * h));
- int trimx = std::max<int>(0, floor((this->x.computed - this->ox) / vw * w));
- int trimy = std::max<int>(0, floor((this->y.computed - this->oy) / vh * h));
-
- double vx = std::max<double>(this->ox, this->x.computed);
- double vy = std::max<double>(this->oy, this->y.computed);
- double vcw = std::min<double>(this->width.computed, vw);
- double vch = std::min<double>(this->height.computed, vh);
-
- Geom::Affine t;
- Geom::Translate tp(vx, vy);
- Geom::Scale s(vcw, -vch);
- Geom::Translate ti(0.0, -1.0);
- t = s * tp;
- t = ti * t;
- sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, t, this->style);
- }
+
+ double vx = this->ox;
+ double vy = this->oy;
+
+ Geom::Affine t;
+ Geom::Translate tp(vx, vy);
+ Geom::Scale s(this->sx, this->sy);
+ t = s * tp;
+ sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style);
delete pb;
}
}
diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp
index b4841c0d0..db6db9909 100644
--- a/src/sp-switch.cpp
+++ b/src/sp-switch.cpp
@@ -82,16 +82,22 @@ gchar *SPSwitch::description() const {
ngettext(_("of <b>%d</b> object"), _("of <b>%d</b> objects"), len), len);
}
-void SPSwitch::child_added(Inkscape::XML::Node* /*child*/, Inkscape::XML::Node* /*ref*/) {
+void SPSwitch::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) {
+ SPGroup::child_added(child, ref);
+
this->_reevaluate(true);
}
-void SPSwitch::remove_child(Inkscape::XML::Node *) {
- this->_reevaluate();
+void SPSwitch::remove_child(Inkscape::XML::Node *child) {
+ SPGroup::remove_child(child);
+
+ this->_reevaluate();
}
-void SPSwitch::order_changed (Inkscape::XML::Node *, Inkscape::XML::Node *, Inkscape::XML::Node *)
+void SPSwitch::order_changed (Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref)
{
+ SPGroup::order_changed(child, old_ref, new_ref);
+
this->_reevaluate();
}
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index d344fb1d6..0411c789c 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -1734,8 +1734,14 @@ void DocumentProperties::onDocUnitChange()
prefs->setBool("/options/transform/gradient", true);
{
ShapeEditor::blockSetItem(true);
+ gdouble viewscale = doc->getWidth().value("px")/doc->getRoot()->viewBox.width();
+ if (doc->getHeight().value("px")/doc->getRoot()->viewBox.height() < viewscale)
+ viewscale = doc->getHeight().value("px")/doc->getRoot()->viewBox.height();
gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit);
- doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px")));
+ doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(-viewscale*doc->getRoot()->viewBox.min()[Geom::X] +
+ (doc->getWidth().value("px") - viewscale*doc->getRoot()->viewBox.width())/2,
+ viewscale*doc->getRoot()->viewBox.min()[Geom::Y] +
+ (doc->getHeight().value("px") + viewscale*doc->getRoot()->viewBox.height())/2));
ShapeEditor::blockSetItem(false);
}
prefs->setBool("/options/transform/stroke", transform_stroke);
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index 98754fb4f..62a2f8572 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -381,8 +381,10 @@ void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) {
}
}
-void SymbolsDialog::documentReplaced(SPDesktop */*desktop*/, SPDocument */*document*/)
+void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document)
{
+ currentDesktop = desktop;
+ currentDocument = document;
rebuild();
}
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index 9c47b50e9..88ed342df 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -152,6 +152,8 @@ void DropperTool::finish() {
#endif
cursor_dropper_fill = NULL;
}
+
+ ToolBase::finish();
}
/**
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 5825a149c..5e406a0d4 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -167,6 +167,8 @@ void FreehandBase::finish() {
}
spdc_free_colors(this);
+
+ ToolBase::finish();
}
void FreehandBase::set(const Inkscape::Preferences::Entry& /*value*/) {
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 0d823dfda..4d7f1e074 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -254,6 +254,8 @@ void MeasureTool::finish() {
sp_canvas_item_ungrab(this->grabbed, GDK_CURRENT_TIME);
this->grabbed = NULL;
}
+
+ ToolBase::finish();
}
//void MeasureTool::setup() {
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 9b5ab1016..ba68c7829 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -266,6 +266,8 @@ void TextTool::finish() {
}
this->text_selection_quads.clear();
+
+ ToolBase::finish();
}
bool TextTool::item_handler(SPItem* item, GdkEvent* event) {
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index d4ede1053..0996e6cf4 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -63,6 +63,8 @@ void ZoomTool::finish() {
sp_canvas_item_ungrab(this->grabbed, GDK_CURRENT_TIME);
this->grabbed = NULL;
}
+
+ ToolBase::finish();
}
void ZoomTool::setup() {
diff --git a/src/uri-test.h b/src/uri-test.h
new file mode 100644
index 000000000..2a4cdab46
--- /dev/null
+++ b/src/uri-test.h
@@ -0,0 +1,90 @@
+
+#ifndef SEEN_URI_TEST_H
+#define SEEN_URI_TEST_H
+/*
+ * Test uri.h
+ *
+ * Written to aid with refactoring the uri handling to support fullPath
+ * and data URIs and also cover code which wasn't before tested.
+ *
+ * Copyright 2014 (c) BasisTech Boston
+ *
+ */
+#include <cxxtest/TestSuite.h>
+
+#include "uri.h"
+
+using Inkscape::URI;
+
+class URITest : public CxxTest::TestSuite
+{
+public:
+ void stringTest( std::string result, std::string expected )
+ {
+ if ( !result.empty() && !expected.empty() ) {
+ TS_ASSERT_EQUALS( result, expected );
+ } else if ( result.empty() && !expected.empty() ) {
+ TS_FAIL( std::string("Expected (") + expected + "), found null" );
+ } else if ( !result.empty() && expected.empty() ) {
+ TS_FAIL( std::string("Expected null, found (") + result + ")" );
+ }
+ }
+
+ std::string ValueOrEmpty(const char* s) {
+ return s == NULL ? std::string() : s;
+ }
+
+ void toStringTest( std::string uri, std::string expected ) {
+ stringTest( URI(uri.c_str()).toString(), expected );
+ }
+ void pathTest( std::string uri, std::string expected ) {
+ stringTest( ValueOrEmpty(URI(uri.c_str()).getPath()), expected );
+ }
+
+ void testToString()
+ {
+ char const* cases[][2] = {
+ { "foo", "foo" },
+ { "#foo", "#foo" },
+ { "blah.svg#h", "blah.svg#h" },
+ //{ "data:data", "data:data" },
+ };
+
+ for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) {
+ toStringTest( std::string(cases[i][0]), std::string(cases[i][1]) );
+ }
+ }
+
+ void testPath()
+ {
+ char const* cases[][2] = {
+ { "foo.svg", "foo.svg" },
+ { "foo.svg#bar", "foo.svg" },
+ { "#bar", NULL },
+ { "data:data", NULL },
+ };
+
+ for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) {
+ pathTest( ValueOrEmpty(cases[i][0]), ValueOrEmpty(cases[i][1]) );
+ }
+ }
+ void testFullPath() {
+ std::ofstream fhl("/tmp/cxxtest-uri.svg", std::ofstream::out);
+ stringTest( URI("cxxtest-uri.svg").getFullPath("/tmp"), std::string("/tmp/cxxtest-uri.svg") );
+ stringTest( URI("cxxtest-uri.svg").getFullPath("/usr/../tmp"), std::string("/tmp/cxxtest-uri.svg") );
+ }
+
+};
+
+#endif // SEEN_URI_TEST_H
+
+/*
+ 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:fileencoding=utf-8:textwidth=99 :