зеркало из https://github.com/mozilla/pjs.git
38232 (nsbeta2+): Make line break character configurable in the
output system, and use \n (the DOM linebreak character) when getting output from text controls. Also fix some warnings. r=kin.
This commit is contained in:
Родитель
b822c170d2
Коммит
7dfa57ab2f
|
@ -98,7 +98,13 @@ public:
|
|||
|
||||
// Encode entities when outputting to a string.
|
||||
// E.g. If set, we'll output if clear, we'll output 0xa0.
|
||||
OutputEncodeEntities = 256
|
||||
OutputEncodeEntities = 256,
|
||||
|
||||
// LineBreak processing: we can do either platform line breaks,
|
||||
// CR, LF, or CRLF. If neither of these flags is set, then we
|
||||
// will use platform line breaks.
|
||||
OutputCRLineBreak = 512,
|
||||
OutputLFLineBreak = 1024
|
||||
};
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
|
|
@ -64,7 +64,6 @@ static PRInt32 BreakBeforeClose(eHTMLTags aTag);
|
|||
static PRInt32 BreakAfterClose(eHTMLTags aTag);
|
||||
static PRBool IndentChildren(eHTMLTags aTag);
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called as part of our COM-like interfaces.
|
||||
* Its purpose is to create an interface to parser object
|
||||
|
@ -144,6 +143,17 @@ nsHTMLContentSinkStream::Initialize(nsIOutputStream* aOutStream,
|
|||
mMaxColumn = 72;
|
||||
mFlags = aFlags;
|
||||
|
||||
// Set the line break character:
|
||||
if ((mFlags & nsIDocumentEncoder::OutputCRLineBreak)
|
||||
&& (mFlags & nsIDocumentEncoder::OutputLFLineBreak)) // Windows/mail
|
||||
mLineBreak.AssignWithConversion("\r\n");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputCRLineBreak) // Mac
|
||||
mLineBreak.AssignWithConversion("\r");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputLFLineBreak) // Unix/DOM
|
||||
mLineBreak.AssignWithConversion("\n");
|
||||
else
|
||||
mLineBreak.AssignWithConversion(NS_LINEBREAK); // Platform/default
|
||||
|
||||
mStream = aOutStream;
|
||||
mString = aOutString;
|
||||
if (aCharsetOverride != nsnull)
|
||||
|
@ -638,7 +648,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
// If this turns out to be a problem, we could do this only if gMozDirty.
|
||||
else if (tag == eHTMLTag_br && mPreLevel > 0)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -660,7 +670,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos != 0
|
||||
&& BreakBeforeOpen(tag))
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos == 0)
|
||||
|
@ -677,7 +687,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
if ((mDoFormat || isDirty) && mPreLevel == 0 && tag == eHTMLTag_style)
|
||||
{
|
||||
Write(kGreaterThan);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
const nsString& data = aNode.GetSkippedContent();
|
||||
PRInt32 size = data.Length();
|
||||
char* buffer = new char[size+1];
|
||||
|
@ -699,7 +709,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
|
||||
if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterOpen(tag)))
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
|
||||
|
@ -711,9 +721,9 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
if(mDoHeader)
|
||||
{
|
||||
Write(gHeaderComment);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
Write(gDocTypeHeader);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -752,7 +762,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
|
|||
if (!(mFlags & nsIDocumentEncoder::OutputSelectionOnly))
|
||||
{
|
||||
Write(kGreaterThan);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
}
|
||||
if ( mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_markupDecl)
|
||||
{
|
||||
|
@ -781,7 +791,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
|
|||
{
|
||||
if (mColPos != 0)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
}
|
||||
|
@ -809,7 +819,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
|
|||
if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterClose(tag))
|
||||
|| tag == eHTMLTag_body || tag == eHTMLTag_html)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
|
||||
|
@ -898,7 +908,7 @@ nsHTMLContentSinkStream::AddLeaf(const nsIParserNode& aNode)
|
|||
{
|
||||
if (!mDoFormat || mPreLevel > 0)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +980,7 @@ void nsHTMLContentSinkStream::WriteWrapped(const nsString& text)
|
|||
first.Truncate(indx);
|
||||
|
||||
Write(first);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
|
||||
// cut the string from the beginning to the index
|
||||
|
@ -1344,5 +1354,3 @@ static PRBool IndentChildren(eHTMLTags aTag)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -142,10 +141,8 @@ class nsHTMLContentSinkStream : public nsIHTMLContentSinkStream
|
|||
NS_IMETHOD BeginContext(PRInt32 aPosition);
|
||||
NS_IMETHOD EndContext(PRInt32 aPosition);
|
||||
|
||||
|
||||
public:
|
||||
void SetLowerCaseTags(PRBool aDoLowerCase) { mLowerCaseTags = aDoLowerCase; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -196,6 +193,8 @@ protected:
|
|||
|
||||
PRInt32 mMaxColumn;
|
||||
|
||||
nsString mLineBreak;
|
||||
|
||||
nsCOMPtr<nsISaveAsCharset> mCharsetEncoder;
|
||||
nsCOMPtr<nsIEntityConverter> mEntityConverter;
|
||||
nsCAutoString mCharsetOverride;
|
||||
|
|
|
@ -262,15 +262,20 @@ nsHTMLToTXTSinkStream::Initialize(nsIOutputStream* aOutStream,
|
|||
mCacheLine = PR_TRUE;
|
||||
}
|
||||
|
||||
// Set the line break character:
|
||||
if ((mFlags & nsIDocumentEncoder::OutputCRLineBreak)
|
||||
&& (mFlags & nsIDocumentEncoder::OutputLFLineBreak)) // Windows/mail
|
||||
mLineBreak.AssignWithConversion("\r\n");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputCRLineBreak) // Mac
|
||||
mLineBreak.AssignWithConversion("\r");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputLFLineBreak) // Unix/DOM
|
||||
mLineBreak.AssignWithConversion("\n");
|
||||
else
|
||||
mLineBreak.AssignWithConversion(NS_LINEBREAK); // Platform/default
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk04/30/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsHTMLToTXTSinkStream::SetCharsetOverride(const nsString* aCharset)
|
||||
{
|
||||
|
@ -1179,7 +1184,7 @@ nsHTMLToTXTSinkStream::EndLine(PRBool softlinebreak)
|
|||
// Add the soft part of the soft linebreak (RFC 2646 4.1)
|
||||
mCurrentLine.AppendWithConversion(' ');
|
||||
}
|
||||
mCurrentLine.AppendWithConversion(NS_LINEBREAK);
|
||||
mCurrentLine.Append(mLineBreak);
|
||||
WriteSimple(mCurrentLine);
|
||||
mCurrentLine.Truncate();
|
||||
mCurrentLineWidth = 0;
|
||||
|
@ -1207,7 +1212,7 @@ nsHTMLToTXTSinkStream::EndLine(PRBool softlinebreak)
|
|||
(sig_delimiter != mCurrentLine))
|
||||
mCurrentLine.SetLength(--currentlinelength);
|
||||
|
||||
mCurrentLine.AppendWithConversion(NS_LINEBREAK);
|
||||
mCurrentLine.Append(mLineBreak);
|
||||
WriteSimple(mCurrentLine);
|
||||
mCurrentLine.Truncate();
|
||||
mCurrentLineWidth = 0;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -91,7 +90,6 @@ class nsHTMLToTXTSinkStream : public nsIHTMLToTXTSinkStream
|
|||
|
||||
NS_IMETHOD SetCharsetOverride(const nsString* aCharset);
|
||||
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -206,6 +204,7 @@ protected:
|
|||
|
||||
nsIUnicodeEncoder* mUnicodeEncoder;
|
||||
nsString mCharsetOverride;
|
||||
nsString mLineBreak;
|
||||
nsILineBreaker* mLineBreaker;
|
||||
};
|
||||
|
||||
|
|
|
@ -98,7 +98,13 @@ public:
|
|||
|
||||
// Encode entities when outputting to a string.
|
||||
// E.g. If set, we'll output if clear, we'll output 0xa0.
|
||||
OutputEncodeEntities = 256
|
||||
OutputEncodeEntities = 256,
|
||||
|
||||
// LineBreak processing: we can do either platform line breaks,
|
||||
// CR, LF, or CRLF. If neither of these flags is set, then we
|
||||
// will use platform line breaks.
|
||||
OutputCRLineBreak = 512,
|
||||
OutputLFLineBreak = 1024
|
||||
};
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOCUMENT_ENCODER_IID; return iid; }
|
||||
|
|
|
@ -71,5 +71,5 @@ public:
|
|||
NS_IMETHOD SetSelectionRange(PRInt32 aSelectionStart, PRInt32 aSelectionEnd) = 0;
|
||||
NS_IMETHOD GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd) = 0;
|
||||
|
||||
NS_IMETHOD GetSelectionController(nsISelectionController **aSelCon) = 0;
|
||||
NS_IMETHOD GetSelectionContr(nsISelectionController **aSelCon) = 0;
|
||||
};
|
||||
|
|
|
@ -2181,7 +2181,7 @@ nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionContro
|
|||
nsIGfxTextControlFrame2 *tcf;
|
||||
if (NS_SUCCEEDED(tmp->QueryInterface(nsIGfxTextControlFrame2::GetIID(),(void**)&tcf)))
|
||||
{
|
||||
return tcf->GetSelectionController(aSelCon);
|
||||
return tcf->GetSelectionContr(aSelCon);
|
||||
}
|
||||
if (NS_FAILED(tmp->GetParent(&tmp)))
|
||||
break;
|
||||
|
|
|
@ -2181,7 +2181,7 @@ nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionContro
|
|||
nsIGfxTextControlFrame2 *tcf;
|
||||
if (NS_SUCCEEDED(tmp->QueryInterface(nsIGfxTextControlFrame2::GetIID(),(void**)&tcf)))
|
||||
{
|
||||
return tcf->GetSelectionController(aSelCon);
|
||||
return tcf->GetSelectionContr(aSelCon);
|
||||
}
|
||||
if (NS_FAILED(tmp->GetParent(&tmp)))
|
||||
break;
|
||||
|
|
|
@ -71,5 +71,5 @@ public:
|
|||
NS_IMETHOD SetSelectionRange(PRInt32 aSelectionStart, PRInt32 aSelectionEnd) = 0;
|
||||
NS_IMETHOD GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd) = 0;
|
||||
|
||||
NS_IMETHOD GetSelectionController(nsISelectionController **aSelCon) = 0;
|
||||
NS_IMETHOD GetSelectionContr(nsISelectionController **aSelCon) = 0;
|
||||
};
|
||||
|
|
|
@ -71,5 +71,5 @@ public:
|
|||
NS_IMETHOD SetSelectionRange(PRInt32 aSelectionStart, PRInt32 aSelectionEnd) = 0;
|
||||
NS_IMETHOD GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd) = 0;
|
||||
|
||||
NS_IMETHOD GetSelectionController(nsISelectionController **aSelCon) = 0;
|
||||
NS_IMETHOD GetSelectionContr(nsISelectionController **aSelCon) = 0;
|
||||
};
|
||||
|
|
|
@ -100,15 +100,6 @@
|
|||
|
||||
static NS_DEFINE_CID(kHTMLEditorCID, NS_HTMLEDITOR_CID);
|
||||
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
|
||||
static void RemoveNewlines(nsString &aString);
|
||||
|
||||
static void RemoveNewlines(nsString &aString)
|
||||
{
|
||||
// strip CR/LF and null
|
||||
static const char badChars[] = {10, 13, 0};
|
||||
aString.StripChars(badChars);
|
||||
}
|
||||
|
||||
|
||||
//listen for the return key. kinda lame.
|
||||
//listen for onchange notifications
|
||||
|
@ -1703,8 +1694,6 @@ nsGfxTextControlFrame2::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|||
aPresContext->GetCompatibilityMode(&mode);
|
||||
PRBool navQuirksMode = eCompatibility_NavQuirks == mode && nameSpaceID == kNameSpaceID_HTML;
|
||||
|
||||
nsSize desiredSize;
|
||||
|
||||
nsReflowStatus aStatus;
|
||||
nsMargin border;
|
||||
border.SizeTo(0, 0, 0, 0);
|
||||
|
@ -2238,7 +2227,7 @@ nsGfxTextControlFrame2::GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSe
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::GetSelectionController(nsISelectionController **aSelCon)
|
||||
nsGfxTextControlFrame2::GetSelectionContr(nsISelectionController **aSelCon)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSelCon);
|
||||
NS_IF_ADDREF(*aSelCon = mSelCon);
|
||||
|
@ -2553,7 +2542,7 @@ void nsGfxTextControlFrame2::GetTextControlFrameState(nsString& aValue)
|
|||
if (mEditor)
|
||||
{
|
||||
nsString format; format.AssignWithConversion("text/plain");
|
||||
PRUint32 flags = 0;
|
||||
PRUint32 flags = nsIDocumentEncoder::OutputLFLineBreak;;
|
||||
|
||||
if (PR_TRUE==IsPlainTextControl()) {
|
||||
flags |= nsIDocumentEncoder::OutputBodyOnly; // OutputNoDoctype if head info needed
|
||||
|
|
|
@ -122,7 +122,7 @@ public:
|
|||
NS_IMETHOD SetSelectionEnd(PRInt32 aSelectionEnd);
|
||||
NS_IMETHOD SetSelectionRange(PRInt32 aSelectionStart, PRInt32 aSelectionEnd);
|
||||
NS_IMETHOD GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd);
|
||||
NS_IMETHOD GetSelectionController(nsISelectionController **aSelCon);
|
||||
NS_IMETHOD GetSelectionContr(nsISelectionController **aSelCon);
|
||||
|
||||
//==== END NSIGFXTEXTCONTROLFRAME2
|
||||
//==== OVERLOAD of nsIFrame
|
||||
|
|
|
@ -64,7 +64,6 @@ static PRInt32 BreakBeforeClose(eHTMLTags aTag);
|
|||
static PRInt32 BreakAfterClose(eHTMLTags aTag);
|
||||
static PRBool IndentChildren(eHTMLTags aTag);
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called as part of our COM-like interfaces.
|
||||
* Its purpose is to create an interface to parser object
|
||||
|
@ -144,6 +143,17 @@ nsHTMLContentSinkStream::Initialize(nsIOutputStream* aOutStream,
|
|||
mMaxColumn = 72;
|
||||
mFlags = aFlags;
|
||||
|
||||
// Set the line break character:
|
||||
if ((mFlags & nsIDocumentEncoder::OutputCRLineBreak)
|
||||
&& (mFlags & nsIDocumentEncoder::OutputLFLineBreak)) // Windows/mail
|
||||
mLineBreak.AssignWithConversion("\r\n");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputCRLineBreak) // Mac
|
||||
mLineBreak.AssignWithConversion("\r");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputLFLineBreak) // Unix/DOM
|
||||
mLineBreak.AssignWithConversion("\n");
|
||||
else
|
||||
mLineBreak.AssignWithConversion(NS_LINEBREAK); // Platform/default
|
||||
|
||||
mStream = aOutStream;
|
||||
mString = aOutString;
|
||||
if (aCharsetOverride != nsnull)
|
||||
|
@ -638,7 +648,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
// If this turns out to be a problem, we could do this only if gMozDirty.
|
||||
else if (tag == eHTMLTag_br && mPreLevel > 0)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -660,7 +670,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos != 0
|
||||
&& BreakBeforeOpen(tag))
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
if ((mDoFormat || isDirty) && mPreLevel == 0 && mColPos == 0)
|
||||
|
@ -677,7 +687,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
if ((mDoFormat || isDirty) && mPreLevel == 0 && tag == eHTMLTag_style)
|
||||
{
|
||||
Write(kGreaterThan);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
const nsString& data = aNode.GetSkippedContent();
|
||||
PRInt32 size = data.Length();
|
||||
char* buffer = new char[size+1];
|
||||
|
@ -699,7 +709,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
|
||||
if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterOpen(tag)))
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
|
||||
|
@ -711,9 +721,9 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
|
|||
if(mDoHeader)
|
||||
{
|
||||
Write(gHeaderComment);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
Write(gDocTypeHeader);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -752,7 +762,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
|
|||
if (!(mFlags & nsIDocumentEncoder::OutputSelectionOnly))
|
||||
{
|
||||
Write(kGreaterThan);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
}
|
||||
if ( mHTMLTagStack[mHTMLStackPos-1] == eHTMLTag_markupDecl)
|
||||
{
|
||||
|
@ -781,7 +791,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
|
|||
{
|
||||
if (mColPos != 0)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
}
|
||||
|
@ -809,7 +819,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
|
|||
if (((mDoFormat || isDirty) && mPreLevel == 0 && BreakAfterClose(tag))
|
||||
|| tag == eHTMLTag_body || tag == eHTMLTag_html)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
mHTMLTagStack[--mHTMLStackPos] = eHTMLTag_unknown;
|
||||
|
@ -898,7 +908,7 @@ nsHTMLContentSinkStream::AddLeaf(const nsIParserNode& aNode)
|
|||
{
|
||||
if (!mDoFormat || mPreLevel > 0)
|
||||
{
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +980,7 @@ void nsHTMLContentSinkStream::WriteWrapped(const nsString& text)
|
|||
first.Truncate(indx);
|
||||
|
||||
Write(first);
|
||||
Write(NS_LINEBREAK);
|
||||
Write(mLineBreak);
|
||||
mColPos = 0;
|
||||
|
||||
// cut the string from the beginning to the index
|
||||
|
@ -1344,5 +1354,3 @@ static PRBool IndentChildren(eHTMLTags aTag)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -142,10 +141,8 @@ class nsHTMLContentSinkStream : public nsIHTMLContentSinkStream
|
|||
NS_IMETHOD BeginContext(PRInt32 aPosition);
|
||||
NS_IMETHOD EndContext(PRInt32 aPosition);
|
||||
|
||||
|
||||
public:
|
||||
void SetLowerCaseTags(PRBool aDoLowerCase) { mLowerCaseTags = aDoLowerCase; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -196,6 +193,8 @@ protected:
|
|||
|
||||
PRInt32 mMaxColumn;
|
||||
|
||||
nsString mLineBreak;
|
||||
|
||||
nsCOMPtr<nsISaveAsCharset> mCharsetEncoder;
|
||||
nsCOMPtr<nsIEntityConverter> mEntityConverter;
|
||||
nsCAutoString mCharsetOverride;
|
||||
|
|
|
@ -262,15 +262,20 @@ nsHTMLToTXTSinkStream::Initialize(nsIOutputStream* aOutStream,
|
|||
mCacheLine = PR_TRUE;
|
||||
}
|
||||
|
||||
// Set the line break character:
|
||||
if ((mFlags & nsIDocumentEncoder::OutputCRLineBreak)
|
||||
&& (mFlags & nsIDocumentEncoder::OutputLFLineBreak)) // Windows/mail
|
||||
mLineBreak.AssignWithConversion("\r\n");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputCRLineBreak) // Mac
|
||||
mLineBreak.AssignWithConversion("\r");
|
||||
else if (mFlags & nsIDocumentEncoder::OutputLFLineBreak) // Unix/DOM
|
||||
mLineBreak.AssignWithConversion("\n");
|
||||
else
|
||||
mLineBreak.AssignWithConversion(NS_LINEBREAK); // Platform/default
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk04/30/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsHTMLToTXTSinkStream::SetCharsetOverride(const nsString* aCharset)
|
||||
{
|
||||
|
@ -1179,7 +1184,7 @@ nsHTMLToTXTSinkStream::EndLine(PRBool softlinebreak)
|
|||
// Add the soft part of the soft linebreak (RFC 2646 4.1)
|
||||
mCurrentLine.AppendWithConversion(' ');
|
||||
}
|
||||
mCurrentLine.AppendWithConversion(NS_LINEBREAK);
|
||||
mCurrentLine.Append(mLineBreak);
|
||||
WriteSimple(mCurrentLine);
|
||||
mCurrentLine.Truncate();
|
||||
mCurrentLineWidth = 0;
|
||||
|
@ -1207,7 +1212,7 @@ nsHTMLToTXTSinkStream::EndLine(PRBool softlinebreak)
|
|||
(sig_delimiter != mCurrentLine))
|
||||
mCurrentLine.SetLength(--currentlinelength);
|
||||
|
||||
mCurrentLine.AppendWithConversion(NS_LINEBREAK);
|
||||
mCurrentLine.Append(mLineBreak);
|
||||
WriteSimple(mCurrentLine);
|
||||
mCurrentLine.Truncate();
|
||||
mCurrentLineWidth = 0;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -91,7 +90,6 @@ class nsHTMLToTXTSinkStream : public nsIHTMLToTXTSinkStream
|
|||
|
||||
NS_IMETHOD SetCharsetOverride(const nsString* aCharset);
|
||||
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -206,6 +204,7 @@ protected:
|
|||
|
||||
nsIUnicodeEncoder* mUnicodeEncoder;
|
||||
nsString mCharsetOverride;
|
||||
nsString mLineBreak;
|
||||
nsILineBreaker* mLineBreaker;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче