Diff for /chimera/BookmarksService.mm between versions 1.6 and 1.7

version 1.6, 2002/02/09 20:31:06 version 1.7, 2002/02/09 23:17:02
Line 69 Line 69
     nsCOMPtr<nsIContent> content;      nsCOMPtr<nsIContent> content;
     int index = [mOutlineView selectedRow];      int index = [mOutlineView selectedRow];
         
    if (index > 0) {    if (index >= 0) {
         BookmarkItem* item = [mOutlineView itemAtRow: index];          BookmarkItem* item = [mOutlineView itemAtRow: index];
         if ([mOutlineView isExpandable: item])           if ([mOutlineView isExpandable: item]) 
             content = [item contentNode];              content = [item contentNode];
Line 263 Line 263
 {  {
     mContentNode = aContentNode;      mContentNode = aContentNode;
 }  }
   
   - (id)copyWithZone:(NSZone *)aZone
   {
       BookmarkItem* copy = [[[self class] allocWithZone: aZone] init];
       [copy setContentNode: mContentNode];
       return copy;
   }
   
 @end  @end
   
 // Helper for stripping whitespace  // Helper for stripping whitespace
Line 293  StripWhitespaceNodes(nsIContent* aElemen Line 301  StripWhitespaceNodes(nsIContent* aElemen
 PRUint32 BookmarksService::gRefCnt = 0;  PRUint32 BookmarksService::gRefCnt = 0;
 nsIDocument* BookmarksService::gBookmarks = nsnull;  nsIDocument* BookmarksService::gBookmarks = nsnull;
 NSMutableDictionary* BookmarksService::gDictionary = nil;  NSMutableDictionary* BookmarksService::gDictionary = nil;
   NSMutableDictionary* BookmarksService::gBookmarkToMenuMap = nil;
   NSMutableDictionary* BookmarksService::gMenuToBookmarkMap = nil;
 nsIAtom* BookmarksService::gFolderAtom = nsnull;  nsIAtom* BookmarksService::gFolderAtom = nsnull;
 nsIAtom* BookmarksService::gBookmarkAtom = nsnull;  nsIAtom* BookmarksService::gBookmarkAtom = nsnull;
 nsIAtom* BookmarksService::gHrefAtom = nsnull;  nsIAtom* BookmarksService::gHrefAtom = nsnull;
Line 422  BookmarksService::RemoveObserver() Line 432  BookmarksService::RemoveObserver()
         NS_RELEASE(gNameAtom);          NS_RELEASE(gNameAtom);
         NS_RELEASE(gHrefAtom);          NS_RELEASE(gHrefAtom);
         [gDictionary release];          [gDictionary release];
           [gBookmarkToMenuMap release];
           [gMenuToBookmarkMap release];
     }      }
 }  }
   
Line 440  BookmarksService::FlushBookmarks() Line 452  BookmarksService::FlushBookmarks()
     nsCOMPtr<nsIDOMSerializer> domSerializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));      nsCOMPtr<nsIDOMSerializer> domSerializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));
     domSerializer->SerializeToStream(domDoc, outputStream, nsnull);      domSerializer->SerializeToStream(domDoc, outputStream, nsnull);
 }  }
   
   void
   BookmarksService::ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent)
   {
       // Create our menu maps.
       if (!gMenuToBookmarkMap)
           gMenuToBookmarkMap = [[NSMutableDictionary alloc] initWithCapacity: 30];
       if (!gBookmarkToMenuMap)
           gBookmarkToMenuMap = [[NSMutableDictionary alloc] initWithCapacity: 30];
       
       nsCOMPtr<nsIContent> content = aContent;
       if (!content) {
           GetRootContent(getter_AddRefs(content));
           // Add the root entry to our maps.
           BookmarkItem* item = GetWrapperFor(content);
           [gMenuToBookmarkMap setObject: item forKey: aMenu];
           [gBookmarkToMenuMap setObject: aMenu forKey: item];
       }
       
       // Now walk our children, and for folders also recur into them.
       PRInt32 childCount;
       content->ChildCount(childCount);
       
       for (PRInt32 i = 0; i < childCount; i++) {
           nsCOMPtr<nsIContent> child;
           content->ChildAt(i, *getter_AddRefs(child));
           
           // Obtain our name attribute.
           nsAutoString name;
           child->GetAttr(kNameSpaceID_None, gNameAtom, name);
           nsCAutoString nameCStr; nameCStr.AssignWithConversion(name);
           NSString* title = [NSString stringWithCString: nameCStr.get()];
                   
           // Create a menu or menu item for the child.
           nsCOMPtr<nsIAtom> tag;
           content->GetTag(*getter_AddRefs(tag));
           if (tag == gFolderAtom) {
               // We are building a menu.
               NSMenu* menu = [[[NSMenu alloc] initWithTitle: title] autorelease];
               BookmarkItem* item = GetWrapperFor(child);
               [gMenuToBookmarkMap setObject: item forKey: menu];
               [gBookmarkToMenuMap setObject: menu forKey: item];
               
               [aMenu addItem: menu];
                           
               ConstructBookmarksMenu(menu, child);
           }
           else {
               // We are building a menu item.
               NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
               BookmarkItem* item = GetWrapperFor(child);
               [gMenuToBookmarkMap setObject: item forKey: menuItem];
               [gBookmarkToMenuMap setObject: menuItem forKey: item];
               
               [aMenu addItem: menuItem];
           }
       }
   }

Removed from v.1.6  
changed lines
  Added in v.1.7


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