1 /* 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 */ 23 24 #ifndef Clipboard_h 25 #define Clipboard_h 26 27 #include "CachedResourceHandle.h" 28 #include "ClipboardAccessPolicy.h" 29 #include "DragActions.h" 30 #include "DragImage.h" 31 #include "IntPoint.h" 32 #include "Node.h" 33 34 namespace WebCore { 35 36 // State available during IE's events for drag and drop and copy/paste 37 class Clipboard : public RefCounted<Clipboard> { 38 public: ~Clipboard()39 virtual ~Clipboard() { } 40 41 // Is this operation a drag-drop or a copy-paste? isForDragging()42 bool isForDragging() const { return m_forDragging; } 43 dropEffect()44 String dropEffect() const { return m_dropEffect; } 45 void setDropEffect(const String&); effectAllowed()46 String effectAllowed() const { return m_effectAllowed; } 47 void setEffectAllowed(const String&); 48 49 virtual void clearData(const String& type) = 0; 50 virtual void clearAllData() = 0; 51 virtual String getData(const String& type, bool& success) const = 0; 52 virtual bool setData(const String& type, const String& data) = 0; 53 54 // extensions beyond IE's API 55 virtual HashSet<String> types() const = 0; 56 dragLocation()57 IntPoint dragLocation() const { return m_dragLoc; } dragImage()58 CachedImage* dragImage() const { return m_dragImage.get(); } 59 virtual void setDragImage(CachedImage*, const IntPoint&) = 0; dragImageElement()60 Node* dragImageElement() { return m_dragImageElement.get(); } 61 virtual void setDragImageElement(Node*, const IntPoint&) = 0; 62 63 virtual DragImageRef createDragImage(IntPoint& dragLocation) const = 0; 64 virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0; 65 virtual void writeURL(const KURL&, const String&, Frame*) = 0; 66 virtual void writeRange(Range*, Frame*) = 0; 67 68 virtual bool hasData() = 0; 69 70 void setAccessPolicy(ClipboardAccessPolicy); 71 72 bool sourceOperation(DragOperation&) const; 73 bool destinationOperation(DragOperation&) const; 74 void setSourceOperation(DragOperation); 75 void setDestinationOperation(DragOperation); 76 setDragHasStarted()77 void setDragHasStarted() { m_dragStarted = true; } 78 79 protected: 80 Clipboard(ClipboardAccessPolicy, bool isForDragging); 81 policy()82 ClipboardAccessPolicy policy() const { return m_policy; } dragStarted()83 bool dragStarted() const { return m_dragStarted; } 84 85 private: 86 ClipboardAccessPolicy m_policy; 87 String m_dropEffect; 88 String m_effectAllowed; 89 bool m_dragStarted; 90 91 protected: 92 bool m_forDragging; 93 IntPoint m_dragLoc; 94 CachedResourceHandle<CachedImage> m_dragImage; 95 RefPtr<Node> m_dragImageElement; 96 }; 97 98 } // namespace WebCore 99 100 #endif // Clipboard_h 101