diff options
author | Ocke Janssen <oj@openoffice.org> | 2002-02-06 07:15:30 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2002-02-06 07:15:30 +0000 |
commit | 78029666b972020ced2c3c31fcb401d9159c707d (patch) | |
tree | c181d1ff00ebc9b31ab097cea43baa509261b0bf /dbaccess/source/ui/querydesign | |
parent | e31dcc276b3f0851338593c0dc9d42f022d736df (diff) |
#96957# new handling inserted for context menu and accessibility
Diffstat (limited to 'dbaccess/source/ui/querydesign')
17 files changed, 881 insertions, 667 deletions
diff --git a/dbaccess/source/ui/querydesign/ConnectionLine.cxx b/dbaccess/source/ui/querydesign/ConnectionLine.cxx index 6ff0c7a895f9..b2236767aead 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLine.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLine.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ConnectionLine.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-10-08 07:26:32 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,6 +87,81 @@ using namespace dbaui; const long DESCRIPT_LINE_WIDTH = 15; const long HIT_SENSITIVE_RADIUS = 5; + +namespace +{ + /** calcRect creates a new rectangle with the given points + @param _rBase the base point + @param _aVector the vector which will be added + */ + inline Rectangle calcRect(const Point& _rBase,const Point& _aVector) + { + return Rectangle( _rBase - _aVector, _rBase + _aVector ); + } + // ----------------------------------------------------------------------------- + /** GetTextPos calculate the rectangle for the connection to be drawn + @param _pWin the table window where to draw it + @param _aConnPos the connection point + @param _aDescrLinePos the description line pos + */ + Rectangle GetTextPos(const OTableWindow* _pWin, const Point& _aConnPos,const Point& _aDescrLinePos) + { + OTableWindowListBox* pListBox = _pWin ? _pWin->GetListBox() : NULL; + DBG_ASSERT(_pWin && pListBox, "OConnectionLine::GetSourceTextPos : invalid call !"); + + long nRowHeight = pListBox->GetEntryHeight(); + + Rectangle aReturn; + aReturn.Top() = _aConnPos.Y() - nRowHeight; + aReturn.Bottom() = aReturn.Top() + nRowHeight; + if (_aDescrLinePos.X() < _aConnPos.X()) + { + aReturn.Left() = _aDescrLinePos.X(); + aReturn.Right() = aReturn.Left() + _aConnPos.X() - _aDescrLinePos.X(); + } + else + { + aReturn.Left() = _aConnPos.X(); + aReturn.Right() = aReturn.Left() + _aDescrLinePos.X() - _aConnPos.X(); + } + + return aReturn; + } + // ----------------------------------------------------------------------------- + /** calcPointsYValue calculate the points Y value in relation to the listbox entry + @param _pWin the corresponding window + @param _pEntry the source or dest entry + @param _rNewConPos (in/out) the connection pos + @param _rNewDescrPos (in/out) the description pos + */ + void calcPointsYValue(const OTableWindow* _pWin,SvLBoxEntry* _pEntry,Point& _rNewConPos,Point& _rNewDescrPos) + { + const OTableWindowListBox* pListBox = _pWin->GetListBox(); + long nRowHeight = pListBox->GetEntryHeight(); + + _rNewConPos.Y() = _pWin->GetPosPixel().Y(); + _rNewConPos.Y() += pListBox->GetPosPixel().Y(); + long nEntryPos = pListBox->GetEntryPos( _pEntry ).Y(); + + if( nEntryPos >= 0 ) + { + _rNewConPos.Y() += nEntryPos; + _rNewConPos.Y() += (long)( 0.5 * nRowHeight ); + } + else + _rNewConPos.Y() -= (long)( 0.5 * nRowHeight ); + + long nListBoxBottom = _pWin->GetPosPixel().Y() + + pListBox->GetPosPixel().Y() + + pListBox->GetSizePixel().Height(); + if( _rNewConPos.Y() > nListBoxBottom ) + _rNewConPos.Y() = nListBoxBottom + 2; + + _rNewDescrPos.Y() = _rNewConPos.Y(); + } + // ----------------------------------------------------------------------------- +} + //======================================================================== // class OConnectionLine //======================================================================== @@ -111,8 +186,6 @@ OConnectionLine::OConnectionLine( OTableConnection* _pConn, const String& _rSour { DBG_CTOR(OConnectionLine,NULL); m_pData = new OConnectionLineData( _rSourceFieldName,_rDestFieldName); -// m_pData->SetSourceFieldName( _rSourceFieldName ); -// m_pData->SetDestFieldName( _rDestFieldName ); } //------------------------------------------------------------------------ @@ -133,33 +206,31 @@ OConnectionLine::~OConnectionLine() void OConnectionLine::SetSourceFieldName( const String& rSourceFieldName ) { m_pData->SetSourceFieldName( rSourceFieldName ); -// m_pSourceEntry = m_pTabConn->GetSourceWin()->GetListBox()->GetEntryFromText( rSourceFieldName ); } //------------------------------------------------------------------------ void OConnectionLine::SetDestFieldName( const String& rDestFieldName ) { m_pData->SetDestFieldName( rDestFieldName ); -// m_pDestEntry = m_pTabConn->GetDestWin()->GetListBox()->GetEntryFromText( rDestFieldName ); } //------------------------------------------------------------------------ OConnectionLine& OConnectionLine::operator=( const OConnectionLine& rLine ) { - if( &rLine == this ) - return *this; - - // da mir die Daten nicht gehoeren, loesche ich die alten nicht - m_pData->CopyFrom(*rLine.GetData()); - // CopyFrom ist virtuell, damit ist es kein Problem, wenn m_pData von einem von OTableConnectionData abgeleiteten Typ ist - - m_pTabConn = rLine.m_pTabConn; - m_pSourceEntry = rLine.m_pSourceEntry; - m_pDestEntry = rLine.m_pDestEntry; - m_aSourceConnPos = rLine.m_aSourceConnPos; - m_aDestConnPos = rLine.m_aDestConnPos; - m_aSourceDescrLinePos = rLine.m_aSourceDescrLinePos; - m_aDestDescrLinePos = rLine.m_aDestDescrLinePos; + if( &rLine != this ) + { + // da mir die Daten nicht gehoeren, loesche ich die alten nicht + m_pData->CopyFrom(*rLine.GetData()); + // CopyFrom ist virtuell, damit ist es kein Problem, wenn m_pData von einem von OTableConnectionData abgeleiteten Typ ist + + m_pTabConn = rLine.m_pTabConn; + m_pSourceEntry = rLine.m_pSourceEntry; + m_pDestEntry = rLine.m_pDestEntry; + m_aSourceConnPos = rLine.m_aSourceConnPos; + m_aDestConnPos = rLine.m_aDestConnPos; + m_aSourceDescrLinePos = rLine.m_aSourceDescrLinePos; + m_aDestDescrLinePos = rLine.m_aDestDescrLinePos; + } return *this; } @@ -177,16 +248,6 @@ BOOL OConnectionLine::Connect( const String& rSourceFieldName, const String& rDe m_pData->SetSourceFieldName( rSourceFieldName ); m_pData->SetDestFieldName( rDestFieldName ); - ////////////////////////////////////////////////////////////////////// - // Entries setzen -/* m_pSourceEntry = m_pTabConn->GetSourceWin()->GetListBox()->GetEntryFromText( rSourceFieldName ); - if( !m_pSourceEntry ) - return FALSE; - m_pDestEntry = m_pTabConn->GetDestWin()->GetListBox()->GetEntryFromText( rDestFieldName ); - if( !m_pDestEntry ) - return FALSE; -*/ - return TRUE; } @@ -237,7 +298,20 @@ Rectangle OConnectionLine::GetBoundingRect() return aBoundingRect; } - +// ----------------------------------------------------------------------------- +void calcPointX1(const OTableWindow* _pWin,Point& _rNewConPos,Point& _rNewDescrPos) +{ + _rNewConPos.X() = _pWin->GetPosPixel().X() + _pWin->GetSizePixel().Width(); + _rNewDescrPos.X() = _rNewConPos.X(); + _rNewConPos.X() += DESCRIPT_LINE_WIDTH; +} +// ----------------------------------------------------------------------------- +void calcPointX2(const OTableWindow* _pWin,Point& _rNewConPos,Point& _rNewDescrPos) +{ + _rNewConPos.X() = _pWin->GetPosPixel().X(); + _rNewDescrPos.X() = _rNewConPos.X(); + _rNewConPos.X() -= DESCRIPT_LINE_WIDTH; +} //------------------------------------------------------------------------ BOOL OConnectionLine::RecalcLine() { @@ -262,133 +336,37 @@ BOOL OConnectionLine::RecalcLine() aSourceCenter.X() = pSourceWin->GetPosPixel().X() + (long)( 0.5*pSourceWin->GetSizePixel().Width() ); aDestCenter.X() = pDestWin->GetPosPixel().X() + (long)( 0.5*pDestWin->GetSizePixel().Width() ); - if( aDestCenter.X()>aSourceCenter.X() ) - { - ////////////////////////////////////////////////////////////////////// - // DestWin liegt rechts vom SourceWin - m_aSourceConnPos.X() = pSourceWin->GetPosPixel().X()+pSourceWin->GetSizePixel().Width(); - m_aSourceDescrLinePos.X() = m_aSourceConnPos.X(); - m_aSourceConnPos.X() += DESCRIPT_LINE_WIDTH; - - m_aDestConnPos.X() = pDestWin->GetPosPixel().X(); - m_aDestDescrLinePos.X() = m_aDestConnPos.X(); - m_aDestConnPos.X() -= DESCRIPT_LINE_WIDTH; - } - else - { - ////////////////////////////////////////////////////////////////////// - // DestWin liegt links vom SourceWin - m_aSourceConnPos.X() = pSourceWin->GetPosPixel().X(); - m_aSourceDescrLinePos.X() = m_aSourceConnPos.X(); - m_aSourceConnPos.X() -= DESCRIPT_LINE_WIDTH; - - m_aDestConnPos.X() = pDestWin->GetPosPixel().X()+pDestWin->GetSizePixel().Width(); - m_aDestDescrLinePos.X() = m_aDestConnPos.X(); - m_aDestConnPos.X() += DESCRIPT_LINE_WIDTH; - } - ////////////////////////////////////////////////////////////////////// - // aSourceConnPosY bestimmen - OTableWindowListBox* pListBox = pSourceWin->GetListBox(); - long nRowHeight = pListBox->GetEntryHeight(); - - m_aSourceConnPos.Y() = pSourceWin->GetPosPixel().Y(); - m_aSourceConnPos.Y() += pListBox->GetPosPixel().Y(); - long nEntryPos = pListBox->GetEntryPos( m_pSourceEntry ).Y(); - - if( nEntryPos >= 0 ) + const OTableWindow* pFirstWin = pDestWin; + const OTableWindow* pSecondWin = pSourceWin; + Point* pFirstConPos = &m_aDestConnPos; + Point* pFirstDescrPos = &m_aDestDescrLinePos; + Point* pSecondConPos = &m_aSourceConnPos; + Point* pSecondDescrPos = &m_aSourceDescrLinePos; + if( aDestCenter.X() > aSourceCenter.X() ) { - m_aSourceConnPos.Y() += nEntryPos; - m_aSourceConnPos.Y() += (long)( 0.5 * nRowHeight ); + pFirstWin = pSourceWin; + pSecondWin = pDestWin; + pFirstConPos = &m_aSourceConnPos; + pFirstDescrPos = &m_aSourceDescrLinePos; + pSecondConPos = &m_aDestConnPos; + pSecondDescrPos = &m_aDestDescrLinePos; } - else - m_aSourceConnPos.Y() -= (long)( 0.5 * nRowHeight ); - long nListBoxBottom = pSourceWin->GetPosPixel().Y() - +pListBox->GetPosPixel().Y() - +pListBox->GetSizePixel().Height(); - if( m_aSourceConnPos.Y() > nListBoxBottom ) - m_aSourceConnPos.Y() = nListBoxBottom + 2; + calcPointX1(pFirstWin,*pFirstConPos,*pFirstDescrPos); + calcPointX2(pSecondWin,*pSecondConPos,*pSecondDescrPos); - m_aSourceDescrLinePos.Y() = m_aSourceConnPos.Y(); + ////////////////////////////////////////////////////////////////////// + // aSourceConnPosY bestimmen + calcPointsYValue(pSourceWin,m_pSourceEntry,m_aSourceConnPos,m_aSourceDescrLinePos); ////////////////////////////////////////////////////////////////////// // aDestConnPosY bestimmen - pListBox = pDestWin->GetListBox(); - - m_aDestConnPos.Y() = pDestWin->GetPosPixel().Y(); - m_aDestConnPos.Y() += pListBox->GetPosPixel().Y(); - nEntryPos = pListBox->GetEntryPos( m_pDestEntry ).Y(); - if( nEntryPos >= 0 ) - { - m_aDestConnPos.Y() += nEntryPos; - m_aDestConnPos.Y() += (long)( 0.5 * nRowHeight ); - } - else - m_aDestConnPos.Y() -= (long)( 0.5 * nRowHeight ); - - nListBoxBottom = pDestWin->GetPosPixel().Y() - +pListBox->GetPosPixel().Y() - +pListBox->GetSizePixel().Height(); - if( m_aDestConnPos.Y() > nListBoxBottom ) - m_aDestConnPos.Y() = nListBoxBottom + 2; - - m_aDestDescrLinePos.Y() = m_aDestConnPos.Y(); + calcPointsYValue(pDestWin,m_pDestEntry,m_aDestConnPos,m_aDestDescrLinePos); return TRUE; } - -//------------------------------------------------------------------------ -Rectangle OConnectionLine::GetSourceTextPos() const -{ - const OTableWindow* pDestWin = m_pTabConn->GetDestWin(); - OTableWindowListBox* pListBox = pDestWin ? pDestWin->GetListBox() : NULL; - DBG_ASSERT(pDestWin && pListBox, "OConnectionLine::GetSourceTextPos : invalid call !"); - - long nRowHeight = pListBox->GetEntryHeight(); - - Rectangle aReturn; - aReturn.Top() = m_aSourceConnPos.Y() - nRowHeight; - aReturn.Bottom() = aReturn.Top() + nRowHeight; - if (m_aSourceDescrLinePos.X() < m_aSourceConnPos.X()) - { - aReturn.Left() = m_aSourceDescrLinePos.X(); - aReturn.Right() = aReturn.Left() + m_aSourceConnPos.X() - m_aSourceDescrLinePos.X(); - } - else - { - aReturn.Left() = m_aSourceConnPos.X(); - aReturn.Right() = aReturn.Left() + m_aSourceDescrLinePos.X() - m_aSourceConnPos.X(); - } - - return aReturn; -} - -//------------------------------------------------------------------------ -Rectangle OConnectionLine::GetDestTextPos() const -{ - const OTableWindow* pSourceWin = m_pTabConn->GetSourceWin(); - OTableWindowListBox* pListBox = pSourceWin ? pSourceWin->GetListBox() : NULL; - DBG_ASSERT(pSourceWin && pListBox, "OConnectionLine::GetSourceTextPos : invalid call !"); - - long nRowHeight = pListBox->GetEntryHeight(); - - Rectangle aReturn; - aReturn.Top() = m_aDestConnPos.Y() - nRowHeight; - aReturn.Bottom() = aReturn.Top() + nRowHeight; - if (m_aDestDescrLinePos.X() < m_aDestConnPos.X()) - { - aReturn.Left() = m_aDestDescrLinePos.X(); - aReturn.Right() = aReturn.Left() + m_aDestConnPos.X() - m_aDestDescrLinePos.X(); - } - else - { - aReturn.Left() = m_aDestConnPos.X(); - aReturn.Right() = aReturn.Left() + m_aDestDescrLinePos.X() - m_aDestConnPos.X(); - } - - return aReturn; -} +// ----------------------------------------------------------------------------- //------------------------------------------------------------------------ void OConnectionLine::Draw( OutputDevice* pOutDev ) @@ -425,26 +403,24 @@ void OConnectionLine::Draw( OutputDevice* pOutDev ) xOffset = 0; yOffset = 1; } - pOutDev->DrawLine(m_aSourceConnPos + Point(-xOffset, -yOffset), m_aDestConnPos + Point(-xOffset, -yOffset)); - pOutDev->DrawLine(m_aSourceConnPos + Point(xOffset, yOffset), m_aDestConnPos + Point(xOffset, yOffset)); + + Point aPos1(-xOffset, -yOffset); + Point aPos2(xOffset, yOffset); + pOutDev->DrawLine(m_aSourceConnPos + aPos1, m_aDestConnPos + aPos1); + pOutDev->DrawLine(m_aSourceConnPos + aPos2, m_aDestConnPos + aPos2); } ////////////////////////////////////////////////////////////////////// - // Zeichnen der Verbindungs-Rechtecke -// pOutDev->SetLineColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor()); - Rectangle aSourceRect( m_aSourceDescrLinePos-Point(nRectSize,nRectSize), - m_aSourceDescrLinePos+Point(nRectSize,nRectSize) ); - - Rectangle aDestRect( m_aDestDescrLinePos-Point(nRectSize,nRectSize), - m_aDestDescrLinePos+Point(nRectSize,nRectSize) ); + // draw the connection rectangles pOutDev->SetFillColor(Application::GetSettings().GetStyleSettings().GetWindowColor()); - pOutDev->DrawRect( aSourceRect ); - pOutDev->DrawRect( aDestRect ); -} -//------------------------------------------------------------------------ -BOOL OConnectionLine::IsValid() + Point aVector(nRectSize,nRectSize); + pOutDev->DrawRect( calcRect(m_aSourceDescrLinePos,aVector) ); + pOutDev->DrawRect( calcRect( m_aDestDescrLinePos,aVector) ); +} +// ----------------------------------------------------------------------------- +BOOL OConnectionLine::IsValid() const { return m_pData.isValid() && m_pData->IsValid(); } @@ -483,5 +459,24 @@ bool OConnectionLine::CheckHit( const Point& rMousePos ) const return false; } // ----------------------------------------------------------------------------- +Rectangle OConnectionLine::GetSourceTextPos() const +{ + return GetTextPos(m_pTabConn->GetSourceWin(),m_aSourceConnPos,m_aSourceDescrLinePos); +} +// ----------------------------------------------------------------------------- +Rectangle OConnectionLine::GetDestTextPos() const +{ + return GetTextPos(m_pTabConn->GetDestWin(),m_aDestConnPos,m_aDestDescrLinePos); +} +// ----------------------------------------------------------------------------- +Point OConnectionLine::getMidPoint() const +{ + Point aDest = m_aDestConnPos - m_aSourceConnPos; + aDest.X() *= 0.5; + aDest.Y() *= 0.5; + + return m_aSourceConnPos + aDest; +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/ConnectionLineData.cxx b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx index d43f57088455..ebcf5f11a83d 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLineData.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ConnectionLineData.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-10-08 07:26:32 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -106,7 +106,7 @@ void OConnectionLineData::CopyFrom(const OConnectionLineData& rSource) } //------------------------------------------------------------------------ -BOOL OConnectionLineData::IsValid() +bool OConnectionLineData::IsValid() const { return (GetSourceFieldName().getLength() && GetDestFieldName().getLength()); } @@ -124,9 +124,10 @@ OConnectionLineData& OConnectionLineData::operator=( const OConnectionLineData& } //------------------------------------------------------------------------ -void OConnectionLineData::Reset() +bool OConnectionLineData::Reset() { m_aDestFieldName = m_aSourceFieldName = ::rtl::OUString(); + return true; } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 230c8a47d95d..b48bc3d4f9aa 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: JoinTableView.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: oj $ $Date: 2001-11-09 08:30:00 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,13 +118,19 @@ #ifndef DBAUI_TABLEWINDOWDATA_HXX #include "TableWindowData.hxx" #endif - +#ifndef DBACCESS_JACCESS_HXX +#include "JAccess.hxx" +#endif +#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_ +#include <drafts/com/sun/star/accessibility/XAccessible.hpp> +#endif #include <algorithm> #include <functional> using namespace dbaui; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; +using namespace ::drafts::com::sun::star::accessibility; const long LINE_SIZE = 50; DBG_NAME(OScrollWindowHelper); @@ -246,6 +252,9 @@ OJoinTableView::~OJoinTableView() // Listen loeschen clearLayoutInformation(); + m_pLastFocusTabWin = NULL; + m_pSelectedConn = NULL; + m_aTableMap.clear(); // den Undo-Manager des Dokuments leeren (da die UndoActions sich eventuell TabWins von mir halten, das gibt sonst eine // Assertion in Window::~Window) m_pView->getController()->getUndoMgr()->Clear(); @@ -267,7 +276,7 @@ void OJoinTableView::Resize() m_aOutputSize = GetSizePixel(); // tab win positions may not be up-to-date - if (!m_aTableMap.size()) + if (m_aTableMap.empty()) // no tab wins ... return; @@ -315,6 +324,7 @@ BOOL OJoinTableView::RemoveConnection( OTableConnection* pConn ) m_pView->getController()->removeConnectionData( ::std::auto_ptr<OTableConnectionData>(pConn->GetData()) ); m_vTableConnection.erase( ::std::find(m_vTableConnection.begin(),m_vTableConnection.end(),pConn) ); + delete pConn; pConn = NULL; return TRUE; @@ -362,6 +372,7 @@ void OJoinTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rt m_pView->getController()->setModified( sal_True ); m_pView->getController()->InvalidateFeature(ID_BROWSER_ADDTABLE); + m_pView->getController()->InvalidateFeature(ID_REALTION_ADD_RELATION); } else { @@ -419,8 +430,8 @@ void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin ) if(bRemove && (sal_Int32)m_aTableMap.size() < (nCount-1)) // if some connections could be removed { m_pView->getController()->setModified( sal_True ); - m_pView->getController()->InvalidateFeature( ID_BROWSER_SAVEDOC ); m_pView->getController()->InvalidateFeature(ID_BROWSER_ADDTABLE); + m_pView->getController()->InvalidateFeature(ID_REALTION_ADD_RELATION); } } @@ -599,7 +610,7 @@ void OJoinTableView::BeginChildMove( OTableWindow* pTabWin, const Point& rMouseP m_pDragWin = pTabWin; SetPointer(Pointer(POINTER_MOVE)); Point aMousePos = ScreenToOutputPixel( rMousePos ); - m_aDragOffset = aMousePos-pTabWin->GetPosPixel(); + m_aDragOffset = aMousePos - pTabWin->GetPosPixel(); m_pDragWin->SetZOrder(NULL, WINDOW_ZORDER_FIRST); m_bTrackingInitiallyMoved = FALSE; StartTracking(); @@ -748,32 +759,21 @@ void OJoinTableView::Tracking( const TrackingEvent& rTEvt ) // erst mal testen, ob ich mich ueberhaupt bewegt habe // (das verhindert das Setzen des modified-Flags, wenn sich eigentlich gar nichts getan hat) OTableWindowData* pData = m_pDragWin->GetData(); - if (pData && pData->HasPosition() && (pData->GetPosition() == aDragWinPos)) + if ( ! (pData && pData->HasPosition() && (pData->GetPosition() == aDragWinPos))) { - m_pDragWin = NULL; - SetPointer(Pointer(POINTER_ARROW)); - return; - } - - // die alten logischen Koordinaten - Point ptOldPos = m_pDragWin->GetPosPixel() + Point(GetHScrollBar()->GetThumbPos(), GetVScrollBar()->GetThumbPos()); - // neu positionieren - m_pDragWin->SetPosPixel(aDragWinPos); - TabWinMoved(m_pDragWin, ptOldPos); + // die alten logischen Koordinaten + Point ptOldPos = m_pDragWin->GetPosPixel() + Point(GetHScrollBar()->GetThumbPos(), GetVScrollBar()->GetThumbPos()); + // neu positionieren + m_pDragWin->SetPosPixel(aDragWinPos); + TabWinMoved(m_pDragWin, ptOldPos); - Invalidate(INVALIDATE_NOCHILDREN); - - m_pDragWin->GrabFocus(); + m_pDragWin->GrabFocus(); + } m_pDragWin = NULL; SetPointer(Pointer(POINTER_ARROW)); - - m_pView->getController()->setModified( sal_True ); - m_pView->getController()->InvalidateFeature( ID_BROWSER_SAVEDOC ); - return; } - ////////////////////////////////////////////////////////////////////// - // Position des Childs nach Sizing anpassen - if( m_pSizingWin ) + // else we handle the resizing + else if( m_pSizingWin ) { SetPointer( Pointer() ); EndTracking(); @@ -788,12 +788,6 @@ void OJoinTableView::Tracking( const TrackingEvent& rTEvt ) m_pSizingWin->Invalidate( m_aSizingRect ); m_pSizingWin = NULL; - - Invalidate(INVALIDATE_NOCHILDREN); - - m_pView->getController()->setModified( sal_True ); - m_pView->getController()->InvalidateFeature( ID_BROWSER_SAVEDOC ); - return; } } else if (rTEvt.IsTrackingCanceled()) @@ -801,7 +795,8 @@ void OJoinTableView::Tracking( const TrackingEvent& rTEvt ) if (m_aDragScrollTimer.IsActive()) m_aDragScrollTimer.Stop(); EndTracking(); - }else + } + else { if( m_pDragWin ) { @@ -1023,19 +1018,25 @@ void OJoinTableView::DrawConnections( const Rectangle& rRect ) //------------------------------------------------------------------------------ +::std::vector<OTableConnection*>::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const +{ + return ::std::find_if( m_vTableConnection.begin(), + m_vTableConnection.end(), + ::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin)); +} +// ----------------------------------------------------------------------------- +sal_Int32 OJoinTableView::getConnectionCount(const OTableWindow* _pFromWin) const +{ + return ::std::count_if( m_vTableConnection.begin(), + m_vTableConnection.end(), + ::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin)); +} +//------------------------------------------------------------------------------ BOOL OJoinTableView::ExistsAConn(const OTableWindow* pFrom) const { DBG_CHKTHIS(OJoinTableView,NULL); - ::std::vector<OTableConnection*>::const_iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) - { - if (pFrom == (*aIter)->GetSourceWin() || pFrom == (*aIter)->GetDestWin()) - break; - } - - return (aIter != m_vTableConnection.end()); + return getTableConnections(pFrom) != m_vTableConnection.end(); } - //------------------------------------------------------------------------ void OJoinTableView::ClearAll() { @@ -1050,7 +1051,8 @@ void OJoinTableView::ClearAll() RemoveConnection(*aIter); m_vTableConnection.clear(); - m_pLastFocusTabWin = NULL; + m_pLastFocusTabWin = NULL; + m_pSelectedConn = NULL; // scroll to the upper left Scroll(-GetScrollOffset().X(), TRUE, TRUE); @@ -1142,7 +1144,12 @@ IMPL_LINK(OJoinTableView, OnDragScrollTimer, void*, EMPTYARG) ScrollWhileDragging(); return 0L; } - +// ----------------------------------------------------------------------------- +void OJoinTableView::invalidateAndModify(SfxUndoAction *_pAction) +{ + Invalidate(INVALIDATE_NOCHILDREN); + m_pView->getController()->addUndoActionAndInvalidate(_pAction); +} //------------------------------------------------------------------------ void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition) { @@ -1150,9 +1157,7 @@ void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPositi Point ptThumbPos(GetHScrollBar()->GetThumbPos(), GetVScrollBar()->GetThumbPos()); ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel() + ptThumbPos); - SfxUndoAction* pUndoAction = new OJoinMoveTabWinUndoAct(this, ptOldPosition, ptWhich); - m_pView->getController()->getUndoMgr()->AddUndoAction(pUndoAction); - m_pView->getController()->InvalidateFeature(ID_BROWSER_UNDO); + invalidateAndModify(new OJoinMoveTabWinUndoAct(this, ptOldPosition, ptWhich)); } //------------------------------------------------------------------------ @@ -1162,9 +1167,7 @@ void OJoinTableView::TabWinSized(OTableWindow* ptWhich, const Point& ptOldPositi ptWhich->GetData()->SetSize(ptWhich->GetSizePixel()); ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel()); - SfxUndoAction* pUndoAction = new OJoinSizeTabWinUndoAct(this, ptOldPosition, szOldSize, ptWhich); - m_pView->getController()->getUndoMgr()->AddUndoAction(pUndoAction); - m_pView->getController()->InvalidateFeature(ID_BROWSER_UNDO); + invalidateAndModify(new OJoinSizeTabWinUndoAct(this, ptOldPosition, szOldSize, ptWhich)); } //------------------------------------------------------------------------------ @@ -1199,6 +1202,20 @@ BOOL OJoinTableView::IsAddAllowed() return TRUE; } +// ----------------------------------------------------------------------------- +void OJoinTableView::executePopup(const Point& _aPos,OTableConnection* _pSelConnection) +{ + PopupMenu aContextMenu(ModuleRes(RID_QUERYCOLPOPUPMENU)); + switch (aContextMenu.Execute(this, _aPos)) + { + case SID_DELETE: + RemoveConnection(_pSelConnection); + break; + case ID_QUERY_EDIT_JOINCONNECTION: + ConnDoubleClicked(_pSelConnection); // is the same as double clicked + break; + } +} //------------------------------------------------------------------------------ void OJoinTableView::Command(const CommandEvent& rEvt) { @@ -1210,33 +1227,36 @@ void OJoinTableView::Command(const CommandEvent& rEvt) { case COMMAND_CONTEXTMENU: { - if (!rEvt.IsMouseEvent()) - { - Window::Command(rEvt); - return; - } - if( m_vTableConnection.empty() ) return; - DeselectConn(GetSelectedConn()); - ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) + OTableConnection* pSelConnection = GetSelectedConn(); + // when it wasn't a mouse event use the selected connection + if (!rEvt.IsMouseEvent()) + { + if( pSelConnection ) + { + const ::std::vector<OConnectionLine*>* pLines = pSelConnection->GetConnLineList(); + ::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(pLines->begin(),pLines->end(),::std::mem_fun(&OConnectionLine::IsValid)); + if( aIter != pLines->end() ) + executePopup((*aIter)->getMidPoint(),pSelConnection); + } + } + else { - if( (*aIter)->CheckHit(rEvt.GetMousePosPixel()) ) + DeselectConn(pSelConnection); + + const Point& aMousePos = rEvt.GetMousePosPixel(); + ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); + for(;aIter != m_vTableConnection.end();++aIter) { - SelectConn((*aIter)); - if(!getDesignView()->getController()->isReadOnly() && getDesignView()->getController()->isConnected()) + if( (*aIter)->CheckHit(aMousePos) ) { - PopupMenu aContextMenu(ModuleRes(RID_QUERYCOLPOPUPMENU)); - switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel())) - { - case SID_DELETE: - RemoveConnection((*aIter)); - break; - } + SelectConn(*aIter); + if(!getDesignView()->getController()->isReadOnly() && getDesignView()->getController()->isConnected()) + executePopup(rEvt.GetMousePosPixel(),*aIter); + break; } - break; } } bHandled = TRUE; @@ -1247,7 +1267,7 @@ void OJoinTableView::Command(const CommandEvent& rEvt) } //------------------------------------------------------------------------------ -OTableConnection* OJoinTableView::GetTabConn(OTableWindow* pLhs,OTableWindow* pRhs, OTableConnection* _rpFirstAfter) +OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,const OTableConnection* _rpFirstAfter) const { OTableConnection* pConn = NULL; DBG_ASSERT(pRhs || pLhs, "OJoinTableView::GetTabConn : invalid args !"); @@ -1257,7 +1277,7 @@ OTableConnection* OJoinTableView::GetTabConn(OTableWindow* pLhs,OTableWindow* pR { BOOL bFoundStart = _rpFirstAfter ? FALSE : TRUE; - ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); + ::std::vector<OTableConnection*>::const_iterator aIter = m_vTableConnection.begin(); for(;aIter != m_vTableConnection.end();++aIter) { OTableConnection* pData = *aIter; @@ -1448,6 +1468,9 @@ long OJoinTableView::PreNotify(NotifyEvent& rNEvt) break; case EVENT_GETFOCUS: { + if (m_aTableMap.empty()) + // no tab wins -> no conns -> no focus change + break; Window* pSource = rNEvt.GetWindow(); if (pSource) { @@ -1588,6 +1611,23 @@ void OJoinTableView::GetFocus() // GrabTabWinFocus(); } // ----------------------------------------------------------------------------- +Reference< XAccessible > OJoinTableView::CreateAccessible() +{ + Reference< XAccessible > aRet; + if (getDesignView()->getController()) + { + Reference< XAccessible > xParent; + Window* pParent = GetParent(); + if(pParent) + xParent = pParent->GetAccessible(); + // create our VIEWPORT + aRet = new OJoinDesignViewAccess(this,xParent); + } + else + aRet = Window::CreateAccessible(); + return aRet; +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/QTableConnection.cxx b/dbaccess/source/ui/querydesign/QTableConnection.cxx index c8194ef25560..7b8eab018553 100644 --- a/dbaccess/source/ui/querydesign/QTableConnection.cxx +++ b/dbaccess/source/ui/querydesign/QTableConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QTableConnection.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-02-28 10:18:26 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,6 +67,9 @@ #ifndef DBAUI_QUERYTABLEVIEW_HXX #include "QueryTableView.hxx" #endif +#ifndef DBAUI_CONNECTIONLINE_HXX +#include "ConnectionLine.hxx" +#endif using namespace dbaui; diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx index ce3536a12d4d..b5bdc88bb24a 100644 --- a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QTableConnectionData.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-10-08 07:32:33 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -210,6 +210,11 @@ OTableConnectionData* OQueryTableConnectionData::NewInstance() const return new OQueryTableConnectionData(); } // ----------------------------------------------------------------------------- +BOOL OQueryTableConnectionData::Update() +{ + return TRUE; +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx index afea3b370b72..ce5575329203 100644 --- a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx +++ b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx @@ -2,9 +2,9 @@ * * $RCSfile: QTableConnectionData.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-10-08 07:32:33 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,6 +100,7 @@ namespace dbaui virtual OConnectionLineDataRef CreateLineDataObj(); virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData ); + OQueryTableConnectionData& operator=( const OQueryTableConnectionData& rConnData ); public: TYPEINFO(); OQueryTableConnectionData(); @@ -111,7 +112,12 @@ namespace dbaui virtual void CopyFrom(const OTableConnectionData& rSource); virtual OTableConnectionData* NewInstance() const; - OQueryTableConnectionData& operator=( const OQueryTableConnectionData& rConnData ); + + /** Update create a new connection + + @return true if successful + */ + virtual BOOL Update(); ::rtl::OUString GetTableName(EConnectionSide nWhich) const; ::rtl::OUString GetAliasName(EConnectionSide nWhich) const; diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx index 4126d7280b4e..5031055a6c62 100644 --- a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx +++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryTabConnUndoAction.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-08-27 14:24:23 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,6 +89,7 @@ OQueryTabConnUndoAction::~OQueryTabConnUndoAction() DBG_DTOR(OQueryTabConnUndoAction,NULL); if (m_bOwnerOfConn) { // ich besitze die Connection -> loeschen + m_pOwner->DeselectConn(m_pConnection); delete m_pConnection->GetData(); delete m_pConnection; } diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx index ef5f67bb26f4..54310322a6d3 100644 --- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx +++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryTabWinUndoAct.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-08-27 14:24:23 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,6 +109,7 @@ OQueryTabWinUndoAct::~OQueryTabWinUndoAct() ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); for(;aIter != m_vTableConnection.end();++aIter) { + m_pOwner->DeselectConn(*aIter); delete (*aIter)->GetData(); delete (*aIter); } @@ -131,6 +132,8 @@ void OTabFieldSizedUndoAct::Undo() pOwner->SetColWidth(m_nColId, m_nNextWidth); m_nNextWidth = nNextWidth; } +// ----------------------------------------------------------------------------- + diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index f1a0668a4c41..c6d86b01772e 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryTableView.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-10-26 07:57:11 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -143,6 +143,9 @@ #ifndef _DBU_RESOURCE_HRC_ #include "dbu_resource.hrc" #endif +#ifndef _SV_MSGBOX_HXX +#include <vcl/msgbox.hxx> +#endif using namespace dbaui; using namespace ::com::sun::star::uno; @@ -180,6 +183,162 @@ TYPEINIT1(OQueryTableView, OJoinTableView); return aTmp; } +namespace +{ + // ----------------------------------------------------------------------------- + sal_Bool isColumnInKeyType(const Reference<XKeysSupplier>& _rxKeys,const ::rtl::OUString& _rColumnName,sal_Int32 _nKeyType) + { + sal_Bool bReturn = sal_False; + if(_rxKeys.is()) + { + Reference< XIndexAccess> xKeyIndex = _rxKeys->getKeys(); + Reference<XColumnsSupplier> xColumnsSupplier; + // search the one and only primary key + for(sal_Int32 i=0;i< xKeyIndex->getCount();++i) + { + Reference<XPropertySet> xProp; + ::cppu::extractInterface(xProp,xKeyIndex->getByIndex(i)); + if(xProp.is()) + { + sal_Int32 nKeyType = 0; + xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; + if(_nKeyType == nKeyType) + { + xColumnsSupplier = Reference<XColumnsSupplier>(xProp,UNO_QUERY); + if(xColumnsSupplier.is()) + { + Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns(); + if(xColumns.is() && xColumns->hasByName(_rColumnName)) + { + bReturn = sal_True; + break; + } + } + } + } + } + } + return bReturn; + } + // ----------------------------------------------------------------------------- + /** addTabAddUndoAction appends a new TabAdd Undo action at controller + @param _pView the view which we use + @param _pConnection the connection for which the undo action should be appended + */ + // ----------------------------------------------------------------------------- + void addTabAddUndoAction(OQueryTableView* _pView,OQueryTableConnection* _pConnection) + { + OQueryTabConnUndoAction* pUndoAction = new OQueryAddTabConnUndoAction(_pView); + pUndoAction->SetOwnership(sal_False); + pUndoAction->SetConnection(_pConnection); + _pView->getDesignView()->getController()->addUndoActionAndInvalidate(pUndoAction); + } + // ----------------------------------------------------------------------------- + /** openJoinDialog opens the join dialog with this connection data + @param _pView the view which we use + @param _pConnectionData the connection data + + @return true when OK was pressed otherwise false + */ + sal_Bool openJoinDialog(OQueryTableView* _pView,OTableConnectionData* _pConnectionData,BOOL _bSelectableTables) + { + OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pConnectionData); + + DlgQryJoin aDlg(_pView,pData,_pView->GetTabWinMap(),_pView->getDesignView()->getController()->getConnection(),_bSelectableTables); + sal_Bool bOk = aDlg.Execute() == RET_OK; + if( bOk ) + { + pData->SetJoinType(aDlg.GetJoinType()); + _pView->getDesignView()->getController()->setModified(sal_True); + } + + return bOk; + } + // ----------------------------------------------------------------------------- + /** connectionModified adds an undo action for the modified connection and forces an redraw + @param _pView the view which we use + @param _pConnection the connection which was modified + @param _bAddUndo true when an undo action should be appended + */ + void connectionModified(OQueryTableView* _pView, + OTableConnection* _pConnection, + sal_Bool _bAddUndo) + { + OSL_ENSURE(_pConnection,"Invalid connection!"); + _pConnection->UpdateLineList(); + + // add an undo action + if ( _bAddUndo ) + addTabAddUndoAction(_pView,static_cast< OQueryTableConnection*>(_pConnection)); + // redraw + _pConnection->RecalcLines(); + // force an invalidation of the bounding rectangle + _pConnection->Invalidate(); + + _pView->Invalidate(INVALIDATE_NOCHILDREN); + } + // ----------------------------------------------------------------------------- + void addConnections(OQueryTableView* _pView, + const OQueryTableWindow* _pSource, + const OQueryTableWindow* _pDest, + const Reference<XNameAccess>& _rxSourceForeignKeyColumns) + { + // we found a table in our view where we can insert some connections + // the key columns have a property called RelatedColumn + // OQueryTableConnectionData aufbauen + OQueryTableConnectionData aNewConnData( _pSource->GetTableName(), _pDest->GetTableName(), + _pSource->GetAliasName(), _pDest->GetAliasName()); + + Reference<XKeysSupplier> xReferencedKeys(_pDest->GetTable(),UNO_QUERY); + ::rtl::OUString sRelatedColumn; + + // iterate through all foreignkey columns to create the connections + Sequence< ::rtl::OUString> aElements(_rxSourceForeignKeyColumns->getElementNames()); + const ::rtl::OUString* pBegin = aElements.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aElements.getLength(); + for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i) + { + Reference<XPropertySet> xColumn; + ::cppu::extractInterface(xColumn,_rxSourceForeignKeyColumns->getByName(*pBegin)); + + aNewConnData.SetFieldType(JTCS_FROM,TAB_NORMAL_FIELD); + + xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn; + aNewConnData.SetFieldType(JTCS_TO,isColumnInKeyType(xReferencedKeys,sRelatedColumn,KeyType::PRIMARY) ? TAB_PRIMARY_FIELD : TAB_NORMAL_FIELD); + + { + Sequence< sal_Int16> aFind(::comphelper::findValue(_pSource->GetOriginalColumns()->getElementNames(),*pBegin,sal_True)); + if(aFind.getLength()) + aNewConnData.SetFieldIndex(JTCS_FROM,aFind[0]+1); + else + OSL_ENSURE(0,"Column not found!"); + } + // get the position inside the tabe + Reference<XNameAccess> xRefColumns = _pDest->GetOriginalColumns(); + if(xRefColumns.is()) + { + Sequence< sal_Int16> aFind(::comphelper::findValue(xRefColumns->getElementNames(),sRelatedColumn,sal_True)); + if(aFind.getLength()) + aNewConnData.SetFieldIndex(JTCS_TO,aFind[0]+1); + else + OSL_ENSURE(0,"Column not found!"); + } + aNewConnData.AppendConnLine(*pBegin,sRelatedColumn); + + // dann die Conn selber dazu + OQueryTableConnection aNewConn(_pView, &aNewConnData); + // der Verweis auf die lokale Variable ist unkritisch, da NotifyQueryTabConn eine neue Kopie anlegt + // und mir hinzufuegen (wenn nicht schon existent) + _pView->NotifyTabConnection(aNewConn, sal_False); + // don't create an Undo-Action for the new connection : the connection is + // covered by the Undo-Action for the tabwin, as the "Undo the insert" will + // automatically remove all connections adjacent to the win. + // (Because of this automatism we would have an ownerhsip ambiguity for + // the connection data if we would insert the conn-Undo-Action) + // FS - 21.10.99 - 69183 + } + } +} //================================================================== // class OQueryTableView //================================================================== @@ -326,29 +485,10 @@ void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn, // die neuen Daten ... OQueryTableConnectionData* pNewData = static_cast< OQueryTableConnectionData*>(rNewConn.GetData()->NewInstance()); pNewData->CopyFrom(*rNewConn.GetData()); - // ... an das Dokument anhaengen - m_pView->getController()->getTableConnectionData()->push_back(pNewData); - // ... und an eine neue OQueryTableConnection-Instanz haengen, die ich mir gleich merke OQueryTableConnection* pNewConn = new OQueryTableConnection(this, pNewData); - GetTabConnList()->push_back(pNewConn); + GetConnection(pNewConn); - // Modified-Flag - m_pView->getController()->setModified(sal_True); - - // eine Undo-Action fuer die Connection - if (_bCreateUndoAction) - { - OQueryTabConnUndoAction* pUndoAction = new OQueryAddTabConnUndoAction(this); - pUndoAction->SetOwnership(sal_False); - pUndoAction->SetConnection(pNewConn); - m_pView->getController()->getUndoMgr()->AddUndoAction(pUndoAction); - } - - // und neu zeichnen - pNewConn->RecalcLines(); - // fuer das unten folgende Invalidate muss ich dieser neuen Connection erst mal die Moeglichkeit geben, - // ihr BoundingRect zu ermitteln - pNewConn->Invalidate(); + connectionModified(this,pNewConn,_bCreateUndoAction); } } // ----------------------------------------------------------------------------- @@ -418,99 +558,6 @@ Reference<XPropertySet> getKeyReferencedTo(const Reference<XKeysSupplier>& _rxKe } return Reference<XPropertySet>(); } -// ----------------------------------------------------------------------------- -sal_Bool isColumnInKeyType(const Reference<XKeysSupplier>& _rxKeys,const ::rtl::OUString& _rColumnName,sal_Int32 _nKeyType) -{ - sal_Bool bReturn = sal_False; - if(_rxKeys.is()) - { - Reference< XIndexAccess> xKeyIndex = _rxKeys->getKeys(); - Reference<XColumnsSupplier> xColumnsSupplier; - // search the one and only primary key - for(sal_Int32 i=0;i< xKeyIndex->getCount();++i) - { - Reference<XPropertySet> xProp; - ::cppu::extractInterface(xProp,xKeyIndex->getByIndex(i)); - if(xProp.is()) - { - sal_Int32 nKeyType = 0; - xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; - if(_nKeyType == nKeyType) - { - xColumnsSupplier = Reference<XColumnsSupplier>(xProp,UNO_QUERY); - if(xColumnsSupplier.is()) - { - Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns(); - if(xColumns.is() && xColumns->hasByName(_rColumnName)) - { - bReturn = sal_True; - break; - } - } - } - } - } - } - return bReturn; -} -// ----------------------------------------------------------------------------- -void OQueryTableView::addConnections(const OQueryTableWindow* _pSource,const OQueryTableWindow* _pDest,const Reference<XNameAccess>& _rxSourceForeignKeyColumns) -{ - // we found a table in our view where we can insert some connections - // the key columns have a property called RelatedColumn - // OQueryTableConnectionData aufbauen - OQueryTableConnectionData aNewConnData( _pSource->GetTableName(), _pDest->GetTableName(), - _pSource->GetAliasName(), _pDest->GetAliasName()); - - Reference<XKeysSupplier> xReferencedKeys(_pDest->GetTable(),UNO_QUERY); - ::rtl::OUString sRelatedColumn; - - // iterate through all foreignkey columns to create the connections - Sequence< ::rtl::OUString> aElements(_rxSourceForeignKeyColumns->getElementNames()); - const ::rtl::OUString* pBegin = aElements.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aElements.getLength(); - for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i) - { - Reference<XPropertySet> xColumn; - ::cppu::extractInterface(xColumn,_rxSourceForeignKeyColumns->getByName(*pBegin)); - - aNewConnData.SetFieldType(JTCS_FROM,TAB_NORMAL_FIELD); - - xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn; - aNewConnData.SetFieldType(JTCS_TO,isColumnInKeyType(xReferencedKeys,sRelatedColumn,KeyType::PRIMARY) ? TAB_PRIMARY_FIELD : TAB_NORMAL_FIELD); - - { - Sequence< sal_Int16> aFind(::comphelper::findValue(_pSource->GetOriginalColumns()->getElementNames(),*pBegin,sal_True)); - if(aFind.getLength()) - aNewConnData.SetFieldIndex(JTCS_FROM,aFind[0]+1); - else - OSL_ENSURE(0,"Column not found!"); - } - // get the position inside the tabe - Reference<XNameAccess> xRefColumns = _pDest->GetOriginalColumns(); - if(xRefColumns.is()) - { - Sequence< sal_Int16> aFind(::comphelper::findValue(xRefColumns->getElementNames(),sRelatedColumn,sal_True)); - if(aFind.getLength()) - aNewConnData.SetFieldIndex(JTCS_TO,aFind[0]+1); - else - OSL_ENSURE(0,"Column not found!"); - } - aNewConnData.AppendConnLine(*pBegin,sRelatedColumn); - - // dann die Conn selber dazu - OQueryTableConnection aNewConn(this, &aNewConnData); - // der Verweis auf die lokale Variable ist unkritisch, da NotifyQueryTabConn eine neue Kopie anlegt - // und mir hinzufuegen (wenn nicht schon existent) - NotifyTabConnection(aNewConn, sal_False); - // don't create an Undo-Action for the new connection : the connection is - // covered by the Undo-Action for the tabwin, as the "Undo the insert" will - // automatically remove all connections adjacent to the win. - // (Because of this automatism we would have an ownerhsip ambiguity for - // the connection data if we would insert the conn-Undo-Action) - // FS - 21.10.99 - 69183 - } -} //------------------------------------------------------------------------------ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& strTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable) { @@ -602,7 +649,7 @@ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::r } } if(aIter != pTabWins->end()) - addConnections(pNewTabWin,static_cast<OQueryTableWindow*>(aIter->second),xFKeyColumns); + addConnections(this,pNewTabWin,static_cast<OQueryTableWindow*>(aIter->second),xFKeyColumns); } else if(KeyType::PRIMARY == nKeyType) { @@ -621,7 +668,7 @@ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::r OSL_ENSURE(xFKColumnsSupplier.is(),"Key isn't a column supplier"); Reference<XNameAccess> xTColumns = xFKColumnsSupplier->getColumns(); OSL_ENSURE(xTColumns.is(),"No Key columns available!"); - addConnections(pTabWinTmp,pNewTabWin,xTColumns); + addConnections(this,pTabWinTmp,pNewTabWin,xTColumns); } } } @@ -633,19 +680,13 @@ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::r } // mein Parent brauche ich, da es vom Loeschen erfahren soll - m_pView->getController()->setModified(sal_True); - - m_pView->getController()->getUndoMgr()->AddUndoAction( pUndoAction ); + m_pView->getController()->addUndoActionAndInvalidate( pUndoAction ); if (bSuccess && m_lnkTabWinsChangeHandler.IsSet()) { TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_ADDED_WIN, pNewTabWin->GetAliasName()); m_lnkTabWinsChangeHandler.Call(&aHint); } - - m_pView->getController()->InvalidateFeature(ID_BROWSER_UNDORECORD); - m_pView->getController()->InvalidateFeature(ID_BROWSER_REDO); - // GetViewShell()->GetViewShell()->UIFeatureChanged(); } //------------------------------------------------------------------------ void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) @@ -703,50 +744,55 @@ void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJ } pConn->GetData()->AppendConnLine( aSourceFieldName,aDestFieldName ); - pConn->UpdateLineList(); - // Modified-Flag - m_pView->getController()->setModified(sal_True); - // eine Undo-Action fuer die Connection - OQueryTabConnUndoAction* pUndoAction = new OQueryAddTabConnUndoAction(this); - pUndoAction->SetOwnership(sal_False); - pUndoAction->SetConnection(static_cast< OQueryTableConnection*>(pConn)); - m_pView->getController()->getUndoMgr()->AddUndoAction(pUndoAction); - - // und neu zeichnen - pConn->RecalcLines(); - // fuer das unten folgende Invalidate muss ich dieser neuen Connection erst mal die Moeglichkeit geben, - // ihr BoundingRect zu ermitteln - pConn->Invalidate(); + connectionModified(this,pConn,sal_False); } } - - -//------------------------------------------------------------------------ +// ----------------------------------------------------------------------------- void OQueryTableView::ConnDoubleClicked(OTableConnection* pConnection) { DBG_CHKTHIS(OQueryTableView,NULL); DBG_ASSERT(pConnection->ISA(OQueryTableConnection), "OQueryTableView::ConnDoubleClicked : pConnection hat falschen Typ"); // da ich nur solche selber verwende, duerfen auch nur solche hier ankommen - DlgQryJoin aDlg(this,static_cast< OQueryTableConnectionData*>(pConnection->GetData()),m_pView->getController()->getConnection()->getMetaData()); - aDlg.Execute(); - if(static_cast< OQueryTableConnectionData*>(pConnection->GetData())->GetJoinType() != aDlg.GetJoinType()) + if( openJoinDialog(this,pConnection->GetData(),FALSE) ) { - static_cast< OQueryTableConnectionData*>(pConnection->GetData())->SetJoinType(aDlg.GetJoinType()); - m_pView->getController()->setModified(sal_True); + connectionModified(this,pConnection,sal_False); + SelectConn( pConnection ); } -/* - String strMessage(ModuleRes(RID_STR_CONNECTION_DATA)); - strMessage.SearchAndReplace("$alias1$", static_cast< OQueryTableConnection*>(pConnection)->GetAliasName(JTCS_FROM)); - strMessage.SearchAndReplace("$alias2$", static_cast< OQueryTableConnection*>(pConnection)->GetAliasName(JTCS_TO)); - strMessage.SearchAndReplace("$field1$", static_cast< OQueryTableConnection*>(pConnection)->GetFieldName(JTCS_FROM)); - strMessage.SearchAndReplace("$field2$", static_cast< OQueryTableConnection*>(pConnection)->GetFieldName(JTCS_TO)); - - InfoBox(this, strMessage).Execute(); -*/ } - +// ----------------------------------------------------------------------------- +void OQueryTableView::createNewConnection() +{ + OQueryTableConnectionData* pData = new OQueryTableConnectionData(); + if( openJoinDialog(this,pData,TRUE) ) + { + OTableWindowMap* pMap = GetTabWinMap(); + OQueryTableWindow* pSourceWin = static_cast< OQueryTableWindow*>((*pMap)[pData->GetSourceWinName()]); + OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>((*pMap)[pData->GetDestWinName()]); + // first we have to look if the this connection already exists + OTableConnection* pConn = GetTabConn(pSourceWin,pDestWin); + sal_Bool bNew = sal_True; + if ( pConn ) + { + pConn->GetData()->CopyFrom( *pData ); + delete pData; + bNew = sal_False; + } + else + { + // create a new conenction and append it + OQueryTableConnection* pQConn = new OQueryTableConnection(this, pData); + GetConnection(pQConn); + pConn = pQConn; + } + connectionModified(this,pConn,bNew); + if ( !bNew && pConn == GetSelectedConn() ) // our connection was selected before so we have to reselect it + SelectConn( pConn ); + } + else + delete pData; +} //------------------------------------------------------------------------------ sal_Bool OQueryTableView::RemoveConnection( OTableConnection* pConn ) { @@ -759,10 +805,8 @@ sal_Bool OQueryTableView::RemoveConnection( OTableConnection* pConn ) OQueryTabConnUndoAction* pUndoAction = new OQueryDelTabConnUndoAction(this); pUndoAction->SetOwnership(sal_True); pUndoAction->SetConnection(static_cast< OQueryTableConnection*>(pConn)); - m_pView->getController()->getUndoMgr()->AddUndoAction(pUndoAction); + m_pView->getController()->addUndoActionAndInvalidate(pUndoAction); - // modified-Flag - m_pView->getController()->setModified(sal_True); return sal_True; } @@ -795,7 +839,7 @@ sal_Bool OQueryTableView::FindTableFromField(const String& rFieldName, OTableFie for(;aIter != GetTabWinMap()->end();++aIter) { if(static_cast<OQueryTableWindow*>(aIter->second)->ExistsField(rFieldName, rInfo)) - rCnt++; + ++rCnt; } return rCnt == 1; @@ -806,11 +850,9 @@ sal_Bool OQueryTableView::RemoveTabWin(const String& strAliasName) { DBG_CHKTHIS(OQueryTableView,NULL); OQueryTableWindow* pTabWin = FindTable(strAliasName); - if (!pTabWin) - return sal_False; - - RemoveTabWin(pTabWin); - return sal_True; + if ( pTabWin ) + RemoveTabWin(pTabWin); + return pTabWin != NULL; } //------------------------------------------------------------------------------ @@ -828,7 +870,6 @@ void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin) // Undo Actions und Loeschen der Felder in SelectionBrowseBox pParent->TableDeleted( static_cast< OQueryTableWindowData*>(pTabWin->GetData())->GetAliasName() ); - m_pView->getController()->setModified(sal_True); // Undo-Action anlegen OQueryTabWinDelUndoAct* pUndoAction = new OQueryTabWinDelUndoAct(this); @@ -837,13 +878,9 @@ void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin) // und Fenster verstecken HideTabWin(static_cast< OQueryTableWindow*>(pTabWin), pUndoAction); - pUndoMgr->AddUndoAction( pUndoAction ); + m_pView->getController()->addUndoActionAndInvalidate( pUndoAction ); pUndoMgr->LeaveListAction(); - m_pView->getController()->InvalidateFeature(ID_BROWSER_UNDO); - m_pView->getController()->InvalidateFeature(ID_BROWSER_REDO); - // GetViewShell()->GetViewShell()->UIFeatureChanged(); - if (m_lnkTabWinsChangeHandler.IsSet()) { TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_REMOVED_WIN, static_cast< OQueryTableWindow*>(pTabWin)->GetAliasName()); @@ -963,7 +1000,6 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc // damit habe ich das Doc natuerlich modifiziert m_pView->getController()->setModified( sal_True ); - m_pView->getController()->InvalidateFeature( ID_BROWSER_SAVEDOC ); m_pView->getController()->InvalidateFeature(ID_BROWSER_CLEAR_QUERY); } } @@ -1041,7 +1077,7 @@ sal_Bool OQueryTableView::ShowTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUn // damit habe ich das Doc natuerlich modifiziert if(!m_pView->getController()->isReadOnly()) m_pView->getController()->setModified( sal_True ); - m_pView->getController()->InvalidateFeature( ID_BROWSER_SAVEDOC ); + m_pView->getController()->InvalidateFeature(ID_BROWSER_CLEAR_QUERY); return bSuccess; @@ -1074,8 +1110,4 @@ sal_Bool OQueryTableView::ExistsAVisitedConn(const OQueryTableWindow* pFrom) con return sal_False; } -// ----------------------------------------------------------------------------- - - - diff --git a/dbaccess/source/ui/querydesign/QueryTextView.cxx b/dbaccess/source/ui/querydesign/QueryTextView.cxx index 406d834ecd22..3fe4b02bdaa9 100644 --- a/dbaccess/source/ui/querydesign/QueryTextView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTextView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryTextView.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-09-27 06:19:01 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -165,11 +165,10 @@ void OQueryTextView::setReadOnly(sal_Bool _bReadOnly) // ----------------------------------------------------------------------------- void OQueryTextView::clear() { - SfxUndoManager* pUndoMgr = getContainerWindow()->getDesignView()->getController()->getUndoMgr(); OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit ); pUndoAct->SetOriginalText( m_pEdit->GetText() ); - pUndoMgr->AddUndoAction( pUndoAct ); + getContainerWindow()->getDesignView()->getController()->addUndoActionAndInvalidate( pUndoAct ); m_pEdit->SetText(String()); } diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 8168744fc73d..dc772c35dacb 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SelectionBrowseBox.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: svesik $ $Date: 2002-01-02 11:07:17 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -914,7 +914,7 @@ sal_Bool OSelectionBrowseBox::SaveModified() static_cast<OQueryController*>(getDesignView()->getController())->getNumberFormatter(), xColumn, getDesignView()->getLocale(), - getDesignView()->getDecimalSeparator().toChar(), + static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()), &(static_cast<OQueryController*>(getDesignView()->getController())->getParser()->getContext())); delete pParseNode; } @@ -952,7 +952,7 @@ sal_Bool OSelectionBrowseBox::SaveModified() static_cast<OQueryController*>(getDesignView()->getController())->getNumberFormatter(), xColumn, getDesignView()->getLocale(), - getDesignView()->getDecimalSeparator().toChar(), + static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()), &(static_cast<OQueryController*>(getDesignView()->getController())->getParser()->getContext())); delete pParseNode; } @@ -1122,7 +1122,7 @@ void OSelectionBrowseBox::RemoveField(sal_uInt16 nId, sal_Bool bActivate) pUndoAction->SetTabFieldDescr(pDesc); pUndoAction->SetOwnership(sal_True); pUndoAction->SetColId( nId ); - pController->getUndoMgr()->AddUndoAction( pUndoAction ); + pController->addUndoActionAndInvalidate( pUndoAction ); RemoveColumn(nId); @@ -1433,7 +1433,7 @@ OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _r pUndoAction->SetTabFieldDescr( pEntry ); pUndoAction->SetOwnership(sal_False); pUndoAction->SetColId( nColId ); - static_cast<OQueryController*>(getDesignView()->getController())->getUndoMgr()->AddUndoAction( pUndoAction ); + getDesignView()->getController()->addUndoActionAndInvalidate( pUndoAction ); return pEntry; } @@ -1718,6 +1718,8 @@ void OSelectionBrowseBox::Command(const CommandEvent& rEvt) if (!static_cast<OQueryController*>(getDesignView()->getController())->isReadOnly()) { PopupMenu aContextMenu(ModuleRes(RID_QUERYCOLPOPUPMENU)); + aContextMenu.EnableItem(ID_QUERY_EDIT_JOINCONNECTION,FALSE); + aContextMenu.RemoveDisabledEntries(); switch (aContextMenu.Execute(this, aPoint)) { case SID_DELETE: // Aussch @@ -2071,7 +2073,7 @@ void OSelectionBrowseBox::ColumnResized(sal_uInt16 nColId) OTabFieldSizedUndoAct* pUndo = new OTabFieldSizedUndoAct(this); pUndo->SetColId(nColId); pUndo->SetOriginalWidth(pEntry->GetColWidth()); - static_cast<OQueryController*>(getDesignView()->getController())->getUndoMgr()->AddUndoAction(pUndo); + getDesignView()->getController()->addUndoActionAndInvalidate(pUndo); pEntry->SetColWidth(sal_uInt16(GetColumnWidth(nColId))); } } @@ -2178,7 +2180,7 @@ void OSelectionBrowseBox::appendUndoAction(const String& _rOldValue,const String pUndoAct->SetCellIndex(_nRow); pUndoAct->SetColId(GetCurColumnId()); pUndoAct->SetCellContents(_rOldValue); - static_cast<OQueryController*>(getDesignView()->getController())->getUndoMgr()->AddUndoAction(pUndoAct); + getDesignView()->getController()->addUndoActionAndInvalidate(pUndoAct); } } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx index 2c720452229b..1eaab8465dee 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx @@ -2,9 +2,9 @@ * * $RCSfile: SelectionBrowseBox.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-10-26 07:49:36 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -183,6 +183,9 @@ namespace dbaui virtual void GetFocus(); virtual void DeactivateCell(sal_Bool bUpdate = sal_True); + void Fill(); + void PreFill(); + protected: virtual sal_Bool SeekRow( long nRow ); @@ -211,7 +214,7 @@ namespace dbaui virtual sal_uInt16 GetDefaultColumnWidth(const String& rName) const; - void Fill(); + void stopTimer(); void startTimer(); @@ -230,7 +233,6 @@ namespace dbaui long GetBrowseRow(long nRowId) const; sal_Bool GetFunktionName(String& rFkt); void appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow); - void PreFill(); OTableFields& getFields() const; void enableControl(const OTableFieldDescRef& _rEntry,Window* _pControl); void setTextCellContext(const OTableFieldDescRef& _rEntry,const String& _sText,ULONG _nHelpId); diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx index 990b69a35351..08181697f3b2 100644 --- a/dbaccess/source/ui/querydesign/TableConnection.cxx +++ b/dbaccess/source/ui/querydesign/TableConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableConnection.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: hr $ $Date: 2001-10-26 14:29:00 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,217 +67,208 @@ #ifndef DBAUI_TABLECONNECTIONDATA_HXX #include "TableConnectionData.hxx" #endif -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif #ifndef DBAUI_JOINTABLEVIEW_HXX #include "JoinTableView.hxx" #endif #ifndef _COMPHELPER_STLTYPES_HXX_ #include <comphelper/stl_types.hxx> #endif - +#ifndef DBACCESS_CONNECTIONLINEACCESS_HXX +#include "ConnectionLineAccess.hxx" +#endif #include <algorithm> using namespace dbaui; using namespace comphelper; +using namespace ::com::sun::star::uno; +using namespace ::drafts::com::sun::star::accessibility; TYPEINIT0(OTableConnection); //======================================================================== // class OTableConnection //======================================================================== -DBG_NAME(OTableConnection); -//------------------------------------------------------------------------ -OTableConnection::OTableConnection( OJoinTableView* _pContainer, OTableConnectionData* _pTabConnData ) - :m_bSelected( FALSE ) - ,m_pParent( _pContainer ) - ,m_pData( _pTabConnData ) +namespace dbaui { - DBG_CTOR(OTableConnection,NULL); - Init(); -} + DBG_NAME(OTableConnection) + //------------------------------------------------------------------------ + OTableConnection::OTableConnection( OJoinTableView* _pContainer, OTableConnectionData* _pTabConnData ) + :m_bSelected( FALSE ) + ,m_pParent( _pContainer ) + ,m_pData( _pTabConnData ) + { + DBG_CTOR(OTableConnection,NULL); + Init(); + } -//------------------------------------------------------------------------ -OTableConnection::OTableConnection( const OTableConnection& _rConn ) -{ - DBG_CTOR(OTableConnection,NULL); - m_pData = _rConn.GetData()->NewInstance(); - *this = _rConn; -} -//------------------------------------------------------------------------ -OTableConnection::~OTableConnection() -{ - ////////////////////////////////////////////////////////////////////// - // clear vector - for(::std::vector<OConnectionLine*>::iterator aIter = m_vConnLine.begin();aIter != m_vConnLine.end();++aIter) - delete *aIter; - m_vConnLine.clear(); - DBG_DTOR(OTableConnection,NULL); -} + //------------------------------------------------------------------------ + OTableConnection::OTableConnection( const OTableConnection& _rConn ) + { + DBG_CTOR(OTableConnection,NULL); + m_pData = _rConn.GetData()->NewInstance(); + *this = _rConn; + } -//------------------------------------------------------------------------ -void OTableConnection::Init() -{ - ////////////////////////////////////////////////////////////////////// - // Linienliste mit Defaults initialisieren - OConnectionLineDataVec* pLineData = GetData()->GetConnLineDataList(); - OConnectionLineDataVec::const_iterator aIter = pLineData->begin(); - for(;aIter != pLineData->end();++aIter) + //------------------------------------------------------------------------ + void OTableConnection::Init() { - OConnectionLine* pConnLine = new OConnectionLine(this, *aIter); - m_vConnLine.push_back( pConnLine); + ////////////////////////////////////////////////////////////////////// + // Linienliste mit Defaults initialisieren + OConnectionLineDataVec* pLineData = GetData()->GetConnLineDataList(); + OConnectionLineDataVec::const_iterator aIter = pLineData->begin(); + m_vConnLine.reserve(pLineData->size()); + for(;aIter != pLineData->end();++aIter) + m_vConnLine.push_back( new OConnectionLine(this, *aIter) ); } -} -//------------------------------------------------------------------------ -OConnectionLine* OTableConnection::CreateConnLine( const OConnectionLine& rConnLine ) -{ - return new OConnectionLine( rConnLine ); -} -//------------------------------------------------------------------------ -void OTableConnection::UpdateLineList() -{ - ////////////////////////////////////////////////////////////////////// - // Linienliste loeschen - for(::std::vector<OConnectionLine*>::iterator aLineIter = m_vConnLine.begin();aLineIter != m_vConnLine.end();++aLineIter) - delete *aLineIter; - m_vConnLine.clear(); + //------------------------------------------------------------------------ + OConnectionLine* OTableConnection::CreateConnLine( const OConnectionLine& rConnLine ) + { + return new OConnectionLine( rConnLine ); + } + // ----------------------------------------------------------------------------- + void OTableConnection::clearLineData() + { + for(::std::vector<OConnectionLine*>::iterator aLineIter = m_vConnLine.begin();aLineIter != m_vConnLine.end();++aLineIter) + delete *aLineIter; + m_vConnLine.clear(); + } + //------------------------------------------------------------------------ + void OTableConnection::UpdateLineList() + { + ////////////////////////////////////////////////////////////////////// + // Linienliste loeschen + clearLineData(); - Init(); -} + Init(); + } -//------------------------------------------------------------------------ -OTableConnection& OTableConnection::operator=( const OTableConnection& rConn ) -{ - if( &rConn == this ) - return *this; + //------------------------------------------------------------------------ + OTableConnection& OTableConnection::operator=( const OTableConnection& rConn ) + { + if( &rConn == this ) + return *this; - // Linienliste loeschen - for(::std::vector<OConnectionLine*>::iterator aIter = m_vConnLine.begin();aIter != m_vConnLine.end();++aIter) - delete *aIter; - m_vConnLine.clear(); + // Linienliste loeschen + clearLineData(); - // Linienliste kopieren - if(! rConn.GetConnLineList()->empty() ) - { - const ::std::vector<OConnectionLine*>* pLine = rConn.GetConnLineList(); - ::std::vector<OConnectionLine*>::const_iterator aIter = pLine->begin(); - for(;aIter != pLine->end();++aIter) + // Linienliste kopieren + if(! rConn.GetConnLineList()->empty() ) { - OConnectionLine* pDestLine = CreateConnLine( **aIter ); - m_vConnLine.push_back( pDestLine); + const ::std::vector<OConnectionLine*>* pLine = rConn.GetConnLineList(); + ::std::vector<OConnectionLine*>::const_iterator aIter = pLine->begin(); + m_vConnLine.reserve(pLine->size()); + for(;aIter != pLine->end();++aIter) + m_vConnLine.push_back( CreateConnLine( **aIter )); } - } - // da mir die Daten nicht gehoeren, loesche ich die alten nicht - m_pData->CopyFrom(*rConn.GetData()); - // CopyFrom ist virtuell, damit ist es kein Problem, wenn m_pData von einem von OTableConnectionData abgeleiteten Typ ist + // da mir die Daten nicht gehoeren, loesche ich die alten nicht + m_pData->CopyFrom(*rConn.GetData()); + // CopyFrom ist virtuell, damit ist es kein Problem, wenn m_pData von einem von OTableConnectionData abgeleiteten Typ ist - m_bSelected = rConn.m_bSelected; - m_pParent = rConn.m_pParent; + m_bSelected = rConn.m_bSelected; + m_pParent = rConn.m_pParent; - return *this; -} + return *this; + } -//------------------------------------------------------------------------ -bool OTableConnection::RecalcLines() -{ - ::std::for_each(m_vConnLine.begin(),m_vConnLine.end(),::std::mem_fun(&OConnectionLine::RecalcLine)); - return true; -} -//------------------------------------------------------------------------ -OTableWindow* OTableConnection::GetSourceWin() const -{ - return m_pParent->GetWindow( GetData()->GetSourceWinName() ); -} -//------------------------------------------------------------------------ -OTableWindow* OTableConnection::GetDestWin() const -{ - return m_pParent->GetWindow( GetData()->GetDestWinName() ); -} + //------------------------------------------------------------------------ + bool OTableConnection::RecalcLines() + { + // call RecalcLines on each line + ::std::for_each(m_vConnLine.begin(),m_vConnLine.end(),::std::mem_fun(&OConnectionLine::RecalcLine)); + return true; + } + //------------------------------------------------------------------------ + OTableWindow* OTableConnection::GetSourceWin() const + { + return m_pParent->GetWindow( GetData()->GetSourceWinName() ); + } + //------------------------------------------------------------------------ + OTableWindow* OTableConnection::GetDestWin() const + { + return m_pParent->GetWindow( GetData()->GetDestWinName() ); + } -//------------------------------------------------------------------------ -void OTableConnection::Select() -{ - m_bSelected = TRUE; - m_pParent->Invalidate( GetBoundingRect(), INVALIDATE_NOCHILDREN); -} + //------------------------------------------------------------------------ + void OTableConnection::Select() + { + m_bSelected = TRUE; + m_pParent->Invalidate( GetBoundingRect(), INVALIDATE_NOCHILDREN); + } -//------------------------------------------------------------------------ -void OTableConnection::Deselect() -{ - m_bSelected = FALSE; - Rectangle rcBounding = GetBoundingRect(); - rcBounding.Bottom() += 1; - rcBounding.Right() += 1; - m_pParent->Invalidate( rcBounding, INVALIDATE_NOCHILDREN ); - // Kommentar siehe ::Invalidate ... -} + //------------------------------------------------------------------------ + void OTableConnection::Deselect() + { + m_bSelected = FALSE; + Rectangle rcBounding = GetBoundingRect(); + rcBounding.Bottom() += 1; + rcBounding.Right() += 1; + m_pParent->Invalidate( rcBounding, INVALIDATE_NOCHILDREN ); + // Kommentar siehe ::Invalidate ... + } -//------------------------------------------------------------------------ -BOOL OTableConnection::CheckHit( const Point& rMousePos ) -{ - ////////////////////////////////////////////////////////////////////// - // Pruefen, ob auf eine der Linien geclickt worden ist - ::std::vector<OConnectionLine*>::iterator aIter = ::std::find_if(m_vConnLine.begin(), - m_vConnLine.end(), - ::std::compose2(::std::logical_and<bool>(), - ::std::mem_fun(&OConnectionLine::IsValid), - ::std::bind2nd(TConnectionLineCheckHitFunctor(),rMousePos))); - return aIter != m_vConnLine.end(); -} + //------------------------------------------------------------------------ + BOOL OTableConnection::CheckHit( const Point& rMousePos ) const + { + ////////////////////////////////////////////////////////////////////// + // check if the point hit our line + ::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(m_vConnLine.begin(), + m_vConnLine.end(), + ::std::bind2nd(TConnectionLineCheckHitFunctor(),rMousePos)); + return aIter != m_vConnLine.end(); + } -//------------------------------------------------------------------------ -bool OTableConnection::Invalidate() -{ - Rectangle rcBounding = GetBoundingRect(); - rcBounding.Bottom() += 1; - rcBounding.Right() += 1; - // ich glaube, dass sich Invalidate und Draw(Rectangle) nicht konsistent verhalten : jedenfalls waere dadurch zu - // erklaeren, warum ohne diesen Fake hier beim Loeschen einer Connection ein Strich an ihrem unteren Ende stehen bleibt : - // Invalidate erfasst dabei offensichtlich eine Pixelzeile weniger als Draw. - // Oder alles haengt ganz anders zusammen ... jedenfalls klappt es so ... - m_pParent->Invalidate( rcBounding, INVALIDATE_NOCHILDREN ); + //------------------------------------------------------------------------ + bool OTableConnection::Invalidate() + { + Rectangle rcBounding = GetBoundingRect(); + rcBounding.Bottom() += 1; + rcBounding.Right() += 1; + // ich glaube, dass sich Invalidate und Draw(Rectangle) nicht konsistent verhalten : jedenfalls waere dadurch zu + // erklaeren, warum ohne diesen Fake hier beim Loeschen einer Connection ein Strich an ihrem unteren Ende stehen bleibt : + // Invalidate erfasst dabei offensichtlich eine Pixelzeile weniger als Draw. + // Oder alles haengt ganz anders zusammen ... jedenfalls klappt es so ... + m_pParent->Invalidate( rcBounding, INVALIDATE_NOCHILDREN ); - return true; -} + return true; + } -//------------------------------------------------------------------------ -Rectangle OTableConnection::GetBoundingRect() -{ - ////////////////////////////////////////////////////////////////////// - // Aus allen Linien das umgebende Rechteck bestimmen - Rectangle aBoundingRect( Point(0,0), Point(0,0) ); - Rectangle aTempRect; - for(::std::vector<OConnectionLine*>::iterator aIter = m_vConnLine.begin();aIter != m_vConnLine.end();++aIter) + //------------------------------------------------------------------------ + Rectangle OTableConnection::GetBoundingRect() const { - aTempRect = (*aIter)->GetBoundingRect(); - ////////////////////////////////////////////////////////////////////// - // Ist das BoundingRect dieser Linie gueltig? - if( (aTempRect.GetWidth()!=1) && (aTempRect.GetHeight()!=1) ) + // Aus allen Linien das umgebende Rechteck bestimmen + Rectangle aBoundingRect( Point(0,0), Point(0,0) ); + Rectangle aTempRect; + for(::std::vector<OConnectionLine*>::const_iterator aIter = m_vConnLine.begin();aIter != m_vConnLine.end();++aIter) { - if( (aBoundingRect.GetWidth()==1) && (aBoundingRect.GetHeight()==1) ) - aBoundingRect = aTempRect; - else - aBoundingRect.Union( aTempRect ); + aTempRect = (*aIter)->GetBoundingRect(); + + ////////////////////////////////////////////////////////////////////// + // Ist das BoundingRect dieser Linie gueltig? + if( (aTempRect.GetWidth()!=1) && (aTempRect.GetHeight()!=1) ) + { + if( (aBoundingRect.GetWidth()==1) && (aBoundingRect.GetHeight()==1) ) + aBoundingRect = aTempRect; + else + aBoundingRect.Union( aTempRect ); + } } - } - return aBoundingRect; -} + return aBoundingRect; + } -//------------------------------------------------------------------------ -void OTableConnection::Draw( const Rectangle& rRect ) -{ - ////////////////////////////////////////////////////////////////////// - // Linien zeichnen - ::std::for_each(m_vConnLine.begin(),m_vConnLine.end(),TConnectionLineDrawFunctor(m_pParent)); + //------------------------------------------------------------------------ + void OTableConnection::Draw( const Rectangle& rRect ) + { + ////////////////////////////////////////////////////////////////////// + // Linien zeichnen + ::std::for_each(m_vConnLine.begin(),m_vConnLine.end(),TConnectionLineDrawFunctor(m_pParent)); + } + // ----------------------------------------------------------------------------- } -// ----------------------------------------------------------------------------- - diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx index 4f8485005679..eb8de230e97e 100644 --- a/dbaccess/source/ui/querydesign/TableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableConnectionData.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-10-08 07:32:34 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -229,6 +229,24 @@ OTableConnectionData* OTableConnectionData::NewInstance() const return new OTableConnectionData(); } // ----------------------------------------------------------------------------- +void OTableConnectionData::normalizeLines() +{ + // noch ein wenig Normalisierung auf den LineDatas : leere Lines vom Anfang an das Ende verschieben + sal_Int32 nCount = m_vConnLineData.size(); + for(sal_Int32 i=0;i<nCount;) + { + if(!m_vConnLineData[i]->GetSourceFieldName().getLength() && !m_vConnLineData[i]->GetDestFieldName().getLength()) + { + OConnectionLineDataRef pData = m_vConnLineData[i]; + m_vConnLineData.erase(m_vConnLineData.begin()+i); + m_vConnLineData.push_back(pData); + --nCount; + } + else + ++i; + } +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx index cb70e40416db..d3d95c1813de 100644 --- a/dbaccess/source/ui/querydesign/TableWindow.cxx +++ b/dbaccess/source/ui/querydesign/TableWindow.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableWindow.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-11-09 12:20:16 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,7 +118,12 @@ #ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" #endif - +#ifndef DBACCESS_TABLEWINDOWACCESS_HXX +#include "TableWindowAccess.hxx" +#endif +#ifndef DBACCESS_UI_BROWSER_ID_HXX +#include "browserids.hxx" +#endif using namespace dbaui; using namespace ::utl; @@ -128,10 +133,11 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; +using namespace ::drafts::com::sun::star::accessibility; -const long TABWIN_SIZING_AREA = 4; -const long LISTBOX_SCROLLING_AREA = 6; -const ULONG SCROLLING_TIMESPAN = 500; +const long TABWIN_SIZING_AREA = 4; +const long LISTBOX_SCROLLING_AREA = 6; +const ULONG SCROLLING_TIMESPAN = 500; TYPEINIT0(OTableWindow); @@ -146,6 +152,8 @@ OTableWindow::OTableWindow( Window* pParent, OTableWindowData* pTabWinData ) ,m_nSizingFlags( SIZING_NONE ) ,m_bActive( FALSE ) ,m_pListBox(NULL) + ,m_nMoveCount(0) + ,m_nMoveIncrement(1) { DBG_CTOR(OTableWindow,NULL); // ich uebernehme nicht die Verantwortung fuer die Daten, ich merke mir nur den Zeiger darauf @@ -159,8 +167,8 @@ OTableWindow::OTableWindow( Window* pParent, OTableWindowData* pTabWinData ) SetSizePixel( GetData()->GetSize() ); // Hintergrund setzen - StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); - SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor()))); + const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings(); + SetBackground(Wallpaper(aSystemStyle.GetFaceColor())); // und Textfarbe (obwohl ich eigentlich keinen Text habe, aber wer weiss, was // abgeleitete Klassen machen) SetTextColor(aSystemStyle.GetButtonTextColor()); @@ -289,13 +297,16 @@ BOOL OTableWindow::FillListBox() void OTableWindow::EmptyListBox() { // da ich defaultmaessig keine USerData an die Items haenge, kann ich hier einfach loeschen - SvLBoxEntry* pEntry = m_pListBox->First(); - - while(pEntry) + if ( m_pListBox ) { - SvLBoxEntry* pNextEntry = m_pListBox->Next(pEntry); - m_pListBox->GetModel()->Remove(pEntry); - pEntry = pNextEntry; + SvLBoxEntry* pEntry = m_pListBox->First(); + + while(pEntry) + { + SvLBoxEntry* pNextEntry = m_pListBox->Next(pEntry); + m_pListBox->GetModel()->Remove(pEntry); + pEntry = pNextEntry; + } } } @@ -384,7 +395,7 @@ void OTableWindow::DataChanged(const DataChangedEvent& rDCEvt) { // nehmen wir den worst-case an : die Farben haben sich geaendert, also // mich anpassen - StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); + const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings(); SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor()))); SetTextColor(aSystemStyle.GetButtonTextColor()); } @@ -407,7 +418,7 @@ void OTableWindow::SetTitle( const ::rtl::OUString& rTit ) void OTableWindow::Draw3DBorder(const Rectangle& rRect) { // die Style-Settings des Systems fuer meine Farben - StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); + const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings(); // Schwarze Linie unten und rechts SetLineColor(aSystemStyle.GetDarkShadowColor()); @@ -416,13 +427,14 @@ void OTableWindow::Draw3DBorder(const Rectangle& rRect) // Dunkelgraue Linie ueber der schwarzen SetLineColor(aSystemStyle.GetShadowColor()); - DrawLine( rRect.BottomLeft()+Point(1,-1), rRect.BottomRight()-Point(1,1) ); - DrawLine( rRect.BottomRight()-Point(1,1), rRect.TopRight()+Point(-1,1) ); + Point aEHvector(1,1); + DrawLine( rRect.BottomLeft()+Point(1,-1), rRect.BottomRight() - aEHvector ); + DrawLine( rRect.BottomRight() - aEHvector, rRect.TopRight()+Point(-1,1) ); // Hellgraue Linie links und oben SetLineColor(aSystemStyle.GetLightColor()); - DrawLine( rRect.BottomLeft()+Point(1,-2), rRect.TopLeft()+Point(1,1) ); - DrawLine( rRect.TopLeft()+Point(1,1), rRect.TopRight()+Point(-2,1) ); + DrawLine( rRect.BottomLeft()+Point(1,-2), rRect.TopLeft() + aEHvector ); + DrawLine( rRect.TopLeft() + aEHvector, rRect.TopRight()+Point(-2,1) ); } //------------------------------------------------------------------------------ @@ -581,10 +593,16 @@ void OTableWindow::Remove() //------------------------------------------------------------------------------ void OTableWindow::KeyInput( const KeyEvent& rEvt ) { - USHORT nCode = rEvt.GetKeyCode().GetCode(); - BOOL bShift = rEvt.GetKeyCode().IsShift(); - BOOL bCtrl = rEvt.GetKeyCode().IsMod1(); + const KeyCode& rCode = rEvt.GetKeyCode(); + USHORT nCode = rCode.GetCode(); + BOOL bShift = rCode.IsShift(); + BOOL bCtrl = rCode.IsMod1(); + if ( rCode.IsMod2() ) + { + m_nMoveCount = 0; // reset our move ment count + m_nMoveIncrement = 1; + } if( !bCtrl && !bShift && (nCode==KEY_DELETE) ) { Remove(); @@ -609,14 +627,15 @@ void OTableWindow::EnumValidFields(::std::vector< ::rtl::OUString>& arrstrFields { arrstrFields.clear(); // diese Default-Implementierung zaehlt einfach alles auf, was es in der ListBox gibt ... fuer anderes Verhalten ueberschreiben - if (!m_pListBox) - return; - - SvLBoxEntry* pEntryLoop = m_pListBox->First(); - while (pEntryLoop) + if ( m_pListBox ) { - arrstrFields.push_back(m_pListBox->GetEntryText(pEntryLoop)); - pEntryLoop = m_pListBox->Next(pEntryLoop); + arrstrFields.reserve(m_pListBox->GetEntryCount()); + SvLBoxEntry* pEntryLoop = m_pListBox->First(); + while (pEntryLoop) + { + arrstrFields.push_back(m_pListBox->GetEntryText(pEntryLoop)); + pEntryLoop = m_pListBox->Next(pEntryLoop); + } } } // ----------------------------------------------------------------------------- @@ -647,7 +666,101 @@ void OTableWindow::_disposing( const ::com::sun::star::lang::EventObject& _rSour m_xColumns = NULL; } // ----------------------------------------------------------------------------- +Reference< XAccessible > OTableWindow::CreateAccessible() +{ + return new OTableWindowAccess(getTableView()->GetAccessible(),this); +} +// ----------------------------------------------------------------------------- +void OTableWindow::Command(const CommandEvent& rEvt) +{ + switch (rEvt.GetCommand()) + { + case COMMAND_CONTEXTMENU: + { + OJoinController* pController = getDesignView()->getController(); + if(!pController->isReadOnly() && pController->isConnected()) + { + Point ptWhere; + if ( rEvt.IsMouseEvent() ) + ptWhere = rEvt.GetMousePosPixel(); + else + { + SvLBoxEntry* pCurrent = m_pListBox->GetCurEntry(); + if ( pCurrent ) + ptWhere = m_pListBox->GetEntryPos(pCurrent); + else + ptWhere = m_aTitle.GetPosPixel(); + } - - - + PopupMenu aContextMenu(ModuleRes(RID_QUERYCOLPOPUPMENU)); + aContextMenu.EnableItem(ID_QUERY_EDIT_JOINCONNECTION,FALSE); + aContextMenu.RemoveDisabledEntries(); + switch (aContextMenu.Execute(this, ptWhere)) + { + case SID_DELETE: + Remove(); + break; + } + } + break; + } + default: + Window::Command(rEvt); + } +} +// ----------------------------------------------------------------------------- +long OTableWindow::PreNotify(NotifyEvent& rNEvt) +{ + BOOL bHandled = FALSE; + switch (rNEvt.GetType()) + { + case EVENT_KEYINPUT: + { + const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); + const KeyCode& rCode = pKeyEvent->GetKeyCode(); + if ( rCode.IsMod2() ) + { + Point aStartPoint = GetPosPixel(); + switch( rCode.GetCode() ) + { + case KEY_DOWN: + bHandled = TRUE; + aStartPoint.Y() += m_nMoveIncrement; + break; + case KEY_UP: + bHandled = TRUE; + aStartPoint.Y() += -m_nMoveIncrement; + break; + case KEY_LEFT: + bHandled = TRUE; + aStartPoint.X() += -m_nMoveIncrement; + break; + case KEY_RIGHT: + bHandled = TRUE; + aStartPoint.X() += m_nMoveIncrement; + break; + } + if( bHandled ) + { + // remember how often the user moved our window + ++m_nMoveCount; + if( m_nMoveCount == 5 ) + m_nMoveIncrement = 10; + else if( m_nMoveCount > 15 ) + m_nMoveCount = m_nMoveIncrement = 20; + + + SetPosPixel(aStartPoint); + getTableView()->TabWinMoved(this,aStartPoint); + Invalidate(INVALIDATE_NOCHILDREN); + getDesignView()->getController()->setModified( sal_True ); + } + } + } + break; + } + if (!bHandled) + return Window::PreNotify(rNEvt); + return 1L; +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx index ecb4ade8a343..103c8b84613b 100644 --- a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableWindowListBox.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-12-10 11:04:08 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -205,8 +205,7 @@ long OTableWindowListBox::PreNotify(NotifyEvent& rNEvt) { const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); const KeyCode& rCode = pKeyEvent->GetKeyCode(); - if (rCode.IsMod1() || rCode.IsMod2() || rCode.IsShift()) - break; + if (rCode.GetCode() != KEY_RETURN) { if(m_pTabWin) @@ -214,6 +213,8 @@ long OTableWindowListBox::PreNotify(NotifyEvent& rNEvt) break; } + if (rCode.IsMod1() || rCode.IsMod2() || rCode.IsShift()) + break; if (FirstSelected()) static_cast<OTableWindow*>(Window::GetParent())->OnEntryDoubleClicked(FirstSelected()); } @@ -431,4 +432,18 @@ IMPL_LINK( OTableWindowListBox, DoubleClickHdl, SvTreeListBox *, pBox ) return 0; } // ----------------------------------------------------------------------------- +void OTableWindowListBox::Command(const CommandEvent& rEvt) +{ + switch (rEvt.GetCommand()) + { + case COMMAND_CONTEXTMENU: + { + static_cast<OTableWindow*>(Window::GetParent())->Command(rEvt); + break; + } + default: + SvTreeListBox::Command(rEvt); + } +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx index 4972dfe0a64c..4b0d2ed2efc7 100644 --- a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableWindowTitle.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: hr $ $Date: 2001-10-31 17:32:48 $ + * last change: $Author: oj $ $Date: 2002-02-06 08:15:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -181,22 +181,10 @@ void OTableWindowTitle::Command( const CommandEvent& rEvt ) case COMMAND_CONTEXTMENU: { GrabFocus(); - OQueryTableView* pView = static_cast<OQueryTableView*>(m_pTabWin->getTableView()); - OSL_ENSURE(pView,"No OQueryTableView!"); - if(!pView->getDesignView()->getController()->isReadOnly() && pView->getDesignView()->getController()->isConnected()) - { - Point aPoint = rEvt.GetMousePosPixel(); - PopupMenu aContextMenu( ModuleRes(RID_QUERYCOLPOPUPMENU) ); - switch (aContextMenu.Execute(this, aPoint)) - { - case SID_DELETE: - m_pTabWin->Remove(); - - break; - default: - Control::Command(rEvt); - } - } + if ( m_pTabWin ) + m_pTabWin->Command( rEvt ); + else + Control::Command(rEvt); } } } |