diff options
Diffstat (limited to 'dbaccess/source/ui/querydesign')
47 files changed, 1003 insertions, 1316 deletions
diff --git a/dbaccess/source/ui/querydesign/ConnectionLine.cxx b/dbaccess/source/ui/querydesign/ConnectionLine.cxx index cf5af7def510..b22a05424df3 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLine.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLine.cxx @@ -22,6 +22,7 @@ #include <TableWindow.hxx> #include <TableWindowListBox.hxx> #include <TableConnection.hxx> +#include <utility> #include <vcl/svapp.hxx> #include <math.h> #include <osl/diagnose.h> @@ -29,8 +30,8 @@ #include <vcl/settings.hxx> using namespace dbaui; -const long DESCRIPT_LINE_WIDTH = 15; -const long HIT_SENSITIVE_RADIUS = 5; +const tools::Long DESCRIPT_LINE_WIDTH = 15; +const tools::Long HIT_SENSITIVE_RADIUS = 5; namespace { @@ -55,7 +56,7 @@ namespace tools::Rectangle aReturn; if ( pListBox ) { - const long nRowHeight = pListBox->GetEntryHeight(); + const tools::Long nRowHeight = pListBox->get_widget().get_height_rows(1); aReturn.SetTop( _aConnPos.Y() - nRowHeight ); aReturn.SetBottom( aReturn.Top() + nRowHeight ); if (_aDescrLinePos.X() < _aConnPos.X()) @@ -74,29 +75,41 @@ namespace } /** 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 _nEntry the source or dest entry @param _rNewConPos (in/out) the connection pos @param _rNewDescrPos (in/out) the description pos */ - void calcPointsYValue(const OTableWindow* _pWin,SvTreeListEntry* _pEntry,Point& _rNewConPos,Point& _rNewDescrPos) + void calcPointsYValue(const OTableWindow* _pWin, int _nEntry, Point& _rNewConPos, Point& _rNewDescrPos) { const OTableWindowListBox* pListBox = _pWin->GetListBox(); _rNewConPos.setY( _pWin->GetPosPixel().Y() ); - if ( _pEntry ) + + std::unique_ptr<weld::TreeIter> xEntry; + const weld::TreeView& rTreeView = pListBox->get_widget(); + + if (_nEntry != -1) { - const long nRowHeight = pListBox->GetEntryHeight(); _rNewConPos.AdjustY(pListBox->GetPosPixel().Y() ); - long nEntryPos = pListBox->GetEntryPosition( _pEntry ).Y(); + xEntry = rTreeView.make_iterator(); + if (!rTreeView.get_iter_first(*xEntry) || !rTreeView.iter_nth_sibling(*xEntry, _nEntry)) + xEntry.reset(); + } + + if (xEntry) + { + auto nEntryPos = rTreeView.get_row_area(*xEntry).Center().Y(); if( nEntryPos >= 0 ) { - _rNewConPos.AdjustY(nEntryPos ); - _rNewConPos.AdjustY(static_cast<long>( 0.5 * nRowHeight ) ); + _rNewConPos.AdjustY(nEntryPos); } else - _rNewConPos.AdjustY( -static_cast<long>( 0.5 * nRowHeight ) ); + { + const auto nRowHeight = rTreeView.get_height_rows(1); + _rNewConPos.AdjustY( -static_cast<tools::Long>( 0.5 * nRowHeight ) ); + } - long nListBoxBottom = _pWin->GetPosPixel().Y() + tools::Long nListBoxBottom = _pWin->GetPosPixel().Y() + pListBox->GetPosPixel().Y() + pListBox->GetSizePixel().Height(); if( _rNewConPos.Y() > nListBoxBottom ) @@ -109,9 +122,9 @@ namespace } } -OConnectionLine::OConnectionLine( OTableConnection* _pConn, OConnectionLineDataRef const & _pLineData ) +OConnectionLine::OConnectionLine( OTableConnection* _pConn, OConnectionLineDataRef _pLineData ) : m_pTabConn( _pConn ) - , m_pData( _pLineData ) + , m_pData(std::move( _pLineData )) { } @@ -213,15 +226,15 @@ bool OConnectionLine::RecalcLine() if( !pSourceWin || !pDestWin ) return false; - SvTreeListEntry* pSourceEntry = pSourceWin->GetListBox()->GetEntryFromText( GetData()->GetSourceFieldName() ); - SvTreeListEntry* pDestEntry = pDestWin->GetListBox()->GetEntryFromText( GetData()->GetDestFieldName() ); + int nSourceEntry = pSourceWin->GetListBox()->GetEntryFromText( GetData()->GetSourceFieldName() ); + int nDestEntry = pDestWin->GetListBox()->GetEntryFromText( GetData()->GetDestFieldName() ); // determine X-coordinates Point aSourceCenter( 0, 0 ); Point aDestCenter( 0, 0 ); - aSourceCenter.setX( pSourceWin->GetPosPixel().X() + static_cast<long>( 0.5*pSourceWin->GetSizePixel().Width() ) ); - aDestCenter.setX( pDestWin->GetPosPixel().X() + static_cast<long>( 0.5*pDestWin->GetSizePixel().Width() ) ); + aSourceCenter.setX( pSourceWin->GetPosPixel().X() + static_cast<tools::Long>( 0.5*pSourceWin->GetSizePixel().Width() ) ); + aDestCenter.setX( pDestWin->GetPosPixel().X() + static_cast<tools::Long>( 0.5*pDestWin->GetSizePixel().Width() ) ); const OTableWindow* pFirstWin = pDestWin; const OTableWindow* pSecondWin = pSourceWin; @@ -239,17 +252,17 @@ bool OConnectionLine::RecalcLine() pSecondDescrPos = &m_aDestDescrLinePos; } - if ( pFirstWin == pSecondWin && pSourceEntry != pDestEntry ) + if (pFirstWin == pSecondWin && nSourceEntry != nDestEntry) calcPointX2(pFirstWin,*pFirstConPos,*pFirstDescrPos); else calcPointX1(pFirstWin,*pFirstConPos,*pFirstDescrPos); calcPointX2(pSecondWin,*pSecondConPos,*pSecondDescrPos); // determine aSourceConnPosY - calcPointsYValue(pSourceWin,pSourceEntry,m_aSourceConnPos,m_aSourceDescrLinePos); + calcPointsYValue(pSourceWin, nSourceEntry, m_aSourceConnPos,m_aSourceDescrLinePos); // determine aDestConnPosY - calcPointsYValue(pDestWin,pDestEntry,m_aDestConnPos,m_aDestDescrLinePos); + calcPointsYValue(pDestWin, nDestEntry, m_aDestConnPos,m_aDestDescrLinePos); return true; } @@ -295,12 +308,12 @@ static double dist_Euklid(const Point &p1, const Point& p2,const Point& pM, Poin { Point v(p2 - p1); Point w(pM - p1); - double a = sqrt(static_cast<double>(v.X()*v.X() + v.Y()*v.Y())); + double a = std::hypot(v.X(), v.Y()); double l = (v.X() * w.Y() - v.Y() * w.X()) / a; double a2 = w.X()*v.X()+w.Y()*v.Y(); a = a2 / (a * a); - q.setX( long(p1.X() + a * v.X()) ); - q.setY( long(p1.Y() + a * v.Y()) ); + q.setX( tools::Long(p1.X() + a * v.X()) ); + q.setY( tools::Long(p1.Y() + a * v.Y()) ); return l; } diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx index 763e53990276..a45993a5721d 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx @@ -25,18 +25,16 @@ #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <TableConnection.hxx> #include <TableWindow.hxx> -#include <comphelper/sequence.hxx> namespace dbaui { using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using namespace ::com::sun::star; OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine) - : VCLXAccessibleComponent(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : nullptr) + : ImplInheritanceHelper(_pLine) ,m_pLine(_pLine) { } @@ -45,32 +43,23 @@ namespace dbaui m_pLine = nullptr; VCLXAccessibleComponent::disposing(); } - Any SAL_CALL OConnectionLineAccess::queryInterface( const Type& aType ) - { - Any aRet(VCLXAccessibleComponent::queryInterface( aType )); - return aRet.hasValue() ? aRet : OConnectionLineAccess_BASE::queryInterface( aType ); - } - Sequence< Type > SAL_CALL OConnectionLineAccess::getTypes( ) - { - return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OConnectionLineAccess_BASE::getTypes()); - } OUString SAL_CALL OConnectionLineAccess::getImplementationName() { - return "org.openoffice.comp.dbu.ConnectionLineAccessibility"; + return u"org.openoffice.comp.dbu.ConnectionLineAccessibility"_ustr; } // XAccessibleContext - sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( ) + sal_Int64 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( ) { return 0; } - Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int32 /*i*/ ) + Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int64 /*i*/ ) { return Reference< XAccessible >(); } - sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( ) + sal_Int64 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( ) { ::osl::MutexGuard aGuard( m_aMutex ); - sal_Int32 nIndex = -1; + sal_Int64 nIndex = -1; if( m_pLine ) { // search the position of our table window in the table window map @@ -97,7 +86,7 @@ namespace dbaui } OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription( ) { - return "Relation"; + return u"Relation"_ustr; } Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( ) { @@ -109,30 +98,13 @@ namespace dbaui { return Reference< XAccessible >(); } - awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( ) + + awt::Rectangle OConnectionLineAccess::implGetBounds() { - ::osl::MutexGuard aGuard( m_aMutex ); tools::Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : tools::Rectangle()); - return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight()); - } - awt::Point SAL_CALL OConnectionLineAccess::getLocation( ) - { - ::osl::MutexGuard aGuard( m_aMutex ); - Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point()); - return awt::Point(aPoint.X(),aPoint.Y()); - } - awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( ) - { - ::osl::MutexGuard aGuard( m_aMutex ); - Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point()); - return awt::Point(aPoint.X(),aPoint.Y()); - } - awt::Size SAL_CALL OConnectionLineAccess::getSize( ) - { - ::osl::MutexGuard aGuard( m_aMutex ); - Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size()); - return awt::Size(aSize.Width(),aSize.Height()); + return awt::Rectangle(aRect.Left(),aRect.Top(),aRect.getOpenWidth(),aRect.getOpenHeight()); } + // XAccessibleRelationSet sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( ) { @@ -144,22 +116,22 @@ namespace dbaui if( nIndex < 0 || nIndex >= getRelationCount() ) throw IndexOutOfBoundsException(); - Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0); + Sequence<Reference<XAccessible>> aSeq; if( m_pLine ) { - aSeq[0] = m_pLine->GetSourceWin()->GetAccessible(); - aSeq[1] = m_pLine->GetDestWin()->GetAccessible(); + aSeq = { m_pLine->GetSourceWin()->GetAccessible(), + m_pLine->GetDestWin()->GetAccessible() }; } - return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq); + return AccessibleRelation(AccessibleRelationType_CONTROLLED_BY,aSeq); } - sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) + sal_Bool SAL_CALL OConnectionLineAccess::containsRelation(AccessibleRelationType eRelationType) { - return AccessibleRelationType::CONTROLLED_BY == aRelationType; + return AccessibleRelationType_CONTROLLED_BY == eRelationType; } - AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) + AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType(AccessibleRelationType eRelationType) { - if( AccessibleRelationType::CONTROLLED_BY == aRelationType ) + if (AccessibleRelationType_CONTROLLED_BY == eRelationType) return getRelation(0); return AccessibleRelation(); } @@ -175,13 +147,9 @@ namespace dbaui { // clear vector clearLineData(); - m_pParent.clear(); + m_pParent.reset(); vcl::Window::dispose(); } - Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) - { - return this; - } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/ConnectionLineData.cxx b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx index db7177294e64..8267cc3ed8c2 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLineData.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx @@ -18,15 +18,16 @@ */ #include <ConnectionLineData.hxx> +#include <utility> using namespace dbaui; OConnectionLineData::OConnectionLineData() { } -OConnectionLineData::OConnectionLineData( const OUString& rSourceFieldName, const OUString& rDestFieldName ) - :m_aSourceFieldName( rSourceFieldName ) - ,m_aDestFieldName( rDestFieldName ) +OConnectionLineData::OConnectionLineData( OUString sSourceFieldName, OUString sDestFieldName ) + :m_aSourceFieldName(std::move( sSourceFieldName )) + ,m_aDestFieldName(std::move( sDestFieldName )) { } diff --git a/dbaccess/source/ui/querydesign/JAccess.cxx b/dbaccess/source/ui/querydesign/JAccess.cxx index 8068f0fa7f21..1104cefb023f 100644 --- a/dbaccess/source/ui/querydesign/JAccess.cxx +++ b/dbaccess/source/ui/querydesign/JAccess.cxx @@ -29,17 +29,16 @@ namespace dbaui { using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; OJoinDesignViewAccess::OJoinDesignViewAccess(OJoinTableView* _pTableView) - :VCLXAccessibleComponent(_pTableView->GetComponentInterface().is() ? _pTableView->GetWindowPeer() : nullptr) - ,m_pTableView(_pTableView) + : VCLXAccessibleComponent(_pTableView) + , m_pTableView(_pTableView) { } OUString SAL_CALL OJoinDesignViewAccess::getImplementationName() { - return "org.openoffice.comp.dbu.JoinViewAccessibility"; + return u"org.openoffice.comp.dbu.JoinViewAccessibility"_ustr; } void OJoinDesignViewAccess::clearTableView() { @@ -47,24 +46,24 @@ namespace dbaui m_pTableView = nullptr; } // XAccessibleContext - sal_Int32 SAL_CALL OJoinDesignViewAccess::getAccessibleChildCount( ) + sal_Int64 SAL_CALL OJoinDesignViewAccess::getAccessibleChildCount( ) { // TODO may be this will change to only visible windows // this is the same assumption mt implements ::osl::MutexGuard aGuard( m_aMutex ); - sal_Int32 nChildCount = 0; + sal_Int64 nChildCount = 0; if ( m_pTableView ) nChildCount = m_pTableView->GetTabWinCount() + m_pTableView->getTableConnections().size(); return nChildCount; } - Reference< XAccessible > SAL_CALL OJoinDesignViewAccess::getAccessibleChild( sal_Int32 i ) + Reference< XAccessible > SAL_CALL OJoinDesignViewAccess::getAccessibleChild( sal_Int64 i ) { Reference< XAccessible > aRet; ::osl::MutexGuard aGuard( m_aMutex ); if(i < 0 || i >= getAccessibleChildCount() || !m_pTableView) throw IndexOutOfBoundsException(); // check if we should return a table window or a connection - sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount(); + sal_Int64 nTableWindowCount = m_pTableView->GetTabWinCount(); if( i < nTableWindowCount ) { OJoinTableView::OTableWindowMap::const_iterator aIter = std::next(m_pTableView->GetTabWinMap().begin(), i); @@ -78,14 +77,6 @@ namespace dbaui { return AccessibleRole::VIEW_PORT; } - Reference< XAccessibleContext > SAL_CALL OJoinDesignViewAccess::getAccessibleContext( ) - { - return this; - } - // XInterface - IMPLEMENT_FORWARD_XINTERFACE2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE ) - // XTypeProvider - IMPLEMENT_FORWARD_XTYPEPROVIDER2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE ) } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index 49ad53027729..cac9082a0903 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -34,12 +34,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::container; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::ui::dialogs; using namespace ::dbtools; using namespace ::comphelper; @@ -157,7 +153,7 @@ void OJoinController::impl_onModifyChanged() InvalidateFeature( SID_RELATION_ADD_RELATION ); } -void OJoinController::SaveTabWinPosSize(OTableWindow const * pTabWin, long nOffsetX, long nOffsetY) +void OJoinController::SaveTabWinPosSize(OTableWindow const * pTabWin, tools::Long nOffsetX, tools::Long nOffsetY) { // the data for the window const TTableWindowData::value_type& pData = pTabWin->GetData(); @@ -204,6 +200,7 @@ AddTableDialogContext& OJoinController::impl_getDialogContext() const OJoinController* pNonConstThis = const_cast< OJoinController* >( this ); pNonConstThis->m_pDialogContext.reset( new AddTableDialogContext( *pNonConstThis ) ); } + assert(m_pDialogContext && "always exists at this point"); return *m_pDialogContext; } @@ -262,7 +259,7 @@ void OJoinController::runDialogAsync() }); } -void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY ) +void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, tools::Long nOffsetX, tools::Long nOffsetY ) { // Deletion and recreation of the old implementation with the current model is not correct anymore: // The TabWins have a pointer to their data, but they are managed by me. When I delete the old ones, the TabWins suddenly have a pointer to objects, which no longer exist. @@ -277,19 +274,19 @@ void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabW void OJoinController::removeConnectionData(const TTableConnectionData::value_type& _pData) { - m_vTableConnectionData.erase( std::remove(m_vTableConnectionData.begin(),m_vTableConnectionData.end(),_pData),m_vTableConnectionData.end()); + std::erase(m_vTableConnectionData, _pData); } void OJoinController::describeSupportedFeatures() { OJoinController_BASE::describeSupportedFeatures(); - implDescribeSupportedFeature( ".uno:Redo", ID_BROWSER_REDO, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:AddTable", ID_BROWSER_ADDTABLE,CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:EditDoc", ID_BROWSER_EDITDOC, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:GetUndoStrings", SID_GETUNDOSTRINGS ); - implDescribeSupportedFeature( ".uno:GetRedoStrings", SID_GETREDOSTRINGS ); + implDescribeSupportedFeature( u".uno:Redo"_ustr, ID_BROWSER_REDO, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:Save"_ustr, ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:Undo"_ustr, ID_BROWSER_UNDO, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:AddTable"_ustr, ID_BROWSER_ADDTABLE,CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:EditDoc"_ustr, ID_BROWSER_EDITDOC, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:GetUndoStrings"_ustr, SID_GETUNDOSTRINGS ); + implDescribeSupportedFeature( u".uno:GetRedoStrings"_ustr, SID_GETREDOSTRINGS ); } sal_Bool SAL_CALL OJoinController::suspend(sal_Bool _bSuspend) @@ -317,14 +314,9 @@ void OJoinController::loadTableWindows( const ::comphelper::NamedValueCollection m_aMinimumTableViewSize = Point(); - Sequence< PropertyValue > aWindowData; - aWindowData = i_rViewSettings.getOrDefault( "Tables", aWindowData ); - - const PropertyValue* pTablesIter = aWindowData.getConstArray(); - const PropertyValue* pTablesEnd = pTablesIter + aWindowData.getLength(); - for ( ; pTablesIter != pTablesEnd; ++pTablesIter ) + for (auto& table : i_rViewSettings.getOrDefault(u"Tables"_ustr, Sequence<PropertyValue>())) { - ::comphelper::NamedValueCollection aSingleTableData( pTablesIter->Value ); + ::comphelper::NamedValueCollection aSingleTableData(table.Value); loadTableWindow( aSingleTableData ); } if ( m_aMinimumTableViewSize != Point() ) @@ -340,14 +332,14 @@ void OJoinController::loadTableWindow( const ::comphelper::NamedValueCollection& OUString sComposedName,sTableName,sWindowName; bool bShowAll = false; - sComposedName = i_rTableWindowSettings.getOrDefault( "ComposedName", sComposedName ); - sTableName = i_rTableWindowSettings.getOrDefault( "TableName", sTableName ); - sWindowName = i_rTableWindowSettings.getOrDefault( "WindowName", sWindowName ); - nY = i_rTableWindowSettings.getOrDefault( "WindowTop", nY ); - nX = i_rTableWindowSettings.getOrDefault( "WindowLeft", nX ); - nWidth = i_rTableWindowSettings.getOrDefault( "WindowWidth", nWidth ); - nHeight = i_rTableWindowSettings.getOrDefault( "WindowHeight", nHeight ); - bShowAll = i_rTableWindowSettings.getOrDefault( "ShowAll", bShowAll ); + sComposedName = i_rTableWindowSettings.getOrDefault( u"ComposedName"_ustr, sComposedName ); + sTableName = i_rTableWindowSettings.getOrDefault( u"TableName"_ustr, sTableName ); + sWindowName = i_rTableWindowSettings.getOrDefault( u"WindowName"_ustr, sWindowName ); + nY = i_rTableWindowSettings.getOrDefault( u"WindowTop"_ustr, nY ); + nX = i_rTableWindowSettings.getOrDefault( u"WindowLeft"_ustr, nX ); + nWidth = i_rTableWindowSettings.getOrDefault( u"WindowWidth"_ustr, nWidth ); + nHeight = i_rTableWindowSettings.getOrDefault( u"WindowHeight"_ustr, nHeight ); + bShowAll = i_rTableWindowSettings.getOrDefault( u"ShowAll"_ustr, bShowAll ); TTableWindowData::value_type pData = createTableWindowData(sComposedName,sTableName,sWindowName); if ( pData ) @@ -374,20 +366,20 @@ void OJoinController::saveTableWindows( ::comphelper::NamedValueCollection& o_rV for (auto const& elem : m_vTableData) { ::comphelper::NamedValueCollection aWindowData; - aWindowData.put( "ComposedName", elem->GetComposedName() ); - aWindowData.put( "TableName", elem->GetTableName() ); - aWindowData.put( "WindowName", elem->GetWinName() ); - aWindowData.put( "WindowTop", static_cast<sal_Int32>(elem->GetPosition().Y()) ); - aWindowData.put( "WindowLeft", static_cast<sal_Int32>(elem->GetPosition().X()) ); - aWindowData.put( "WindowWidth", static_cast<sal_Int32>(elem->GetSize().Width()) ); - aWindowData.put( "WindowHeight", static_cast<sal_Int32>(elem->GetSize().Height()) ); - aWindowData.put( "ShowAll", elem->IsShowAll() ); + aWindowData.put( u"ComposedName"_ustr, elem->GetComposedName() ); + aWindowData.put( u"TableName"_ustr, elem->GetTableName() ); + aWindowData.put( u"WindowName"_ustr, elem->GetWinName() ); + aWindowData.put( u"WindowTop"_ustr, static_cast<sal_Int32>(elem->GetPosition().Y()) ); + aWindowData.put( u"WindowLeft"_ustr, static_cast<sal_Int32>(elem->GetPosition().X()) ); + aWindowData.put( u"WindowWidth"_ustr, static_cast<sal_Int32>(elem->GetSize().Width()) ); + aWindowData.put( u"WindowHeight"_ustr, static_cast<sal_Int32>(elem->GetSize().Height()) ); + aWindowData.put( u"ShowAll"_ustr, elem->IsShowAll() ); const OUString sTableName( "Table" + OUString::number( i++ ) ); aAllTablesData.put( sTableName, aWindowData.getPropertyValues() ); } - o_rViewSettings.put( "Tables", aAllTablesData.getPropertyValues() ); + o_rViewSettings.put( u"Tables"_ustr, aAllTablesData.getPropertyValues() ); } TTableWindowData::value_type OJoinController::createTableWindowData(const OUString& _sComposedName,const OUString& _sTableName,const OUString& _sWindowName) diff --git a/dbaccess/source/ui/querydesign/JoinDesignView.cxx b/dbaccess/source/ui/querydesign/JoinDesignView.cxx index c0d3ea81c7a0..ae09be66c26b 100644 --- a/dbaccess/source/ui/querydesign/JoinDesignView.cxx +++ b/dbaccess/source/ui/querydesign/JoinDesignView.cxx @@ -24,11 +24,6 @@ #include <vcl/settings.hxx> using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; namespace dbaui { diff --git a/dbaccess/source/ui/querydesign/JoinExchange.cxx b/dbaccess/source/ui/querydesign/JoinExchange.cxx index 312c9d8e9958..8b218ccf269f 100644 --- a/dbaccess/source/ui/querydesign/JoinExchange.cxx +++ b/dbaccess/source/ui/querydesign/JoinExchange.cxx @@ -20,37 +20,25 @@ #include <JoinExchange.hxx> #include <sot/formats.hxx> #include <comphelper/servicehelper.hxx> -#include <cppuhelper/typeprovider.hxx> namespace dbaui { using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::datatransfer; - OJoinExchObj::OJoinExchObj(const OJoinExchangeData& jxdSource,bool _bFirstEntry) - :m_bFirstEntry(_bFirstEntry) - ,m_jxdSourceDescription(jxdSource) - ,m_pDragListener(nullptr) + void OJoinExchObj::setDescriptors(const OJoinExchangeData& jxdSource,bool _bFirstEntry) { - // add available types to list + m_bFirstEntry = _bFirstEntry; + m_jxdSourceDescription = jxdSource; } - OJoinExchObj::~OJoinExchObj() - { - } - - void OJoinExchObj::StartDrag( vcl::Window* _pWindow, sal_Int8 _nDragSourceActions, IDragTransferableListener* _pListener ) + OJoinExchObj::OJoinExchObj() + : m_bFirstEntry(false) { - m_pDragListener = _pListener; - TransferableHelper::StartDrag(_pWindow, _nDragSourceActions); } - void OJoinExchObj::DragFinished( sal_Int8 /*nDropAction*/ ) + OJoinExchObj::~OJoinExchObj() { - if (m_pDragListener) - m_pDragListener->dragFinished(); - m_pDragListener = nullptr; } bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotClipboardFormatId _nSlotID) @@ -66,25 +54,21 @@ namespace dbaui OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject) { OJoinExchangeData aReturn; - auto pImplementation = comphelper::getUnoTunnelImplementation<OJoinExchObj>(_rxObject); + auto pImplementation = comphelper::getFromUnoTunnel<OJoinExchObj>(_rxObject); if (pImplementation) aReturn = pImplementation->m_jxdSourceDescription; return aReturn; } - Sequence< sal_Int8 > OJoinExchObj::getUnoTunnelId() + const Sequence< sal_Int8 > & OJoinExchObj::getUnoTunnelId() { - static ::cppu::OImplementationId implId; - - return implId.getImplementationId(); + static const comphelper::UnoIdInit implId; + return implId.getSeq(); } sal_Int64 SAL_CALL OJoinExchObj::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) { - if (isUnoTunnelId<OJoinExchObj>(_rIdentifier)) - return reinterpret_cast<sal_Int64>(this); - - return 0; + return comphelper::getSomethingImpl(_rIdentifier, this); } void OJoinExchObj::AddSupportedFormats() @@ -108,20 +92,20 @@ namespace dbaui Any SAL_CALL OJoinExchObj::queryInterface( const Type& _rType ) { - Any aReturn = TransferableHelper::queryInterface(_rType); + Any aReturn = TransferDataContainer::queryInterface(_rType); if (!aReturn.hasValue()) aReturn = OJoinExchObj_Base::queryInterface(_rType); return aReturn; } - void SAL_CALL OJoinExchObj::acquire( ) throw() + void SAL_CALL OJoinExchObj::acquire( ) noexcept { - TransferableHelper::acquire( ); + TransferDataContainer::acquire( ); } - void SAL_CALL OJoinExchObj::release( ) throw() + void SAL_CALL OJoinExchObj::release( ) noexcept { - TransferableHelper::release( ); + TransferDataContainer::release( ); } } // namespace dbaui diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 54ea53f0e18f..f2f263d7f006 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -38,7 +38,7 @@ #include <vcl/commandevent.hxx> #include <vcl/event.hxx> #include <vcl/ptrstyle.hxx> -#include <vcl/builder.hxx> +#include <vcl/weldutils.hxx> #include <TableWindowData.hxx> #include <JAccess.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> @@ -46,7 +46,7 @@ #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <cppuhelper/exc_hlp.hxx> #include <connectivity/dbtools.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <algorithm> #include <functional> @@ -54,7 +54,6 @@ using namespace dbaui; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::accessibility; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; #define LINE_SIZE 50 @@ -66,14 +65,14 @@ using namespace ::com::sun::star::lang; #define TABWIN_HEIGHT_STD 120 OScrollWindowHelper::OScrollWindowHelper( vcl::Window* pParent) : Window( pParent) - ,m_aHScrollBar( VclPtr<ScrollBar>::Create(this, WB_HSCROLL|WB_REPEAT|WB_DRAG) ) - ,m_aVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL|WB_REPEAT|WB_DRAG) ) - ,m_pCornerWindow(VclPtr<ScrollBarBox>::Create(this, WB_3DLOOK)) + ,m_aHScrollBar( VclPtr<ScrollAdaptor>::Create(this, true) ) + ,m_aVScrollBar( VclPtr<ScrollAdaptor>::Create(this, false) ) ,m_pTableView(nullptr) { + StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); + SetBackground(aSystemStyle.GetFaceColor()); // ScrollBars - GetHScrollBar().SetRange( Range(0, 1000) ); GetVScrollBar().SetRange( Range(0, 1000) ); @@ -82,7 +81,6 @@ OScrollWindowHelper::OScrollWindowHelper( vcl::Window* pParent) : Window( pParen GetHScrollBar().Show(); GetVScrollBar().Show(); - m_pCornerWindow->Show(); // normally we should be SCROLL_PANE SetAccessibleRole(AccessibleRole::SCROLL_PANE); @@ -97,8 +95,7 @@ void OScrollWindowHelper::dispose() { m_aHScrollBar.disposeAndClear(); m_aVScrollBar.disposeAndClear(); - m_pCornerWindow.disposeAndClear(); - m_pTableView.clear(); + m_pTableView.reset(); vcl::Window::dispose(); } @@ -106,8 +103,8 @@ void OScrollWindowHelper::setTableView(OJoinTableView* _pTableView) { m_pTableView = _pTableView; // ScrollBars - GetHScrollBar().SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) ); - GetVScrollBar().SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) ); + GetHScrollBar().SetScrollHdl( LINK(m_pTableView, OJoinTableView, HorzScrollHdl) ); + GetVScrollBar().SetScrollHdl( LINK(m_pTableView, OJoinTableView, VertScrollHdl) ); } void OScrollWindowHelper::resetRange(const Point& _aSize) @@ -122,8 +119,8 @@ void OScrollWindowHelper::Resize() Window::Resize(); Size aTotalOutputSize = GetOutputSizePixel(); - long nHScrollHeight = GetHScrollBar().GetSizePixel().Height(); - long nVScrollWidth = GetVScrollBar().GetSizePixel().Width(); + tools::Long nHScrollHeight = GetHScrollBar().GetSizePixel().Height(); + tools::Long nVScrollWidth = GetVScrollBar().GetSizePixel().Width(); GetHScrollBar().SetPosSizePixel( Point( 0, aTotalOutputSize.Height()-nHScrollHeight ), @@ -135,11 +132,6 @@ void OScrollWindowHelper::Resize() Size( nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight ) ); - m_pCornerWindow->SetPosSizePixel( - Point( aTotalOutputSize.Width() - nVScrollWidth, aTotalOutputSize.Height() - nHScrollHeight), - Size( nVScrollWidth, nHScrollHeight ) - ); - GetHScrollBar().SetPageSize( aTotalOutputSize.Width() ); GetHScrollBar().SetVisibleSize( aTotalOutputSize.Width() ); @@ -147,7 +139,7 @@ void OScrollWindowHelper::Resize() GetVScrollBar().SetVisibleSize( aTotalOutputSize.Height() ); // adjust the ranges of the scrollbars if necessary - long lRange = GetHScrollBar().GetRange().Max() - GetHScrollBar().GetRange().Min(); + tools::Long lRange = GetHScrollBar().GetRange().Max() - GetHScrollBar().GetRange().Min(); if (m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() > lRange) GetHScrollBar().SetRangeMax(m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() + GetHScrollBar().GetRange().Min()); @@ -162,6 +154,7 @@ void OScrollWindowHelper::Resize() OJoinTableView::OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView ) :Window( pParent,WB_BORDER ) ,DropTargetHelper(this) + ,m_aDragScrollIdle("dbaccess OJoinTableView m_aDragScrollIdle") ,m_aDragOffset( Point(0,0) ) ,m_aScrollOffset( Point(0,0) ) ,m_pDragWin( nullptr ) @@ -169,7 +162,6 @@ OJoinTableView::OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView ) ,m_pSelectedConn( nullptr ) ,m_pLastFocusTabWin(nullptr) ,m_pView( pView ) - ,m_pAccessible(nullptr) { SetSizePixel( Size(1000, 1000) ); @@ -192,19 +184,25 @@ void OJoinTableView::dispose() } // delete lists clearLayoutInformation(); - m_pDragWin.clear(); - m_pSizingWin.clear(); - m_pSelectedConn.clear(); - m_pLastFocusTabWin.clear(); - m_pView.clear(); + m_pDragWin.reset(); + m_pSizingWin.reset(); + m_pSelectedConn.reset(); + m_pLastFocusTabWin.reset(); + m_pView.reset(); m_vTableConnection.clear(); vcl::Window::dispose(); } -IMPL_LINK( OJoinTableView, ScrollHdl, ScrollBar*, pScrollBar, void ) +IMPL_LINK(OJoinTableView, HorzScrollHdl, weld::Scrollbar&, rScrollbar, void) { // move all windows - ScrollPane( pScrollBar->GetDelta(), (pScrollBar == &GetHScrollBar()), false ); + ScrollPane(rScrollbar.adjustment_get_value() - m_aScrollOffset.X(), true, false); +} + +IMPL_LINK(OJoinTableView, VertScrollHdl, weld::Scrollbar&, rScrollbar, void) +{ + // move all windows + ScrollPane(rScrollbar.adjustment_get_value() - m_aScrollOffset.Y(), false, false); } void OJoinTableView::Resize() @@ -237,7 +235,7 @@ void OJoinTableView::Resize() } } -sal_uLong OJoinTableView::GetTabWinCount() const +sal_Int64 OJoinTableView::GetTabWinCount() const { return m_aTableMap.size(); } @@ -258,7 +256,7 @@ bool OJoinTableView::RemoveConnection(VclPtr<OTableConnection>& rConn, bool _bDe modified(); if ( m_pAccessible ) m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, - makeAny(xConn->GetAccessible()), + Any(xConn->GetAccessible()), Any()); if (_bDelete) xConn->disposeOnce(); @@ -326,7 +324,7 @@ void OJoinTableView::AddTabWin(const OUString& _rComposedName, const OUString& r { m_pView->getController().getTableWindowData().push_back( pNewTabWinData); // when we already have a table with this name insert the full qualified one instead - if(m_aTableMap.find(rWinName) != m_aTableMap.end()) + if(m_aTableMap.contains(rWinName)) m_aTableMap[_rComposedName] = pNewTabWin; else m_aTableMap[rWinName] = pNewTabWin; @@ -338,7 +336,7 @@ void OJoinTableView::AddTabWin(const OUString& _rComposedName, const OUString& r if ( m_pAccessible ) m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, Any(), - makeAny(pNewTabWin->GetAccessible())); + Any(pNewTabWin->GetAccessible())); } else { @@ -374,7 +372,7 @@ void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin ) { if ( m_pAccessible ) m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, - makeAny(pTabWin->GetAccessible()),Any() + Any(pTabWin->GetAccessible()),Any() ); pTabWin->Hide(); @@ -402,13 +400,13 @@ void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin ) namespace { - bool isScrollAllowed( OJoinTableView* _pView,long nDelta, bool bHoriz) + bool isScrollAllowed( OJoinTableView* _pView,tools::Long nDelta, bool bHoriz) { // adjust ScrollBar-Positions - ScrollBar& rBar = bHoriz ? _pView->GetHScrollBar() : _pView->GetVScrollBar() ; + ScrollAdaptor& rBar = bHoriz ? _pView->GetHScrollBar() : _pView->GetVScrollBar(); - long nOldThumbPos = rBar.GetThumbPos(); - long nNewThumbPos = nOldThumbPos + nDelta; + tools::Long nOldThumbPos = rBar.GetThumbPos(); + tools::Long nNewThumbPos = nOldThumbPos + nDelta; if( nNewThumbPos < 0 ) nNewThumbPos = 0; else if( nNewThumbPos > rBar.GetRangeMax() ) @@ -424,7 +422,7 @@ namespace return true; } - bool getMovementImpl(OJoinTableView* _pView,const Point& _rPoint,const Size& _rSize,long& _nScrollX,long& _nScrollY) + bool getMovementImpl(OJoinTableView* _pView,const Point& _rPoint,const Size& _rSize,tools::Long& _nScrollX,tools::Long& _nScrollY) { _nScrollY = _nScrollX = 0; // data about the tab win @@ -486,21 +484,21 @@ namespace bool OJoinTableView::isMovementAllowed(const Point& _rPoint,const Size& _rSize) { - long nX,nY; + tools::Long nX,nY; return getMovementImpl(this,_rPoint,_rSize,nX,nY); } void OJoinTableView::EnsureVisible(const OTableWindow* _pWin) { // data about the tab win - TTableWindowData::value_type pData = _pWin->GetData(); + const TTableWindowData::value_type& pData = _pWin->GetData(); EnsureVisible( pData->GetPosition() , pData->GetSize()); Invalidate(InvalidateFlags::NoChildren); } void OJoinTableView::EnsureVisible(const Point& _rPoint,const Size& _rSize) { - long nScrollX,nScrollY; + tools::Long nScrollX,nScrollY; if ( getMovementImpl(this,_rPoint,_rSize,nScrollX,nScrollY) ) { @@ -581,9 +579,9 @@ void OJoinTableView::SetDefaultTabWinPosSize( OTableWindow* pTabWin ) aBottom.AdjustX(aNewSize.Width() ); aBottom.AdjustY(aNewSize.Height() ); - if(!GetHScrollBar().GetRange().IsInside(aBottom.X())) + if(!GetHScrollBar().GetRange().Contains(aBottom.X())) GetHScrollBar().SetRange( Range(0, aBottom.X()) ); - if(!GetVScrollBar().GetRange().IsInside(aBottom.Y())) + if(!GetVScrollBar().GetRange().Contains(aBottom.Y())) GetVScrollBar().SetRange( Range(0, aBottom.Y()) ); pTabWin->SetPosSizePixel( aNewPos, aNewSize ); @@ -638,7 +636,7 @@ void OJoinTableView::BeginChildSizing( OTableWindow* pTabWin, PointerStyle nPoin StartTracking(); } -bool OJoinTableView::ScrollPane( long nDelta, bool bHoriz, bool bPaintScrollBars ) +bool OJoinTableView::ScrollPane( tools::Long nDelta, bool bHoriz, bool bPaintScrollBars ) { bool bRet = true; @@ -647,8 +645,8 @@ bool OJoinTableView::ScrollPane( long nDelta, bool bHoriz, bool bPaintScrollBars { if( bHoriz ) { - long nOldThumbPos = GetHScrollBar().GetThumbPos(); - long nNewThumbPos = nOldThumbPos + nDelta; + tools::Long nOldThumbPos = GetHScrollBar().GetThumbPos(); + tools::Long nNewThumbPos = nOldThumbPos + nDelta; if( nNewThumbPos < 0 ) { nNewThumbPos = 0; @@ -664,8 +662,8 @@ bool OJoinTableView::ScrollPane( long nDelta, bool bHoriz, bool bPaintScrollBars } else { - long nOldThumbPos = GetVScrollBar().GetThumbPos(); - long nNewThumbPos = nOldThumbPos+nDelta; + tools::Long nOldThumbPos = GetVScrollBar().GetThumbPos(); + tools::Long nNewThumbPos = nOldThumbPos+nDelta; if( nNewThumbPos < 0 ) { nNewThumbPos = 0; @@ -861,11 +859,11 @@ void OJoinTableView::DeselectConn(OTableConnection* pConn) // deselect the corresponding entries in the ListBox of the table window OTableWindow* pWin = pConn->GetSourceWin(); if (pWin && pWin->GetListBox()) - pWin->GetListBox()->SelectAll(false); + pWin->GetListBox()->get_widget().unselect_all(); pWin = pConn->GetDestWin(); if (pWin && pWin->GetListBox()) - pWin->GetListBox()->SelectAll(false); + pWin->GetListBox()->get_widget().unselect_all(); pConn->Deselect(); m_pSelectedConn = nullptr; @@ -890,11 +888,10 @@ void OJoinTableView::SelectConn(OTableConnection* pConn) if (!(pSourceBox && pDestBox)) return; - pSourceBox->SelectAll(false); - pDestBox->SelectAll(false); + pSourceBox->get_widget().unselect_all(); + pDestBox->get_widget().unselect_all(); - SvTreeListEntry* pFirstSourceVisible = pSourceBox->GetFirstEntryInView(); - SvTreeListEntry* pFirstDestVisible = pDestBox->GetFirstEntryInView(); + bool bScrolled = false; const std::vector<std::unique_ptr<OConnectionLine>>& rLines = pConn->GetConnLineList(); auto aIter = rLines.rbegin(); @@ -902,27 +899,29 @@ void OJoinTableView::SelectConn(OTableConnection* pConn) { if ((*aIter)->IsValid()) { - SvTreeListEntry* pSourceEntry = pSourceBox->GetEntryFromText((*aIter)->GetData()->GetSourceFieldName()); - if (pSourceEntry) + int nSourceEntry = pSourceBox->GetEntryFromText((*aIter)->GetData()->GetSourceFieldName()); + if (nSourceEntry != -1) { - pSourceBox->Select(pSourceEntry); - pSourceBox->MakeVisible(pSourceEntry); + pSourceBox->get_widget().select(nSourceEntry); + pSourceBox->get_widget().scroll_to_row(nSourceEntry); + bScrolled = true; } - SvTreeListEntry* pDestEntry = pDestBox->GetEntryFromText((*aIter)->GetData()->GetDestFieldName()); - if (pDestEntry) + int nDestEntry = pDestBox->GetEntryFromText((*aIter)->GetData()->GetDestFieldName()); + if (nDestEntry != -1) { - pDestBox->Select(pDestEntry); - pDestBox->MakeVisible(pDestEntry); + pDestBox->get_widget().select(nDestEntry); + pDestBox->get_widget().scroll_to_row(nDestEntry); + bScrolled = true; } - } } - if ((pFirstSourceVisible != pSourceBox->GetFirstEntryInView()) - || (pFirstDestVisible != pDestBox->GetFirstEntryInView())) + if (bScrolled) + { // scrolling was done -> redraw Invalidate(InvalidateFlags::NoChildren); + } } void OJoinTableView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) @@ -1116,12 +1115,13 @@ bool OJoinTableView::IsAddAllowed() return true; } -void OJoinTableView::executePopup(const Point& _aPos, VclPtr<OTableConnection>& rSelConnection) +void OJoinTableView::executePopup(const Point& rPos, VclPtr<OTableConnection>& rSelConnection) { - VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "dbaccess/ui/joinviewmenu.ui", ""); - VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu")); - aContextMenu->Execute(this, _aPos); - OString sIdent = aContextMenu->GetCurItemIdent(); + ::tools::Rectangle aRect(rPos, Size(1, 1)); + weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, u"dbaccess/ui/joinviewmenu.ui"_ustr)); + std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu(u"menu"_ustr)); + OUString sIdent = xContextMenu->popup_at_rect(pPopupParent, aRect); if (sIdent == "delete") RemoveConnection(rSelConnection, true); else if (sIdent == "edit") @@ -1177,7 +1177,7 @@ void OJoinTableView::Command(const CommandEvent& rEvt) Window::Command(rEvt); } -OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin) const +OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSuppressCrossOrNaturalJoin) const { OTableConnection* pConn = nullptr; OSL_ENSURE(pRhs || pLhs, "OJoinTableView::GetTabConn : invalid args !"); @@ -1199,9 +1199,9 @@ OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTab ) ) { - if ( _bSupressCrossOrNaturalJoin ) + if ( _bSuppressCrossOrNaturalJoin ) { - if ( supressCrossNaturalJoin(pData->GetData()) ) + if ( suppressCrossNaturalJoin(pData->GetData()) ) continue; } pConn = pData; @@ -1217,7 +1217,7 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt) bool bHandled = false; switch (rNEvt.GetType()) { - case MouseNotifyEvent::COMMAND: + case NotifyEventType::COMMAND: { const CommandEvent* pCommand = rNEvt.GetCommandEvent(); if (pCommand->GetCommand() == CommandEventId::Wheel) @@ -1234,7 +1234,7 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt) } } break; - case MouseNotifyEvent::KEYINPUT: + case NotifyEventType::KEYINPUT: { if (m_aTableMap.empty()) // no tab wins -> no conns -> no traveling @@ -1362,7 +1362,7 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt) } } break; - case MouseNotifyEvent::GETFOCUS: + case NotifyEventType::GETFOCUS: { if (m_aTableMap.empty()) // no tab wins -> no conns -> no focus change @@ -1433,7 +1433,7 @@ void OJoinTableView::StateChanged( StateChangedType nType ) vcl::Font aFont = rStyleSettings.GetGroupFont(); if ( IsControlFont() ) aFont.Merge( GetControlFont() ); - SetZoomedPointFont(*this, aFont); + SetZoomedPointFont(*GetOutDev(), aFont); for (auto const& elem : m_aTableMap) { @@ -1544,7 +1544,7 @@ void OJoinTableView::addConnection(OTableConnection* _pConnection,bool _bAddData if ( m_pAccessible ) m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, Any(), - makeAny(_pConnection->GetAccessible())); + Any(_pConnection->GetAccessible())); } bool OJoinTableView::allowQueries() const @@ -1558,7 +1558,7 @@ void OJoinTableView::onNoColumns_throw() throw SQLException(); } -bool OJoinTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& ) const +bool OJoinTableView::suppressCrossNaturalJoin(const TTableConnectionData::value_type& ) const { return false; } diff --git a/dbaccess/source/ui/querydesign/QTableConnection.hxx b/dbaccess/source/ui/querydesign/QTableConnection.hxx index b15a26102bb5..c6bd2e10d408 100644 --- a/dbaccess/source/ui/querydesign/QTableConnection.hxx +++ b/dbaccess/source/ui/querydesign/QTableConnection.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLECONNECTION_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLECONNECTION_HXX +#pragma once #include <TableConnection.hxx> #include "QTableConnectionData.hxx" @@ -43,6 +42,5 @@ namespace dbaui }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLECONNECTION_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx index f96a5b1cd033..a42d65508008 100644 --- a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx @@ -25,8 +25,7 @@ using namespace dbaui; OQueryTableConnectionData::OQueryTableConnectionData() - : OTableConnectionData() - , m_nFromEntryIndex(0) + : m_nFromEntryIndex(0) , m_nDestEntryIndex(0) , m_eJoinType (INNER_JOIN) , m_bNatural(false) @@ -88,8 +87,8 @@ void OQueryTableConnectionData::InitFromDrag(const OTableFieldDescRef& rDragLeft // convert Information in rDrag into parameters for the base class init OQueryTableWindow* pSourceWin = static_cast<OQueryTableWindow*>(rDragLeft->GetTabWindow()); OQueryTableWindow* pDestWin = static_cast<OQueryTableWindow*>(rDragRight->GetTabWindow()); - OSL_ENSURE(pSourceWin,"NO Source window found!"); - OSL_ENSURE(pDestWin,"NO Dest window found!"); + assert(pSourceWin && "NO Source window found!"); + assert(pDestWin && "NO Dest window found!"); m_pReferencingTable = pSourceWin->GetData(); m_pReferencedTable = pDestWin->GetData(); diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx index 41639470f1c1..7ccbb03acdfb 100644 --- a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx +++ b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLECONNECTIONDATA_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLECONNECTIONDATA_HXX +#pragma once #include <TableConnectionData.hxx> #include <TableFieldDescription.hxx> @@ -64,6 +63,5 @@ namespace dbaui }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLECONNECTIONDATA_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QTableWindow.cxx b/dbaccess/source/ui/querydesign/QTableWindow.cxx index 6d2916683db9..ed490860c3ea 100644 --- a/dbaccess/source/ui/querydesign/QTableWindow.cxx +++ b/dbaccess/source/ui/querydesign/QTableWindow.cxx @@ -30,12 +30,10 @@ #include <com/sun/star/sdbc/SQLException.hpp> #include "TableFieldInfo.hxx" #include <comphelper/stl_types.hxx> -#include <vcl/treelistentry.hxx> #include <comphelper/types.hxx> using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::beans; using namespace dbaui; OQueryTableWindow::OQueryTableWindow( vcl::Window* pParent, const TTableWindowData::value_type& pTabWinData) @@ -105,22 +103,20 @@ void OQueryTableWindow::deleteUserData(void*& _pUserData) _pUserData = nullptr; } -void OQueryTableWindow::OnEntryDoubleClicked(SvTreeListEntry* pEntry) +void OQueryTableWindow::OnEntryDoubleClicked(weld::TreeIter& rEntry) { - OSL_ENSURE(pEntry != nullptr, "OQueryTableWindow::OnEntryDoubleClicked : pEntry must not be NULL !"); - // you could also scan that and then return, but like this it could possibly hint to faults at the caller - if (getTableView()->getDesignView()->getController().isReadOnly()) return; - OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData()); - OSL_ENSURE(pInf != nullptr, "OQueryTableWindow::OnEntryDoubleClicked : field doesn't have FieldInfo !"); + weld::TreeView& rTreeView = m_xListBox->get_widget(); + OTableFieldInfo* pInf = weld::fromId<OTableFieldInfo*>(rTreeView.get_id(rEntry)); + assert(pInf && "OQueryTableWindow::OnEntryDoubleClicked : field doesn't have FieldInfo !"); // build up DragInfo - OTableFieldDescRef aInfo = new OTableFieldDesc(GetTableName(), m_xListBox->GetEntryText(pEntry)); + OTableFieldDescRef aInfo = new OTableFieldDesc(GetTableName(), rTreeView.get_text(rEntry)); aInfo->SetTabWindow(this); aInfo->SetAlias(GetAliasName()); - aInfo->SetFieldIndex(m_xListBox->GetModel()->GetAbsPos(pEntry)); + aInfo->SetFieldIndex(rTreeView.get_iter_index_in_parent(rEntry)); aInfo->SetDataType(pInf->GetDataType()); // and insert corresponding field @@ -135,29 +131,31 @@ bool OQueryTableWindow::ExistsField(const OUString& strFieldName, OTableFieldDes bool bExists = false; if(xConnection.is()) { - SvTreeListEntry* pEntry = m_xListBox->First(); + weld::TreeView& rTreeView = m_xListBox->get_widget(); + std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator()); + bool bEntry = rTreeView.get_iter_first(*xEntry); try { Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()); - while (pEntry) + while (bEntry) { - if (bCase(strFieldName,m_xListBox->GetEntryText(pEntry))) + if (bCase(strFieldName, rTreeView.get_text(*xEntry))) { - OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData()); + OTableFieldInfo* pInf = weld::fromId<OTableFieldInfo*>(rTreeView.get_id(*xEntry)); assert(pInf && "OQueryTableWindow::ExistsField : field doesn't have FieldInfo !"); rInfo->SetTabWindow(this); rInfo->SetField(strFieldName); rInfo->SetTable(GetTableName()); rInfo->SetAlias(GetAliasName()); - rInfo->SetFieldIndex(m_xListBox->GetModel()->GetAbsPos(pEntry)); + rInfo->SetFieldIndex(rTreeView.get_iter_index_in_parent(*xEntry)); rInfo->SetDataType(pInf->GetDataType()); bExists = true; break; } - pEntry = m_xListBox->Next(pEntry); + bEntry = rTreeView.iter_next(*xEntry); } } catch(SQLException&) diff --git a/dbaccess/source/ui/querydesign/QTableWindow.hxx b/dbaccess/source/ui/querydesign/QTableWindow.hxx index e64fd2e85b7a..72c698c832b7 100644 --- a/dbaccess/source/ui/querydesign/QTableWindow.hxx +++ b/dbaccess/source/ui/querydesign/QTableWindow.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLEWINDOW_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLEWINDOW_HXX +#pragma once #include <TableWindow.hxx> #include "QTableWindowData.hxx" @@ -51,7 +50,7 @@ namespace dbaui protected: - virtual void OnEntryDoubleClicked(SvTreeListEntry* pEntry) override; + virtual void OnEntryDoubleClicked(weld::TreeIter& rEntry) override; // is called from DoubleClickHdl of the ListBox /** delete the user data with the equal type as created within createUserData @param _pUserData @@ -73,6 +72,5 @@ namespace dbaui bool _bPrimaryKey) override; }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLEWINDOW_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QTableWindowData.hxx b/dbaccess/source/ui/querydesign/QTableWindowData.hxx index 382611eeca52..327dc27f1a42 100644 --- a/dbaccess/source/ui/querydesign/QTableWindowData.hxx +++ b/dbaccess/source/ui/querydesign/QTableWindowData.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLEWINDOWDATA_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLEWINDOWDATA_HXX +#pragma once #include <TableWindowData.hxx> @@ -34,7 +33,6 @@ namespace dbaui void SetAliasName(const OUString& rNewAlias) { SetWinName(rNewAlias); } }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QTABLEWINDOWDATA_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx index 37e13213d6c0..dd641be1da4d 100644 --- a/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx +++ b/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYADDTABCONNUNDOACTION_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYADDTABCONNUNDOACTION_HXX +#pragma once #include "QueryTabConnUndoAction.hxx" @@ -46,6 +45,5 @@ namespace dbaui virtual void Redo() override; }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYADDTABCONNUNDOACTION_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx index 63f09af2e508..13262f570290 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX +#pragma once #include <GeneralUndo.hxx> #include <strings.hrc> @@ -38,7 +37,7 @@ namespace dbaui virtual void Redo() override = 0; public: - OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, const char* pCommentID); + OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, TranslateId pCommentID); virtual ~OQueryDesignFieldUndoAct() override; void SetColumnPosition(sal_uInt16 _nColumnPosition) @@ -72,12 +71,12 @@ namespace dbaui class OTabFieldSizedUndoAct final : public OQueryDesignFieldUndoAct { - long m_nNextWidth; + tools::Long m_nNextWidth; public: explicit OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { } - void SetOriginalWidth(long nWidth) { m_nNextWidth = nWidth; } + void SetOriginalWidth(tools::Long nWidth) { m_nNextWidth = nWidth; } virtual void Undo() override; virtual void Redo() override { Undo(); } @@ -91,7 +90,7 @@ namespace dbaui OTableFieldDescRef pDescr; // the deleted column description public: - OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, const char* pCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, pCommentID) { } + OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, TranslateId pCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, pCommentID) { } void SetTabFieldDescr(OTableFieldDescRef const & pDescription) { pDescr = pDescription; } }; @@ -135,6 +134,5 @@ namespace dbaui explicit OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { } }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNFIELDUNDOACT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx index 817e003415a8..c816ede08e06 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx +++ b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNUNDOACTION_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNUNDOACTION_HXX +#pragma once #include <GeneralUndo.hxx> #include <JoinTableView.hxx> @@ -26,16 +25,14 @@ namespace dbaui { // OQueryDesignUndoAction - undo base class for actions in graphical query design (without field list) - class OJoinTableView; class OQueryDesignUndoAction : public OCommentUndoAction { protected: VclPtr<OJoinTableView> m_pOwner; // in this container it all happens public: - OQueryDesignUndoAction(OJoinTableView* pOwner, const char* pCommentID) : OCommentUndoAction(pCommentID), m_pOwner(pOwner) { } + OQueryDesignUndoAction(OJoinTableView* pOwner, TranslateId pCommentID) : OCommentUndoAction(pCommentID), m_pOwner(pOwner) { } }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDESIGNUNDOACTION_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 035e805dbfaa..cd00da8dcf60 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -23,8 +23,9 @@ #include <querycontroller.hxx> #include <sqlbison.hxx> #include <vcl/split.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -49,14 +50,13 @@ #include <unotools/syslocale.hxx> #include <memory> #include <set> +#include <string_view> using namespace ::dbaui; -using namespace ::utl; using namespace ::connectivity; using namespace ::dbtools; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; @@ -95,7 +95,7 @@ namespace bool bHaving, bool _bAddOrOnOneLine); - OUString quoteTableAlias(bool _bQuote, const OUString& _sAliasName, const OUString& _sQuote) + OUString quoteTableAlias(bool _bQuote, const OUString& _sAliasName, std::u16string_view _sQuote) { OUString sRet; if ( _bQuote && !_sAliasName.isEmpty() ) @@ -134,13 +134,10 @@ namespace try { Reference<XNameAccess> xReferencedTableColumns(xInfoData->getReferencedTable()->getColumns()); - Sequence< OUString> aSeq = xInfoData->getReferencingTable()->getColumns()->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& column : xInfoData->getReferencingTable()->getColumns()->getElementNames()) { - if ( xReferencedTableColumns->hasByName(*pIter) ) - xInfoData->AppendConnLine(*pIter,*pIter); + if (xReferencedTableColumns->hasByName(column)) + xInfoData->AppendConnLine(column, column); } } catch( const Exception& ) @@ -159,12 +156,8 @@ namespace OUString aSourceFieldName(_aDragLeft->GetField()); OUString aDestFieldName(_aDragRight->GetField()); // the connection could point on the other side - if(pConn->GetSourceWin() == _aDragRight->GetTabWindow()) - { - OUString aTmp(aSourceFieldName); - aSourceFieldName = aDestFieldName; - aDestFieldName = aTmp; - } + if (pConn->GetSourceWin() == _aDragRight->GetTabWindow()) + std::swap(aSourceFieldName, aDestFieldName); pConn->GetData()->AppendConnLine( aSourceFieldName,aDestFieldName); pConn->UpdateLineList(); // Modified-Flag @@ -238,7 +231,6 @@ namespace bool bErg = false; OUString aTableRange,aColumnName; - sal_uInt16 nCntAccount; ::connectivity::OSQLParseTreeIterator& rParseIter = static_cast<OQueryController&>(_pView->getController()).getParseIterator(); rParseIter.getColumnRange( pColumnRef, aColumnName, aTableRange ); @@ -249,6 +241,7 @@ namespace } if ( !bErg ) { + sal_uInt16 nCntAccount; bErg = static_cast<OQueryTableView*>(_pView->getTableView())->FindTableFromField(aColumnName, _rDragInfo, nCntAccount); if ( !bErg ) bErg = _pView->HasFieldByAliasName(aColumnName, _rDragInfo); @@ -289,11 +282,12 @@ namespace { if(!aCondition.isEmpty()) aCondition.append(C_AND); - aCondition.append(quoteTableAlias(true,pData->GetAliasName(JTCS_FROM),aQuote)); - aCondition.append(::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_FROM) )); - aCondition.append(" = "); - aCondition.append(quoteTableAlias(true,pData->GetAliasName(JTCS_TO),aQuote)); - aCondition.append(::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_TO) )); + aCondition.append( + quoteTableAlias(true,pData->GetAliasName(JTCS_FROM),aQuote) + + ::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_FROM) ) + + " = " + + quoteTableAlias(true,pData->GetAliasName(JTCS_TO),aQuote) + + ::dbtools::quoteName(aQuote, lineData->GetFieldName(JTCS_TO) )); } } catch(SQLException&) @@ -315,7 +309,7 @@ namespace const OQueryTableWindow* _pEntryTabTo, OUString& _rJoin ) { - OSL_ENSURE(_pEntryConn,"TableConnection can not be null!"); + assert(_pEntryConn && "TableConnection can not be null!"); OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pEntryConn->GetData().get()); if ( !(pData->GetJoinType() != INNER_JOIN && _pEntryTabTo->ExistsAVisitedConn()) ) @@ -325,7 +319,7 @@ namespace if(_rJoin.endsWith(")")) { bBrace = true; - _rJoin = _rJoin.replaceAt(_rJoin.getLength()-1,1,OUString(' ')); + _rJoin = _rJoin.replaceAt(_rJoin.getLength()-1,1, u" "); } _rJoin += C_AND + BuildJoinCriteria(_xConnection,&pData->GetConnLineDataList(),pData); if(bBrace) @@ -368,7 +362,7 @@ namespace } OUString BuildJoin( const Reference< XConnection>& _xConnection, const OUString& rLh, - const OUString& rRh, + std::u16string_view rRh, const OQueryTableConnectionData* pData) { @@ -395,7 +389,7 @@ namespace aErg += " FULL OUTER "; break; } - aErg += "JOIN " + rRh; + aErg += OUString::Concat("JOIN ") + rRh; if ( CROSS_JOIN != pData->GetJoinType() && !pData->isNatural() ) { aErg += " ON " + BuildJoinCriteria(_xConnection,&pData->GetConnLineDataList(),pData); @@ -657,11 +651,7 @@ namespace if ( field->isAggregateFunction() ) { OSL_ENSURE(!field->GetFunction().isEmpty(),"Function name must not be empty! ;-("); - OUStringBuffer aTmpStr2( field->GetFunction()); - aTmpStr2.append("("); - aTmpStr2.append(aTmpStr.makeStringAndClear()); - aTmpStr2.append(")"); - aTmpStr = aTmpStr2; + aTmpStr = field->GetFunction() + "(" + aTmpStr.makeStringAndClear() + ")"; } if (!rFieldAlias.isEmpty() && @@ -669,10 +659,10 @@ namespace field->isNumericOrAggregateFunction() || field->isOtherFunction())) { - aTmpStr.append(" AS "); - aTmpStr.append(::dbtools::quoteName(aQuote, rFieldAlias)); + aTmpStr.append(" AS " + ::dbtools::quoteName(aQuote, rFieldAlias)); } - aFieldListStr.append(aTmpStr.makeStringAndClear()); + aFieldListStr.append(aTmpStr); + aTmpStr.setLength(0); aFieldListStr.append(", "); } } @@ -708,7 +698,7 @@ namespace const OUString aQuote = xMetaData->getIdentifierQuoteString(); const IParseContext& rContext = static_cast<OQueryController&>(_pView->getController()).getParser().getContext(); // * must not contain a filter : have I already shown the correct warning ? - bool bCritsOnAsterikWarning = false; // ** TMFS ** + bool bCritsOnAsteriskWarning = false; // ** TMFS ** for (sal_uInt16 i=0 ; i < nMaxCriteria ; i++) { @@ -728,14 +718,14 @@ namespace if ( aFieldName.toChar() == '*' && field->isNoneFunction() ) { // only show the messagebox the first time - if (!bCritsOnAsterikWarning) + if (!bCritsOnAsteriskWarning) { std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(_pView->GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, DBA_RES(STR_QRY_CRITERIA_ON_ASTERISK))); xBox->run(); } - bCritsOnAsterikWarning = true; + bCritsOnAsteriskWarning = true; continue; } aWork = quoteTableAlias(bMulti,field->GetAlias(),aQuote); @@ -872,7 +862,7 @@ namespace Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); OUString aQuote = xMetaData->getIdentifierQuoteString(); // * must not contain filter - have I already shown the warning? - bool bCritsOnAsterikWarning = false; // ** TMFS ** + bool bCritsOnAsteriskWarning = false; // ** TMFS ** for (auto const& field : _rFieldList) { EOrderDir eOrder = field->GetOrderDir(); @@ -884,14 +874,14 @@ namespace if(aColumnName.toChar() == '*') { // only show the MessageBox the first time - if (!bCritsOnAsterikWarning) + if (!bCritsOnAsteriskWarning) { std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(_pView->GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, DBA_RES(STR_QRY_ORDERBY_ON_ASTERISK))); xBox->run(); } - bCritsOnAsterikWarning = true; + bCritsOnAsteriskWarning = true; continue; } @@ -921,14 +911,11 @@ namespace { aWorkStr += quoteTableAlias(bMulti,field->GetAlias(),aQuote) + ::dbtools::quoteName(aQuote, aColumnName); } - aWorkStr += " " + OUString( ";ASC;DESC" ).getToken( static_cast<sal_uInt16>(eOrder), ';' ) + ","; + aWorkStr += OUString::Concat(" ") + o3tl::getToken( u";ASC;DESC", static_cast<sal_uInt16>(eOrder), ';' ) + ","; } } - { - OUString sTemp(comphelper::string::stripEnd(aWorkStr, ',')); - aWorkStr = sTemp; - } + aWorkStr = comphelper::string::stripEnd(aWorkStr, ','); if ( !aWorkStr.isEmpty() ) { @@ -1084,7 +1071,7 @@ namespace } if(!aTableListStr.isEmpty()) - aTableListStr = aTableListStr.replaceAt(aTableListStr.getLength()-1,1, OUString() ); + aTableListStr = aTableListStr.replaceAt(aTableListStr.getLength()-1,1, u"" ); return aTableListStr; } OUString GenerateGroupBy(const OQueryDesignView* _pView,OTableFields& _rFieldList, bool bMulti ) @@ -1142,9 +1129,8 @@ namespace } if ( !aGroupByStr.isEmpty() ) { - aGroupByStr = aGroupByStr.replaceAt(aGroupByStr.getLength()-1,1, OUString(' ') ); - OUString aGroupByStr2 = " GROUP BY " + aGroupByStr; - aGroupByStr = aGroupByStr2; + aGroupByStr = aGroupByStr.replaceAt(aGroupByStr.getLength()-1,1, u" " ); + aGroupByStr = " GROUP BY " + aGroupByStr; } } catch(SQLException&) @@ -1489,7 +1475,7 @@ namespace for (auto const& table : rTabList) { OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(table.second.get()); - if (pTabWin->ExistsField( "*", aDragLeft )) + if (pTabWin->ExistsField( u"*"_ustr, aDragLeft )) { aDragLeft->SetAlias(OUString()); aDragLeft->SetTable(OUString()); @@ -1821,27 +1807,26 @@ namespace else return false; - if ( eJoinType == CROSS_JOIN || bNatural ) - { + if ( eJoinType != CROSS_JOIN && !bNatural ) + return true; - OQueryTableWindow* pLeftWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pNode->getChild(0)) ); - OQueryTableWindow* pRightWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTableRef) ); - OSL_ENSURE(pLeftWindow && pRightWindow,"Table Windows could not be found!"); - if ( !pLeftWindow || !pRightWindow ) - return false; + OQueryTableWindow* pLeftWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pNode->getChild(0)) ); + OQueryTableWindow* pRightWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTableRef) ); + OSL_ENSURE(pLeftWindow && pRightWindow,"Table Windows could not be found!"); + if ( !pLeftWindow || !pRightWindow ) + return false; - OTableFieldDescRef aDragLeft = new OTableFieldDesc(); - aDragLeft->SetTabWindow(pLeftWindow); - aDragLeft->SetTable(pLeftWindow->GetTableName()); - aDragLeft->SetAlias(pLeftWindow->GetAliasName()); + OTableFieldDescRef aDragLeft = new OTableFieldDesc(); + aDragLeft->SetTabWindow(pLeftWindow); + aDragLeft->SetTable(pLeftWindow->GetTableName()); + aDragLeft->SetAlias(pLeftWindow->GetAliasName()); - OTableFieldDescRef aDragRight = new OTableFieldDesc(); - aDragRight->SetTabWindow(pRightWindow); - aDragRight->SetTable(pRightWindow->GetTableName()); - aDragRight->SetAlias(pRightWindow->GetAliasName()); + OTableFieldDescRef aDragRight = new OTableFieldDesc(); + aDragRight->SetTabWindow(pRightWindow); + aDragRight->SetTable(pRightWindow->GetTableName()); + aDragRight->SetAlias(pRightWindow->GetAliasName()); - insertConnection(_pView,eJoinType,aDragLeft,aDragRight,bNatural); - } + insertConnection(_pView,eJoinType,aDragLeft,aDragRight,bNatural); return true; } @@ -2041,7 +2026,7 @@ namespace { OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(table.second.get()); OTableFieldDescRef aInfo = new OTableFieldDesc(); - if (pTabWin->ExistsField( "*", aInfo )) + if (pTabWin->ExistsField( u"*"_ustr, aInfo )) { eErrorCode = _pView->InsertField(aInfo, bFirstField); bFirstField = false; @@ -2137,7 +2122,7 @@ namespace for (auto const& table : *pTabList) { OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(table.second.get()); - if (pTabWin->ExistsField( "*", aInfo )) + if (pTabWin->ExistsField( u"*"_ustr, aInfo )) { aInfo->SetAlias(OUString()); aInfo->SetTable(OUString()); @@ -2174,7 +2159,7 @@ namespace if ( SQL_ISRULE(pColumnRef,general_set_fct) ) { aInfo->SetFunctionType(nFunctionType|FKT_AGGREGATE); - aInfo->SetFunction(comphelper::string::stripEnd(aColumns.getToken(0,'('), ' ')); + aInfo->SetFunction(OUString(comphelper::string::stripEnd(o3tl::getToken(aColumns,0,'('), ' '))); } else aInfo->SetFunctionType(nFunctionType|FKT_OTHER); @@ -2363,7 +2348,7 @@ namespace OUString getParseErrorMessage( SqlParseError _eErrorCode ) { - const char* pResId; + TranslateId pResId; switch (_eErrorCode) { case eIllegalJoin: @@ -2427,7 +2412,7 @@ OQueryDesignView::OQueryDesignView( OQueryContainerWindow* _pParent, m_pSelectionBox = VclPtr<OSelectionBrowseBox>::Create(this); - setNoneVisbleRow(static_cast<OQueryController&>(getController()).getVisibleRows()); + setNoneVisibleRow(static_cast<OQueryController&>(getController()).getVisibleRows()); m_pSelectionBox->Show(); // setup Splitter m_aSplitter->SetSplitHdl(LINK(this, OQueryDesignView,SplitHdl)); @@ -2627,7 +2612,7 @@ void OQueryDesignView::TableDeleted(const OUString& rAliasName) static_cast<OQueryController&>(getController()).InvalidateFeature(ID_BROWSER_ADDTABLE); // inform the view again } -bool OQueryDesignView::HasFieldByAliasName(const OUString& rFieldName, OTableFieldDescRef const & rInfo) const +bool OQueryDesignView::HasFieldByAliasName(std::u16string_view rFieldName, OTableFieldDescRef const & rInfo) const { return m_pSelectionBox->HasFieldByAliasName( rFieldName, rInfo); } @@ -2639,18 +2624,18 @@ SqlParseError OQueryDesignView::InsertField( const OTableFieldDescRef& rInfo, bo sal_Int32 OQueryDesignView::getColWidth(sal_uInt16 _nColPos) const { - static sal_Int32 s_nDefaultWidth = GetTextWidth("0") * 15; + static sal_Int32 s_nDefaultWidth = GetTextWidth(u"0"_ustr) * 15; sal_Int32 nWidth = static_cast<OQueryController&>(getController()).getColWidth(_nColPos); if ( !nWidth ) nWidth = s_nDefaultWidth; return nWidth; } -void OQueryDesignView::fillValidFields(const OUString& sAliasName, weld::ComboBox& rFieldList) +void OQueryDesignView::fillValidFields(std::u16string_view sAliasName, weld::ComboBox& rFieldList) { rFieldList.clear(); - bool bAllTables = sAliasName.isEmpty(); + bool bAllTables = sAliasName.empty(); OJoinTableView::OTableWindowMap& rTabWins = m_pTableView->GetTabWinMap(); OUString strCurrentPrefix; @@ -2682,7 +2667,7 @@ void OQueryDesignView::fillValidFields(const OUString& sAliasName, weld::ComboBo bool OQueryDesignView::PreNotify(NotifyEvent& rNEvt) { - if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS) + if (rNEvt.GetType() == NotifyEventType::GETFOCUS) { if ( m_pSelectionBox && m_pSelectionBox->HasChildPathFocus() ) m_eChildFocus = SELECTION; @@ -2764,22 +2749,19 @@ OUString OQueryDesignView::getStatement() OUString aTmp = "( " + aJoinCrit + " )"; if(!aCriteriaListStr.isEmpty()) { - aTmp += C_AND + aCriteriaListStr.makeStringAndClear(); + aTmp += C_AND; } - aCriteriaListStr = aTmp; + aCriteriaListStr.insert(0, aTmp); } // ----------------- construct statement ---------------------- OUStringBuffer aSqlCmd("SELECT "); if(rController.isDistinct()) aSqlCmd.append(" DISTINCT "); - aSqlCmd.append(aFieldListStr); - aSqlCmd.append(" FROM "); - aSqlCmd.append(aTableListStr); + aSqlCmd.append(aFieldListStr + " FROM " + aTableListStr); if (!aCriteriaListStr.isEmpty()) { - aSqlCmd.append(" WHERE "); - aSqlCmd.append(aCriteriaListStr.makeStringAndClear()); + aSqlCmd.append(" WHERE " + aCriteriaListStr); } Reference<XDatabaseMetaData> xMeta; if ( xConnection.is() ) @@ -2792,8 +2774,7 @@ OUString OQueryDesignView::getStatement() // ----------------- construct GroupBy and attach ------------ if(!aHavingStr.isEmpty()) { - aSqlCmd.append(" HAVING "); - aSqlCmd.append(aHavingStr.makeStringAndClear()); + aSqlCmd.append(" HAVING " + aHavingStr); } // ----------------- construct sorting and attach ------------ OUString sOrder; @@ -2812,7 +2793,7 @@ OUString OQueryDesignView::getStatement() const sal_Int64 nLimit = rController.getLimit(); if( nLimit != -1 ) { - aSqlCmd.append( " LIMIT " ).append( OUString::number(nLimit) ); + aSqlCmd.append( " LIMIT " + OUString::number(nLimit) ); } } @@ -2943,7 +2924,7 @@ std::unique_ptr<OSQLParseNode> OQueryDesignView::getPredicateTreeFromEntry(const } Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); - parse::OParseColumn* pColumn = new parse::OParseColumn( pEntry->GetField(), + rtl::Reference<parse::OParseColumn> pColumn = new parse::OParseColumn( pEntry->GetField(), OUString(), OUString(), OUString(), @@ -3009,9 +2990,9 @@ void OQueryDesignView::reset() m_pTableView->ReSync(); } -void OQueryDesignView::setNoneVisbleRow(sal_Int32 _nRows) +void OQueryDesignView::setNoneVisibleRow(sal_Int32 _nRows) { - m_pSelectionBox->SetNoneVisbleRow(_nRows); + m_pSelectionBox->SetNoneVisibleRow(_nRows); } void OQueryDesignView::initByFieldDescriptions( const Sequence< PropertyValue >& i_rFieldDescriptions ) diff --git a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx index 1e7ca6bb9525..39873281586a 100644 --- a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx +++ b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx @@ -23,7 +23,8 @@ using namespace dbaui; void OJoinMoveTabWinUndoAct::TogglePosition() { - Point ptFrameScrollPos(m_pOwner->GetHScrollBar().GetThumbPos(), m_pOwner->GetVScrollBar().GetThumbPos()); + Point ptFrameScrollPos(m_pOwner->GetHScrollBar().GetThumbPos(), + m_pOwner->GetVScrollBar().GetThumbPos()); Point ptNext = m_pTabWin->GetPosPixel() + ptFrameScrollPos; m_pTabWin->SetPosPixel(m_ptNextPosition - ptFrameScrollPos); diff --git a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx index 38cca8bc61bd..b11108f85c9e 100644 --- a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYMOVETABWINUNDOACT_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYMOVETABWINUNDOACT_HXX +#pragma once #include "QueryDesignUndoAction.hxx" #include <strings.hrc> @@ -29,7 +28,6 @@ namespace dbaui { // OQueryMoveTabWinUndoAct - Undo class for moving a TabWin - class OTableWindow; class OJoinMoveTabWinUndoAct final : public OQueryDesignUndoAction { Point m_ptNextPosition; @@ -51,6 +49,5 @@ namespace dbaui { } } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYMOVETABWINUNDOACT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx index a36eb5eb5fe9..a8c62bfa1350 100644 --- a/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYSIZETABWINUNDOACT_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYSIZETABWINUNDOACT_HXX +#pragma once #include "QueryDesignUndoAction.hxx" #include <strings.hrc> @@ -27,7 +26,6 @@ namespace dbaui { // OQuerySizeTabWinUndoAct - undo class to change size of TabWins - class OTableWindow; class OJoinSizeTabWinUndoAct final : public OQueryDesignUndoAction { Point m_ptNextPosition; @@ -68,6 +66,4 @@ namespace dbaui } } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYSIZETABWINUNDOACT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx index b209a62ce5e8..e3b6cd0e94bb 100644 --- a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx +++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx @@ -29,16 +29,16 @@ using namespace dbaui; OQueryTabConnUndoAction::~OQueryTabConnUndoAction() { if (m_bOwnerOfConn) - { // I have the connection -> delete + { // I have the connection -> delete m_pOwner->DeselectConn(m_pConnection); m_pConnection.disposeAndClear(); } } -OQueryTabConnUndoAction::OQueryTabConnUndoAction(OQueryTableView* pOwner, const char* pCommentID) - :OQueryDesignUndoAction(pOwner, pCommentID) - ,m_pConnection(nullptr) - ,m_bOwnerOfConn(false) +OQueryTabConnUndoAction::OQueryTabConnUndoAction(OQueryTableView* pOwner, TranslateId pCommentID) + : OQueryDesignUndoAction(pOwner, pCommentID) + , m_pConnection(nullptr) + , m_bOwnerOfConn(false) { } @@ -77,13 +77,11 @@ void OQueryDelTabConnUndoAction::Redo() } OQueryTabWinShowUndoAct::OQueryTabWinShowUndoAct(OQueryTableView* pOwner) - : OQueryTabWinUndoAct(pOwner, STR_QUERY_UNDO_TABWINSHOW) + : OQueryTabWinUndoAct(pOwner, STR_QUERY_UNDO_TABWINSHOW) { } -OQueryTabWinShowUndoAct::~OQueryTabWinShowUndoAct() -{ -} +OQueryTabWinShowUndoAct::~OQueryTabWinShowUndoAct() {} void OQueryTabWinShowUndoAct::Undo() { @@ -93,28 +91,26 @@ void OQueryTabWinShowUndoAct::Undo() void OQueryTabWinShowUndoAct::Redo() { - static_cast<OQueryTableView*>(m_pOwner.get())->ShowTabWin(m_pTabWin, this,true); + static_cast<OQueryTableView*>(m_pOwner.get())->ShowTabWin(m_pTabWin, this, true); SetOwnership(false); } OQueryTabWinDelUndoAct::OQueryTabWinDelUndoAct(OQueryTableView* pOwner) - : OQueryTabWinUndoAct(pOwner, STR_QUERY_UNDO_TABWINDELETE) + : OQueryTabWinUndoAct(pOwner, STR_QUERY_UNDO_TABWINDELETE) { } -OQueryTabWinDelUndoAct::~OQueryTabWinDelUndoAct() -{ -} +OQueryTabWinDelUndoAct::~OQueryTabWinDelUndoAct() {} void OQueryTabWinDelUndoAct::Undo() { - static_cast<OQueryTableView*>(m_pOwner.get())->ShowTabWin( m_pTabWin, this,true ); + static_cast<OQueryTableView*>(m_pOwner.get())->ShowTabWin(m_pTabWin, this, true); SetOwnership(false); } void OQueryTabWinDelUndoAct::Redo() { - static_cast<OQueryTableView*>(m_pOwner.get())->HideTabWin( m_pTabWin, this ); + static_cast<OQueryTableView*>(m_pOwner.get())->HideTabWin(m_pTabWin, this); SetOwnership(true); } diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx index 36b1aae981a6..2905572adaed 100644 --- a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx +++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABCONNUNDOACTION_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABCONNUNDOACTION_HXX +#pragma once #include "QueryDesignUndoAction.hxx" #include "QTableConnection.hxx" @@ -25,7 +24,6 @@ namespace dbaui { - class OQueryTableConnection; class OQueryTableView; class OQueryTabConnUndoAction : public OQueryDesignUndoAction { @@ -35,7 +33,7 @@ namespace dbaui // am I the only owner of the connection? (changes with every redo and undo) public: - OQueryTabConnUndoAction(OQueryTableView* pOwner, const char* pCommentID); + OQueryTabConnUndoAction(OQueryTableView* pOwner, TranslateId pCommentID); virtual ~OQueryTabConnUndoAction() override; virtual void Undo() override = 0; @@ -46,7 +44,6 @@ namespace dbaui void SetOwnership(bool bTakeIt) { m_bOwnerOfConn = bTakeIt; } }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABCONNUNDOACTION_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx index 748ca7c38110..95b740de9871 100644 --- a/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABWINSHOWUNDOACT_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABWINSHOWUNDOACT_HXX +#pragma once #include "QueryTabWinUndoAct.hxx" @@ -48,6 +47,5 @@ namespace dbaui virtual void Redo() override; }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABWINSHOWUNDOACT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx index 6242c94fc09f..2afe74db4232 100644 --- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx +++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx @@ -20,12 +20,11 @@ #include "QueryTabWinUndoAct.hxx" #include <osl/diagnose.h> #include "QTableWindow.hxx" -#include <TableConnection.hxx> #include "QueryDesignFieldUndoAct.hxx" #include <QueryTableView.hxx> using namespace dbaui; -OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, const char* pCommentID) +OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, TranslateId pCommentID) : OCommentUndoAction(pCommentID) , pOwner(pSelBrwBox) , m_nColumnPosition(BROWSER_INVALIDID) @@ -37,7 +36,7 @@ OQueryDesignFieldUndoAct::~OQueryDesignFieldUndoAct() pOwner = nullptr; } -OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, const char* pCommentID) +OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, TranslateId pCommentID) : OQueryDesignUndoAction(pOwner, pCommentID) , m_pTabWin(nullptr) , m_bOwnerOfObjects(false) @@ -88,7 +87,7 @@ void OTabFieldSizedUndoAct::Undo() if ( m_nColumnPosition != BROWSER_INVALIDID ) { sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPosition); - long nNextWidth = pOwner->GetColumnWidth(nColumnId); + tools::Long nNextWidth = pOwner->GetColumnWidth(nColumnId); pOwner->SetColWidth(nColumnId, m_nNextWidth); m_nNextWidth = nNextWidth; } diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx index 008c76260216..540f332757eb 100644 --- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx +++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABWINUNDOACT_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABWINUNDOACT_HXX +#pragma once #include "QueryDesignUndoAction.hxx" #include "QTableWindow.hxx" @@ -28,8 +27,6 @@ namespace dbaui { // OQueryTabWinUndoAct - undo base class for all which is concerned with insert/remove TabWins - class OQueryTableWindow; - class OTableConnection; class OQueryTableView; class OQueryTabWinUndoAct : public OQueryDesignUndoAction { @@ -40,7 +37,7 @@ namespace dbaui // am I the only owner of the managed objects? (changes with every redo or undo) public: - OQueryTabWinUndoAct(OQueryTableView* pOwner, const char* pCommentID); + OQueryTabWinUndoAct(OQueryTableView* pOwner, TranslateId pCommentID); virtual ~OQueryTabWinUndoAct() override; void SetOwnership(bool bTakeIt) { m_bOwnerOfObjects = bTakeIt; } @@ -58,6 +55,5 @@ namespace dbaui }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYTABWINUNDOACT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index 1847cfe7b5ee..2ca8c71b837f 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -19,7 +19,7 @@ #include <QueryTableView.hxx> #include <TableFieldDescription.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <helpids.h> #include "QTableWindow.hxx" @@ -224,7 +224,7 @@ void OQueryTableView::ReSync() pTabWin.disposeAndClear(); arrInvalidTables.push_back(pData->GetAliasName()); - rTabWinDataList.erase( std::remove(rTabWinDataList.begin(), rTabWinDataList.end(), *aIter), rTabWinDataList.end()); + std::erase(rTabWinDataList, *aIter); continue; } @@ -253,7 +253,7 @@ void OQueryTableView::ReSync() if (bInvalid) { // no -> bad luck, no connection - rTabConnDataList.erase( std::remove(rTabConnDataList.begin(), rTabConnDataList.end(), *aConIter), rTabConnDataList.end()); + std::erase(rTabConnDataList, *aConIter); continue; } @@ -353,7 +353,7 @@ void OQueryTableView::AddTabWin(const OUString& _rTableName, const OUString& _rA } // find the table which has a foreign key with this referencedTable name -static Reference<XPropertySet> getKeyReferencedTo(const Reference<XIndexAccess>& _rxKeys,const OUString& _rReferencedTable) +static Reference<XPropertySet> getKeyReferencedTo(const Reference<XIndexAccess>& _rxKeys,std::u16string_view _rReferencedTable) { if(!_rxKeys.is()) return Reference<XPropertySet>(); @@ -430,7 +430,7 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString& if ( m_pAccessible ) m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, Any(), - makeAny(pNewTabWin->GetAccessible()) + Any(pNewTabWin->GetAccessible()) ); do { @@ -493,10 +493,10 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString& if ( pTabWinTmp == pNewTabWin ) continue; + assert(pTabWinTmp && "TableWindow is null!"); if ( pTabWinTmp->GetData()->isQuery() ) continue; - OSL_ENSURE(pTabWinTmp,"TableWindow is null!"); Reference< XPropertySet > xFKKey = getKeyReferencedTo( pTabWinTmp->GetData()->getKeys(), pNewTabWin->GetComposedName() ); if ( !xFKKey.is() ) continue; @@ -528,8 +528,10 @@ void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJ OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>(jxdDest.pListBox->GetTabWin()); OUString aSourceFieldName, aDestFieldName; - aSourceFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry); - aDestFieldName = jxdDest.pListBox->GetEntryText(jxdDest.pEntry); + weld::TreeView& rSourceTreeView = jxdSource.pListBox->get_widget(); + aSourceFieldName = rSourceTreeView.get_text(jxdSource.nEntry); + weld::TreeView& rDestTreeView = jxdDest.pListBox->get_widget(); + aDestFieldName = rDestTreeView.get_text(jxdDest.nEntry); OTableConnection* pConn = GetTabConn(pSourceWin,pDestWin,true); if ( !pConn ) @@ -541,9 +543,9 @@ void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJ // Get name/position of both affected fields ... // Source - nSourceFieldIndex = jxdSource.pListBox->GetModel()->GetAbsPos(jxdSource.pEntry); + nSourceFieldIndex = jxdSource.nEntry; // Dest - nDestFieldIndex = jxdDest.pListBox->GetModel()->GetAbsPos(jxdDest.pEntry); + nDestFieldIndex = jxdDest.nEntry; // ... and set them xNewConnectionData->SetFieldIndex(JTCS_FROM, nSourceFieldIndex); @@ -559,11 +561,7 @@ void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJ { // the connection could point on the other side if(pConn->GetSourceWin() == pDestWin) - { - OUString aTmp(aSourceFieldName); - aSourceFieldName = aDestFieldName; - aDestFieldName = aTmp; - } + std::swap(aSourceFieldName, aDestFieldName); pConn->GetData()->AppendConnLine( aSourceFieldName,aDestFieldName ); @@ -691,7 +689,7 @@ void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin) modified(); if ( m_pAccessible ) m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD, - makeAny(pTabWin->GetAccessible()), + Any(pTabWin->GetAccessible()), Any() ); } @@ -736,7 +734,7 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc // the TabWin data must also be passed out of my responsibility TTableWindowData& rTabWinDataList = m_pView->getController().getTableWindowData(); - rTabWinDataList.erase( std::remove(rTabWinDataList.begin(), rTabWinDataList.end(), pTabWin->GetData()), rTabWinDataList.end()); + std::erase(rTabWinDataList, pTabWin->GetData()); // The data should not be destroyed as TabWin itself - which is still alive - needs them // Either it goes back into my responsibility, (via ShowTabWin), then I add the data back, // or the Undo-Action, which currently has full responsibility for the window @@ -753,7 +751,7 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc { VclPtr<OTableConnection> xTmpEntry = *aIter2; OQueryTableConnection* pTmpEntry = static_cast<OQueryTableConnection*>(xTmpEntry.get()); - OSL_ENSURE(pTmpEntry,"OQueryTableConnection is null!"); + assert(pTmpEntry && "OQueryTableConnection is null!"); if( pTmpEntry->GetAliasName(JTCS_FROM) == pTabWin->GetAliasName() || pTmpEntry->GetAliasName(JTCS_TO) == pTabWin->GetAliasName() ) { @@ -878,7 +876,7 @@ void OQueryTableView::onNoColumns_throw() ::dbtools::throwSQLException( sError, ::dbtools::StandardSQLState::GENERAL_ERROR, nullptr ); } -bool OQueryTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const +bool OQueryTableView::suppressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const { OQueryTableConnectionData* pQueryData = static_cast<OQueryTableConnectionData*>(_pData.get()); return pQueryData && (pQueryData->GetJoinType() == CROSS_JOIN); diff --git a/dbaccess/source/ui/querydesign/QueryTextView.cxx b/dbaccess/source/ui/querydesign/QueryTextView.cxx index 9633146900c6..d08de914530d 100644 --- a/dbaccess/source/ui/querydesign/QueryTextView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTextView.cxx @@ -17,94 +17,159 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <svx/svxids.hrc> #include <QueryTextView.hxx> #include <querycontainerwindow.hxx> +#include <helpids.h> +#include <querycontroller.hxx> #include <sqledit.hxx> #include <undosqledit.hxx> -#include <QueryDesignView.hxx> using namespace dbaui; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; // end of temp classes -OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent) - :Window(_pParent) +OQueryTextView::OQueryTextView(OQueryContainerWindow* pParent, OQueryController& rController) + : InterimItemWindow(pParent, u"dbaccess/ui/queryview.ui"_ustr, u"QueryView"_ustr) + , m_rController(rController) + , m_xSQL(new SQLEditView(m_xBuilder->weld_scrolled_window(u"scrolledwindow"_ustr, true))) + , m_xSQLEd(new weld::CustomWeld(*m_xBuilder, u"sql"_ustr, *m_xSQL)) + , m_timerUndoActionCreation("dbaccess OQueryTextView m_timerUndoActionCreation") + , m_timerInvalidate("dbaccess OQueryTextView m_timerInvalidate") + , m_bStopTimer(false) { - m_pEdit = VclPtr<OSqlEdit>::Create(this); - m_pEdit->SetRightToLeft(false); - m_pEdit->ClearModifyFlag(); - m_pEdit->SaveValue(); - m_pEdit->SetPosPixel( Point( 0, 0 ) ); - m_pEdit->Show(); + m_xSQL->DisableInternalUndo(); + m_xSQL->SetHelpId(HID_CTL_QRYSQLEDIT); + m_xSQL->SetModifyHdl(LINK(this, OQueryTextView, ModifyHdl)); + m_xSQL->SetAcceptsTab(true); + + m_timerUndoActionCreation.SetTimeout(1000); + m_timerUndoActionCreation.SetInvokeHandler(LINK(this, OQueryTextView, OnUndoActionTimer)); + + m_timerInvalidate.SetTimeout(200); + m_timerInvalidate.SetInvokeHandler(LINK(this, OQueryTextView, OnInvalidateTimer)); + m_timerInvalidate.Start(); } -OQueryTextView::~OQueryTextView() +IMPL_LINK_NOARG(OQueryTextView, ModifyHdl, LinkParamNone*, void) { - disposeOnce(); + if (m_timerUndoActionCreation.IsActive()) + m_timerUndoActionCreation.Stop(); + m_timerUndoActionCreation.Start(); + + if (!m_rController.isModified()) + m_rController.setModified(true); + + m_rController.InvalidateFeature(SID_SBA_QRY_EXECUTE); + m_rController.InvalidateFeature(SID_CUT); + m_rController.InvalidateFeature(SID_COPY); } -void OQueryTextView::dispose() +IMPL_LINK_NOARG(OQueryTextView, OnUndoActionTimer, Timer*, void) { - m_pEdit.disposeAndClear(); - vcl::Window::dispose(); + OUString aText = m_xSQL->GetText(); + if (aText == m_strOrigText) + return; + + SfxUndoManager& rUndoMgr = m_rController.GetUndoManager(); + std::unique_ptr<OSqlEditUndoAct> xUndoAct(new OSqlEditUndoAct(*this)); + + xUndoAct->SetOriginalText(m_strOrigText); + rUndoMgr.AddUndoAction(std::move(xUndoAct)); + + m_rController.InvalidateFeature(SID_UNDO); + m_rController.InvalidateFeature(SID_REDO); + + m_strOrigText = aText; } -void OQueryTextView::GetFocus() +IMPL_LINK_NOARG(OQueryTextView, OnInvalidateTimer, Timer*, void) { - if ( m_pEdit ) - m_pEdit->GrabFocus(); + m_rController.InvalidateFeature(SID_CUT); + m_rController.InvalidateFeature(SID_COPY); + if (!m_bStopTimer) + m_timerInvalidate.Start(); } -void OQueryTextView::Resize() +void OQueryTextView::startTimer() { - Window::Resize(); - m_pEdit->SetSizePixel( GetOutputSizePixel() ); + m_bStopTimer = false; + if (!m_timerInvalidate.IsActive()) + m_timerInvalidate.Start(); } -OUString OQueryTextView::getStatement() const +void OQueryTextView::stopTimer() { - return m_pEdit->GetText(); + m_bStopTimer = true; + if (m_timerInvalidate.IsActive()) + m_timerInvalidate.Stop(); } -void OQueryTextView::clear() -{ - std::unique_ptr<OSqlEditUndoAct> pUndoAct(new OSqlEditUndoAct( m_pEdit )); +OQueryTextView::~OQueryTextView() { disposeOnce(); } - pUndoAct->SetOriginalText( m_pEdit->GetText() ); - getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( std::move(pUndoAct) ); +void OQueryTextView::dispose() +{ + if (m_timerUndoActionCreation.IsActive()) + m_timerUndoActionCreation.Stop(); - m_pEdit->SetText(OUString()); + m_xSQLEd.reset(); + m_xSQL.reset(); + InterimItemWindow::dispose(); } -void OQueryTextView::setStatement(const OUString& _rsStatement) +void OQueryTextView::GetFocus() { - m_pEdit->SetText(_rsStatement); + if (m_xSQL) + { + m_xSQL->GrabFocus(); + m_strOrigText = m_xSQL->GetText(); + } + InterimItemWindow::GetFocus(); } -void OQueryTextView::copy() +OUString OQueryTextView::getStatement() const { return m_xSQL->GetText(); } + +void OQueryTextView::clear() { - if(!m_pEdit->IsInAccelAct() ) - m_pEdit->Copy(); + std::unique_ptr<OSqlEditUndoAct> xUndoAct(new OSqlEditUndoAct(*this)); + + xUndoAct->SetOriginalText(m_xSQL->GetText()); + m_rController.addUndoActionAndInvalidate(std::move(xUndoAct)); + + SetSQLText(OUString()); } -bool OQueryTextView::isCutAllowed() const +void OQueryTextView::setStatement(const OUString& rsStatement) { SetSQLText(rsStatement); } + +OUString OQueryTextView::GetSQLText() const { return m_xSQL->GetText(); } + +void OQueryTextView::SetSQLText(const OUString& rNewText) { - return !m_pEdit->GetSelected().isEmpty(); + if (m_timerUndoActionCreation.IsActive()) + { + // create the trailing undo-actions + m_timerUndoActionCreation.Stop(); + OnUndoActionTimer(nullptr); + } + + m_xSQL->SetTextAndUpdate(rNewText); + + m_strOrigText = rNewText; } +void OQueryTextView::copy() { m_xSQL->Copy(); } + +bool OQueryTextView::isCutAllowed() const { return m_xSQL->HasSelection(); } + void OQueryTextView::cut() { - if(!m_pEdit->IsInAccelAct() ) - m_pEdit->Cut(); - getContainerWindow()->getDesignView()->getController().setModified(true); + m_xSQL->Cut(); + m_rController.setModified(true); } void OQueryTextView::paste() { - if(!m_pEdit->IsInAccelAct() ) - m_pEdit->Paste(); - getContainerWindow()->getDesignView()->getController().setModified(true); + m_xSQL->Paste(); + m_rController.setModified(true); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx index e7d6758f480f..a51f2941addb 100644 --- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx +++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx @@ -23,7 +23,6 @@ #include <querycontainerwindow.hxx> #include <adtabdlg.hxx> #include <querycontroller.hxx> -#include <sqledit.hxx> using namespace dbaui; using namespace ::com::sun::star::uno; @@ -33,7 +32,7 @@ OQueryViewSwitch::OQueryViewSwitch(OQueryContainerWindow* _pParent, OQueryContro : m_bAddTableDialogWasVisible(false) { - m_pTextView = VclPtr<OQueryTextView>::Create(_pParent); + m_pTextView = VclPtr<OQueryTextView>::Create(_pParent, _rController); m_pDesignView = VclPtr<OQueryDesignView>::Create( _pParent, _rController, _rxContext ); } @@ -154,7 +153,7 @@ void OQueryViewSwitch::impl_forceSQLView() // tell the views they're in/active m_pDesignView->stopTimer(); - m_pTextView->getSqlEdit()->startTimer(); + m_pTextView->startTimer(); // set the most recent statement at the text view m_pTextView->clear(); @@ -170,7 +169,7 @@ void OQueryViewSwitch::forceInitialView() else { // tell the text view it's inactive now - m_pTextView->getSqlEdit()->stopTimer(); + m_pTextView->stopTimer(); // update the "Add Table" dialog OAddTableDlg* pAddTabDialog( getAddTableDialog() ); @@ -199,7 +198,7 @@ bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo ) else { // tell the text view it's inactive now - m_pTextView->getSqlEdit()->stopTimer(); + m_pTextView->stopTimer(); // update the "Add Table" dialog OAddTableDlg* pAddTabDialog( getAddTableDialog() ); @@ -284,10 +283,10 @@ void OQueryViewSwitch::reset() switchView( nullptr ); } -void OQueryViewSwitch::setNoneVisbleRow(sal_Int32 _nRows) +void OQueryViewSwitch::setNoneVisibleRow(sal_Int32 _nRows) { if(m_pDesignView) - m_pDesignView->setNoneVisbleRow(_nRows); + m_pDesignView->setNoneVisibleRow(_nRows); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index bb7bd9584115..b1b4ae673efa 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include "SelectionBrowseBox.hxx" #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> #include <com/sun/star/sdbc/DataType.hpp> @@ -42,9 +46,10 @@ #include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <i18nlangtag/languagetag.hxx> -#include <vcl/treelistentry.hxx> #include <vcl/commandevent.hxx> #include <vcl/svapp.hxx> +#include <comphelper/diagnose_ex.hxx> +#include <o3tl/string_view.hxx> using namespace ::svt; using namespace ::dbaui; @@ -52,26 +57,24 @@ using namespace ::connectivity; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::accessibility; #define DEFAULT_QUERY_COLS 20 -#define DEFAULT_SIZE GetTextWidth("0") * 30 +#define DEFAULT_SIZE GetTextWidth(u"0"_ustr) * 30 #define HANDLE_ID 0 #define HANDLE_COLUMN_WIDTH 70 #define SORT_COLUMN_NONE 0xFFFFFFFF namespace { - bool isFieldNameAsterisk(const OUString& _sFieldName ) + bool isFieldNameAsterisk(std::u16string_view _sFieldName ) { - bool bAsterisk = _sFieldName.isEmpty() || _sFieldName.toChar() == '*'; + bool bAsterisk = _sFieldName.empty() || _sFieldName[0] == '*'; if ( !bAsterisk ) { sal_Int32 nTokenCount = comphelper::string::getTokenCount(_sFieldName, '.'); - if ( (nTokenCount == 2 && _sFieldName.getToken(1,'.')[0] == '*' ) - || (nTokenCount == 3 && _sFieldName.getToken(2,'.')[0] == '*' ) ) + if ( (nTokenCount == 2 && o3tl::getToken(_sFieldName,1,'.')[0] == '*' ) + || (nTokenCount == 3 && o3tl::getToken(_sFieldName,2,'.')[0] == '*' ) ) { bAsterisk = true; } @@ -99,6 +102,7 @@ namespace OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent ) :EditBrowseBox( pParent,EditBrowseBoxFlags::NO_HANDLE_COLUMN_CONTENT, WB_3DLOOK, BrowserMode::COLUMNSELECTION | BrowserMode::KEEPHIGHLIGHT | BrowserMode::HIDESELECT | BrowserMode::HIDECURSOR | BrowserMode::HLINES | BrowserMode::VLINES ) + ,m_timerInvalidate("dbaccess OSelectionBrowseBox m_timerInvalidate") ,m_nSeekRow(0) ,m_nMaxColumns(0) ,m_aFunctionStrings(DBA_RES(STR_QUERY_FUNCTIONS)) @@ -141,7 +145,7 @@ OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent ) const OUString aTxt(DBA_RES(STR_QUERY_SORTTEXT)); for (sal_Int32 nIdx {0}; nIdx>=0;) - rOrderBox.append_text(aTxt.getToken(0, ';', nIdx)); + rOrderBox.append_text(OUString(o3tl::getToken(aTxt, 0, ';', nIdx))); m_bVisibleRow.insert(m_bVisibleRow.end(), BROW_ROW_CNT, true); @@ -251,7 +255,7 @@ namespace public: explicit OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent); virtual ~OSelectionBrwBoxHeader() override { disposeOnce(); } - virtual void dispose() override { m_pBrowseBox.clear(); ::svt::EditBrowserHeader::dispose(); } + virtual void dispose() override { m_pBrowseBox.reset(); ::svt::EditBrowserHeader::dispose(); } }; OSelectionBrwBoxHeader::OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent) : ::svt::EditBrowserHeader(pParent,WB_BUTTONSTYLE|WB_DRAG) @@ -356,7 +360,7 @@ void OSelectionBrowseBox::Init() SetDataRowHeight(aHeight.Height()); SetTitleLines(1); // get number of visible rows - for(long i=0;i<BROW_ROW_CNT;i++) + for(tools::Long i=0;i<BROW_ROW_CNT;i++) { if(m_bVisibleRow[i]) m_nVisibleCount++; @@ -376,7 +380,7 @@ void OSelectionBrowseBox::Init() } catch(const SQLException&) { - OSL_FAIL("Caught Exception when asking for database metadata options!"); + TOOLS_WARN_EXCEPTION( "dbaccess", "Caught Exception when asking for database metadata options!"); m_nMaxColumns = 0; } } @@ -430,7 +434,7 @@ void OSelectionBrowseBox::SetReadOnly(bool bRO) } } -CellController* OSelectionBrowseBox::GetController(long nRow, sal_uInt16 nColId) +CellController* OSelectionBrowseBox::GetController(sal_Int32 nRow, sal_uInt16 nColId) { if ( nColId > getFields().size() ) return nullptr; @@ -443,7 +447,7 @@ CellController* OSelectionBrowseBox::GetController(long nRow, sal_uInt16 nColId) if (static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly()) return nullptr; - long nCellIndex = GetRealRow(nRow); + sal_Int32 nCellIndex = GetRealRow(nRow); switch (nCellIndex) { case BROW_FIELD_ROW: @@ -461,7 +465,7 @@ CellController* OSelectionBrowseBox::GetController(long nRow, sal_uInt16 nColId) } } -void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColId) +void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, sal_Int32 nRow, sal_uInt16 nColId) { OSL_ENSURE(nColId != BROWSER_INVALIDID,"An Invalid Id was set!"); if ( nColId == BROWSER_INVALIDID ) @@ -471,7 +475,7 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon return; OTableFieldDescRef pEntry = getFields()[nPos-1]; OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::InitController : invalid FieldDescription !"); - long nCellIndex = GetRealRow(nRow); + sal_Int32 nCellIndex = GetRealRow(nRow); switch (nCellIndex) { @@ -487,7 +491,7 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon getDesignView()->fillValidFields(aTable, rComboBox); // replace with alias.* - if (aField.trim() == "*") + if (o3tl::trim(aField) == u"*") { aField = aTable + ".*"; } @@ -555,14 +559,14 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon Controller()->SaveValue(); } -void OSelectionBrowseBox::notifyTableFieldChanged(const OUString& _sOldAlias, const OUString& _sAlias, bool& _bListAction, sal_uInt16 _nColumnId) +void OSelectionBrowseBox::notifyTableFieldChanged(const OUString& _sOldAlias, std::u16string_view _sAlias, bool& _bListAction, sal_uInt16 _nColumnId) { appendUndoAction(_sOldAlias,_sAlias,BROW_TABLE_ROW,_bListAction); if ( m_bVisibleRow[BROW_TABLE_ROW] ) RowModified(GetBrowseRow(BROW_TABLE_ROW), _nColumnId); } -void OSelectionBrowseBox::notifyFunctionFieldChanged(const OUString& _sOldFunctionName, const OUString& _sFunctionName, bool& _bListAction, sal_uInt16 _nColumnId) +void OSelectionBrowseBox::notifyFunctionFieldChanged(const OUString& _sOldFunctionName, std::u16string_view _sFunctionName, bool& _bListAction, sal_uInt16 _nColumnId) { appendUndoAction(_sOldFunctionName,_sFunctionName,BROW_FUNCTION_ROW,_bListAction); if ( !m_bVisibleRow[BROW_FUNCTION_ROW] ) @@ -570,7 +574,7 @@ void OSelectionBrowseBox::notifyFunctionFieldChanged(const OUString& _sOldFuncti RowModified(GetBrowseRow(BROW_FUNCTION_ROW), _nColumnId); } -void OSelectionBrowseBox::clearEntryFunctionField(const OUString& _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId) +void OSelectionBrowseBox::clearEntryFunctionField(std::u16string_view _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId) { if ( !(isFieldNameAsterisk( _sFieldName ) && (!_pEntry->isNoneFunction() || _pEntry->IsGroupBy())) ) return; @@ -596,12 +600,12 @@ bool OSelectionBrowseBox::fillColumnRef(const OSQLParseNode* _pColumnRef, const return fillColumnRef(sColumnName,sTableRange,_rxConnection->getMetaData(),_pEntry,_bListAction); } -bool OSelectionBrowseBox::fillColumnRef(const OUString& _sColumnName, const OUString& _sTableRange, const Reference<XDatabaseMetaData>& _xMetaData, OTableFieldDescRef const & _pEntry, bool& _bListAction) +bool OSelectionBrowseBox::fillColumnRef(const OUString& _sColumnName, std::u16string_view _sTableRange, const Reference<XDatabaseMetaData>& _xMetaData, OTableFieldDescRef const & _pEntry, bool& _bListAction) { bool bError = false; ::comphelper::UStringMixEqual bCase(_xMetaData->supportsMixedCaseQuotedIdentifiers()); // check if the table name is the same - if ( !_sTableRange.isEmpty() && (bCase(_pEntry->GetTable(),_sTableRange) || bCase(_pEntry->GetAlias(),_sTableRange)) ) + if ( !_sTableRange.empty() && (bCase(_pEntry->GetTable(),_sTableRange) || bCase(_pEntry->GetAlias(),_sTableRange)) ) { // a table was already inserted and the tables contains that column name if ( !_pEntry->GetTabWindow() ) @@ -703,7 +707,7 @@ bool OSelectionBrowseBox::saveField(OUString& _sFieldName ,OTableFieldDescRef co bool bQuote = ( nPass <= 2 ); bool bInternational = ( nPass % 2 ) == 0; - OUString sSql {"SELECT "}; + OUString sSql {u"SELECT "_ustr}; if ( bQuote ) sSql += sQuotedFullFieldName; else @@ -807,7 +811,7 @@ bool OSelectionBrowseBox::saveField(OUString& _sFieldName ,OTableFieldDescRef co if ( nFunCount == 4 && SQL_ISRULE(pColumnRef->getChild(3),column_ref) ) bError = fillColumnRef( pColumnRef->getChild(3), xConnection, aSelEntry, _bListAction ); else if ( nFunCount == 3 ) // we have a COUNT(*) here, so take the first table - bError = fillColumnRef( "*", OUString(), xMetaData, aSelEntry, _bListAction ); + bError = fillColumnRef( u"*"_ustr, std::u16string_view(), xMetaData, aSelEntry, _bListAction ); else { nFunctionType |= FKT_NUMERIC; @@ -906,15 +910,17 @@ bool OSelectionBrowseBox::SaveModified() { // for the Undo-action OUString strOldCellContents,sNewValue; - long nRow = GetRealRow(GetCurRow()); + sal_Int32 nRow = GetRealRow(GetCurRow()); bool bAppendRow = false; switch (nRow) { case BROW_VIS_ROW: { bool bOldValue = m_pVisibleCell->GetBox().get_saved_state() != TRISTATE_FALSE; - strOldCellContents = bOldValue ? OUStringLiteral("1") : OUStringLiteral("0"); - sNewValue = !bOldValue ? OUStringLiteral("1") : OUStringLiteral("0"); + strOldCellContents + = bOldValue ? std::u16string_view(u"1") : std::u16string_view(u"0"); + sNewValue + = !bOldValue ? std::u16string_view(u"1") : std::u16string_view(u"0"); } if((m_bOrderByUnRelated || pEntry->GetOrderDir() == ORDER_NONE) && (m_bGroupByUnRelated || !pEntry->IsGroupBy())) @@ -1046,7 +1052,7 @@ bool OSelectionBrowseBox::SaveModified() sal_Int32 nPos = rComboBox.get_active(); // these functions are only available in CORE OUString sFunctionName = rComboBox.get_text(nPos); - OUString sGroupFunctionName = m_aFunctionStrings.copy(m_aFunctionStrings.lastIndexOf(';')+1); + std::u16string_view sGroupFunctionName = m_aFunctionStrings.subView(m_aFunctionStrings.lastIndexOf(';')+1); bool bGroupBy = false; if ( sGroupFunctionName == sFunctionName ) // check if the function name is GROUP { @@ -1057,7 +1063,7 @@ bool OSelectionBrowseBox::SaveModified() // we have to change the visible flag, so we must append also an undo action pEntry->SetVisible(); m_pVisibleCell->GetBox().set_active(true); - appendUndoAction("0","1",BROW_VIS_ROW,bListAction); + appendUndoAction(u"0"_ustr,u"1",BROW_VIS_ROW,bListAction); RowModified(GetBrowseRow(BROW_VIS_ROW), GetCurColumnId()); } @@ -1198,7 +1204,7 @@ bool OSelectionBrowseBox::SaveModified() { // Default to visible pEntry->SetVisible(); - appendUndoAction("0","1",BROW_VIS_ROW,bListAction); + appendUndoAction(u"0"_ustr,u"1",BROW_VIS_ROW,bListAction); RowModified(BROW_VIS_ROW, GetCurColumnId()); // if required add empty columns @@ -1212,7 +1218,7 @@ bool OSelectionBrowseBox::SaveModified() return pEntry != nullptr && !bError; } -bool OSelectionBrowseBox::SeekRow(long nRow) +bool OSelectionBrowseBox::SeekRow(sal_Int32 nRow) { m_nSeekRow = nRow; return nRow < m_nVisibleCount; @@ -1230,7 +1236,7 @@ void OSelectionBrowseBox::PaintCell(OutputDevice& rDev, const tools::Rectangle& if (!pEntry.is()) return; - long nRow = GetRealRow(m_nSeekRow); + sal_Int32 nRow = GetRealRow(m_nSeekRow); if (nRow == BROW_VIS_ROW) PaintTristate(rRect, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); else @@ -1261,7 +1267,7 @@ void OSelectionBrowseBox::RemoveColumn(sal_uInt16 _nColumnId) // ColId is synonymous to Position, and the condition should be valid sal_uInt16 nCurCol = GetCurColumnId(); - long nCurrentRow = GetCurRow(); + sal_Int32 nCurrentRow = GetCurRow(); DeactivateCell(); @@ -1447,7 +1453,7 @@ void OSelectionBrowseBox::DeleteFields(const OUString& rAliasName) ActivateCell(nRow , nColId); } -void OSelectionBrowseBox::SetColWidth(sal_uInt16 nColId, long nNewWidth) +void OSelectionBrowseBox::SetColWidth(sal_uInt16 nColId, tools::Long nNewWidth) { bool bWasEditing = IsEditing(); if (bWasEditing) @@ -1480,11 +1486,11 @@ tools::Rectangle OSelectionBrowseBox::GetInvalidRect( sal_uInt16 nColId ) void OSelectionBrowseBox::InsertColumn(const OTableFieldDescRef& pEntry, sal_uInt16& _nColumnPosition) { // the control should have exactly one more column: the HandleColumn - OSL_ENSURE(_nColumnPosition == BROWSER_INVALIDID || (_nColumnPosition <= static_cast<long>(getFields().size())), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId."); + OSL_ENSURE(_nColumnPosition == BROWSER_INVALIDID || (_nColumnPosition <= static_cast<tools::Long>(getFields().size())), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId."); // -1 means at the end. Count means at the end, others denotes a correct position sal_uInt16 nCurCol = GetCurColumnId(); - long nCurrentRow = GetCurRow(); + sal_Int32 nCurrentRow = GetCurRow(); DeactivateCell(); @@ -1500,7 +1506,9 @@ void OSelectionBrowseBox::InsertColumn(const OTableFieldDescRef& pEntry, sal_uIn getFields().size()); } else - ++_nColumnPosition; // within the list + { + _nColumnPosition = static_cast<sal_uInt16>(_nColumnPosition + 1); // within the list + } nColumnId = GetColumnId(_nColumnPosition); pEntry->SetColumnId( nColumnId ); getFields()[ _nColumnPosition - 1] = pEntry; @@ -1546,9 +1554,10 @@ OTableFieldDescRef OSelectionBrowseBox::InsertField(const OJoinExchangeData& jxd return nullptr; // name and position of the selected field - OUString aFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry); - sal_uInt32 nFieldIndex = jxdSource.pListBox->GetModel()->GetAbsPos(jxdSource.pEntry); - OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(jxdSource.pEntry->GetUserData()); + weld::TreeView& rTreeView = jxdSource.pListBox->get_widget(); + OUString aFieldName = rTreeView.get_text(jxdSource.nEntry); + sal_uInt32 nFieldIndex = jxdSource.nEntry; + OTableFieldInfo* pInf = weld::fromId<OTableFieldInfo*>(rTreeView.get_id(jxdSource.nEntry)); // construct DragInfo, such that I use the other InsertField OTableFieldDescRef aInfo = new OTableFieldDesc(pSourceWin->GetTableName(),aFieldName); @@ -1609,7 +1618,7 @@ OTableFieldDescRef OSelectionBrowseBox::FindFirstFreeCol(sal_uInt16& _rColumnPos for (auto const& field : getFields()) { - ++_rColumnPosition; + _rColumnPosition = static_cast<sal_uInt16>(_rColumnPosition + 1); OTableFieldDescRef pEntry = field; if ( pEntry.is() && pEntry->IsEmpty() ) return pEntry; @@ -1857,7 +1866,7 @@ bool OSelectionBrowseBox::Save() void OSelectionBrowseBox::CellModified() { - long nRow = GetRealRow(GetCurRow()); + sal_Int32 nRow = GetRealRow(GetCurRow()); switch (nRow) { case BROW_VIS_ROW: @@ -1928,7 +1937,7 @@ void OSelectionBrowseBox::Command(const CommandEvent& rEvt) } sal_uInt16 nColId = GetColumnId(GetColumnAtXPosPixel( aMenuPos.X() )); - long nRow = GetRowAtYPosPixel( aMenuPos.Y() ); + sal_Int32 nRow = GetRowAtYPosPixel( aMenuPos.Y() ); if (nRow < 0 && nColId > HANDLE_ID ) { @@ -1940,12 +1949,14 @@ void OSelectionBrowseBox::Command(const CommandEvent& rEvt) if (!static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly()) { - VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "dbaccess/ui/querycolmenu.ui", ""); - VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu")); - sal_uInt16 nItemId = aContextMenu->Execute(this, aMenuPos); - if (nItemId == aContextMenu->GetItemId("delete")) + ::tools::Rectangle aRect(aMenuPos, Size(1, 1)); + weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, u"dbaccess/ui/querycolmenu.ui"_ustr)); + std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu(u"menu"_ustr)); + OUString sIdent = xContextMenu->popup_at_rect(pPopupParent, aRect); + if (sIdent == "delete") RemoveField(nColId); - else if (nItemId == aContextMenu->GetItemId("width")) + else if (sIdent == "width") adjustBrowseBoxColumnWidth( this, nColId ); } } @@ -1953,16 +1964,16 @@ void OSelectionBrowseBox::Command(const CommandEvent& rEvt) { if (!static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly()) { - VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "dbaccess/ui/queryfuncmenu.ui", ""); - VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu")); - aContextMenu->CheckItem("functions", m_bVisibleRow[BROW_FUNCTION_ROW]); - aContextMenu->CheckItem("tablename", m_bVisibleRow[BROW_TABLE_ROW]); - aContextMenu->CheckItem("alias", m_bVisibleRow[BROW_COLUMNALIAS_ROW]); - aContextMenu->CheckItem("distinct", static_cast<OQueryController&>(getDesignView()->getController()).isDistinct()); - - aContextMenu->Execute(this, aMenuPos); - - OString sIdent = aContextMenu->GetCurItemIdent(); + ::tools::Rectangle aRect(aMenuPos, Size(1, 1)); + weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, u"dbaccess/ui/queryfuncmenu.ui"_ustr)); + std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu(u"menu"_ustr)); + xContextMenu->set_active(u"functions"_ustr, m_bVisibleRow[BROW_FUNCTION_ROW]); + xContextMenu->set_active(u"tablename"_ustr, m_bVisibleRow[BROW_TABLE_ROW]); + xContextMenu->set_active(u"alias"_ustr, m_bVisibleRow[BROW_COLUMNALIAS_ROW]); + xContextMenu->set_active(u"distinct"_ustr, static_cast<OQueryController&>(getDesignView()->getController()).isDistinct()); + + OUString sIdent = xContextMenu->popup_at_rect(pPopupParent, aRect); if (sIdent == "functions") { SetRowVisible(BROW_FUNCTION_ROW, !IsRowVisible(BROW_FUNCTION_ROW)); @@ -2018,7 +2029,7 @@ void OSelectionBrowseBox::SetRowVisible(sal_uInt16 _nWhich, bool _bVis) // do this before removing or inserting rows, as this triggers ActivateCell-calls, which rely on m_bVisibleRow m_bVisibleRow[_nWhich] = !m_bVisibleRow[_nWhich]; - long nId = GetBrowseRow(_nWhich); + tools::Long nId = GetBrowseRow(_nWhich); if (_bVis) { RowInserted(nId); @@ -2034,10 +2045,10 @@ void OSelectionBrowseBox::SetRowVisible(sal_uInt16 _nWhich, bool _bVis) ActivateCell(); } -long OSelectionBrowseBox::GetBrowseRow(long nRowId) const +sal_Int32 OSelectionBrowseBox::GetBrowseRow(sal_Int32 nRowId) const { - sal_uInt16 nCount(0); - for(long i = 0 ; i < nRowId ; ++i) + sal_Int32 nCount(0); + for(sal_Int32 i = 0 ; i < nRowId ; ++i) { if ( m_bVisibleRow[i] ) ++nCount; @@ -2045,20 +2056,20 @@ long OSelectionBrowseBox::GetBrowseRow(long nRowId) const return nCount; } -long OSelectionBrowseBox::GetRealRow(long nRowId) const +sal_Int32 OSelectionBrowseBox::GetRealRow(sal_Int32 nRowId) const { - long nErg=0,i; - const long nCount = m_bVisibleRow.size(); + sal_Int32 nErg=0,i; + const sal_Int32 nCount = m_bVisibleRow.size(); for(i=0;i < nCount; ++i) { if(m_bVisibleRow[i] && nErg++ == nRowId) break; } - OSL_ENSURE(nErg <= long(m_bVisibleRow.size()),"nErg cannot be greater than BROW_ROW_CNT!"); + OSL_ENSURE(nErg <= tools::Long(m_bVisibleRow.size()),"nErg cannot be greater than BROW_ROW_CNT!"); return i; } -const long nVisibleRowMask[] = +const tools::Long nVisibleRowMask[] = { 0x0001, 0x0002, @@ -2077,8 +2088,8 @@ sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const { sal_Int32 nErg(0); // only the first 11 rows are interesting - sal_Int32 const nSize = SAL_N_ELEMENTS(nVisibleRowMask); - for(sal_Int32 i=0;i<nSize;i++) + std::size_t const nSize = std::size(nVisibleRowMask); + for(std::size_t i=0;i<nSize;i++) { if(!m_bVisibleRow[i]) nErg |= nVisibleRowMask[i]; @@ -2086,18 +2097,20 @@ sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const return nErg; } -void OSelectionBrowseBox::SetNoneVisbleRow(long nRows) +void OSelectionBrowseBox::SetNoneVisibleRow(sal_Int32 nRows) { // only the first 11 rows are interesting - sal_Int32 const nSize = SAL_N_ELEMENTS(nVisibleRowMask); - for(sal_Int32 i=0;i< nSize;i++) + std::size_t const nSize = std::size(nVisibleRowMask); + for(std::size_t i=0;i< nSize;i++) m_bVisibleRow[i] = !(nRows & nVisibleRowMask[i]); } -OUString OSelectionBrowseBox::GetCellText(long nRow, sal_uInt16 nColId) const +OUString OSelectionBrowseBox::GetCellText(sal_Int32 nRow, sal_uInt16 nColId) const { sal_uInt16 nPos = GetColumnPos(nColId); + if ( nPos == 0 || nPos == BROWSER_INVALIDID || nPos > getFields().size() ) + return OUString(); OTableFieldDescRef pEntry = getFields()[nPos-1]; OSL_ENSURE(pEntry != nullptr, "OSelectionBrowseBox::GetCellText : invalid column id, prepare for GPF ... "); @@ -2225,7 +2238,7 @@ OUString OSelectionBrowseBox::GetCellContents(sal_Int32 nCellIndex, sal_uInt16 n switch (nCellIndex) { case BROW_VIS_ROW : - return pEntry->IsVisible() ? OUStringLiteral("1") : OUStringLiteral("0"); + return OUString(pEntry->IsVisible() ? std::u16string_view(u"1") : std::u16string_view(u"0")); case BROW_ORDER_ROW: { sal_Int32 nIdx = m_pOrderCell->get_widget().get_active(); @@ -2269,16 +2282,16 @@ void OSelectionBrowseBox::SetCellContents(sal_Int32 nRow, sal_uInt16 nColId, con break; case BROW_FUNCTION_ROW: { - OUString sGroupFunctionName = m_aFunctionStrings.copy(m_aFunctionStrings.lastIndexOf(';')+1); + std::u16string_view sGroupFunctionName = m_aFunctionStrings.subView(m_aFunctionStrings.lastIndexOf(';')+1); pEntry->SetFunction(strNewText); // first reset this two member sal_Int32 nFunctionType = pEntry->GetFunctionType(); nFunctionType &= ~FKT_AGGREGATE; pEntry->SetFunctionType(nFunctionType); - if ( pEntry->IsGroupBy() && !sGroupFunctionName.equalsIgnoreAsciiCase(strNewText) ) + if ( pEntry->IsGroupBy() && !o3tl::equalsIgnoreAsciiCase(sGroupFunctionName, strNewText) ) pEntry->SetGroupBy(false); - if ( sGroupFunctionName.equalsIgnoreAsciiCase(strNewText) ) + if ( o3tl::equalsIgnoreAsciiCase(sGroupFunctionName, strNewText) ) pEntry->SetGroupBy(true); else if ( !strNewText.isEmpty() ) { @@ -2290,7 +2303,7 @@ void OSelectionBrowseBox::SetCellContents(sal_Int32 nRow, sal_uInt16 nColId, con pEntry->SetCriteria(sal_uInt16(nRow - BROW_CRIT1_ROW), strNewText); } - long nCellIndex = GetRealRow(nRow); + tools::Long nCellIndex = GetRealRow(nRow); if(IsRowVisible(static_cast<sal_uInt16>(nRow))) RowModified(nCellIndex, nColId); @@ -2333,7 +2346,7 @@ void OSelectionBrowseBox::ColumnResized(sal_uInt16 nColId) } } -sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRowId, sal_uInt16 nColId) +sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(sal_Int32 nRowId, sal_uInt16 nColId) { sal_uInt16 nPos = GetColumnPos(nColId); OSL_ENSURE((nPos == 0) || (nPos <= getFields().size()), "OSelectionBrowseBox::GetTotalCellWidth : invalid parameter nColId"); @@ -2341,7 +2354,7 @@ sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRowId, sal_uInt16 nColId OTableFieldDescRef pEntry = getFields()[nPos-1]; OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::GetTotalCellWidth : invalid FieldDescription !"); - long nRow = GetRealRow(nRowId); + sal_Int32 nRow = GetRealRow(nRowId); OUString strText(GetCellText(nRow, nColId)); return GetDataWindow().LogicToPixel(Size(GetDataWindow().GetTextWidth(strText),0)).Width(); } @@ -2349,7 +2362,7 @@ sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRowId, sal_uInt16 nColId bool OSelectionBrowseBox::isCutAllowed() const { bool bCutAllowed = false; - long nRow = GetRealRow(GetCurRow()); + sal_Int32 nRow = GetRealRow(GetCurRow()); switch (nRow) { case BROW_VIS_ROW: @@ -2377,7 +2390,7 @@ bool OSelectionBrowseBox::isCutAllowed() const void OSelectionBrowseBox::cut() { - long nRow = GetRealRow(GetCurRow()); + sal_Int32 nRow = GetRealRow(GetCurRow()); switch (nRow) { case BROW_FIELD_ROW: @@ -2400,7 +2413,7 @@ void OSelectionBrowseBox::cut() void OSelectionBrowseBox::paste() { - long nRow = GetRealRow(GetCurRow()); + sal_Int32 nRow = GetRealRow(GetCurRow()); switch (nRow) { case BROW_FIELD_ROW: @@ -2423,7 +2436,7 @@ void OSelectionBrowseBox::paste() bool OSelectionBrowseBox::isPasteAllowed() const { bool bPasteAllowed = true; - long nRow = GetRealRow(GetCurRow()); + sal_Int32 nRow = GetRealRow(GetCurRow()); switch (nRow) { case BROW_VIS_ROW: @@ -2443,7 +2456,7 @@ bool OSelectionBrowseBox::isCopyAllowed() const void OSelectionBrowseBox::copy() { - long nRow = GetRealRow(GetCurRow()); + sal_Int32 nRow = GetRealRow(GetCurRow()); switch (nRow) { case BROW_FIELD_ROW: @@ -2461,7 +2474,7 @@ void OSelectionBrowseBox::copy() } } -void OSelectionBrowseBox::appendUndoAction(const OUString& _rOldValue, const OUString& _rNewValue, sal_Int32 _nRow, bool& _bListAction) +void OSelectionBrowseBox::appendUndoAction(const OUString& _rOldValue, std::u16string_view _rNewValue, sal_Int32 _nRow, bool& _bListAction) { if ( !m_bInUndoMode && _rNewValue != _rOldValue ) { @@ -2474,7 +2487,7 @@ void OSelectionBrowseBox::appendUndoAction(const OUString& _rOldValue, const OUS } } -void OSelectionBrowseBox::appendUndoAction(const OUString& _rOldValue,const OUString& _rNewValue,sal_Int32 _nRow) +void OSelectionBrowseBox::appendUndoAction(const OUString& _rOldValue,std::u16string_view _rNewValue,sal_Int32 _nRow) { if ( !m_bInUndoMode && _rNewValue != _rOldValue ) { @@ -2523,7 +2536,7 @@ void OSelectionBrowseBox::enableControl(const OTableFieldDescRef& _rEntry,Window _pControl->EnableInput(bEnable); } -void OSelectionBrowseBox::setTextCellContext(const OTableFieldDescRef& _rEntry,const OUString& _sText,const OString& _sHelpId) +void OSelectionBrowseBox::setTextCellContext(const OTableFieldDescRef& _rEntry,const OUString& _sText,const OUString& _sHelpId) { weld::Entry& rEntry = m_pTextCell->get_widget(); rEntry.set_text(_sText); @@ -2589,12 +2602,12 @@ OUString OSelectionBrowseBox::GetRowDescription( sal_Int32 _nRow ) const return aLabel.getToken(nToken, ';'); } -OUString OSelectionBrowseBox::GetAccessibleObjectName( ::vcl::AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition) const +OUString OSelectionBrowseBox::GetAccessibleObjectName( AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition) const { OUString sRetText; switch( _eObjType ) { - case ::vcl::BBTYPE_ROWHEADERCELL: + case AccessibleBrowseBoxObjType::RowHeaderCell: sRetText = GetRowDescription(_nPosition); break; default: @@ -2682,7 +2695,7 @@ void OSelectionBrowseBox::setFunctionCell(OTableFieldDescRef const & _pEntry) Reference< XAccessible > OSelectionBrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) { OTableFieldDescRef pEntry; - if(getFields().size() > o3tl::make_unsigned(_nColumnPos - 1)) + if ( _nColumnPos != 0 && _nColumnPos != BROWSER_INVALIDID && _nColumnPos <= getFields().size() ) pEntry = getFields()[_nColumnPos - 1]; if ( _nRow == BROW_VIS_ROW && pEntry.is() ) @@ -2691,7 +2704,7 @@ Reference< XAccessible > OSelectionBrowseBox::CreateAccessibleCell( sal_Int32 _n return EditBrowseBox::CreateAccessibleCell( _nRow, _nColumnPos ); } -bool OSelectionBrowseBox::HasFieldByAliasName(const OUString& rFieldName, OTableFieldDescRef const & rInfo) const +bool OSelectionBrowseBox::HasFieldByAliasName(std::u16string_view rFieldName, OTableFieldDescRef const & rInfo) const { for (auto const& field : getFields()) { diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx index 325554b6f0bc..d5e11c03e332 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx @@ -16,8 +16,11 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_SELECTIONBROWSEBOX_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_SELECTIONBROWSEBOX_HXX +#pragma once + +#include <sal/config.h> + +#include <string_view> #include <svtools/editbrowsebox.hxx> #include <TableFieldDescription.hxx> @@ -53,7 +56,7 @@ namespace dbaui std::vector<bool> m_bVisibleRow; // at pos we find the RowId Timer m_timerInvalidate; - long m_nSeekRow; + sal_Int32 m_nSeekRow; BrowserMode m_nMode; // remember the BrowseModes VclPtr< ::svt::EditControl> m_pTextCell; VclPtr< ::svt::CheckBoxControl> m_pVisibleCell; @@ -87,7 +90,7 @@ namespace dbaui void RemoveColumn( sal_uInt16 _nColumnId ); void DeleteFields( const OUString& rAliasName ); - bool HasFieldByAliasName(const OUString& rFieldName, OTableFieldDescRef const & rInfo) const; + bool HasFieldByAliasName(std::u16string_view rFieldName, OTableFieldDescRef const & rInfo) const; // AddGroupBy:: inserts a field with function == grouping. If the fields already exists and uses an aggregate function, // the flag is not set @@ -105,14 +108,14 @@ namespace dbaui OQueryDesignView* getDesignView() const; sal_uInt16 FieldsCount(); - void SetColWidth(sal_uInt16 nColId, long lNewWidth); + void SetColWidth(sal_uInt16 nColId, tools::Long lNewWidth); // unlike SetColumnWidth of the base class it checks an active cell in this column OUString GetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId); void SetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId, const OUString& strNewText); // cell content (formatted as string) set/return sal_Int32 GetNoneVisibleRows() const; - void SetNoneVisbleRow(long nRows); + void SetNoneVisibleRow(sal_Int32 nRows); bool IsRowVisible(sal_uInt16 _nWhich) const; void SetRowVisible(sal_uInt16 _nWhich, bool _bVis); @@ -151,7 +154,7 @@ namespace dbaui @return the text out of the cell */ - virtual OUString GetCellText(long _nRow, sal_uInt16 _nColId) const override; + virtual OUString GetCellText(sal_Int32 _nRow, sal_uInt16 _nColId) const override; /** returns the description of the row. @param _nRow @@ -169,7 +172,7 @@ namespace dbaui @return The name of the specified object. */ - virtual OUString GetAccessibleObjectName( ::vcl::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const override; + virtual OUString GetAccessibleObjectName( AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const override; // IAccessibleTableProvider /** Creates the accessible object of a data table cell. @@ -179,7 +182,7 @@ namespace dbaui virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId ) override; private: - virtual bool SeekRow( long nRow ) override; + virtual bool SeekRow( sal_Int32 nRow ) override; virtual void PaintStatusCell(OutputDevice& rDev, const tools::Rectangle& rRect) const override; virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect, @@ -192,14 +195,14 @@ namespace dbaui virtual void KeyInput( const KeyEvent& rEvt ) override; virtual void Command(const CommandEvent& rEvt) override; - virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol) override; - virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol) override; + virtual ::svt::CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol) override; + virtual void InitController(::svt::CellControllerRef& rController, sal_Int32 nRow, sal_uInt16 nCol) override; virtual void CellModified() override; virtual bool SaveModified() override; virtual void Init() override; virtual void ColumnResized( sal_uInt16 nColId ) override; - virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId) override; + virtual sal_uInt32 GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId) override; // if you want to have an own header ... virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) override; @@ -217,14 +220,14 @@ namespace dbaui void RemoveField( sal_uInt16 nId ); tools::Rectangle GetInvalidRect( sal_uInt16 nColId ); - long GetRealRow(long nRow) const; - long GetBrowseRow(long nRowId) const; + sal_Int32 GetRealRow(sal_Int32 nRow) const; + sal_Int32 GetBrowseRow(sal_Int32 nRowId) const; bool GetFunctionName(sal_uInt32 _nFunctionTokenId, OUString& rFkt); - void appendUndoAction(const OUString& _rOldValue,const OUString& _rNewValue,sal_Int32 _nRow, bool& _bListAction); - void appendUndoAction(const OUString& _rOldValue,const OUString& _rNewValue,sal_Int32 _nRow); + void appendUndoAction(const OUString& _rOldValue,std::u16string_view _rNewValue,sal_Int32 _nRow, bool& _bListAction); + void appendUndoAction(const OUString& _rOldValue,std::u16string_view _rNewValue,sal_Int32 _nRow); OTableFields& getFields() const; static void enableControl(const OTableFieldDescRef& _rEntry,Window* _pControl); - void setTextCellContext(const OTableFieldDescRef& _rEntry,const OUString& _sText,const OString& _sHelpId); + void setTextCellContext(const OTableFieldDescRef& _rEntry,const OUString& _sText,const OUString& _sHelpId); void invalidateUndoRedo(); OTableFieldDescRef getEntry(OTableFields::size_type _nPos); @@ -269,7 +272,7 @@ namespace dbaui OTableFieldDescRef const & _pEntry, bool& _bListAction); bool fillColumnRef( const OUString& _sColumnName, - const OUString& _sTableRange, + std::u16string_view _sTableRange, const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _xMetaData, OTableFieldDescRef const & _pEntry, bool& _bListAction); @@ -282,7 +285,7 @@ namespace dbaui @param _bListAction Will be set to <TRUE/> when we are in a list action otherwise <FALSE/> */ - void notifyTableFieldChanged(const OUString& _sOldAlias,const OUString& _sAlias, bool& _bListAction,sal_uInt16 _nColumnId); + void notifyTableFieldChanged(const OUString& _sOldAlias,std::u16string_view _sAlias, bool& _bListAction,sal_uInt16 _nColumnId); /** append an undo action for the function field @param _sOldFunctionName @@ -292,7 +295,7 @@ namespace dbaui @param _bListAction Will be set to <TRUE/> when we are in a list action otherwise <FALSE/> */ - void notifyFunctionFieldChanged(const OUString& _sOldFunctionName,const OUString& _sFunctionName, bool& _bListAction,sal_uInt16 _nColumnId); + void notifyFunctionFieldChanged(const OUString& _sOldFunctionName,std::u16string_view _sFunctionName, bool& _bListAction,sal_uInt16 _nColumnId); /** clears the function fields of the submitted entry if it doesn't match the SQL standard and append an undo action. E.q. AGGREGATE functions are only valid when the field name isn't an asterisk @@ -303,7 +306,7 @@ namespace dbaui @param _bListAction When <TRUE/> a list action will be created. */ - void clearEntryFunctionField(const OUString& _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId); + void clearEntryFunctionField(std::u16string_view _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId); /** remove or insert the necessary function types @param _pEntry @@ -317,6 +320,5 @@ namespace dbaui using ::svt::EditBrowseBox::MouseButtonUp; }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_SELECTIONBROWSEBOX_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx index ada4b5990890..1e9d31f419c0 100644 --- a/dbaccess/source/ui/querydesign/TableConnection.cxx +++ b/dbaccess/source/ui/querydesign/TableConnection.cxx @@ -21,17 +21,16 @@ #include <ConnectionLine.hxx> #include <TableConnectionData.hxx> #include <JoinTableView.hxx> +#include <utility> using namespace dbaui; -using namespace comphelper; -using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; namespace dbaui { - OTableConnection::OTableConnection( OJoinTableView* _pContainer,const TTableConnectionData::value_type& _pTabConnData ) + OTableConnection::OTableConnection( OJoinTableView* _pContainer, TTableConnectionData::value_type _aTabConnData ) :Window(_pContainer) - ,m_pData( _pTabConnData ) + ,m_pData(std::move( _aTabConnData )) ,m_pParent( _pContainer ) ,m_bSelected( false ) { diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx index 107d8a9d1a48..aa524a5ac7f9 100644 --- a/dbaccess/source/ui/querydesign/TableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx @@ -18,6 +18,7 @@ */ #include <TableConnectionData.hxx> +#include <utility> #include <osl/diagnose.h> using namespace dbaui; @@ -27,10 +28,10 @@ OTableConnectionData::OTableConnectionData() Init(); } -OTableConnectionData::OTableConnectionData(const TTableWindowData::value_type& _pReferencingTable - ,const TTableWindowData::value_type& _pReferencedTable ) - :m_pReferencingTable(_pReferencingTable) - ,m_pReferencedTable(_pReferencedTable) +OTableConnectionData::OTableConnectionData(TTableWindowData::value_type _pReferencingTable + ,TTableWindowData::value_type _pReferencedTable ) + :m_pReferencingTable(std::move(_pReferencingTable)) + ,m_pReferencedTable(std::move(_pReferencedTable)) { Init(); } diff --git a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx index 95476cafd51e..b835f3b62aff 100644 --- a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx +++ b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx @@ -22,9 +22,7 @@ #include <osl/diagnose.h> #include <com/sun/star/sdbc/DataType.hpp> #include <comphelper/namedvaluecollection.hxx> -#include <vcl/window.hxx> -using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace comphelper; @@ -132,23 +130,23 @@ void OTableFieldDesc::Load( const css::beans::PropertyValue& i_rSettings, const { ::comphelper::NamedValueCollection aFieldDesc( i_rSettings.Value ); - m_aAliasName = aFieldDesc.getOrDefault( "AliasName", m_aAliasName ); - m_aTableName = aFieldDesc.getOrDefault( "TableName", m_aTableName ); - m_aFieldName = aFieldDesc.getOrDefault( "FieldName", m_aFieldName ); - m_aFieldAlias = aFieldDesc.getOrDefault( "FieldAlias", m_aFieldAlias ); - m_aFunctionName = aFieldDesc.getOrDefault( "FunctionName", m_aFunctionName ); - m_eDataType = aFieldDesc.getOrDefault( "DataType", m_eDataType ); - m_eFunctionType = aFieldDesc.getOrDefault( "FunctionType", m_eFunctionType ); - m_nColWidth = aFieldDesc.getOrDefault( "ColWidth", m_nColWidth ); - m_bGroupBy = aFieldDesc.getOrDefault( "GroupBy", m_bGroupBy ); - m_bVisible = aFieldDesc.getOrDefault( "Visible", m_bVisible ); - - m_eFieldType = static_cast< ETableFieldType >( aFieldDesc.getOrDefault( "FieldType", static_cast< sal_Int32 >( m_eFieldType ) ) ); - m_eOrderDir = static_cast< EOrderDir >( aFieldDesc.getOrDefault( "OrderDir", static_cast< sal_Int32 >( m_eOrderDir ) ) ); + m_aAliasName = aFieldDesc.getOrDefault( u"AliasName"_ustr, m_aAliasName ); + m_aTableName = aFieldDesc.getOrDefault( u"TableName"_ustr, m_aTableName ); + m_aFieldName = aFieldDesc.getOrDefault( u"FieldName"_ustr, m_aFieldName ); + m_aFieldAlias = aFieldDesc.getOrDefault( u"FieldAlias"_ustr, m_aFieldAlias ); + m_aFunctionName = aFieldDesc.getOrDefault( u"FunctionName"_ustr, m_aFunctionName ); + m_eDataType = aFieldDesc.getOrDefault( u"DataType"_ustr, m_eDataType ); + m_eFunctionType = aFieldDesc.getOrDefault( u"FunctionType"_ustr, m_eFunctionType ); + m_nColWidth = aFieldDesc.getOrDefault( u"ColWidth"_ustr, m_nColWidth ); + m_bGroupBy = aFieldDesc.getOrDefault( u"GroupBy"_ustr, m_bGroupBy ); + m_bVisible = aFieldDesc.getOrDefault( u"Visible"_ustr, m_bVisible ); + + m_eFieldType = static_cast< ETableFieldType >( aFieldDesc.getOrDefault( u"FieldType"_ustr, static_cast< sal_Int32 >( m_eFieldType ) ) ); + m_eOrderDir = static_cast< EOrderDir >( aFieldDesc.getOrDefault( u"OrderDir"_ustr, static_cast< sal_Int32 >( m_eOrderDir ) ) ); if ( i_bIncludingCriteria ) { - const Sequence< PropertyValue > aCriteria( aFieldDesc.getOrDefault( "Criteria", Sequence< PropertyValue >() ) ); + const Sequence< PropertyValue > aCriteria( aFieldDesc.getOrDefault( u"Criteria"_ustr, Sequence< PropertyValue >() ) ); m_aCriteria.resize( aCriteria.getLength() ); std::transform( aCriteria.begin(), @@ -162,18 +160,18 @@ void OTableFieldDesc::Load( const css::beans::PropertyValue& i_rSettings, const void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria ) { - o_rSettings.put( "AliasName", m_aAliasName ); - o_rSettings.put( "TableName", m_aTableName ); - o_rSettings.put( "FieldName", m_aFieldName ); - o_rSettings.put( "FieldAlias", m_aFieldAlias ); - o_rSettings.put( "FunctionName", m_aFunctionName ); - o_rSettings.put( "DataType", m_eDataType ); - o_rSettings.put( "FunctionType", m_eFunctionType ); - o_rSettings.put( "FieldType", static_cast<sal_Int32>(m_eFieldType) ); - o_rSettings.put( "OrderDir", static_cast<sal_Int32>(m_eOrderDir) ); - o_rSettings.put( "ColWidth", m_nColWidth ); - o_rSettings.put( "GroupBy", m_bGroupBy ); - o_rSettings.put( "Visible", m_bVisible ); + o_rSettings.put( u"AliasName"_ustr, m_aAliasName ); + o_rSettings.put( u"TableName"_ustr, m_aTableName ); + o_rSettings.put( u"FieldName"_ustr, m_aFieldName ); + o_rSettings.put( u"FieldAlias"_ustr, m_aFieldAlias ); + o_rSettings.put( u"FunctionName"_ustr, m_aFunctionName ); + o_rSettings.put( u"DataType"_ustr, m_eDataType ); + o_rSettings.put( u"FunctionType"_ustr, m_eFunctionType ); + o_rSettings.put( u"FieldType"_ustr, static_cast<sal_Int32>(m_eFieldType) ); + o_rSettings.put( u"OrderDir"_ustr, static_cast<sal_Int32>(m_eOrderDir) ); + o_rSettings.put( u"ColWidth"_ustr, m_nColWidth ); + o_rSettings.put( u"GroupBy"_ustr, m_bGroupBy ); + o_rSettings.put( u"Visible"_ustr, m_bVisible ); if ( !i_bIncludingCriteria ) return; @@ -183,14 +181,15 @@ void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings, con sal_Int32 c = 0; Sequence< PropertyValue > aCriteria( m_aCriteria.size() ); + auto pCriteria = aCriteria.getArray(); for (auto const& criteria : m_aCriteria) { - aCriteria[c].Name = "Criterion_" + OUString::number( c ); - aCriteria[c].Value <<= criteria; + pCriteria[c].Name = "Criterion_" + OUString::number( c ); + pCriteria[c].Value <<= criteria; ++c; } - o_rSettings.put( "Criteria", aCriteria ); + o_rSettings.put( u"Criteria"_ustr, aCriteria ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/TableFieldInfo.cxx b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx index 15c60b83352d..808862c11c4e 100644 --- a/dbaccess/source/ui/querydesign/TableFieldInfo.cxx +++ b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx @@ -21,12 +21,9 @@ using namespace dbaui; -OTableFieldInfo::OTableFieldInfo() : - m_eFieldType(TAB_NORMAL_FIELD), m_eDataType(1000) -{ -} - -OTableFieldInfo::~OTableFieldInfo() +OTableFieldInfo::OTableFieldInfo() + : m_eFieldType(TAB_NORMAL_FIELD) + , m_eDataType(1000) { } diff --git a/dbaccess/source/ui/querydesign/TableFieldInfo.hxx b/dbaccess/source/ui/querydesign/TableFieldInfo.hxx index 7d0e83b4c0e4..e7d2c9b72da4 100644 --- a/dbaccess/source/ui/querydesign/TableFieldInfo.hxx +++ b/dbaccess/source/ui/querydesign/TableFieldInfo.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_TABLEFIELDINFO_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_TABLEFIELDINFO_HXX +#pragma once #include <QEnumTypes.hxx> #include <sal/types.h> @@ -32,7 +31,6 @@ namespace dbaui public: OTableFieldInfo(); - ~OTableFieldInfo(); ETableFieldType GetKeyType() const { return m_eFieldType; } void SetKey(ETableFieldType bKey) { m_eFieldType = bKey; } @@ -40,7 +38,6 @@ namespace dbaui void SetDataType(sal_Int32 eTyp) { m_eDataType = eTyp; } }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_TABLEFIELDINFO_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx index d32ba27b90ca..ac48bab4bb34 100644 --- a/dbaccess/source/ui/querydesign/TableWindow.cxx +++ b/dbaccess/source/ui/querydesign/TableWindow.cxx @@ -25,12 +25,15 @@ #include <JoinTableView.hxx> #include <JoinDesignView.hxx> #include <osl/diagnose.h> +#include <utility> #include <vcl/svapp.hxx> -#include <vcl/wall.hxx> #include <vcl/settings.hxx> #include <vcl/commandevent.hxx> #include <vcl/event.hxx> #include <vcl/ptrstyle.hxx> +#include <vcl/wall.hxx> +#include <vcl/weldutils.hxx> +#include <comphelper/diagnose_ex.hxx> #include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -39,19 +42,13 @@ #include <bitmaps.hlst> #include <TableWindowAccess.hxx> #include <connectivity/dbtools.hxx> -#include <vcl/treelistentry.hxx> -#include <vcl/builder.hxx> using namespace dbaui; -using namespace ::utl; using namespace ::com::sun::star; using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; 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 ::com::sun::star::accessibility; namespace DatabaseObject = css::sdb::application::DatabaseObject; @@ -86,17 +83,15 @@ void Draw3DBorder(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR } -OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_type& pTabWinData ) - : ::comphelper::OContainerListener(m_aMutex) - ,Window( pParent, WB_3DLOOK|WB_MOVEABLE ) - ,m_aTypeImage( VclPtr<FixedImage>::Create(this) ) - ,m_xTitle( VclPtr<OTableWindowTitle>::Create(this) ) - ,m_pData( pTabWinData ) - ,m_nMoveCount(0) - ,m_nMoveIncrement(1) - ,m_nSizingFlags( SizingFlags::NONE ) +OTableWindow::OTableWindow( vcl::Window* pParent, TTableWindowData::value_type pTabWinData ) + : ::comphelper::OContainerListener(m_aMutex) + , Window( pParent, WB_3DLOOK|WB_MOVEABLE ) + , m_xTitle( VclPtr<OTableWindowTitle>::Create(this) ) + , m_pData(std::move( pTabWinData )) + , m_nMoveCount(0) + , m_nMoveIncrement(1) + , m_nSizingFlags( SizingFlags::NONE ) { - // Set position and size if( GetData()->HasPosition() ) SetPosPixel( GetData()->GetPosition() ); @@ -123,13 +118,12 @@ void OTableWindow::dispose() { if (m_xListBox) { - OSL_ENSURE(m_xListBox->GetEntryCount()==0,"Forgot to call EmptyListbox()!"); + OSL_ENSURE(m_xListBox->get_widget().n_children()==0,"Forgot to call EmptyListbox()!"); } m_xListBox.disposeAndClear(); if ( m_pContainerListener.is() ) m_pContainerListener->dispose(); - m_aTypeImage.disposeAndClear(); m_xTitle.disposeAndClear(); vcl::Window::dispose(); } @@ -179,7 +173,10 @@ void OTableWindow::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) void OTableWindow::FillListBox() { - m_xListBox->Clear(); + clearListBox(); + weld::TreeView& rTreeView = m_xListBox->get_widget(); + assert(!rTreeView.n_children()); + if ( !m_pContainerListener.is() ) { Reference< XContainer> xContainer(m_pData->getColumns(),UNO_QUERY); @@ -188,12 +185,11 @@ void OTableWindow::FillListBox() } // mark all primary keys with special image - Image aPrimKeyImage(StockImage::Yes, BMP_PRIMARY_KEY); + OUString aPrimKeyImage(BMP_PRIMARY_KEY); if (GetData()->IsShowAll()) { - SvTreeListEntry* pEntry = m_xListBox->InsertEntry( OUString("*") ); - pEntry->SetUserData( createUserData(nullptr,false) ); + rTreeView.append(weld::toId(createUserData(nullptr,false)), u"*"_ustr); } Reference<XNameAccess> xPKeyColumns; @@ -203,36 +199,34 @@ void OTableWindow::FillListBox() } catch(Exception&) { - OSL_FAIL("Exception occurred!"); + TOOLS_WARN_EXCEPTION( "dbaccess", ""); } try { Reference< XNameAccess > xColumns = m_pData->getColumns(); if( xColumns.is() ) { - Sequence< OUString> aColumns = xColumns->getElementNames(); - const OUString* pIter = aColumns.getConstArray(); - const OUString* pEnd = pIter + aColumns.getLength(); - - SvTreeListEntry* pEntry = nullptr; - for (; pIter != pEnd; ++pIter) + for (auto& column : xColumns->getElementNames()) { - bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName( *pIter ); + bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName(column); + + OUString sId; + Reference<XPropertySet> xColumn(xColumns->getByName(column), UNO_QUERY); + if (xColumn.is()) + sId = weld::toId(createUserData(xColumn, bPrimaryKeyColumn)); + + rTreeView.append(sId, column); + // is this column in the primary key if ( bPrimaryKeyColumn ) - pEntry = m_xListBox->InsertEntry(*pIter, aPrimKeyImage, aPrimKeyImage); - else - pEntry = m_xListBox->InsertEntry(*pIter); - - Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY); - if ( xColumn.is() ) - pEntry->SetUserData( createUserData(xColumn,bPrimaryKeyColumn) ); + rTreeView.set_image(rTreeView.n_children() - 1, aPrimKeyImage); } + } } catch(Exception&) { - OSL_FAIL("Exception occurred!"); + TOOLS_WARN_EXCEPTION( "dbaccess", ""); } } @@ -252,33 +246,22 @@ void OTableWindow::clearListBox() if ( !m_xListBox ) return; - SvTreeListEntry* pEntry = m_xListBox->First(); - - while(pEntry) - { - void* pUserData = pEntry->GetUserData(); + weld::TreeView& rTreeView = m_xListBox->get_widget(); + rTreeView.all_foreach([this, &rTreeView](weld::TreeIter& rEntry){ + void* pUserData = weld::fromId<void*>(rTreeView.get_id(rEntry)); deleteUserData(pUserData); - SvTreeListEntry* pNextEntry = m_xListBox->Next(pEntry); - m_xListBox->GetModel()->Remove(pEntry); - pEntry = pNextEntry; - } + return false; + }); + + rTreeView.clear(); } void OTableWindow::impl_updateImage() { + weld::Image& rImage = m_xTitle->GetImage(); ImageProvider aImageProvider( getDesignView()->getController().getConnection() ); - - Image aImage; - aImageProvider.getImages( GetComposedName(), m_pData->isQuery() ? DatabaseObject::QUERY : DatabaseObject::TABLE, aImage ); - - if ( !aImage ) - { - OSL_FAIL( "OTableWindow::impl_updateImage: no images!" ); - return; - } - - m_aTypeImage->SetModeImage( aImage ); - m_aTypeImage->Show(); + rImage.set_from_icon_name(aImageProvider.getImageId(GetComposedName(), m_pData->isQuery() ? DatabaseObject::QUERY : DatabaseObject::TABLE)); + rImage.show(); } bool OTableWindow::Init() @@ -287,20 +270,21 @@ bool OTableWindow::Init() if ( !m_xListBox ) { m_xListBox = VclPtr<OTableWindowListBox>::Create(this); - OSL_ENSURE( m_xListBox != nullptr, "OTableWindow::Init() : CreateListBox returned NULL !" ); - m_xListBox->SetSelectionMode( SelectionMode::Multiple ); + assert(m_xListBox && "OTableWindow::Init() : CreateListBox returned NULL !"); + m_xListBox->get_widget().set_selection_mode(SelectionMode::Multiple); } // Set the title - m_xTitle->SetText( m_pData->GetWinName() ); + weld::Label& rLabel = m_xTitle->GetLabel(); + rLabel.set_label(m_pData->GetWinName()); + rLabel.set_tooltip_text(GetComposedName()); m_xTitle->Show(); m_xListBox->Show(); // add the fields to the ListBox - clearListBox(); FillListBox(); - m_xListBox->SelectAll( false ); + m_xListBox->get_widget().unselect_all(); impl_updateImage(); @@ -428,25 +412,20 @@ void OTableWindow::Resize() Size aOutSize = GetOutputSizePixel(); aOutSize = Size(CalcZoom(aOutSize.Width()),CalcZoom(aOutSize.Height())); - long nTitleHeight = CalcZoom( GetTextHeight() )+ CalcZoom( 4 ); + tools::Long nTitleHeight = CalcZoom( GetTextHeight() )+ CalcZoom( 4 ); // Set the title and ListBox - long n5Pos = CalcZoom(5); - long nPositionX = n5Pos; - long nPositionY = n5Pos; - - // position the image which indicates the type - m_aTypeImage->SetPosPixel( Point( nPositionX, nPositionY ) ); - Size aImageSize( m_aTypeImage->GetImage().GetSizePixel() ); - m_aTypeImage->SetSizePixel( aImageSize ); + tools::Long n5Pos = CalcZoom(5); + tools::Long nPositionX = n5Pos; + tools::Long nPositionY = n5Pos; - if ( nTitleHeight < aImageSize.Height() ) - nTitleHeight = aImageSize.Height(); + Size aPreferredSize = m_xTitle->get_preferred_size(); + if (nTitleHeight < aPreferredSize.Height()) + nTitleHeight = aPreferredSize.Height(); - nPositionX += aImageSize.Width() + CalcZoom( 2 ); m_xTitle->SetPosSizePixel( Point( nPositionX, nPositionY ), Size( aOutSize.Width() - nPositionX - n5Pos, nTitleHeight ) ); - long nTitleToList = CalcZoom( 3 ); + tools::Long nTitleToList = CalcZoom( 3 ); m_xListBox->SetPosSizePixel( Point( n5Pos, nPositionY + nTitleHeight + nTitleToList ), @@ -458,10 +437,10 @@ void OTableWindow::Resize() void OTableWindow::SetBoldTitle( bool bBold ) { - vcl::Font aFont = m_xTitle->GetFont(); - aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL ); - m_xTitle->SetFont( aFont ); - m_xTitle->Invalidate(); + weld::Label& rLabel = m_xTitle->GetLabel(); + vcl::Font aFont = rLabel.get_font(); + aFont.SetWeight(bBold ? WEIGHT_BOLD : WEIGHT_NORMAL); + rLabel.set_font(aFont); } void OTableWindow::GetFocus() @@ -475,8 +454,12 @@ void OTableWindow::GetFocus() void OTableWindow::setActive(bool _bActive) { SetBoldTitle( _bActive ); - if (!_bActive && m_xListBox && m_xListBox->GetSelectionCount() != 0) - m_xListBox->SelectAll(false); + if (_bActive || !m_xListBox) + return; + + weld::TreeView& rTreeView = m_xListBox->get_widget(); + if (rTreeView.get_selected_index() != -1) + rTreeView.unselect_all(); } void OTableWindow::Remove() @@ -488,23 +471,6 @@ void OTableWindow::Remove() pTabWinCont->Invalidate(); } -bool OTableWindow::HandleKeyInput( const KeyEvent& rEvt ) -{ - const vcl::KeyCode& rCode = rEvt.GetKeyCode(); - sal_uInt16 nCode = rCode.GetCode(); - bool bShift = rCode.IsShift(); - bool bCtrl = rCode.IsMod1(); - - bool bHandle = false; - - if( !bCtrl && !bShift && (nCode==KEY_DELETE) ) - { - Remove(); - bHandle = true; - } - return bHandle; -} - bool OTableWindow::ExistsAConn() const { return getTableView()->ExistsAConn(this); @@ -513,17 +479,13 @@ bool OTableWindow::ExistsAConn() const void OTableWindow::EnumValidFields(std::vector< OUString>& arrstrFields) { arrstrFields.clear(); + weld::TreeView& rTreeView = m_xListBox->get_widget(); + // This default implementation counts every item in the ListBox ... for any other behaviour it must be over-written - if ( m_xListBox ) - { - arrstrFields.reserve(m_xListBox->GetEntryCount()); - SvTreeListEntry* pEntryLoop = m_xListBox->First(); - while (pEntryLoop) - { - arrstrFields.push_back(m_xListBox->GetEntryText(pEntryLoop)); - pEntryLoop = m_xListBox->Next(pEntryLoop); - } - } + rTreeView.all_foreach([&rTreeView, &arrstrFields](weld::TreeIter& rEntry){ + arrstrFields.push_back(rTreeView.get_text(rEntry)); + return false; + }); } void OTableWindow::StateChanged( StateChangedType nType ) @@ -540,7 +502,7 @@ void OTableWindow::StateChanged( StateChangedType nType ) vcl::Font aFont = rStyleSettings.GetGroupFont(); if ( IsControlFont() ) aFont.Merge( GetControlFont() ); - SetZoomedPointFont(*this, aFont); + SetZoomedPointFont(*GetOutDev(), aFont); m_xTitle->SetZoom(GetZoom()); m_xListBox->SetZoom(GetZoom()); @@ -567,16 +529,19 @@ void OTableWindow::Command(const CommandEvent& rEvt) ptWhere = rEvt.GetMousePosPixel(); else { - SvTreeListEntry* pCurrent = m_xListBox->GetCurEntry(); - if ( pCurrent ) - ptWhere = m_xListBox->GetEntryPosition(pCurrent); + weld::TreeView& rTreeView = m_xListBox->get_widget(); + std::unique_ptr<weld::TreeIter> xCurrent = rTreeView.make_iterator(); + if (rTreeView.get_cursor(xCurrent.get())) + ptWhere = rTreeView.get_row_area(*xCurrent).Center(); else ptWhere = m_xTitle->GetPosPixel(); } - VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "dbaccess/ui/jointablemenu.ui", ""); - VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu")); - if (aContextMenu->Execute(this, ptWhere)) + ::tools::Rectangle aRect(ptWhere, Size(1, 1)); + weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, u"dbaccess/ui/jointablemenu.ui"_ustr)); + std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu(u"menu"_ustr)); + if (!xContextMenu->popup_at_rect(pPopupParent, aRect).isEmpty()) Remove(); } break; @@ -591,7 +556,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt) bool bHandled = false; switch (rNEvt.GetType()) { - case MouseNotifyEvent::KEYINPUT: + case NotifyEventType::KEYINPUT: { if ( getDesignView()->getController().isReadOnly() ) break; @@ -701,7 +666,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt) } break; } - case MouseNotifyEvent::KEYUP: + case NotifyEventType::KEYUP: { const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); const vcl::KeyCode& rCode = pKeyEvent->GetKeyCode(); @@ -723,7 +688,7 @@ bool OTableWindow::PreNotify(NotifyEvent& rNEvt) OUString OTableWindow::getTitle() const { - return m_xTitle->GetText(); + return m_xTitle->GetLabel().get_label(); } void OTableWindow::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx index 3cd87ded7a61..1c524c27a82e 100644 --- a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx @@ -24,18 +24,17 @@ #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <comphelper/sequence.hxx> +#include <vcl/vclevent.hxx> namespace dbaui { using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using namespace ::com::sun::star; OTableWindowAccess::OTableWindowAccess(OTableWindow* _pTable) - :VCLXAccessibleComponent(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : nullptr) + :ImplInheritanceHelper(_pTable) ,m_pTable(_pTable) { } @@ -54,29 +53,19 @@ namespace dbaui VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); } - Any SAL_CALL OTableWindowAccess::queryInterface( const Type& aType ) - { - Any aRet(VCLXAccessibleComponent::queryInterface( aType )); - return aRet.hasValue() ? aRet : OTableWindowAccess_BASE::queryInterface( aType ); - } - Sequence< Type > SAL_CALL OTableWindowAccess::getTypes( ) - { - return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OTableWindowAccess_BASE::getTypes()); - } OUString SAL_CALL OTableWindowAccess::getImplementationName() { - return "org.openoffice.comp.dbu.TableWindowAccessibility"; + return u"org.openoffice.comp.dbu.TableWindowAccessibility"_ustr; } Sequence< OUString > SAL_CALL OTableWindowAccess::getSupportedServiceNames() { - return { "com.sun.star.accessibility.Accessible", - "com.sun.star.accessibility.AccessibleContext" }; + return { u"com.sun.star.accessibility.AccessibleContext"_ustr }; } // XAccessibleContext - sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleChildCount( ) + sal_Int64 SAL_CALL OTableWindowAccess::getAccessibleChildCount( ) { ::osl::MutexGuard aGuard( m_aMutex ); - sal_Int32 nCount = 0; + sal_Int64 nCount = 0; if(m_pTable) { ++nCount; @@ -85,11 +74,11 @@ namespace dbaui } return nCount; } - Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int32 i ) + Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int64 i ) { ::osl::MutexGuard aGuard( m_aMutex ); Reference< XAccessible > aRet; - if (m_pTable && !m_pTable->IsDisposed()) + if (m_pTable && !m_pTable->isDisposed()) { switch(i) { @@ -113,10 +102,10 @@ namespace dbaui } return aRet; } - sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent( ) + sal_Int64 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent( ) { ::osl::MutexGuard aGuard( m_aMutex ); - sal_Int32 nIndex = -1; + sal_Int64 nIndex = -1; if( m_pTable ) { // search the position of our table window in the table window map @@ -148,18 +137,18 @@ namespace dbaui { ::osl::MutexGuard aGuard( m_aMutex ); Reference< XAccessible > aRet; - if(m_pTable && !m_pTable->IsDisposed()) + if(m_pTable && !m_pTable->isDisposed()) { - Point aPoint(_aPoint.X,_aPoint.Y); - tools::Rectangle aRect(m_pTable->GetDesktopRectPixel()); - if( aRect.IsInside(aPoint) ) + AbsoluteScreenPixelPoint aPoint(_aPoint.X,_aPoint.Y); + AbsoluteScreenPixelRectangle aRect(m_pTable->GetDesktopRectPixel()); + if( aRect.Contains(aPoint) ) aRet = this; - else if( m_pTable->GetListBox()->GetDesktopRectPixel().IsInside(aPoint)) + else if( m_pTable->GetListBox()->GetDesktopRectPixel().Contains(aPoint)) aRet = m_pTable->GetListBox()->GetAccessible(); } return aRet; } - Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int32 _nIndex) + Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int64 _nIndex) { Reference< XAccessible > xReturn; Reference< XAccessible > xParent = getAccessibleParent(); @@ -190,41 +179,40 @@ namespace dbaui { OJoinTableView* pView = m_pTable->getTableView(); auto aIter = pView->getTableConnections(m_pTable) + nIndex; - aRet.TargetSet.realloc(1); - aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections().begin()); - aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR; + aRet.TargetSet = { getParentChild(aIter - pView->getTableConnections().begin()) }; + aRet.RelationType = AccessibleRelationType_CONTROLLER_FOR; } return aRet; } - sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType ) + sal_Bool SAL_CALL OTableWindowAccess::containsRelation(AccessibleRelationType eRelationType) { ::osl::MutexGuard aGuard( m_aMutex ); - return AccessibleRelationType::CONTROLLER_FOR == aRelationType + return AccessibleRelationType_CONTROLLER_FOR == eRelationType && m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable); } - AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType ) + AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType(AccessibleRelationType eRelationType) { ::osl::MutexGuard aGuard( m_aMutex ); - if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable) + if (AccessibleRelationType_CONTROLLER_FOR == eRelationType && m_pTable) { OJoinTableView* pView = m_pTable->getTableView(); const auto& rConnectionList = pView->getTableConnections(); auto aIter = pView->getTableConnections(m_pTable); auto aEnd = rConnectionList.end(); - std::vector< Reference<XInterface> > aRelations; + std::vector< Reference<css::accessibility::XAccessible> > aRelations; aRelations.reserve(5); // just guessing // TODO JNA aIter comes from pView->getTableConnections(m_pTable) // and aEnd comes from pView->getTableConnections().end() for (; aIter != aEnd ; ++aIter ) { - uno::Reference<uno::XInterface> xInterface( + uno::Reference<css::accessibility::XAccessible> xAccessible( getParentChild(aIter - rConnectionList.begin())); - aRelations.push_back(xInterface); + aRelations.push_back(xAccessible); } - Sequence< Reference<XInterface> > aSeq(aRelations.data(), aRelations.size()); - return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq); + Sequence<Reference<css::accessibility::XAccessible>> aSeq(aRelations.data(), aRelations.size()); + return AccessibleRelation(AccessibleRelationType_CONTROLLER_FOR, aSeq); } return AccessibleRelation(); } @@ -240,11 +228,6 @@ namespace dbaui sAccessibleName = m_pTable->getTitle(); return sAccessibleName; } - Reference< XAccessibleContext > SAL_CALL OTableWindowAccess::getAccessibleContext( ) - { - return this; - } - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/TableWindowData.cxx b/dbaccess/source/ui/querydesign/TableWindowData.cxx index d07c8214a17c..3cbead6e406c 100644 --- a/dbaccess/source/ui/querydesign/TableWindowData.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowData.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/lang/XComponent.hpp> +#include <utility> using namespace dbaui; using namespace ::com::sun::star::lang; @@ -37,13 +38,13 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; OTableWindowData::OTableWindowData( const Reference< XPropertySet>& _xTable - ,const OUString& _rComposedName - ,const OUString& rTableName - ,const OUString& rWinName ) + ,OUString _sComposedName + ,OUString sTableName + ,OUString sWinName ) :m_xTable(_xTable) - ,m_aTableName( rTableName ) - ,m_aWinName( rWinName ) - ,m_sComposedName(_rComposedName) + ,m_aTableName(std::move( sTableName )) + ,m_aWinName(std::move( sWinName )) + ,m_sComposedName(std::move(_sComposedName)) ,m_aPosition( Point(-1,-1) ) ,m_aSize( Size(-1,-1) ) ,m_bShowAll( true ) diff --git a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx index a4ba5f0022ae..0141b8ed89f4 100644 --- a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx @@ -28,7 +28,7 @@ #include <com/sun/star/sdbc/SQLException.hpp> #include <vcl/svapp.hxx> #include <vcl/commandevent.hxx> -#include <vcl/event.hxx> +#include <o3tl/string_view.hxx> using namespace dbaui; using namespace ::com::sun::star::sdbc; @@ -37,41 +37,49 @@ using namespace ::com::sun::star::datatransfer; OJoinExchangeData::OJoinExchangeData(OTableWindowListBox* pBox) : pListBox(pBox) - , pEntry(pBox->FirstSelected()) -{ } - -const sal_uLong SCROLLING_TIMESPAN = 500; -const long LISTBOX_SCROLLING_AREA = 6; -OTableWindowListBox::OTableWindowListBox( OTableWindow* pParent ) - :SvTreeListBox( pParent, WB_HASBUTTONS | WB_BORDER) - ,m_aMousePos( Point(0,0) ) - ,m_pTabWin( pParent ) - ,m_nDropEvent(nullptr) - ,m_nUiEvent(nullptr) - ,m_bReallyScrolled( false ) + , nEntry(pBox->get_widget().get_selected_index()) { - m_aScrollTimer.SetTimeout( SCROLLING_TIMESPAN ); - SetDoubleClickHdl( LINK(this, OTableWindowListBox, OnDoubleClick) ); +} - SetSelectionMode(SelectionMode::Single); +OTableWindowListBox::OTableWindowListBox(OTableWindow* pParent) + : InterimItemWindow(pParent, u"dbaccess/ui/tablelistbox.ui"_ustr, u"TableListBox"_ustr) + , m_xTreeView(m_xBuilder->weld_tree_view(u"treeview"_ustr)) + , m_xDragDropTargetHelper(new TableWindowListBoxHelper(*this, m_xTreeView->get_drop_target())) + , m_pTabWin(pParent) + , m_nDropEvent(nullptr) + , m_nUiEvent(nullptr) +{ + m_xTreeView->connect_row_activated(LINK(this, OTableWindowListBox, OnDoubleClick)); + m_xTreeView->connect_visible_range_changed(LINK(this, OTableWindowListBox, ScrollHdl)); + m_xTreeView->connect_popup_menu(LINK(this, OTableWindowListBox, CommandHdl)); + + m_xHelper.set(new OJoinExchObj); + rtl::Reference<TransferDataContainer> xHelper(m_xHelper); + m_xTreeView->enable_drag_source(xHelper, DND_ACTION_LINK); + m_xTreeView->connect_drag_begin(LINK(this, OTableWindowListBox, DragBeginHdl)); +} - SetHighlightRange( ); +IMPL_LINK(OTableWindowListBox, CommandHdl, const CommandEvent&, rCEvt, bool) +{ + if (rCEvt.GetCommand() != CommandEventId::ContextMenu) + return false; + m_pTabWin->Command(rCEvt); + return true; } -void OTableWindowListBox::dragFinished( ) +void OTableWindowListBox::dragFinished() { // first show the error msg when existing - m_pTabWin->getDesignView()->getController().showError(m_pTabWin->getDesignView()->getController().clearOccurredError()); + m_pTabWin->getDesignView()->getController().showError( + m_pTabWin->getDesignView()->getController().clearOccurredError()); // second look for ui activities which should happen after d&d if (m_nUiEvent) Application::RemoveUserEvent(m_nUiEvent); - m_nUiEvent = Application::PostUserEvent(LINK(this, OTableWindowListBox, LookForUiHdl), nullptr, true); + m_nUiEvent + = Application::PostUserEvent(LINK(this, OTableWindowListBox, LookForUiHdl), nullptr, true); } -OTableWindowListBox::~OTableWindowListBox() -{ - disposeOnce(); -} +OTableWindowListBox::~OTableWindowListBox() { disposeOnce(); } void OTableWindowListBox::dispose() { @@ -79,17 +87,15 @@ void OTableWindowListBox::dispose() Application::RemoveUserEvent(m_nDropEvent); if (m_nUiEvent) Application::RemoveUserEvent(m_nUiEvent); - if( m_aScrollTimer.IsActive() ) - m_aScrollTimer.Stop(); - m_pTabWin.clear(); - SvTreeListBox::dispose(); + m_pTabWin.reset(); + m_xDragDropTargetHelper.reset(); + m_xTreeView.reset(); + InterimItemWindow::dispose(); } -SvTreeListEntry* OTableWindowListBox::GetEntryFromText( const OUString& rEntryText ) +int OTableWindowListBox::GetEntryFromText(std::u16string_view rEntryText) { // iterate through the list - SvTreeList* pTreeList = GetModel(); - SvTreeListEntry* pEntry = pTreeList->First(); OJoinDesignView* pView = m_pTabWin->getDesignView(); OJoinController& rController = pView->getController(); @@ -97,258 +103,174 @@ SvTreeListEntry* OTableWindowListBox::GetEntryFromText( const OUString& rEntryTe { bool bCase = false; const Reference<XConnection>& xConnection = rController.getConnection(); - if(xConnection.is()) + if (xConnection.is()) { Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); - if(xMeta.is()) + if (xMeta.is()) bCase = xMeta->supportsMixedCaseQuotedIdentifiers(); } - while( pEntry ) + for (int nEntry = 0, nCount = m_xTreeView->n_children(); nEntry < nCount; ++nEntry) { - if(bCase ? rEntryText == GetEntryText(pEntry) : rEntryText.equalsIgnoreAsciiCase(GetEntryText(pEntry))) - { - return pEntry; - } - pEntry = pTreeList->Next(pEntry); + if (bCase ? rEntryText == m_xTreeView->get_text(nEntry) + : o3tl::equalsIgnoreAsciiCase(rEntryText, m_xTreeView->get_text(nEntry))) + return nEntry; } } - catch(SQLException&) + catch (SQLException&) { } - return nullptr; + return -1; } -void OTableWindowListBox::NotifyScrolled() +IMPL_LINK_NOARG(OTableWindowListBox, ScrollHdl, weld::TreeView&, void) { - m_bReallyScrolled = true; -} - -void OTableWindowListBox::NotifyEndScroll() -{ - if (m_bReallyScrolled) - // connections of this table, if any, should be redrawn - m_pTabWin->getTableView()->Invalidate(InvalidateFlags::NoChildren); - - // without InvalidateFlags::NoChildren all tables would be redrawn, - // so: flickering - m_bReallyScrolled = false; + // connections of this table, if any, should be redrawn + m_pTabWin->getTableView()->Invalidate(InvalidateFlags::NoChildren); } -bool OTableWindowListBox::PreNotify(NotifyEvent& rNEvt) +IMPL_LINK(OTableWindowListBox, DragBeginHdl, bool&, rUnsetDragIcon, bool) { - bool bHandled = false; - switch (rNEvt.GetType()) + rUnsetDragIcon = false; + if (m_xTreeView->get_selected_index() == -1) { - case MouseNotifyEvent::KEYINPUT: - { - const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); - const vcl::KeyCode& rCode = pKeyEvent->GetKeyCode(); - - if (rCode.GetCode() != KEY_RETURN) - { - if(m_pTabWin) - { - bHandled = m_pTabWin->HandleKeyInput(*pKeyEvent); - } - break; - } - - if (rCode.IsMod1() || rCode.IsMod2() || rCode.IsShift()) - break; - if (FirstSelected()) - static_cast<OTableWindow*>(Window::GetParent())->OnEntryDoubleClicked(FirstSelected()); - break; - } - default: - break; + // no drag without a field + return true; } - if (!bHandled) - return SvTreeListBox::PreNotify(rNEvt); - return true; -} - -IMPL_LINK_NOARG( OTableWindowListBox, ScrollUpHdl, Timer*, void ) -{ - SvTreeListEntry* pEntry = GetEntry( m_aMousePos ); - if( !pEntry ) - return; - - if( pEntry != Last() ) - { - ScrollOutputArea( -1 ); - pEntry = GetEntry( m_aMousePos ); - Select( pEntry ); - } -} - -IMPL_LINK_NOARG( OTableWindowListBox, ScrollDownHdl, Timer*, void ) -{ - SvTreeListEntry* pEntry = GetEntry( m_aMousePos ); - if( !pEntry ) - return; - - if( pEntry != Last() ) - { - ScrollOutputArea( 1 ); - pEntry = GetEntry( m_aMousePos ); - Select( pEntry ); - } -} - -void OTableWindowListBox::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ ) -{ OJoinTableView* pCont = m_pTabWin->getTableView(); - if (!pCont->getDesignView()->getController().isReadOnly() && pCont->getDesignView()->getController().isConnected()) + if (!pCont->getDesignView()->getController().isReadOnly() + && pCont->getDesignView()->getController().isConnected()) { // asterisk was not allowed to be copied to selection browsebox - bool bFirstNotAllowed = FirstSelected() == First() && m_pTabWin->GetData()->IsShowAll(); - EndSelection(); + bool bFirstNotAllowed = m_xTreeView->is_selected(0) && m_pTabWin->GetData()->IsShowAll(); // create a description of the source OJoinExchangeData jxdSource(this); - // put it into an exchange object - rtl::Reference<OJoinExchObj> pJoin = new OJoinExchObj(jxdSource,bFirstNotAllowed); - pJoin->StartDrag(this, DND_ACTION_LINK, this); + // update the exchange object + m_xHelper->setDescriptors(jxdSource, bFirstNotAllowed); + + return false; } + + return true; } -sal_Int8 OTableWindowListBox::AcceptDrop( const AcceptDropEvent& _rEvt ) +sal_Int8 OTableWindowListBox::AcceptDrop(const AcceptDropEvent& _rEvt) { + // to enable the autoscroll when we're close to the edges + std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator()); + bool bHasDestRow = m_xTreeView->get_dest_row_at_pos(_rEvt.maPosPixel, xEntry.get(), true); + sal_Int8 nDND_Action = DND_ACTION_NONE; // check the format - if ( !OJoinExchObj::isFormatAvailable(GetDataFlavorExVector(),SotClipboardFormatId::SBA_TABID) // this means that the first entry is to be dragged - && OJoinExchObj::isFormatAvailable(GetDataFlavorExVector()) ) - { // don't drop into the window if it's the drag source itself + if (!OJoinExchObj::isFormatAvailable( + m_xDragDropTargetHelper->GetDataFlavorExVector(), + SotClipboardFormatId::SBA_TABID) // this means that the first entry is to be dragged + && OJoinExchObj::isFormatAvailable(m_xDragDropTargetHelper->GetDataFlavorExVector())) + { // don't drop into the window if it's the drag source itself // remove the selection if the dragging operation is leaving the window if (_rEvt.mbLeaving) - SelectAll(false); + m_xTreeView->unselect_all(); else { - // hit test - m_aMousePos = _rEvt.maPosPixel; - Size aOutputSize = GetOutputSizePixel(); - SvTreeListEntry* pEntry = GetEntry( m_aMousePos ); - if( !pEntry ) + if (!bHasDestRow) return DND_ACTION_NONE; - // Scrolling Areas - tools::Rectangle aBottomScrollArea( Point(0, aOutputSize.Height()-LISTBOX_SCROLLING_AREA), - Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) ); - tools::Rectangle aTopScrollArea( Point(0,0), Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) ); - - // scroll up if the pointer is on the upper scroll area - if( aBottomScrollArea.IsInside(m_aMousePos) ) - { - if( !m_aScrollTimer.IsActive() ) - { - m_aScrollTimer.SetInvokeHandler( LINK(this, OTableWindowListBox, ScrollUpHdl) ); - ScrollUpHdl( nullptr ); - } - } - // scroll down if the pointer is on the lower scroll area - else if( aTopScrollArea.IsInside(m_aMousePos) ) - { - if( !m_aScrollTimer.IsActive() ) - { - m_aScrollTimer.SetInvokeHandler( LINK(this, OTableWindowListBox, ScrollDownHdl) ); - ScrollDownHdl( nullptr ); - } - } - else - { - if( m_aScrollTimer.IsActive() ) - m_aScrollTimer.Stop(); - } - // automatically select right entry when dragging - if ((FirstSelected() != pEntry) || NextSelected(FirstSelected())) - SelectAll(false); - Select(pEntry); + m_xTreeView->unselect_all(); + m_xTreeView->select(*xEntry); // one cannot drop on the first (*) entry - if(!( m_pTabWin->GetData()->IsShowAll() && (pEntry==First()) )) + if (!(m_pTabWin->GetData()->IsShowAll() + && (m_xTreeView->get_iter_index_in_parent(*xEntry) == 0))) nDND_Action = DND_ACTION_LINK; } } return nDND_Action; } -IMPL_LINK_NOARG( OTableWindowListBox, LookForUiHdl, void*, void ) +IMPL_LINK_NOARG(OTableWindowListBox, LookForUiHdl, void*, void) { m_nUiEvent = nullptr; m_pTabWin->getTableView()->lookForUiActivities(); } -IMPL_LINK_NOARG( OTableWindowListBox, DropHdl, void*, void ) +IMPL_LINK_NOARG(OTableWindowListBox, DropHdl, void*, void) { // create the connection m_nDropEvent = nullptr; - OSL_ENSURE(m_pTabWin,"No TableWindow!"); + OSL_ENSURE(m_pTabWin, "No TableWindow!"); try { OJoinTableView* pCont = m_pTabWin->getTableView(); - OSL_ENSURE(pCont,"No QueryTableView!"); + OSL_ENSURE(pCont, "No QueryTableView!"); pCont->AddConnection(m_aDropInfo.aSource, m_aDropInfo.aDest); } - catch(const SQLException& e) + catch (const SQLException& e) { // remember the exception so that we can show them later when d&d is finished - m_pTabWin->getDesignView()->getController().setErrorOccurred(::dbtools::SQLExceptionInfo(e)); + m_pTabWin->getDesignView()->getController().setErrorOccurred( + ::dbtools::SQLExceptionInfo(e)); } } -sal_Int8 OTableWindowListBox::ExecuteDrop( const ExecuteDropEvent& _rEvt ) +sal_Int8 OTableWindowListBox::ExecuteDrop(const ExecuteDropEvent& _rEvt) { TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable); - if ( OJoinExchObj::isFormatAvailable(aDropped.GetDataFlavorExVector())) - { // don't drop into the window if it's the drag source itself + if (OJoinExchObj::isFormatAvailable(aDropped.GetDataFlavorExVector())) + { // don't drop into the window if it's the drag source itself m_aDropInfo.aSource = OJoinExchangeData(this); - m_aDropInfo.aDest = OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable); + m_aDropInfo.aDest = OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable); if (m_nDropEvent) Application::RemoveUserEvent(m_nDropEvent); - m_nDropEvent = Application::PostUserEvent(LINK(this, OTableWindowListBox, DropHdl), nullptr, true); + m_nDropEvent + = Application::PostUserEvent(LINK(this, OTableWindowListBox, DropHdl), nullptr, true); + + dragFinished(); - return DND_ACTION_LINK; + return DND_ACTION_NONE; } return DND_ACTION_NONE; } void OTableWindowListBox::LoseFocus() { - if(m_pTabWin) + if (m_pTabWin) m_pTabWin->setActive(false); - SvTreeListBox::LoseFocus(); + InterimItemWindow::LoseFocus(); } void OTableWindowListBox::GetFocus() { - if(m_pTabWin) + if (m_pTabWin) m_pTabWin->setActive(); - if (GetCurEntry() != nullptr) + if (m_xTreeView) { - if ( GetSelectionCount() == 0 || GetCurEntry() != FirstSelected() ) + std::unique_ptr<weld::TreeIter> xCurrent = m_xTreeView->make_iterator(); + if (m_xTreeView->get_cursor(xCurrent.get())) { - if ( FirstSelected() ) - Select(FirstSelected(), false); - Select(GetCurEntry()); + m_xTreeView->unselect_all(); + m_xTreeView->select(*xCurrent); } - else - ShowFocusRect(FirstSelected()); } - SvTreeListBox::GetFocus(); + + InterimItemWindow::GetFocus(); } -IMPL_LINK_NOARG( OTableWindowListBox, OnDoubleClick, SvTreeListBox *, bool ) +IMPL_LINK_NOARG(OTableWindowListBox, OnDoubleClick, weld::TreeView&, bool) { // tell my parent vcl::Window* pParent = Window::GetParent(); OSL_ENSURE(pParent != nullptr, "OTableWindowListBox::OnDoubleClick : have no Parent !"); - static_cast<OTableWindow*>(pParent)->OnEntryDoubleClicked(GetHdlEntry()); + std::unique_ptr<weld::TreeIter> xCurrent = m_xTreeView->make_iterator(); + if (!m_xTreeView->get_cursor(xCurrent.get())) + return false; + + static_cast<OTableWindow*>(pParent)->OnEntryDoubleClicked(*xCurrent); return false; } @@ -363,7 +285,7 @@ void OTableWindowListBox::Command(const CommandEvent& rEvt) break; } default: - SvTreeListBox::Command(rEvt); + InterimItemWindow::Command(rEvt); } } diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx index 952063d5d3cc..90f2c615dcba 100644 --- a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx @@ -19,9 +19,6 @@ #include <TableWindowTitle.hxx> #include <TableWindow.hxx> -#include <vcl/svapp.hxx> -#include <vcl/help.hxx> -#include <vcl/settings.hxx> #include <vcl/commandevent.hxx> #include <vcl/event.hxx> #include <TableWindowListBox.hxx> @@ -29,20 +26,13 @@ #include <JoinController.hxx> using namespace dbaui; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::uno; -OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) : - FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER ) - ,m_pTabWin( pParent ) +OTableWindowTitle::OTableWindowTitle(OTableWindow* pParent) + : InterimItemWindow(pParent, u"dbaccess/ui/tabletitle.ui"_ustr, u"TableTitle"_ustr) + , m_pTabWin( pParent ) + , m_xLabel(m_xBuilder->weld_label(u"label"_ustr)) + , m_xImage(m_xBuilder->weld_image(u"image"_ustr)) { - // set background- and text colour - StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); - SetBackground(Wallpaper(aSystemStyle.GetFaceColor())); - SetTextColor(aSystemStyle.GetButtonTextColor()); - - vcl::Font aFont( GetFont() ); - aFont.SetTransparent( true ); - SetFont( aFont ); + m_xLabel->connect_mouse_press(LINK(this, OTableWindowTitle, MousePressHdl)); } OTableWindowTitle::~OTableWindowTitle() @@ -52,88 +42,29 @@ OTableWindowTitle::~OTableWindowTitle() void OTableWindowTitle::dispose() { - m_pTabWin.clear(); - FixedText::dispose(); -} - -void OTableWindowTitle::GetFocus() -{ - if(m_pTabWin) - m_pTabWin->GetFocus(); - else - FixedText::GetFocus(); -} - -void OTableWindowTitle::LoseFocus() -{ - if (m_pTabWin) - m_pTabWin->LoseFocus(); - else - FixedText::LoseFocus(); -} - -void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt ) -{ - if(!m_pTabWin) - return; - - OUString aHelpText = m_pTabWin->GetComposedName(); - if( aHelpText.isEmpty()) - return; - - // show help - tools::Rectangle aItemRect(Point(0,0),GetSizePixel()); - aItemRect = LogicToPixel( aItemRect ); - Point aPt = OutputToScreenPixel( aItemRect.TopLeft() ); - aItemRect.SetLeft( aPt.X() ); - aItemRect.SetTop( aPt.Y() ); - aPt = OutputToScreenPixel( aItemRect.BottomRight() ); - aItemRect.SetRight( aPt.X() ); - aItemRect.SetBottom( aPt.Y() ); - if( rHEvt.GetMode() == HelpEventMode::BALLOON ) - Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText); - else - Help::ShowQuickHelp( this, aItemRect, aHelpText ); -} - -void OTableWindowTitle::Command( const CommandEvent& rEvt ) -{ - if ( rEvt.GetCommand() == CommandEventId::ContextMenu ) - { - GrabFocus(); - if ( m_pTabWin ) - { - // tdf#94709 - protect shutdown code-path. - VclPtr<OTableWindow> xTabWin(m_pTabWin); - xTabWin->Command( rEvt ); - } - else - Control::Command(rEvt); - } -} - -void OTableWindowTitle::KeyInput( const KeyEvent& rEvt ) -{ - if ( m_pTabWin ) - m_pTabWin->KeyInput( rEvt ); + m_xImage.reset(); + m_xLabel.reset(); + m_pTabWin.reset(); + InterimItemWindow::dispose(); } -void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt ) +IMPL_LINK(OTableWindowTitle, MousePressHdl, const MouseEvent&, rEvt, bool) { - if( rEvt.IsLeft() ) + if (rEvt.IsLeft()) { if( rEvt.GetClicks() == 2) { Size aSize(GetTextWidth(GetText()) + 20, m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height()); - aSize.AdjustHeight((m_pTabWin->GetListBox()->GetEntryCount() + 2) * m_pTabWin->GetListBox()->GetEntryHeight() ); - if(m_pTabWin->GetSizePixel() != aSize) + weld::TreeView& rTreeView = m_pTabWin->GetListBox()->get_widget(); + aSize.AdjustHeight(rTreeView.get_height_rows(rTreeView.n_children() + 2)); + if (m_pTabWin->GetSizePixel() != aSize) { m_pTabWin->SetSizePixel(aSize); OJoinTableView* pView = m_pTabWin->getTableView(); - OSL_ENSURE(pView,"No OJoinTableView!"); + assert(pView && "No OJoinTableView!"); for (auto& conn : pView->getTableConnections()) conn->RecalcLines(); @@ -150,38 +81,15 @@ void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt ) OSL_ENSURE(pView,"No OJoinTableView!"); pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos ); } - GrabFocus(); } - else - Control::MouseButtonDown( rEvt ); -} - -void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt) -{ - if (rDCEvt.GetType() == DataChangedEventType::SETTINGS) + else if (rEvt.IsRight()) { - // assume worst-case: colours have changed, therefore I have to adept - StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings(); - SetBackground(Wallpaper(aSystemStyle.GetFaceColor())); - SetTextColor(aSystemStyle.GetButtonTextColor()); - } -} - -void OTableWindowTitle::StateChanged( StateChangedType nType ) -{ - Window::StateChanged( nType ); - - if ( nType == StateChangedType::Zoom ) - { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - vcl::Font aFont = rStyleSettings.GetGroupFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont(*this, aFont); - - Resize(); + CommandEvent aCEvt(rEvt.GetPosPixel(), CommandEventId::ContextMenu, true); + // tdf#94709 - protect shutdown code-path. + VclPtr<OTableWindow> xTabWin(m_pTabWin); + xTabWin->Command(aCEvt); } + return false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx index 74d01b71134c..59d563388fd5 100644 --- a/dbaccess/source/ui/querydesign/limitboxcontroller.cxx +++ b/dbaccess/source/ui/querydesign/limitboxcontroller.cxx @@ -8,20 +8,19 @@ */ #include "limitboxcontroller.hxx" -#include <apitools.hxx> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <comphelper/propertyvalue.hxx> #include <vcl/InterimItemWindow.hxx> #include <vcl/event.hxx> #include <vcl/svapp.hxx> #include <vcl/window.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <cppuhelper/queryinterface.hxx> -#include <comphelper/processfactory.hxx> #include <core_resource.hxx> #include <strings.hrc> @@ -53,10 +52,12 @@ class LimitBox final : public InterimItemWindow { public: LimitBox(vcl::Window* pParent, LimitBoxController* pCtrl) - : InterimItemWindow(pParent, "dbaccess/ui/limitbox.ui", "LimitBox") + : InterimItemWindow(pParent, u"dbaccess/ui/limitbox.ui"_ustr, u"LimitBox"_ustr) , m_pControl( pCtrl ) - , m_xWidget(m_xBuilder->weld_combo_box("limit")) + , m_xWidget(m_xBuilder->weld_combo_box(u"limit"_ustr)) { + InitControlBase(m_xWidget.get()); + LoadDefaultLimits(); m_xWidget->connect_key_press(LINK(this, LimitBox, KeyInputHdl)); @@ -83,13 +84,6 @@ public: m_xWidget->set_sensitive(bSensitive); } - virtual void GetFocus() override - { - if (m_xWidget) - m_xWidget->grab_focus(); - InterimItemWindow::GetFocus(); - } - void set_value(int nLimit) { if (nLimit < 0) @@ -112,8 +106,6 @@ private: { if (!m_xWidget->get_value_changed_from_saved()) return; - uno::Sequence< beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "DBLimit.Value"; sal_Int64 nLimit; OUString sActiveText = m_xWidget->get_active_text(); if (sActiveText == DBA_RES(STR_QUERY_LIMIT_ALL)) @@ -125,8 +117,7 @@ private: nLimit = -1; } set_value(nLimit); - aArgs[0].Value <<= nLimit; - m_pControl->dispatchCommand( aArgs ); + m_pControl->dispatchCommand({ comphelper::makePropertyValue(u"DBLimit.Value"_ustr, nLimit) }); } ///Initialize entries @@ -183,7 +174,7 @@ IMPL_LINK_NOARG(LimitBox, ActivateHdl, weld::ComboBox&, bool) LimitBoxController::LimitBoxController( const uno::Reference< uno::XComponentContext >& rxContext ) : - svt::ToolboxController( rxContext, + LimitBoxController_Base( rxContext, uno::Reference< frame::XFrame >(), ".uno:DBLimit" ), m_xLimitBox( nullptr ) @@ -194,38 +185,25 @@ LimitBoxController::~LimitBoxController() { } -/// XInterface -uno::Any SAL_CALL LimitBoxController::queryInterface( const uno::Type& aType ) -{ - uno::Any a = ToolboxController::queryInterface( aType ); - if ( a.hasValue() ) - return a; - - return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this )); -} - -void SAL_CALL LimitBoxController::acquire() throw () -{ - ToolboxController::acquire(); -} - -void SAL_CALL LimitBoxController::release() throw () -{ - ToolboxController::release(); -} - - /// XServiceInfo OUString SAL_CALL LimitBoxController::getImplementationName() { - return "org.libreoffice.comp.dbu.LimitBoxController"; + return u"org.libreoffice.comp.dbu.LimitBoxController"_ustr; } -IMPLEMENT_SERVICE_INFO_SUPPORTS(LimitBoxController) +sal_Bool SAL_CALL LimitBoxController::supportsService(const OUString& _rServiceName) + { + const css::uno::Sequence< OUString > aSupported(getSupportedServiceNames()); + for (const OUString& s : aSupported) + if (s == _rServiceName) + return true; + + return false; + } css::uno::Sequence< OUString > SAL_CALL LimitBoxController::getSupportedServiceNames() { - return { "com.sun.star.frame.ToolbarController" }; + return { u"com.sun.star.frame.ToolbarController"_ustr }; } /// XComponent diff --git a/dbaccess/source/ui/querydesign/limitboxcontroller.hxx b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx index 9899c3bb7855..142280937235 100644 --- a/dbaccess/source/ui/querydesign/limitboxcontroller.hxx +++ b/dbaccess/source/ui/querydesign/limitboxcontroller.hxx @@ -7,14 +7,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_LIMITBOXCONTROLLER_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_LIMITBOXCONTROLLER_HXX +#pragma once #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <connectivity/CommonTools.hxx> #include <svtools/toolboxcontroller.hxx> -#include <rtl/ustring.hxx> #include <vcl/vclptr.hxx> namespace dbaui @@ -27,19 +24,14 @@ class LimitBox; * It is communicating with querycontroller and this channel make enable * to set\get the value of limitbox when switching between views */ -class LimitBoxController: public svt::ToolboxController, - public css::lang::XServiceInfo +typedef cppu::ImplInheritanceHelper< ::svt::ToolboxController, css::lang::XServiceInfo> LimitBoxController_Base; +class LimitBoxController: public LimitBoxController_Base { public: explicit LimitBoxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); virtual ~LimitBoxController() override; - /// XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; - virtual void SAL_CALL acquire() throw () override; - virtual void SAL_CALL release() throw () override; - /// XServiceInfo DECLARE_SERVICE_INFO(); @@ -65,6 +57,4 @@ class LimitBoxController: public svt::ToolboxController, } ///dbaui namespace -#endif /// INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_LIMITBOXCONTROLLER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx index 9481f6518cf5..b755dc886aef 100644 --- a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx +++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx @@ -35,7 +35,6 @@ namespace dbaui { using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::beans; @@ -65,7 +64,7 @@ namespace dbaui } if ( m_pBeamer ) ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); - m_pBeamer.clear(); + m_pBeamer.reset(); if ( m_xBeamer.is() ) { Reference< css::util::XCloseable > xCloseable(m_xBeamer,UNO_QUERY); @@ -157,7 +156,7 @@ namespace dbaui } bool OQueryContainerWindow::PreNotify( NotifyEvent& rNEvt ) { - if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS && m_pViewSwitch) + if (rNEvt.GetType() == NotifyEventType::GETFOCUS && m_pViewSwitch) { OJoinController& rController = m_pViewSwitch->getDesignView()->getController(); rController.InvalidateFeature(SID_CUT); @@ -184,7 +183,7 @@ namespace dbaui Reference < XPropertySet > xLMPropSet(m_xBeamer->getLayoutManager(), UNO_QUERY); if ( xLMPropSet.is() ) { - xLMPropSet->setPropertyValue( "AutomaticToolbars", Any( false )); + xLMPropSet->setPropertyValue( u"AutomaticToolbars"_ustr, Any( false )); } } catch( Exception& ) @@ -201,7 +200,7 @@ namespace dbaui Size aSize = GetOutputSizePixel(); Size aBeamer(aSize.Width(),sal_Int32(aSize.Height()*0.33)); - const long nFrameHeight = LogicToPixel(Size(0, 3), MapMode(MapUnit::MapAppFont)).Height(); + const tools::Long nFrameHeight = LogicToPixel(Size(0, 3), MapMode(MapUnit::MapAppFont)).Height(); Point aPos(0,aBeamer.Height()+nFrameHeight); m_pBeamer->SetPosSizePixel(Point(0,0),aBeamer); diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 17c8f1933354..5134161cce5a 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -55,7 +55,6 @@ #include <com/sun/star/ui/XUIElement.hpp> #include <comphelper/propertysequence.hxx> -#include <comphelper/processfactory.hxx> #include <comphelper/property.hxx> #include <comphelper/types.hxx> #include <connectivity/dbexception.hxx> @@ -63,12 +62,14 @@ #include <cppuhelper/exc_hlp.hxx> #include <svl/undo.hxx> #include <toolkit/helper/vclunohelper.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> +#include <utility> #include <vcl/stdtext.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <osl/mutex.hxx> +#include <o3tl/string_view.hxx> #include <memory> #include <vector> @@ -93,11 +94,11 @@ namespace dbaui { virtual OUString SAL_CALL getImplementationName() override { - return "org.openoffice.comp.dbu.OViewDesign"; + return u"org.openoffice.comp.dbu.OViewDesign"_ustr; } virtual Sequence< OUString> SAL_CALL getSupportedServiceNames() override { - return { "com.sun.star.sdb.ViewDesign" }; + return { u"com.sun.star.sdb.ViewDesign"_ustr }; } public: @@ -120,7 +121,7 @@ namespace dbaui namespace { - OUString lcl_getObjectResourceString(const char* pResId, sal_Int32 _nCommandType) + OUString lcl_getObjectResourceString(TranslateId pResId, sal_Int32 _nCommandType) { OUString sMessageText = DBA_RES(pResId); OUString sObjectType = DBA_RES(RSC_QUERY_OBJECT_TYPE[_nCommandType]); @@ -129,13 +130,11 @@ namespace dbaui } } -using namespace ::com::sun::star::io; using namespace ::com::sun::star::container; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::ui; -using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::awt; using namespace ::dbtools; @@ -150,8 +149,8 @@ namespace return; xLayoutManager->lock(); - static const char s_sDesignToolbar[] = "private:resource/toolbar/designobjectbar"; - static const char s_sSqlToolbar[] = "private:resource/toolbar/sqlobjectbar"; + static constexpr OUString s_sDesignToolbar = u"private:resource/toolbar/designobjectbar"_ustr; + static constexpr OUString s_sSqlToolbar = u"private:resource/toolbar/sqlobjectbar"_ustr; if ( _bDesign ) { xLayoutManager->destroyElement( s_sSqlToolbar ); @@ -174,7 +173,7 @@ namespace void grabFocusFromLimitBox( OQueryController& _rController ) { Reference< XLayoutManager > xLayoutManager = OGenericUnoController::getLayoutManager( _rController.getFrame() ); - Reference< XUIElement > xUIElement = xLayoutManager->getElement("private:resource/toolbar/designobjectbar"); + Reference< XUIElement > xUIElement = xLayoutManager->getElement(u"private:resource/toolbar/designobjectbar"_ustr); if (xUIElement.is()) { Reference< XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY); @@ -189,12 +188,12 @@ namespace OUString SAL_CALL OQueryController::getImplementationName() { - return "org.openoffice.comp.dbu.OQueryDesign"; + return u"org.openoffice.comp.dbu.OQueryDesign"_ustr; } Sequence< OUString> SAL_CALL OQueryController::getSupportedServiceNames() { - return { "com.sun.star.sdb.QueryDesign" }; + return { u"com.sun.star.sdb.QueryDesign"_ustr }; } OQueryController::OQueryController(const Reference< XComponentContext >& _rM) @@ -245,18 +244,18 @@ void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i case PROPERTY_ID_CURRENT_QUERY_DESIGN: { ::comphelper::NamedValueCollection aCurrentDesign; - aCurrentDesign.put( "GraphicalDesign", isGraphicalDesign() ); - aCurrentDesign.put( OUString(PROPERTY_ESCAPE_PROCESSING), m_bEscapeProcessing ); + aCurrentDesign.put( u"GraphicalDesign"_ustr, isGraphicalDesign() ); + aCurrentDesign.put( PROPERTY_ESCAPE_PROCESSING, m_bEscapeProcessing ); if ( isGraphicalDesign() ) { getContainer()->SaveUIConfig(); saveViewSettings( aCurrentDesign, true ); - aCurrentDesign.put( "Statement", m_sStatement ); + aCurrentDesign.put( u"Statement"_ustr, m_sStatement ); } else { - aCurrentDesign.put( "Statement", getContainer()->getStatement() ); + aCurrentDesign.put( u"Statement"_ustr, getContainer()->getStatement() ); } o_rValue <<= aCurrentDesign.getPropertyValues(); @@ -282,16 +281,17 @@ void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i // one additional property: const sal_Int32 nLength = aProps.getLength(); aProps.realloc( nLength + 1 ); - aProps[ nLength ] = Property( - "CurrentQueryDesign", + auto pProps = aProps.getArray(); + pProps[ nLength ] = Property( + u"CurrentQueryDesign"_ustr, PROPERTY_ID_CURRENT_QUERY_DESIGN, ::cppu::UnoType< Sequence< PropertyValue > >::get(), PropertyAttribute::READONLY ); std::sort( - aProps.begin(), - aProps.end(), + pProps, + pProps + aProps.getLength(), ::comphelper::PropertyCompareByName() ); @@ -463,7 +463,6 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& SQLExceptionInfo aError; try { - OUString aErrorMsg; setStatement_fireEvent( getContainer()->getStatement() ); if(m_sStatement.isEmpty() && m_pSqlIterator) { @@ -475,9 +474,11 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& } else { + OUString aErrorMsg; std::unique_ptr<::connectivity::OSQLParseNode> pNode = m_aSqlParser.parseTree(aErrorMsg,m_sStatement,m_bGraphicalDesign); if ( pNode ) { + assert(m_pSqlIterator && "SqlIterator must exist"); delete m_pSqlIterator->getParseTree(); m_pSqlIterator->setParseTree(pNode.release()); m_pSqlIterator->traverseAll(); @@ -494,7 +495,7 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aError = SQLException( DBA_RES(STR_QRY_NOSELECT), nullptr, - "S1000", + u"S1000"_ustr, 1000, Any() ); @@ -517,7 +518,7 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aError = SQLException( DBA_RES(STR_QRY_SYNTAX), nullptr, - "S1000", + u"S1000"_ustr, 1000, Any() ); @@ -611,11 +612,9 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& void OQueryController::impl_showAutoSQLViewError( const css::uno::Any& _rErrorDetails ) { - SQLContext aErrorContext; - aErrorContext.Message = lcl_getObjectResourceString( STR_ERROR_PARSING_STATEMENT, m_nCommandType ); - aErrorContext.Context = *this; - aErrorContext.Details = lcl_getObjectResourceString( STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType ); - aErrorContext.NextException = _rErrorDetails; + SQLContext aErrorContext( + lcl_getObjectResourceString(STR_ERROR_PARSING_STATEMENT, m_nCommandType), *this, {}, 0, + _rErrorDetails, lcl_getObjectResourceString(STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType)); showError( aErrorContext ); } @@ -635,7 +634,7 @@ void OQueryController::impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInf // don't pass &aError here, this would overwrite the error which the first switchView call // returned in this location. if ( _pErrorInfo ) - *_pErrorInfo = aError; + *_pErrorInfo = std::move(aError); else showError( aError ); } @@ -647,11 +646,9 @@ void OQueryController::impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInf setModified( wasModified ); } -void OQueryController::impl_initialize() +void OQueryController::impl_initialize(const ::comphelper::NamedValueCollection& rArguments) { - OJoinController::impl_initialize(); - - const NamedValueCollection& rArguments( getInitParams() ); + OJoinController::impl_initialize(rArguments); OUString sCommand; m_nCommandType = CommandType::QUERY; @@ -660,7 +657,7 @@ void OQueryController::impl_initialize() // legacy parameters first (later overwritten by regular parameters) OUString sIndependentSQLCommand; - if ( rArguments.get_ensureType( "IndependentSQLCommand", sIndependentSQLCommand ) ) + if ( rArguments.get_ensureType( u"IndependentSQLCommand"_ustr, sIndependentSQLCommand ) ) { OSL_FAIL( "OQueryController::impl_initialize: IndependentSQLCommand is regognized for compatibility only!" ); sCommand = sIndependentSQLCommand; @@ -668,7 +665,7 @@ void OQueryController::impl_initialize() } OUString sCurrentQuery; - if ( rArguments.get_ensureType( "CurrentQuery", sCurrentQuery ) ) + if ( rArguments.get_ensureType( u"CurrentQuery"_ustr, sCurrentQuery ) ) { OSL_FAIL( "OQueryController::impl_initialize: CurrentQuery is regognized for compatibility only!" ); sCommand = sCurrentQuery; @@ -676,7 +673,7 @@ void OQueryController::impl_initialize() } bool bCreateView( false ); - if ( rArguments.get_ensureType( "CreateView", bCreateView ) && bCreateView ) + if ( rArguments.get_ensureType( u"CreateView"_ustr, bCreateView ) && bCreateView ) { OSL_FAIL( "OQueryController::impl_initialize: CurrentQuery is regognized for compatibility only!" ); m_nCommandType = CommandType::TABLE; @@ -692,8 +689,6 @@ void OQueryController::impl_initialize() switch ( m_nCommandType ) { case CommandType::QUERY: - m_sName = sCommand; - break; case CommandType::TABLE: m_sName = sCommand; break; @@ -730,24 +725,24 @@ void OQueryController::impl_initialize() // initial design bool bForceInitialDesign = false; Sequence< PropertyValue > aCurrentQueryDesignProps; - aCurrentQueryDesignProps = rArguments.getOrDefault( "CurrentQueryDesign", aCurrentQueryDesignProps ); + aCurrentQueryDesignProps = rArguments.getOrDefault( u"CurrentQueryDesign"_ustr, aCurrentQueryDesignProps ); if ( aCurrentQueryDesignProps.hasElements() ) { ::comphelper::NamedValueCollection aCurrentQueryDesign( aCurrentQueryDesignProps ); - if ( aCurrentQueryDesign.has( OUString(PROPERTY_GRAPHICAL_DESIGN) ) ) + if ( aCurrentQueryDesign.has( PROPERTY_GRAPHICAL_DESIGN ) ) { aCurrentQueryDesign.get_ensureType( PROPERTY_GRAPHICAL_DESIGN, m_bGraphicalDesign ); } - if ( aCurrentQueryDesign.has( OUString(PROPERTY_ESCAPE_PROCESSING) ) ) + if ( aCurrentQueryDesign.has( PROPERTY_ESCAPE_PROCESSING ) ) { aCurrentQueryDesign.get_ensureType( PROPERTY_ESCAPE_PROCESSING, m_bEscapeProcessing ); } - if ( aCurrentQueryDesign.has( "Statement" ) ) + if ( aCurrentQueryDesign.has( u"Statement"_ustr ) ) { OUString sStatement; - aCurrentQueryDesign.get_ensureType( "Statement", sStatement ); - aCurrentQueryDesign.remove( "Statement" ); + aCurrentQueryDesign.get_ensureType( u"Statement"_ustr, sStatement ); + aCurrentQueryDesign.remove( u"Statement"_ustr ); setStatement_fireEvent( sStatement ); } @@ -874,7 +869,7 @@ OUString OQueryController::getPrivateTitle( ) const SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( getMutex() ); OUString aDefaultName = DBA_RES(editingView() ? STR_VIEW_TITLE : STR_QRY_TITLE); - return aDefaultName.getToken(0, ' ') + OUString::number(getCurrentStartNumber()); + return o3tl::getToken(aDefaultName, 0, ' ') + OUString::number(getCurrentStartNumber()); } } return m_sName; @@ -922,23 +917,23 @@ OJoinDesignView* OQueryController::getJoinView() void OQueryController::describeSupportedFeatures() { OJoinController::describeSupportedFeatures(); - implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:SbaNativeSql", ID_BROWSER_ESCAPEPROCESSING,CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:DBViewFunctions", SID_QUERY_VIEW_FUNCTIONS, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBViewTableNames", SID_QUERY_VIEW_TABLES, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBViewAliases", SID_QUERY_VIEW_ALIASES, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBDistinctValues", SID_QUERY_DISTINCT_VALUES, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:DBChangeDesignMode",ID_BROWSER_SQL, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBClearQuery", SID_BROWSER_CLEAR_QUERY, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:SbaExecuteSql", ID_BROWSER_QUERY_EXECUTE, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBAddRelation", SID_RELATION_ADD_RELATION, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBQueryPreview", SID_DB_QUERY_PREVIEW, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBLimit", SID_QUERY_LIMIT, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:DBQueryPropertiesDialog", SID_QUERY_PROP_DLG, CommandGroup::FORMAT ); + implDescribeSupportedFeature( u".uno:SaveAs"_ustr, ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:SbaNativeSql"_ustr, ID_BROWSER_ESCAPEPROCESSING,CommandGroup::FORMAT ); + implDescribeSupportedFeature( u".uno:DBViewFunctions"_ustr, SID_QUERY_VIEW_FUNCTIONS, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBViewTableNames"_ustr, SID_QUERY_VIEW_TABLES, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBViewAliases"_ustr, SID_QUERY_VIEW_ALIASES, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBDistinctValues"_ustr, SID_QUERY_DISTINCT_VALUES, CommandGroup::FORMAT ); + implDescribeSupportedFeature( u".uno:DBChangeDesignMode"_ustr,ID_BROWSER_SQL, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBClearQuery"_ustr, SID_BROWSER_CLEAR_QUERY, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:SbaExecuteSql"_ustr, ID_BROWSER_QUERY_EXECUTE, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBAddRelation"_ustr, SID_RELATION_ADD_RELATION, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBQueryPreview"_ustr, SID_DB_QUERY_PREVIEW, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBLimit"_ustr, SID_QUERY_LIMIT, CommandGroup::FORMAT ); + implDescribeSupportedFeature( u".uno:DBQueryPropertiesDialog"_ustr, SID_QUERY_PROP_DLG, CommandGroup::FORMAT ); #if OSL_DEBUG_LEVEL > 0 - implDescribeSupportedFeature( ".uno:DBShowParseTree", ID_EDIT_QUERY_SQL ); - implDescribeSupportedFeature( ".uno:DBMakeDisjunct", ID_EDIT_QUERY_DESIGN ); + implDescribeSupportedFeature( u".uno:DBShowParseTree"_ustr, ID_EDIT_QUERY_SQL ); + implDescribeSupportedFeature( u".uno:DBMakeDisjunct"_ustr, ID_EDIT_QUERY_DESIGN ); #endif } @@ -1013,18 +1008,18 @@ void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_r ++i; } - o_rViewSettings.put( "Fields", aAllFieldsData.getPropertyValues() ); - o_rViewSettings.put( "SplitterPosition", m_nSplitPos ); - o_rViewSettings.put( "VisibleRows", m_nVisibleRows ); + o_rViewSettings.put( u"Fields"_ustr, aAllFieldsData.getPropertyValues() ); + o_rViewSettings.put( u"SplitterPosition"_ustr, m_nSplitPos ); + o_rViewSettings.put( u"VisibleRows"_ustr, m_nVisibleRows ); } void OQueryController::loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings ) { loadTableWindows( o_rViewSettings ); - m_nSplitPos = o_rViewSettings.getOrDefault( "SplitterPosition", m_nSplitPos ); - m_nVisibleRows = o_rViewSettings.getOrDefault( "VisibleRows", m_nVisibleRows ); - m_aFieldInformation = o_rViewSettings.getOrDefault( "Fields", m_aFieldInformation ); + m_nSplitPos = o_rViewSettings.getOrDefault( u"SplitterPosition"_ustr, m_nSplitPos ); + m_nVisibleRows = o_rViewSettings.getOrDefault( u"VisibleRows"_ustr, m_nVisibleRows ); + m_aFieldInformation = o_rViewSettings.getOrDefault( u"Fields"_ustr, m_aFieldInformation ); } void OQueryController::execute_QueryPropDlg() @@ -1114,15 +1109,15 @@ void OQueryController::executeQuery() { auto aProps(::comphelper::InitPropertySequence( { - { PROPERTY_DATASOURCENAME, makeAny(sDataSourceName) }, - { PROPERTY_COMMAND_TYPE, makeAny(CommandType::COMMAND) }, - { PROPERTY_COMMAND, makeAny(sTranslatedStmt) }, - { PROPERTY_ENABLE_BROWSER, makeAny(false) }, - { PROPERTY_ACTIVE_CONNECTION, makeAny(getConnection()) }, - { PROPERTY_UPDATE_CATALOGNAME, makeAny(m_sUpdateCatalogName) }, - { PROPERTY_UPDATE_SCHEMANAME, makeAny(m_sUpdateSchemaName) }, - { PROPERTY_UPDATE_TABLENAME, makeAny(OUString()) }, - { PROPERTY_ESCAPE_PROCESSING, makeAny(m_bEscapeProcessing) } + { PROPERTY_DATASOURCENAME, Any(sDataSourceName) }, + { PROPERTY_COMMAND_TYPE, Any(CommandType::COMMAND) }, + { PROPERTY_COMMAND, Any(sTranslatedStmt) }, + { PROPERTY_ENABLE_BROWSER, Any(false) }, + { PROPERTY_ACTIVE_CONNECTION, Any(getConnection()) }, + { PROPERTY_UPDATE_CATALOGNAME, Any(m_sUpdateCatalogName) }, + { PROPERTY_UPDATE_SCHEMANAME, Any(m_sUpdateSchemaName) }, + { PROPERTY_UPDATE_TABLENAME, Any(OUString()) }, + { PROPERTY_ESCAPE_PROCESSING, Any(m_bEscapeProcessing) } })); xDisp->dispatch(aWantToDispatch, aProps); @@ -1262,7 +1257,7 @@ bool OQueryController::doSaveAsDoc(bool _bSaveAs) { xQuery = xFact->createDataDescriptor(); // to set the name is only allowed when the query is new - xQuery->setPropertyValue( PROPERTY_NAME, makeAny( m_sName ) ); + xQuery->setPropertyValue( PROPERTY_NAME, Any( m_sName ) ); } else { @@ -1287,18 +1282,18 @@ bool OQueryController::doSaveAsDoc(bool _bSaveAs) } else { // we're creating a query, or a *new* view - xQuery->setPropertyValue( PROPERTY_COMMAND, makeAny( sTranslatedStmt ) ); + xQuery->setPropertyValue( PROPERTY_COMMAND, Any( sTranslatedStmt ) ); if ( editingView() ) { - xQuery->setPropertyValue( PROPERTY_CATALOGNAME, makeAny( m_sUpdateCatalogName ) ); - xQuery->setPropertyValue( PROPERTY_SCHEMANAME, makeAny( m_sUpdateSchemaName ) ); + xQuery->setPropertyValue( PROPERTY_CATALOGNAME, Any( m_sUpdateCatalogName ) ); + xQuery->setPropertyValue( PROPERTY_SCHEMANAME, Any( m_sUpdateSchemaName ) ); } if ( editingQuery() ) { - xQuery->setPropertyValue( PROPERTY_UPDATE_TABLENAME, makeAny( OUString() ) ); - xQuery->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, css::uno::makeAny( m_bEscapeProcessing ) ); + xQuery->setPropertyValue( PROPERTY_UPDATE_TABLENAME, Any( OUString() ) ); + xQuery->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, css::uno::Any( m_bEscapeProcessing ) ); xQuery->setPropertyValue( PROPERTY_LAYOUTINFORMATION, getViewData() ); } @@ -1315,7 +1310,7 @@ bool OQueryController::doSaveAsDoc(bool _bSaveAs) { Reference< XNameContainer > xCont( xElements, UNO_QUERY ); if ( xCont.is() ) - xCont->insertByName( m_sName, makeAny( xQuery ) ); + xCont->insertByName( m_sName, Any( xQuery ) ); } if ( editingView() ) @@ -1380,8 +1375,8 @@ struct CommentStrip { OUString maComment; bool mbLastOnLine; - CommentStrip( const OUString& rComment, bool bLastOnLine ) - : maComment( rComment), mbLastOnLine( bLastOnLine) {} + CommentStrip( OUString sComment, bool bLastOnLine ) + : maComment(std::move( sComment)), mbLastOnLine( bLastOnLine) {} }; } @@ -1550,7 +1545,7 @@ OUString OQueryController::translateStatement( bool _bFireStatementChange ) } else if(m_sStatement.isEmpty()) { - showError(SQLException(DBA_RES(STR_QRY_NOSELECT), nullptr, "S1000", 1000, Any())); + showError(SQLException(DBA_RES(STR_QRY_NOSELECT), nullptr, u"S1000"_ustr, 1000, Any())); } else sTranslatedStmt = m_sStatement; @@ -1680,7 +1675,7 @@ void OQueryController::impl_reset( const bool i_bForceCurrentControllerSettings { if ( !i_bForceCurrentControllerSettings && m_bGraphicalDesign && !editingView() ) { - impl_showAutoSQLViewError( makeAny( m_pSqlIterator->getErrors() ) ); + impl_showAutoSQLViewError( Any( m_pSqlIterator->getErrors() ) ); } bError = true; } @@ -1711,7 +1706,7 @@ void OQueryController::impl_reset( const bool i_bForceCurrentControllerSettings setQueryComposer(); OSL_ENSURE(m_pSqlIterator,"No SQLIterator set!"); - getContainer()->setNoneVisbleRow(m_nVisibleRows); + getContainer()->setNoneVisibleRow(m_nVisibleRows); } void OQueryController::reset() @@ -1723,9 +1718,9 @@ void OQueryController::reset() void OQueryController::setStatement_fireEvent( const OUString& _rNewStatement, bool _bFireStatementChange ) { - Any aOldValue = makeAny( m_sStatement ); + Any aOldValue( m_sStatement ); m_sStatement = _rNewStatement; - Any aNewValue = makeAny( m_sStatement ); + Any aNewValue( m_sStatement ); sal_Int32 nHandle = PROPERTY_ID_ACTIVECOMMAND; if ( _bFireStatementChange ) @@ -1737,9 +1732,9 @@ void OQueryController::setEscapeProcessing_fireEvent( const bool _bEscapeProcess if ( _bEscapeProcessing == m_bEscapeProcessing ) return; - Any aOldValue = makeAny( m_bEscapeProcessing ); + Any aOldValue( m_bEscapeProcessing ); m_bEscapeProcessing = _bEscapeProcessing; - Any aNewValue = makeAny( m_bEscapeProcessing ); + Any aNewValue( m_bEscapeProcessing ); sal_Int32 nHandle = PROPERTY_ID_ESCAPE_PROCESSING; fire( &nHandle, &aNewValue, &aOldValue, 1, false ); @@ -1761,9 +1756,7 @@ bool OQueryController::allowQueries() const if ( !getSdbMetaData().supportsSubqueriesInFrom() ) return false; - const NamedValueCollection& rArguments( getInitParams() ); - sal_Int32 nCommandType = rArguments.getOrDefault( PROPERTY_COMMAND_TYPE, sal_Int32(CommandType::QUERY) ); - bool bCreatingView = ( nCommandType == CommandType::TABLE ); + bool bCreatingView = ( m_nCommandType == CommandType::TABLE ); return !bCreatingView; } @@ -1776,7 +1769,7 @@ Any SAL_CALL OQueryController::getViewData() ::comphelper::NamedValueCollection aViewSettings; saveViewSettings( aViewSettings, false ); - return makeAny( aViewSettings.getPropertyValues() ); + return Any( aViewSettings.getPropertyValues() ); } void SAL_CALL OQueryController::restoreViewData(const Any& /*Data*/) diff --git a/dbaccess/source/ui/querydesign/querydlg.cxx b/dbaccess/source/ui/querydesign/querydlg.cxx index 422eeb9354fc..5eb7bc96319f 100644 --- a/dbaccess/source/ui/querydesign/querydlg.cxx +++ b/dbaccess/source/ui/querydesign/querydlg.cxx @@ -21,7 +21,7 @@ #include <JoinController.hxx> #include <JoinDesignView.hxx> #include <strings.hrc> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include "QTableConnectionData.hxx" #include <core_resource.hxx> #include <QueryTableView.hxx> @@ -45,14 +45,14 @@ DlgQryJoin::DlgQryJoin(const OQueryTableView* pParent, const OJoinTableView::OTableWindowMap* _pTableMap, const Reference< XConnection >& _xConnection, bool _bAllowTableSelect) - : GenericDialogController(pParent->GetFrameWeld(), "dbaccess/ui/joindialog.ui", "JoinDialog") + : GenericDialogController(pParent->GetFrameWeld(), u"dbaccess/ui/joindialog.ui"_ustr, u"JoinDialog"_ustr) , eJoinType(static_cast<OQueryTableConnectionData*>(_pData.get())->GetJoinType()) , m_pOrigConnData(_pData) , m_xConnection(_xConnection) - , m_xML_HelpText(m_xBuilder->weld_label("helptext")) - , m_xPB_OK(m_xBuilder->weld_button("ok")) - , m_xLB_JoinType(m_xBuilder->weld_combo_box("type")) - , m_xCBNatural(m_xBuilder->weld_check_button("natural")) + , m_xML_HelpText(m_xBuilder->weld_label(u"helptext"_ustr)) + , m_xPB_OK(m_xBuilder->weld_button(u"ok"_ustr)) + , m_xLB_JoinType(m_xBuilder->weld_combo_box(u"type"_ustr)) + , m_xCBNatural(m_xBuilder->weld_check_button(u"natural"_ustr)) { Size aSize(m_xML_HelpText->get_approximate_digit_width() * 44, m_xML_HelpText->get_text_height() * 6); @@ -150,7 +150,7 @@ IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, weld::ComboBox&, void ) OUString sFirstWinName = m_pConnData->getReferencingTable()->GetWinName(); OUString sSecondWinName = m_pConnData->getReferencedTable()->GetWinName(); const EJoinType eOldJoinType = eJoinType; - const char* pResId = nullptr; + TranslateId pResId; const sal_Int32 nPos = m_xLB_JoinType->get_active(); const sal_Int32 nJoinType = m_xLB_JoinType->get_id(nPos).toInt32(); bool bAddHint = true; @@ -167,13 +167,9 @@ IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, weld::ComboBox&, void ) eJoinType = LEFT_JOIN; break; case ID_RIGHT_JOIN: - { - pResId = STR_QUERY_LEFTRIGHT_JOIN; - eJoinType = RIGHT_JOIN; - OUString sTemp = sFirstWinName; - sFirstWinName = sSecondWinName; - sSecondWinName = sTemp; - } + pResId = STR_QUERY_LEFTRIGHT_JOIN; + eJoinType = RIGHT_JOIN; + std::swap( sFirstWinName, sSecondWinName ); break; case ID_FULL_JOIN: pResId = STR_QUERY_FULL_JOIN; @@ -188,7 +184,7 @@ IMPL_LINK_NOARG( DlgQryJoin, LBChangeHdl, weld::ComboBox&, void ) m_xTableControl->lateInit(); m_xCBNatural->set_active(false); m_xTableControl->enableRelation(false); - m_pConnData->AppendConnLine("",""); + m_pConnData->AppendConnLine(u""_ustr,u""_ustr); m_xPB_OK->set_sensitive(true); } break; @@ -230,7 +226,7 @@ IMPL_LINK_NOARG(DlgQryJoin, OKClickHdl, weld::Button&, void) m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG(DlgQryJoin, NaturalToggleHdl, weld::ToggleButton&, void) +IMPL_LINK_NOARG(DlgQryJoin, NaturalToggleHdl, weld::Toggleable&, void) { bool bChecked = m_xCBNatural->get_active(); static_cast<OQueryTableConnectionData*>(m_pConnData.get())->setNatural(bChecked); @@ -242,13 +238,10 @@ IMPL_LINK_NOARG(DlgQryJoin, NaturalToggleHdl, weld::ToggleButton&, void) try { Reference<XNameAccess> xReferencedTableColumns(m_pConnData->getReferencedTable()->getColumns()); - Sequence< OUString> aSeq = m_pConnData->getReferencingTable()->getColumns()->getElementNames(); - const OUString* pIter = aSeq.getConstArray(); - const OUString* pEnd = pIter + aSeq.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& column : m_pConnData->getReferencingTable()->getColumns()->getElementNames()) { - if ( xReferencedTableColumns->hasByName(*pIter) ) - m_pConnData->AppendConnLine(*pIter,*pIter); + if (xReferencedTableColumns->hasByName(column)) + m_pConnData->AppendConnLine(column, column); } } catch( const Exception& ) diff --git a/dbaccess/source/ui/querydesign/querydlg.hxx b/dbaccess/source/ui/querydesign/querydlg.hxx index 4631d7fbe29f..3da416c6e927 100644 --- a/dbaccess/source/ui/querydesign/querydlg.hxx +++ b/dbaccess/source/ui/querydesign/querydlg.hxx @@ -16,8 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDLG_HXX -#define INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDLG_HXX +#pragma once #include <vcl/weld.hxx> @@ -47,7 +46,7 @@ namespace dbaui DECL_LINK(OKClickHdl, weld::Button&, void); DECL_LINK(LBChangeHdl, weld::ComboBox&, void); - DECL_LINK(NaturalToggleHdl, weld::ToggleButton&, void); + DECL_LINK(NaturalToggleHdl, weld::Toggleable&, void); /** setJoinType enables and set the new join type @param _eNewJoinType the new jointype @@ -73,7 +72,6 @@ namespace dbaui virtual void notifyConnectionChange() override; }; } -#endif // INCLUDED_DBACCESS_SOURCE_UI_QUERYDESIGN_QUERYDLG_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |