зеркало из https://github.com/mozilla/gecko-dev.git
Bug 116499 - convert nsIOutlinerView::GetCellText to return an nsAString, so we can avoid copying strings. r=blake, sr=jag.
This commit is contained in:
Родитель
58626137f3
Коммит
2a1819d615
|
@ -611,7 +611,7 @@ nsXULOutlinerBuilder::GetLevel(PRInt32 aRowIndex, PRInt32* aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULOutlinerBuilder::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnichar** aResult)
|
||||
nsXULOutlinerBuilder::GetCellText(PRInt32 aRow, const PRUnichar* aColID, nsAString& aResult)
|
||||
{
|
||||
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad index");
|
||||
if (aRow < 0 || aRow >= mRows.Count())
|
||||
|
@ -624,13 +624,11 @@ nsXULOutlinerBuilder::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnich
|
|||
nsAutoString raw;
|
||||
cell->GetAttr(kNameSpaceID_None, nsXULAtoms::label, raw);
|
||||
|
||||
nsAutoString cooked;
|
||||
SubstituteText(*(mRows[aRow]->mMatch), raw, cooked);
|
||||
SubstituteText(*(mRows[aRow]->mMatch), raw, aResult);
|
||||
|
||||
*aResult = nsCRT::strdup(cooked.get());
|
||||
}
|
||||
else
|
||||
*aResult = nsnull;
|
||||
aResult.SetCapacity(0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1095,17 +1095,17 @@ nsXULTemplateBuilder::ParseAttribute(const nsAReadableString& aAttributeValue,
|
|||
|
||||
|
||||
struct SubstituteTextClosure {
|
||||
SubstituteTextClosure(nsTemplateMatch& aMatch, nsString& aResult)
|
||||
SubstituteTextClosure(nsTemplateMatch& aMatch, nsAString& aResult)
|
||||
: match(aMatch), result(aResult) {}
|
||||
|
||||
nsTemplateMatch& match;
|
||||
nsString& result;
|
||||
nsAString& result;
|
||||
};
|
||||
|
||||
nsresult
|
||||
nsXULTemplateBuilder::SubstituteText(nsTemplateMatch& aMatch,
|
||||
const nsAReadableString& aAttributeValue,
|
||||
nsString& aResult)
|
||||
nsAString& aResult)
|
||||
{
|
||||
// See if it's the special value "..."
|
||||
if (aAttributeValue == NS_LITERAL_STRING("...")) {
|
||||
|
|
|
@ -310,7 +310,7 @@ public:
|
|||
nsresult
|
||||
SubstituteText(nsTemplateMatch& aMatch,
|
||||
const nsAReadableString& aAttributeValue,
|
||||
nsString& aResult);
|
||||
nsAString& aResult);
|
||||
|
||||
static void
|
||||
SubstituteTextAppendText(nsXULTemplateBuilder* aThis, const nsAReadableString& aText, void* aClosure);
|
||||
|
|
|
@ -611,7 +611,7 @@ nsXULOutlinerBuilder::GetLevel(PRInt32 aRowIndex, PRInt32* aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULOutlinerBuilder::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnichar** aResult)
|
||||
nsXULOutlinerBuilder::GetCellText(PRInt32 aRow, const PRUnichar* aColID, nsAString& aResult)
|
||||
{
|
||||
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad index");
|
||||
if (aRow < 0 || aRow >= mRows.Count())
|
||||
|
@ -624,13 +624,11 @@ nsXULOutlinerBuilder::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnich
|
|||
nsAutoString raw;
|
||||
cell->GetAttr(kNameSpaceID_None, nsXULAtoms::label, raw);
|
||||
|
||||
nsAutoString cooked;
|
||||
SubstituteText(*(mRows[aRow]->mMatch), raw, cooked);
|
||||
SubstituteText(*(mRows[aRow]->mMatch), raw, aResult);
|
||||
|
||||
*aResult = nsCRT::strdup(cooked.get());
|
||||
}
|
||||
else
|
||||
*aResult = nsnull;
|
||||
aResult.SetCapacity(0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ inDOMView::GetColumnProperties(const PRUnichar *colID, nsIDOMElement *colElt, ns
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMView::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnichar **_retval)
|
||||
inDOMView::GetCellText(PRInt32 row, const PRUnichar *colID, nsAString& _retval)
|
||||
{
|
||||
inDOMViewNode* node = nsnull;
|
||||
RowToNode(row, &node);
|
||||
|
@ -379,36 +379,30 @@ inDOMView::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnichar **_retval)
|
|||
|
||||
nsIDOMNode* domNode = node->node;
|
||||
|
||||
nsAutoString value;
|
||||
nsAutoString col(colID);
|
||||
if (col.Equals(NS_LITERAL_STRING("colNodeName"))) {
|
||||
domNode->GetNodeName(value);
|
||||
*_retval = ToNewUnicode(value);
|
||||
} else if (col.Equals(NS_LITERAL_STRING("colLocalName"))) {
|
||||
domNode->GetLocalName(value);
|
||||
*_retval = ToNewUnicode(value);
|
||||
} else if (col.Equals(NS_LITERAL_STRING("colPrefix"))) {
|
||||
domNode->GetPrefix(value);
|
||||
*_retval = ToNewUnicode(value);
|
||||
} else if (col.Equals(NS_LITERAL_STRING("colNamespaceURI"))) {
|
||||
domNode->GetNamespaceURI(value);
|
||||
*_retval = ToNewUnicode(value);
|
||||
} else if (col.Equals(NS_LITERAL_STRING("colNodeType"))) {
|
||||
if (col.Equals(NS_LITERAL_STRING("colNodeName")))
|
||||
domNode->GetNodeName(_retval);
|
||||
else if (col.Equals(NS_LITERAL_STRING("colLocalName")))
|
||||
domNode->GetLocalName(_retval);
|
||||
else if (col.Equals(NS_LITERAL_STRING("colPrefix")))
|
||||
domNode->GetPrefix(_retval);
|
||||
else if (col.Equals(NS_LITERAL_STRING("colNamespaceURI")))
|
||||
domNode->GetNamespaceURI(_retval);
|
||||
else if (col.Equals(NS_LITERAL_STRING("colNodeType"))) {
|
||||
PRUint16 nodeType;
|
||||
domNode->GetNodeType(&nodeType);
|
||||
value.AppendInt(PRInt32(nodeType));
|
||||
*_retval = ToNewUnicode(value);
|
||||
} else if (col.Equals(NS_LITERAL_STRING("colNodeValue"))) {
|
||||
domNode->GetNodeValue(value);
|
||||
*_retval = ToNewUnicode(value);
|
||||
} else {
|
||||
nsAutoString temp;
|
||||
temp.AppendInt(PRInt32(nodeType));
|
||||
_retval = temp;
|
||||
} else if (col.Equals(NS_LITERAL_STRING("colNodeValue")))
|
||||
domNode->GetNodeValue(_retval);
|
||||
else {
|
||||
if (Substring(col, 0, 4).Equals(NS_LITERAL_STRING("col@"))) {
|
||||
nsCOMPtr<nsIDOMElement> el = do_QueryInterface(node->node);
|
||||
if (el) {
|
||||
nsAutoString attr;
|
||||
col.Right(attr, col.Length()-4); // have to use this because Substring is crashing on me!
|
||||
el->GetAttribute(attr, value);
|
||||
*_retval = ToNewUnicode(value);
|
||||
el->GetAttribute(attr, _retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -448,12 +448,9 @@ SetTitletipLabel(nsIOutlinerBoxObject* aOutlinerBox, nsIContent* aTooltip,
|
|||
nsCOMPtr<nsIOutlinerView> view;
|
||||
aOutlinerBox->GetView(getter_AddRefs(view));
|
||||
|
||||
PRUnichar* cellText = nsnull;
|
||||
view->GetCellText(aRow, aCol.get(), &cellText);
|
||||
|
||||
nsAutoString label;
|
||||
label.Assign(cellText);
|
||||
|
||||
view->GetCellText(aRow, aCol.get(), label);
|
||||
|
||||
aTooltip->SetAttr(nsnull, nsXULAtoms::label, label, PR_FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ interface nsIOutlinerView : nsISupports
|
|||
* The text for a given cell. If a column consists only of an image, then
|
||||
* the empty string is returned.
|
||||
*/
|
||||
wstring getCellText(in long row, in wstring colID);
|
||||
AString getCellText(in long row, in wstring colID);
|
||||
|
||||
/**
|
||||
* Called during initialization to link the view to the front end box object.
|
||||
|
|
|
@ -994,9 +994,8 @@ nsOutlinerBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID,
|
|||
cellX += imageSize.width;
|
||||
|
||||
// Cell Text
|
||||
nsXPIDLString text;
|
||||
mView->GetCellText(aRow, currCol->GetID(), getter_Copies(text));
|
||||
nsAutoString cellText(text);
|
||||
nsAutoString cellText;
|
||||
mView->GetCellText(aRow, currCol->GetID(), cellText);
|
||||
|
||||
// Create a scratch rect to represent the text rectangle, with the current
|
||||
// X and Y coords, and a guess at the width and height. The width is the
|
||||
|
@ -1229,9 +1228,8 @@ nsOutlinerBodyFrame::IsCellCropped(PRInt32 aRow, const nsAString& aColID, PRBool
|
|||
remainWidth -= imageSize.width;
|
||||
|
||||
// Get the cell text.
|
||||
nsXPIDLString text;
|
||||
mView->GetCellText(aRow, currCol->GetID(), getter_Copies(text));
|
||||
nsAutoString cellText(text);
|
||||
nsAutoString cellText;
|
||||
mView->GetCellText(aRow, currCol->GetID(), cellText);
|
||||
|
||||
nsCOMPtr<nsIStyleContext> textContext;
|
||||
GetPseudoStyleContext(nsXULAtoms::mozoutlinercelltext, getter_AddRefs(textContext));
|
||||
|
@ -2147,12 +2145,10 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
// Now obtain the text for our cell.
|
||||
nsXPIDLString text;
|
||||
mView->GetCellText(aRowIndex, aColumn->GetID(), getter_Copies(text));
|
||||
nsAutoString text;
|
||||
mView->GetCellText(aRowIndex, aColumn->GetID(), text);
|
||||
|
||||
nsAutoString realText(text);
|
||||
|
||||
if (realText.Length() == 0)
|
||||
if (text.Length() == 0)
|
||||
return NS_OK; // Don't paint an empty string. XXX What about background/borders? Still paint?
|
||||
|
||||
// Resolve style for the text. It contains all the info we need to lay ourselves
|
||||
|
@ -2199,21 +2195,19 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
aRenderingContext.SetFont(fontMet);
|
||||
|
||||
nscoord width;
|
||||
aRenderingContext.GetWidth(realText, width);
|
||||
|
||||
aRenderingContext.GetWidth(text, width);
|
||||
|
||||
if (width > textRect.width) {
|
||||
// See if the width is even smaller than the ellipsis
|
||||
// If so, clear the text completely.
|
||||
nscoord ellipsisWidth;
|
||||
aRenderingContext.GetWidth(ELLIPSIS, ellipsisWidth);
|
||||
|
||||
nsAutoString ellipsis; ellipsis.AssignWithConversion(ELLIPSIS);
|
||||
|
||||
nscoord width = textRect.width;
|
||||
if (ellipsisWidth > width)
|
||||
realText.SetLength(0);
|
||||
text.SetLength(0);
|
||||
else if (ellipsisWidth == width)
|
||||
realText = ellipsis;
|
||||
text.Assign(NS_LITERAL_STRING(ELLIPSIS));
|
||||
else {
|
||||
// We will be drawing an ellipsis, thank you very much.
|
||||
// Subtract out the required width of the ellipsis.
|
||||
|
@ -2227,18 +2221,18 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
// Crop right.
|
||||
nscoord cwidth;
|
||||
nscoord twidth = 0;
|
||||
int length = realText.Length();
|
||||
int length = text.Length();
|
||||
int i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
PRUnichar ch = realText.CharAt(i);
|
||||
PRUnichar ch = text[i];
|
||||
aRenderingContext.GetWidth(ch,cwidth);
|
||||
if (twidth + cwidth > width)
|
||||
break;
|
||||
twidth += cwidth;
|
||||
}
|
||||
|
||||
realText.Truncate(i);
|
||||
realText += ellipsis;
|
||||
text.Truncate(i);
|
||||
text += NS_LITERAL_STRING(ELLIPSIS);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2246,10 +2240,10 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
// Crop left.
|
||||
nscoord cwidth;
|
||||
nscoord twidth = 0;
|
||||
int length = realText.Length();
|
||||
int length = text.Length();
|
||||
int i;
|
||||
for (i=length-1; i >= 0; --i) {
|
||||
PRUnichar ch = realText.CharAt(i);
|
||||
PRUnichar ch = text[i];
|
||||
aRenderingContext.GetWidth(ch,cwidth);
|
||||
if (twidth + cwidth > width)
|
||||
break;
|
||||
|
@ -2258,9 +2252,9 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
}
|
||||
|
||||
nsAutoString copy;
|
||||
realText.Right(copy, length-1-i);
|
||||
realText = ellipsis;
|
||||
realText += copy;
|
||||
text.Right(copy, length-1-i);
|
||||
text.Assign(NS_LITERAL_STRING(ELLIPSIS));
|
||||
text += copy;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2277,7 +2271,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
const nsStyleColor* colorStyle = (const nsStyleColor*)textContext->GetStyleData(eStyleStruct_Color);
|
||||
aRenderingContext.SetColor(colorStyle->mColor);
|
||||
|
||||
aRenderingContext.DrawString(realText, textRect.x, textRect.y + baseline);
|
||||
aRenderingContext.DrawString(text, textRect.x, textRect.y + baseline);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -407,13 +407,13 @@ nsOutlinerContentView::GetLevel(PRInt32 aIndex, PRInt32* _retval)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOutlinerContentView::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnichar** _retval)
|
||||
nsOutlinerContentView::GetCellText(PRInt32 aRow, const PRUnichar* aColID, nsAString& _retval)
|
||||
{
|
||||
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
|
||||
if (aRow < 0 || aRow >= mRows.Count())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = nsnull;
|
||||
_retval.SetCapacity(0);
|
||||
|
||||
Row* row = (Row*)mRows[aRow];
|
||||
nsCOMPtr<nsIContent> realRow;
|
||||
|
@ -422,9 +422,7 @@ nsOutlinerContentView::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnic
|
|||
nsCOMPtr<nsIContent> cell;
|
||||
GetNamedCell(realRow, aColID, getter_AddRefs(cell));
|
||||
if (cell) {
|
||||
nsAutoString label;
|
||||
cell->GetAttr(kNameSpaceID_None, nsHTMLAtoms::label, label);
|
||||
*_retval = ToNewUnicode(label);
|
||||
cell->GetAttr(kNameSpaceID_None, nsHTMLAtoms::label, _retval);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ interface nsIOutlinerView : nsISupports
|
|||
* The text for a given cell. If a column consists only of an image, then
|
||||
* the empty string is returned.
|
||||
*/
|
||||
wstring getCellText(in long row, in wstring colID);
|
||||
AString getCellText(in long row, in wstring colID);
|
||||
|
||||
/**
|
||||
* Called during initialization to link the view to the front end box object.
|
||||
|
|
|
@ -994,9 +994,8 @@ nsOutlinerBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID,
|
|||
cellX += imageSize.width;
|
||||
|
||||
// Cell Text
|
||||
nsXPIDLString text;
|
||||
mView->GetCellText(aRow, currCol->GetID(), getter_Copies(text));
|
||||
nsAutoString cellText(text);
|
||||
nsAutoString cellText;
|
||||
mView->GetCellText(aRow, currCol->GetID(), cellText);
|
||||
|
||||
// Create a scratch rect to represent the text rectangle, with the current
|
||||
// X and Y coords, and a guess at the width and height. The width is the
|
||||
|
@ -1229,9 +1228,8 @@ nsOutlinerBodyFrame::IsCellCropped(PRInt32 aRow, const nsAString& aColID, PRBool
|
|||
remainWidth -= imageSize.width;
|
||||
|
||||
// Get the cell text.
|
||||
nsXPIDLString text;
|
||||
mView->GetCellText(aRow, currCol->GetID(), getter_Copies(text));
|
||||
nsAutoString cellText(text);
|
||||
nsAutoString cellText;
|
||||
mView->GetCellText(aRow, currCol->GetID(), cellText);
|
||||
|
||||
nsCOMPtr<nsIStyleContext> textContext;
|
||||
GetPseudoStyleContext(nsXULAtoms::mozoutlinercelltext, getter_AddRefs(textContext));
|
||||
|
@ -2147,12 +2145,10 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
// Now obtain the text for our cell.
|
||||
nsXPIDLString text;
|
||||
mView->GetCellText(aRowIndex, aColumn->GetID(), getter_Copies(text));
|
||||
nsAutoString text;
|
||||
mView->GetCellText(aRowIndex, aColumn->GetID(), text);
|
||||
|
||||
nsAutoString realText(text);
|
||||
|
||||
if (realText.Length() == 0)
|
||||
if (text.Length() == 0)
|
||||
return NS_OK; // Don't paint an empty string. XXX What about background/borders? Still paint?
|
||||
|
||||
// Resolve style for the text. It contains all the info we need to lay ourselves
|
||||
|
@ -2199,21 +2195,19 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
aRenderingContext.SetFont(fontMet);
|
||||
|
||||
nscoord width;
|
||||
aRenderingContext.GetWidth(realText, width);
|
||||
|
||||
aRenderingContext.GetWidth(text, width);
|
||||
|
||||
if (width > textRect.width) {
|
||||
// See if the width is even smaller than the ellipsis
|
||||
// If so, clear the text completely.
|
||||
nscoord ellipsisWidth;
|
||||
aRenderingContext.GetWidth(ELLIPSIS, ellipsisWidth);
|
||||
|
||||
nsAutoString ellipsis; ellipsis.AssignWithConversion(ELLIPSIS);
|
||||
|
||||
nscoord width = textRect.width;
|
||||
if (ellipsisWidth > width)
|
||||
realText.SetLength(0);
|
||||
text.SetLength(0);
|
||||
else if (ellipsisWidth == width)
|
||||
realText = ellipsis;
|
||||
text.Assign(NS_LITERAL_STRING(ELLIPSIS));
|
||||
else {
|
||||
// We will be drawing an ellipsis, thank you very much.
|
||||
// Subtract out the required width of the ellipsis.
|
||||
|
@ -2227,18 +2221,18 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
// Crop right.
|
||||
nscoord cwidth;
|
||||
nscoord twidth = 0;
|
||||
int length = realText.Length();
|
||||
int length = text.Length();
|
||||
int i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
PRUnichar ch = realText.CharAt(i);
|
||||
PRUnichar ch = text[i];
|
||||
aRenderingContext.GetWidth(ch,cwidth);
|
||||
if (twidth + cwidth > width)
|
||||
break;
|
||||
twidth += cwidth;
|
||||
}
|
||||
|
||||
realText.Truncate(i);
|
||||
realText += ellipsis;
|
||||
text.Truncate(i);
|
||||
text += NS_LITERAL_STRING(ELLIPSIS);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2246,10 +2240,10 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
// Crop left.
|
||||
nscoord cwidth;
|
||||
nscoord twidth = 0;
|
||||
int length = realText.Length();
|
||||
int length = text.Length();
|
||||
int i;
|
||||
for (i=length-1; i >= 0; --i) {
|
||||
PRUnichar ch = realText.CharAt(i);
|
||||
PRUnichar ch = text[i];
|
||||
aRenderingContext.GetWidth(ch,cwidth);
|
||||
if (twidth + cwidth > width)
|
||||
break;
|
||||
|
@ -2258,9 +2252,9 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
}
|
||||
|
||||
nsAutoString copy;
|
||||
realText.Right(copy, length-1-i);
|
||||
realText = ellipsis;
|
||||
realText += copy;
|
||||
text.Right(copy, length-1-i);
|
||||
text.Assign(NS_LITERAL_STRING(ELLIPSIS));
|
||||
text += copy;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2277,7 +2271,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintText(int aRowIndex,
|
|||
const nsStyleColor* colorStyle = (const nsStyleColor*)textContext->GetStyleData(eStyleStruct_Color);
|
||||
aRenderingContext.SetColor(colorStyle->mColor);
|
||||
|
||||
aRenderingContext.DrawString(realText, textRect.x, textRect.y + baseline);
|
||||
aRenderingContext.DrawString(text, textRect.x, textRect.y + baseline);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -407,13 +407,13 @@ nsOutlinerContentView::GetLevel(PRInt32 aIndex, PRInt32* _retval)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOutlinerContentView::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnichar** _retval)
|
||||
nsOutlinerContentView::GetCellText(PRInt32 aRow, const PRUnichar* aColID, nsAString& _retval)
|
||||
{
|
||||
NS_PRECONDITION(aRow >= 0 && aRow < mRows.Count(), "bad row");
|
||||
if (aRow < 0 || aRow >= mRows.Count())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = nsnull;
|
||||
_retval.SetCapacity(0);
|
||||
|
||||
Row* row = (Row*)mRows[aRow];
|
||||
nsCOMPtr<nsIContent> realRow;
|
||||
|
@ -422,9 +422,7 @@ nsOutlinerContentView::GetCellText(PRInt32 aRow, const PRUnichar* aColID, PRUnic
|
|||
nsCOMPtr<nsIContent> cell;
|
||||
GetNamedCell(realRow, aColID, getter_AddRefs(cell));
|
||||
if (cell) {
|
||||
nsAutoString label;
|
||||
cell->GetAttr(kNameSpaceID_None, nsHTMLAtoms::label, label);
|
||||
*_retval = ToNewUnicode(label);
|
||||
cell->GetAttr(kNameSpaceID_None, nsHTMLAtoms::label, _retval);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -451,14 +451,18 @@ nsresult nsAbView::GetCardValue(nsIAbCard *card, const PRUnichar *colID, PRUnich
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbView::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnichar **_retval)
|
||||
NS_IMETHODIMP nsAbView::GetCellText(PRInt32 row, const PRUnichar *colID, nsAString& _retval)
|
||||
{
|
||||
// XXX todo remove once #116341 is fixed
|
||||
if (!colID[0])
|
||||
return NS_OK;
|
||||
|
||||
nsIAbCard *card = ((AbCard *)(mCards.ElementAt(row)))->card;
|
||||
return GetCardValue(card, colID, _retval);
|
||||
// XXX fix me by converting GetCardValue to take an nsAString&
|
||||
nsXPIDLString cellText;
|
||||
nsresult rv = GetCardValue(card, colID, getter_Copies(cellText));
|
||||
_retval.Assign(cellText);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbView::SetOutliner(nsIOutlinerBoxObject *outliner)
|
||||
|
|
|
@ -1260,7 +1260,7 @@ nsresult nsMsgDBView::GetDBForViewIndex(nsMsgViewIndex index, nsIMsgDatabase **d
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, PRUnichar ** aValue)
|
||||
NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, nsAString& aValue)
|
||||
{
|
||||
// remove once #116341 is fixed
|
||||
if (!aColID[0])
|
||||
|
@ -1279,31 +1279,35 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P
|
|||
return NS_MSG_INVALID_DBVIEW_INDEX;
|
||||
}
|
||||
|
||||
*aValue = 0;
|
||||
// just a hack
|
||||
nsXPIDLCString dbString;
|
||||
aValue.SetCapacity(0);
|
||||
// XXX fix me by making Fetch* take an nsAString& parameter
|
||||
nsXPIDLString valueText;
|
||||
nsCOMPtr <nsIMsgThread> thread;
|
||||
|
||||
switch (aColID[0])
|
||||
{
|
||||
case 's':
|
||||
if (aColID[1] == 'u') // subject
|
||||
rv = FetchSubject(msgHdr, m_flags[aRow], aValue);
|
||||
rv = FetchSubject(msgHdr, m_flags[aRow], getter_Copies(valueText));
|
||||
else if (aColID[1] == 'e') // sender
|
||||
rv = FetchAuthor(msgHdr, aValue);
|
||||
rv = FetchAuthor(msgHdr, getter_Copies(valueText));
|
||||
else if (aColID[1] == 'i') // size
|
||||
rv = FetchSize(msgHdr, aValue);
|
||||
rv = FetchSize(msgHdr, getter_Copies(valueText));
|
||||
else
|
||||
rv = FetchStatus(m_flags[aRow], aValue);
|
||||
rv = FetchStatus(m_flags[aRow], getter_Copies(valueText));
|
||||
aValue.Assign(valueText);
|
||||
break;
|
||||
case 'd': // date
|
||||
rv = FetchDate(msgHdr, aValue);
|
||||
rv = FetchDate(msgHdr, getter_Copies(valueText));
|
||||
aValue.Assign(valueText);
|
||||
break;
|
||||
case 'p': // priority
|
||||
rv = FetchPriority(msgHdr, aValue);
|
||||
rv = FetchPriority(msgHdr, getter_Copies(valueText));
|
||||
aValue.Assign(valueText);
|
||||
break;
|
||||
case 'l': // label
|
||||
rv = FetchLabel(msgHdr, aValue);
|
||||
rv = FetchLabel(msgHdr, getter_Copies(valueText));
|
||||
aValue.Assign(valueText);
|
||||
break;
|
||||
case 't':
|
||||
// total msgs in thread column
|
||||
|
@ -1318,7 +1322,7 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P
|
|||
PRUint32 numChildren;
|
||||
thread->GetNumChildren(&numChildren);
|
||||
formattedCountString.AppendInt(numChildren);
|
||||
*aValue = ToNewUnicode(formattedCountString);
|
||||
aValue.Assign(formattedCountString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1338,7 +1342,7 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P
|
|||
if (numUnreadChildren > 0)
|
||||
{
|
||||
formattedCountString.AppendInt(numUnreadChildren);
|
||||
*aValue = ToNewUnicode(formattedCountString);
|
||||
aValue.Assign(formattedCountString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,11 +98,15 @@ NS_IMETHODIMP nsMsgSearchDBView::Close()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgSearchDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, PRUnichar ** aValue)
|
||||
NS_IMETHODIMP nsMsgSearchDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, nsAString& aValue)
|
||||
{
|
||||
if (aColID[0] == 'l' && aColID[1] == 'o') // location, need to check for "lo" not just "l" to avoid "label" column
|
||||
{
|
||||
return FetchLocation(aRow, aValue);
|
||||
// XXX fix me by converting Fetch* to take an nsAString& parameter
|
||||
nsXPIDLString valueText;
|
||||
nsresult rv = FetchLocation(aRow, getter_Copies(valueText));
|
||||
aValue.Assign(valueText);
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return nsMsgDBView::GetCellText(aRow, aColID, aValue);
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
NS_IMETHOD DoCommandWithFolder(nsMsgViewCommandTypeValue command, nsIMsgFolder *destFolder);
|
||||
NS_IMETHOD GetHdrForFirstSelectedMessage(nsIMsgDBHdr **hdr);
|
||||
// override to get location
|
||||
NS_IMETHOD GetCellText(PRInt32 aRow, const PRUnichar * aColID, PRUnichar ** aValue);
|
||||
NS_IMETHOD GetCellText(PRInt32 aRow, const PRUnichar * aColID, nsAString& aValue);
|
||||
virtual nsresult GetMsgHdrForViewIndex(nsMsgViewIndex index, nsIMsgDBHdr **msgHdr);
|
||||
virtual nsresult OnNewHeader(nsMsgKey newKey, nsMsgKey parentKey, PRBool ensureListed);
|
||||
NS_IMETHOD GetFolderForViewIndex(nsMsgViewIndex index, nsIMsgFolder **folder);
|
||||
|
|
|
@ -1869,14 +1869,17 @@ nsNntpIncomingServer::GetLevel(PRInt32 index, PRInt32 *_retval)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnichar **_retval)
|
||||
nsNntpIncomingServer::GetCellText(PRInt32 row, const PRUnichar *colID, nsAString& _retval)
|
||||
{
|
||||
if (colID[0] == 'n') {
|
||||
nsCString str;
|
||||
mSubscribeSearchResult.CStringAt(row, str);
|
||||
// some servers have newsgroup names that are non ASCII. we store those as escaped
|
||||
// unescape here so the UI is consistent
|
||||
nsresult rv = NS_MsgDecodeUnescapeURLPath(str.get(), _retval);
|
||||
// XXX fix me by converting NS_MsgDecodeUnescapeURLPath to take an nsAString&
|
||||
nsXPIDLString cellText;
|
||||
nsresult rv = NS_MsgDecodeUnescapeURLPath(str.get(), getter_Copies(cellText));
|
||||
_retval.Assign(cellText);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -399,10 +399,10 @@ nsNSSASN1Outliner::GetLevel(PRInt32 index, PRInt32 *_retval)
|
|||
/* wstring getCellText (in long row, in wstring colID); */
|
||||
NS_IMETHODIMP
|
||||
nsNSSASN1Outliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
||||
PRUnichar **_retval)
|
||||
nsAString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIASN1Object> object;
|
||||
*_retval = nsnull;
|
||||
_retval.SetCapacity(0);
|
||||
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
|
||||
nsresult rv = NS_OK;
|
||||
if (strcmp(col, "certDataCol") == 0) {
|
||||
|
@ -412,7 +412,10 @@ nsNSSASN1Outliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
|||
return rv;
|
||||
|
||||
//There's only one column for ASN1 dump.
|
||||
rv = object->GetDisplayName(_retval);
|
||||
PRUnichar* displayName = nsnull;
|
||||
rv = object->GetDisplayName(&displayName); // copies
|
||||
_retval = displayName; // copies again!
|
||||
nsCRT::free(displayName);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -399,10 +399,10 @@ nsNSSASN1Outliner::GetLevel(PRInt32 index, PRInt32 *_retval)
|
|||
/* wstring getCellText (in long row, in wstring colID); */
|
||||
NS_IMETHODIMP
|
||||
nsNSSASN1Outliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
||||
PRUnichar **_retval)
|
||||
nsAString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIASN1Object> object;
|
||||
*_retval = nsnull;
|
||||
_retval.SetCapacity(0);
|
||||
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
|
||||
nsresult rv = NS_OK;
|
||||
if (strcmp(col, "certDataCol") == 0) {
|
||||
|
@ -412,7 +412,10 @@ nsNSSASN1Outliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
|||
return rv;
|
||||
|
||||
//There's only one column for ASN1 dump.
|
||||
rv = object->GetDisplayName(_retval);
|
||||
PRUnichar* displayName = nsnull;
|
||||
rv = object->GetDisplayName(&displayName); // copies
|
||||
_retval = displayName; // copies again!
|
||||
nsCRT::free(displayName);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -467,18 +467,16 @@ nsCertOutliner::GetLevel(PRInt32 index, PRInt32 *_retval)
|
|||
/* wstring getCellText (in long row, in wstring colID); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
||||
PRUnichar **_retval)
|
||||
nsAString& _retval)
|
||||
{
|
||||
nsresult rv;
|
||||
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(row);
|
||||
if (el != nsnull) {
|
||||
if (strcmp(col, "certcol") == 0) {
|
||||
nsAutoString oName(el->orgName);
|
||||
*_retval = ToNewUnicode(oName);
|
||||
} else {
|
||||
*_retval = nsnull;
|
||||
}
|
||||
if (strcmp(col, "certcol") == 0)
|
||||
_retval.Assign(el->orgName);
|
||||
else
|
||||
_retval.SetCapacity(0);
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIX509Cert> cert = GetCertAtIndex(row);
|
||||
|
@ -565,7 +563,7 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
|||
nsAutoString astr = NS_ConvertASCIItoUCS2(str);
|
||||
wstr = ToNewUnicode(astr);
|
||||
}
|
||||
*_retval = wstr;
|
||||
_retval = wstr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -467,18 +467,16 @@ nsCertOutliner::GetLevel(PRInt32 index, PRInt32 *_retval)
|
|||
/* wstring getCellText (in long row, in wstring colID); */
|
||||
NS_IMETHODIMP
|
||||
nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
||||
PRUnichar **_retval)
|
||||
nsAString& _retval)
|
||||
{
|
||||
nsresult rv;
|
||||
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
|
||||
outlinerArrayEl *el = GetThreadDescAtIndex(row);
|
||||
if (el != nsnull) {
|
||||
if (strcmp(col, "certcol") == 0) {
|
||||
nsAutoString oName(el->orgName);
|
||||
*_retval = ToNewUnicode(oName);
|
||||
} else {
|
||||
*_retval = nsnull;
|
||||
}
|
||||
if (strcmp(col, "certcol") == 0)
|
||||
_retval.Assign(el->orgName);
|
||||
else
|
||||
_retval.SetCapacity(0);
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIX509Cert> cert = GetCertAtIndex(row);
|
||||
|
@ -565,7 +563,7 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID,
|
|||
nsAutoString astr = NS_ConvertASCIItoUCS2(str);
|
||||
wstr = ToNewUnicode(astr);
|
||||
}
|
||||
*_retval = wstr;
|
||||
_retval = wstr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -497,7 +497,7 @@ nsFileView::GetLevel(PRInt32 aIndex, PRInt32* aLevel)
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsFileView::GetCellText(PRInt32 aRow, const PRUnichar* aColID,
|
||||
PRUnichar** aCellText)
|
||||
nsAString& aCellText)
|
||||
{
|
||||
PRUint32 dirCount, fileCount;
|
||||
mDirList->Count(&dirCount);
|
||||
|
@ -514,27 +514,31 @@ nsFileView::GetCellText(PRInt32 aRow, const PRUnichar* aColID,
|
|||
curFile = do_QueryElementAt(mFilteredFiles, aRow - dirCount);
|
||||
} else {
|
||||
// invalid row
|
||||
*aCellText = ToNewUnicode(NS_LITERAL_STRING(""));
|
||||
aCellText.SetCapacity(0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_LITERAL_STRING("FilenameColumn").Equals(aColID)) {
|
||||
curFile->GetUnicodeLeafName(aCellText);
|
||||
// XXX fix this by making GetUnicodeLeafName take an nsAString&
|
||||
nsXPIDLString temp;
|
||||
curFile->GetUnicodeLeafName(getter_Copies(temp));
|
||||
aCellText = temp;
|
||||
} else if (NS_LITERAL_STRING("LastModifiedColumn").Equals(aColID)) {
|
||||
PRInt64 lastModTime;
|
||||
curFile->GetLastModifiedTime(&lastModTime);
|
||||
nsAutoString dateString;
|
||||
// XXX FormatPRTime could take an nsAString&
|
||||
nsAutoString temp;
|
||||
mDateFormatter->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatSeconds,
|
||||
lastModTime * 1000, dateString);
|
||||
*aCellText = ToNewUnicode(dateString);
|
||||
lastModTime * 1000, temp);
|
||||
aCellText = temp;
|
||||
} else {
|
||||
// file size
|
||||
if (isDirectory)
|
||||
*aCellText = ToNewUnicode(NS_LITERAL_STRING(""));
|
||||
aCellText.SetCapacity(0);
|
||||
else {
|
||||
PRInt64 fileSize;
|
||||
curFile->GetFileSize(&fileSize);
|
||||
*aCellText = ToNewUnicode(nsPrintfCString("%lld", fileSize));
|
||||
aCellText = NS_ConvertUTF8toUCS2(nsPrintfCString("%lld", fileSize));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче