summaryrefslogtreecommitdiffstats
path: root/src/ui/clipboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/clipboard.cpp')
-rw-r--r--src/ui/clipboard.cpp97
1 files changed, 48 insertions, 49 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 4f4f8a022..d1191cb3b 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -1,5 +1,6 @@
-/** @file
- * @brief System-wide clipboard management - implementation
+/**
+ * @file
+ * System-wide clipboard management - implementation.
*/
/* Authors:
* Krzysztof KosiƄski <tweenk@o2.pl>
@@ -46,8 +47,6 @@
#include "extension/input.h"
#include "extension/output.h"
#include "selection-chemistry.h"
-#include "libnr/nr-rect.h"
-#include "libnr/nr-convert2geom.h"
#include <2geom/rect.h>
#include <2geom/transforms.h>
#include "box3d.h"
@@ -84,7 +83,7 @@
#include "snap.h"
#include "persp3d.h"
-/// @brief Made up mimetype to represent Gdk::Pixbuf clipboard contents
+/// Made up mimetype to represent Gdk::Pixbuf clipboard contents.
#define CLIPBOARD_GDK_PIXBUF_TARGET "image/x-gdk-pixbuf"
#define CLIPBOARD_TEXT_TARGET "text/plain"
@@ -104,7 +103,7 @@ namespace UI {
/**
- * @brief Default implementation of the clipboard manager
+ * Default implementation of the clipboard manager.
*/
class ClipboardManagerImpl : public ClipboardManager {
public:
@@ -194,7 +193,7 @@ ClipboardManagerImpl::~ClipboardManagerImpl() {}
/**
- * @brief Copy selection contents to the clipboard
+ * Copy selection contents to the clipboard.
*/
void ClipboardManagerImpl::copy(SPDesktop *desktop)
{
@@ -274,8 +273,8 @@ void ClipboardManagerImpl::copy(SPDesktop *desktop)
/**
- * @brief Copy a Live Path Effect path parameter to the clipboard
- * @param pp The path parameter to store in the clipboard
+ * Copy a Live Path Effect path parameter to the clipboard.
+ * @param pp The path parameter to store in the clipboard.
*/
void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam *pp)
{
@@ -301,8 +300,8 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam
}
/**
- * @brief Paste from the system clipboard into the active desktop
- * @param in_place Whether to put the contents where they were when copied
+ * Paste from the system clipboard into the active desktop.
+ * @param in_place Whether to put the contents where they were when copied.
*/
bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place)
{
@@ -343,7 +342,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place)
}
/**
- * @brief Returns the id of the first visible copied object
+ * Returns the id of the first visible copied object.
*/
const gchar *ClipboardManagerImpl::getFirstObjectID()
{
@@ -379,7 +378,7 @@ const gchar *ClipboardManagerImpl::getFirstObjectID()
/**
- * @brief Implements the Paste Style action
+ * Implements the Paste Style action.
*/
bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
{
@@ -427,7 +426,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
/**
- * @brief Resize the selection or each object in the selection to match the clipboard's size
+ * Resize the selection or each object in the selection to match the clipboard's size.
* @param separately Whether to scale each object in the selection separately
* @param apply_x Whether to scale the width of objects / selection
* @param apply_y Whether to scale the height of objects / selection
@@ -467,7 +466,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
if (separately) {
for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) {
SPItem *item = SP_ITEM(i->data);
- Geom::OptRect obj_size = item->getBboxDesktop();
+ Geom::OptRect obj_size = item->desktopVisualBounds();
if ( !obj_size ) {
continue;
}
@@ -476,7 +475,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
}
// resize the selection as a whole
else {
- Geom::OptRect sel_size = selection->bounds();
+ Geom::OptRect sel_size = selection->visualBounds();
if ( sel_size ) {
sp_selection_scale_relative(selection, sel_size->midpoint(),
_getScale(desktop, min, max, *sel_size, apply_x, apply_y));
@@ -490,7 +489,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
/**
- * @brief Applies a path effect from the clipboard to the selected path
+ * Applies a path effect from the clipboard to the selected path.
*/
bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
{
@@ -534,7 +533,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
/**
- * @brief Get LPE path data from the clipboard
+ * Get LPE path data from the clipboard.
* @return The retrieved path data (contents of the d attribute), or "" if no path was found
*/
Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop)
@@ -557,8 +556,8 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop)
/**
- * @brief Get object id of a shape or text item from the clipboard
- * @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found
+ * Get object id of a shape or text item from the clipboard.
+ * @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found.
*/
Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
{
@@ -585,7 +584,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
/**
- * @brief Iterate over a list of items and copy them to the clipboard.
+ * Iterate over a list of items and copy them to the clipboard.
*/
void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
{
@@ -636,7 +635,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
}
}
- Geom::OptRect size = selection->bounds();
+ Geom::OptRect size = selection->visualBounds();
if (size) {
sp_repr_set_point(_clipnode, "min", size->min());
sp_repr_set_point(_clipnode, "max", size->max());
@@ -647,7 +646,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
/**
- * @brief Recursively copy all the definitions used by a given item to the clipboard defs
+ * Recursively copy all the definitions used by a given item to the clipboard defs.
*/
void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
{
@@ -736,7 +735,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
/**
- * @brief Copy a single gradient to the clipboard's defs element
+ * Copy a single gradient to the clipboard's defs element.
*/
void ClipboardManagerImpl::_copyGradient(SPGradient *gradient)
{
@@ -749,7 +748,7 @@ void ClipboardManagerImpl::_copyGradient(SPGradient *gradient)
/**
- * @brief Copy a single pattern to the clipboard document's defs element
+ * Copy a single pattern to the clipboard document's defs element.
*/
void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
{
@@ -770,7 +769,7 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
/**
- * @brief Copy a text path to the clipboard's defs element
+ * Copy a text path to the clipboard's defs element.
*/
void ClipboardManagerImpl::_copyTextPath(SPTextPath *tp)
{
@@ -789,7 +788,7 @@ void ClipboardManagerImpl::_copyTextPath(SPTextPath *tp)
/**
- * @brief Copy a single XML node from one document to another
+ * Copy a single XML node from one document to another.
* @param node The node to be copied
* @param target_doc The document to which the node is to be copied
* @param parent The node in the target document which will become the parent of the copied node
@@ -805,7 +804,7 @@ Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node,
/**
- * @brief Paste the contents of a document into the active desktop
+ * Paste the contents of a document into the active desktop.
* @param clipdoc The document to paste
* @param in_place Whether to paste the selection where it was when copied
* @pre @c clipdoc is not empty and items can be added to the current layer
@@ -852,7 +851,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo
target_document->ensureUpToDate();
// move selection either to original position (in_place) or to mouse pointer
- Geom::OptRect sel_bbox = selection->bounds();
+ Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
// get offset of selection to original position of copied elements
Geom::Point pos_original;
@@ -884,9 +883,9 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo
/**
- * @brief Paste SVG defs from the document retrieved from the clipboard into the active document
- * @param clipdoc The document to paste
- * @pre @c clipdoc != NULL and pasting into the active document is possible
+ * Paste SVG defs from the document retrieved from the clipboard into the active document.
+ * @param clipdoc The document to paste.
+ * @pre @c clipdoc != NULL and pasting into the active document is possible.
*/
void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc)
{
@@ -894,7 +893,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc)
SPDocument *target_document = sp_desktop_document(desktop);
Inkscape::XML::Node *root = clipdoc->getReprRoot();
Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1);
- Inkscape::XML::Node *target_defs = SP_DOCUMENT_DEFS(target_document)->getRepr();
+ Inkscape::XML::Node *target_defs = target_document->getDefs()->getRepr();
Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc();
prevent_id_clashes(clipdoc, target_document);
@@ -906,7 +905,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc)
/**
- * @brief Retrieve a bitmap image from the clipboard and paste it into the active document
+ * Retrieve a bitmap image from the clipboard and paste it into the active document.
*/
bool ClipboardManagerImpl::_pasteImage(SPDocument *doc)
{
@@ -945,7 +944,7 @@ bool ClipboardManagerImpl::_pasteImage(SPDocument *doc)
}
/**
- * @brief Paste text into the selected text object or create a new one to hold it
+ * Paste text into the selected text object or create a new one to hold it.
*/
bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop)
{
@@ -970,7 +969,7 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop)
/**
- * @brief Attempt to parse the passed string as a hexadecimal RGB or RGBA color
+ * Attempt to parse the passed string as a hexadecimal RGB or RGBA color.
* @param text The Glib::ustring to parse
* @return New CSS style representation if the parsing was successful, NULL otherwise
*/
@@ -1040,7 +1039,7 @@ SPCSSAttr *ClipboardManagerImpl::_parseColor(const Glib::ustring &text)
/**
- * @brief Applies a pasted path effect to a given item
+ * Applies a pasted path effect to a given item.
*/
void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectstack)
{
@@ -1073,7 +1072,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta
/**
- * @brief Retrieve the clipboard contents as a document
+ * Retrieve the clipboard contents as a document.
* @return Clipboard contents converted to SPDocument, or NULL if no suitable content was present
*/
SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_target)
@@ -1159,7 +1158,7 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ
/**
- * @brief Callback called when some other application requests data from Inkscape
+ * Callback called when some other application requests data from Inkscape.
*
* Finds a suitable output extension to save the internal clipboard document,
* then saves it to memory and sets the clipboard contents.
@@ -1197,7 +1196,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/)
gdouble dpi = PX_PER_IN;
guint32 bgcolor = 0x00000000;
- Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed);
+ Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed);
Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions());
unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5);
@@ -1234,7 +1233,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/)
/**
- * @brief Callback when someone else takes the clipboard
+ * Callback when someone else takes the clipboard.
*
* When the clipboard owner changes, this callback clears the internal clipboard document
* to reduce memory usage.
@@ -1247,14 +1246,14 @@ void ClipboardManagerImpl::_onClear()
/**
- * @brief Creates an internal clipboard document from scratch
+ * Creates an internal clipboard document from scratch.
*/
void ClipboardManagerImpl::_createInternalClipboard()
{
if ( _clipboardSPDoc == NULL ) {
_clipboardSPDoc = SPDocument::createNewDoc(NULL, false, true);
//g_assert( _clipboardSPDoc != NULL );
- _defs = SP_DOCUMENT_DEFS(_clipboardSPDoc)->getRepr();
+ _defs = _clipboardSPDoc->getDefs()->getRepr();
_doc = _clipboardSPDoc->getReprDoc();
_root = _clipboardSPDoc->getReprRoot();
@@ -1272,7 +1271,7 @@ void ClipboardManagerImpl::_createInternalClipboard()
/**
- * @brief Deletes the internal clipboard document
+ * Deletes the internal clipboard document.
*/
void ClipboardManagerImpl::_discardInternalClipboard()
{
@@ -1288,7 +1287,7 @@ void ClipboardManagerImpl::_discardInternalClipboard()
/**
- * @brief Get the scale to resize an item, based on the command and desktop state
+ * Get the scale to resize an item, based on the command and desktop state.
*/
Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y)
{
@@ -1317,7 +1316,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons
/**
- * @brief Find the most suitable clipboard target
+ * Find the most suitable clipboard target.
*/
Glib::ustring ClipboardManagerImpl::_getBestTarget()
{
@@ -1376,7 +1375,7 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget()
/**
- * @brief Set the clipboard targets to reflect the mimetypes Inkscape can output
+ * Set the clipboard targets to reflect the mimetypes Inkscape can output.
*/
void ClipboardManagerImpl::_setClipboardTargets()
{
@@ -1451,7 +1450,7 @@ void ClipboardManagerImpl::_setClipboardTargets()
/**
- * @brief Set the string representation of a 32-bit RGBA color as the clipboard contents
+ * Set the string representation of a 32-bit RGBA color as the clipboard contents.
*/
void ClipboardManagerImpl::_setClipboardColor(guint32 color)
{
@@ -1462,7 +1461,7 @@ void ClipboardManagerImpl::_setClipboardColor(guint32 color)
/**
- * @brief Put a notification on the mesage stack
+ * Put a notification on the mesage stack.
*/
void ClipboardManagerImpl::_userWarn(SPDesktop *desktop, char const *msg)
{