20#include <core_resource.hxx>
24#include <osl/diagnose.h>
34 BrowserMode::HIDECURSOR | BrowserMode::HIDESELECT | BrowserMode::AUTO_HSCROLL | BrowserMode::AUTO_VSCROLL;
36#define COLUMN_ID_FIELDNAME 1
37#define COLUMN_ID_ORDER 2
40 using namespace ::
svt;
74 , m_aSeekRow(m_aFields.
end())
75 , m_pSortingCell(nullptr)
76 , m_pFieldNameCell(nullptr)
77 , m_bAddIndexAppendix(false)
125 bool bEnabled = IsEnabled();
128 _rDev.
SetTextColor(GetSettings().GetStyleSettings().GetDisableColor());
163 IndexFields::iterator aDest = std::copy_if(
m_aFields.begin(),
m_aFields.end(), _rFields.begin(),
164 [](
const OIndexField& source) { return !source.sFieldName.isEmpty(); });
166 _rFields.resize(aDest - _rFields.begin());
173 sal_Int32 nWidthAsc = GetTextWidth(
m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
174 sal_Int32 nWidthDesc = GetTextWidth(
m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
176 return std::max(nWidthAsc, nWidthDesc) + GetTextWidth(OUString(
'0')) * 2;
188 sal_Int32 nFieldNameWidth = GetSizePixel().Width();
196 OUString sColumnName =
DBA_RES(STR_TAB_INDEX_SORTORDER);
199 sal_Int32 nSortOrderColumnWidth = GetTextWidth(sColumnName);
201 sal_Int32 nOther = GetTextWidth(
m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
202 nSortOrderColumnWidth = std::max(nSortOrderColumnWidth, nOther);
204 nOther = GetTextWidth(
m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
205 nSortOrderColumnWidth = std::max(nSortOrderColumnWidth, nOther);
207 nSortOrderColumnWidth += GetTextWidth(OUString(
'0')) * 2;
216 nFieldNameWidth -= nSortOrderColumnWidth;
220 nFieldNameWidth -= 8;
222 OUString sColumnName =
DBA_RES(STR_TAB_INDEX_FIELD);
231 const OUString* pFields = _rAvailableFields.getConstArray();
232 const OUString* pFieldsEnd = pFields + _rAvailableFields.getLength();
233 for (;pFields < pFieldsEnd; ++pFields)
242 IndexFields::const_iterator aRow;
258 OSL_FAIL(
"IndexFieldsControl::GetController: invalid column id!");
287 bool bEmptySelected = sFieldSelected.isEmpty();
302 OSL_ENSURE(nRow <
static_cast<sal_Int32
>(
m_aFields.size()),
"IndexFieldsControl::SaveModified: invalid current row!");
306 IndexFields::iterator aPos =
m_aFields.begin() + nRow;
310 aPos->sFieldName.clear();
317 if (sFieldSelected == aPos->sFieldName)
321 aPos->sFieldName = sFieldSelected;
330 OSL_ENSURE(!
isNewField(),
"IndexFieldsControl::SaveModified: why the hell ...!!!");
334 OSL_ENSURE(
nPos != -1,
"IndexFieldsControl::SaveModified: how did you get this selection??");
342 OSL_FAIL(
"IndexFieldsControl::SaveModified: invalid column id!");
349 IndexFields::const_iterator aFieldDescription;
357 rNameListBox.
set_active_text(bNewField ? OUString() : aFieldDescription->sFieldName);
371 OSL_FAIL(
"IndexFieldsControl::InitController: invalid column id!");
379 m_aModifyHdl.Call(*
this);
381 if (&rListBox != &m_pFieldNameCell->get_widget())
385 if (GetCurRow() >= GetRowCount() - 2)
388 sal_Int32 nCurrentRow = GetCurRow();
389 sal_Int32 rowCount = GetRowCount();
391 OSL_ENSURE((
static_cast<sal_Int32
>(m_aFields.size() + 1)) == rowCount,
"IndexFieldsControl::OnListEntrySelected: inconsistence!");
393 if (!sSelectedEntry.isEmpty() && (nCurrentRow == rowCount - 1) )
396 m_aFields.emplace_back();
397 RowInserted(GetRowCount());
398 Invalidate(GetRowRectPixel(nCurrentRow));
400 else if (sSelectedEntry.isEmpty() && (nCurrentRow == rowCount - 2))
403 m_aFields.pop_back();
404 RowRemoved(GetRowCount() - 1);
405 Invalidate(GetRowRectPixel(nCurrentRow));
413 IndexFields::const_iterator aRow =
m_aFields.end();
417 OSL_ENSURE(aRow <=
m_aFields.end(),
"IndexFieldsControl::SeekRow: invalid row!");
428 return _rRow->sFieldName;
430 if (_rRow->sFieldName.isEmpty())
435 OSL_FAIL(
"IndexFieldsControl::GetCurrentRowCellText: invalid column id!");
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
void RowRemoved(sal_Int32 nRow, sal_Int32 nNumRows=1, bool bDoPaint=true)
void SetUpdateMode(bool bUpdate)
BrowserDataWin & GetDataWindow() const
void InsertDataColumn(sal_uInt16 nItemId, const OUString &rText, tools::Long nSize, HeaderBarItemBits nBits=HeaderBarItemBits::STDSTYLE, sal_uInt16 nPos=HEADERBAR_APPEND)
sal_Int32 GetCurRow() const
bool GoToRowColumnId(sal_Int32 nRow, sal_uInt16 nColId)
sal_uInt16 GetCurColumnId() const
tools::Rectangle GetRowRectPixel(sal_Int32 nRow) const
void RowInserted(sal_Int32 nRow, sal_Int32 nNumRows=1, bool bDoPaint=true, bool bKeepSelection=false)
virtual sal_Int32 GetRowCount() const override
bool IsClipRegion() const
void SetTextColor(const Color &rColor)
const Color & GetTextColor() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
constexpr tools::Long Y() const
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
sal_Int32 GetScrollBarSize() const
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void callModifyHdl() override
void SetAdditionalModifyHdl(const Link< DbaMouseDownListBoxController &, void > &_rHdl)
DbaMouseDownListBoxController(ListBoxControl *_pParent)
Link< DbaMouseDownListBoxController &, void > m_aAdditionalModifyHdl
virtual void dispose() override
IndexFields::const_iterator m_aSeekRow
void initializeFrom(IndexFields &&_rFields)
OUString m_sAscendingText
VclPtr< ::svt::ListBoxControl > m_pSortingCell
OUString GetRowCellText(const IndexFields::const_iterator &_rRow, sal_uInt16 nColId) const
bool SaveModified() override
virtual sal_uInt32 GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId) override
IndexFieldsControl(const css::uno::Reference< css::awt::XWindow > &rParent)
virtual void PaintCell(OutputDevice &_rDev, const tools::Rectangle &_rRect, sal_uInt16 _nColumnId) const override
VclPtr< ::svt::ListBoxControl > m_pFieldNameCell
OUString m_sDescendingText
virtual OUString GetCellText(sal_Int32 _nRow, sal_uInt16 nColId) const override
virtual bool SeekRow(sal_Int32 nRow) override
void commitTo(IndexFields &_rFields)
virtual bool IsModified() const
virtual ~IndexFieldsControl() override
bool implGetFieldDesc(sal_Int32 _nRow, IndexFields::const_iterator &_rPos)
void InitController(::svt::CellControllerRef &, sal_Int32 _nRow, sal_uInt16 _nColumnId) override
::svt::CellController * GetController(sal_Int32 _nRow, sal_uInt16 _nColumnId) override
virtual bool IsTabAllowed(bool bForward) const override
virtual void callModifyHdl()
virtual sal_uInt32 GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId)
virtual bool SeekRow(sal_Int32 nRow) override
virtual void dispose() override
virtual OUString get_active_text() const=0
virtual bool get_popup_shown() const=0
void append_text(const OUString &rStr)
virtual int get_active() const=0
void set_active_text(const OUString &rStr)
constexpr OUStringLiteral HID_DLGINDEX_INDEXDETAILS_FIELD
constexpr OUStringLiteral HID_DLGINDEX_INDEXDETAILS_SORTORDER
#define COLUMN_ID_FIELDNAME
#define LINK(Instance, Class, Member)
constexpr auto BROWSER_STANDARD_FLAGS
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
std::vector< OIndexField > IndexFields
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)