21#include <osl/diagnose.h>
31#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
32#include <com/sun/star/sdbc/SQLException.hpp>
44#include <com/sun/star/accessibility/XAccessible.hpp>
45#include <com/sun/star/accessibility/AccessibleRole.hpp>
46#include <com/sun/star/accessibility/AccessibleEventId.hpp>
62#define TABWIN_SPACING_X 17
63#define TABWIN_SPACING_Y 17
65#define TABWIN_WIDTH_STD 120
66#define TABWIN_HEIGHT_STD 120
71 ,m_pTableView(nullptr)
127 Point( 0, aTotalOutputSize.
Height()-nHScrollHeight ),
128 Size( aTotalOutputSize.
Width()-nVScrollWidth, nHScrollHeight )
132 Point( aTotalOutputSize.
Width()-nVScrollWidth, 0 ),
133 Size( nVScrollWidth, aTotalOutputSize.
Height()-nHScrollHeight )
157 ,DropTargetHelper(this)
158 ,m_aDragScrollIdle(
"dbaccess OJoinTableView m_aDragScrollIdle")
159 ,m_aDragOffset(
Point(0,0) )
160 ,m_aScrollOffset(
Point(0,0) )
161 ,m_pDragWin( nullptr )
162 ,m_pSizingWin( nullptr )
163 ,m_pSelectedConn( nullptr )
164 ,m_pLastFocusTabWin(nullptr)
200 ScrollPane(rScrollbar.adjustment_get_value() - m_aScrollOffset.X(),
true,
false);
206 ScrollPane(rScrollbar.adjustment_get_value() - m_aScrollOffset.Y(),
false,
false);
224 Point aRealPos = pCheck->GetPosPixel();
227 if (aRealPos == aAssumedPos)
251 xConn->InvalidateConnection();
253 m_pView->getController().removeConnectionData(xConn->GetData());
260 Any(xConn->GetAccessible()),
263 xConn->disposeOnce();
270 OTableWindowMap::const_iterator aIter =
m_aTableMap.find(rName);
272 return aIter ==
m_aTableMap.end() ? nullptr : aIter->second;
276 ,
const OUString& _sTableName
277 ,
const OUString& _rWinName)
279 TTableWindowData::value_type
pData(
CreateImpl(_rComposedName, _sTableName,_rWinName) );
285 if (
pData->isValid() )
291 catch (
const SQLException& )
296 catch(
const WrappedTargetException& e )
299 if ( e.TargetException >>= aSql )
310 ,
const OUString& _sTableName
311 ,
const OUString& _rWinName)
313 return std::make_shared<OTableWindowData>(
nullptr,_rComposedName,_sTableName, _rWinName );
318 OSL_ENSURE(!_rComposedName.isEmpty(),
"There must be a table name supplied!");
320 TTableWindowData::value_type pNewTabWinData(
createTableWindowData( _rComposedName, rWinName,rWinName ));
324 if ( pNewTabWin->Init() )
326 m_pView->getController().getTableWindowData().push_back( pNewTabWinData);
338 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
340 Any(pNewTabWin->GetAccessible()));
344 pNewTabWin->clearListBox();
353 TTableWindowData::value_type
pData = pTabWin->
GetData();
360 (
pData == rTabConn->GetData()->getReferencingTable()) ||
361 (
pData == rTabConn->GetData()->getReferencedTable())
375 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
385 rController.setModified(
true);
411 if( nNewThumbPos < 0 )
428 _nScrollY = _nScrollX = 0;
430 Point aUpperLeft = _rPoint;
439 bool bFitsHor = (aUpperLeft.
X() >= 0) && (aLowerRight.X() <= aSize.
Width());
440 bool bFitsVert= (aUpperLeft.
Y() >= 0) && (aLowerRight.Y() <= aSize.
Height());
441 if (!bFitsHor || !bFitsVert)
446 if ( aLowerRight.X() > aSize.
Width() )
450 if ( aUpperLeft.
X() < 0 )
457 if ( aLowerRight.Y() > aSize.
Height() )
460 if ( aUpperLeft.
Y() < 0 )
465 bVisible = isScrollAllowed(_pView,_nScrollX,
true);
489 return getMovementImpl(
this,_rPoint,_rSize,nX,nY);
522 Point aNewPos( 0,0 );
543 ( (aOtherTabWinRect.
Top()>aRowRect.
Top()) && (aOtherTabWinRect.
Top()<aRowRect.
Bottom()) ) ||
548 if( aOtherTabWinRect.
Right()>aNewPos.
X() )
579 Point aBottom(aNewPos);
593 if (rDCEvt.
GetType() == DataChangedEventType::SETTINGS)
612 if (
m_pView->getController().isReadOnly())
619 m_pDragWin->SetZOrder(
nullptr, ZOrderFlags::First);
632 if (
m_pView->getController().isReadOnly())
645 if( bPaintScrollBars )
651 if( nNewThumbPos < 0 )
668 if( nNewThumbPos < 0 )
700 pTabWin = elem.second;
730 if( aDragWinPos.
X() < 0 )
731 aDragWinPos.
setX( 0 );
732 if( aDragWinPos.
Y() < 0 )
733 aDragWinPos.
setY( 0 );
738 if( aDragWinPos.
X() < 0 )
739 aDragWinPos.
setX( 0 );
740 if( aDragWinPos.
Y() < 0 )
741 aDragWinPos.
setY( 0 );
746 m_pDragWin->SetZOrder(
nullptr, ZOrderFlags::First);
750 if ( ! (
pData &&
pData->HasPosition() && (
pData->GetPosition() == aDragWinPos)))
846 if( !bCtrl && !bShift && (nCode==
KEY_DELETE) )
863 pWin->
GetListBox()->get_widget().unselect_all();
867 pWin->
GetListBox()->get_widget().unselect_all();
884 if (!(pConnSource && pConnDest))
889 if (!(pSourceBox && pDestBox))
895 bool bScrolled =
false;
897 const std::vector<std::unique_ptr<OConnectionLine>>& rLines = pConn->
GetConnLineList();
898 auto aIter = rLines.rbegin();
899 for(;aIter != rLines.rend();++aIter)
901 if ((*aIter)->IsValid())
903 int nSourceEntry = pSourceBox->
GetEntryFromText((*aIter)->GetData()->GetSourceFieldName());
904 if (nSourceEntry != -1)
911 int nDestEntry = pDestBox->
GetEntryFromText((*aIter)->GetData()->GetDestFieldName());
912 if (nDestEntry != -1)
937 conn->InvalidateConnection();
944 connection->Draw(rRenderContext, rRect);
993 OSL_ENSURE(
m_pDragWin !=
nullptr,
"OJoinTableView::ScrollWhileDragging must not be called when a window is being dragged !");
1001 Point aLowerRight(aDragWinPos.
X() + aDragWinSize.
Width(), aDragWinPos.
Y() + aDragWinSize.
Height());
1003 if (aDragWinPos ==
m_pDragWin->GetPosPixel())
1009 bool bScrolling =
false;
1010 bool bNeedScrollTimer =
false;
1014 if( aDragWinPos.
X() < 5 )
1017 if( !bScrolling && (aDragWinPos.
X()<0) )
1018 aDragWinPos.
setX( 0 );
1021 bNeedScrollTimer = bScrolling && (aDragWinPos.
X() < 5);
1034 if( aDragWinPos.
Y() < 5 )
1037 if( !bScrolling && (aDragWinPos.
Y()<0) )
1038 aDragWinPos.
setY( 0 );
1040 bNeedScrollTimer = bScrolling && (aDragWinPos.
Y() < 5);
1053 if (bNeedScrollTimer)
1067 ScrollWhileDragging();
1073 m_pView->getController().addUndoActionAndInvalidate(std::move(_pAction));
1081 invalidateAndModify(std::make_unique<OJoinMoveTabWinUndoAct>(
this, ptOldPosition, ptWhich));
1089 invalidateAndModify(std::make_unique<OJoinSizeTabWinUndoAct>(
this, ptOldPosition, szOldSize, ptWhich));
1096 if (
m_pView->getController().isReadOnly())
1102 if(!xConnection.is())
1107 sal_Int32 nMax = xMetaData.is() ? xMetaData->getMaxTablesInSelect() : 0;
1108 if (nMax && nMax <=
static_cast<sal_Int32
>(
m_aTableMap.size()))
1111 catch(SQLException&)
1124 std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu(
"menu"));
1125 OUString sIdent = xContextMenu->popup_at_rect(pPopupParent, aRect);
1126 if (sIdent ==
"delete")
1128 else if (sIdent ==
"edit")
1135 bool bHandled =
false;
1139 case CommandEventId::ContextMenu:
1150 const std::vector<std::unique_ptr<OConnectionLine>>& rLines = rSelConnection->GetConnLineList();
1152 if( aIter != rLines.end() )
1163 if( elem->CheckHit(aMousePos) )
1184 OSL_ENSURE(pRhs || pLhs,
"OJoinTableView::GetTabConn : invalid args !");
1191 if ( ( (
pData->GetSourceWin() == pLhs)
1192 && ( (
pData->GetDestWin() == pRhs)
1193 || (
nullptr == pRhs)
1196 || ( (
pData->GetSourceWin() == pRhs)
1197 && ( (
pData->GetDestWin() == pLhs)
1198 || (
nullptr == pLhs)
1203 if ( _bSuppressCrossOrNaturalJoin )
1218 bool bHandled =
false;
1221 case NotifyEventType::COMMAND:
1224 if (pCommand->
GetCommand() == CommandEventId::Wheel)
1227 if (
pData->GetMode() == CommandWheelMode::SCROLL)
1229 if (
pData->GetDelta() > 0)
1238 case NotifyEventType::KEYINPUT:
1257 [](
const OTableWindowMap::value_type& rEntry) { return rEntry.second && rEntry.second->HasChildPathFocus(); });
1267 if ((aIter->second ==
m_aTableMap.rbegin()->second) && bForward)
1280 if ( aIter->second ==
m_aTableMap.rbegin()->second )
1285 pNextWin = aIter->second;
1295 pNextWin = aIter->second;
1366 case NotifyEventType::GETFOCUS:
1377 pSearchFor = pSource;
1386 if (elem.second == pSearchFor)
1417 if (pFirstWin->GetListBox())
1418 pFirstWin->GetListBox()->GrabFocus();
1420 pFirstWin->GrabFocus();
1429 if (
nType != StateChangedType::Zoom )
1441 elem.second->SetZoom(
GetZoom());
1442 Size aSize(
CalcZoom(elem.second->GetSizePixel().Width()),
CalcZoom(elem.second->GetSizePixel().Height()));
1443 elem.second->SetSizePixel(aSize);
1456 for (
auto const& elem : aCopy)
1459 m_pView->getController().setModified(
true);
1487 elem.second->clearListBox();
1488 elem.second.disposeAndClear();
1494 elem.disposeAndClear();
1525 rController.setModified(
true );
1527 rController.InvalidateFeature(SID_RELATION_ADD_RELATION);
1534#if OSL_DEBUG_LEVEL > 0
1536 OSL_ENSURE( std::find(rTabConnDataList.begin(), rTabConnDataList.end(),_pConnection->
GetData()) == rTabConnDataList.end(),
"Data already in vector!");
1538 m_pView->getController().getTableConnectionData().push_back(_pConnection->
GetData());
1546 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
1558 OSL_FAIL(
"OTableWindow::onNoColumns_throw: cannot really handle this!" );
1559 throw SQLException();
#define TABWIN_HEIGHT_STD
#define ID_BROWSER_ADDTABLE
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
DataChangedEventType GetType() const
virtual void Start(bool bStartTimer=true) override
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
const KeyEvent * GetKeyEvent() const
vcl::Window * GetWindow() const
const CommandEvent * GetCommandEvent() const
NotifyEventType GetType() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const vcl::Font & GetGroupFont() const
const Color & GetDialogColor() const
const Color & GetFaceColor() const
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
bool IsTrackingEnded() const
bool IsTrackingCanceled() const
const MouseEvent & GetMouseEvent() const
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
TTableWindowData & getTableWindowData()
the class OJoinDesignViewAccess represents the accessible object for join views like the QueryDesign ...
OJoinController & getController() const
Point m_ptPrevDraggingPos
void InvalidateConnections()
void NotifyTitleClicked(OTableWindow *pTabWin, const Point &rMousePos)
virtual void dispose() override
void BeginChildMove(OTableWindow *pTabWin, const Point &rMousePos)
void TabWinMoved(OTableWindow *ptWhich, const Point &ptOldPosition)
Hook that is called after moving/resizing TabWins.
virtual void KeyInput(const KeyEvent &rEvt) override
virtual void LoseFocus() override
ScrollAdaptor & GetVScrollBar()
void ScrollWhileDragging()
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
rtl::Reference< OJoinDesignViewAccess > m_pAccessible
const std::vector< VclPtr< OTableConnection > > & getTableConnections() const
gives a read only access to the connection vector
void executePopup(const Point &_aPos, VclPtr< OTableConnection > &rSelConnection)
opens the context menu to delete a connection
virtual bool RemoveConnection(VclPtr< OTableConnection > &rConnection, bool bDelete)
RemoveConnection allows to remove connections from join table view.
const Point & GetScrollOffset() const
OTableWindow * GetTabWindow(const OUString &rName)
VclPtr< OTableWindow > m_pLastFocusTabWin
VclPtr< OTableWindow > m_pDragWin
void TabWinSized(OTableWindow *ptWhich, const Point &ptOldPosition, const Size &szOldSize)
sal_Int32 getConnectionCount(const OTableWindow *_pFromWin) const
how many connection belongs to single table
tools::Rectangle m_aSizingRect
void clearLayoutInformation()
clear the window map and connection vector without destroying it
virtual VclPtr< OTableWindow > createWindow(const TTableWindowData::value_type &_pData)=0
factory method to create table windows
virtual void MouseButtonDown(const MouseEvent &rEvt) override
TTableWindowData::value_type createTableWindowData(const OUString &_rComposedName, const OUString &_sTableName, const OUString &_rWinName)
virtual ~OJoinTableView() override
virtual void EnsureVisible(const OTableWindow *_pWin)
virtual void Resize() override
virtual void Command(const CommandEvent &rEvt) override
VclPtr< OTableWindow > m_pSizingWin
bool ExistsAConn(const OTableWindow *pFromWin) const
std::map< OUString, VclPtr< OTableWindow > > OTableWindowMap
void BeginChildSizing(OTableWindow *pTabWin, PointerStyle nPointer)
virtual bool IsAddAllowed()
virtual void ClearAll()
Hard deletion.
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
VclPtr< OTableConnection > m_pSelectedConn
virtual bool allowQueries() const
determines whether the classes Init method should accept a query name, or only table names
void GrabTabWinFocus()
set the focus to that tab win which most recently had it (or to the first available one)
void SelectConn(OTableConnection *pConn)
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
virtual bool suppressCrossNaturalJoin(const TTableConnectionData::value_type &_pData) const
virtual std::shared_ptr< OTableWindowData > CreateImpl(const OUString &_rComposedName, const OUString &_sTableName, const OUString &_rWinName)
OJoinDesignView * getDesignView() const
OTableWindowMap m_aTableMap
virtual void GetFocus() override
virtual void Tracking(const TrackingEvent &rTEvt) override
void DeselectConn(OTableConnection *pConn)
std::vector< VclPtr< OTableConnection > > m_vTableConnection
VclPtr< OJoinDesignView > m_pView
bool ScrollPane(tools::Long nDelta, bool bHoriz, bool bPaintScrollBars)
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
virtual void ConnDoubleClicked(VclPtr< OTableConnection > &rConnection)
const Size & getRealOutputSize() const
sal_Int64 GetTabWinCount() const
bool isMovementAllowed(const Point &_rPoint, const Size &_rSize)
check if the given window is visible.
VclPtr< OTableConnection > & GetSelectedConn()
virtual void RemoveTabWin(OTableWindow *pTabWin)
void SetDefaultTabWinPosSize(OTableWindow *pTabWin)
virtual bool PreNotify(NotifyEvent &rNEvt) override
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
tools::Rectangle m_aDragRect
void DrawConnections(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
virtual void dragFinished() override
called when a drag operation done with a Transferable has been finished
ScrollAdaptor & GetHScrollBar()
void invalidateAndModify(std::unique_ptr< SfxUndoAction > _pAction)
invalidates this window without children and set the controller modified
OTableConnection * GetTabConn(const OTableWindow *pLhs, const OTableWindow *pRhs, bool _bSuppressCrossOrNaturalJoin=false) const
OJoinTableView(vcl::Window *pParent, OJoinDesignView *pView)
void addConnection(OTableConnection *_pConnection, bool _bAddData=true)
allows to add new connections to join table view
virtual void lookForUiActivities()
virtual void StateChanged(StateChangedType nStateChange) override
OTableWindowMap & GetTabWinMap()
virtual void AddTabWin(const OUString &_rComposedName, const OUString &rWinName, bool bNewTable=false)
virtual void onNoColumns_throw()
called when init fails at the tablewindowdata because the m_xTable object could not provide columns,...
virtual void MouseButtonUp(const MouseEvent &rEvt) override
const TTableConnectionData::value_type & GetData() const
void InvalidateConnection()
OTableWindow * GetDestWin() const
OTableWindow * GetSourceWin() const
const std::vector< std::unique_ptr< OConnectionLine > > & GetConnLineList() const
int GetEntryFromText(std::u16string_view rEntryText)
const weld::TreeView & get_widget() const
const TTableWindowData::value_type & GetData() const
void SetPosPixel(const Point &rNewPos) override
OUString const & GetWinName() const
void clearListBox()
clears the listbox inside.
const VclPtr< OTableWindowListBox > & GetListBox() const
void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
OUString const & GetComposedName() const
void Merge(const Font &rFont)
sal_uInt16 GetCode() const
virtual void dispose() override
void SetUpdateMode(bool bUpdate)
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
vcl::Window * GetParent() const
virtual void StateChanged(StateChangedType nStateChange)
bool HasChildPathFocus(bool bSystemWindow=false) const
bool IsControlFont() const
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
void SetZoomedPointFont(vcl::RenderContext &rRenderContext, const vcl::Font &rFont)
virtual void SetSizePixel(const Size &rNewSize)
virtual void Command(const CommandEvent &rCEvt)
tools::Long CalcZoom(tools::Long n) const
virtual void MouseButtonDown(const MouseEvent &rMEvt)
virtual Point GetPosPixel() const
const Fraction & GetZoom() const
const AllSettings & GetSettings() const
virtual void MouseButtonUp(const MouseEvent &rMEvt)
virtual void KeyInput(const KeyEvent &rKEvt)
void ShowTracking(const tools::Rectangle &rRect, ShowTrackFlags nFlags=ShowTrackFlags::Small)
virtual bool PreNotify(NotifyEvent &rNEvt)
vcl::Font GetControlFont() const
::OutputDevice const * GetOutDev() const
void SetAccessibleRole(sal_uInt16 nRole)
Point PixelToLogic(const Point &rDevicePt) const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
virtual void SetPointer(PointerStyle)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Point ScreenToOutputPixel(const Point &rPos) const
virtual void scroll_to_row(int row)=0
virtual void select(int pos)=0
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_DELETE
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
std::vector< std::shared_ptr< OTableConnectionData > > TTableConnectionData
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
const tools::Long nScrollX
const tools::Long nScrollY