summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2015-01-15 19:03:17 +0000
committerapenner <penner@vaxxine.com>2015-01-15 19:03:17 +0000
commit45b5e7ad68a9166a61f96b3ffc469818a2bf4fcd (patch)
tree89e99c009d1a73b18a923b81e3986b031df3e313 /src
parentRead properties for SVG 2 text in a shape. (diff)
downloadinkscape-45b5e7ad68a9166a61f96b3ffc469818a2bf4fcd.tar.gz
inkscape-45b5e7ad68a9166a61f96b3ffc469818a2bf4fcd.zip
during copy and paste, scale stock symbols from units of 'px' to 'document-units'. (Bug 1365451)
Fixed bugs: - https://launchpad.net/bugs/1365451 (bzr r13853)
Diffstat (limited to 'src')
-rw-r--r--src/sp-item-group.cpp6
-rw-r--r--src/ui/clipboard.cpp29
-rw-r--r--src/ui/clipboard.h2
-rw-r--r--src/ui/dialog/symbols.cpp2
4 files changed, 25 insertions, 14 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index acf8b2012..b1ba37de2 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -727,8 +727,8 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo
group->scaleChildItemsRec(sc, p, false);
}
} else {
- Geom::OptRect bbox = item->desktopVisualBounds();
- if (bbox) {
+// Geom::OptRect bbox = item->desktopVisualBounds();
+// if (bbox) { // test not needed, this was causing a failure to scale <circle> and <rect> in the clipboard, see LP Bug 1365451
// Scale item
Geom::Translate const s(p);
Geom::Affine final = s.inverse() * sc * s;
@@ -789,7 +789,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo
item->scaleCenter(sc); // All coordinates have been scaled, so also the center must be scaled
item->updateRepr();
}
- }
+// }
}
}
}
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index c2465932b..dabebe1be 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -107,7 +107,7 @@ class ClipboardManagerImpl : public ClipboardManager {
public:
virtual void copy(SPDesktop *desktop);
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *);
- virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style);
+ virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol);
virtual bool paste(SPDesktop *desktop, bool in_place);
virtual bool pasteStyle(SPDesktop *desktop);
virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y);
@@ -303,7 +303,7 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam
* Copy a symbol from the symbol dialog.
* @param symbol The Inkscape::XML::Node for the symbol.
*/
-void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* style)
+void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol)
{
//std::cout << "ClipboardManagerImpl::copySymbol" << std::endl;
if ( symbol == NULL ) {
@@ -326,17 +326,28 @@ void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const*
Glib::ustring id("#");
id += symbol->attribute("id");
+ gdouble scale_units = 1; // scale from "px" to "document-units"
+ Inkscape::XML::Node *nv_repr = SP_ACTIVE_DESKTOP->getNamedView()->getRepr();
+ if (nv_repr->attribute("inkscape:document-units"))
+ scale_units = Inkscape::Util::Quantity::convert(1, "px", nv_repr->attribute("inkscape:document-units"));
+ SPObject *cmobj = _clipboardSPDoc->getObjectByRepr(repr);
+ if (cmobj && !user_symbol) { // convert only stock symbols
+ if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) {
+ dynamic_cast<SPGroup *>(cmobj)->scaleChildItemsRec(Geom::Scale(scale_units),
+ Geom::Point(0, SP_ACTIVE_DESKTOP->getDocument()->getHeight().value("px")),
+ false);
+ }
+ }
+
Inkscape::XML::Node *use = _doc->createElement("svg:use");
use->setAttribute("xlink:href", id.c_str() );
// Set a default style in <use> rather than <symbol> so it can be changed.
use->setAttribute("style", style );
-/* disable rev 13709 in rev 13806, following Bug 1365451, comments 13-16
- Inkscape::XML::Node *nv_repr = SP_ACTIVE_DESKTOP->getNamedView()->getRepr();
- gdouble scale_units = Inkscape::Util::Quantity::convert(1, nv_repr->attribute("inkscape:document-units"), "px");
- gchar *transform_str = sp_svg_transform_write(Geom::Scale(scale_units, scale_units));
- use->setAttribute("transform", transform_str);
- g_free(transform_str);
-*/
+ if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) {
+ gchar *transform_str = sp_svg_transform_write(Geom::Scale(1.0/scale_units));
+ use->setAttribute("transform", transform_str);
+ g_free(transform_str);
+ }
_root->appendChild(use);
// This min and max sets offsets, we don't have any so set to zero.
diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h
index b565740c3..9f3b6cbdb 100644
--- a/src/ui/clipboard.h
+++ b/src/ui/clipboard.h
@@ -44,7 +44,7 @@ class ClipboardManager {
public:
virtual void copy(SPDesktop *desktop) = 0;
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *) = 0;
- virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style) = 0;
+ virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol = true) = 0;
virtual bool paste(SPDesktop *desktop, bool in_place = false) = 0;
virtual bool pasteStyle(SPDesktop *desktop) = 0;
virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) = 0;
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index bdba3e154..eeb4d6cbe 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -498,7 +498,7 @@ void SymbolsDialog::iconChanged() {
}
ClipboardManager *cm = ClipboardManager::get();
- cm->copySymbol(symbol->getRepr(), style);
+ cm->copySymbol(symbol->getRepr(), style, symbolDocument == currentDocument);
}
}