зеркало из https://github.com/mozilla/gecko-dev.git
Finishing clipboard ifdef so we can remove the old clipboard.
This commit is contained in:
Родитель
af15e24c5c
Коммит
616c553b24
|
@ -40,7 +40,9 @@
|
||||||
#include "nsIAtom.h"
|
#include "nsIAtom.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsVoidArray.h"
|
||||||
#include "nsICaret.h"
|
#include "nsICaret.h"
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
#include "nsISelectionMgr.h"
|
#include "nsISelectionMgr.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsIContentIterator.h"
|
#include "nsIContentIterator.h"
|
||||||
|
@ -71,8 +73,6 @@
|
||||||
// END
|
// END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define NEW_CLIPBOARD_SUPPORT
|
|
||||||
|
|
||||||
#ifdef NEW_CLIPBOARD_SUPPORT
|
#ifdef NEW_CLIPBOARD_SUPPORT
|
||||||
|
|
||||||
// Drag & Drop, Clipboard
|
// Drag & Drop, Clipboard
|
||||||
|
@ -836,12 +836,15 @@ NS_IMETHODIMP nsEditor::Cut()
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
extern "C" NS_EXPORT nsISelectionMgr* GetSelectionMgr();
|
extern "C" NS_EXPORT nsISelectionMgr* GetSelectionMgr();
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_IMETHODIMP nsEditor::Copy()
|
NS_IMETHODIMP nsEditor::Copy()
|
||||||
{
|
{
|
||||||
//printf("nsEditor::Copy\n");
|
//printf("nsEditor::Copy\n");
|
||||||
|
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
// Get the nsSelectionMgr:
|
// Get the nsSelectionMgr:
|
||||||
// XXX BWEEP BWEEP TEMPORARY!
|
// XXX BWEEP BWEEP TEMPORARY!
|
||||||
// The selection mgr needs to be a service.
|
// The selection mgr needs to be a service.
|
||||||
|
@ -857,6 +860,10 @@ NS_IMETHODIMP nsEditor::Copy()
|
||||||
|
|
||||||
//NS_ADD_REF(theSelectionMgr);
|
//NS_ADD_REF(theSelectionMgr);
|
||||||
return mPresShell->DoCopy(selectionMgr);
|
return mPresShell->DoCopy(selectionMgr);
|
||||||
|
#else
|
||||||
|
return mPresShell->DoCopy();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsEditor::Paste()
|
NS_IMETHODIMP nsEditor::Paste()
|
||||||
|
|
|
@ -40,7 +40,9 @@
|
||||||
#include "nsIAtom.h"
|
#include "nsIAtom.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsVoidArray.h"
|
||||||
#include "nsICaret.h"
|
#include "nsICaret.h"
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
#include "nsISelectionMgr.h"
|
#include "nsISelectionMgr.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsIContentIterator.h"
|
#include "nsIContentIterator.h"
|
||||||
|
@ -71,8 +73,6 @@
|
||||||
// END
|
// END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define NEW_CLIPBOARD_SUPPORT
|
|
||||||
|
|
||||||
#ifdef NEW_CLIPBOARD_SUPPORT
|
#ifdef NEW_CLIPBOARD_SUPPORT
|
||||||
|
|
||||||
// Drag & Drop, Clipboard
|
// Drag & Drop, Clipboard
|
||||||
|
@ -836,12 +836,15 @@ NS_IMETHODIMP nsEditor::Cut()
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
extern "C" NS_EXPORT nsISelectionMgr* GetSelectionMgr();
|
extern "C" NS_EXPORT nsISelectionMgr* GetSelectionMgr();
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_IMETHODIMP nsEditor::Copy()
|
NS_IMETHODIMP nsEditor::Copy()
|
||||||
{
|
{
|
||||||
//printf("nsEditor::Copy\n");
|
//printf("nsEditor::Copy\n");
|
||||||
|
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
// Get the nsSelectionMgr:
|
// Get the nsSelectionMgr:
|
||||||
// XXX BWEEP BWEEP TEMPORARY!
|
// XXX BWEEP BWEEP TEMPORARY!
|
||||||
// The selection mgr needs to be a service.
|
// The selection mgr needs to be a service.
|
||||||
|
@ -857,6 +860,10 @@ NS_IMETHODIMP nsEditor::Copy()
|
||||||
|
|
||||||
//NS_ADD_REF(theSelectionMgr);
|
//NS_ADD_REF(theSelectionMgr);
|
||||||
return mPresShell->DoCopy(selectionMgr);
|
return mPresShell->DoCopy(selectionMgr);
|
||||||
|
#else
|
||||||
|
return mPresShell->DoCopy();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsEditor::Paste()
|
NS_IMETHODIMP nsEditor::Paste()
|
||||||
|
|
|
@ -38,7 +38,9 @@ class nsString;
|
||||||
class nsStringArray;
|
class nsStringArray;
|
||||||
class nsICaret;
|
class nsICaret;
|
||||||
class nsIStyleContext;
|
class nsIStyleContext;
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
class nsISelectionMgr;
|
class nsISelectionMgr;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NS_IPRESSHELL_IID \
|
#define NS_IPRESSHELL_IID \
|
||||||
{ 0x76e79c60, 0x944e, 0x11d1, \
|
{ 0x76e79c60, 0x944e, 0x11d1, \
|
||||||
|
@ -261,7 +263,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Notify the SelectionMgr that we have something to copy.
|
* Notify the SelectionMgr that we have something to copy.
|
||||||
*/
|
*/
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr) = 0;
|
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr) = 0;
|
||||||
|
#else
|
||||||
|
NS_IMETHOD DoCopy() = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the caret, if it exists. AddRefs it.
|
* Get the caret, if it exists. AddRefs it.
|
||||||
|
|
|
@ -326,7 +326,12 @@ public:
|
||||||
PRUint32 aVFlags,
|
PRUint32 aVFlags,
|
||||||
PRInt32 aHOffsetPercent,
|
PRInt32 aHOffsetPercent,
|
||||||
PRUint32 aHFlags) const;
|
PRUint32 aHFlags) const;
|
||||||
|
|
||||||
|
#ifdef NEW_CLIPBOARD_SUPPORT
|
||||||
|
NS_IMETHOD DoCopy();
|
||||||
|
#else
|
||||||
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr);
|
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr);
|
||||||
|
#endif
|
||||||
|
|
||||||
//nsIViewObserver interface
|
//nsIViewObserver interface
|
||||||
|
|
||||||
|
@ -1542,6 +1547,83 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEW_CLIPBOARD_SUPPORT
|
||||||
|
// New way
|
||||||
|
NS_IMETHODIMP
|
||||||
|
PresShell::DoCopy()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIDocument> doc;
|
||||||
|
GetDocument(getter_AddRefs(doc));
|
||||||
|
if (doc) {
|
||||||
|
nsString buffer;
|
||||||
|
|
||||||
|
nsIDOMSelection* sel = nsnull;
|
||||||
|
GetSelection(&sel);
|
||||||
|
|
||||||
|
if (sel != nsnull)
|
||||||
|
doc->CreateXIF(buffer,sel);
|
||||||
|
NS_IF_RELEASE(sel);
|
||||||
|
|
||||||
|
// Get the Clipboard
|
||||||
|
nsIClipboard* clipboard;
|
||||||
|
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
|
||||||
|
kIClipboardIID,
|
||||||
|
(nsISupports **)&clipboard);
|
||||||
|
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
|
||||||
|
// Create a data flavor to tell the transferable
|
||||||
|
// that it is about to receive XIF
|
||||||
|
nsIDataFlavor * flavor;
|
||||||
|
rv = nsComponentManager::CreateInstance(kCDataFlavorCID,
|
||||||
|
nsnull,
|
||||||
|
kIDataFlavorIID, (void**) &flavor);
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
// Initialize data flavor to XIF
|
||||||
|
flavor->Init(kXIFMime, "XIF");
|
||||||
|
|
||||||
|
// Create a transferable for putting data on the Clipboard
|
||||||
|
nsITransferable * trans;
|
||||||
|
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
|
||||||
|
kITransferableIID, (void**) &trans);
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
// The data on the clipboard will be in "XIF" format
|
||||||
|
// so give the clipboard transferable a "XIFConverter" for
|
||||||
|
// converting from XIF to other formats
|
||||||
|
nsIFormatConverter * xifConverter;
|
||||||
|
rv = nsComponentManager::CreateInstance(kCXIFConverterCID, nsnull,
|
||||||
|
kIFormatConverterIID, (void**) &xifConverter);
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
// Add the XIF DataFlavor to the transferable
|
||||||
|
// this tells the transferable that it can handle receiving the XIF format
|
||||||
|
trans->AddDataFlavor(flavor);
|
||||||
|
|
||||||
|
// Add the converter for going from XIF to other formats
|
||||||
|
trans->SetConverter(xifConverter);
|
||||||
|
|
||||||
|
// Now add the XIF data to the transferable
|
||||||
|
trans->SetTransferData(flavor, buffer.ToNewCString(), buffer.Length());
|
||||||
|
|
||||||
|
// put the transferable on the clipboard
|
||||||
|
clipboard->SetData(trans, nsnull);
|
||||||
|
|
||||||
|
NS_IF_RELEASE(xifConverter);
|
||||||
|
}
|
||||||
|
NS_IF_RELEASE(trans);
|
||||||
|
}
|
||||||
|
NS_IF_RELEASE(flavor);
|
||||||
|
}
|
||||||
|
NS_IF_RELEASE(clipboard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Old SelectionMgr implementation.
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
||||||
{
|
{
|
||||||
|
@ -1557,8 +1639,6 @@ PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
||||||
doc->CreateXIF(buffer,sel);
|
doc->CreateXIF(buffer,sel);
|
||||||
NS_IF_RELEASE(sel);
|
NS_IF_RELEASE(sel);
|
||||||
|
|
||||||
////////////////////////// Old Way
|
|
||||||
#ifndef NEW_CLIPBOARD_SUPPORT
|
|
||||||
nsIParser* parser;
|
nsIParser* parser;
|
||||||
|
|
||||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||||
|
@ -1605,61 +1685,13 @@ PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
||||||
NS_IF_RELEASE(sink);
|
NS_IF_RELEASE(sink);
|
||||||
NS_RELEASE(parser);
|
NS_RELEASE(parser);
|
||||||
|
|
||||||
#else /////////////////////////// New Way
|
|
||||||
// Put XIF into transferable
|
|
||||||
|
|
||||||
// Get the Clipboard
|
|
||||||
nsIClipboard* clipboard;
|
|
||||||
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
|
|
||||||
kIClipboardIID,
|
|
||||||
(nsISupports **)&clipboard);
|
|
||||||
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
|
|
||||||
// Create a data flavor to tell the transferable
|
|
||||||
// that it is about to receive XIF
|
|
||||||
nsIDataFlavor * flavor;
|
|
||||||
rv = nsComponentManager::CreateInstance(kCDataFlavorCID, nsnull, kIDataFlavorIID, (void**) &flavor);
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
// Initialize data flavor to XIF
|
|
||||||
flavor->Init(kXIFMime, "XIF");
|
|
||||||
|
|
||||||
// Create a transferable for putting data on the Clipboard
|
|
||||||
nsITransferable * trans;
|
|
||||||
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull, kITransferableIID, (void**) &trans);
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
// The data on the clipboard will be in "XIF" format
|
|
||||||
// so give the clipboard transferable a "XIFConverter" for
|
|
||||||
// converting from XIF to other formats
|
|
||||||
nsIFormatConverter * xifConverter;
|
|
||||||
rv = nsComponentManager::CreateInstance(kCXIFConverterCID, nsnull, kIFormatConverterIID, (void**) &xifConverter);
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
// Add the XIF DataFlavor to the transferable
|
|
||||||
// this tells the transferable that it can handle receiving the XIF format
|
|
||||||
trans->AddDataFlavor(flavor);
|
|
||||||
|
|
||||||
// Add the converter for going from XIF to other formats
|
|
||||||
trans->SetConverter(xifConverter);
|
|
||||||
|
|
||||||
// Now add the XIF data to the transferable
|
|
||||||
trans->SetTransferData(flavor, buffer.ToNewCString(), buffer.Length());
|
|
||||||
|
|
||||||
// put the transferable on the clipboard
|
|
||||||
clipboard->SetData(trans, nsnull);
|
|
||||||
|
|
||||||
NS_IF_RELEASE(xifConverter);
|
|
||||||
}
|
|
||||||
NS_IF_RELEASE(trans);
|
|
||||||
}
|
|
||||||
NS_IF_RELEASE(flavor);
|
|
||||||
}
|
|
||||||
NS_IF_RELEASE(clipboard);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NEW_CLIPBOARD_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::ContentChanged(nsIDocument *aDocument,
|
PresShell::ContentChanged(nsIDocument *aDocument,
|
||||||
nsIContent* aContent,
|
nsIContent* aContent,
|
||||||
|
|
|
@ -38,7 +38,9 @@ class nsString;
|
||||||
class nsStringArray;
|
class nsStringArray;
|
||||||
class nsICaret;
|
class nsICaret;
|
||||||
class nsIStyleContext;
|
class nsIStyleContext;
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
class nsISelectionMgr;
|
class nsISelectionMgr;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NS_IPRESSHELL_IID \
|
#define NS_IPRESSHELL_IID \
|
||||||
{ 0x76e79c60, 0x944e, 0x11d1, \
|
{ 0x76e79c60, 0x944e, 0x11d1, \
|
||||||
|
@ -261,7 +263,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Notify the SelectionMgr that we have something to copy.
|
* Notify the SelectionMgr that we have something to copy.
|
||||||
*/
|
*/
|
||||||
|
#ifndef NEW_CLIPBOARD_SUPPORT
|
||||||
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr) = 0;
|
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr) = 0;
|
||||||
|
#else
|
||||||
|
NS_IMETHOD DoCopy() = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the caret, if it exists. AddRefs it.
|
* Get the caret, if it exists. AddRefs it.
|
||||||
|
|
|
@ -326,7 +326,12 @@ public:
|
||||||
PRUint32 aVFlags,
|
PRUint32 aVFlags,
|
||||||
PRInt32 aHOffsetPercent,
|
PRInt32 aHOffsetPercent,
|
||||||
PRUint32 aHFlags) const;
|
PRUint32 aHFlags) const;
|
||||||
|
|
||||||
|
#ifdef NEW_CLIPBOARD_SUPPORT
|
||||||
|
NS_IMETHOD DoCopy();
|
||||||
|
#else
|
||||||
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr);
|
NS_IMETHOD DoCopy(nsISelectionMgr* aSelectionMgr);
|
||||||
|
#endif
|
||||||
|
|
||||||
//nsIViewObserver interface
|
//nsIViewObserver interface
|
||||||
|
|
||||||
|
@ -1542,6 +1547,83 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NEW_CLIPBOARD_SUPPORT
|
||||||
|
// New way
|
||||||
|
NS_IMETHODIMP
|
||||||
|
PresShell::DoCopy()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIDocument> doc;
|
||||||
|
GetDocument(getter_AddRefs(doc));
|
||||||
|
if (doc) {
|
||||||
|
nsString buffer;
|
||||||
|
|
||||||
|
nsIDOMSelection* sel = nsnull;
|
||||||
|
GetSelection(&sel);
|
||||||
|
|
||||||
|
if (sel != nsnull)
|
||||||
|
doc->CreateXIF(buffer,sel);
|
||||||
|
NS_IF_RELEASE(sel);
|
||||||
|
|
||||||
|
// Get the Clipboard
|
||||||
|
nsIClipboard* clipboard;
|
||||||
|
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
|
||||||
|
kIClipboardIID,
|
||||||
|
(nsISupports **)&clipboard);
|
||||||
|
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
|
||||||
|
// Create a data flavor to tell the transferable
|
||||||
|
// that it is about to receive XIF
|
||||||
|
nsIDataFlavor * flavor;
|
||||||
|
rv = nsComponentManager::CreateInstance(kCDataFlavorCID,
|
||||||
|
nsnull,
|
||||||
|
kIDataFlavorIID, (void**) &flavor);
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
// Initialize data flavor to XIF
|
||||||
|
flavor->Init(kXIFMime, "XIF");
|
||||||
|
|
||||||
|
// Create a transferable for putting data on the Clipboard
|
||||||
|
nsITransferable * trans;
|
||||||
|
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
|
||||||
|
kITransferableIID, (void**) &trans);
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
// The data on the clipboard will be in "XIF" format
|
||||||
|
// so give the clipboard transferable a "XIFConverter" for
|
||||||
|
// converting from XIF to other formats
|
||||||
|
nsIFormatConverter * xifConverter;
|
||||||
|
rv = nsComponentManager::CreateInstance(kCXIFConverterCID, nsnull,
|
||||||
|
kIFormatConverterIID, (void**) &xifConverter);
|
||||||
|
if (NS_OK == rv) {
|
||||||
|
// Add the XIF DataFlavor to the transferable
|
||||||
|
// this tells the transferable that it can handle receiving the XIF format
|
||||||
|
trans->AddDataFlavor(flavor);
|
||||||
|
|
||||||
|
// Add the converter for going from XIF to other formats
|
||||||
|
trans->SetConverter(xifConverter);
|
||||||
|
|
||||||
|
// Now add the XIF data to the transferable
|
||||||
|
trans->SetTransferData(flavor, buffer.ToNewCString(), buffer.Length());
|
||||||
|
|
||||||
|
// put the transferable on the clipboard
|
||||||
|
clipboard->SetData(trans, nsnull);
|
||||||
|
|
||||||
|
NS_IF_RELEASE(xifConverter);
|
||||||
|
}
|
||||||
|
NS_IF_RELEASE(trans);
|
||||||
|
}
|
||||||
|
NS_IF_RELEASE(flavor);
|
||||||
|
}
|
||||||
|
NS_IF_RELEASE(clipboard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Old SelectionMgr implementation.
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
||||||
{
|
{
|
||||||
|
@ -1557,8 +1639,6 @@ PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
||||||
doc->CreateXIF(buffer,sel);
|
doc->CreateXIF(buffer,sel);
|
||||||
NS_IF_RELEASE(sel);
|
NS_IF_RELEASE(sel);
|
||||||
|
|
||||||
////////////////////////// Old Way
|
|
||||||
#ifndef NEW_CLIPBOARD_SUPPORT
|
|
||||||
nsIParser* parser;
|
nsIParser* parser;
|
||||||
|
|
||||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||||
|
@ -1605,61 +1685,13 @@ PresShell::DoCopy(nsISelectionMgr* aSelectionMgr)
|
||||||
NS_IF_RELEASE(sink);
|
NS_IF_RELEASE(sink);
|
||||||
NS_RELEASE(parser);
|
NS_RELEASE(parser);
|
||||||
|
|
||||||
#else /////////////////////////// New Way
|
|
||||||
// Put XIF into transferable
|
|
||||||
|
|
||||||
// Get the Clipboard
|
|
||||||
nsIClipboard* clipboard;
|
|
||||||
nsresult rv = nsServiceManager::GetService(kCClipboardCID,
|
|
||||||
kIClipboardIID,
|
|
||||||
(nsISupports **)&clipboard);
|
|
||||||
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
|
|
||||||
// Create a data flavor to tell the transferable
|
|
||||||
// that it is about to receive XIF
|
|
||||||
nsIDataFlavor * flavor;
|
|
||||||
rv = nsComponentManager::CreateInstance(kCDataFlavorCID, nsnull, kIDataFlavorIID, (void**) &flavor);
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
// Initialize data flavor to XIF
|
|
||||||
flavor->Init(kXIFMime, "XIF");
|
|
||||||
|
|
||||||
// Create a transferable for putting data on the Clipboard
|
|
||||||
nsITransferable * trans;
|
|
||||||
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull, kITransferableIID, (void**) &trans);
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
// The data on the clipboard will be in "XIF" format
|
|
||||||
// so give the clipboard transferable a "XIFConverter" for
|
|
||||||
// converting from XIF to other formats
|
|
||||||
nsIFormatConverter * xifConverter;
|
|
||||||
rv = nsComponentManager::CreateInstance(kCXIFConverterCID, nsnull, kIFormatConverterIID, (void**) &xifConverter);
|
|
||||||
if (NS_OK == rv) {
|
|
||||||
// Add the XIF DataFlavor to the transferable
|
|
||||||
// this tells the transferable that it can handle receiving the XIF format
|
|
||||||
trans->AddDataFlavor(flavor);
|
|
||||||
|
|
||||||
// Add the converter for going from XIF to other formats
|
|
||||||
trans->SetConverter(xifConverter);
|
|
||||||
|
|
||||||
// Now add the XIF data to the transferable
|
|
||||||
trans->SetTransferData(flavor, buffer.ToNewCString(), buffer.Length());
|
|
||||||
|
|
||||||
// put the transferable on the clipboard
|
|
||||||
clipboard->SetData(trans, nsnull);
|
|
||||||
|
|
||||||
NS_IF_RELEASE(xifConverter);
|
|
||||||
}
|
|
||||||
NS_IF_RELEASE(trans);
|
|
||||||
}
|
|
||||||
NS_IF_RELEASE(flavor);
|
|
||||||
}
|
|
||||||
NS_IF_RELEASE(clipboard);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // NEW_CLIPBOARD_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::ContentChanged(nsIDocument *aDocument,
|
PresShell::ContentChanged(nsIDocument *aDocument,
|
||||||
nsIContent* aContent,
|
nsIContent* aContent,
|
||||||
|
|
|
@ -929,7 +929,7 @@ nsBrowserAppCore::Copy()
|
||||||
#ifdef NEW_CLIPBOARD_SUPPORT
|
#ifdef NEW_CLIPBOARD_SUPPORT
|
||||||
nsIPresShell * presShell = GetPresShellFor(mContentAreaWebShell);
|
nsIPresShell * presShell = GetPresShellFor(mContentAreaWebShell);
|
||||||
if (nsnull != presShell) {
|
if (nsnull != presShell) {
|
||||||
presShell->DoCopy(nsnull);
|
presShell->DoCopy();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче