Author: fmantek
Date: Wed Oct 24 03:58:03 2007
New Revision: 316

Modified:
   trunk/clients/cs/src/core/collections.cs
   trunk/clients/cs/src/gspreadsheet/cellfeed.cs
   trunk/clients/cs/src/unittests/spreadsheetlive.cs

Log:
Changed Publish on the cellfeed to move the new edit uris into the 
original feed, so that you can do it more than once :)

Modified: trunk/clients/cs/src/core/collections.cs
==============================================================================
--- trunk/clients/cs/src/core/collections.cs    (original)
+++ trunk/clients/cs/src/core/collections.cs    Wed Oct 24 03:58:03 2007
@@ -115,6 +115,23 @@
             this.feed = feed;
         }

+        /// <summary>Fins an atomEntry in the collection
+        /// based on it's ID. </summary>
+        /// <param name="value">The atomId to look for</param>
+        /// <returns>Null if not found, otherwise the entry</returns>
+        public AtomEntry FindById( AtomId value )
+        {
+            foreach (AtomEntry entry in List)
+            {
+                if (entry.Id.AbsoluteUri == value.AbsoluteUri)
+                {
+                    return entry;
+                }
+            }
+            return null;
+        }
+
+
         /// <summary>standard typed accessor method </summary>
         public AtomEntry this[ int index ]
         {

Modified: trunk/clients/cs/src/gspreadsheet/cellfeed.cs
==============================================================================
--- trunk/clients/cs/src/gspreadsheet/cellfeed.cs       (original)
+++ trunk/clients/cs/src/gspreadsheet/cellfeed.cs       Wed Oct 24 03:58:03 2007
@@ -178,6 +178,22 @@
                         throw new GDataBatchRequestException(resultFeed);
                     }
                 }
+
+                // if we get here, everything is fine. So update the 
edit URIs in the original feed,
+                // because those might have changed.
+                foreach (AtomEntry resultEntry in resultFeed.Entries )
+                {
+                    AtomEntry originalEntry = 
this.Entries.FindById(resultEntry.Id);
+                    if (originalEntry == null)
+                    {
+                        throw new GDataBatchRequestException(resultFeed);
+                    }
+                    if (originalEntry != null)
+                    {
+                        originalEntry.EditUri = resultEntry.EditUri;
+                    }
+                }
+
             }
             this.Dirty = false;
         }

Modified: trunk/clients/cs/src/unittests/spreadsheetlive.cs
==============================================================================
--- trunk/clients/cs/src/unittests/spreadsheetlive.cs   (original)
+++ trunk/clients/cs/src/unittests/spreadsheetlive.cs   Wed Oct 24 
03:58:03 2007
@@ -94,20 +94,44 @@

             WorksheetFeed sheets = entry.Worksheets;

+
+            // kill all but the default before we start
+            foreach (WorksheetEntry w in sheets.Entries )
+            {
+                if (w.Title.Text  != "DefaultSheet")
+                {
+                    w.Delete();
+                }
+            }
             WorksheetEntry defEntry = sheets.Entries[0] as WorksheetEntry;
+
              Assert.IsTrue(defEntry!= null, "There should be one 
default entry in this account/sheet");
+            Assert.IsTrue(defEntry.Title.Text == "DefaultSheet", "it 
should be the default sheet");
             CellFeed defCells = defEntry.QueryCellFeed();
              Assert.IsTrue(defCells != null, "There should be a cell 
feed for the worksheet");

+
+            CellEntry header=null;
+
             foreach (CellEntry cell in defCells.Entries )
             {
                 if (cell.Title.Text == "A1")
                 {
-                    cell.Cell.InputValue = "";
+                    cell.Cell.InputValue = string.Empty;
                     cell.Update();
+                    header = cell;
                 }
             }

+
+
+            if (header != null)
+            {
+                header.InputValue = "HeaderA";
+                header.Update();
+            }
+
+
              WorksheetEntry newEntry = sheets.Insert(new 
WorksheetEntry(10, 20, "New Worksheet"));

              Assert.IsTrue(newEntry.ColCount.Count == 20, "Column count 
should be equal 20");
@@ -122,8 +146,20 @@
             {
                 for (uint col=1; col <= 20; col++)
                 {
-                    // each of those GET's will got back to the server
                     cells[row,col].InputValue = "R"+row+"C"+col;
+                }
+            }
+            cells.Publish();
+
+            // try to update just one cell
+            cells[1,1].InputValue = string.Empty;
+            cells[1,1].Update();
+
+            for (uint row = 1; row <= 10; row++)
+            {
+                for (uint col=1; col <= 20; col++)
+                {
+                    cells[row,col].InputValue = string.Empty;
                 }
             }
             cells.Publish();

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to