diff --git a/editor/base/nsEditorEventListeners.cpp b/editor/base/nsEditorEventListeners.cpp index d606b7db660b..c8fa6f851732 100644 --- a/editor/base/nsEditorEventListeners.cpp +++ b/editor/base/nsEditorEventListeners.cpp @@ -413,7 +413,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr { printf("Getting number of columns\n"); aProcessed=PR_TRUE; - PRUint32 wrap; + PRInt32 wrap; if (NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap))) printf("Currently wrapping to %d\n", wrap); else @@ -426,7 +426,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr if (PR_TRUE==altKey) { aProcessed=PR_TRUE; - PRUint32 wrap; + PRInt32 wrap; if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap))) { printf("GetBodyWrapWidth returned an error\n"); @@ -447,7 +447,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr if (PR_TRUE==altKey) { aProcessed=PR_TRUE; - PRUint32 wrap; + PRInt32 wrap; if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap))) { printf("GetBodyWrapWidth returned an error\n"); diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index 529c535ea306..c75d25953ad2 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -1623,7 +1623,7 @@ nsEditorShell::GetWrapColumn(PRInt32* aWrapColumn) nsCOMPtr textEditor = do_QueryInterface(mEditor); if (textEditor) { - PRUint32 wc; + PRInt32 wc; err = textEditor->GetBodyWrapWidth(&wc); if (NS_SUCCEEDED(err)) *aWrapColumn = (PRInt32)wc; diff --git a/editor/base/nsTextEditor.cpp b/editor/base/nsTextEditor.cpp index 7cbc0b24e323..083fbbfa45c8 100644 --- a/editor/base/nsTextEditor.cpp +++ b/editor/base/nsTextEditor.cpp @@ -1408,7 +1408,7 @@ NS_IMETHODIMP nsTextEditor::InsertAsQuotation(const nsString& aQuotedText) // Get the wrap width for the first PRE tag in the document. // If no PRE tag, throw an error. // -NS_IMETHODIMP nsTextEditor::GetBodyWrapWidth(PRUint32 *aWrapColumn) +NS_IMETHODIMP nsTextEditor::GetBodyWrapWidth(PRInt32 *aWrapColumn) { nsresult res; @@ -1463,7 +1463,7 @@ NS_IMETHODIMP nsTextEditor::GetBodyWrapWidth(PRUint32 *aWrapColumn) // (Eventually want to search for more than one in case there are // interspersed quoted text blocks.) // -NS_IMETHODIMP nsTextEditor::SetBodyWrapWidth(PRUint32 aWrapColumn) +NS_IMETHODIMP nsTextEditor::SetBodyWrapWidth(PRInt32 aWrapColumn) { nsresult res; @@ -1551,7 +1551,18 @@ NS_IMETHODIMP nsTextEditor::OutputTextToString(nsString& aOutputString, PRBool a // Try to turn on pretty printing, but don't panic if it doesn't work: (void)encoder->PrettyPrint(PR_TRUE); - (void)encoder->SetWrapColumn(mWrapColumn); + // Set the wrap column. If our wrap column is 0, + // i.e. wrap to body width, then don't set it, let the + // document encoder use its own default. + if (mWrapColumn != 0) + { + PRUint32 wc; + if (mWrapColumn < 0) + wc = 0; + else + wc = (PRUint32)mWrapColumn; + (void)encoder->SetWrapColumn(wc); + } rv = encoder->EncodeToString(aOutputString); } diff --git a/editor/base/nsTextEditor.h b/editor/base/nsTextEditor.h index 8fee2ba0e651..a8b2390e59aa 100644 --- a/editor/base/nsTextEditor.h +++ b/editor/base/nsTextEditor.h @@ -119,8 +119,8 @@ public: NS_IMETHOD OutputHTMLToStream(nsIOutputStream* aOutputStream, nsString* aCharsetOverride, PRBool aSelectionOnly); // Plain text wrapping control - NS_IMETHOD GetBodyWrapWidth(PRUint32 *aWrapColumn); - NS_IMETHOD SetBodyWrapWidth(PRUint32 aWrapColumn); + NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn); + NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn); // Logging methods diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index 529c535ea306..c75d25953ad2 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -1623,7 +1623,7 @@ nsEditorShell::GetWrapColumn(PRInt32* aWrapColumn) nsCOMPtr textEditor = do_QueryInterface(mEditor); if (textEditor) { - PRUint32 wc; + PRInt32 wc; err = textEditor->GetBodyWrapWidth(&wc); if (NS_SUCCEEDED(err)) *aWrapColumn = (PRInt32)wc; diff --git a/editor/libeditor/text/nsEditorEventListeners.cpp b/editor/libeditor/text/nsEditorEventListeners.cpp index d606b7db660b..c8fa6f851732 100644 --- a/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/editor/libeditor/text/nsEditorEventListeners.cpp @@ -413,7 +413,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr { printf("Getting number of columns\n"); aProcessed=PR_TRUE; - PRUint32 wrap; + PRInt32 wrap; if (NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap))) printf("Currently wrapping to %d\n", wrap); else @@ -426,7 +426,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr if (PR_TRUE==altKey) { aProcessed=PR_TRUE; - PRUint32 wrap; + PRInt32 wrap; if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap))) { printf("GetBodyWrapWidth returned an error\n"); @@ -447,7 +447,7 @@ nsTextEditorKeyListener::ProcessShortCutKeys(nsIDOMEvent* aKeyEvent, PRBool& aPr if (PR_TRUE==altKey) { aProcessed=PR_TRUE; - PRUint32 wrap; + PRInt32 wrap; if (!NS_SUCCEEDED(mEditor->GetBodyWrapWidth(&wrap))) { printf("GetBodyWrapWidth returned an error\n");