diff --git a/mozilla/editor/base/nsAOLCiter.cpp b/mozilla/editor/base/nsAOLCiter.cpp index ff90855b651..54a4a98d378 100644 --- a/mozilla/editor/base/nsAOLCiter.cpp +++ b/mozilla/editor/base/nsAOLCiter.cpp @@ -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; +} diff --git a/mozilla/editor/base/nsAOLCiter.h b/mozilla/editor/base/nsAOLCiter.h index bc3bf8d36fc..7b8e981f6c1 100644 --- a/mozilla/editor/base/nsAOLCiter.h +++ b/mozilla/editor/base/nsAOLCiter.h @@ -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__ diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 16646f9740c..e85ac0e536f 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -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 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 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 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 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 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 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 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 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 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 refreshURI = do_QueryInterface(mContentAreaDocShell); + if (refreshURI) + refreshURI->CancelRefreshURITimers(); + // can we handle this document? if (mParserObserver) { diff --git a/mozilla/editor/base/nsEditorShell.h b/mozilla/editor/base/nsEditorShell.h index c817b96ba3b..4fd0bc37906 100644 --- a/mozilla/editor/base/nsEditorShell.h +++ b/mozilla/editor/base/nsEditorShell.h @@ -157,12 +157,12 @@ class nsEditorShell : public nsIEditorShell, nsCOMPtr mAllTagsModeStyleSheet; nsCOMPtr 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. diff --git a/mozilla/editor/base/nsInternetCiter.cpp b/mozilla/editor/base/nsInternetCiter.cpp index 1fdfaef8d8a..e156b989522 100644 --- a/mozilla/editor/base/nsInternetCiter.cpp +++ b/mozilla/editor/base/nsInternetCiter.cpp @@ -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; +} diff --git a/mozilla/editor/base/nsInternetCiter.h b/mozilla/editor/base/nsInternetCiter.h index 47e8ce73a22..d177307b0e2 100644 --- a/mozilla/editor/base/nsInternetCiter.h +++ b/mozilla/editor/base/nsInternetCiter.h @@ -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__ diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 16646f9740c..e85ac0e536f 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -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 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 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 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 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 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 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 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 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 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 refreshURI = do_QueryInterface(mContentAreaDocShell); + if (refreshURI) + refreshURI->CancelRefreshURITimers(); + // can we handle this document? if (mParserObserver) { diff --git a/mozilla/editor/composer/src/nsEditorShell.h b/mozilla/editor/composer/src/nsEditorShell.h index c817b96ba3b..4fd0bc37906 100644 --- a/mozilla/editor/composer/src/nsEditorShell.h +++ b/mozilla/editor/composer/src/nsEditorShell.h @@ -157,12 +157,12 @@ class nsEditorShell : public nsIEditorShell, nsCOMPtr mAllTagsModeStyleSheet; nsCOMPtr 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. diff --git a/mozilla/editor/idl/nsIEditorShell.idl b/mozilla/editor/idl/nsIEditorShell.idl index 7fe428a37ce..5b6a94969aa 100644 --- a/mozilla/editor/idl/nsIEditorShell.idl +++ b/mozilla/editor/idl/nsIEditorShell.idl @@ -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); diff --git a/mozilla/editor/libeditor/text/nsAOLCiter.cpp b/mozilla/editor/libeditor/text/nsAOLCiter.cpp index ff90855b651..54a4a98d378 100644 --- a/mozilla/editor/libeditor/text/nsAOLCiter.cpp +++ b/mozilla/editor/libeditor/text/nsAOLCiter.cpp @@ -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; +} diff --git a/mozilla/editor/libeditor/text/nsAOLCiter.h b/mozilla/editor/libeditor/text/nsAOLCiter.h index bc3bf8d36fc..7b8e981f6c1 100644 --- a/mozilla/editor/libeditor/text/nsAOLCiter.h +++ b/mozilla/editor/libeditor/text/nsAOLCiter.h @@ -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__ diff --git a/mozilla/editor/libeditor/text/nsInternetCiter.cpp b/mozilla/editor/libeditor/text/nsInternetCiter.cpp index 1fdfaef8d8a..e156b989522 100644 --- a/mozilla/editor/libeditor/text/nsInternetCiter.cpp +++ b/mozilla/editor/libeditor/text/nsInternetCiter.cpp @@ -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; +} diff --git a/mozilla/editor/libeditor/text/nsInternetCiter.h b/mozilla/editor/libeditor/text/nsInternetCiter.h index 47e8ce73a22..d177307b0e2 100644 --- a/mozilla/editor/libeditor/text/nsInternetCiter.h +++ b/mozilla/editor/libeditor/text/nsInternetCiter.h @@ -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__ diff --git a/mozilla/editor/public/nsICiter.h b/mozilla/editor/public/nsICiter.h index 2a45569cab5..a424a1761ae 100644 --- a/mozilla/editor/public/nsICiter.h +++ b/mozilla/editor/public/nsICiter.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__ diff --git a/mozilla/editor/ui/composer/content/editorOverlay.xul b/mozilla/editor/ui/composer/content/editorOverlay.xul index acd1bbc8841..9368a432e86 100644 --- a/mozilla/editor/ui/composer/content/editorOverlay.xul +++ b/mozilla/editor/ui/composer/content/editorOverlay.xul @@ -771,7 +771,13 @@ function EditorApplyStyleSheet(styleSheetURL) - + + + diff --git a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd index 7bcacc9f16b..efdf4010886 100644 --- a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd +++ b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd @@ -79,6 +79,8 @@ + +