Commit 31628cee authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

msi: Factor out msi_view_refresh_row().

parent 40a08f83
...@@ -287,7 +287,7 @@ UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb, ...@@ -287,7 +287,7 @@ UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb,
return ret; return ret;
} }
UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) UINT msi_view_refresh_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD *rec)
{ {
UINT row_count = 0, col_count = 0, i, ival, ret, type; UINT row_count = 0, col_count = 0, i, ival, ret, type;
...@@ -300,13 +300,6 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) ...@@ -300,13 +300,6 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec)
if (!col_count) if (!col_count)
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
if (row >= row_count)
return ERROR_NO_MORE_ITEMS;
*rec = MSI_CreateRecord(col_count);
if (!*rec)
return ERROR_FUNCTION_FAILED;
for (i = 1; i <= col_count; i++) for (i = 1; i <= col_count; i++)
{ {
ret = view->ops->get_column_info(view, i, NULL, &type, NULL, NULL); ret = view->ops->get_column_info(view, i, NULL, &type, NULL, NULL);
...@@ -323,7 +316,7 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) ...@@ -323,7 +316,7 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec)
ret = view->ops->fetch_stream(view, row, i, &stm); ret = view->ops->fetch_stream(view, row, i, &stm);
if ((ret == ERROR_SUCCESS) && stm) if ((ret == ERROR_SUCCESS) && stm)
{ {
MSI_RecordSetIStream(*rec, i, stm); MSI_RecordSetIStream(rec, i, stm);
IStream_Release(stm); IStream_Release(stm);
} }
else else
...@@ -342,28 +335,48 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) ...@@ -342,28 +335,48 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec)
if (! (type & MSITYPE_VALID)) if (! (type & MSITYPE_VALID))
ERR("Invalid type!\n"); ERR("Invalid type!\n");
/* check if it's nul (0) - if so, don't set anything */
if (!ival)
continue;
if (type & MSITYPE_STRING) if (type & MSITYPE_STRING)
{ {
int len; int len;
const WCHAR *sval = msi_string_lookup( db->strings, ival, &len ); const WCHAR *sval = msi_string_lookup(db->strings, ival, &len);
msi_record_set_string( *rec, i, sval, len ); msi_record_set_string(rec, i, sval, len);
} }
else else
{ {
if ((type & MSI_DATASIZEMASK) == 2) if ((type & MSI_DATASIZEMASK) == 2)
MSI_RecordSetInteger(*rec, i, ival - (1<<15)); MSI_RecordSetInteger(rec, i, ival ? ival - (1<<15) : MSI_NULL_INTEGER);
else else
MSI_RecordSetInteger(*rec, i, ival - (1u<<31)); MSI_RecordSetInteger(rec, i, ival - (1u<<31));
} }
} }
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec)
{
UINT row_count = 0, col_count = 0, r;
MSIRECORD *object;
TRACE("view %p, row %u, rec %p.\n", view, row, rec);
if ((r = view->ops->get_dimensions(view, &row_count, &col_count)))
return r;
if (row >= row_count)
return ERROR_NO_MORE_ITEMS;
if (!(object = MSI_CreateRecord( col_count )))
return ERROR_OUTOFMEMORY;
if ((r = msi_view_refresh_row(db, view, row, object)))
msiobj_release( &object->hdr );
else
*rec = object;
return r;
}
UINT MSI_ViewFetch(MSIQUERY *query, MSIRECORD **prec) UINT MSI_ViewFetch(MSIQUERY *query, MSIRECORD **prec)
{ {
MSIVIEW *view; MSIVIEW *view;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment