Added file opening functionality
git-svn-id: svn://10.0.0.236/trunk@31300 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
a2ad6b315b
commit
ac1a4a233b
@ -28,6 +28,7 @@
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDiskDocument.h"
|
||||
#include "nsVector.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsEditFactory.h"
|
||||
@ -682,6 +683,13 @@ nsEditor::Do(nsITransaction *aTxn)
|
||||
}
|
||||
selection->EndBatchChanges();
|
||||
}
|
||||
|
||||
PRBool isTransientTransaction;
|
||||
if (NS_SUCCEEDED(result) &&
|
||||
NS_SUCCEEDED(aTxn->GetIsTransient(&isTransientTransaction) &&
|
||||
!isTransientTransaction)) // don't count transient transactions
|
||||
result = IncDocModCount(+1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -706,6 +714,10 @@ nsEditor::Undo(PRUint32 aCount)
|
||||
}
|
||||
selection->EndBatchChanges();
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = IncDocModCount(-1); // all undoable transactions are non-transient
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2565,6 +2577,41 @@ nsEditor::IsEditable(nsIDOMNode *aNode)
|
||||
//END nsEditor static utility methods
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::IncDocModCount(PRInt32 inNumMods)
|
||||
{
|
||||
if (!mDoc) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(mDoc);
|
||||
if (diskDoc)
|
||||
diskDoc->IncrementModCount(inNumMods);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::GetDocModCount(PRInt32 &outModCount)
|
||||
{
|
||||
if (!mDoc) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(mDoc);
|
||||
if (diskDoc)
|
||||
diskDoc->GetModCount(&outModCount);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::ResetDocModCount()
|
||||
{
|
||||
if (!mDoc) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(mDoc);
|
||||
if (diskDoc)
|
||||
diskDoc->ResetModCount();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void nsEditor::HACKForceRedraw()
|
||||
{
|
||||
|
||||
@ -88,7 +88,7 @@ public:
|
||||
*/
|
||||
virtual ~nsEditor();
|
||||
|
||||
/*BEGIN nsIEdieditor for more details*/
|
||||
/*BEGIN nsIEditor for more details*/
|
||||
|
||||
//Interfaces for addref and release and queryinterface
|
||||
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
||||
@ -272,10 +272,22 @@ protected:
|
||||
|
||||
NS_IMETHOD DebugDumpContent() const;
|
||||
|
||||
// should these me methodimp?
|
||||
NS_IMETHODIMP SetPreeditText(const nsString& aStringToInsert);
|
||||
|
||||
NS_IMETHODIMP DoInitialPreeeditInsert(const nsString& aStringToInsert);
|
||||
|
||||
// called each time we modify the document. Increments the mod
|
||||
// count of the doc.
|
||||
NS_IMETHOD IncDocModCount(PRInt32 inNumMods);
|
||||
|
||||
// return the mod count of the doc we are editing. Zero means unchanged.
|
||||
NS_IMETHOD GetDocModCount(PRInt32 &outModCount);
|
||||
|
||||
// called ONLY when we need to override the doc's modification
|
||||
// state. This should already be handled by nsIDiskDocument.
|
||||
NS_IMETHOD ResetDocModCount();
|
||||
|
||||
protected:
|
||||
// XXXX: Horrible hack! We are doing this because
|
||||
// of an error in Gecko which is not rendering the
|
||||
|
||||
@ -991,6 +991,11 @@ NS_IMETHODIMP nsTextEditor::SaveDocument(PRBool saveAs, PRBool saveCopy)
|
||||
|
||||
replacing = (dialogResult == nsFileDlgResults_Replace);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(0, "Failed to get file widget");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString charsetStr("ISO-8859-1");
|
||||
@ -999,6 +1004,7 @@ NS_IMETHODIMP nsTextEditor::SaveDocument(PRBool saveAs, PRBool saveCopy)
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
// show some error dialog?
|
||||
NS_WARNING("Saving file failed");
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDiskDocument.h"
|
||||
#include "nsVector.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsEditFactory.h"
|
||||
@ -682,6 +683,13 @@ nsEditor::Do(nsITransaction *aTxn)
|
||||
}
|
||||
selection->EndBatchChanges();
|
||||
}
|
||||
|
||||
PRBool isTransientTransaction;
|
||||
if (NS_SUCCEEDED(result) &&
|
||||
NS_SUCCEEDED(aTxn->GetIsTransient(&isTransientTransaction) &&
|
||||
!isTransientTransaction)) // don't count transient transactions
|
||||
result = IncDocModCount(+1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -706,6 +714,10 @@ nsEditor::Undo(PRUint32 aCount)
|
||||
}
|
||||
selection->EndBatchChanges();
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
result = IncDocModCount(-1); // all undoable transactions are non-transient
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2565,6 +2577,41 @@ nsEditor::IsEditable(nsIDOMNode *aNode)
|
||||
//END nsEditor static utility methods
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::IncDocModCount(PRInt32 inNumMods)
|
||||
{
|
||||
if (!mDoc) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(mDoc);
|
||||
if (diskDoc)
|
||||
diskDoc->IncrementModCount(inNumMods);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::GetDocModCount(PRInt32 &outModCount)
|
||||
{
|
||||
if (!mDoc) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(mDoc);
|
||||
if (diskDoc)
|
||||
diskDoc->GetModCount(&outModCount);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsEditor::ResetDocModCount()
|
||||
{
|
||||
if (!mDoc) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(mDoc);
|
||||
if (diskDoc)
|
||||
diskDoc->ResetModCount();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void nsEditor::HACKForceRedraw()
|
||||
{
|
||||
|
||||
@ -88,7 +88,7 @@ public:
|
||||
*/
|
||||
virtual ~nsEditor();
|
||||
|
||||
/*BEGIN nsIEdieditor for more details*/
|
||||
/*BEGIN nsIEditor for more details*/
|
||||
|
||||
//Interfaces for addref and release and queryinterface
|
||||
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
||||
@ -272,10 +272,22 @@ protected:
|
||||
|
||||
NS_IMETHOD DebugDumpContent() const;
|
||||
|
||||
// should these me methodimp?
|
||||
NS_IMETHODIMP SetPreeditText(const nsString& aStringToInsert);
|
||||
|
||||
NS_IMETHODIMP DoInitialPreeeditInsert(const nsString& aStringToInsert);
|
||||
|
||||
// called each time we modify the document. Increments the mod
|
||||
// count of the doc.
|
||||
NS_IMETHOD IncDocModCount(PRInt32 inNumMods);
|
||||
|
||||
// return the mod count of the doc we are editing. Zero means unchanged.
|
||||
NS_IMETHOD GetDocModCount(PRInt32 &outModCount);
|
||||
|
||||
// called ONLY when we need to override the doc's modification
|
||||
// state. This should already be handled by nsIDiskDocument.
|
||||
NS_IMETHOD ResetDocModCount();
|
||||
|
||||
protected:
|
||||
// XXXX: Horrible hack! We are doing this because
|
||||
// of an error in Gecko which is not rendering the
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user