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 class FileList; 37 38 // State available during IE's events for drag and drop and copy/paste 39 class Clipboard : public RefCounted<Clipboard> { 40 public: ~Clipboard()41 virtual ~Clipboard() { } 42 43 // Is this operation a drag-drop or a copy-paste? isForDragging()44 bool isForDragging() const { return m_forDragging; } 45 dropEffect()46 String dropEffect() const { return m_dropEffect; } 47 void setDropEffect(const String&); effectAllowed()48 String effectAllowed() const { return m_effectAllowed; } 49 void setEffectAllowed(const String&); 50 51 virtual void clearData(const String& type) = 0; 52 virtual void clearAllData() = 0; 53 virtual String getData(const String& type, bool& success) const = 0; 54 virtual bool setData(const String& type, const String& data) = 0; 55 56 // extensions beyond IE's API 57 virtual HashSet<String> types() const = 0; 58 virtual PassRefPtr<FileList> files() const = 0; 59 dragLocation()60 IntPoint dragLocation() const { return m_dragLoc; } dragImage()61 CachedImage* dragImage() const { return m_dragImage.get(); } 62 virtual void setDragImage(CachedImage*, const IntPoint&) = 0; dragImageElement()63 Node* dragImageElement() const { return m_dragImageElement.get(); } 64 virtual void setDragImageElement(Node*, const IntPoint&) = 0; 65 66 virtual DragImageRef createDragImage(IntPoint& dragLocation) const = 0; 67 virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0; 68 virtual void writeURL(const KURL&, const String&, Frame*) = 0; 69 virtual void writeRange(Range*, Frame*) = 0; 70 71 virtual bool hasData() = 0; 72 73 void setAccessPolicy(ClipboardAccessPolicy); 74 75 bool sourceOperation(DragOperation&) const; 76 bool destinationOperation(DragOperation&) const; 77 void setSourceOperation(DragOperation); 78 void setDestinationOperation(DragOperation); 79 setDragHasStarted()80 void setDragHasStarted() { m_dragStarted = true; } 81 82 protected: 83 Clipboard(ClipboardAccessPolicy, bool isForDragging); 84 policy()85 ClipboardAccessPolicy policy() const { return m_policy; } dragStarted()86 bool dragStarted() const { return m_dragStarted; } 87 88 private: 89 ClipboardAccessPolicy m_policy; 90 String m_dropEffect; 91 String m_effectAllowed; 92 bool m_dragStarted; 93 94 protected: 95 bool m_forDragging; 96 IntPoint m_dragLoc; 97 CachedResourceHandle<CachedImage> m_dragImage; 98 RefPtr<Node> m_dragImageElement; 99 }; 100 101 } // namespace WebCore 102 103 #endif // Clipboard_h 104