DbGridControl's confusion of BrowseBox's column number vs. column ID
Lionel Elie Mamane
lionel at mamane.lu
Fri Mar 10 14:29:04 UTC 2017
On Fri, Mar 10, 2017 at 01:52:36PM +0100, Stephan Bergmann wrote:
> svtools' BrowseBox class (include/svtools/brwbox.hxx; effectively a
> collection of BrowseColumn via the BrowseBox::pCols member) apparently
> distinguishes between a column's index/position/number (i.e., the
> BrowseColumn's position within the BrowseBox::pCols vector) and its ID
> (i.e., the BrowseColumn::_nId member, svtools/source/brwbox/datwin.hxx).
> Does anybody (Lionel?) known something about that DbGridControl code? Would
> this be a bug (if so, any idea how to reproduce it at the GUI?) or is it
> maybe an invariant of such a DbGridControl that it's columns' ID always
> match the columns' positions?
No, it is not an invariant. Consider
file fmgridcl.cxx function FmGridControl::InitColumnsByModels
for (i = 0; i < xColumns->getCount(); ++i)
{
...
AppendColumn(aName, (sal_uInt16)nWidth);
...
}
// now all columns are inserted with identical id and pos
...
for (i = 0; i < xColumns->getCount(); ++i)
{
Reference< css::beans::XPropertySet > xCol(
xColumns->getByIndex(i), css::uno::UNO_QUERY);
aHidden = xCol->getPropertyValue(FM_PROP_HIDDEN);
if (::comphelper::getBOOL(aHidden))
HideColumn(GetColumnIdFromModelPos((sal_uInt16)i));
}
And HideColumn calls
DbGridControl::HideColumn(nId);
which calls
DbGridControl_base::HideColumn(nId);
that is
BrowseBox::RemoveColumn
which does
BrowserColumns::iterator it = pCols->begin();
::std::advance( it, nPos );
delete *it;
pCols->erase( it );
As soon as there is a hidden column, the position and id of the
columns after that one don't match anymore.
--
Lionel
More information about the LibreOffice
mailing list