From f220b28ee3896ae9446b4959b56efca251dc19bd Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Mon, 9 Aug 1999 01:34:04 +0000 Subject: [PATCH] First Checked In. git-svn-id: svn://10.0.0.236/trunk@42723 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/TypeInState.cpp | 54 ++++++ mozilla/editor/base/nsEditorFactory.cpp | 150 +++++++++++++++++ mozilla/editor/base/nsEditorFactory.h | 67 ++++++++ mozilla/editor/base/nsEditorRegistration.cpp | 154 ++++++++++++++++++ mozilla/editor/base/nsEditorUtils.cpp | 52 ++++++ mozilla/editor/base/nsEditorUtils.h | 62 +++++++ .../editor/libeditor/base/nsEditorFactory.h | 67 ++++++++ .../editor/libeditor/base/nsEditorUtils.cpp | 52 ++++++ mozilla/editor/libeditor/base/nsEditorUtils.h | 62 +++++++ .../libeditor/build/nsEditorRegistration.cpp | 154 ++++++++++++++++++ mozilla/editor/libeditor/html/TypeInState.cpp | 54 ++++++ mozilla/editor/public/nsIEditorIMESupport.h | 60 +++++++ mozilla/editor/public/nsIEditorLogging.h | 48 ++++++ mozilla/editor/public/nsIEditorMailSupport.h | 88 ++++++++++ mozilla/editor/public/nsIEditorStyleSheets.h | 62 +++++++ mozilla/editor/public/nsITableEditor.h | 138 ++++++++++++++++ 16 files changed, 1324 insertions(+) create mode 100644 mozilla/editor/base/TypeInState.cpp create mode 100644 mozilla/editor/base/nsEditorFactory.cpp create mode 100644 mozilla/editor/base/nsEditorFactory.h create mode 100644 mozilla/editor/base/nsEditorRegistration.cpp create mode 100644 mozilla/editor/base/nsEditorUtils.cpp create mode 100644 mozilla/editor/base/nsEditorUtils.h create mode 100644 mozilla/editor/libeditor/base/nsEditorFactory.h create mode 100644 mozilla/editor/libeditor/base/nsEditorUtils.cpp create mode 100644 mozilla/editor/libeditor/base/nsEditorUtils.h create mode 100644 mozilla/editor/libeditor/build/nsEditorRegistration.cpp create mode 100644 mozilla/editor/libeditor/html/TypeInState.cpp create mode 100644 mozilla/editor/public/nsIEditorIMESupport.h create mode 100644 mozilla/editor/public/nsIEditorLogging.h create mode 100644 mozilla/editor/public/nsIEditorMailSupport.h create mode 100644 mozilla/editor/public/nsIEditorStyleSheets.h create mode 100644 mozilla/editor/public/nsITableEditor.h diff --git a/mozilla/editor/base/TypeInState.cpp b/mozilla/editor/base/TypeInState.cpp new file mode 100644 index 00000000000..bb8c73c689d --- /dev/null +++ b/mozilla/editor/base/TypeInState.cpp @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#include "TypeInState.h" + + +NS_IMPL_ADDREF(TypeInState) +NS_IMPL_RELEASE(TypeInState) + +NS_IMETHODIMP +TypeInState::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (nsnull == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*)(nsISupports*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(nsIDOMSelectionListener::GetIID())) { + *aInstancePtr = (void*)(nsIDOMSelectionListener*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +TypeInState::~TypeInState() +{ +}; + +NS_IMETHODIMP TypeInState::NotifySelectionChanged() +{ + Reset(); + return NS_OK; +}; + diff --git a/mozilla/editor/base/nsEditorFactory.cpp b/mozilla/editor/base/nsEditorFactory.cpp new file mode 100644 index 00000000000..2735585f7a2 --- /dev/null +++ b/mozilla/editor/base/nsEditorFactory.cpp @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://wwwt.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsCOMPtr.h" + +#include "nsEditorFactory.h" +#include "nsIEditor.h" +#include "nsIHTMLEditor.h" + +#include "nsEditorShell.h" +#include "nsEditorShellFactory.h" + +#include "nsHTMLEditor.h" +#include "nsEditor.h" + +#include "nsEditorCID.h" + +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" + +static NS_DEFINE_IID(kHTMLEditorCID, NS_HTMLEDITOR_CID); + + +nsresult +GetEditorFactory(nsIFactory **aFactory, const nsCID & aClass) +{ + + // XXX Note static which never gets released, even on library unload. + // XXX Was an nsCOMPtr but that caused a crash on exit, + // XXX http://bugzilla.mozilla.org/show_bug.cgi?id=7938 + PR_EnterMonitor(GetEditorMonitor()); + + nsEditorFactory *factory = new nsEditorFactory(aClass); + if (!factory) + return NS_ERROR_OUT_OF_MEMORY; + nsCOMPtr pNSIFactory = do_QueryInterface(factory); + if (!pNSIFactory) + return NS_ERROR_NO_INTERFACE; + + nsresult result = pNSIFactory->QueryInterface(nsIFactory::GetIID(), + (void **)aFactory); + PR_ExitMonitor(GetEditorMonitor()); + return result; +} + +nsEditorFactory::nsEditorFactory(const nsCID &aClass) +: mCID(aClass) +{ + NS_INIT_REFCNT(); +} + +nsEditorFactory::~nsEditorFactory() +{ + //nsComponentManager::UnregisterFactory(mCID, (nsIFactory *)this); //we are out of ref counts anyway +} + +//////////////////////////////////////////////////////////////////////////// +// from nsISupports + +NS_METHOD +nsEditorFactory::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + if (nsnull == aInstancePtr) { + NS_NOTREACHED("!nsEditor"); + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(nsIFactory::GetIID()) || + aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*) this; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMPL_ADDREF(nsEditorFactory) +NS_IMPL_RELEASE(nsEditorFactory) + + +//////////////////////////////////////////////////////////////////////////// +// from nsIFactory: + +NS_METHOD +nsEditorFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult) +{ + *aResult = nsnull; + nsISupports *obj = nsnull; + if (!aResult) + return NS_ERROR_NULL_POINTER; + if (aOuter && !aIID.Equals(nsCOMTypeInfo::GetIID())) + return NS_NOINTERFACE; // XXX right error? + + +/* nsEditor is pure virtual + if (mCID.Equals(kEditorCID)) + obj = (nsISupports *)(nsIEditor*)new nsEditor(); +*/ + + if (mCID.Equals(kHTMLEditorCID)) + { + //Need to cast to interface first to avoid "ambiguous conversion..." error + // because of multiple nsISupports in the class hierarchy + obj = (nsISupports *)(nsIHTMLEditor*)new nsHTMLEditor(); + } + + if (obj && NS_FAILED(obj->QueryInterface(aIID, (void**)aResult)) ) + { + delete obj; + return NS_NOINTERFACE; + } + return NS_OK; +} + + + +NS_METHOD +nsEditorFactory::LockFactory(PRBool aLock) +{ + return NS_OK; +} + + +//if more than one person asks for the monitor at the same time for the FIRST time, we are screwed +PRMonitor *GetEditorMonitor() +{ + static PRMonitor *ns_editlock = nsnull; + if (nsnull == ns_editlock) + { + ns_editlock = (PRMonitor *)1; //how long will the next line take? lets cut down on the chance of reentrancy + ns_editlock = PR_NewMonitor(); + } + else if ((PRMonitor *)1 == ns_editlock) + return GetEditorMonitor(); + return ns_editlock; +} diff --git a/mozilla/editor/base/nsEditorFactory.h b/mozilla/editor/base/nsEditorFactory.h new file mode 100644 index 00000000000..fcdf53ed7e6 --- /dev/null +++ b/mozilla/editor/base/nsEditorFactory.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://wwwt.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +#ifndef nsIEditFactory_h___ +#define nsIEditFactory_h___ + +#include "nsISupports.h" +#include "nsIFactory.h" + +/* +EditFactory that can make an editor +*/ + +/** + * This supplies the neccessary entrance to the edit module. it will return any + * instantiations that we need. + */ + +nsresult GetEditorFactory(nsIFactory **aFactory, const nsCID & aClass); + +class nsEditorFactory : public nsIFactory +{ +public: + //////////////////////////////////////////////////////////////////////////// + // from nsISupports and AggregatedQueryInterface: + + NS_DECL_ISUPPORTS + + //////////////////////////////////////////////////////////////////////////// + // from nsIFactory: + + NS_IMETHOD + CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult); + + NS_IMETHOD + LockFactory(PRBool aLock); + + + //////////////////////////////////////////////////////////////////////////// + // from nsEditFactory: + + virtual ~nsEditorFactory(void); +private: + nsEditorFactory(const nsCID &aClass); //will fill the aFactory with the result from queryinterface + + /** getEditFactory + * creates an edit factory other CSID supported friend functions here. + */ + friend nsresult GetEditorFactory(nsIFactory **, const nsCID & ); + const nsCID &mCID; +}; + +#endif //nsIEditFactory_h___ diff --git a/mozilla/editor/base/nsEditorRegistration.cpp b/mozilla/editor/base/nsEditorRegistration.cpp new file mode 100644 index 00000000000..539ee101d70 --- /dev/null +++ b/mozilla/editor/base/nsEditorRegistration.cpp @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://wwwt.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#include "nsCOMPtr.h" + +#include "nsIServiceManager.h" +#include "nsIComponentManager.h" + +#include "nsEditorCID.h" + +#include "nsEditorShell.h" // for the CID +#include "nsEditorShellFactory.h" + +#include "nsEditor.h" // for gInstanceCount +#include "nsEditorFactory.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); + + +static NS_DEFINE_IID(kHTMLEditorCID, NS_HTMLEDITOR_CID); +static NS_DEFINE_IID(kEditorShellCID, NS_EDITORSHELL_CID); + + +/* +we must be good providers of factories etc. this is where to put ALL editor exports +*/ +//BEGIN EXPORTS +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, + const nsCID & aClass, + const char * aClassName, + const char * aProgID, + nsIFactory ** aFactory) +{ + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = nsnull; + + nsresult rv; + nsCOMPtr servMgr(do_QueryInterface(aServMgr, &rv)); + if (NS_FAILED(rv)) return rv; + + nsIComponentManager* componentManager = nsnull; + rv = servMgr->GetService(kComponentManagerCID, nsIComponentManager::GetIID(), + (nsISupports**)&componentManager); + if (NS_FAILED(rv)) return rv; + + rv = NS_NOINTERFACE; + + if (aClass.Equals(kHTMLEditorCID)) { + rv = GetEditorFactory(aFactory, aClass); + if (NS_FAILED(rv)) goto done; + } + else if (aClass.Equals(kEditorShellCID)) { + rv = GetEditorShellFactory(aFactory, aClass, aClassName, aProgID); + if (NS_FAILED(rv)) goto done; + } + + done: + (void)servMgr->ReleaseService(kComponentManagerCID, componentManager); + + return rv; +} + +extern "C" NS_EXPORT PRBool +NSCanUnload(nsISupports* aServMgr) +{ + return nsEditor::gInstanceCount; +} + + + +extern "C" NS_EXPORT nsresult +NSRegisterSelf(nsISupports* aServMgr, const char *path) +{ + nsresult rv; + nsCOMPtr servMgr(do_QueryInterface(aServMgr, &rv)); + if (NS_FAILED(rv)) return rv; + + nsIComponentManager* compMgr; + rv = servMgr->GetService(kComponentManagerCID, + nsIComponentManager::GetIID(), + (nsISupports**)&compMgr); + if (NS_FAILED(rv)) return rv; + + + rv = compMgr->RegisterComponent(kHTMLEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Component", + "component://netscape/editor/editorshell", + path, PR_TRUE, PR_TRUE); + + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Spell Checker", + "component://netscape/editor/editorspellcheck", + path, PR_TRUE, PR_TRUE); + + done: + (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); + return rv; +} + +extern "C" NS_EXPORT nsresult +NSUnregisterSelf(nsISupports* aServMgr, const char *path) +{ + nsresult rv; + + nsCOMPtr servMgr(do_QueryInterface(aServMgr, &rv)); + if (NS_FAILED(rv)) return rv; + + nsIComponentManager* compMgr; + rv = servMgr->GetService(kComponentManagerCID, + nsIComponentManager::GetIID(), + (nsISupports**)&compMgr); + if (NS_FAILED(rv)) return rv; + +/* + rv = compMgr->UnregisterComponent(kEditorCID, path); + if (NS_FAILED(rv)) goto done; + rv = compMgr->UnregisterComponent(kTextEditorCID, path); + if (NS_FAILED(rv)) goto done; +*/ + rv = compMgr->UnregisterComponent(kHTMLEditorCID, path); + if (NS_FAILED(rv)) goto done; + rv = compMgr->UnregisterComponent(kEditorShellCID, path); + + done: + (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); + return rv; +} + +//END EXPORTS + + diff --git a/mozilla/editor/base/nsEditorUtils.cpp b/mozilla/editor/base/nsEditorUtils.cpp new file mode 100644 index 00000000000..e258231e16b --- /dev/null +++ b/mozilla/editor/base/nsEditorUtils.cpp @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#include "nsEditorUtils.h" + + +/****************************************************************************** + * nsAutoSelectionReset + *****************************************************************************/ + +nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel) +{ + mInitialized = PR_FALSE; + mSel = do_QueryInterface(aSel); + if (mSel) + { + mSel->GetAnchorNode(getter_AddRefs(mStartNode)); + mSel->GetAnchorOffset(&mStartOffset); + mSel->GetFocusNode(getter_AddRefs(mEndNode)); + mSel->GetFocusOffset(&mEndOffset); + if (mStartNode && mEndNode) + mInitialized = PR_TRUE; + } +} + +nsAutoSelectionReset::~nsAutoSelectionReset() +{ + if (mSel && mInitialized) + { + // restore original selection + mSel->Collapse(mStartNode, mStartOffset); + mSel->Extend(mEndNode, mEndOffset); + } +} + + diff --git a/mozilla/editor/base/nsEditorUtils.h b/mozilla/editor/base/nsEditorUtils.h new file mode 100644 index 00000000000..9cdf8dc5fd0 --- /dev/null +++ b/mozilla/editor/base/nsEditorUtils.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#ifndef nsEditorUtils_h__ +#define nsEditorUtils_h__ + + +#include "nsCOMPtr.h" +#include "nsIDOMNode.h" +#include "nsIDOMSelection.h" +#include "nsIEditor.h" + +class nsAutoEditBatch +{ + private: + nsCOMPtr mEd; + public: + nsAutoEditBatch( nsIEditor *aEd) : mEd(do_QueryInterface(aEd)) + { if (mEd) mEd->BeginTransaction(); } + ~nsAutoEditBatch() { if (mEd) mEd->EndTransaction(); } +}; + +class nsAutoSelectionReset +{ + private: + /** ref-counted reference to the selection that we are supposed to restore */ + nsCOMPtr mSel; + + /** PR_TRUE if this instance initialized itself correctly */ + PRBool mInitialized; + + nsCOMPtr mStartNode; + nsCOMPtr mEndNode; + PRInt32 mStartOffset; + PRInt32 mEndOffset; + + public: + /** constructor responsible for remembering all state needed to restore aSel */ + nsAutoSelectionReset(nsIDOMSelection *aSel); + + /** destructor restores mSel to its former state */ + ~nsAutoSelectionReset(); +}; + + +#endif // nsEditorUtils_h__ diff --git a/mozilla/editor/libeditor/base/nsEditorFactory.h b/mozilla/editor/libeditor/base/nsEditorFactory.h new file mode 100644 index 00000000000..fcdf53ed7e6 --- /dev/null +++ b/mozilla/editor/libeditor/base/nsEditorFactory.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://wwwt.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +#ifndef nsIEditFactory_h___ +#define nsIEditFactory_h___ + +#include "nsISupports.h" +#include "nsIFactory.h" + +/* +EditFactory that can make an editor +*/ + +/** + * This supplies the neccessary entrance to the edit module. it will return any + * instantiations that we need. + */ + +nsresult GetEditorFactory(nsIFactory **aFactory, const nsCID & aClass); + +class nsEditorFactory : public nsIFactory +{ +public: + //////////////////////////////////////////////////////////////////////////// + // from nsISupports and AggregatedQueryInterface: + + NS_DECL_ISUPPORTS + + //////////////////////////////////////////////////////////////////////////// + // from nsIFactory: + + NS_IMETHOD + CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult); + + NS_IMETHOD + LockFactory(PRBool aLock); + + + //////////////////////////////////////////////////////////////////////////// + // from nsEditFactory: + + virtual ~nsEditorFactory(void); +private: + nsEditorFactory(const nsCID &aClass); //will fill the aFactory with the result from queryinterface + + /** getEditFactory + * creates an edit factory other CSID supported friend functions here. + */ + friend nsresult GetEditorFactory(nsIFactory **, const nsCID & ); + const nsCID &mCID; +}; + +#endif //nsIEditFactory_h___ diff --git a/mozilla/editor/libeditor/base/nsEditorUtils.cpp b/mozilla/editor/libeditor/base/nsEditorUtils.cpp new file mode 100644 index 00000000000..e258231e16b --- /dev/null +++ b/mozilla/editor/libeditor/base/nsEditorUtils.cpp @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#include "nsEditorUtils.h" + + +/****************************************************************************** + * nsAutoSelectionReset + *****************************************************************************/ + +nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel) +{ + mInitialized = PR_FALSE; + mSel = do_QueryInterface(aSel); + if (mSel) + { + mSel->GetAnchorNode(getter_AddRefs(mStartNode)); + mSel->GetAnchorOffset(&mStartOffset); + mSel->GetFocusNode(getter_AddRefs(mEndNode)); + mSel->GetFocusOffset(&mEndOffset); + if (mStartNode && mEndNode) + mInitialized = PR_TRUE; + } +} + +nsAutoSelectionReset::~nsAutoSelectionReset() +{ + if (mSel && mInitialized) + { + // restore original selection + mSel->Collapse(mStartNode, mStartOffset); + mSel->Extend(mEndNode, mEndOffset); + } +} + + diff --git a/mozilla/editor/libeditor/base/nsEditorUtils.h b/mozilla/editor/libeditor/base/nsEditorUtils.h new file mode 100644 index 00000000000..9cdf8dc5fd0 --- /dev/null +++ b/mozilla/editor/libeditor/base/nsEditorUtils.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#ifndef nsEditorUtils_h__ +#define nsEditorUtils_h__ + + +#include "nsCOMPtr.h" +#include "nsIDOMNode.h" +#include "nsIDOMSelection.h" +#include "nsIEditor.h" + +class nsAutoEditBatch +{ + private: + nsCOMPtr mEd; + public: + nsAutoEditBatch( nsIEditor *aEd) : mEd(do_QueryInterface(aEd)) + { if (mEd) mEd->BeginTransaction(); } + ~nsAutoEditBatch() { if (mEd) mEd->EndTransaction(); } +}; + +class nsAutoSelectionReset +{ + private: + /** ref-counted reference to the selection that we are supposed to restore */ + nsCOMPtr mSel; + + /** PR_TRUE if this instance initialized itself correctly */ + PRBool mInitialized; + + nsCOMPtr mStartNode; + nsCOMPtr mEndNode; + PRInt32 mStartOffset; + PRInt32 mEndOffset; + + public: + /** constructor responsible for remembering all state needed to restore aSel */ + nsAutoSelectionReset(nsIDOMSelection *aSel); + + /** destructor restores mSel to its former state */ + ~nsAutoSelectionReset(); +}; + + +#endif // nsEditorUtils_h__ diff --git a/mozilla/editor/libeditor/build/nsEditorRegistration.cpp b/mozilla/editor/libeditor/build/nsEditorRegistration.cpp new file mode 100644 index 00000000000..539ee101d70 --- /dev/null +++ b/mozilla/editor/libeditor/build/nsEditorRegistration.cpp @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://wwwt.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#include "nsCOMPtr.h" + +#include "nsIServiceManager.h" +#include "nsIComponentManager.h" + +#include "nsEditorCID.h" + +#include "nsEditorShell.h" // for the CID +#include "nsEditorShellFactory.h" + +#include "nsEditor.h" // for gInstanceCount +#include "nsEditorFactory.h" + +static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); + + +static NS_DEFINE_IID(kHTMLEditorCID, NS_HTMLEDITOR_CID); +static NS_DEFINE_IID(kEditorShellCID, NS_EDITORSHELL_CID); + + +/* +we must be good providers of factories etc. this is where to put ALL editor exports +*/ +//BEGIN EXPORTS +extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports * aServMgr, + const nsCID & aClass, + const char * aClassName, + const char * aProgID, + nsIFactory ** aFactory) +{ + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = nsnull; + + nsresult rv; + nsCOMPtr servMgr(do_QueryInterface(aServMgr, &rv)); + if (NS_FAILED(rv)) return rv; + + nsIComponentManager* componentManager = nsnull; + rv = servMgr->GetService(kComponentManagerCID, nsIComponentManager::GetIID(), + (nsISupports**)&componentManager); + if (NS_FAILED(rv)) return rv; + + rv = NS_NOINTERFACE; + + if (aClass.Equals(kHTMLEditorCID)) { + rv = GetEditorFactory(aFactory, aClass); + if (NS_FAILED(rv)) goto done; + } + else if (aClass.Equals(kEditorShellCID)) { + rv = GetEditorShellFactory(aFactory, aClass, aClassName, aProgID); + if (NS_FAILED(rv)) goto done; + } + + done: + (void)servMgr->ReleaseService(kComponentManagerCID, componentManager); + + return rv; +} + +extern "C" NS_EXPORT PRBool +NSCanUnload(nsISupports* aServMgr) +{ + return nsEditor::gInstanceCount; +} + + + +extern "C" NS_EXPORT nsresult +NSRegisterSelf(nsISupports* aServMgr, const char *path) +{ + nsresult rv; + nsCOMPtr servMgr(do_QueryInterface(aServMgr, &rv)); + if (NS_FAILED(rv)) return rv; + + nsIComponentManager* compMgr; + rv = servMgr->GetService(kComponentManagerCID, + nsIComponentManager::GetIID(), + (nsISupports**)&compMgr); + if (NS_FAILED(rv)) return rv; + + + rv = compMgr->RegisterComponent(kHTMLEditorCID, NULL, NULL, path, + PR_TRUE, PR_TRUE); + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Component", + "component://netscape/editor/editorshell", + path, PR_TRUE, PR_TRUE); + + if (NS_FAILED(rv)) goto done; + rv = compMgr->RegisterComponent(kEditorShellCID, + "Editor Shell Spell Checker", + "component://netscape/editor/editorspellcheck", + path, PR_TRUE, PR_TRUE); + + done: + (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); + return rv; +} + +extern "C" NS_EXPORT nsresult +NSUnregisterSelf(nsISupports* aServMgr, const char *path) +{ + nsresult rv; + + nsCOMPtr servMgr(do_QueryInterface(aServMgr, &rv)); + if (NS_FAILED(rv)) return rv; + + nsIComponentManager* compMgr; + rv = servMgr->GetService(kComponentManagerCID, + nsIComponentManager::GetIID(), + (nsISupports**)&compMgr); + if (NS_FAILED(rv)) return rv; + +/* + rv = compMgr->UnregisterComponent(kEditorCID, path); + if (NS_FAILED(rv)) goto done; + rv = compMgr->UnregisterComponent(kTextEditorCID, path); + if (NS_FAILED(rv)) goto done; +*/ + rv = compMgr->UnregisterComponent(kHTMLEditorCID, path); + if (NS_FAILED(rv)) goto done; + rv = compMgr->UnregisterComponent(kEditorShellCID, path); + + done: + (void)servMgr->ReleaseService(kComponentManagerCID, compMgr); + return rv; +} + +//END EXPORTS + + diff --git a/mozilla/editor/libeditor/html/TypeInState.cpp b/mozilla/editor/libeditor/html/TypeInState.cpp new file mode 100644 index 00000000000..bb8c73c689d --- /dev/null +++ b/mozilla/editor/libeditor/html/TypeInState.cpp @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#include "TypeInState.h" + + +NS_IMPL_ADDREF(TypeInState) +NS_IMPL_RELEASE(TypeInState) + +NS_IMETHODIMP +TypeInState::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (nsnull == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(nsCOMTypeInfo::GetIID())) { + *aInstancePtr = (void*)(nsISupports*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(nsIDOMSelectionListener::GetIID())) { + *aInstancePtr = (void*)(nsIDOMSelectionListener*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +TypeInState::~TypeInState() +{ +}; + +NS_IMETHODIMP TypeInState::NotifySelectionChanged() +{ + Reset(); + return NS_OK; +}; + diff --git a/mozilla/editor/public/nsIEditorIMESupport.h b/mozilla/editor/public/nsIEditorIMESupport.h new file mode 100644 index 00000000000..e2285881893 --- /dev/null +++ b/mozilla/editor/public/nsIEditorIMESupport.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIEditorIMESupport_h__ +#define nsIEditorIMESupport_h__ + + +#define NS_IEDITORIMESUPPORT_IID \ +{ /* {4805e680-49b9-11d3-9ce4-ed60bd6cb5bc} */ \ +0x4805e680, 0x49b9, 0x11d3, \ +{ 0x9c, 0xe4, 0xed, 0x60, 0xbd, 0x6c, 0xb5, 0xbc } } + + +class nsIPrivateTextRangeList; +struct nsTextEventReply; + +class nsIEditorIMESupport : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_IEDITORIMESUPPORT_IID; return iid; } + + + /** + * BeginComposition() Handles the start of inline input composition. + */ + + NS_IMETHOD BeginComposition(void) = 0; + + /** + * SetCompositionString() Sets the inline input composition string. + * BeginComposition must be called prior to this. + */ + + NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRange, nsTextEventReply* aReply) = 0; + + /** + * BeginComposition() Handles the end of inline input composition. + */ + + NS_IMETHOD EndComposition(void) = 0; + +}; + + +#endif // nsIEditorIMESupport_h__ \ No newline at end of file diff --git a/mozilla/editor/public/nsIEditorLogging.h b/mozilla/editor/public/nsIEditorLogging.h new file mode 100644 index 00000000000..893031b20c6 --- /dev/null +++ b/mozilla/editor/public/nsIEditorLogging.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIEditorLogging_h__ +#define nsIEditorLogging_h__ +#include "nsISupports.h" +#include "nscore.h" + + +#define NS_IEDITORLOGGING_IID \ +{ /* 4805e681-49b9-11d3-9ce4-ed60bd6cb5bc} */ \ +0x4805e681, 0x49b9, 0x11d3, \ +{ 0x9c, 0xe4, 0xed, 0x60, 0xbd, 0x6c, 0xb5, 0xbc } } + + +class nsIFileSpec; + +class nsIEditorLogging : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_IEDITORLOGGING_IID; return iid; } + + + /* Start logging */ + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile)=0; + + /* Stop logging */ + NS_IMETHOD StopLogging()=0; + +}; + + +#endif // nsIEditorLogging_h__ diff --git a/mozilla/editor/public/nsIEditorMailSupport.h b/mozilla/editor/public/nsIEditorMailSupport.h new file mode 100644 index 00000000000..84c6b414028 --- /dev/null +++ b/mozilla/editor/public/nsIEditorMailSupport.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIEditorMailSupport_h__ +#define nsIEditorMailSupport_h__ + + +#define NS_IEDITORMAILSUPPORT_IID \ +{ /* {fdf23301-4a94-11d3-9ce4-9960496c41bc} */ \ +0xfdf23301, 0x4a94, 0x11d3, \ +{ 0x9c, 0xe4, 0x99, 0x60, 0x49, 0x6c, 0x41, 0xbc } } + +class nsString; +class nsISupportsArray; + + +class nsIEditorMailSupport : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_IEDITORMAILSUPPORT_IID; return iid; } + + + /** Get and set the body wrap width + * @param aWrapColumn - the column to wrap at. This is set as a COLS attribute + * on a PRE block. + * + * Special values: + * 0 = wrap to window width + * -1 = no wrap at all + * + */ + NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn)=0; + NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn)=0; + + + /** paste the text in the OS clipboard at the cursor position + * as a quotation (whose representation is dependant on the editor type), + * replacing the selected text (if any) + * @param aCitation The "mid" URL of the source message + */ + NS_IMETHOD PasteAsQuotation()=0; + + /** insert a string as quoted text, + * as a quotation (whose representation is dependant on the editor type), + * replacing the selected text (if any) + * @param aQuotedText The actual text to be quoted + * @param aCitation The "mid" URL of the source message + */ + NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText)=0; + + /** + * Document me! + * + */ + NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation)=0; + + /** + * Document me! + * + */ + NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, + const nsString& aCitation)=0; + + /** + * Document me! + * + */ + NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList)=0; + +}; + + +#endif // nsIEditorMailSupport_h__ \ No newline at end of file diff --git a/mozilla/editor/public/nsIEditorStyleSheets.h b/mozilla/editor/public/nsIEditorStyleSheets.h new file mode 100644 index 00000000000..0858fbfb3ae --- /dev/null +++ b/mozilla/editor/public/nsIEditorStyleSheets.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIEditorStyleSheets_h__ +#define nsIEditorStyleSheets_h__ + + +#include "nsISupports.h" + +class nsString; +class nsICSSStyleSheet; + +#define NS_IEDITORSTYLESHEETS_IID \ +{ /* 4805e682-49b9-11d3-9ce4-ed60bd6cb5bc} */ \ +0x4805e682, 0x49b9, 0x11d3, \ +{ 0x9c, 0xe4, 0xed, 0x60, 0xbd, 0x6c, 0xb5, 0xbc } } + + +class nsIEditorStyleSheets : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_IEDITORSTYLESHEETS_IID; return iid; } + + /** load and apply the style sheet, specified by aURL, to + * the editor's document. This can involve asynchronous + * network I/O + * @param aURL The style sheet to be loaded and applied. + */ + NS_IMETHOD ApplyStyleSheet(const nsString& aURL)=0; + + /** Add the given Style Sheet to the editor's document + * This is always synchronous + * @param aSheet The style sheet to be applied. + */ + NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet)=0; + + /** Remove the given Style Sheet from the editor's document + * This is always synchronous + * @param aSheet The style sheet to be applied. + */ + NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet)=0; + +}; + + +#endif // nsIEditorStyleSheets_h__ + diff --git a/mozilla/editor/public/nsITableEditor.h b/mozilla/editor/public/nsITableEditor.h new file mode 100644 index 00000000000..15954ebe2fc --- /dev/null +++ b/mozilla/editor/public/nsITableEditor.h @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL")=0; you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +#ifndef nsITableEditor_h__ +#define nsITableEditor_h__ + + +#define NS_ITABLEEDITOR_IID \ +{ /* 4805e684-49b9-11d3-9ce4-ed60bd6cb5bc} */ \ +0x4805e684, 0x49b9, 0x11d3, \ +{ 0x9c, 0xe4, 0xed, 0x60, 0xbd, 0x6c, 0xb5, 0xbc } } + +class nsIDOMElement; + +class nsITableEditor : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_ITABLEEDITOR_IID; return iid; } + + /* ------------ Table editing Methods -------------- */ + + /** Insert table methods + * Insert relative to the selected cell or the + * cell enclosing the selection anchor + * The selection is collapsed and is left in the new cell + * at the same row,col location as the original anchor cell + * + * @param aNumber Number of items to insert + * @param aAfter If TRUE, insert after the current cell, + * else insert before current cell + */ + NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter)=0; + NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter)=0; + NS_IMETHOD InsertTableRow(PRInt32 aNumber, PRBool aAfter)=0; + + /** Delete table methods + * Delete starting at the selected cell or the + * cell (or table) enclosing the selection anchor + * The selection is collapsed and is left in the + * cell at the same row,col location as + * the previous selection anchor, if possible, + * else in the closest neigboring cell + * + * @param aNumber Number of items to insert/delete + */ + NS_IMETHOD DeleteTable()=0; + NS_IMETHOD DeleteTableCell(PRInt32 aNumber)=0; + NS_IMETHOD DeleteTableColumn(PRInt32 aNumber)=0; + NS_IMETHOD DeleteTableRow(PRInt32 aNumber)=0; + + /** Join the contents of the selected cells into one cell, + * expanding that cells ROWSPAN and COLSPAN to take up + * the same number of cellmap locations as before. + * Cells whose contents were moved are deleted. + * If there's one cell selected or caret is in one cell, + * it is joined with the cell to the right, if it exists + */ + NS_IMETHOD JoinTableCells()=0; + + + /** Scan through all rows and add cells as needed so + * all locations in the cellmap are occupied. + * Used after inserting single cells or pasting + * a collection of cells that extend past the + * previous size of the table + * If aTable is null, it uses table enclosing the selection anchor + */ + NS_IMETHOD NormalizeTable(nsIDOMElement *aTable)=0; + + /** Get the row an column index from the layout's cellmap + * If aTable is null, it will try to find enclosing table of selection ancho + * + */ + NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex)=0; + + /** Get the number of rows and columns in a table from the layout's cellmap + * If aTable is null, it will try to find enclosing table of selection ancho + * Note that all rows in table will not have this many because of + * ROWSPAN effects or if table is not "rectangular" (has short rows) + */ + NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount)=0; + + /** Get a cell element at cellmap grid coordinates + * A cell that spans across multiple cellmap locations will + * be returned multiple times, once for each location it occupies + * + * @param aTable A table in the document + * @param aRowIndex, aColIndex The 0-based cellmap indexes + * + * Note that this returns NS_TABLELAYOUT_CELL_NOT_FOUND + * when a cell is not found at the given indexes, + * but this passes the NS_SUCCEEDED() test, + * so you can scan for all cells in a row or column + * by iterating through the appropriate indexes + * until the returned aCell is null + */ + NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell)=0; + + /** Get a cell at cellmap grid coordinates and associated data + * A cell that spans across multiple cellmap locations will + * be returned multiple times, once for each location it occupies + * Examine the returned aStartRowIndex and aStartColIndex to see + * if it is in the same layout column or layout row: + * A "layout row" is all cells sharing the same top edge + * A "layout column" is all cells sharing the same left edge + * This is important to determine what to do when inserting or deleting a column or row + * + * @param aTable A table in the document + * @param aRowIndex, aColIndex The 0-based cellmap indexes + * + * Note that this returns NS_TABLELAYOUT_CELL_NOT_FOUND + * when a cell is not found at the given indexes (see note for GetCellAt()) + */ + NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell, + PRInt32& aStartRowIndex, PRInt32& aStartColIndex, + PRInt32& aRowSpan, PRInt32& aColSpan, PRBool& aIsSelected)=0; + + +}; + + +#endif // nsITableEditor_h__