Author: fmantek
Date: Wed Oct 24 03:02:54 2007
New Revision: 315
Modified:
trunk/clients/cs/RELEASE_NOTES.HTML
trunk/clients/cs/src/core/atomfeed.cs
trunk/clients/cs/src/core/atomfeedentry.cs
trunk/clients/cs/src/core/exceptions.cs
trunk/clients/cs/src/core/service.cs
trunk/clients/cs/src/core/serviceinterface.cs
trunk/clients/cs/src/gdocuments/documententry.cs
trunk/clients/cs/src/gdocuments/documentquery.cs
trunk/clients/cs/src/gspreadsheet/cellentry.cs
trunk/clients/cs/src/gspreadsheet/cellfeed.cs
trunk/clients/cs/src/gspreadsheet/worksheetentry.cs
trunk/clients/cs/src/gspreadsheet/worksheetfeed.cs
trunk/clients/cs/src/unittests/spreadsheetlive.cs
Log:
Added a bundle of new spreadsheet goodies.
Modified: trunk/clients/cs/RELEASE_NOTES.HTML
==============================================================================
--- trunk/clients/cs/RELEASE_NOTES.HTML (original)
+++ trunk/clients/cs/RELEASE_NOTES.HTML Wed Oct 24 03:02:54 2007
@@ -12,9 +12,34 @@
<li>The SpreadsheetEntry has a new property, WorksheetsLink. This
property returns a string that can be used to retrieve the
Worksheets feed uri for a given Spreadsheet.</li>
+ <li>Added CreateBatchFeed to the Atomfeed object. This will create
+ a default batch feed for you, if the feed supports
batching. The
+ created batch feed will contain all currently dirty entries.</li>
+ <li>Added a GDataBatchRequestException for that operation.</li>
+ <li>Added Delete(Uri uir) to the service interface.</li>
+ <li>Added more constructors to the CellEntry object, and moved
+ accessors for the CellEntry.Cell up to the CellEntry
object. So
+ instead of writing CellEntry.Cell.Column, you can call
+ CellEntry.Column directly (and others).</li>
+ <li>Added an index accessor to the CellFeed, you can now access
+ Cells on the CellFeed like this: CellEntry entry = CellFeed[1,1].
+ This will retrieve not existing cells if needed.</li>
+ <li>Added QueryCellFeed() and QueryCellFeedLink(ReturnEmptyCells
+ parameter) to the WorksheetEntry. The method with no
parameters will
+ get you the serverdefault cell feed.</li>
+ <li>Added the CellFeedLink property on the WorksheetEntry. This
+ returns the URI to the CellFeed as string.</li>
+ <li>Added an overloaded Insert method to the WorksheetFeed so that
+ you do not need to cast the return anymore.</li>
+
</ul>
<li>Bugfixes/changes</li>
+ <ul>
+ <li>When an entry was copied from one feed to another, the internal
+ service object was set correctly.</li>
+ <li>Added unittests for the new spreadsheet code.</li>
+ </ul>
</ul>
Modified: trunk/clients/cs/src/core/atomfeed.cs
==============================================================================
--- trunk/clients/cs/src/core/atomfeed.cs (original)
+++ trunk/clients/cs/src/core/atomfeed.cs Wed Oct 24 03:02:54 2007
@@ -295,6 +295,41 @@
}
/////////////////////////////////////////////////////////////////////////////
+ /// <summary>
+ /// returns a new batchfeed with all the currently dirty
entries in it
+ /// </summary>
+ /// <param name="defaultOperation">the default operation to
execute</param>
+ /// <returns>AtomFeed</returns>
+ public AtomFeed CreateBatchFeed(GDataBatchOperationType
defaultOperation)
+ {
+ AtomFeed batchFeed = null;
+
+ if (this.Batch != null)
+ {
+
+ batchFeed = new AtomFeed(this);
+ // set the default operation.
+ batchFeed.BatchData = new GDataBatchFeedData();
+ batchFeed.BatchData.Type = defaultOperation;
+
+ int id = 1;
+ foreach (AtomEntry entry in this.Entries)
+ {
+ if (entry.Dirty == true)
+ {
+ int i = batchFeed.Entries.Add(entry);
+ AtomEntry batchEntry = batchFeed.Entries[i];
+ batchEntry.BatchData = new GDataBatchEntryData();
+ batchEntry.BatchData.Id = id.ToString();
+ id++;
+ entry.Dirty = false;
+ }
+ }
+
+ }
+ return batchFeed;
+ }
+
//////////////////////////////////////////////////////////////////////
/// <summary>returns whether or not the entry is read-only </summary>
//////////////////////////////////////////////////////////////////////
@@ -753,7 +788,7 @@
/// <summary>goes over all entries, and updates the ones that
are dirty</summary>
/// <returns> </returns>
//////////////////////////////////////////////////////////////////////
- public void Publish()
+ public virtual void Publish()
{
if (this.Service != null)
{
Modified: trunk/clients/cs/src/core/atomfeedentry.cs
==============================================================================
--- trunk/clients/cs/src/core/atomfeedentry.cs (original)
+++ trunk/clients/cs/src/core/atomfeedentry.cs Wed Oct 24 03:02:54 2007
@@ -260,6 +260,7 @@
if (feed != null)
{
this.Dirty = true;
+ this.Service = feed.Service;
}
this.feed = feed;
}
@@ -630,7 +631,7 @@
//////////////////////////////////////////////////////////////////////
- /// <summary>accessor method public AtomCategoryCollection
Categories, holds an array of AtomCategory objects</summary>
+ /// <summary>holds an array of AtomCategory objects</summary>
/// <returns> </returns>
//////////////////////////////////////////////////////////////////////
public AtomCategoryCollection Categories
Modified: trunk/clients/cs/src/core/exceptions.cs
==============================================================================
--- trunk/clients/cs/src/core/exceptions.cs (original)
+++ trunk/clients/cs/src/core/exceptions.cs Wed Oct 24 03:02:54 2007
@@ -193,6 +193,63 @@
}
/////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>standard exception class to be used inside the feed object
+ /// </summary>
+ //////////////////////////////////////////////////////////////////////
+#if WindowsCE || PocketPC
+#else
+ [Serializable]
+#endif
+ public class GDataBatchRequestException : LoggedException
+ {
+
+ private AtomFeed batchResult;
+
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>standard overloaded constructor</summary>
+ //////////////////////////////////////////////////////////////////////
+ public GDataBatchRequestException()
+ {
+ }
+
/////////////////////////////////////////////////////////////////////////////
+
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>default constructor so that FxCop does not
complain</summary>
+ //////////////////////////////////////////////////////////////////////
+ public GDataBatchRequestException(AtomFeed batchResult)
+ {
+ this.batchResult = batchResult;
+ }
+
/////////////////////////////////////////////////////////////////////////////
+
+ public AtomFeed BatchResult
+ {
+ get { return this.batchResult; }
+ }
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>standard overloaded constructor</summary>
+ /// <param name="msg">msg for the exception</param>
+ //////////////////////////////////////////////////////////////////////
+ public GDataBatchRequestException(string msg) : base(msg)
+ {
+ }
+
/////////////////////////////////////////////////////////////////////////////
+
+ /// <summary>here to please FxCop and for future use</summary>
+ public GDataBatchRequestException(string msg, Exception
innerException) : base(msg, innerException)
+ {
+ }
+
/////////////////////////////////////////////////////////////////////////////
+#if WindowsCE || PocketPC
+#else
+ /// <summary>here to please FxCop and maybe for future use</summary>
+ protected GDataBatchRequestException(SerializationInfo info,
StreamingContext context) : base(info, context)
+ {
+ }
+#endif
+ }
+
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// <summary>standard exception class to be used inside GDataRequest
Modified: trunk/clients/cs/src/core/service.cs
==============================================================================
--- trunk/clients/cs/src/core/service.cs (original)
+++ trunk/clients/cs/src/core/service.cs Wed Oct 24 03:02:54 2007
@@ -763,13 +763,9 @@
Tracing.Assert(entry.EditUri != null, "Entry should have a
valid edit URI");
if (entry.EditUri != null)
+
{
- Tracing.TraceMsg("Deleting entry: " +
entry.EditUri.ToString());
- IGDataRequest request =
this.RequestFactory.CreateRequest(GDataRequestType.Delete,new
Uri(entry.EditUri.ToString()));
- request.Credentials = this.Credentials;
- request.Execute();
- IDisposable disp = request as IDisposable;
- disp.Dispose();
+ Delete(new Uri(entry.EditUri.ToString()));
}
else
{
Modified: trunk/clients/cs/src/core/serviceinterface.cs
==============================================================================
--- trunk/clients/cs/src/core/serviceinterface.cs (original)
+++ trunk/clients/cs/src/core/serviceinterface.cs Wed Oct 24 03:02:54 2007
@@ -60,6 +60,8 @@
AtomEntry Insert(AtomFeed feed, AtomEntry entry);
/// <summary>delete an entry</summary>
void Delete(AtomEntry entry);
+ /// <summary>delete an entry</summary>
+ void Delete(Uri uriTarget);
/// <summary>batch operation, posting of a set of entries</summary>
AtomFeed Batch(AtomFeed feed, Uri batchUri);
/// <summary>simple update for media resources</summary>
Modified: trunk/clients/cs/src/gdocuments/documententry.cs
==============================================================================
--- trunk/clients/cs/src/gdocuments/documententry.cs (original)
+++ trunk/clients/cs/src/gdocuments/documententry.cs Wed Oct 24
03:02:54 2007
@@ -37,6 +37,16 @@
{
static string PRESENTATION_KIND =
"http://schemas.google.com/docs/2007#presentation";
+ static string DOCUMENT_KIND =
"http://schemas.google.com/docs/2007#document";
+ static string SPREADSHEET_KIND =
"http://schemas.google.com/docs/2007#spreadsheet";
+
+ public static AtomCategory DOCUMENT_CATEGORY =
+ new AtomCategory(DOCUMENT_KIND, new AtomUri(BaseNameTable.gKind));
+ public static AtomCategory SPREADSHEET_CATEGORY =
+ new AtomCategory(SPREADSHEET_KIND, new
AtomUri(BaseNameTable.gKind));
+ public static AtomCategory PRESENTATION_CATEGORY =
+ new AtomCategory(PRESENTATION_KIND, new
AtomUri(BaseNameTable.gKind));
+
/// <summary>
/// Constructs a new EventEntry instance with the appropriate category
@@ -46,7 +56,69 @@
: base()
{
Tracing.TraceMsg("Created DocumentEntry");
- // todo: add extensions as appropriate
+ }
+
+ /// <summary>
+ /// returns TRUE if this entry is a Document entry
+ /// </summary>
+ public bool IsDocument
+ {
+ get
+ {
+ return
this.Categories.Contains(DocumentEntry.DOCUMENT_CATEGORY);
+ }
+ set
+ {
+ if (value == true)
+ {
+ if (this.IsDocument == false)
+ {
+ this.Categories.Add(DocumentEntry.DOCUMENT_CATEGORY);
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// returns TRUE if this entry is a Document entry
+ /// </summary>
+ public bool IsSpreadsheet
+ {
+ get
+ {
+ return
this.Categories.Contains(DocumentEntry.SPREADSHEET_CATEGORY);
+ }
+ set
+ {
+ if (value == true)
+ {
+ if (this.IsSpreadsheet == false)
+ {
+
this.Categories.Add(DocumentEntry.SPREADSHEET_CATEGORY);
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// returns TRUE if this entry is a Document entry
+ /// </summary>
+ public bool IsPresentation
+ {
+ get
+ {
+ return
this.Categories.Contains(DocumentEntry.PRESENTATION_CATEGORY);
+ }
+ set
+ {
+ if (value == true)
+ {
+ if (this.IsPresentation == false)
+ {
+
this.Categories.Add(DocumentEntry.PRESENTATION_CATEGORY);
+ }
+ }
+ }
}
}
}
Modified: trunk/clients/cs/src/gdocuments/documentquery.cs
==============================================================================
--- trunk/clients/cs/src/gdocuments/documentquery.cs (original)
+++ trunk/clients/cs/src/gdocuments/documentquery.cs Wed Oct 24
03:02:54 2007
@@ -66,13 +66,13 @@
/// </summary>
public static string documentsBaseUri =
"http://docs.google.com/feeds/documents/private/full";
- public static AtomCategory ATOMCATEGORY_DOCUMENTS = new
AtomCategory("document");
+ private static AtomCategory ATOMCATEGORY_DOCUMENTS = new
AtomCategory("document");
public static QueryCategory DOCUMENTS = new
QueryCategory(ATOMCATEGORY_DOCUMENTS);
- public static AtomCategory ATOMCATEGORY_SPREADSHEETS = new
AtomCategory("spreadsheet");
+ private static AtomCategory ATOMCATEGORY_SPREADSHEETS = new
AtomCategory("spreadsheet");
public static QueryCategory SPREADSHEETS = new
QueryCategory(ATOMCATEGORY_SPREADSHEETS);
- public static AtomCategory ATOMCATEGORY_PRESENTATIONS = new
AtomCategory("presentations");
+ private static AtomCategory ATOMCATEGORY_PRESENTATIONS = new
AtomCategory("presentation");
public static QueryCategory PRESENTATIONS = new
QueryCategory(ATOMCATEGORY_PRESENTATIONS);
/// <summary>
Modified: trunk/clients/cs/src/gspreadsheet/cellentry.cs
==============================================================================
--- trunk/clients/cs/src/gspreadsheet/cellentry.cs (original)
+++ trunk/clients/cs/src/gspreadsheet/cellentry.cs Wed Oct 24 03:02:54 2007
@@ -54,6 +54,8 @@
this.Attributes.Add(GDataSpreadsheetsNameTable.XmlAttributeNumericValue, null);
}
+
+
/// <summary>
/// The row the cell lies in
/// </summary>
@@ -144,6 +146,31 @@
}
/// <summary>
+ /// create a CellEntry for a given row/column
+ /// </summary>
+ /// <param name="row"></param>
+ /// <param name="column"></param>
+ public CellEntry(uint row, uint column) : this()
+ {
+ this.Cell = new CellElement();
+ this.Cell.Column = column;
+ this.Cell.Row = row;
+ }
+
+ /// <summary>
+ /// create a CellEntry for a given row/column and
+ /// initial value
+ /// </summary>
+ /// <param name="row"></param>
+ /// <param name="column"></param>
+ /// <param name="inputValue">The uncalculated content of the
cell.</param>
+ public CellEntry(uint row, uint column, string inputValue) :
this(row, column)
+ {
+ this.Cell.InputValue = inputValue;
+ }
+
+
+ /// <summary>
/// The cell element in this cell entry
/// </summary>
public CellElement Cell
@@ -163,8 +190,96 @@
{
ReplaceExtension(GDataSpreadsheetsNameTable.XmlCellElement,
GDataSpreadsheetsNameTable.NSGSpreadsheets, value);
+ this.Dirty = true;
+ }
+ }
+
+
+ /// <summary>
+ /// The row the cell lies in
+ /// </summary>
+ public uint Row
+ {
+ get
+ {
+ return this.Cell.Row;
+ }
+
+ set
+ {
+ this.Cell.Row = value;
+ this.Dirty = true;
+ }
+ }
+
+ /// <summary>
+ /// The column the cell lies in
+ /// </summary>
+ public uint Column
+ {
+ get
+ {
+ return this.Cell.Column;
+ }
+
+ set
+ {
+ this.Cell.Column = value;
+ this.Dirty = true;
+ }
+ }
+
+ /// <summary>
+ /// The input (uncalculated) value for the cell
+ /// </summary>
+ public string InputValue
+ {
+ get
+ {
+ return this.Cell.InputValue;
+ }
+
+ set
+ {
+ this.Cell.InputValue = value;
+ this.Dirty = true;
+ }
+ }
+
+ /// <summary>
+ /// The numeric (calculated) value for the cell
+ /// </summary>
+ public string NumericValue
+ {
+ get
+ {
+ return this.Cell.NumericValue;
+ }
+
+ set
+ {
+ this.Cell.NumericValue = value;
+ this.Dirty = true;
+ }
+ }
+
+ /// <summary>
+ /// The numeric (calculated) value for the cell
+ /// </summary>
+ public string Value
+ {
+ get
+ {
+ return this.Cell.Value;
+ }
+
+ set
+ {
+ this.Cell.Value = value;
+ this.Dirty = true;
}
}
+
/// <summary>
/// add the spreadsheet NS
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:02:54 2007
@@ -17,6 +17,7 @@
using System.Collections;
using System.Text;
using System.Xml;
+using System.Net;
using Google.GData.Client;
using Google.GData.Extensions;
@@ -88,5 +89,99 @@
{
return new CellEntry();
}
+
+ /// <summary>
+ /// returns an update URI for a given row/column combination
+ /// in general that URI is based on the feeds POST feed plus the
+ /// cell address in RnCn notation:
+ ///
http://spreadsheets.google.com/feeds/cells/key/worksheetId/private/full/cell
+ /// </summary>
+ /// <param name="row"></param>
+ /// <param name="column"></param>
+ /// <returns>string</returns>
+ public string CellUri(uint row, uint column)
+ {
+ string target = this.Post;
+ if (!target.EndsWith("/"))
+ {
+ target += "/";
+ }
+ target += "R" + row.ToString() + "C" + column.ToString();
+ return target;
+ }
+
+ /// <summary>
+ /// returns the given CellEntry object. Note that the getter
will go to the server
+ /// to get CellEntries that are NOT yet on the client
+ /// </summary>
+ /// <returns>CellEntry</returns>
+ public CellEntry this[uint row, uint column]
+ {
+ get
+ {
+ // let's find the cell
+ foreach (CellEntry entry in this.Entries )
+ {
+ CellEntry.CellElement cell = entry.Cell;
+ if (cell.Row == row && cell.Column == column)
+ {
+ return entry;
+ }
+ }
+ // if we are here, we need to get the entry from the service
+ string url = CellUri(row, column);
+ CellQuery query = new CellQuery(url);
+
+ CellFeed feed = this.Service.Query(query) as CellFeed;
+ CellEntry newEntry = feed.Entries[0] as CellEntry;
+ this.Entries.Add(newEntry);
+ // we don't want this one to show up in the batch feed
on it's own
+ newEntry.Dirty = false;
+ return newEntry;
+ }
+ }
+
+
+ /// <summary>
+ /// deletes a cell by using row && column addressing
+ /// </summary>
+ /// <param name="row"></param>
+ /// <param name="column"></param>
+ public void Delete(uint row, uint column)
+ {
+ // now we need to create a new guy
+ string url = CellUri(row, column);
+ this.Service.Delete(new Uri(url));
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>uses GData batch to batchupdate the cell feed. If
the returned
+ /// batch result set contained an error, it will throw a
GDataRequestBatchException</summary>
+ /// <returns> </returns>
+ //////////////////////////////////////////////////////////////////////
+ public override void Publish()
+ {
+ if (this.Batch == null)
+ {
+ throw new InvalidOperationException("This feed has no
batch URI");
+ }
+
+ AtomFeed batchFeed =
CreateBatchFeed(GDataBatchOperationType.update);
+ if (batchFeed != null)
+ {
+ AtomFeed resultFeed = this.Service.Batch(batchFeed,
new Uri(this.Batch));
+ foreach (AtomEntry resultEntry in resultFeed.Entries )
+ {
+ GDataBatchEntryData data = resultEntry.BatchData;
+ if (data.Status.Code != (int) HttpStatusCode.OK)
+ {
+ throw new GDataBatchRequestException(resultFeed);
+ }
+ }
+ }
+ this.Dirty = false;
+ }
+
/////////////////////////////////////////////////////////////////////////////
+
}
}
Modified: trunk/clients/cs/src/gspreadsheet/worksheetentry.cs
==============================================================================
--- trunk/clients/cs/src/gspreadsheet/worksheetentry.cs (original)
+++ trunk/clients/cs/src/gspreadsheet/worksheetentry.cs Wed Oct 24
03:02:54 2007
@@ -31,7 +31,7 @@
/// Category used to label entries that contain Cell extension data.
/// </summary>
public static AtomCategory WORKSHEET_CATEGORY
- = new AtomCategory(GDataSpreadsheetsNameTable.Worksheet,
+ = new AtomCategory(GDataSpreadsheetsNameTable.Worksheet,
new AtomUri(BaseNameTable.gKind));
/// <summary>
@@ -124,25 +124,39 @@
set { this.RowCount.Count = value; }
}
+
/// <summary>
/// Retrieves the cell-based metafeed of the cells within the
worksheet.
/// </summary>
/// <returns>The CellsFeed of the cells in this worksheet.</returns>
- public CellFeed GetCellFeed()
+ public CellFeed QueryCellFeed()
{
- CellQuery query = new CellQuery(this.GetCellFeedLink());
+ return QueryCellFeed(ReturnEmtpyCells.serverDefault);
+ }
- return (CellFeed) this.Service.Query(query);
+ /// <summary>
+ /// Retrieves the cell-based metafeed of the cells within the
worksheet.
+ /// </summary>
+ /// <param name="returnEmpty">indicates if a full sheet should
be returned</param>
+ /// <returns>The CellsFeed of the cells in this worksheet.</returns>
+ public CellFeed QueryCellFeed(ReturnEmtpyCells returnEmpty)
+ {
+ CellQuery query = new CellQuery(this.CellFeedLink);
+ query.ReturnEmpty = returnEmpty;
+ return this.Service.Query(query) as CellFeed;
}
/// <summary>
/// Retrieves the URI for the cells feed of the worksheet.
/// </summary>
/// <returns>The URI of the cells feed for this worksheet.</returns>
- public string GetCellFeedLink()
+ public string CellFeedLink
{
- AtomLink cellFeedLink =
this.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
- return cellFeedLink.HRef.ToString();
+ get
+ {
+ AtomLink cellFeedLink =
this.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
+ return cellFeedLink.HRef.ToString();
+ }
}
}
}
Modified: trunk/clients/cs/src/gspreadsheet/worksheetfeed.cs
==============================================================================
--- trunk/clients/cs/src/gspreadsheet/worksheetfeed.cs (original)
+++ trunk/clients/cs/src/gspreadsheet/worksheetfeed.cs Wed Oct 24
03:02:54 2007
@@ -1,61 +1,73 @@
-/* Copyright (c) 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-using System;
-using System.Collections;
-using System.Text;
-using System.Xml;
-using Google.GData.Client;
-using Google.GData.Extensions;
-
-namespace Google.GData.Spreadsheets
-{
- /// <summary>
- /// Feed API customzation class for defining Worksheets feed.
- /// </summary>
- public class WorksheetFeed : AbstractFeed
- {
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="uriBase">The uri for the worksheets feed.</param>
- /// <param name="iService">The Spreadsheets service.</param>
- public WorksheetFeed(Uri uriBase, IService iService)
- : base(uriBase, iService)
- {
- }
-
-
- /// <summary>
- /// returns a new entry for this feed
- /// </summary>
- /// <returns>AtomEntry</returns>
- public override AtomEntry CreateFeedEntry()
- {
- return new WorksheetEntry();
- }
-
- /// <summary>
- /// get's called after we already handled the custom entry, to
handle all
- /// other potential parsing tasks
- /// </summary>
- /// <param name="e">the event arguments</param>
- /// <param name="parser">the atom feed parser calling</param>
- protected override void
HandleExtensionElements(ExtensionElementEventArgs e, AtomFeedParser parser)
- {
- Tracing.TraceMsg("\t HandleExtensionElements for
worksheet feed called");
- }
- }
-}
+/* Copyright (c) 2006 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+using System;
+using System.Collections;
+using System.Text;
+using System.Xml;
+using Google.GData.Client;
+using Google.GData.Extensions;
+
+namespace Google.GData.Spreadsheets
+{
+ /// <summary>
+ /// Feed API customzation class for defining Worksheets feed.
+ /// </summary>
+ public class WorksheetFeed : AbstractFeed
+ {
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="uriBase">The uri for the worksheets feed.</param>
+ /// <param name="iService">The Spreadsheets service.</param>
+ public WorksheetFeed(Uri uriBase, IService iService)
+ : base(uriBase, iService)
+ {
+ }
+
+
+ /// <summary>
+ /// returns a new entry for this feed
+ /// </summary>
+ /// <returns>AtomEntry</returns>
+ public override AtomEntry CreateFeedEntry()
+ {
+ return new WorksheetEntry();
+ }
+
+ /// <summary>
+ /// custom insert to avoid the casting in the developer's code
+ /// </summary>
+ /// <param name="newEntry"></param>
+ /// <returns>WorksheetEntry</returns>
+ public WorksheetEntry Insert(WorksheetEntry newEntry)
+ {
+ return base.Insert(newEntry) as WorksheetEntry;
+ }
+
+
+
+ /// <summary>
+ /// get's called after we already handled the custom entry, to
handle all
+ /// other potential parsing tasks
+ /// </summary>
+ /// <param name="e">the event arguments</param>
+ /// <param name="parser">the atom feed parser calling</param>
+ protected override void
HandleExtensionElements(ExtensionElementEventArgs e, AtomFeedParser parser)
+ {
+ Tracing.TraceMsg("\t HandleExtensionElements for
worksheet feed called");
+ }
+ }
+}
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:02:54 2007
@@ -96,7 +96,7 @@
WorksheetEntry defEntry = sheets.Entries[0] as WorksheetEntry;
Assert.IsTrue(defEntry!= null, "There should be one
default entry in this account/sheet");
- CellFeed defCells = defEntry.GetCellFeed();
+ CellFeed defCells = defEntry.QueryCellFeed();
Assert.IsTrue(defCells != null, "There should be a cell
feed for the worksheet");
foreach (CellEntry cell in defCells.Entries )
@@ -108,23 +108,25 @@
}
}
- WorksheetEntry wEntry = new WorksheetEntry();
- wEntry.ColCount = new ColCountElement();
- wEntry.ColCount.Count = 20;
- wEntry.RowCount = new RowCountElement();
- wEntry.RowCount.Count = 10;
- wEntry.Title.Text = "new Sheet";
-
- WorksheetEntry newEntry = sheets.Insert(wEntry) as WorksheetEntry;
-
+ WorksheetEntry newEntry = sheets.Insert(new
WorksheetEntry(10, 20, "New Worksheet"));
+
Assert.IsTrue(newEntry.ColCount.Count == 20, "Column count
should be equal 20");
Assert.IsTrue(newEntry.RowCount.Count == 10, "Row count
should be equal 10");
- Assert.IsTrue(newEntry.Title.Text ==
wEntry.Title.Text, "Titles should be identical");
+ Assert.IsTrue(newEntry.Title.Text == "New
Worksheet", "Titles should be identical");
- CellFeed cells = newEntry.GetCellFeed();
+ CellFeed cells = newEntry.QueryCellFeed(ReturnEmtpyCells.yes);
Assert.IsTrue(cells != null, "There should be a cell feed
for the new worksheet");
- Assert.IsTrue(cells.Entries.Count == 0, "There should be
no cells");
+ Assert.IsTrue(cells.Entries.Count == 200, "There should be
200 cells");
+ for (uint row = 1; row <= 10; row++)
+ {
+ 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();
// cleanup the new worksheet at the end
// newEntry.Delete();
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---