21#include <core_resource.hxx>
23#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
24#include <com/sun/star/sdbc/XConnection.hpp>
25#include <com/sun/star/sdbc/SQLException.hpp>
26#include <com/sun/star/container/XContainer.hpp>
27#include <com/sun/star/container/XIndexAccess.hpp>
28#include <com/sun/star/container/XNameAccess.hpp>
29#include <com/sun/star/beans/XPropertySet.hpp>
46#include <com/sun/star/accessibility/AccessibleEventId.hpp>
61 ,m_pExistingConnection(nullptr)
89 if ( xContainer.is() )
95 std::vector< OUString> arrInvalidTables;
99 TTableWindowData::const_reverse_iterator aIter = rTabWinDataList.rbegin();
100 for(;aIter != rTabWinDataList.rend();++aIter)
102 TTableWindowData::value_type
pData = *aIter;
105 if (!pTabWin->Init())
109 pTabWin->clearListBox();
111 arrInvalidTables.push_back(
pData->GetTableName());
113 rTabWinDataList.erase( std::remove(rTabWinDataList.begin(), rTabWinDataList.end(), *aIter), rTabWinDataList.end());
119 if (!
pData->HasPosition() && !
pData->HasSize())
127 TTableConnectionData::const_reverse_iterator aConIter = rTabConnDataList.rbegin();
129 for(;aConIter != rTabConnDataList.rend();++aConIter)
132 if ( !arrInvalidTables.empty() )
136 bool bInvalid = std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
138 bInvalid = bInvalid || std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
143 rTabConnDataList.erase( std::remove(rTabConnDataList.begin(), rTabConnDataList.end(), *aConIter), rTabConnDataList.end() );
158 return !
m_pView->getController().isReadOnly();
170 if((pFirst->GetSourceWin() == pSourceWin && pFirst->GetDestWin() == pDestWin) ||
171 (pFirst->GetSourceWin() == pDestWin && pFirst->GetDestWin() == pSourceWin))
178 TTableConnectionData::value_type pTabConnData = std::make_shared<ORelationTableConnectionData>(pSourceWin->
GetData(),
183 OUString sSourceFieldName = rSourceTreeView.
get_text(jxdSource.
nEntry);
189 bool bAskUser = xPrimaryKeyColumns.is() &&
Reference< XIndexAccess>(xPrimaryKeyColumns,UNO_QUERY_THROW)->getCount() > 1;
191 pTabConnData->SetConnLine( 0, sSourceFieldName, sDestFieldName );
200 if( pTabConnData->Update() )
206 catch(
const SQLException&)
220 switch (aRelDlg.
run())
224 rConnection->UpdateLineList();
246 TTableConnectionData::value_type pNewConnData = std::make_shared<ORelationTableConnectionData>();
249 bool bSuccess = (aRelDlg.
run() ==
RET_OK);
267 catch(SQLException& e)
273 TOOLS_WARN_EXCEPTION(
"dbaccess",
"ORelationTableView::RemoveConnection: Something other than SQLException occurred!");
280 OSL_ENSURE(!_rComposedName.isEmpty(),
"There must be a table name supplied!");
281 OJoinTableView::OTableWindowMap::const_iterator aIter =
GetTabWinMap().find(_rComposedName);
285 aIter->second->SetZOrder(
nullptr, ZOrderFlags::First);
286 aIter->second->GrabFocus();
293 TTableWindowData::value_type pNewTabWinData(
createTableWindowData( _rComposedName, rWinName,rWinName ));
294 pNewTabWinData->ShowAll(
false);
298 if(pNewTabWin->Init())
300 m_pView->getController().getTableWindowData().push_back( pNewTabWinData);
310 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
312 Any(pNewTabWin->GetAccessible()));
316 pNewTabWin->clearListBox();
326 m_pView->getController().ClearUndoManager();
329 m_pView->getController().InvalidateFeature(SID_RELATION_ADD_RELATION);
339 OUString sTitle(
DBA_RES(STR_RELATIONDESIGN));
340 sTitle = sTitle.copy(3);
347 sal_uInt16 nRet = aDlg.
run();
352 else if ( nRet ==
RET_OK )
390 if ( _rEvent.Accessor >>=
sName )
395 m_pView->getController().ClearUndoManager();
398 m_pView->getController().InvalidateFeature(SID_RELATION_ADD_RELATION);
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
OJoinController & getController() const
virtual void dispose() override
rtl::Reference< OJoinDesignViewAccess > m_pAccessible
const std::vector< VclPtr< OTableConnection > > & getTableConnections() const
gives a read only access to the connection vector
virtual bool RemoveConnection(VclPtr< OTableConnection > &rConnection, bool bDelete)
RemoveConnection allows to remove connections from join table view.
OTableWindow * GetTabWindow(const OUString &rName)
TTableWindowData::value_type createTableWindowData(const OUString &_rComposedName, const OUString &_sTableName, const OUString &_rWinName)
virtual void EnsureVisible(const OTableWindow *_pWin)
OJoinDesignView * getDesignView() const
VclPtr< OJoinDesignView > m_pView
virtual void RemoveTabWin(OTableWindow *pTabWin)
void SetDefaultTabWinPosSize(OTableWindow *pTabWin)
void addConnection(OTableConnection *_pConnection, bool _bAddData=true)
allows to add new connections to join table view
OTableWindowMap & GetTabWinMap()
virtual short run() override
virtual VclPtr< OTableWindow > createWindow(const TTableWindowData::value_type &_pData) override
factory method to create table windows
virtual void AddConnection(const OJoinExchangeData &jxdSource, const OJoinExchangeData &jxdDest) override
virtual void RemoveTabWin(OTableWindow *pTabWin) override
virtual void _elementInserted(const css::container::ContainerEvent &_rEvent) override
TTableConnectionData::value_type m_pCurrentlyTabConnData
set when we creating a connection with more than one keycolumn
virtual void ConnDoubleClicked(VclPtr< OTableConnection > &rConnection) override
virtual bool allowQueries() const override
determines whether the classes Init method should accept a query name, or only table names
virtual void _elementRemoved(const css::container::ContainerEvent &_rEvent) override
virtual void lookForUiActivities() override
virtual bool RemoveConnection(VclPtr< OTableConnection > &rConn, bool _bDelete) override
RemoveConnection allows to remove connections from join table view.
virtual void _elementReplaced(const css::container::ContainerEvent &_rEvent) override
VclPtr< OTableConnection > m_pExistingConnection
is set when a connection was dragged on an existing connection
virtual void ReSync() override
take all WinData and ConnData from the document and create the corresponding Wins and Conns
virtual ~ORelationTableView() override
virtual void AddTabWin(const OUString &_rComposedName, const OUString &rWinName, bool bNewTable=false) override
void AddNewRelation()
Creates a dialogue for a completely new relation.
::rtl::Reference< comphelper::OContainerListenerAdapter > m_pContainerListener
virtual bool IsAddAllowed() override
used by AddTabDlg to check if tables can be added
virtual void dispose() override
void set_default_response(int nResponse)
void add_button(const OUString &rText, int nResponse, const OUString &rHelpId={})
void set_title(const OUString &rTitle)
const TTableWindowData::value_type & getReferencingTable() const
const TTableWindowData::value_type & getReferencedTable() const
const TTableWindowData::value_type & GetData() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
weld::Window * GetFrameWeld() const
void SetHelpId(const OUString &)
virtual OUString get_text(int row, int col=-1) const=0
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral HID_CTL_RELATIONTAB
std::unique_ptr< sal_Int32[]> pData
std::vector< std::shared_ptr< OTableConnectionData > > TTableConnectionData
std::vector< std::shared_ptr< OTableWindowData > > TTableWindowData
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)
VclPtr< OTableWindowListBox > pListBox