Support for UI state maintenance, for styles, and the document dirty flag.

This commit is contained in:
sfraser%netscape.com 1999-07-28 02:54:35 +00:00
Родитель 39e696088a
Коммит 972a6948be
4 изменённых файлов: 58 добавлений и 60 удалений

Просмотреть файл

@ -82,6 +82,7 @@
#include "nsTextServicesCID.h"
#include "nsITextServicesDocument.h"
#include "nsISpellChecker.h"
#include "nsInterfaceState.h"
///////////////////////////////////////
@ -137,6 +138,7 @@ nsEditorShell::nsEditorShell()
, mContentAreaWebShell(nsnull)
, mEditorType(eUninitializedEditorType)
, mWrapColumn(0)
, mStateMaintainer(nsnull)
, mSuggestedWordIndex(0)
, mDictionaryIndex(0)
{
@ -149,7 +151,9 @@ nsEditorShell::nsEditorShell()
nsEditorShell::~nsEditorShell()
{
// the only references we hold are in nsCOMPtrs, so they'll take
NS_IF_RELEASE(mStateMaintainer);
// the only other references we hold are in nsCOMPtrs, so they'll take
// care of themselves.
}
@ -706,21 +710,27 @@ nsEditorShell::PrepareDocumentForEditing()
if (NS_FAILED(rv))
return rv;
#if 0
// work in progress
// make the UI state maintainer
rv = NS_NewInterfaceState(mEditor, getter_AddRefs(mStateMaintainer));
if (NS_FAILED(rv))
return rv;
mStateMaintainer = new nsInterfaceState;
if (!mStateMaintainer) return NS_ERROR_OUT_OF_MEMORY;
mStateMaintainer->AddRef(); // the owning reference
rv = mStateMaintainer->Init(mEditor, mWebShell);
if (NS_FAILED(rv)) return rv;
// set it up as a selection listener
nsCOMPtr<nsIDOMSelection> domSelection;
rv = GetEditorSelection(getter_AddRefs(domSelection));
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv)) return rv;
domSelection->AddSelectionListener(mStateMaintainer);
#endif
rv = domSelection->AddSelectionListener(mStateMaintainer);
if (NS_FAILED(rv)) return rv;
// and set it up as a doc state listener
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor, &rv);
if (NS_FAILED(rv)) return rv;
rv = editor->AddDocumentStateListener(mStateMaintainer);
if (NS_FAILED(rv)) return rv;
// Force initial focus to the content window -- HOW?
// mWebShellWin->SetFocus();
return NS_OK;
@ -1722,23 +1732,13 @@ nsEditorShell::GetEditorSelection(nsIDOMSelection** aEditorSelection)
}
NS_IMETHODIMP
nsEditorShell::GetDocumentStatus(PRInt32 *aDocumentStatus)
nsEditorShell::GetDocumentModified(PRBool *aDocumentModified)
{
if (!aDocumentStatus)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMDocument> theDoc;
nsresult rv = GetEditorDocument(getter_AddRefs(theDoc));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(theDoc, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor)
return editor->GetDocumentModified(aDocumentModified);
PRInt32 modCount = 0;
diskDoc->GetModCount(&modCount);
*aDocumentStatus = (modCount == 0) ? eDocumentStatusUnmodified : eDocumentStatusModified;
return NS_OK;
return NS_NOINTERFACE;
}

Просмотреть файл

@ -39,6 +39,7 @@
#include "nsTextServicesCID.h"
#include "nsIEditorSpellCheck.h"
#include "nsISpellChecker.h"
#include "nsInterfaceState.h"
class nsIBrowserWindow;
class nsIWebShell;
@ -87,7 +88,7 @@ class nsEditorShell : public nsIEditorShell,
NS_IMETHOD GetEditorDocument(nsIDOMDocument * *aEditorDocument);
NS_IMETHOD GetEditorSelection(nsIDOMSelection * *aEditorSelection);
NS_IMETHOD GetDocumentStatus(PRInt32 *aDocumentStatus);
NS_IMETHOD GetDocumentModified(PRBool *aDocumentModified);
NS_IMETHOD GetWrapColumn(PRInt32 *aWrapColumn);
NS_IMETHOD SetWrapColumn(PRInt32 aWrapColumn);
@ -297,9 +298,7 @@ class nsEditorShell : public nsIEditorShell,
nsCOMPtr<nsISupports> mSearchContext; // context used for search and replace. Owned by the appshell.
#if 0
nsCOMPtr<nsIDOMSelectionListener> mStateMaintainer;
#endif
nsInterfaceState* mStateMaintainer; // we hold the owning ref to this.
PRInt32 mWrapColumn; // can't actually set this 'til the editor is created, so we may have to hold on to it for a while

Просмотреть файл

@ -82,6 +82,7 @@
#include "nsTextServicesCID.h"
#include "nsITextServicesDocument.h"
#include "nsISpellChecker.h"
#include "nsInterfaceState.h"
///////////////////////////////////////
@ -137,6 +138,7 @@ nsEditorShell::nsEditorShell()
, mContentAreaWebShell(nsnull)
, mEditorType(eUninitializedEditorType)
, mWrapColumn(0)
, mStateMaintainer(nsnull)
, mSuggestedWordIndex(0)
, mDictionaryIndex(0)
{
@ -149,7 +151,9 @@ nsEditorShell::nsEditorShell()
nsEditorShell::~nsEditorShell()
{
// the only references we hold are in nsCOMPtrs, so they'll take
NS_IF_RELEASE(mStateMaintainer);
// the only other references we hold are in nsCOMPtrs, so they'll take
// care of themselves.
}
@ -706,21 +710,27 @@ nsEditorShell::PrepareDocumentForEditing()
if (NS_FAILED(rv))
return rv;
#if 0
// work in progress
// make the UI state maintainer
rv = NS_NewInterfaceState(mEditor, getter_AddRefs(mStateMaintainer));
if (NS_FAILED(rv))
return rv;
mStateMaintainer = new nsInterfaceState;
if (!mStateMaintainer) return NS_ERROR_OUT_OF_MEMORY;
mStateMaintainer->AddRef(); // the owning reference
rv = mStateMaintainer->Init(mEditor, mWebShell);
if (NS_FAILED(rv)) return rv;
// set it up as a selection listener
nsCOMPtr<nsIDOMSelection> domSelection;
rv = GetEditorSelection(getter_AddRefs(domSelection));
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv)) return rv;
domSelection->AddSelectionListener(mStateMaintainer);
#endif
rv = domSelection->AddSelectionListener(mStateMaintainer);
if (NS_FAILED(rv)) return rv;
// and set it up as a doc state listener
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor, &rv);
if (NS_FAILED(rv)) return rv;
rv = editor->AddDocumentStateListener(mStateMaintainer);
if (NS_FAILED(rv)) return rv;
// Force initial focus to the content window -- HOW?
// mWebShellWin->SetFocus();
return NS_OK;
@ -1722,23 +1732,13 @@ nsEditorShell::GetEditorSelection(nsIDOMSelection** aEditorSelection)
}
NS_IMETHODIMP
nsEditorShell::GetDocumentStatus(PRInt32 *aDocumentStatus)
nsEditorShell::GetDocumentModified(PRBool *aDocumentModified)
{
if (!aDocumentStatus)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMDocument> theDoc;
nsresult rv = GetEditorDocument(getter_AddRefs(theDoc));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(theDoc, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIEditor> editor = do_QueryInterface(mEditor);
if (editor)
return editor->GetDocumentModified(aDocumentModified);
PRInt32 modCount = 0;
diskDoc->GetModCount(&modCount);
*aDocumentStatus = (modCount == 0) ? eDocumentStatusUnmodified : eDocumentStatusModified;
return NS_OK;
return NS_NOINTERFACE;
}

Просмотреть файл

@ -39,6 +39,7 @@
#include "nsTextServicesCID.h"
#include "nsIEditorSpellCheck.h"
#include "nsISpellChecker.h"
#include "nsInterfaceState.h"
class nsIBrowserWindow;
class nsIWebShell;
@ -87,7 +88,7 @@ class nsEditorShell : public nsIEditorShell,
NS_IMETHOD GetEditorDocument(nsIDOMDocument * *aEditorDocument);
NS_IMETHOD GetEditorSelection(nsIDOMSelection * *aEditorSelection);
NS_IMETHOD GetDocumentStatus(PRInt32 *aDocumentStatus);
NS_IMETHOD GetDocumentModified(PRBool *aDocumentModified);
NS_IMETHOD GetWrapColumn(PRInt32 *aWrapColumn);
NS_IMETHOD SetWrapColumn(PRInt32 aWrapColumn);
@ -297,9 +298,7 @@ class nsEditorShell : public nsIEditorShell,
nsCOMPtr<nsISupports> mSearchContext; // context used for search and replace. Owned by the appshell.
#if 0
nsCOMPtr<nsIDOMSelectionListener> mStateMaintainer;
#endif
nsInterfaceState* mStateMaintainer; // we hold the owning ref to this.
PRInt32 mWrapColumn; // can't actually set this 'til the editor is created, so we may have to hold on to it for a while