зеркало из https://github.com/mozilla/pjs.git
29794: Disable meta-refresh in editor pages.
API and some implementation for 6276: rewrap.
This commit is contained in:
Родитель
7b7cec79e5
Коммит
a9942efa49
|
@ -82,7 +82,17 @@ nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAOLCiter::StripCites(const nsString& aInString, nsString& aOutString)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAOLCiter::Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,12 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString);
|
||||
};
|
||||
|
||||
#endif //nsAOLCiter_h__
|
||||
|
|
|
@ -85,8 +85,10 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocShellTreeNode.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
#include "nsIRefreshURI.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
// Editor Includes
|
||||
|
@ -114,6 +116,9 @@
|
|||
#include "nsISpellChecker.h"
|
||||
#include "nsInterfaceState.h"
|
||||
|
||||
#include "nsAOLCiter.h"
|
||||
#include "nsInternetCiter.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
// Drag & Drop, Clipboard
|
||||
|
@ -131,6 +136,7 @@ static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
|||
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID );
|
||||
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
/* Define Interface IDs */
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -211,15 +217,15 @@ GetTreeOwner(nsIDocShell* aDocShell, nsIBaseWindow** aBaseWindow)
|
|||
nsEditorShell::nsEditorShell()
|
||||
: mToolbarWindow(nsnull)
|
||||
, mContentWindow(nsnull)
|
||||
, mParserObserver(nsnull)
|
||||
, mStateMaintainer(nsnull)
|
||||
, mDocShell(nsnull)
|
||||
, mContentAreaDocShell(nsnull)
|
||||
, mCloseWindowWhenLoaded(PR_FALSE)
|
||||
, mEditorType(eUninitializedEditorType)
|
||||
, mStateMaintainer(nsnull)
|
||||
, mWrapColumn(0)
|
||||
, mSuggestedWordIndex(0)
|
||||
, mDictionaryIndex(0)
|
||||
, mCloseWindowWhenLoaded(PR_FALSE)
|
||||
, mParserObserver(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -2148,6 +2154,163 @@ nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText,
|
|||
return err;
|
||||
}
|
||||
|
||||
// Utility routine to make a new citer. This addrefs, of course.
|
||||
static nsICiter* MakeACiter()
|
||||
{
|
||||
// Make a citer of an appropriate type
|
||||
nsICiter* citer = 0;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
char *citationType = 0;
|
||||
rv = prefs->CopyCharPref("mail.compose.citationType", &citationType);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && citationType[0])
|
||||
{
|
||||
if (!strncmp(citationType, "aol", 3))
|
||||
citer = new nsAOLCiter;
|
||||
else
|
||||
citer = new nsInternetCiter;
|
||||
PL_strfree(citationType);
|
||||
}
|
||||
else
|
||||
citer = new nsInternetCiter;
|
||||
|
||||
if (citer)
|
||||
NS_ADDREF(citer);
|
||||
return citer;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::Rewrap()
|
||||
{
|
||||
PRInt32 wrapCol;
|
||||
nsresult rv = GetWrapColumn(&wrapCol);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
#ifdef DEBUG_akkana
|
||||
printf("nsEditorShell::Rewrap to %ld columns\n", (long)wrapCol);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
rv = GetEditorSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!selection)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
PRBool isCollapsed;
|
||||
rv = selection->GetIsCollapsed(&isCollapsed);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Variables we'll need either way
|
||||
nsAutoString format("text/plain");
|
||||
nsAutoString current;
|
||||
nsString wrapped;
|
||||
nsCOMPtr<nsIEditor> nsied (do_QueryInterface(mEditor));
|
||||
if (!nsied)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (isCollapsed) // rewrap the whole document
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = citer->Rewrap(current, wrapCol, 0, wrapped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SelectAll();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(wrapped);
|
||||
}
|
||||
else // rewrap only the selection
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted
|
||||
| nsIDocumentEncoder::OutputSelectionOnly);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRUint32 firstLineOffset = 0; // XXX need to get this
|
||||
rv = citer->Rewrap(current, wrapCol, firstLineOffset, wrapped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(wrapped);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::StripCites()
|
||||
{
|
||||
#ifdef DEBUG_akkana
|
||||
printf("nsEditorShell::StripCites()\n");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
nsresult rv = GetEditorSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!selection)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
PRBool isCollapsed;
|
||||
rv = selection->GetIsCollapsed(&isCollapsed);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Variables we'll need either way
|
||||
nsAutoString format("text/plain");
|
||||
nsAutoString current;
|
||||
nsString stripped;
|
||||
nsCOMPtr<nsIEditor> nsied (do_QueryInterface(mEditor));
|
||||
if (!nsied)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (isCollapsed) // rewrap the whole document
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = citer->StripCites(current, stripped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SelectAll();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(stripped);
|
||||
}
|
||||
else // rewrap only the selection
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted
|
||||
| nsIDocumentEncoder::OutputSelectionOnly);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = citer->StripCites(current, stripped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(stripped);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SelectAll()
|
||||
{
|
||||
|
@ -4018,11 +4181,6 @@ nsEditorShell::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons
|
|||
}
|
||||
}
|
||||
|
||||
// Disable meta-refresh
|
||||
nsCOMPtr<nsIRefreshURI> refreshURI = do_QueryInterface(mDocShell);
|
||||
if (refreshURI)
|
||||
refreshURI->CancelRefreshURITimers();
|
||||
|
||||
// set up a parser observer
|
||||
if (!mParserObserver)
|
||||
{
|
||||
|
@ -4048,6 +4206,11 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
|
|||
if (NS_FAILED(aStatus))
|
||||
return NS_OK;
|
||||
|
||||
// Disable meta-refresh
|
||||
nsCOMPtr<nsIRefreshURI> refreshURI = do_QueryInterface(mContentAreaDocShell);
|
||||
if (refreshURI)
|
||||
refreshURI->CancelRefreshURITimers();
|
||||
|
||||
// can we handle this document?
|
||||
if (mParserObserver)
|
||||
{
|
||||
|
|
|
@ -157,12 +157,12 @@ class nsEditorShell : public nsIEditorShell,
|
|||
nsCOMPtr<nsICSSStyleSheet> mAllTagsModeStyleSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mParagraphMarksStyleSheet;
|
||||
|
||||
nsEditorParserObserver* mParserObserver; // we hold the owning ref to this.
|
||||
nsInterfaceState* mStateMaintainer; // we hold the owning ref to this.
|
||||
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
|
||||
nsEditorParserObserver* mParserObserver; // we hold the owning ref to this.
|
||||
nsInterfaceState* mStateMaintainer; // we hold the owning ref to this.
|
||||
|
||||
nsIDocShell *mDocShell; // weak reference
|
||||
|
||||
// The webshell that contains the document being edited.
|
||||
|
|
|
@ -64,7 +64,7 @@ nsInternetCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_IMETHODIMP
|
||||
nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
|
||||
{
|
||||
PRUnichar newline ('\n');
|
||||
PRUnichar newline ('\n'); // Not XP!
|
||||
PRInt32 i = 0;
|
||||
PRInt32 length = aInString.Length();
|
||||
aOutString.SetLength(0);
|
||||
|
@ -86,7 +86,37 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInternetCiter::StripCites(const nsString& aInString, nsString& aOutString)
|
||||
{
|
||||
aOutString.SetLength(0);
|
||||
|
||||
PRInt32 length = aInString.Length();
|
||||
PRInt32 i = 0;
|
||||
PRUnichar gt ('>');
|
||||
while (i < length) // loop over lines
|
||||
{
|
||||
while (aInString[i] == gt || nsCRT::IsAsciiSpace(aInString[i]))
|
||||
++i;
|
||||
PRInt32 nextNewline = aInString.FindCharInSet("\r\n", i);
|
||||
if (nextNewline > i)
|
||||
{
|
||||
while (i < nextNewline)
|
||||
aOutString += aInString[i++];
|
||||
aOutString += NS_LINEBREAK;
|
||||
while (aOutString[i] == '\r' || aOutString[i] == '\n')
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInternetCiter::Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString)
|
||||
{
|
||||
printf("nsInternetCiter::Rewrap not yet implemented\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,12 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString);
|
||||
};
|
||||
|
||||
#endif //nsInternetCiter_h__
|
||||
|
|
|
@ -85,8 +85,10 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocShellTreeNode.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
#include "nsIRefreshURI.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
// Editor Includes
|
||||
|
@ -114,6 +116,9 @@
|
|||
#include "nsISpellChecker.h"
|
||||
#include "nsInterfaceState.h"
|
||||
|
||||
#include "nsAOLCiter.h"
|
||||
#include "nsInternetCiter.h"
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
// Drag & Drop, Clipboard
|
||||
|
@ -131,6 +136,7 @@ static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
|||
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID );
|
||||
static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
/* Define Interface IDs */
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -211,15 +217,15 @@ GetTreeOwner(nsIDocShell* aDocShell, nsIBaseWindow** aBaseWindow)
|
|||
nsEditorShell::nsEditorShell()
|
||||
: mToolbarWindow(nsnull)
|
||||
, mContentWindow(nsnull)
|
||||
, mParserObserver(nsnull)
|
||||
, mStateMaintainer(nsnull)
|
||||
, mDocShell(nsnull)
|
||||
, mContentAreaDocShell(nsnull)
|
||||
, mCloseWindowWhenLoaded(PR_FALSE)
|
||||
, mEditorType(eUninitializedEditorType)
|
||||
, mStateMaintainer(nsnull)
|
||||
, mWrapColumn(0)
|
||||
, mSuggestedWordIndex(0)
|
||||
, mDictionaryIndex(0)
|
||||
, mCloseWindowWhenLoaded(PR_FALSE)
|
||||
, mParserObserver(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -2148,6 +2154,163 @@ nsEditorShell::InsertAsCitedQuotation(const PRUnichar *quotedText,
|
|||
return err;
|
||||
}
|
||||
|
||||
// Utility routine to make a new citer. This addrefs, of course.
|
||||
static nsICiter* MakeACiter()
|
||||
{
|
||||
// Make a citer of an appropriate type
|
||||
nsICiter* citer = 0;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
char *citationType = 0;
|
||||
rv = prefs->CopyCharPref("mail.compose.citationType", &citationType);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && citationType[0])
|
||||
{
|
||||
if (!strncmp(citationType, "aol", 3))
|
||||
citer = new nsAOLCiter;
|
||||
else
|
||||
citer = new nsInternetCiter;
|
||||
PL_strfree(citationType);
|
||||
}
|
||||
else
|
||||
citer = new nsInternetCiter;
|
||||
|
||||
if (citer)
|
||||
NS_ADDREF(citer);
|
||||
return citer;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::Rewrap()
|
||||
{
|
||||
PRInt32 wrapCol;
|
||||
nsresult rv = GetWrapColumn(&wrapCol);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
#ifdef DEBUG_akkana
|
||||
printf("nsEditorShell::Rewrap to %ld columns\n", (long)wrapCol);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
rv = GetEditorSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!selection)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
PRBool isCollapsed;
|
||||
rv = selection->GetIsCollapsed(&isCollapsed);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Variables we'll need either way
|
||||
nsAutoString format("text/plain");
|
||||
nsAutoString current;
|
||||
nsString wrapped;
|
||||
nsCOMPtr<nsIEditor> nsied (do_QueryInterface(mEditor));
|
||||
if (!nsied)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (isCollapsed) // rewrap the whole document
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = citer->Rewrap(current, wrapCol, 0, wrapped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SelectAll();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(wrapped);
|
||||
}
|
||||
else // rewrap only the selection
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted
|
||||
| nsIDocumentEncoder::OutputSelectionOnly);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRUint32 firstLineOffset = 0; // XXX need to get this
|
||||
rv = citer->Rewrap(current, wrapCol, firstLineOffset, wrapped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(wrapped);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::StripCites()
|
||||
{
|
||||
#ifdef DEBUG_akkana
|
||||
printf("nsEditorShell::StripCites()\n");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
nsresult rv = GetEditorSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!selection)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
PRBool isCollapsed;
|
||||
rv = selection->GetIsCollapsed(&isCollapsed);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Variables we'll need either way
|
||||
nsAutoString format("text/plain");
|
||||
nsAutoString current;
|
||||
nsString stripped;
|
||||
nsCOMPtr<nsIEditor> nsied (do_QueryInterface(mEditor));
|
||||
if (!nsied)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (isCollapsed) // rewrap the whole document
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = citer->StripCites(current, stripped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SelectAll();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(stripped);
|
||||
}
|
||||
else // rewrap only the selection
|
||||
{
|
||||
rv = nsied->OutputToString(current, format,
|
||||
nsIDocumentEncoder::OutputFormatted
|
||||
| nsIDocumentEncoder::OutputSelectionOnly);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsICiter> citer = dont_AddRef(MakeACiter());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!citer) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = citer->StripCites(current, stripped);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mEditor->InsertText(stripped);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorShell::SelectAll()
|
||||
{
|
||||
|
@ -4018,11 +4181,6 @@ nsEditorShell::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons
|
|||
}
|
||||
}
|
||||
|
||||
// Disable meta-refresh
|
||||
nsCOMPtr<nsIRefreshURI> refreshURI = do_QueryInterface(mDocShell);
|
||||
if (refreshURI)
|
||||
refreshURI->CancelRefreshURITimers();
|
||||
|
||||
// set up a parser observer
|
||||
if (!mParserObserver)
|
||||
{
|
||||
|
@ -4048,6 +4206,11 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* aChanne
|
|||
if (NS_FAILED(aStatus))
|
||||
return NS_OK;
|
||||
|
||||
// Disable meta-refresh
|
||||
nsCOMPtr<nsIRefreshURI> refreshURI = do_QueryInterface(mContentAreaDocShell);
|
||||
if (refreshURI)
|
||||
refreshURI->CancelRefreshURITimers();
|
||||
|
||||
// can we handle this document?
|
||||
if (mParserObserver)
|
||||
{
|
||||
|
|
|
@ -157,12 +157,12 @@ class nsEditorShell : public nsIEditorShell,
|
|||
nsCOMPtr<nsICSSStyleSheet> mAllTagsModeStyleSheet;
|
||||
nsCOMPtr<nsICSSStyleSheet> mParagraphMarksStyleSheet;
|
||||
|
||||
nsEditorParserObserver* mParserObserver; // we hold the owning ref to this.
|
||||
nsInterfaceState* mStateMaintainer; // we hold the owning ref to this.
|
||||
|
||||
nsIDOMWindow *mToolbarWindow; // weak reference
|
||||
nsIDOMWindow *mContentWindow; // weak reference
|
||||
|
||||
nsEditorParserObserver* mParserObserver; // we hold the owning ref to this.
|
||||
nsInterfaceState* mStateMaintainer; // we hold the owning ref to this.
|
||||
|
||||
nsIDocShell *mDocShell; // weak reference
|
||||
|
||||
// The webshell that contains the document being edited.
|
||||
|
|
|
@ -146,6 +146,9 @@ interface nsIEditorShell : nsISupports
|
|||
void InsertAsCitedQuotation(in wstring quotedText, in wstring cite,
|
||||
in boolean insertHTML, in wstring charset,
|
||||
out nsIDOMNode nodeInserted);
|
||||
|
||||
void Rewrap();
|
||||
void StripCites();
|
||||
|
||||
void SelectAll();
|
||||
void DeleteSelection(in PRInt32 action);
|
||||
|
|
|
@ -82,7 +82,17 @@ nsAOLCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAOLCiter::StripCites(const nsString& aInString, nsString& aOutString)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAOLCiter::Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,12 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString);
|
||||
};
|
||||
|
||||
#endif //nsAOLCiter_h__
|
||||
|
|
|
@ -64,7 +64,7 @@ nsInternetCiter::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_IMETHODIMP
|
||||
nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
|
||||
{
|
||||
PRUnichar newline ('\n');
|
||||
PRUnichar newline ('\n'); // Not XP!
|
||||
PRInt32 i = 0;
|
||||
PRInt32 length = aInString.Length();
|
||||
aOutString.SetLength(0);
|
||||
|
@ -86,7 +86,37 @@ nsInternetCiter::GetCiteString(const nsString& aInString, nsString& aOutString)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInternetCiter::StripCites(const nsString& aInString, nsString& aOutString)
|
||||
{
|
||||
aOutString.SetLength(0);
|
||||
|
||||
PRInt32 length = aInString.Length();
|
||||
PRInt32 i = 0;
|
||||
PRUnichar gt ('>');
|
||||
while (i < length) // loop over lines
|
||||
{
|
||||
while (aInString[i] == gt || nsCRT::IsAsciiSpace(aInString[i]))
|
||||
++i;
|
||||
PRInt32 nextNewline = aInString.FindCharInSet("\r\n", i);
|
||||
if (nextNewline > i)
|
||||
{
|
||||
while (i < nextNewline)
|
||||
aOutString += aInString[i++];
|
||||
aOutString += NS_LINEBREAK;
|
||||
while (aOutString[i] == '\r' || aOutString[i] == '\n')
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInternetCiter::Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString)
|
||||
{
|
||||
printf("nsInternetCiter::Rewrap not yet implemented\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,12 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString);
|
||||
|
||||
NS_IMETHOD Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString);
|
||||
};
|
||||
|
||||
#endif //nsInternetCiter_h__
|
||||
|
|
|
@ -41,6 +41,12 @@ public:
|
|||
static const nsIID& GetIID() { static nsIID iid = NS_ICITER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetCiteString(const nsString& aInString, nsString& aOutString) = 0;
|
||||
|
||||
NS_IMETHOD StripCites(const nsString& aInString, nsString& aOutString) = 0;
|
||||
|
||||
NS_IMETHOD Rewrap(const nsString& aInString,
|
||||
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
|
||||
nsString& aOutString) = 0;
|
||||
};
|
||||
|
||||
#endif //nsICiter_h__
|
||||
|
|
|
@ -771,7 +771,13 @@ function EditorApplyStyleSheet(styleSheetURL)
|
|||
<menuitem value="&outputXIFCmd.label;"
|
||||
oncommand="EditorGetXIF()"/>
|
||||
<menuseparator />
|
||||
<menuitem value="&pasteAsQuotationCmd.label;" accesskey="&editpastequotation.accesskey;" oncommand="EditorPasteAsQuotation()"/>
|
||||
<menuitem value="&pasteAsQuotationCmd.label;"
|
||||
accesskey="&editpastequotation.accesskey;"
|
||||
oncommand="EditorPasteAsQuotation()"/>
|
||||
<menuitem value="&editRewrapCmd.label;"
|
||||
oncommand="editorShell.Rewrap()"/>
|
||||
<menuitem value="&editStripQuotesCmd.label;"
|
||||
oncommand="editorShell.StripCites()"/>
|
||||
<menuitem value="&insertTextCmd.label;"
|
||||
oncommand="EditorInsertText('All good things come to those who wait. ')"/>
|
||||
<menuseparator />
|
||||
|
|
|
@ -79,6 +79,8 @@
|
|||
<!ENTITY editpaste.keybinding "v">
|
||||
<!ENTITY pasteAsQuotationCmd.label "Paste As Quotation">
|
||||
<!ENTITY editpastequotation.accesskey "q">
|
||||
<!ENTITY editStripQuotesCmd.label "Strip Quotes">
|
||||
<!ENTITY editRewrapCmd.label "Rewrap">
|
||||
<!ENTITY clearCmd.label "Clear">
|
||||
<!ENTITY editclear.accesskey "l">
|
||||
<!ENTITY selectAllCmd.label "Select All">
|
||||
|
|
Загрузка…
Ссылка в новой задаче