mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Added nsString, so the conversion goes to a string and to a stream
Eventually, we will want it to just go to a string.
This commit is contained in:
parent
dcdc02d44e
commit
f33501ef59
@ -423,6 +423,12 @@ void nsHTMLToTXTSinkStream::UnicodeToTXTString(const nsString& aSrc)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLToTXTSinkStream::GetStringBuffer(nsString & aStrBuffer)
|
||||
{
|
||||
aStrBuffer = mStrBuffer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -449,6 +455,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode, ostream& aStream)
|
||||
|
||||
UnicodeToTXTString(text);
|
||||
aStream << mBuffer;
|
||||
mStrBuffer.Append(mBuffer);
|
||||
mColPos += text.Length();
|
||||
}
|
||||
else if (type == eHTMLTag_whitespace)
|
||||
@ -458,6 +465,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode, ostream& aStream)
|
||||
const nsString& text = aNode.GetText();
|
||||
UnicodeToTXTString(text);
|
||||
aStream << mBuffer;
|
||||
mStrBuffer.Append(mBuffer);
|
||||
mColPos += text.Length();
|
||||
}
|
||||
}
|
||||
@ -466,6 +474,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode, ostream& aStream)
|
||||
if (PR_TRUE)
|
||||
{
|
||||
aStream << endl;
|
||||
mStrBuffer.Append("\n");
|
||||
mColPos += 1;
|
||||
}
|
||||
}
|
||||
@ -543,7 +552,9 @@ nsHTMLToTXTSinkStream::CloseContainer(const nsIParserNode& aNode){
|
||||
{
|
||||
if (mColPos != 0)
|
||||
{
|
||||
*mOutput << endl;
|
||||
if (mOutput)
|
||||
*mOutput << endl;
|
||||
mStrBuffer.Append("\n");
|
||||
mColPos = 0;
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ class nsHTMLToTXTSinkStream : public nsIHTMLContentSink {
|
||||
virtual ~nsHTMLToTXTSinkStream();
|
||||
|
||||
NS_IMETHOD_(void) SetOutputStream(ostream& aStream);
|
||||
NS_IMETHOD GetStringBuffer(nsString & aStrBuffer);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -124,6 +125,8 @@ protected:
|
||||
char* mBuffer;
|
||||
PRInt32 mBufferSize;
|
||||
|
||||
nsString mStrBuffer;
|
||||
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
|
@ -423,6 +423,12 @@ void nsHTMLToTXTSinkStream::UnicodeToTXTString(const nsString& aSrc)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLToTXTSinkStream::GetStringBuffer(nsString & aStrBuffer)
|
||||
{
|
||||
aStrBuffer = mStrBuffer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -449,6 +455,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode, ostream& aStream)
|
||||
|
||||
UnicodeToTXTString(text);
|
||||
aStream << mBuffer;
|
||||
mStrBuffer.Append(mBuffer);
|
||||
mColPos += text.Length();
|
||||
}
|
||||
else if (type == eHTMLTag_whitespace)
|
||||
@ -458,6 +465,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode, ostream& aStream)
|
||||
const nsString& text = aNode.GetText();
|
||||
UnicodeToTXTString(text);
|
||||
aStream << mBuffer;
|
||||
mStrBuffer.Append(mBuffer);
|
||||
mColPos += text.Length();
|
||||
}
|
||||
}
|
||||
@ -466,6 +474,7 @@ nsHTMLToTXTSinkStream::AddLeaf(const nsIParserNode& aNode, ostream& aStream)
|
||||
if (PR_TRUE)
|
||||
{
|
||||
aStream << endl;
|
||||
mStrBuffer.Append("\n");
|
||||
mColPos += 1;
|
||||
}
|
||||
}
|
||||
@ -543,7 +552,9 @@ nsHTMLToTXTSinkStream::CloseContainer(const nsIParserNode& aNode){
|
||||
{
|
||||
if (mColPos != 0)
|
||||
{
|
||||
*mOutput << endl;
|
||||
if (mOutput)
|
||||
*mOutput << endl;
|
||||
mStrBuffer.Append("\n");
|
||||
mColPos = 0;
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ class nsHTMLToTXTSinkStream : public nsIHTMLContentSink {
|
||||
virtual ~nsHTMLToTXTSinkStream();
|
||||
|
||||
NS_IMETHOD_(void) SetOutputStream(ostream& aStream);
|
||||
NS_IMETHOD GetStringBuffer(nsString & aStrBuffer);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -124,6 +125,8 @@ protected:
|
||||
char* mBuffer;
|
||||
PRInt32 mBufferSize;
|
||||
|
||||
nsString mStrBuffer;
|
||||
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
|
Loading…
Reference in New Issue
Block a user