Fix bug # 31624 (add Mac IE favorites foreign charset alias resolution support) and bug # 29135 (default to adding new bookmark items under the root node if there is no selection). Review: me

This commit is contained in:
rjc%netscape.com 2000-03-15 01:24:47 +00:00
Родитель 229a971907
Коммит 1b9efe018d
2 изменённых файлов: 46 добавлений и 16 удалений

Просмотреть файл

@ -612,12 +612,6 @@ function doContextCmd(cmdName)
cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource);
if (!cmdResource) return(false);
var select_list = treeNode.selectedItems;
if (!select_list) return(false);
if (select_list.length < 1) return(false);
debug("# of Nodes selected: " + select_list.length);
// set up selection nsISupportsArray
var selectionInstance = Components.classes["component://netscape/supports-array"].createInstance();
var selectionArray = selectionInstance.QueryInterface(Components.interfaces.nsISupportsArray);
@ -630,7 +624,22 @@ function doContextCmd(cmdName)
var parentArc = rdf.GetResource("http://home.netscape.com/NC-rdf#parent");
if (!parentArc) return(false);
for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
var select_list = treeNode.selectedItems;
debug("# of Nodes selected: " + select_list.length);
if (select_list.length < 1)
{
// if nothing is selected, default to using the "ref" on the root of the tree
var uri = treeNode.getAttribute("ref");
if (!uri || uri=="") return(false);
var rdfNode = rdf.GetResource(uri);
// add node into selection array
if (rdfNode)
{
selectionArray.AppendElement(rdfNode);
}
}
else for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)
{
var node = select_list[nodeIndex];
if (!node) break;

Просмотреть файл

@ -861,6 +861,19 @@ BookmarkParser::ParseMetaTag(const nsString &aLine, nsIUnicodeDecoder **decoder)
content.Mid(charset, start, content.Length() - start);
if (charset.Length() < 1) return(NS_ERROR_UNEXPECTED);
NS_WITH_SERVICE(nsICharsetAlias, calias, kCharsetAliasCID, &rv);
if (NS_SUCCEEDED(rv) && (calias))
{
nsAutoString charsetName;
if (NS_SUCCEEDED(rv = calias->GetPreferred(charset, charsetName)))
{
if (charsetName.Length() > 0)
{
charset = charsetName;
}
}
}
// found a charset, now try and get a decoder from it to Unicode
nsICharsetConverterManager *charsetConv = nsnull;
rv = nsServiceManager::GetService(kCharsetConverterManagerCID,
@ -3273,12 +3286,19 @@ nsresult
nsBookmarksService::insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex, nsIRDFResource *objType)
{
nsresult rv;
PRInt32 srcIndex = 0;
nsCOMPtr<nsIRDFResource> argParent;
if (NS_FAILED(rv = getArgumentN(aArguments, kNC_Parent,
parentArgIndex, getter_AddRefs(argParent))))
return(rv);
if (src == kNC_BookmarksRoot)
{
argParent = src;
}
else
{
if (NS_FAILED(rv = getArgumentN(aArguments, kNC_Parent,
parentArgIndex, getter_AddRefs(argParent))))
return(rv);
}
nsCOMPtr<nsIRDFContainer> container;
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContainerCID, nsnull,
NS_GET_IID(nsIRDFContainer), getter_AddRefs(container))))
@ -3286,9 +3306,11 @@ nsBookmarksService::insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aA
if (NS_FAILED(rv = container->Init(mInner, argParent)))
return(rv);
PRInt32 srcIndex;
if (NS_FAILED(rv = container->IndexOf(src, &srcIndex)))
return(rv);
if (src != kNC_BookmarksRoot)
{
if (NS_FAILED(rv = container->IndexOf(src, &srcIndex)))
return(rv);
}
nsCOMPtr<nsIRDFResource> newElement;
if (NS_FAILED(rv = BookmarkParser::CreateAnonymousResource(&newElement)))
@ -3324,9 +3346,8 @@ nsBookmarksService::insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aA
if (NS_FAILED(rv = mInner->Assert(newElement, kNC_BookmarkAddDate, dateLiteral, PR_TRUE)))
return(rv);
if (NS_FAILED(rv = container->InsertElementAt(newElement, srcIndex + 1, PR_TRUE)))
if (NS_FAILED(rv = container->InsertElementAt(newElement, ((srcIndex == 0) ? 1 : srcIndex), PR_TRUE)))
return(rv);
return(rv);
}