23#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/awt/XWindow.hpp>
30#include <com/sun/star/container/XNameAccess.hpp>
31#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
35#include <osl/diagnose.h>
42#define SOURCE_COLUMN 1
66 typedef std::vector< pair < opcode, pair < OConnectionLineDataVec::size_type, OConnectionLineDataVec::size_type> > >
ops_type;
78 explicit ORelationControl(
const css::uno::Reference<css::awt::XWindow>& rParent);
103 virtual void Resize()
override;
107 virtual bool IsTabAllowed(
bool bForward)
const override;
109 void Init(
const TTableConnectionData::value_type& _pConnData);
112 virtual ::svt::CellController*
GetController( sal_Int32 nRow, sal_uInt16 nCol )
override;
114 virtual bool SeekRow( sal_Int32 nRow )
override;
116 virtual OUString
GetCellText( sal_Int32 nRow, sal_uInt16 nColId )
const override;
132 , m_pBoxControl(nullptr)
162 SetMode( BrowserMode::COLUMNSELECTION |
163 BrowserMode::HLINES |
164 BrowserMode::VLINES |
165 BrowserMode::HIDECURSOR |
166 BrowserMode::HIDESELECT |
167 BrowserMode::AUTO_HSCROLL |
168 BrowserMode::AUTO_VSCROLL);
180 tools::Long nOutputWidth = GetOutputSizePixel().Width() - 1;
189 else if (rNEvt.
GetType() == NotifyEventType::GETFOCUS)
227 nRow = rLines.size() - 1;
229 m_ops.emplace_back(
INSERT, make_pair(nRow+1, nRow+2));
237 pConnLineData->SetSourceFieldName( sFieldName );
240 pConnLineData->SetDestFieldName( sFieldName );
248 const OConnectionLineDataVec::size_type oldSize =
m_pConnData->GetConnLineDataList().size();
249 OConnectionLineDataVec::size_type
line =
m_pConnData->normalizeLines();
250 const OConnectionLineDataVec::size_type newSize =
m_pConnData->GetConnLineDataList().size();
251 assert(newSize <= oldSize);
253 m_ops.emplace_back(
DELETE, make_pair(newSize, oldSize));
260 sal_uInt16
nId = _nColId;
275 sText = pConnLineData->GetSourceFieldName();
278 sText = pConnLineData->GetDestFieldName();
340 if( aPos.
X() < rRect.
Left() || aPos.
X() + aTextSize.
Width() > rRect.
Right() ||
363 const OUString* pIter = aNames.getConstArray();
364 const OUString* pEnd = pIter + aNames.getLength();
365 for(;pIter != pEnd;++pIter)
384 if ( _pSource && _pDest )
394 if ( pConn && !
m_pConnData->GetConnLineDataList().empty() )
403 for(
const auto& rLine : rLines )
434 return LogicToPixel(
Size(140, 80),
MapMode(MapUnit::MapAppFont));
440 : m_xLeftTable(_pParent->weld_combo_box(
"table1"))
441 , m_xRightTable(_pParent->weld_combo_box(
"table2"))
442 , m_xTable(_pParent->weld_container(
"relations"))
443 , m_xTableCtrlParent(m_xTable->CreateChildFrame())
445 , m_pTableMap(_pTableMap)
446 , m_pParentDialog(_pParentDialog)
470 OSL_ENSURE( !
m_pTableMap->empty(),
"OTableListBoxControl::fillListBoxes: no table window!");
482 pInitialLeft = elem.second;
485 else if (!pInitialRight)
487 pInitialRight = elem.second;
492 if ( !pInitialRight )
494 pInitialRight = pInitialLeft;
499 m_xRC_Tables->setWindowTables(pInitialLeft,pInitialRight);
519 OUString strSelected(rListBox.get_active_text());
524 if ( m_pTableMap->size() == 2 )
527 if (&rListBox == m_xLeftTable.get())
528 pOther = m_xRightTable.get();
530 pOther = m_xLeftTable.get();
533 OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin();
538 if (m_xLeftTable->get_active_text() == pFirst->
GetName())
552 OJoinTableView::OTableWindowMap::const_iterator aFind = m_pTableMap->find(strSelected);
554 if( aFind != m_pTableMap->end() )
555 pLoop = aFind->second;
556 OSL_ENSURE(pLoop !=
nullptr,
"ORelationDialog::OnTableChanged: invalid ListBox entry!");
558 if (&rListBox == m_xLeftTable.get())
561 m_xRightTable->append_text(m_strCurrentLeft);
563 m_xRightTable->remove_text(strSelected);
564 m_strCurrentLeft = strSelected;
568 OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_xRightTable->get_active_text());
569 OSL_ENSURE( aIter != m_pTableMap->end(),
"Invalid name");
570 if ( aIter != m_pTableMap->end() )
571 pRight = aIter->second;
573 m_xLeftTable->grab_focus();
578 m_xLeftTable->append_text(m_strCurrentRight);
580 m_xLeftTable->remove_text(strSelected);
581 m_strCurrentRight = strSelected;
584 OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_xLeftTable->get_active_text());
585 OSL_ENSURE( aIter != m_pTableMap->end(),
"Invalid name");
586 if ( aIter != m_pTableMap->end() )
587 pLeft = aIter->second;
591 rListBox.grab_focus();
593 m_xRC_Tables->setWindowTables(pLeft,pRight);
601 TTableConnectionData::value_type pConnData =
m_xRC_Tables->getData();
603 bool bValid = !rLines.empty();
606 for (
auto const&
line : rLines)
608 bValid = ! (
line->GetSourceFieldName().isEmpty() ||
line->GetDestFieldName().isEmpty());
621 m_xRC_Tables->RowRemoved(elem.second.first, elem.second.second - elem.second.first);
624 m_xRC_Tables->RowInserted(elem.second.first, elem.second.second - elem.second.first);
627 for(OConnectionLineDataVec::size_type j = elem.second.first; j < elem.second.second; ++j)
constexpr sal_Int32 BROWSER_ENDOFSELECTION
void RowRemoved(sal_Int32 nRow, sal_Int32 nNumRows=1, bool bDoPaint=true)
BrowserDataWin & GetDataWindow() const
void InsertDataColumn(sal_uInt16 nItemId, const OUString &rText, tools::Long nSize, HeaderBarItemBits nBits=HeaderBarItemBits::STDSTYLE, sal_uInt16 nPos=HEADERBAR_APPEND)
bool GoToRow(sal_Int32 nRow)
sal_Int32 GetCurRow() const
sal_uInt16 ColCount() const
void SetColumnTitle(sal_uInt16 nColumnId, const OUString &rTitle)
void SetMode(BrowserMode nMode)
void SetColumnWidth(sal_uInt16 nColumnId, sal_uLong nWidth)
sal_uInt16 GetCurColumnId() const
void RowInserted(sal_Int32 nRow, sal_Int32 nNumRows=1, bool bDoPaint=true, bool bKeepSelection=false)
virtual sal_Int32 GetRowCount() const override
NotifyEventType GetType() const
bool IsClipRegion() 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
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual void setValid(bool _bValid)=0
setValid set the valid inside, can be used for OK buttons
virtual void notifyConnectionChange()=0
notifyConnectionChange is callback which is called when the table selection has changed and a new con...
the class OConnectionLineData contains the data of a connection e.g.
std::map< OUString, VclPtr< OTableWindow > > OTableWindowMap
OTableConnection * GetTabConn(const OTableWindow *pLhs, const OTableWindow *pRhs, bool _bSuppressCrossOrNaturalJoin=false) const
virtual bool SaveModified() override
TTableConnectionData::value_type m_pConnData
void setWindowTables(const OTableWindow *_pSource, const OTableWindow *_pDest)
searches for a connection between these two tables
virtual void Resize() override
virtual bool IsTabAllowed(bool bForward) const override
void SetController(OTableListBoxControl *pController)
virtual Size GetOptimalSize() const override
const TTableConnectionData::value_type & getData() const
allows to access the connection data from outside
virtual void CellModified() override
void fillListBox(const Reference< XPropertySet > &_xDest)
DECL_LINK(AsynchActivate, void *, void)
sal_uInt16 getColumnIdent(sal_uInt16 _nColId) const
returns the column id for the editbrowsebox
virtual ~ORelationControl() override
DECL_LINK(AsynchDeactivate, void *, void)
VclPtr< ::svt::ListBoxControl > m_pListCell
virtual ::svt::CellController * GetController(sal_Int32 nRow, sal_uInt16 nCol) override
virtual void PaintCell(OutputDevice &rDev, const tools::Rectangle &rRect, sal_uInt16 nColId) const override
std::vector< pair< opcode, pair< OConnectionLineDataVec::size_type, OConnectionLineDataVec::size_type > > > ops_type
virtual OUString GetCellText(sal_Int32 nRow, sal_uInt16 nColId) const override
ORelationControl(const css::uno::Reference< css::awt::XWindow > &rParent)
virtual void InitController(::svt::CellControllerRef &rController, sal_Int32 nRow, sal_uInt16 nCol) override
Reference< XPropertySet > m_xDestDef
OTableListBoxControl * m_pBoxControl
virtual void dispose() override
Reference< XPropertySet > m_xSourceDef
virtual bool SeekRow(sal_Int32 nRow) override
virtual bool PreNotify(NotifyEvent &rNEvt) override
const TTableConnectionData::value_type & GetData() const
IRelationControlInterface * getContainer() const
getContainer returns the container interface
OTableListBoxControl(weld::Builder *_pParent, const OJoinTableView::OTableWindowMap *_pTableMap, IRelationControlInterface *_pParentDialog)
OUString m_strCurrentLeft
std::unique_ptr< weld::Container > m_xTable
std::unique_ptr< weld::ComboBox > m_xRightTable
std::unique_ptr< weld::ComboBox > m_xLeftTable
VclPtr< ORelationControl > m_xRC_Tables
void fillAndDisable(const TTableConnectionData::value_type &_pConnectionData)
fillAndDisable fill the listboxes only with one entry and then disable them
css::uno::Reference< css::awt::XWindow > m_xTableCtrlParent
const OJoinTableView::OTableWindowMap * m_pTableMap
OUString m_strCurrentRight
void NotifyCellChange()
NotifyCellChange notifies the browse control that the connection data has changed.
TTableWindowData::value_type const & getReferencingTable() const
IRelationControlInterface * m_pParentDialog
void fillListBoxes()
fillListBoxes fills the list boxes with the table windows
void enableRelation(bool _bEnable)
enables the relation control
void Init(const TTableConnectionData::value_type &_pConnData)
Init is a call through to the control inside this one.
OJoinTableView * getTableView()
const TTableWindowData::value_type & GetData() const
virtual OUString GetName() const =0
returns the name which should be used when displaying join or relations
css::uno::Reference< css::beans::XPropertySet > GetTable() const
virtual bool IsTabAllowed(bool bForward) const
virtual void DeactivateCell(bool bUpdate=true)
virtual void Resize() override
virtual bool PreNotify(NotifyEvent &rNEvt) override
bool ControlHasFocus() const
virtual void dispose() override
virtual void CellModified()
virtual OUString get_active_text() const=0
virtual void set_active(int pos)=0
void append_text(const OUString &rStr)
void insert_text(int pos, const OUString &rStr)
virtual int get_active() const=0
void set_active_text(const OUString &rStr)
#define DBG_UNHANDLED_EXCEPTION(...)
@ NO_HANDLE_COLUMN_CONTENT
constexpr OUStringLiteral HID_RELATIONDIALOG_LEFTFIELDCELL
constexpr OUStringLiteral HID_RELATIONDIALOG_RIGHTFIELDCELL
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
std::vector< OConnectionLineDataRef > OConnectionLineDataVec
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
static void fillEntryAndDisable(weld::ComboBox &_rListBox, const OUString &_sEntry)
::svt::EditBrowseBox ORelationControl_Base
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)