content/base/public/nsCopySupport.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/public/nsCopySupport.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsCopySupport_h__
    1.10 +#define nsCopySupport_h__
    1.11 +
    1.12 +#include "nscore.h"
    1.13 +#include "nsINode.h"
    1.14 +
    1.15 +class nsISelection;
    1.16 +class nsIDocument;
    1.17 +class nsIImageLoadingContent;
    1.18 +class nsIContent;
    1.19 +class nsITransferable;
    1.20 +class nsACString;
    1.21 +class nsAString;
    1.22 +class nsIPresShell;
    1.23 +class nsILoadContext;
    1.24 +
    1.25 +class nsCopySupport
    1.26 +{
    1.27 +  // class of static helper functions for copy support
    1.28 +  public:
    1.29 +    static nsresult HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, int16_t aClipboardID);
    1.30 +    static nsresult DoHooks(nsIDocument *aDoc, nsITransferable *aTrans,
    1.31 +                            bool *aDoPutOnClipboard);
    1.32 +
    1.33 +    // Get the selection, or entire document, in the format specified by the mime type
    1.34 +    // (text/html or text/plain). If aSel is non-null, use it, otherwise get the entire
    1.35 +    // doc.
    1.36 +    static nsresult GetContents(const nsACString& aMimeType, uint32_t aFlags, nsISelection *aSel, nsIDocument *aDoc, nsAString& outdata);
    1.37 +    
    1.38 +    static nsresult ImageCopy(nsIImageLoadingContent* aImageElement,
    1.39 +                              nsILoadContext* aLoadContext,
    1.40 +                              int32_t aCopyFlags);
    1.41 +
    1.42 +    // Get the selection as a transferable. Similar to HTMLCopy except does
    1.43 +    // not deal with the clipboard.
    1.44 +    static nsresult GetTransferableForSelection(nsISelection* aSelection,
    1.45 +                                                nsIDocument* aDocument,
    1.46 +                                                nsITransferable** aTransferable);
    1.47 +
    1.48 +    // Same as GetTransferableForSelection, but doesn't skip invisible content.
    1.49 +    static nsresult GetTransferableForNode(nsINode* aNode,
    1.50 +                                           nsIDocument* aDoc,
    1.51 +                                           nsITransferable** aTransferable);
    1.52 +    /**
    1.53 +     * Retrieve the selection for the given document. If the current focus
    1.54 +     * within the document has its own selection, aSelection will be set to it
    1.55 +     * and this focused content node returned. Otherwise, aSelection will be
    1.56 +     * set to the document's selection and null will be returned.
    1.57 +     */
    1.58 +    static nsIContent* GetSelectionForCopy(nsIDocument* aDocument,
    1.59 +                                           nsISelection** aSelection);
    1.60 +
    1.61 +    /**
    1.62 +     * Returns true if a copy operation is currently permitted based on the
    1.63 +     * current focus and selection within the specified document.
    1.64 +     */
    1.65 +    static bool CanCopy(nsIDocument* aDocument);
    1.66 +
    1.67 +    /**
    1.68 +     * Fires a cut, copy or paste event, on the given presshell, depending
    1.69 +     * on the value of aType, which should be either NS_CUT, NS_COPY or
    1.70 +     * NS_PASTE, and perform the default copy action if the event was not
    1.71 +     * cancelled.
    1.72 +     *
    1.73 +     * If aSelection is specified, then this selection is used as the target
    1.74 +     * of the operation. Otherwise, GetSelectionForCopy is used to retrieve
    1.75 +     * the current selection.
    1.76 +     *
    1.77 +     * This will fire a cut, copy or paste event at the node at the start
    1.78 +     * point of the selection. If a cut or copy event is not cancelled, the
    1.79 +     * selection is copied to the clipboard and true is returned. Paste events
    1.80 +     * have no default behaviour but true will be returned. It is expected
    1.81 +     * that the caller will execute any needed default paste behaviour. Also,
    1.82 +     * note that this method only copies text to the clipboard, the caller is
    1.83 +     * responsible for removing the content during a cut operation if true is
    1.84 +     * returned.
    1.85 +     *
    1.86 +     * aClipboardType specifies which clipboard to use, from nsIClipboard.
    1.87 +     *
    1.88 +     * If the event is cancelled or an error occurs, false will be returned.
    1.89 +     */
    1.90 +    static bool FireClipboardEvent(int32_t aType,
    1.91 +                                   int32_t aClipboardType,
    1.92 +                                   nsIPresShell* aPresShell,
    1.93 +                                   nsISelection* aSelection);
    1.94 +};
    1.95 +
    1.96 +#endif

mercurial