Commit a3e81930 by Celine Mercier

Views: finished handling and documenting the conditions for an existing

column to be added to a view
parent 644b55b4
......@@ -2281,18 +2281,30 @@ int obi_view_add_column(Obiview_p view,
obidebug(1, "\nError opening a column to add to a view");
return -1;
}
// Check that, if it's not the first column in the view, the column's line count is at least the view's line count if there's a line selection
// Otherwise it should be the same line count
// TODO rediscuss. When cloning a view, if there's a line selection associated,
// when re-adding the columns to the cloned view, it is normal that the columns have a line count greater than the view's.
if (((view->infos)->column_count > 0)
&& (((view->line_selection != NULL) && ((column->header)->lines_used < (view->infos)->line_count))
|| ((view->line_selection == NULL) && ((column->header)->lines_used != (view->infos)->line_count))))
{
// - If there is a line selection:
// - The column's lines_used attribute must be at least the view's line count
// - If there is no line selection:
// - If it's the first column in the view:
// - The view's line count is set to the column's lines_used attribute
// - If it's not the first column in the view:
// - The column's lines_used attribute must be equal to the view's line count
if ((view->line_selection != NULL) && ((column->header)->lines_used < (view->infos)->line_count))
{ // - If there is a line selection, the column's lines_used attribute must be at least the view's line count
obi_set_errno(OBIVIEW_ERROR);
obidebug(1, "\nError adding an existing column to a view: the column's line count (%lld) must be at least the view's (%lld) (when there is a line selection)", (column->header)->line_count, (view->infos)->line_count);
obidebug(1, "\nError adding an existing column to a view: the column's lines_used attribute (%lld) must be equal to or greater than the view's line count (%lld)", (column->header)->lines_used, (view->infos)->line_count);
return -1;
}
else if (view->line_selection == NULL)
{ // If there is no line selection:
if ((view->infos)->column_count == 0) // If it's the first column in the view:
(view->infos)->line_count = (column->header)->lines_used; // The view's line count is set to the column's lines_used attribute
else if ((column->header)->lines_used != (view->infos)->line_count)
{ // If it's not the first column in the view, the column's lines_used attribute must be equal to the view's line count
obi_set_errno(OBIVIEW_ERROR);
obidebug(1, "\nError adding an existing column to a view: the column's lines_used attribute (%lld) must be equal to the view's line count (%lld)", (column->header)->lines_used, (view->infos)->line_count);
return -1;
}
}
}
// Store column pointer in the view structure
......@@ -2311,10 +2323,6 @@ int obi_view_add_column(Obiview_p view,
// Save column alias
strcpy((((view->infos)->column_references)[(view->infos)->column_count]).alias, alias);
// If it's the first column of the view, set the view's line count to the column's line count, except if there's a line selection associated
if (((view->infos)->column_count == 0) && (view->line_selection == NULL))
(view->infos)->line_count = (column->header)->lines_used;
// Update column count in view
(view->infos)->column_count++;
......
......@@ -340,6 +340,14 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name);
/**
* @brief Adds a column to a view.
*
* - If there is a line selection:
* - The column's lines_used attribute must be at least the view's line count
* - If there is no line selection:
* - If it's the first column in the view:
* - The view's line count is set to the column's lines_used attribute
* - If it's not the first column in the view:
* - The column's lines_used attribute must be equal to the view's line count
*
* @warning The view must be writable.
*
* @param view A pointer on the 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