Source Code (Use browser search to find items of interest.)

Class Index

killustrator'PasteCmd (./koffice/killustrator/share/PasteCmd.h:34)

class PasteCmd : public Command {
public:
  PasteCmd (GDocument* doc);
  ~PasteCmd ();

  void execute ();
  void unexecute ();

private:
  GDocument* document;
  list<GObject*> objects;
};

killustrator'PasteCmd::PasteCmd() (./koffice/killustrator/share/PasteCmd.cc:36)

PasteCmd::PasteCmd (GDocument* doc) 
  : Command(i18n("Paste")) 
{
  document = doc;
}


killustrator'PasteCmd::~PasteCmd() (./koffice/killustrator/share/PasteCmd.cc:42)

PasteCmd::~PasteCmd () {
  for (list<GObject*>::iterator it = objects.begin ();
       it != objects.end (); it++)
      (*it)->unref ();
}


killustrator'PasteCmd::execute() (./koffice/killustrator/share/PasteCmd.cc:48)

void PasteCmd::execute () {
    for (list<GObject*>::iterator it = objects.begin ();
	 it != objects.end (); it++)
	(*it)->unref ();
    objects.clear ();
    const char* buf = QApplication::clipboard ()->text ();
    if (::strlen (buf)) {
      if (::strncmp (buf, "<?xml", 5) == 0) {
	// KIllustrator objects
	QWMatrix m;
	m.translate (10, 10);
	
	istrstream is (buf);
	document->insertFromXml (is, objects);
	document->unselectAllObjects ();
	for (list<GObject*>::iterator it = objects.begin ();
	     it != objects.end (); it++) {
	  (*it)->ref ();
	  (*it)->transform (m, true);
	  document->selectObject (*it);
	}
      }
      else {
	// plain text
	GText *tobj = new GText ();
	tobj->setText (buf);
	objects.push_back (tobj);
	document->insertObject (tobj);
      }
    }
}


killustrator'PasteCmd::unexecute() (./koffice/killustrator/share/PasteCmd.cc:80)

void PasteCmd::unexecute () {
  for (list<GObject*>::iterator it = objects.begin ();
       it != objects.end (); it++)
      document->deleteObject (*it);
}