Diff for /chimera/BookmarksService.mm between versions 1.23 and 1.24

version 1.23, 2002/04/17 22:57:07 version 1.24, 2002/04/17 23:55:25
Line 93 Line 93
   
 -(IBAction)addBookmark:(id)aSender  -(IBAction)addBookmark:(id)aSender
 {  {
  [self addBookmark: aSender useSelection: YES];  [self addBookmark: aSender useSelection: YES isFolder: NO];
 }  }
   
-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel-(IBAction)addFolder:(id)aSender
 {
   [self addBookmark: aSender useSelection: YES isFolder: YES];
 }
 
 -(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel isFolder:(BOOL)aIsFolder
 {  {
   if (!mBookmarks)    if (!mBookmarks)
     return;      return;
Line 115 Line 120
   if (!content)    if (!content)
     mBookmarks->GetRootContent(getter_AddRefs(content));      mBookmarks->GetRootContent(getter_AddRefs(content));
   
     mCachedParent = content;
     
   nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));    nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
       
   // Fetch the title of the current page and the URL.    // Fetch the title of the current page and the URL.
   nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[[mBrowserWindowController getMyBrowserView] getBrowserView] getWebBrowser]);  
   nsCOMPtr<nsIDOMWindow> window;  
   webBrowser->GetContentDOMWindow(getter_AddRefs(window));  
   nsCOMPtr<nsIDOMDocument> htmlDoc;  
   window->GetDocument(getter_AddRefs(htmlDoc));  
   nsCOMPtr<nsIDocument> pageDoc(do_QueryInterface(htmlDoc));  
   
   nsAutoString href;  
   if (pageDoc) {  
     nsCOMPtr<nsIURI> url;  
     pageDoc->GetDocumentURL(getter_AddRefs(url));  
     nsCAutoString spec;  
     url->GetSpec(spec);  
     href.AssignWithConversion(spec.get());  
   }  
   
   mCachedHref = [NSString stringWithCharacters: href.get() length: nsCRT::strlen(href.get())];  
   [mCachedHref retain];  
     
   mCachedParent = content;  
     
   nsAutoString title;    nsAutoString title;
  nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(htmlDoc));  if (!aIsFolder) {
  if (htmlDocument)    nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[[mBrowserWindowController getMyBrowserView]
    htmlDocument->GetTitle(title);      getBrowserView] getWebBrowser]);
  if (title.IsEmpty())    nsCOMPtr<nsIDOMWindow> window;
    title = href;    webBrowser->GetContentDOMWindow(getter_AddRefs(window));
     nsCOMPtr<nsIDOMDocument> htmlDoc;
     window->GetDocument(getter_AddRefs(htmlDoc));
     nsCOMPtr<nsIDocument> pageDoc(do_QueryInterface(htmlDoc));
 
     nsAutoString href;
     if (pageDoc) {
       nsCOMPtr<nsIURI> url;
       pageDoc->GetDocumentURL(getter_AddRefs(url));
       nsCAutoString spec;
       url->GetSpec(spec);
       href.AssignWithConversion(spec.get());
     }
 
     mCachedHref = [NSString stringWithCharacters: href.get() length: nsCRT::strlen(href.get())];
     [mCachedHref retain];
   
     nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(htmlDoc));
     if (htmlDocument)
       htmlDocument->GetTitle(title);
     if (title.IsEmpty())
       title = href;
   }
   else {
     mCachedHref = nil;
     title = NS_LITERAL_STRING("New Folder");
   }
       
   NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];    NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
   [textField setStringValue: [NSString stringWithCharacters: title.get() length: nsCRT::strlen(title.get())]];    [textField setStringValue: [NSString stringWithCharacters: title.get() length: nsCRT::strlen(title.get())]];
Line 166 Line 178
   const char* titleC = [[[mBrowserWindowController getAddBookmarkTitle] stringValue] cString];    const char* titleC = [[[mBrowserWindowController getAddBookmarkTitle] stringValue] cString];
   nsAutoString title; title.AssignWithConversion(titleC);    nsAutoString title; title.AssignWithConversion(titleC);
   
     nsAutoString tagName;
     if (mCachedHref)
       tagName = NS_LITERAL_STRING("bookmark");
     else
       tagName = NS_LITERAL_STRING("folder");
     
   nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));    nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
   nsCOMPtr<nsIDOMElement> elt;    nsCOMPtr<nsIDOMElement> elt;
  domDoc->CreateElementNS(NS_LITERAL_STRING("http://chimera.mozdev.org/bookmarks"),  domDoc->CreateElementNS(NS_LITERAL_STRING("http://chimera.mozdev.org/bookmarks/"),
                          NS_LITERAL_STRING("bookmark"),                          tagName,
                           getter_AddRefs(elt));                            getter_AddRefs(elt));
   
   elt->SetAttribute(NS_LITERAL_STRING("name"), title);    elt->SetAttribute(NS_LITERAL_STRING("name"), title);
   nsAutoString href; href.AssignWithConversion([mCachedHref cString]);  
   [mCachedHref release];  
     
   elt->SetAttribute(NS_LITERAL_STRING("href"), href);  
   
     if (mCachedHref) {
       nsAutoString href; href.AssignWithConversion([mCachedHref cString]);
       [mCachedHref release];
       elt->SetAttribute(NS_LITERAL_STRING("href"), href);
     }
     
   nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(mCachedParent));    nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(mCachedParent));
   nsCOMPtr<nsIDOMNode> dummy;    nsCOMPtr<nsIDOMNode> dummy;
   parent->AppendChild(elt, getter_AddRefs(dummy));    parent->AppendChild(elt, getter_AddRefs(dummy));

Removed from v.1.23  
changed lines
  Added in v.1.24


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>