diff options
Diffstat (limited to 'dbaccess/source/ui/browser')
-rw-r--r-- | dbaccess/source/ui/browser/AsynchronousLink.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/brwctrlr.cxx | 174 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/brwview.cxx | 22 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dataview.cxx | 16 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbexchange.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbloader.cxx | 62 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dbtreemodel.hxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dsEntriesNoExp.cxx | 34 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/dsbrowserDnD.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/exsrcbrw.cxx | 15 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/formadapter.cxx | 50 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/genericcontroller.cxx | 194 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.cxx | 102 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbamultiplex.cxx | 78 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 371 |
15 files changed, 505 insertions, 648 deletions
diff --git a/dbaccess/source/ui/browser/AsynchronousLink.cxx b/dbaccess/source/ui/browser/AsynchronousLink.cxx index e4dcdb2f9eeb..538ea702c4ac 100644 --- a/dbaccess/source/ui/browser/AsynchronousLink.cxx +++ b/dbaccess/source/ui/browser/AsynchronousLink.cxx @@ -31,14 +31,14 @@ OAsynchronousLink::OAsynchronousLink(const Link<void*, void>& _rHandler) OAsynchronousLink::~OAsynchronousLink() { { - ::osl::MutexGuard aEventGuard(m_aEventSafety); + std::unique_lock aEventGuard(m_aEventSafety); if (m_nEventId) Application::RemoveUserEvent(m_nEventId); m_nEventId = nullptr; } { - ::osl::MutexGuard aDestructionGuard(m_aDestructionSafety); + std::unique_lock aDestructionGuard(m_aDestructionSafety); // this is just for the case we're deleted while another thread just handled the event : // if this other thread called our link while we were deleting the event here, the // link handler blocked. With leaving the above block it continued, but now we are prevented @@ -48,7 +48,7 @@ OAsynchronousLink::~OAsynchronousLink() void OAsynchronousLink::Call(void* _pArgument) { - ::osl::MutexGuard aEventGuard(m_aEventSafety); + std::unique_lock aEventGuard(m_aEventSafety); if (m_nEventId) Application::RemoveUserEvent(m_nEventId); m_nEventId = Application::PostUserEvent(LINK(this, OAsynchronousLink, OnAsyncCall), _pArgument); @@ -56,7 +56,7 @@ void OAsynchronousLink::Call(void* _pArgument) void OAsynchronousLink::CancelCall() { - ::osl::MutexGuard aEventGuard(m_aEventSafety); + std::unique_lock aEventGuard(m_aEventSafety); if (m_nEventId) Application::RemoveUserEvent(m_nEventId); m_nEventId = nullptr; @@ -65,9 +65,9 @@ void OAsynchronousLink::CancelCall() IMPL_LINK(OAsynchronousLink, OnAsyncCall, void*, _pArg, void) { { - ::osl::MutexGuard aDestructionGuard(m_aDestructionSafety); + std::unique_lock aDestructionGuard(m_aDestructionSafety); { - ::osl::MutexGuard aEventGuard(m_aEventSafety); + std::unique_lock aEventGuard(m_aEventSafety); if (!m_nEventId) // our destructor deleted the event just while we are waiting for m_aEventSafety // -> get outta here diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 65333da089f9..3a3927a2dfe7 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -68,7 +68,7 @@ #include <sal/log.hxx> #include <svx/fmsearch.hxx> #include <svx/svxdlg.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -396,12 +396,12 @@ void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setMode( const OUSt OUString SAL_CALL SbaXDataBrowserController::FormControllerImpl::getMode( ) { - return "DataMode"; + return u"DataMode"_ustr; } Sequence< OUString > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getSupportedModes( ) { - Sequence< OUString > aModes { "DataMode" }; + Sequence< OUString > aModes { u"DataMode"_ustr }; return aModes; } @@ -436,8 +436,8 @@ Sequence< Reference< css::awt::XControl > > SAL_CALL SbaXDataBrowserController:: { if (m_pOwner->getBrowserView()) { - Reference< css::awt::XControl > xGrid = m_pOwner->getBrowserView()->getGridControl(); - return Sequence< Reference< css::awt::XControl > >(&xGrid, 1); + rtl::Reference< SbaXGridControl > xGrid = m_pOwner->getBrowserView()->getGridControl(); + return { Reference< css::awt::XControl >(xGrid) }; } return Sequence< Reference< css::awt::XControl > >(); } @@ -509,7 +509,7 @@ SbaXDataBrowserController::SbaXDataBrowserController(const Reference< css::uno:: ,m_aAsyncDisplayError( LINK( this, SbaXDataBrowserController, OnAsyncDisplayError ) ) ,m_sStateSaveRecord(DBA_RES(RID_STR_SAVE_CURRENT_RECORD)) ,m_sStateUndoRecord(DBA_RES(RID_STR_UNDO_MODIFY_RECORD)) - ,m_sModuleIdentifier( OUString( "com.sun.star.sdb.DataSourceBrowser" ) ) + ,m_sModuleIdentifier( u"com.sun.star.sdb.DataSourceBrowser"_ustr ) ,m_nFormActionNestingLevel(0) ,m_bLoadCanceled( false ) ,m_bCannotSelectUnfiltered( true ) @@ -668,24 +668,24 @@ void SbaXDataBrowserController::initFormatter() void SbaXDataBrowserController::describeSupportedFeatures() { SbaXDataBrowserController_Base::describeSupportedFeatures(); - implDescribeSupportedFeature( ".uno:FormSlots/undoRecord", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:FormController/undoRecord", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:RecUndo", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:FormSlots/saveRecord", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:FormController/saveRecord", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:RecSave", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVERECORD, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:RecSearch", SID_FM_SEARCH, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:AutoFilter", SID_FM_AUTOFILTER, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:Refresh", SID_FM_REFRESH, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:OrderCrit", SID_FM_ORDERCRIT, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:RemoveFilterSort", SID_FM_REMOVE_FILTER_SORT,CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:FormFiltered", SID_FM_FORM_FILTERED, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:FilterCrit", SID_FM_FILTERCRIT, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN, CommandGroup::CONTROLS ); - implDescribeSupportedFeature( ".uno:FormSlots/deleteRecord", SID_FM_DELETEROWS, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:FormSlots/insertRecord", ID_BROWSER_INSERT_ROW, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:FormSlots/undoRecord"_ustr, ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:FormController/undoRecord"_ustr, ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:RecUndo"_ustr, ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:FormSlots/saveRecord"_ustr, ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:FormController/saveRecord"_ustr, ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:RecSave"_ustr, ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:Save"_ustr, ID_BROWSER_SAVERECORD, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:RecSearch"_ustr, SID_FM_SEARCH, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:AutoFilter"_ustr, SID_FM_AUTOFILTER, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:Refresh"_ustr, SID_FM_REFRESH, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:OrderCrit"_ustr, SID_FM_ORDERCRIT, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:RemoveFilterSort"_ustr, SID_FM_REMOVE_FILTER_SORT,CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:FormFiltered"_ustr, SID_FM_FORM_FILTERED, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:FilterCrit"_ustr, SID_FM_FILTERCRIT, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:Sortup"_ustr, ID_BROWSER_SORTUP, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:SortDown"_ustr, ID_BROWSER_SORTDOWN, CommandGroup::CONTROLS ); + implDescribeSupportedFeature( u".uno:FormSlots/deleteRecord"_ustr, SID_FM_DELETEROWS, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:FormSlots/insertRecord"_ustr, ID_BROWSER_INSERT_ROW, CommandGroup::INSERT ); } bool SbaXDataBrowserController::Construct(vcl::Window* pParent) @@ -712,14 +712,14 @@ bool SbaXDataBrowserController::Construct(vcl::Window* pParent) // we want to have a grid with a "flat" border Reference< XPropertySet > xGridSet(m_xGridModel, UNO_QUERY); if ( xGridSet.is() ) - xGridSet->setPropertyValue(PROPERTY_BORDER, makeAny(sal_Int16(2))); + xGridSet->setPropertyValue(PROPERTY_BORDER, Any(sal_Int16(2))); // marry them Reference< css::container::XNameContainer > xNameCont(m_xRowSet, UNO_QUERY); { OUString sText(DBA_RES(STR_DATASOURCE_GRIDCONTROL_NAME)); - xNameCont->insertByName(sText, makeAny(m_xGridModel)); + xNameCont->insertByName(sText, Any(m_xGridModel)); } // create the view @@ -816,14 +816,14 @@ void SbaXDataBrowserController::RemoveColumnListener(const Reference< XPropertyS Reference< XRowSet > SbaXDataBrowserController::CreateForm() { return Reference< XRowSet > ( - getORB()->getServiceManager()->createInstanceWithContext("com.sun.star.form.component.Form", getORB()), + getORB()->getServiceManager()->createInstanceWithContext(u"com.sun.star.form.component.Form"_ustr, getORB()), UNO_QUERY); } Reference< css::form::XFormComponent > SbaXDataBrowserController::CreateGridModel() { return Reference< css::form::XFormComponent > ( - getORB()->getServiceManager()->createInstanceWithContext("com.sun.star.form.component.GridControl", getORB()), + getORB()->getServiceManager()->createInstanceWithContext(u"com.sun.star.form.component.GridControl"_ustr, getORB()), UNO_QUERY); } @@ -868,14 +868,13 @@ void SbaXDataBrowserController::removeModelListeners(const Reference< XControlMo void SbaXDataBrowserController::addControlListeners(const Reference< css::awt::XControl > & _xGridControl) { // to ge the 'modified' for the current cell - Reference< XModifyBroadcaster > xBroadcaster(getBrowserView()->getGridControl(), UNO_QUERY); - if (xBroadcaster.is()) - xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this)); + rtl::Reference< SbaXGridControl > xGridControl(getBrowserView()->getGridControl() ); + if (xGridControl.is()) + xGridControl->addModifyListener(static_cast<XModifyListener*>(this)); // introduce ourself as dispatch provider for the grid - Reference< XDispatchProviderInterception > xInterception(getBrowserView()->getGridControl(), UNO_QUERY); - if (xInterception.is()) - xInterception->registerDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this)); + if (xGridControl.is()) + xGridControl->registerDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this)); // add as focus listener to the control (needed for the form controller functionality) Reference< XWindow > xWindow(_xGridControl, UNO_QUERY); @@ -902,9 +901,7 @@ void SAL_CALL SbaXDataBrowserController::focusGained(const FocusEvent& /*e*/) { // notify our activate listeners (registered on the form controller aggregate) EventObject aEvt(*this); - ::comphelper::OInterfaceIteratorHelper3 aIter(m_xFormControllerImpl->m_aActivateListeners); - while (aIter.hasMoreElements()) - aIter.next()->formActivated(aEvt); + m_xFormControllerImpl->m_aActivateListeners.notifyEach( &css::form::XFormControllerListener::formActivated, aEvt ); } void SAL_CALL SbaXDataBrowserController::focusLost(const FocusEvent& e) @@ -928,12 +925,10 @@ void SAL_CALL SbaXDataBrowserController::focusLost(const FocusEvent& e) // notify the listeners that the "form" we represent has been deactivated EventObject aEvt(*this); - ::comphelper::OInterfaceIteratorHelper3 aIter(m_xFormControllerImpl->m_aActivateListeners); - while (aIter.hasMoreElements()) - aIter.next()->formDeactivated(aEvt); + m_xFormControllerImpl->m_aActivateListeners.notifyEach( &css::form::XFormControllerListener::formDeactivated, aEvt ); // commit the changes of the grid control (as we're deactivated) - Reference< XBoundComponent > xCommitable(getBrowserView()->getGridControl(), UNO_QUERY); + rtl::Reference< SbaXGridControl > xCommitable(getBrowserView()->getGridControl()); if (xCommitable.is()) xCommitable->commit(); else @@ -987,7 +982,7 @@ void SbaXDataBrowserController::disposing(const EventObject& Source) if (getBrowserView()) { Reference< css::awt::XControl > xSourceControl(Source.Source, UNO_QUERY); - if (xSourceControl == getBrowserView()->getGridControl()) + if (xSourceControl == cppu::getXWeak(getBrowserView()->getGridControl().get())) removeControlListeners(getBrowserView()->getGridControl()); } @@ -1243,11 +1238,11 @@ void SbaXDataBrowserController::errorOccured(const css::sdb::SQLErrorEvent& aEve if ( m_nFormActionNestingLevel ) { OSL_ENSURE( !m_aCurrentError.isValid(), "SbaXDataBrowserController::errorOccurred: can handle one error per transaction only!" ); - m_aCurrentError = aInfo; + m_aCurrentError = std::move(aInfo); } else { - m_aCurrentError = aInfo; + m_aCurrentError = std::move(aInfo); m_aAsyncDisplayError.Call(); } } @@ -1261,7 +1256,6 @@ sal_Bool SbaXDataBrowserController::approveParameter(const css::form::DatabasePa return true; } - Reference< css::container::XIndexAccess > xParameters = aEvent.Parameters; SolarMutexGuard aSolarGuard; // default handling: instantiate an interaction handler and let it handle the parameter request @@ -1272,9 +1266,9 @@ sal_Bool SbaXDataBrowserController::approveParameter(const css::form::DatabasePa rtl::Reference<OInteractionAbort> pAbort = new OInteractionAbort; // the request ParametersRequest aRequest; - aRequest.Parameters = xParameters; + aRequest.Parameters = aEvent.Parameters; aRequest.Connection = getConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY)); - rtl::Reference<OInteractionRequest> pParamRequest = new OInteractionRequest(makeAny(aRequest)); + rtl::Reference<OInteractionRequest> pParamRequest = new OInteractionRequest(Any(aRequest)); // some knittings pParamRequest->addContinuation(pParamValues); pParamRequest->addContinuation(pAbort); @@ -1297,8 +1291,7 @@ sal_Bool SbaXDataBrowserController::approveParameter(const css::form::DatabasePa setLoadingCancelled(); return false; } - const PropertyValue* pFinalValues = aFinalValues.getConstArray(); - for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues) + for (sal_Int32 i = 0; i < aFinalValues.getLength(); ++i) { Reference< XPropertySet > xParam( aRequest.Parameters->getByIndex(i), css::uno::UNO_QUERY); @@ -1308,9 +1301,9 @@ sal_Bool SbaXDataBrowserController::approveParameter(const css::form::DatabasePa #ifdef DBG_UTIL OUString sName; xParam->getPropertyValue(PROPERTY_NAME) >>= sName; - OSL_ENSURE(sName == pFinalValues->Name, "SbaXDataBrowserController::approveParameter: suspicious value names!"); + OSL_ENSURE(sName == aFinalValues[i].Name, "SbaXDataBrowserController::approveParameter: suspicious value names!"); #endif - try { xParam->setPropertyValue(PROPERTY_VALUE, pFinalValues->Value); } + try { xParam->setPropertyValue(PROPERTY_VALUE, aFinalValues[i].Value); } catch(Exception&) { SAL_WARN("dbaccess.ui", "SbaXDataBrowserController::approveParameter: setting one of the properties failed!"); @@ -1391,7 +1384,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const try { Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW ); - OSL_VERIFY( xRowSetProps->getPropertyValue("AllowInserts") >>= bAllowInsertions ); + OSL_VERIFY( xRowSetProps->getPropertyValue(u"AllowInserts"_ustr) >>= bAllowInsertions ); } catch( const Exception& ) { @@ -1410,7 +1403,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const try { Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW ); - OSL_VERIFY( xRowSetProps->getPropertyValue("AllowDeletes") >>= bAllowDeletions ); + OSL_VERIFY( xRowSetProps->getPropertyValue(u"AllowDeletes"_ustr) >>= bAllowDeletions ); OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ROWCOUNT ) >>= nRowCount ); OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ISNEW ) >>= bInsertionRow ); } @@ -1527,9 +1520,9 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const break; // no datasource -> no edit mode sal_Int32 nDataSourcePrivileges = ::comphelper::getINT32(xDataSourceSet->getPropertyValue(PROPERTY_PRIVILEGES)); - bool bInsertAllowedAndPossible = ((nDataSourcePrivileges & css::sdbcx::Privilege::INSERT) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue("AllowInserts")); - bool bUpdateAllowedAndPossible = ((nDataSourcePrivileges & css::sdbcx::Privilege::UPDATE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue("AllowUpdates")); - bool bDeleteAllowedAndPossible = ((nDataSourcePrivileges & css::sdbcx::Privilege::DELETE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue("AllowDeletes")); + bool bInsertAllowedAndPossible = ((nDataSourcePrivileges & css::sdbcx::Privilege::INSERT) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(u"AllowInserts"_ustr)); + bool bUpdateAllowedAndPossible = ((nDataSourcePrivileges & css::sdbcx::Privilege::UPDATE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(u"AllowUpdates"_ustr)); + bool bDeleteAllowedAndPossible = ((nDataSourcePrivileges & css::sdbcx::Privilege::DELETE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(u"AllowDeletes"_ustr)); if (!bInsertAllowedAndPossible && !bUpdateAllowedAndPossible && !bDeleteAllowedAndPossible) break; // no insert/update/delete -> no edit mode @@ -1585,7 +1578,7 @@ void SbaXDataBrowserController::applyParserOrder(const OUString& _rOldOrder,cons bool bSuccess = false; try { - xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_xParser->getOrder())); + xFormSet->setPropertyValue(PROPERTY_ORDER, Any(_xParser->getOrder())); bSuccess = reloadForm(m_xLoadable); } catch(Exception&) @@ -1594,7 +1587,7 @@ void SbaXDataBrowserController::applyParserOrder(const OUString& _rOldOrder,cons if (!bSuccess) { - xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_rOldOrder)); + xFormSet->setPropertyValue(PROPERTY_ORDER, Any(_rOldOrder)); try { @@ -1627,8 +1620,8 @@ void SbaXDataBrowserController::applyParserFilter(const OUString& _rOldFilter, b try { FormErrorHelper aError(this); - xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_xParser->getFilter())); - xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_xParser->getHavingClause())); + xFormSet->setPropertyValue(PROPERTY_FILTER, Any(_xParser->getFilter())); + xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, Any(_xParser->getHavingClause())); xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, css::uno::Any(true)); bSuccess = reloadForm(m_xLoadable); @@ -1639,8 +1632,8 @@ void SbaXDataBrowserController::applyParserFilter(const OUString& _rOldFilter, b if (!bSuccess) { - xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_rOldFilter)); - xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_sOldHaving)); + xFormSet->setPropertyValue(PROPERTY_FILTER, Any(_rOldFilter)); + xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, Any(_sOldHaving)); xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, css::uno::Any(_bOldFilterApplied)); try @@ -1767,7 +1760,7 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(bool bFilter) void SbaXDataBrowserController::ExecuteSearch() { // calculate the control source of the active field - Reference< css::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY); + rtl::Reference< SbaXGridControl > xGrid(getBrowserView()->getGridControl()); OSL_ENSURE(xGrid.is(), "SbaXDataBrowserController::ExecuteSearch : the control should have a css::form::XGrid interface !"); Reference< css::form::XGridPeer > xGridPeer(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY); @@ -1791,9 +1784,9 @@ void SbaXDataBrowserController::ExecuteSearch() // prohibit the synchronization of the grid's display with the cursor's position Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY); OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::ExecuteSearch : no model set ?!"); - xModelSet->setPropertyValue("DisplayIsSynchron", css::uno::Any(false)); - xModelSet->setPropertyValue("AlwaysShowCursor", css::uno::Any(true)); - xModelSet->setPropertyValue("CursorColor", makeAny(COL_LIGHTRED)); + xModelSet->setPropertyValue(u"DisplayIsSynchron"_ustr, css::uno::Any(false)); + xModelSet->setPropertyValue(u"AlwaysShowCursor"_ustr, css::uno::Any(true)); + xModelSet->setPropertyValue(u"CursorColor"_ustr, Any(COL_LIGHTRED)); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); VclPtr<AbstractFmSearchDialog> pDialog; @@ -1807,9 +1800,9 @@ void SbaXDataBrowserController::ExecuteSearch() pDialog.disposeAndClear(); // restore the grid's normal operating state - xModelSet->setPropertyValue("DisplayIsSynchron", css::uno::Any(true)); - xModelSet->setPropertyValue("AlwaysShowCursor", css::uno::Any(false)); - xModelSet->setPropertyValue("CursorColor", Any()); + xModelSet->setPropertyValue(u"DisplayIsSynchron"_ustr, css::uno::Any(true)); + xModelSet->setPropertyValue(u"AlwaysShowCursor"_ustr, css::uno::Any(false)); + xModelSet->setPropertyValue(u"CursorColor"_ustr, Any()); } void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< PropertyValue >& _rArgs) @@ -1945,7 +1938,6 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property bool bParserSuccess = false; try { - bParserSuccess = false; xParser->setOrder(OUString()); xParser->appendOrderByColumn(xField, bSortUp); bParserSuccess = true; @@ -2083,9 +2075,9 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property Reference< XPropertySet > xSet(getRowSet(), UNO_QUERY); if ( xSet.is() ) { - xSet->setPropertyValue(PROPERTY_FILTER,makeAny(OUString())); - xSet->setPropertyValue(PROPERTY_HAVING_CLAUSE,makeAny(OUString())); - xSet->setPropertyValue(PROPERTY_ORDER,makeAny(OUString())); + xSet->setPropertyValue(PROPERTY_FILTER,Any(OUString())); + xSet->setPropertyValue(PROPERTY_HAVING_CLAUSE,Any(OUString())); + xSet->setPropertyValue(PROPERTY_ORDER,Any(OUString())); } try { @@ -2155,8 +2147,8 @@ bool SbaXDataBrowserController::SaveModified(bool bAskFor) { getBrowserView()->getVclControl()->GrabFocus(); - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "dbaccess/ui/savemodifieddialog.ui")); - std::unique_ptr<weld::MessageDialog> xQry(xBuilder->weld_message_dialog("SaveModifiedDialog")); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), u"dbaccess/ui/savemodifieddialog.ui"_ustr)); + std::unique_ptr<weld::MessageDialog> xQry(xBuilder->weld_message_dialog(u"SaveModifiedDialog"_ustr)); switch (xQry->run()) { case RET_NO: @@ -2203,16 +2195,12 @@ bool SbaXDataBrowserController::CommitCurrent() if (!getBrowserView()) return true; - Reference< css::awt::XControl > xActiveControl(getBrowserView()->getGridControl()); - Reference< css::form::XBoundControl > xLockingTest(xActiveControl, UNO_QUERY); + rtl::Reference< SbaXGridControl > xActiveControl(getBrowserView()->getGridControl()); + Reference< css::form::XBoundControl > xLockingTest(static_cast<cppu::OWeakObject*>(xActiveControl.get()), UNO_QUERY); bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock(); if (xActiveControl.is() && !bControlIsLocked) { - // At first check Control if it supports the IFace - Reference< css::form::XBoundComponent > xBoundControl(xActiveControl, UNO_QUERY); - if (!xBoundControl.is()) - xBoundControl.set(xActiveControl->getModel(), UNO_QUERY); - if (xBoundControl.is() && !xBoundControl->commit()) + if (!xActiveControl->commit()) return false; } return true; @@ -2284,7 +2272,7 @@ Reference< XPropertySet > SbaXDataBrowserController::getBoundField() const Reference< XPropertySet > xEmptyReturn; // get the current column from the grid - Reference< css::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY); + rtl::Reference< SbaXGridControl > xGrid(getBrowserView()->getGridControl()); if (!xGrid.is()) return xEmptyReturn; sal_uInt16 nViewPos = xGrid->getCurrentColumnPosition(); @@ -2304,7 +2292,7 @@ Reference< XPropertySet > SbaXDataBrowserController::getBoundField() const IMPL_LINK(SbaXDataBrowserController, OnSearchContextRequest, FmSearchContext&, rContext, sal_uInt32) { - Reference< css::container::XIndexAccess > xPeerContainer(getBrowserView()->getGridControl(), UNO_QUERY); + rtl::Reference< SbaXGridControl > xPeerContainer(getBrowserView()->getGridControl()); // check all grid columns for their control source Reference< css::container::XIndexAccess > xModelColumns(getFormComponent(), UNO_QUERY); @@ -2359,9 +2347,9 @@ IMPL_LINK(SbaXDataBrowserController, OnFoundData, FmFoundRecordInformation&, rIn // let the grid sync its display with the cursor Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY); OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::OnFoundData : no model set ?!"); - Any aOld = xModelSet->getPropertyValue("DisplayIsSynchron"); - xModelSet->setPropertyValue("DisplayIsSynchron", css::uno::Any(true)); - xModelSet->setPropertyValue("DisplayIsSynchron", aOld); + Any aOld = xModelSet->getPropertyValue(u"DisplayIsSynchron"_ustr); + xModelSet->setPropertyValue(u"DisplayIsSynchron"_ustr, css::uno::Any(true)); + xModelSet->setPropertyValue(u"DisplayIsSynchron"_ustr, aOld); // and move to the field Reference< css::container::XIndexAccess > aColumnControls(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY); @@ -2379,7 +2367,7 @@ IMPL_LINK(SbaXDataBrowserController, OnFoundData, FmFoundRecordInformation&, rIn } } - Reference< css::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY); + rtl::Reference< SbaXGridControl > xGrid(getBrowserView()->getGridControl()); xGrid->setCurrentColumnPosition(nViewPos); //TODO: sal_Int32 -> sal_Int16! } @@ -2403,9 +2391,9 @@ IMPL_LINK(SbaXDataBrowserController, OnCanceledNotFound, FmFoundRecordInformatio // let the grid sync its display with the cursor Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY); OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::OnCanceledNotFound : no model set ?!"); - Any aOld = xModelSet->getPropertyValue("DisplayIsSynchron"); - xModelSet->setPropertyValue("DisplayIsSynchron", css::uno::Any(true)); - xModelSet->setPropertyValue("DisplayIsSynchron", aOld); + Any aOld = xModelSet->getPropertyValue(u"DisplayIsSynchron"_ustr); + xModelSet->setPropertyValue(u"DisplayIsSynchron"_ustr, css::uno::Any(true)); + xModelSet->setPropertyValue(u"DisplayIsSynchron"_ustr, aOld); } catch( const Exception& ) { @@ -2564,7 +2552,7 @@ bool SbaXDataBrowserController::isValidCursor() const sal_Int16 SbaXDataBrowserController::getCurrentColumnPosition() const { - Reference< css::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY); + rtl::Reference< SbaXGridControl > xGrid(getBrowserView()->getGridControl()); sal_Int16 nViewPos = -1; try { @@ -2577,7 +2565,7 @@ sal_Int16 SbaXDataBrowserController::getCurrentColumnPosition() const void SbaXDataBrowserController::setCurrentColumnPosition( sal_Int16 _nPos ) { - Reference< css::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY); + rtl::Reference< SbaXGridControl > xGrid(getBrowserView()->getGridControl()); try { if ( -1 != _nPos ) diff --git a/dbaccess/source/ui/browser/brwview.cxx b/dbaccess/source/ui/browser/brwview.cxx index b68819d6740a..6a15ce0fca39 100644 --- a/dbaccess/source/ui/browser/brwview.cxx +++ b/dbaccess/source/ui/browser/brwview.cxx @@ -32,7 +32,6 @@ using namespace dbaui; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::form; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; @@ -44,7 +43,7 @@ namespace { bool bGrabFocus = false; SbaGridControl* pVclControl = _pView->getVclControl(); - const Reference< css::awt::XControl >& xGrid = _pView->getGridControl(); + const rtl::Reference< SbaXGridControl > xGrid = _pView->getGridControl(); if (pVclControl && xGrid.is()) { bGrabFocus = true; @@ -88,10 +87,8 @@ void UnoDataBrowserView::Construct(const Reference< css::awt::XControlModel >& x OSL_ENSURE(m_xGrid.is(), "UnoDataBrowserView::Construct : could not create a grid control !"); // in design mode (for the moment) m_xGrid->setDesignMode(true); - - Reference< css::awt::XWindow > xGridWindow(m_xGrid, UNO_QUERY); - xGridWindow->setVisible(true); - xGridWindow->setEnable(true); + m_xGrid->setVisible(true); + m_xGrid->setEnable(true); // introduce the model to the grid m_xGrid->setModel(xModel); @@ -129,8 +126,8 @@ void UnoDataBrowserView::dispose() } catch(const Exception&) {} - m_pTreeView.clear(); - m_pVclControl.clear(); + m_pTreeView.reset(); + m_pVclControl.reset(); ODataView::dispose(); } @@ -226,9 +223,8 @@ void UnoDataBrowserView::resizeDocumentView(tools::Rectangle& _rPlayground) } // set the size of grid control - Reference< css::awt::XWindow > xGridAsWindow(m_xGrid, UNO_QUERY); - if (xGridAsWindow.is()) - xGridAsWindow->setPosSize( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(), + if (m_xGrid.is()) + m_xGrid->setPosSize( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(), aPlaygroundSize.Width() - aSplitSize.Width() - aSplitPos.X(), aPlaygroundSize.Height(), css::awt::PosSize::POSSIZE); // just for completeness: there is no space left, we occupied it all ... @@ -251,7 +247,7 @@ SbaGridControl* UnoDataBrowserView::getVclControl() const Reference< css::awt::XWindowPeer > xPeer = m_xGrid->getPeer(); if ( xPeer.is() ) { - SbaXGridPeer* pPeer = comphelper::getFromUnoTunnel<SbaXGridPeer>(xPeer); + SbaXGridPeer* pPeer = dynamic_cast<SbaXGridPeer*>(xPeer.get()); UnoDataBrowserView* pTHIS = const_cast<UnoDataBrowserView*>(this); if ( pPeer ) { @@ -292,7 +288,7 @@ void UnoDataBrowserView::_disposing( const css::lang::EventObject& /*_rSource*/ bool UnoDataBrowserView::PreNotify( NotifyEvent& rNEvt ) { bool bDone = false; - if(rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) + if(rNEvt.GetType() == NotifyEventType::KEYINPUT) { bool bGrabAllowed = isGrabVclControlFocusAllowed(this); if ( bGrabAllowed ) diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx index 74ceea688ba1..11f9a91df015 100644 --- a/dbaccess/source/ui/browser/dataview.cxx +++ b/dbaccess/source/ui/browser/dataview.cxx @@ -23,16 +23,14 @@ #include <comphelper/namedvaluecollection.hxx> #include <dbaccess/IController.hxx> #include <svtools/acceleratorexecute.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/event.hxx> #include <vcl/settings.hxx> namespace dbaui { using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::beans; using namespace ::com::sun::star::util; - using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; ODataView::ODataView( vcl::Window* pParent, @@ -71,7 +69,7 @@ namespace dbaui // draw the background { rRenderContext.Push(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); - rRenderContext.SetLineColor(COL_TRANSPARENT); + rRenderContext.SetLineColor(); rRenderContext.SetFillColor(GetSettings().GetStyleSettings().GetFaceColor()); rRenderContext.DrawRect(_rRect); rRenderContext.Pop(); @@ -98,7 +96,7 @@ namespace dbaui bool bHandled = false; switch ( _rNEvt.GetType() ) { - case MouseNotifyEvent::KEYINPUT: + case NotifyEventType::KEYINPUT: { const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent(); const vcl::KeyCode& aKeyCode = pKeyEvent->GetKeyCode(); @@ -107,9 +105,9 @@ namespace dbaui return true; [[fallthrough]]; } - case MouseNotifyEvent::KEYUP: - case MouseNotifyEvent::MOUSEBUTTONDOWN: - case MouseNotifyEvent::MOUSEBUTTONUP: + case NotifyEventType::KEYUP: + case NotifyEventType::MOUSEBUTTONDOWN: + case NotifyEventType::MOUSEBUTTONUP: bHandled = m_xController->interceptUserInput( _rNEvt ); break; default: @@ -133,7 +131,7 @@ namespace dbaui if ( xModel.is() ) { ::comphelper::NamedValueCollection aArgs( xModel->getArgs() ); - aArgs.remove( "Hidden" ); + aArgs.remove( u"Hidden"_ustr ); xModel->attachResource( xModel->getURL(), aArgs.getPropertyValues() ); } } diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx index dc6398f48aea..dc318dc0f61c 100644 --- a/dbaccess/source/ui/browser/dbexchange.cxx +++ b/dbaccess/source/ui/browser/dbexchange.cxx @@ -140,14 +140,14 @@ namespace dbaui osl_atomic_decrement( &m_refCount ); } - bool ODataClipboard::WriteObject( ::tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& /*rFlavor*/ ) + bool ODataClipboard::WriteObject( SvStream& rOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& /*rFlavor*/ ) { if (nUserObjectId == FORMAT_OBJECT_ID_RTF || nUserObjectId == FORMAT_OBJECT_ID_HTML ) { ODatabaseImportExport* pExport = static_cast<ODatabaseImportExport*>(pUserObject); - if ( pExport && rxOStm.is() ) + if ( pExport ) { - pExport->setStream(rxOStm.get()); + pExport->setStream(&rOStm); return pExport->Write(); } } diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx index 3530bf7a6acd..ba4e206d446c 100644 --- a/dbaccess/source/ui/browser/dbloader.cxx +++ b/dbaccess/source/ui/browser/dbloader.cxx @@ -36,8 +36,9 @@ #include <comphelper/types.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/urlobj.hxx> +#include <unotools/fcm.hxx> #include <vcl/svapp.hxx> using namespace ::com::sun::star; @@ -91,7 +92,7 @@ org_openoffice_comp_dbu_DBContentLoader_get_implementation( // XServiceInfo OUString SAL_CALL DBContentLoader::getImplementationName() { - return "org.openoffice.comp.dbu.DBContentLoader"; + return u"org.openoffice.comp.dbu.DBContentLoader"_ustr; } // XServiceInfo @@ -103,7 +104,7 @@ sal_Bool SAL_CALL DBContentLoader::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > SAL_CALL DBContentLoader::getSupportedServiceNames() { - return { "com.sun.star.frame.FrameLoader", "com.sun.star.sdb.ContentLoader" }; + return { u"com.sun.star.frame.FrameLoader"_ustr, u"com.sun.star.sdb.ContentLoader"_ustr }; } void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OUString& rURL, @@ -113,22 +114,17 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU m_xListener = rListener; m_aArgs = rArgs; - static const struct ServiceNameToImplName + static constexpr struct ServiceNameToImplName { - const char* pAsciiServiceName; - const char* pAsciiImplementationName; - ServiceNameToImplName( const char* _pService, const char* _pImpl ) - :pAsciiServiceName( _pService ) - ,pAsciiImplementationName( _pImpl ) - { - } + OUString sServiceName; + OUString aAsciiImplementationName; } aImplementations[] = { - ServiceNameToImplName( URL_COMPONENT_FORMGRIDVIEW, "org.openoffice.comp.dbu.OFormGridView" ), - ServiceNameToImplName( URL_COMPONENT_DATASOURCEBROWSER, "org.openoffice.comp.dbu.ODatasourceBrowser" ), - ServiceNameToImplName( URL_COMPONENT_QUERYDESIGN, "org.openoffice.comp.dbu.OQueryDesign" ), - ServiceNameToImplName( URL_COMPONENT_TABLEDESIGN, "org.openoffice.comp.dbu.OTableDesign" ), - ServiceNameToImplName( URL_COMPONENT_RELATIONDESIGN, "org.openoffice.comp.dbu.ORelationDesign" ), - ServiceNameToImplName( URL_COMPONENT_VIEWDESIGN, "org.openoffice.comp.dbu.OViewDesign" ) + { URL_COMPONENT_FORMGRIDVIEW, u"org.openoffice.comp.dbu.OFormGridView"_ustr }, + { URL_COMPONENT_DATASOURCEBROWSER, u"org.openoffice.comp.dbu.ODatasourceBrowser"_ustr }, + { URL_COMPONENT_QUERYDESIGN, u"org.openoffice.comp.dbu.OQueryDesign"_ustr }, + { URL_COMPONENT_TABLEDESIGN, u"org.openoffice.comp.dbu.OTableDesign"_ustr }, + { URL_COMPONENT_RELATIONDESIGN, u"org.openoffice.comp.dbu.ORelationDesign"_ustr }, + { URL_COMPONENT_VIEWDESIGN, u"org.openoffice.comp.dbu.OViewDesign"_ustr } }; INetURLObject aParser( rURL ); @@ -137,10 +133,10 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU const OUString sComponentURL( aParser.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ) ); for (const ServiceNameToImplName& aImplementation : aImplementations) { - if ( sComponentURL.equalsAscii( aImplementation.pAsciiServiceName ) ) + if ( sComponentURL == aImplementation.sServiceName ) { xController.set( m_xContext->getServiceManager()-> - createInstanceWithContext( OUString::createFromAscii( aImplementation.pAsciiImplementationName ), m_xContext), UNO_QUERY_THROW ); + createInstanceWithContext( aImplementation.aAsciiImplementationName, m_xContext), UNO_QUERY_THROW ); break; } } @@ -152,7 +148,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU if ( sComponentURL == URL_COMPONENT_DATASOURCEBROWSER ) { - bool bDisableBrowser = !aLoadArgs.getOrDefault( "ShowTreeViewButton", true ) // compatibility name + bool bDisableBrowser = !aLoadArgs.getOrDefault( u"ShowTreeViewButton"_ustr, true ) // compatibility name || !aLoadArgs.getOrDefault( PROPERTY_ENABLE_BROWSER, true ); if ( bDisableBrowser ) @@ -160,7 +156,7 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU try { Reference< XModule > xModule( xController, UNO_QUERY_THROW ); - xModule->setIdentifier( "com.sun.star.sdb.TableDataView" ); + xModule->setIdentifier( u"com.sun.star.sdb.TableDataView"_ustr ); } catch( const Exception& ) { @@ -171,20 +167,18 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU if ( sComponentURL == URL_COMPONENT_REPORTDESIGN ) { - bool bPreview = aLoadArgs.getOrDefault( "Preview", false ); + bool bPreview = aLoadArgs.getOrDefault( u"Preview"_ustr, false ); if ( bPreview ) { // report designs cannot be previewed if ( rListener.is() ) rListener->loadCancelled( this ); return; } - Reference< XModel > xReportModel( aLoadArgs.getOrDefault( "Model", Reference< XModel >() ) ); + Reference< XModel > xReportModel( aLoadArgs.getOrDefault( u"Model"_ustr, Reference< XModel >() ) ); if ( xReportModel.is() ) { xController.set( ReportDesign::create( m_xContext ) ); - xController->attachModel( xReportModel ); - xReportModel->connectController( xController ); - xReportModel->setCurrentController( xController ); + utl::ConnectModelController(xReportModel, xController); } } @@ -192,9 +186,9 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU Reference< XModel > xDatabaseDocument; if ( bSuccess ) { - Reference< XDataSource > xDataSource ( aLoadArgs.getOrDefault( "DataSource", Reference< XDataSource >() ) ); - OUString sDataSourceName( aLoadArgs.getOrDefault( "DataSourceName", OUString() ) ); - Reference< XConnection > xConnection ( aLoadArgs.getOrDefault( "ActiveConnection", Reference< XConnection >() ) ); + Reference< XDataSource > xDataSource ( aLoadArgs.getOrDefault( u"DataSource"_ustr, Reference< XDataSource >() ) ); + OUString sDataSourceName( aLoadArgs.getOrDefault( u"DataSourceName"_ustr, OUString() ) ); + Reference< XConnection > xConnection ( aLoadArgs.getOrDefault( u"ActiveConnection"_ustr, Reference< XConnection >() ) ); if ( xDataSource.is() ) { xDatabaseDocument.set( getDataSourceOrModel( xDataSource ), UNO_QUERY ); @@ -221,17 +215,13 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const OU try { Reference<XInitialization > xIni(xController,UNO_QUERY); - PropertyValue aFrame("Frame",0,makeAny(rFrame),PropertyState_DIRECT_VALUE); + PropertyValue aFrame(u"Frame"_ustr,0,Any(rFrame),PropertyState_DIRECT_VALUE); Sequence< Any > aInitArgs(m_aArgs.getLength()+1); Any* pBegin = aInitArgs.getArray(); - Any* pEnd = pBegin + aInitArgs.getLength(); *pBegin <<= aFrame; - const PropertyValue* pIter = m_aArgs.getConstArray(); - for(++pBegin;pBegin != pEnd;++pBegin,++pIter) - { - *pBegin <<= *pIter; - } + std::transform(m_aArgs.begin(), m_aArgs.end(), ++pBegin, + [](auto& val) { return Any(val); }); xIni->initialize(aInitArgs); } diff --git a/dbaccess/source/ui/browser/dbtreemodel.hxx b/dbaccess/source/ui/browser/dbtreemodel.hxx index 2ea11b900975..55b1a3cffcc9 100644 --- a/dbaccess/source/ui/browser/dbtreemodel.hxx +++ b/dbaccess/source/ui/browser/dbtreemodel.hxx @@ -29,11 +29,6 @@ // tables holds the nameaccess for the tables // table holds the table -#define CONTAINER_QUERIES sal_uLong( 0 ) -#define CONTAINER_TABLES sal_uLong( 1 ) - -namespace com::sun::star::lang { class XMultiServiceFactory; } - namespace dbaui { struct DBTreeListUserData diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx index debc3fa51a67..f2c4dc949c64 100644 --- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx +++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx @@ -28,8 +28,6 @@ #include "dbtreemodel.hxx" using namespace ::com::sun::star::frame; -using namespace ::dbtools; -using namespace ::svx; namespace dbaui { @@ -56,7 +54,7 @@ OUString SbaTableQueryBrowser::GetEntryText(const weld::TreeIter& rEntry) const SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType(const weld::TreeIter& rEntry) const { const weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntry).toUInt64()); + DBTreeListUserData* pEntryData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(rEntry)); return pEntryData ? pEntryData->eType : etUnknown; } @@ -108,28 +106,28 @@ void SbaTableQueryBrowser::describeSupportedFeatures() { SbaXDataBrowserController::describeSupportedFeatures(); - implDescribeSupportedFeature( ".uno:Title", ID_BROWSER_TITLE ); + implDescribeSupportedFeature( u".uno:Title"_ustr, ID_BROWSER_TITLE ); if ( !m_bShowMenu ) { - implDescribeSupportedFeature( ".uno:DSBEditDB", ID_TREE_EDIT_DATABASE ); - implDescribeSupportedFeature( ".uno:DSBCloseConnection", ID_TREE_CLOSE_CONN ); - implDescribeSupportedFeature( ".uno:DSBAdministrate", ID_TREE_ADMINISTRATE ); + implDescribeSupportedFeature( u".uno:DSBEditDB"_ustr, ID_TREE_EDIT_DATABASE ); + implDescribeSupportedFeature( u".uno:DSBCloseConnection"_ustr, ID_TREE_CLOSE_CONN ); + implDescribeSupportedFeature( u".uno:DSBAdministrate"_ustr, ID_TREE_ADMINISTRATE ); - implDescribeSupportedFeature( ".uno:DSBrowserExplorer", ID_BROWSER_EXPLORER, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DSBrowserExplorer"_ustr, ID_BROWSER_EXPLORER, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DSBFormLetter", ID_BROWSER_FORMLETTER, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:DSBInsertColumns", ID_BROWSER_INSERTCOLUMNS, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DSBInsertContent", ID_BROWSER_INSERTCONTENT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DSBDocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DSBFormLetter"_ustr, ID_BROWSER_FORMLETTER, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:DSBInsertColumns"_ustr, ID_BROWSER_INSERTCOLUMNS, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DSBInsertContent"_ustr, ID_BROWSER_INSERTCONTENT, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DSBDocumentDataSource"_ustr, ID_BROWSER_DOCUMENT_DATASOURCE, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DataSourceBrowser/FormLetter", ID_BROWSER_FORMLETTER ); - implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertColumns", ID_BROWSER_INSERTCOLUMNS ); - implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertContent", ID_BROWSER_INSERTCONTENT ); - implDescribeSupportedFeature( ".uno:DataSourceBrowser/DocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE ); + implDescribeSupportedFeature( u".uno:DataSourceBrowser/FormLetter"_ustr, ID_BROWSER_FORMLETTER ); + implDescribeSupportedFeature( u".uno:DataSourceBrowser/InsertColumns"_ustr, ID_BROWSER_INSERTCOLUMNS ); + implDescribeSupportedFeature( u".uno:DataSourceBrowser/InsertContent"_ustr, ID_BROWSER_INSERTCONTENT ); + implDescribeSupportedFeature( u".uno:DataSourceBrowser/DocumentDataSource"_ustr, ID_BROWSER_DOCUMENT_DATASOURCE ); } - implDescribeSupportedFeature( ".uno:CloseWin", ID_BROWSER_CLOSE, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:DBRebuildData", ID_BROWSER_REFRESH_REBUILD, CommandGroup::DATA ); + implDescribeSupportedFeature( u".uno:CloseWin"_ustr, ID_BROWSER_CLOSE, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:DBRebuildData"_ustr, ID_BROWSER_REFRESH_REBUILD, CommandGroup::DATA ); } sal_Int32 SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType ) diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx index 7d51a5abf8fb..774f43b4c7a4 100644 --- a/dbaccess/source/ui/browser/dsbrowserDnD.cxx +++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx @@ -31,7 +31,7 @@ #include <connectivity/dbtools.hxx> #include <cppuhelper/exc_hlp.hxx> #include <svx/dataaccessdescriptor.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <vcl/svapp.hxx> @@ -43,16 +43,8 @@ namespace dbaui using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; - using namespace ::com::sun::star::sdbcx; - using namespace ::com::sun::star::beans; - using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::container; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::form; - using namespace ::com::sun::star::io; - using namespace ::com::sun::star::i18n; - using namespace ::com::sun::star::task; using namespace ::com::sun::star::datatransfer; using namespace ::dbtools; using namespace ::svx; @@ -232,7 +224,7 @@ namespace dbaui weld::TreeView& rTreeView = m_pTreeView->GetWidget(); rTreeView.all_foreach([this, &rTreeView](weld::TreeIter& rEntryLoop){ // clear the user data of the tree model - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntryLoop).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(rEntryLoop)); if (pData) { rTreeView.set_id(rEntryLoop, OUString()); diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx index 2b304f23e511..ffcf40e3c91d 100644 --- a/dbaccess/source/ui/browser/exsrcbrw.cxx +++ b/dbaccess/source/ui/browser/exsrcbrw.cxx @@ -25,11 +25,10 @@ #include <formadapter.hxx> #include <strings.hxx> #include <o3tl/any.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::beans; @@ -72,12 +71,12 @@ SbaExternalSourceBrowser::~SbaExternalSourceBrowser() css::uno::Sequence<OUString> SAL_CALL SbaExternalSourceBrowser::getSupportedServiceNames() { - return { "com.sun.star.sdb.FormGridView" }; + return { u"com.sun.star.sdb.FormGridView"_ustr }; } OUString SAL_CALL SbaExternalSourceBrowser::getImplementationName() { - return "org.openoffice.comp.dbu.OFormGridView"; + return u"org.openoffice.comp.dbu.OFormGridView"_ustr; } Reference< XRowSet > SbaExternalSourceBrowser::CreateForm() @@ -104,9 +103,7 @@ void SbaExternalSourceBrowser::modified(const css::lang::EventObject& aEvent) // multiplex this event to all my listeners css::lang::EventObject aEvt(*this); - ::comphelper::OInterfaceIteratorHelper3 aIt(m_aModifyListeners); - while (aIt.hasMoreElements()) - aIt.next()->modified(aEvt); + m_aModifyListeners.notifyEach( &css::util::XModifyListener::modified, aEvt ); } void SAL_CALL SbaExternalSourceBrowser::dispatch(const css::util::URL& aURL, const Sequence< css::beans::PropertyValue>& aArgs) @@ -160,7 +157,7 @@ void SAL_CALL SbaExternalSourceBrowser::dispatch(const css::util::URL& aURL, con // set its properties if (xNewColProperties.is()) { - for (const css::beans::PropertyValue& rControlProp : std::as_const(aControlProps)) + for (const css::beans::PropertyValue& rControlProp : aControlProps) { try { @@ -183,7 +180,7 @@ void SAL_CALL SbaExternalSourceBrowser::dispatch(const css::util::URL& aURL, con nControlPos = 0; // append the column - xColContainer->insertByIndex(nControlPos, makeAny(xNewCol)); + xColContainer->insertByIndex(nControlPos, Any(xNewCol)); } else if ( aURL.Complete == ".uno:FormSlots/ClearView" ) { diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx index 8dafddca1442..e0288c51dc38 100644 --- a/dbaccess/source/ui/browser/formadapter.cxx +++ b/dbaccess/source/ui/browser/formadapter.cxx @@ -224,7 +224,7 @@ void SbaXFormAdapter::StartListening() { Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); if (xBroadcaster.is()) - xBroadcaster->addPropertiesChangeListener(css::uno::Sequence<OUString>{""}, &m_aPropertiesChangeListeners); + xBroadcaster->addPropertiesChangeListener(css::uno::Sequence<OUString>{u""_ustr}, &m_aPropertiesChangeListeners); } // log off ourself @@ -249,9 +249,7 @@ void SbaXFormAdapter::AttachForm(const Reference< css::sdbc::XRowSet >& xNewMast if (xLoadable->isLoaded()) { css::lang::EventObject aEvt(*this); - ::comphelper::OInterfaceIteratorHelper3 aIt(m_aLoadListeners); - while (aIt.hasMoreElements()) - aIt.next()->unloaded(aEvt); + m_aLoadListeners.notifyEach( &css::form::XLoadListener::unloaded, aEvt ); } } @@ -267,9 +265,7 @@ void SbaXFormAdapter::AttachForm(const Reference< css::sdbc::XRowSet >& xNewMast if (xLoadable->isLoaded()) { css::lang::EventObject aEvt(*this); - ::comphelper::OInterfaceIteratorHelper3 aIt(m_aLoadListeners); - while (aIt.hasMoreElements()) - aIt.next()->loaded(aEvt); + m_aLoadListeners.notifyEach( &css::form::XLoadListener::loaded, aEvt ); } // TODO : perhaps _all_ of our listeners should be notified about our new state @@ -301,8 +297,6 @@ sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const OUString& columnName) return xIface->findColumn(columnName); ::dbtools::throwInvalidColumnException( columnName, *this ); - assert(false); - return 0; // Never reached } // css::sdbcx::XColumnsSupplier @@ -1277,6 +1271,8 @@ void SAL_CALL SbaXFormAdapter::dispose() xComp->dispose(); } m_aChildren.clear(); + m_xMainForm.clear(); + m_xParent.clear(); } void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< css::lang::XEventListener >& xListener) @@ -1297,7 +1293,7 @@ void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any if (m_nNamePropHandle == nHandle) { - if (aValue.getValueType().getTypeClass() != TypeClass_STRING) + if (aValue.getValueTypeClass() != TypeClass_STRING) { throw css::lang::IllegalArgumentException(); } @@ -1312,9 +1308,8 @@ void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any aValue >>= m_sName; - ::comphelper::OInterfaceIteratorHelper2 aIt(*m_aPropertyChangeListeners.getContainer(PROPERTY_NAME)); - while (aIt.hasMoreElements()) - static_cast< css::beans::XPropertyChangeListener*>(aIt.next())->propertyChange(aEvt); + m_aPropertyChangeListeners.getContainer(PROPERTY_NAME)->notifyEach( + &XPropertyChangeListener::propertyChange, aEvt ); return; } @@ -1328,7 +1323,7 @@ Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle) OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !"); if (m_nNamePropHandle == nHandle) - return makeAny(m_sName); + return Any(m_sName); return xSet->getFastPropertyValue(nHandle); } @@ -1341,7 +1336,7 @@ OUString SAL_CALL SbaXFormAdapter::getName() void SAL_CALL SbaXFormAdapter::setName(const OUString& aName) { - setPropertyValue(PROPERTY_NAME, makeAny(aName)); + setPropertyValue(PROPERTY_NAME, Any(aName)); } // css::io::XPersistObject @@ -1427,7 +1422,7 @@ void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< OUStr { Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); if (xBroadcaster.is()) - xBroadcaster->addPropertiesChangeListener(Sequence< OUString>{""}, &m_aPropertiesChangeListeners); + xBroadcaster->addPropertiesChangeListener(Sequence< OUString>{u""_ustr}, &m_aPropertiesChangeListeners); } } @@ -1598,7 +1593,7 @@ void SAL_CALL SbaXFormAdapter::removeResetListener(const css::uno::Reference< cs void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const OUString* pNewElName) { // extract the form component - if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE) + if (aElement.getValueTypeClass() != TypeClass_INTERFACE) { throw css::lang::IllegalArgumentException(); } @@ -1619,7 +1614,7 @@ void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const OU try { if (pNewElName) - xElementSet->setPropertyValue(PROPERTY_NAME, makeAny(*pNewElName)); + xElementSet->setPropertyValue(PROPERTY_NAME, Any(*pNewElName)); xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName; } @@ -1649,9 +1644,7 @@ void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const OU aEvt.Source = *this; aEvt.Accessor <<= nIndex; aEvt.Element <<= xElement; - ::comphelper::OInterfaceIteratorHelper3 aIt(m_aContainerListeners); - while (aIt.hasMoreElements()) - aIt.next()->elementInserted(aEvt); + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvt ); } sal_Int32 SbaXFormAdapter::implGetPos(const OUString& rName) @@ -1700,7 +1693,7 @@ Any SAL_CALL SbaXFormAdapter::getByName(const OUString& aName) { throw css::container::NoSuchElementException(); } - return makeAny(m_aChildren[nPos]); + return Any(m_aChildren[nPos]); } Sequence< OUString > SAL_CALL SbaXFormAdapter::getElementNames() @@ -1754,10 +1747,7 @@ void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex) css::container::ContainerEvent aEvt; aEvt.Source = *this; aEvt.Element <<= xAffected; - ::comphelper::OInterfaceIteratorHelper3 aIt(m_aContainerListeners); - while (aIt.hasMoreElements()) - aIt.next()->elementRemoved(aEvt); - + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvt ); } // css::container::XIndexReplace @@ -1767,7 +1757,7 @@ void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Elem throw css::lang::IndexOutOfBoundsException(); // extract the form component - if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE) + if (Element.getValueTypeClass() != TypeClass_INTERFACE) { throw css::lang::IllegalArgumentException(); } @@ -1817,9 +1807,7 @@ void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Elem aEvt.Element <<= xElement; aEvt.ReplacedElement <<= xOld; - ::comphelper::OInterfaceIteratorHelper3 aIt(m_aContainerListeners); - while (aIt.hasMoreElements()) - aIt.next()->elementReplaced(aEvt); + m_aContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvt ); } // css::container::XIndexAccess @@ -1834,7 +1822,7 @@ Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex) throw css::lang::IndexOutOfBoundsException(); Reference< css::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex); - return makeAny(xElement); + return Any(xElement); } // css::container::XContainer diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index e317c2a3beeb..77aaafdbadfb 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -23,7 +23,7 @@ #include <vcl/weld.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <dbaccess/dataview.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <vcl/stdtext.hxx> #include <framework/titlehelper.hxx> @@ -37,7 +37,6 @@ #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/ui/XSidebarProvider.hpp> -#include <sfx2/userinputinterception.hxx> #include <datasourceconnector.hxx> #include <com/sun/star/frame/FrameSearchFlag.hpp> @@ -57,7 +56,6 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame::status; 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::task; @@ -66,43 +64,22 @@ using namespace ::com::sun::star::ui; using namespace ::dbtools; using namespace ::comphelper; -#define ALL_FEATURES -1 +constexpr auto ALL_FEATURES = -1; typedef std::unordered_map< sal_Int16, sal_Int16 > CommandHashMap; namespace dbaui { -namespace { - -// UserDefinedFeatures -class UserDefinedFeatures -{ -public: - explicit UserDefinedFeatures( const Reference< XController >& _rxController ); - - void execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs ); - -private: - css::uno::WeakReference< XController > m_aController; -}; - -} - -UserDefinedFeatures::UserDefinedFeatures( const Reference< XController >& _rxController ) - :m_aController( _rxController ) -{ -} - -void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs ) +void OGenericUnoController::executeUserDefinedFeatures( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs ) { try { - Reference< XController > xController( Reference< XController >(m_aController), UNO_SET_THROW ); + Reference< XController > xController( getXController(), UNO_SET_THROW ); Reference< XDispatchProvider > xDispatchProvider( xController->getFrame(), UNO_QUERY_THROW ); Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( _rFeatureURL, - "_self", + u"_self"_ustr, FrameSearchFlag::AUTO ) ); @@ -121,22 +98,10 @@ void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< Prop } } -// OGenericUnoController_Data -struct OGenericUnoController_Data -{ - ::sfx2::UserInputInterception m_aUserInputInterception; - UserDefinedFeatures m_aUserDefinedFeatures; - - OGenericUnoController_Data( OGenericUnoController& _rController, ::osl::Mutex& _rMutex ) - :m_aUserInputInterception( _rController, _rMutex ) - ,m_aUserDefinedFeatures( _rController.getXController() ) - { - } -}; - // OGenericUnoController OGenericUnoController::OGenericUnoController(const Reference< XComponentContext >& _rM) :OGenericUnoController_Base( getMutex() ) + ,m_aUserInputInterception(*this, getMutex()) ,m_pView(nullptr) #ifdef DBG_UTIL ,m_bDescribingSupportedFeatures( false ) @@ -150,12 +115,6 @@ OGenericUnoController::OGenericUnoController(const Reference< XComponentContext ,m_bCurrentlyModified(false) ,m_bExternalTitle(false) { - osl_atomic_increment( &m_refCount ); - { - m_pData.reset( new OGenericUnoController_Data( *this, getMutex() ) ); - } - osl_atomic_decrement( &m_refCount ); - try { @@ -207,7 +166,7 @@ IMPL_LINK_NOARG(OGenericUnoController, OnAsyncInvalidateAll, void*, void) InvalidateFeature_Impl(); } -void OGenericUnoController::impl_initialize() +void OGenericUnoController::impl_initialize(const ::comphelper::NamedValueCollection& /*rArguments*/) { } @@ -218,45 +177,44 @@ void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArgumen Reference< XFrame > xFrame; - PropertyValue aValue; - const Any* pIter = aArguments.getConstArray(); - const Any* pEnd = pIter + aArguments.getLength(); - - for ( ; pIter != pEnd; ++pIter ) + for (auto& arg : aArguments) { - if ( ( *pIter >>= aValue ) && aValue.Name == "Frame" ) - { - xFrame.set(aValue.Value,UNO_QUERY_THROW); - } - else if ( ( *pIter >>= aValue ) && aValue.Name == "Preview" ) + PropertyValue aValue; + if (arg >>= aValue) { - aValue.Value >>= m_bPreview; - m_bReadOnly = true; + if (aValue.Name == "Frame") + { + xFrame.set(aValue.Value, UNO_QUERY_THROW); + } + else if (aValue.Name == "Preview") + { + aValue.Value >>= m_bPreview; + m_bReadOnly = true; + } } } try { if ( !xFrame.is() ) - throw IllegalArgumentException("need a frame", *this, 1 ); + throw IllegalArgumentException(u"need a frame"_ustr, *this, 1 ); Reference<XWindow> xParent = xFrame->getContainerWindow(); VclPtr<vcl::Window> pParentWin = VCLUnoHelper::GetWindow(xParent); if (!pParentWin) { - throw IllegalArgumentException("Parent window is null", *this, 1 ); + throw IllegalArgumentException(u"Parent window is null"_ustr, *this, 1 ); } - m_aInitParameters.assign( aArguments ); Construct( pParentWin ); ODataView* pView = getView(); if ( !pView ) - throw RuntimeException("unable to create a view", *this ); + throw RuntimeException(u"unable to create a view"_ustr, *this ); if ( m_bReadOnly || m_bPreview ) pView->EnableInput( false ); - impl_initialize(); + impl_initialize(::comphelper::NamedValueCollection(aArguments)); } catch(Exception&) { @@ -323,7 +281,7 @@ Reference<XSidebarProvider> SAL_CALL OGenericUnoController::getSidebar() OUString SAL_CALL OGenericUnoController::getViewControllerName() { - return "Default"; + return u"Default"_ustr; } Sequence< PropertyValue > SAL_CALL OGenericUnoController::getCreationArguments() @@ -370,11 +328,11 @@ namespace // #i68216# is the bug which requests to fix the code in Draw which relies on // framework's implementation details if ( !!_rFeatureState.sTitle ) - _out_rStates.push_back( makeAny( *_rFeatureState.sTitle ) ); - if ( !!_rFeatureState.bChecked ) - _out_rStates.push_back( makeAny( *_rFeatureState.bChecked ) ); - if ( !!_rFeatureState.bInvisible ) - _out_rStates.push_back( makeAny( Visibility( !*_rFeatureState.bInvisible ) ) ); + _out_rStates.push_back( Any( *_rFeatureState.sTitle ) ); + if ( _rFeatureState.bChecked.has_value() ) + _out_rStates.push_back( Any( *_rFeatureState.bChecked ) ); + if ( _rFeatureState.bInvisible.has_value() ) + _out_rStates.push_back( Any( Visibility( !*_rFeatureState.bInvisible ) ) ); if ( _rFeatureState.aValue.hasValue() ) _out_rStates.push_back( _rFeatureState.aValue ); if ( _out_rStates.empty() ) @@ -429,7 +387,7 @@ void OGenericUnoController::ImplBroadcastFeatureState(const OUString& _rFeature, // it is possible that listeners are registered or revoked while // we are notifying them, so we must use a copy of m_arrStatusListener, not // m_arrStatusListener itself - Dispatch aNotifyLoop( m_arrStatusListener ); + std::vector<DispatchTarget> aNotifyLoop( m_arrStatusListener ); for (auto const& elem : aNotifyLoop) { @@ -459,7 +417,7 @@ void OGenericUnoController::InvalidateFeature_Impl() bool bEmpty = true; FeatureListener aNextFeature; { - ::osl::MutexGuard aGuard( m_aFeatureMutex); + std::unique_lock aGuard( m_aFeatureMutex); bEmpty = m_aFeaturesToInvalidate.empty(); if (!bEmpty) aNextFeature = m_aFeaturesToInvalidate.front(); @@ -492,7 +450,7 @@ void OGenericUnoController::InvalidateFeature_Impl() ImplBroadcastFeatureState( aFeaturePos->first, aNextFeature.xListener, aNextFeature.bForceBroadcast ); } - ::osl::MutexGuard aGuard( m_aFeatureMutex); + std::unique_lock aGuard( m_aFeatureMutex); m_aFeaturesToInvalidate.pop_front(); bEmpty = m_aFeaturesToInvalidate.empty(); if (!bEmpty) @@ -521,7 +479,7 @@ void OGenericUnoController::ImplInvalidateFeature( sal_Int32 _nId, const Referen bool bWasEmpty; { - ::osl::MutexGuard aGuard( m_aFeatureMutex ); + std::unique_lock aGuard( m_aFeatureMutex ); bWasEmpty = m_aFeaturesToInvalidate.empty(); m_aFeaturesToInvalidate.push_back( aListener ); } @@ -547,7 +505,7 @@ void OGenericUnoController::InvalidateAll_Impl() ImplBroadcastFeatureState( supportedFeature.first, nullptr, true ); { - ::osl::MutexGuard aGuard( m_aFeatureMutex); + std::unique_lock aGuard( m_aFeatureMutex); OSL_ENSURE(m_aFeaturesToInvalidate.size(), "OGenericUnoController::InvalidateAll_Impl: to be called from within InvalidateFeature_Impl only!"); m_aFeaturesToInvalidate.pop_front(); if(!m_aFeaturesToInvalidate.empty()) @@ -584,19 +542,13 @@ Reference< XDispatch > OGenericUnoController::queryDispatch(const URL& aURL, co Sequence< Reference< XDispatch > > OGenericUnoController::queryDispatches(const Sequence< DispatchDescriptor >& aDescripts) { - Sequence< Reference< XDispatch > > aReturn; - sal_Int32 nLen = aDescripts.getLength(); - if ( nLen ) + Sequence< Reference< XDispatch > > aReturn(aDescripts.getLength()); + if (aDescripts.hasElements()) { - aReturn.realloc( nLen ); - Reference< XDispatch >* pReturn = aReturn.getArray(); - const Reference< XDispatch >* pReturnEnd = aReturn.getArray() + nLen; - const DispatchDescriptor* pDescripts = aDescripts.getConstArray(); - - for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts ) - { - *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags ); - } + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), + [this](auto& desc) { + return queryDispatch(desc.FeatureURL, desc.FrameName, desc.SearchFlags); + }); } return aReturn; @@ -653,14 +605,12 @@ void OGenericUnoController::removeStatusListener(const Reference< XStatusListene { if (_rURL.Complete.isEmpty()) { - m_arrStatusListener.erase(std::remove_if(m_arrStatusListener.begin(), m_arrStatusListener.end(), - [&aListener](const DispatchTarget& rCurrent) { return rCurrent.xListener == aListener; }), - m_arrStatusListener.end()); + std::erase_if(m_arrStatusListener, [&aListener](const DispatchTarget& rCurrent) { return rCurrent.xListener == aListener; }); } else { // remove the listener only for the given URL - Dispatch::iterator iterSearch = std::find_if(m_arrStatusListener.begin(), m_arrStatusListener.end(), + auto iterSearch = std::find_if(m_arrStatusListener.begin(), m_arrStatusListener.end(), [&aListener, &_rURL](const DispatchTarget& rCurrent) { return (rCurrent.xListener == aListener) && (rCurrent.aURL.Complete == _rURL.Complete); }); if (iterSearch != m_arrStatusListener.end()) @@ -674,18 +624,14 @@ void OGenericUnoController::removeStatusListener(const Reference< XStatusListene SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find(_rURL.Complete); if (aIter != m_aSupportedFeatures.end()) { // clear the cache for that feature - StateCache::const_iterator aCachePos = m_aStateCache.find( aIter->second.nFeatureId ); + auto aCachePos = m_aStateCache.find( aIter->second.nFeatureId ); if ( aCachePos != m_aStateCache.end() ) m_aStateCache.erase( aCachePos ); } // now remove the listener from the deque - ::osl::MutexGuard aGuard( m_aFeatureMutex ); - m_aFeaturesToInvalidate.erase( - std::remove_if( m_aFeaturesToInvalidate.begin(), - m_aFeaturesToInvalidate.end(), - FindFeatureListener(aListener)) - ,m_aFeaturesToInvalidate.end()); + std::unique_lock aGuard( m_aFeatureMutex ); + std::erase_if( m_aFeaturesToInvalidate, FindFeatureListener(aListener)); } void OGenericUnoController::releaseNumberForComponent() @@ -707,7 +653,7 @@ void OGenericUnoController::disposing() { EventObject aDisposeEvent; aDisposeEvent.Source = static_cast<XWeak*>(this); - Dispatch aStatusListener = m_arrStatusListener; + std::vector<DispatchTarget> aStatusListener = m_arrStatusListener; for (auto const& statusListener : aStatusListener) { statusListener.xListener->disposing(aDisposeEvent); @@ -717,7 +663,7 @@ void OGenericUnoController::disposing() m_xDatabaseContext = nullptr; { - ::osl::MutexGuard aGuard( m_aFeatureMutex); + std::unique_lock aGuard( m_aFeatureMutex); m_aAsyncInvalidateAll.CancelCall(); m_aFeaturesToInvalidate.clear(); } @@ -733,7 +679,6 @@ void OGenericUnoController::disposing() m_xSlaveDispatcher = nullptr; m_xTitleHelper.clear(); m_xUrlTransformer.clear(); - m_aInitParameters.clear(); } void SAL_CALL OGenericUnoController::addEventListener( const Reference< XEventListener >& xListener ) @@ -755,7 +700,7 @@ void OGenericUnoController::frameAction(const FrameActionEvent& aEvent) m_aCurrentFrame.frameAction( aEvent.Action ); } -void OGenericUnoController::implDescribeSupportedFeature( const char* _pAsciiCommandURL, +void OGenericUnoController::implDescribeSupportedFeature( const OUString& _rCommandURL, sal_uInt16 _nFeatureId, sal_Int16 _nCommandGroup ) { #ifdef DBG_UTIL @@ -765,7 +710,7 @@ void OGenericUnoController::implDescribeSupportedFeature( const char* _pAsciiCom "OGenericUnoController::implDescribeSupportedFeature: invalid feature id!" ); ControllerFeature aFeature; - aFeature.Command = OUString::createFromAscii( _pAsciiCommandURL ); + aFeature.Command = _rCommandURL; aFeature.nFeatureId = _nFeatureId; aFeature.GroupId = _nCommandGroup; @@ -779,11 +724,11 @@ void OGenericUnoController::implDescribeSupportedFeature( const char* _pAsciiCom void OGenericUnoController::describeSupportedFeatures() { // add all supported features - implDescribeSupportedFeature( ".uno:Copy", ID_BROWSER_COPY, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:Cut", ID_BROWSER_CUT, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:Paste", ID_BROWSER_PASTE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:ClipboardFormatItems", ID_BROWSER_CLIPBOARD_FORMAT_ITEMS ); - implDescribeSupportedFeature( ".uno:DSBEditDoc", ID_BROWSER_EDITDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:Copy"_ustr, ID_BROWSER_COPY, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:Cut"_ustr, ID_BROWSER_CUT, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:Paste"_ustr, ID_BROWSER_PASTE, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:ClipboardFormatItems"_ustr, ID_BROWSER_CLIPBOARD_FORMAT_ITEMS ); + implDescribeSupportedFeature( u".uno:DSBEditDoc"_ustr, ID_BROWSER_EDITDOC, CommandGroup::DOCUMENT ); } FeatureState OGenericUnoController::GetState( sal_uInt16 _nId ) const @@ -815,7 +760,7 @@ void OGenericUnoController::Execute( sal_uInt16 _nId, const Sequence< PropertyVa // user defined features can be handled by dispatch interceptors resp. protocol handlers only. // So, we need to do a queryDispatch, and dispatch the URL - m_pData->m_aUserDefinedFeatures.execute( getURLForId( _nId ), _rArgs ); + executeUserDefinedFeatures( getURLForId( _nId ), _rArgs ); } URL OGenericUnoController::getURLForId(sal_Int32 _nId) const @@ -923,7 +868,7 @@ Reference< XLayoutManager > OGenericUnoController::getLayoutManager(const Refere { try { - xLayoutManager.set(xPropSet->getPropertyValue("LayoutManager"),UNO_QUERY); + xLayoutManager.set(xPropSet->getPropertyValue(u"LayoutManager"_ustr),UNO_QUERY); } catch ( Exception& ) { @@ -938,8 +883,8 @@ void OGenericUnoController::loadMenu(const Reference< XFrame >& _xFrame) if ( xLayoutManager.is() ) { xLayoutManager->lock(); - xLayoutManager->createElement( "private:resource/menubar/menubar" ); - xLayoutManager->createElement( "private:resource/toolbar/toolbar" ); + xLayoutManager->createElement( u"private:resource/menubar/menubar"_ustr ); + xLayoutManager->createElement( u"private:resource/toolbar/toolbar"_ustr ); xLayoutManager->unlock(); xLayoutManager->doLayout(); } @@ -1050,12 +995,12 @@ Reference< awt::XWindow> OGenericUnoController::getTopMostContainerWindow() cons return xWindow; } -Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw() +Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw(bool bCreateIfNecessary) { SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( getMutex() ); - if ( ! m_xTitleHelper.is ()) + if (!m_xTitleHelper.is() && bCreateIfNecessary) { Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY ); @@ -1093,7 +1038,7 @@ void SAL_CALL OGenericUnoController::addTitleChangeListener(const Reference< XTi void SAL_CALL OGenericUnoController::removeTitleChangeListener(const Reference< XTitleChangeListener >& xListener) { - Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY); + Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(false), UNO_QUERY); if (xBroadcaster.is ()) xBroadcaster->removeTitleChangeListener (xListener); } @@ -1102,23 +1047,23 @@ void SAL_CALL OGenericUnoController::removeTitleChangeListener(const Reference< void SAL_CALL OGenericUnoController::addKeyHandler( const Reference< XKeyHandler >& _rxHandler ) { if ( _rxHandler.is() ) - m_pData->m_aUserInputInterception.addKeyHandler( _rxHandler ); + m_aUserInputInterception.addKeyHandler( _rxHandler ); } void SAL_CALL OGenericUnoController::removeKeyHandler( const Reference< XKeyHandler >& _rxHandler ) { - m_pData->m_aUserInputInterception.removeKeyHandler( _rxHandler ); + m_aUserInputInterception.removeKeyHandler( _rxHandler ); } void SAL_CALL OGenericUnoController::addMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler ) { if ( _rxHandler.is() ) - m_pData->m_aUserInputInterception.addMouseClickHandler( _rxHandler ); + m_aUserInputInterception.addMouseClickHandler( _rxHandler ); } void SAL_CALL OGenericUnoController::removeMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler ) { - m_pData->m_aUserInputInterception.removeMouseClickHandler( _rxHandler ); + m_aUserInputInterception.removeMouseClickHandler( _rxHandler ); } void OGenericUnoController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs) @@ -1144,14 +1089,14 @@ Reference< XController > OGenericUnoController::getXController() bool OGenericUnoController::interceptUserInput( const NotifyEvent& _rEvent ) { - return m_pData->m_aUserInputInterception.handleNotifyEvent( _rEvent ); + return m_aUserInputInterception.handleNotifyEvent( _rEvent ); } bool OGenericUnoController::isCommandChecked(sal_uInt16 _nCommandId) const { FeatureState aState = GetState( _nCommandId ); - return aState.bChecked && *aState.bChecked; + return aState.bChecked.has_value() && *aState.bChecked; } bool OGenericUnoController::isCommandEnabled( const OUString& _rCompleteCommandURL ) const @@ -1205,6 +1150,11 @@ void SAL_CALL OGenericUnoController::dispose() { SolarMutexGuard aSolarGuard; OGenericUnoController_Base::dispose(); + m_xUrlTransformer.clear(); + m_xSlaveDispatcher.clear(); + m_xMasterDispatcher.clear(); + m_xDatabaseContext.clear(); + m_xTitleHelper.clear(); } weld::Window* OGenericUnoController::getFrameWeld() const diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 16980f05bfe5..58017ff4c24c 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -18,7 +18,6 @@ */ #include <core_resource.hxx> -#include <helpids.h> #include <sot/exchange.hxx> @@ -34,26 +33,22 @@ #include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/awt/XTextComponent.hpp> #include <com/sun/star/sdbc/XResultSetUpdate.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <svl/numuno.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/svapp.hxx> -#include <svl/zforlist.hxx> #include <cppuhelper/queryinterface.hxx> #include <connectivity/dbtools.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/types.hxx> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/SQLException.hpp> -#include <browserids.hxx> #include <strings.hrc> #include <strings.hxx> #include <dbexchange.hxx> -#include <TableRowExchange.hxx> -#include <TableRow.hxx> #include <svtools/stringtransfer.hxx> #include <UITools.hxx> #include <TokenWriter.hxx> @@ -64,12 +59,10 @@ using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::datatransfer; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::view; using namespace ::com::sun::star::form; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::util; @@ -87,8 +80,8 @@ com_sun_star_comp_dbu_SbaXGridControl_get_implementation( css::uno::Sequence<OUString> SAL_CALL SbaXGridControl::getSupportedServiceNames() { - return { "com.sun.star.form.control.InteractionGridControl", "com.sun.star.form.control.GridControl", - "com.sun.star.awt.UnoControl" }; + return { u"com.sun.star.form.control.InteractionGridControl"_ustr, u"com.sun.star.form.control.GridControl"_ustr, + u"com.sun.star.awt.UnoControl"_ustr }; } @@ -96,7 +89,7 @@ css::uno::Sequence<OUString> SAL_CALL SbaXGridControl::getSupportedServiceNames( OUString SAL_CALL SbaXGridControl::getImplementationName() { - return "com.sun.star.comp.dbu.SbaXGridControl"; + return u"com.sun.star.comp.dbu.SbaXGridControl"_ustr; } SbaXGridControl::SbaXGridControl(const Reference< XComponentContext >& _rM) @@ -132,9 +125,9 @@ rtl::Reference<FmXGridPeer> SbaXGridControl::imp_CreatePeer(vcl::Window* pParent return pReturn; } -Any SAL_CALL SbaXGridControl::queryInterface(const Type& _rType) +Any SAL_CALL SbaXGridControl::queryAggregation(const Type& _rType) { - Any aRet = FmXGridControl::queryInterface(_rType); + Any aRet = FmXGridControl::queryAggregation(_rType); return aRet.hasValue() ? aRet : ::cppu::queryInterface(_rType,static_cast<css::frame::XDispatch*>(this)); } @@ -242,7 +235,6 @@ void SAL_CALL SbaXGridControl::dispose() // SbaXGridPeer SbaXGridPeer::SbaXGridPeer(const Reference< XComponentContext >& _rM) : FmXGridPeer(_rM) -,m_aStatusListeners(m_aMutex) { } @@ -252,10 +244,11 @@ SbaXGridPeer::~SbaXGridPeer() void SAL_CALL SbaXGridPeer::dispose() { - EventObject aEvt(*this); - - m_aStatusListeners.disposeAndClear(aEvt); - + { + std::unique_lock g(m_aMutex); + EventObject aEvt(*this); + m_aStatusListeners.disposeAndClear(g, aEvt); + } FmXGridPeer::dispose(); } @@ -280,13 +273,13 @@ void SbaXGridPeer::NotifyStatusChanged(const css::util::URL& _rUrl, const Refere xControl->statusChanged(aEvt); else { - ::comphelper::OInterfaceContainerHelper2 * pIter = m_aStatusListeners.getContainer(_rUrl); + std::unique_lock g(m_aMutex); + ::comphelper::OInterfaceContainerHelper4<css::frame::XStatusListener> * pIter + = m_aStatusListeners.getContainer(g, _rUrl); if (pIter) { - ::comphelper::OInterfaceIteratorHelper2 aListIter(*pIter); - while (aListIter.hasMoreElements()) - static_cast< css::frame::XStatusListener*>(aListIter.next())->statusChanged(aEvt); + pIter->notifyEach( g, &XStatusListener::statusChanged, aEvt ); } } } @@ -445,19 +438,24 @@ void SAL_CALL SbaXGridPeer::dispatch(const URL& aURL, const Sequence< PropertyVa void SAL_CALL SbaXGridPeer::addStatusListener(const Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) { - ::comphelper::OInterfaceContainerHelper2* pCont = m_aStatusListeners.getContainer(aURL); - if (!pCont) - m_aStatusListeners.addInterface(aURL,xControl); - else - pCont->addInterface(xControl); + { + std::unique_lock g(m_aMutex); + ::comphelper::OInterfaceContainerHelper4< css::frame::XStatusListener >* pCont + = m_aStatusListeners.getContainer(g, aURL); + if (!pCont) + m_aStatusListeners.addInterface(g, aURL,xControl); + else + pCont->addInterface(g, xControl); + } NotifyStatusChanged(aURL, xControl); } void SAL_CALL SbaXGridPeer::removeStatusListener(const Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) { - ::comphelper::OInterfaceContainerHelper2* pCont = m_aStatusListeners.getContainer(aURL); + std::unique_lock g(m_aMutex); + ::comphelper::OInterfaceContainerHelper4< css::frame::XStatusListener >* pCont = m_aStatusListeners.getContainer(g, aURL); if ( pCont ) - pCont->removeInterface(xControl); + pCont->removeInterface(g, xControl); } Sequence< Type > SAL_CALL SbaXGridPeer::getTypes() @@ -467,8 +465,6 @@ Sequence< Type > SAL_CALL SbaXGridPeer::getTypes() Sequence { cppu::UnoType<css::frame::XDispatch>::get() }); } -UNO3_GETIMPLEMENTATION2_IMPL(SbaXGridPeer, FmXGridPeer); - VclPtr<FmGridControl> SbaXGridPeer::imp_CreateControl(vcl::Window* pParent, WinBits nStyle) { return VclPtr<SbaGridControl>::Create( m_xContext, pParent, this, nStyle); @@ -555,10 +551,10 @@ void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu& r if (bDBIsReadOnly) { - rMenu.set_visible("hide", false); - rMenu.set_sensitive("hide", false); - rMenu.set_visible("show", false); - rMenu.set_sensitive("show", false); + rMenu.set_visible(u"hide"_ustr, false); + rMenu.set_sensitive(u"hide"_ustr, false); + rMenu.set_visible(u"show"_ustr, false); + rMenu.set_sensitive(u"show"_ustr, false); } // prepend some new items @@ -584,18 +580,18 @@ void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu& r case DataType::REF: break; default: - rMenu.insert(nPos++, "colattrset", DBA_RES(RID_STR_COLUMN_FORMAT), + rMenu.insert(nPos++, u"colattrset"_ustr, DBA_RES(RID_STR_COLUMN_FORMAT), nullptr, nullptr, nullptr, TRISTATE_INDET); - rMenu.insert_separator(nPos++, "separator1"); + rMenu.insert_separator(nPos++, u"separator1"_ustr); } } - rMenu.insert(nPos++, "colwidth", DBA_RES(RID_STR_COLUMN_WIDTH), + rMenu.insert(nPos++, u"colwidth"_ustr, DBA_RES(RID_STR_COLUMN_WIDTH), nullptr, nullptr, nullptr, TRISTATE_INDET); - rMenu.insert_separator(nPos++, "separator2"); + rMenu.insert_separator(nPos++, u"separator2"_ustr); } -void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const weld::Menu& rMenu, const OString& rExecutionResult) +void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const weld::Menu& rMenu, const OUString& rExecutionResult) { if (rExecutionResult == "colwidth") static_cast<SbaGridControl*>(GetParent())->SetColWidth(nColId); @@ -649,18 +645,18 @@ void SbaGridControl::PreExecuteRowContextMenu(weld::Menu& rMenu) if (!IsReadOnlyDB()) { - rMenu.insert(nPos++, "tableattr", DBA_RES(RID_STR_TABLE_FORMAT), + rMenu.insert(nPos++, u"tableattr"_ustr, DBA_RES(RID_STR_TABLE_FORMAT), nullptr, nullptr, nullptr, TRISTATE_INDET); - rMenu.insert(nPos++, "rowheight", DBA_RES(RID_STR_ROW_HEIGHT), + rMenu.insert(nPos++, u"rowheight"_ustr, DBA_RES(RID_STR_ROW_HEIGHT), nullptr, nullptr, nullptr, TRISTATE_INDET); - rMenu.insert_separator(nPos++, "separator1"); + rMenu.insert_separator(nPos++, u"separator1"_ustr); } if ( GetSelectRowCount() > 0 ) { - rMenu.insert(nPos++, "copy", DBA_RES(RID_STR_COPY), + rMenu.insert(nPos++, u"copy"_ustr, DBA_RES(RID_STR_COPY), nullptr, nullptr, nullptr, TRISTATE_INDET); - rMenu.insert_separator(nPos++, "separator2"); + rMenu.insert_separator(nPos++, u"separator2"_ustr); } } @@ -779,10 +775,10 @@ void SbaGridControl::SetBrowserAttrs() { Reference< XComponentContext > xContext = getContext(); css::uno::Sequence<css::uno::Any> aArguments{ - Any(comphelper::makePropertyValue("IntrospectedObject", xGridModel)), - Any(comphelper::makePropertyValue("ParentWindow", VCLUnoHelper::GetInterface(this))) + Any(comphelper::makePropertyValue(u"IntrospectedObject"_ustr, xGridModel)), + Any(comphelper::makePropertyValue(u"ParentWindow"_ustr, VCLUnoHelper::GetInterface(this))) }; - Reference<XExecutableDialog> xExecute(xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.form.ControlFontDialog", + Reference<XExecutableDialog> xExecute(xContext->getServiceManager()->createInstanceWithArgumentsAndContext(u"com.sun.star.form.ControlFontDialog"_ustr, aArguments, xContext), css::uno::UNO_QUERY_THROW); xExecute->execute(); } @@ -792,7 +788,7 @@ void SbaGridControl::SetBrowserAttrs() } } -void SbaGridControl::PostExecuteRowContextMenu(const OString& rExecutionResult) +void SbaGridControl::PostExecuteRowContextMenu(const OUString& rExecutionResult) { if (rExecutionResult == "tableattr") SetBrowserAttrs(); @@ -902,7 +898,7 @@ void SbaGridControl::MouseButtonDown( const BrowserMouseEvent& rMEvt) { sal_Int32 nRow = GetRowAtYPosPixel(rMEvt.GetPosPixel().Y()); sal_uInt16 nColPos = GetColumnAtXPosPixel(rMEvt.GetPosPixel().X()); - sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? sal_uInt16(-1) : nColPos-1; + sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? sal_uInt16(-1) : sal_uInt16(nColPos - 1); // 'the handle column' and 'no valid column' will both result in a view position of -1 ! bool bHitEmptySpace = (nRow > GetRowCount()) || (nViewPos == sal_uInt16(-1)); @@ -928,7 +924,7 @@ void SbaGridControl::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) // my laziness says 'do it here'...) sal_Int32 nRow = GetRowAtYPosPixel(_rPosPixel.Y()); sal_uInt16 nColPos = GetColumnAtXPosPixel(_rPosPixel.X()); - sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? sal_uInt16(-1) : nColPos-1; + sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? sal_uInt16(-1) : sal_uInt16(nColPos-1); // 'the handle column' and 'no valid column' will both result in a view position of -1 ! bool bCurrentRowVirtual = IsCurrentAppending() && IsModified(); @@ -1094,10 +1090,10 @@ void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos) OUString sCellText; Reference< XGridFieldDataSupplier > xFieldData(GetPeer()); Sequence<sal_Bool> aSupportingText = xFieldData->queryFieldDataType(cppu::UnoType<decltype(sCellText)>::get()); - if (aSupportingText.getConstArray()[nColumnPos]) + if (aSupportingText[nColumnPos]) { Sequence< Any> aCellContents = xFieldData->queryFieldData(nRowPos, cppu::UnoType<decltype(sCellText)>::get()); - sCellText = ::comphelper::getString(aCellContents.getConstArray()[nColumnPos]); + sCellText = ::comphelper::getString(aCellContents[nColumnPos]); ::svt::OStringTransfer::StartStringDrag(sCellText, this, DND_ACTION_COPY); } } diff --git a/dbaccess/source/ui/browser/sbamultiplex.cxx b/dbaccess/source/ui/browser/sbamultiplex.cxx index 732b730c2b3d..8bf7ed747c03 100644 --- a/dbaccess/source/ui/browser/sbamultiplex.cxx +++ b/dbaccess/source/ui/browser/sbamultiplex.cxx @@ -18,6 +18,8 @@ */ #include <sbamultiplex.hxx> +#include <cppuhelper/queryinterface.hxx> + using namespace dbaui; // the listener multiplexers @@ -49,9 +51,7 @@ void SAL_CALL SbaXStatusMultiplexer::statusChanged(const css::frame::FeatureStat { m_aLastKnownStatus = e; m_aLastKnownStatus.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt( *this ); - while ( aIt.hasMoreElements() ) - aIt.next()->statusChanged( m_aLastKnownStatus ); + notifyEach( &XStatusListener::statusChanged, m_aLastKnownStatus ); } // LoadListener @@ -80,44 +80,34 @@ void SAL_CALL SbaXLoadMultiplexer::loaded(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->loaded(aMulti); + notifyEach( &XLoadListener::loaded, aMulti ); } void SAL_CALL SbaXLoadMultiplexer::unloaded(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->unloaded(aMulti); + notifyEach( &XLoadListener::unloaded, aMulti ); } void SAL_CALL SbaXLoadMultiplexer::unloading(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->unloading(aMulti); + notifyEach( &XLoadListener::unloading, aMulti ); } void SAL_CALL SbaXLoadMultiplexer::reloading(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->reloading(aMulti); + notifyEach( &XLoadListener::reloading, aMulti ); } void SAL_CALL SbaXLoadMultiplexer::reloaded(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->reloaded(aMulti); + notifyEach( &XLoadListener::reloaded, aMulti ); } @@ -147,27 +137,21 @@ void SAL_CALL SbaXRowSetMultiplexer::cursorMoved(const css::lang::EventObject& e { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->cursorMoved(aMulti); + notifyEach( &XRowSetListener::cursorMoved, aMulti ); } void SAL_CALL SbaXRowSetMultiplexer::rowChanged(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->rowChanged(aMulti); + notifyEach( &XRowSetListener::rowChanged, aMulti ); } void SAL_CALL SbaXRowSetMultiplexer::rowSetChanged(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->rowSetChanged(aMulti); + notifyEach( &XRowSetListener::rowSetChanged, aMulti ); } // css::sdb::XRowSetApproveListener @@ -251,9 +235,7 @@ void SAL_CALL SbaXSQLErrorMultiplexer::errorOccured(const css::sdb::SQLErrorEven { css::sdb::SQLErrorEvent aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->errorOccured(aMulti); + notifyEach( &XSQLErrorListener::errorOccured, aMulti ); } // css::form::XDatabaseParameterListener @@ -362,9 +344,7 @@ void SAL_CALL SbaXResetMultiplexer::resetted(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->resetted(aMulti); + notifyEach( &XResetListener::resetted, aMulti ); } // css::beans::XPropertyChangeListener @@ -390,7 +370,7 @@ void SAL_CALL SbaXPropertyChangeMultiplexer::disposing(const css::lang::EventObj } void SAL_CALL SbaXPropertyChangeMultiplexer::propertyChange(const css::beans::PropertyChangeEvent& e) { - ::comphelper::OInterfaceContainerHelper2* pListeners = m_aListeners.getContainer(e.PropertyName); + ::comphelper::OInterfaceContainerHelper3<XPropertyChangeListener>* pListeners = m_aListeners.getContainer(e.PropertyName); if (pListeners) Notify(*pListeners, e); @@ -401,13 +381,13 @@ void SAL_CALL SbaXPropertyChangeMultiplexer::propertyChange(const css::beans::Pr } void SbaXPropertyChangeMultiplexer::addInterface(const OUString& rName, - const css::uno::Reference< css::uno::XInterface > & rListener) + const css::uno::Reference< css::beans::XPropertyChangeListener > & rListener) { m_aListeners.addInterface(rName, rListener); } void SbaXPropertyChangeMultiplexer::removeInterface(const OUString& rName, - const css::uno::Reference< css::uno::XInterface > & rListener) + const css::uno::Reference< css::beans::XPropertyChangeListener > & rListener) { m_aListeners.removeInterface(rName, rListener); } @@ -424,7 +404,7 @@ sal_Int32 SbaXPropertyChangeMultiplexer::getOverallLen() const const std::vector< OUString > aContained = m_aListeners.getContainedTypes(); for ( OUString const & s : aContained) { - ::comphelper::OInterfaceContainerHelper2* pListeners = m_aListeners.getContainer(s); + ::comphelper::OInterfaceContainerHelper3<XPropertyChangeListener>* pListeners = m_aListeners.getContainer(s); if (!pListeners) continue; nLen += pListeners->getLength(); @@ -432,13 +412,11 @@ sal_Int32 SbaXPropertyChangeMultiplexer::getOverallLen() const return nLen; } -void SbaXPropertyChangeMultiplexer::Notify(::comphelper::OInterfaceContainerHelper2& rListeners, const css::beans::PropertyChangeEvent& e) +void SbaXPropertyChangeMultiplexer::Notify(::comphelper::OInterfaceContainerHelper3<XPropertyChangeListener>& rListeners, const css::beans::PropertyChangeEvent& e) { css::beans::PropertyChangeEvent aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper2 aIt(rListeners); - while (aIt.hasMoreElements()) - static_cast< css::beans::XPropertyChangeListener*>(aIt.next())->propertyChange(aMulti); + rListeners.notifyEach( &XPropertyChangeListener::propertyChange, aMulti ); } // css::beans::XVetoableChangeListener @@ -464,7 +442,7 @@ void SAL_CALL SbaXVetoableChangeMultiplexer::disposing(const css::lang::EventObj } void SAL_CALL SbaXVetoableChangeMultiplexer::vetoableChange(const css::beans::PropertyChangeEvent& e) { - ::comphelper::OInterfaceContainerHelper2* pListeners = m_aListeners.getContainer(e.PropertyName); + ::comphelper::OInterfaceContainerHelper3<css::beans::XVetoableChangeListener>* pListeners = m_aListeners.getContainer(e.PropertyName); if (pListeners) Notify(*pListeners, e); @@ -475,13 +453,13 @@ void SAL_CALL SbaXVetoableChangeMultiplexer::vetoableChange(const css::beans::Pr } void SbaXVetoableChangeMultiplexer::addInterface(const OUString& rName, - const css::uno::Reference< css::uno::XInterface > & rListener) + const css::uno::Reference< css::beans::XVetoableChangeListener > & rListener) { m_aListeners.addInterface(rName, rListener); } void SbaXVetoableChangeMultiplexer::removeInterface(const OUString& rName, - const css::uno::Reference< css::uno::XInterface > & rListener) + const css::uno::Reference< css::beans::XVetoableChangeListener > & rListener) { m_aListeners.removeInterface(rName, rListener); } @@ -498,7 +476,7 @@ sal_Int32 SbaXVetoableChangeMultiplexer::getOverallLen() const const std::vector< OUString > aContained = m_aListeners.getContainedTypes(); for ( OUString const & s : aContained) { - ::comphelper::OInterfaceContainerHelper2* pListeners = m_aListeners.getContainer(s); + ::comphelper::OInterfaceContainerHelper3<XVetoableChangeListener>* pListeners = m_aListeners.getContainer(s); if (!pListeners) continue; nLen += pListeners->getLength(); @@ -506,13 +484,11 @@ sal_Int32 SbaXVetoableChangeMultiplexer::getOverallLen() const return nLen; } -void SbaXVetoableChangeMultiplexer::Notify(::comphelper::OInterfaceContainerHelper2& rListeners, const css::beans::PropertyChangeEvent& e) +void SbaXVetoableChangeMultiplexer::Notify(::comphelper::OInterfaceContainerHelper3<XVetoableChangeListener>& rListeners, const css::beans::PropertyChangeEvent& e) { css::beans::PropertyChangeEvent aMulti(e); aMulti.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper2 aIt(rListeners); - while (aIt.hasMoreElements()) - static_cast< css::beans::XVetoableChangeListener*>(aIt.next())->vetoableChange(aMulti); + rListeners.notifyEach( &XVetoableChangeListener::vetoableChange, aMulti ); } // css::beans::XPropertiesChangeListener @@ -546,9 +522,7 @@ void SbaXPropertiesChangeMultiplexer::propertiesChange(const css::uno::Sequence< for (css::beans::PropertyChangeEvent & rEvent : asNonConstRange(aMulti)) rEvent.Source = &m_rParent; - ::comphelper::OInterfaceIteratorHelper3 aIt(*this); - while (aIt.hasMoreElements()) - aIt.next()->propertiesChange(aMulti); + notifyEach( &css::beans::XPropertiesChangeListener::propertiesChange, aMulti ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index 035a0e1ef8c2..283f3680afd6 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -82,12 +82,13 @@ #include <svx/dataaccessdescriptor.hxx> #include <svx/databaseregistrationui.hxx> #include <toolkit/helper/vclunohelper.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> #include <tools/multisel.hxx> #include <tools/urlobj.hxx> #include <unotools/confignode.hxx> +#include <utility> #include <vcl/split.hxx> #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> @@ -110,7 +111,6 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::task; using namespace ::com::sun::star::form; -using namespace ::com::sun::star::io; using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::view; using namespace ::com::sun::star::datatransfer; @@ -151,12 +151,12 @@ static void SafeRemovePropertyListener(const Reference< XPropertySet > & xSet, c OUString SAL_CALL SbaTableQueryBrowser::getImplementationName() { - return "org.openoffice.comp.dbu.ODatasourceBrowser"; + return u"org.openoffice.comp.dbu.ODatasourceBrowser"_ustr; } css::uno::Sequence<OUString> SAL_CALL SbaTableQueryBrowser::getSupportedServiceNames() { - return { "com.sun.star.sdb.DataSourceBrowser" }; + return { u"com.sun.star.sdb.DataSourceBrowser"_ustr }; } SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XComponentContext >& _rM) @@ -192,9 +192,9 @@ Any SAL_CALL SbaTableQueryBrowser::queryInterface(const Type& _rType) { if ( _rType.equals( cppu::UnoType<XScriptInvocationContext>::get() ) ) { - OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::queryInterface: did not initialize this, yet!" ); - if ( !!m_aDocScriptSupport && *m_aDocScriptSupport ) - return makeAny( Reference< XScriptInvocationContext >( this ) ); + OSL_PRECOND( m_aDocScriptSupport.has_value(), "SbaTableQueryBrowser::queryInterface: did not initialize this, yet!" ); + if ( m_aDocScriptSupport.has_value() && *m_aDocScriptSupport ) + return Any( Reference< XScriptInvocationContext >( this ) ); return Any(); } @@ -211,8 +211,8 @@ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) SbaTableQueryBrowser_Base::getTypes() ) ); - OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::getTypes: did not initialize this, yet!" ); - if ( !m_aDocScriptSupport || !*m_aDocScriptSupport ) + OSL_PRECOND( m_aDocScriptSupport.has_value(), "SbaTableQueryBrowser::getTypes: did not initialize this, yet!" ); + if ( !m_aDocScriptSupport.has_value() || !*m_aDocScriptSupport ) { auto [begin, end] = asNonConstRange(aTypes); auto newEnd = std::remove_if( begin, end, @@ -286,49 +286,49 @@ bool SbaTableQueryBrowser::Construct(vcl::Window* pParent) { SAL_WARN("dbaccess.ui", "SbaTableQueryBrowser::Construct: could not create (or start listening at) the database context!"); } + // some help ids - if (getBrowserView() && getBrowserView()->getVclControl()) - { + if (!getBrowserView() || !getBrowserView()->getVclControl()) + return true; - // create controls and set sizes - const tools::Long nFrameWidth = getBrowserView()->LogicToPixel(::Size(3, 0), MapMode(MapUnit::MapAppFont)).Width(); + // create controls and set sizes + const tools::Long nFrameWidth = getBrowserView()->LogicToPixel(::Size(3, 0), MapMode(MapUnit::MapAppFont)).Width(); - m_pSplitter = VclPtr<Splitter>::Create(getBrowserView(),WB_HSCROLL); - m_pSplitter->SetPosSizePixel( ::Point(0,0), ::Size(nFrameWidth,0) ); - m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) ); + m_pSplitter = VclPtr<Splitter>::Create(getBrowserView(),WB_HSCROLL); + m_pSplitter->SetPosSizePixel( ::Point(0,0), ::Size(nFrameWidth,0) ); + m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) ); - m_pTreeView = VclPtr<InterimDBTreeListBox>::Create(getBrowserView()); + m_pTreeView = VclPtr<InterimDBTreeListBox>::Create(getBrowserView()); - weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - rTreeView.connect_expanding(LINK(this, SbaTableQueryBrowser, OnExpandEntry)); + weld::TreeView& rTreeView = m_pTreeView->GetWidget(); + rTreeView.connect_expanding(LINK(this, SbaTableQueryBrowser, OnExpandEntry)); - m_pTreeView->setCopyHandler(LINK(this, SbaTableQueryBrowser, OnCopyEntry)); + m_pTreeView->setCopyHandler(LINK(this, SbaTableQueryBrowser, OnCopyEntry)); - m_pTreeView->setContextMenuProvider( this ); - m_pTreeView->setControlActionListener( this ); - m_pTreeView->SetHelpId(HID_CTL_TREEVIEW); + m_pTreeView->setContextMenuProvider( this ); + m_pTreeView->setControlActionListener( this ); + m_pTreeView->SetHelpId(HID_CTL_TREEVIEW); - // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide - m_pSplitter->SetSplitPosPixel(getBrowserView()->LogicToPixel(::Size(80, 0), MapMode(MapUnit::MapAppFont)).Width()); + // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide + m_pSplitter->SetSplitPosPixel(getBrowserView()->LogicToPixel(::Size(80, 0), MapMode(MapUnit::MapAppFont)).Width()); - getBrowserView()->setSplitter(m_pSplitter); - getBrowserView()->setTreeView(m_pTreeView); + getBrowserView()->setSplitter(m_pSplitter); + getBrowserView()->setTreeView(m_pTreeView); - // fill view with data - rTreeView.set_sort_order(true); - rTreeView.set_sort_func([this](const weld::TreeIter& rLeft, const weld::TreeIter& rRight){ - return OnTreeEntryCompare(rLeft, rRight); - }); - rTreeView.make_sorted(); - m_pTreeView->SetSelChangeHdl(LINK(this, SbaTableQueryBrowser, OnSelectionChange)); - m_pTreeView->show_container(); + // fill view with data + rTreeView.set_sort_order(true); + rTreeView.set_sort_func([this](const weld::TreeIter& rLeft, const weld::TreeIter& rRight){ + return OnTreeEntryCompare(rLeft, rRight); + }); + rTreeView.make_sorted(); + m_pTreeView->SetSelChangeHdl(LINK(this, SbaTableQueryBrowser, OnSelectionChange)); + m_pTreeView->show_container(); - // TODO - getBrowserView()->getVclControl()->SetHelpId(HID_CTL_TABBROWSER); - if (getBrowserView()->getVclControl()->GetHeaderBar()) - getBrowserView()->getVclControl()->GetHeaderBar()->SetHelpId(HID_DATABROWSE_HEADER); - InvalidateFeature(ID_BROWSER_EXPLORER); - } + // TODO + getBrowserView()->getVclControl()->SetHelpId(HID_CTL_TABBROWSER); + if (getBrowserView()->getVclControl()->GetHeaderBar()) + getBrowserView()->getVclControl()->GetHeaderBar()->SetHelpId(HID_DATABROWSE_HEADER); + InvalidateFeature(ID_BROWSER_EXPLORER); return true; } @@ -416,8 +416,8 @@ void SbaTableQueryBrowser::impl_sanitizeRowSetClauses_nothrow() if ( invalidColumn ) { // reset the complete order statement at both the row set and the parser - xRowSetProps->setPropertyValue( PROPERTY_ORDER, makeAny( OUString() ) ); - xComposer->setOrder( "" ); + xRowSetProps->setPropertyValue( PROPERTY_ORDER, Any( OUString() ) ); + xComposer->setOrder( u""_ustr ); } // check if the columns participating in the filter refer to existing tables @@ -469,7 +469,7 @@ bool SbaTableQueryBrowser::InitializeForm( const Reference< XPropertySet > & i_f try { weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed)); ENSURE_OR_RETURN_FALSE( pData, "SbaTableQueryBrowser::InitializeForm: No user data set at the currently displayed entry!" ); ENSURE_OR_RETURN_FALSE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeForm: No table available!" ); @@ -479,10 +479,10 @@ bool SbaTableQueryBrowser::InitializeForm( const Reference< XPropertySet > & i_f const OUString aTransferProperties[] = { - OUString(PROPERTY_APPLYFILTER), - OUString(PROPERTY_FILTER), - OUString(PROPERTY_HAVING_CLAUSE), - OUString(PROPERTY_ORDER) + PROPERTY_APPLYFILTER, + PROPERTY_FILTER, + PROPERTY_HAVING_CLAUSE, + PROPERTY_ORDER }; for (const auto & aTransferProperty : aTransferProperties) { @@ -523,9 +523,9 @@ void SbaTableQueryBrowser::initializePreviewMode() Reference< XPropertySet > xDataSourceSet(getRowSet(), UNO_QUERY); if ( xDataSourceSet.is() ) { - xDataSourceSet->setPropertyValue("AllowInserts",makeAny(false)); - xDataSourceSet->setPropertyValue("AllowUpdates",makeAny(false)); - xDataSourceSet->setPropertyValue("AllowDeletes",makeAny(false)); + xDataSourceSet->setPropertyValue(u"AllowInserts"_ustr,Any(false)); + xDataSourceSet->setPropertyValue(u"AllowUpdates"_ustr,Any(false)); + xDataSourceSet->setPropertyValue(u"AllowDeletes"_ustr,Any(false)); } } @@ -546,10 +546,10 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm if (m_xCurrentlyDisplayed) { Sequence< OUString> aProperties(6 + ( m_bPreview ? 5 : 0 )); - Sequence< Any> aValues(7 + ( m_bPreview ? 5 : 0 )); + Sequence< Any> aValues(6 + ( m_bPreview ? 5 : 0 )); weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed)); OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeGridModel: No table available!" ); if ( !pData->xObjectProperties.is() ) return; @@ -641,14 +641,14 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm case DataType::BOOLEAN: { aCurrentModelType = "CheckBox"; - aInitialValues.emplace_back( "VisualEffect", makeAny( VisualEffect::FLAT ) ); + aInitialValues.emplace_back( "VisualEffect", Any( VisualEffect::FLAT ) ); sDefaultProperty = PROPERTY_DEFAULTSTATE; sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN; OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable ); aInitialValues.emplace_back( "TriState", - makeAny( ColumnValue::NO_NULLS != nNullable ) + Any( ColumnValue::NO_NULLS != nNullable ) ); if ( ColumnValue::NO_NULLS == nNullable ) aDefault <<= sal_Int16(TRISTATE_FALSE); @@ -657,7 +657,7 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm case DataType::LONGVARCHAR: case DataType::CLOB: - aInitialValues.emplace_back( "MultiLine", makeAny( true ) ); + aInitialValues.emplace_back( "MultiLine", Any( true ) ); [[fallthrough]]; case DataType::BINARY: case DataType::VARBINARY: @@ -675,19 +675,19 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm sDefaultProperty = PROPERTY_EFFECTIVEDEFAULT; if ( xSupplier.is() ) - aInitialValues.emplace_back( "FormatsSupplier", makeAny( xSupplier ) ); - aInitialValues.emplace_back( "TreatAsNumber", makeAny( bFormattedIsNumeric ) ); + aInitialValues.emplace_back( "FormatsSupplier", Any( xSupplier ) ); + aInitialValues.emplace_back( "TreatAsNumber", Any( bFormattedIsNumeric ) ); aCopyProperties.emplace_back(PROPERTY_FORMATKEY ); break; } - aInitialValues.emplace_back( PROPERTY_CONTROLSOURCE, makeAny( rName ) ); + aInitialValues.emplace_back( PROPERTY_CONTROLSOURCE, Any( rName ) ); OUString sLabel; xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; if ( !sLabel.isEmpty() ) - aInitialValues.emplace_back( PROPERTY_LABEL, makeAny( sLabel ) ); + aInitialValues.emplace_back( PROPERTY_LABEL, Any( sLabel ) ); else - aInitialValues.emplace_back( PROPERTY_LABEL, makeAny( rName ) ); + aInitialValues.emplace_back( PROPERTY_LABEL, Any( rName ) ); Reference< XPropertySet > xGridCol( xColFactory->createColumn( aCurrentModelType ), UNO_SET_THROW ); Reference< XPropertySetInfo > xGridColPSI( xGridCol->getPropertySetInfo(), UNO_SET_THROW ); @@ -734,7 +734,7 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm // don't allow the mouse to scroll in the cells if ( xGridColPSI->hasPropertyByName( PROPERTY_MOUSE_WHEEL_BEHAVIOR ) ) - aInitialValues.emplace_back( PROPERTY_MOUSE_WHEEL_BEHAVIOR, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) ); + aInitialValues.emplace_back( PROPERTY_MOUSE_WHEEL_BEHAVIOR, Any( MouseWheelBehavior::SCROLL_DISABLED ) ); // now set all those values for (auto const& property : aInitialValues) @@ -744,7 +744,7 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm for (auto const& copyPropertyName : aCopyProperties) xGridCol->setPropertyValue( copyPropertyName, xColumn->getPropertyValue(copyPropertyName) ); - xColContainer->insertByName(rName, makeAny(xGridCol)); + xColContainer->insertByName(rName, Any(xGridCol)); } } } @@ -761,7 +761,7 @@ static Reference<XPropertySet> getColumnHelper(const weld::TreeView& rTreeView, Reference<XPropertySet> xRet; if (pCurrentlyDisplayed) { - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pCurrentlyDisplayed).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*pCurrentlyDisplayed)); Reference<XColumnsSupplier> xColumnsSup(pData->xObjectProperties,UNO_QUERY); Reference<XNameAccess> xNames = xColumnsSup->getColumns(); OUString aName; @@ -777,7 +777,7 @@ void SbaTableQueryBrowser::transferChangedControlProperty(const OUString& _rProp if (m_xCurrentlyDisplayed) { weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed)); Reference< XPropertySet > xObjectProps = pData->xObjectProperties; OSL_ENSURE(xObjectProps.is(),"SbaTableQueryBrowser::transferChangedControlProperty: no table/query object!"); if (xObjectProps.is()) @@ -805,7 +805,7 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) if(xProp.is()) { if(!evt.NewValue.hasValue()) - xProp->setPropertyValue(PROPERTY_WIDTH,makeAny(sal_Int32(227))); + xProp->setPropertyValue(PROPERTY_WIDTH,Any(sal_Int32(227))); else xProp->setPropertyValue(PROPERTY_WIDTH,evt.NewValue); } @@ -831,12 +831,12 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) { sal_Int16 nAlign = 0; if(evt.NewValue >>= nAlign) - xProp->setPropertyValue(PROPERTY_ALIGN,makeAny(sal_Int32(nAlign))); + xProp->setPropertyValue(PROPERTY_ALIGN,Any(sal_Int32(nAlign))); else xProp->setPropertyValue(PROPERTY_ALIGN,evt.NewValue); } else - xProp->setPropertyValue(PROPERTY_ALIGN,makeAny(css::awt::TextAlign::LEFT)); + xProp->setPropertyValue(PROPERTY_ALIGN,Any(css::awt::TextAlign::LEFT)); } } catch( const Exception& ) @@ -862,12 +862,12 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) { if (m_xCurrentlyDisplayed) { - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed)); OSL_ENSURE( pData->xObjectProperties.is(), "No table available!" ); bool bDefault = !evt.NewValue.hasValue(); if (bDefault) - pData->xObjectProperties->setPropertyValue(PROPERTY_ROW_HEIGHT,makeAny(sal_Int32(45))); + pData->xObjectProperties->setPropertyValue(PROPERTY_ROW_HEIGHT,Any(sal_Int32(45))); else pData->xObjectProperties->setPropertyValue(PROPERTY_ROW_HEIGHT,evt.NewValue); } @@ -1037,7 +1037,7 @@ namespace struct FilterByEntryDataId : public IEntryFilter { OUString sId; - explicit FilterByEntryDataId( const OUString& _rId ) : sId( _rId ) { } + explicit FilterByEntryDataId( OUString _aId ) : sId(std::move( _aId )) { } virtual ~FilterByEntryDataId() {} @@ -1054,8 +1054,8 @@ namespace OUString SbaTableQueryBrowser::getDataSourceAccessor(const weld::TreeIter& rDataSourceEntry) const { weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rDataSourceEntry).toUInt64()); - OSL_ENSURE( pData, "SbaTableQueryBrowser::getDataSourceAccessor: invalid entry data!" ); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(rDataSourceEntry)); + assert(pData && "SbaTableQueryBrowser::getDataSourceAccessor: invalid entry data!"); OSL_ENSURE( pData->eType == etDatasource, "SbaTableQueryBrowser::getDataSourceAccessor: entry does not denote a data source!" ); return !pData->sAccessor.isEmpty() ? pData->sAccessor : GetEntryText(rDataSourceEntry); } @@ -1167,7 +1167,7 @@ std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::getObjectEntry(const OUStr { if (ensureEntryObject(*xObject)) { - DBTreeListUserData* pParentData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xObject).toUInt64()); + DBTreeListUserData* pParentData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xObject)); Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY ); sal_Int32 nIndex2 = nIndex; sPath = _rCommand.getToken( 0, '/', nIndex2 ); @@ -1226,33 +1226,33 @@ void SbaTableQueryBrowser::connectExternalDispatches() if ( m_aExternalFeatures.empty() ) { - const char* pURLs[] = { - ".uno:DataSourceBrowser/DocumentDataSource", - ".uno:DataSourceBrowser/FormLetter", - ".uno:DataSourceBrowser/InsertColumns", - ".uno:DataSourceBrowser/InsertContent", + static constexpr OUString aURLs[] { + u".uno:DataSourceBrowser/DocumentDataSource"_ustr, + u".uno:DataSourceBrowser/FormLetter"_ustr, + u".uno:DataSourceBrowser/InsertColumns"_ustr, + u".uno:DataSourceBrowser/InsertContent"_ustr, }; - const sal_uInt16 nIds[] = { + static constexpr sal_uInt16 nIds[] = { ID_BROWSER_DOCUMENT_DATASOURCE, ID_BROWSER_FORMLETTER, ID_BROWSER_INSERTCOLUMNS, ID_BROWSER_INSERTCONTENT }; - for ( size_t i=0; i < SAL_N_ELEMENTS( pURLs ); ++i ) + for ( size_t i=0; i < std::size( aURLs ); ++i ) { URL aURL; - aURL.Complete = OUString::createFromAscii( pURLs[i] ); + aURL.Complete = aURLs[i]; if ( m_xUrlTransformer.is() ) m_xUrlTransformer->parseStrict( aURL ); - m_aExternalFeatures[ nIds[ i ] ] = ExternalFeature( aURL ); + m_aExternalFeatures[ nIds[ i ] ] = ExternalFeature( std::move(aURL) ); } } for (auto & externalFeature : m_aExternalFeatures) { externalFeature.second.xDispatcher = xProvider->queryDispatch( - externalFeature.second.aURL, "_parent", FrameSearchFlag::PARENT + externalFeature.second.aURL, u"_parent"_ustr, FrameSearchFlag::PARENT ); if ( externalFeature.second.xDispatcher.get() == static_cast< XDispatch* >( this ) ) @@ -1345,7 +1345,7 @@ void SAL_CALL SbaTableQueryBrowser::disposing( const css::lang::EventObject& _rS { do { - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDSLoop).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xDSLoop)); if ( pData && pData->xConnection == xCon ) { // we set the connection to null to avoid a second disposing of the connection @@ -1459,7 +1459,7 @@ void SbaTableQueryBrowser::attachFrame(const Reference< css::frame::XFrame > & _ Reference< XFrame > xCurrentFrame( getFrame() ); if ( xCurrentFrame.is() ) { - m_xCurrentFrameParent = xCurrentFrame->findFrame("_parent",FrameSearchFlag::PARENT); + m_xCurrentFrameParent = xCurrentFrame->findFrame(u"_parent"_ustr,FrameSearchFlag::PARENT); if ( m_xCurrentFrameParent.is() ) m_xCurrentFrameParent->addFrameActionListener(static_cast<css::frame::XFrameActionListener*>(this)); @@ -1468,13 +1468,13 @@ void SbaTableQueryBrowser::attachFrame(const Reference< css::frame::XFrame > & _ { Reference< XPropertySet > xFrameProps( m_aCurrentFrame.getFrame(), UNO_QUERY_THROW ); Reference< XLayoutManager > xLayouter( - xFrameProps->getPropertyValue("LayoutManager"), + xFrameProps->getPropertyValue(u"LayoutManager"_ustr), UNO_QUERY ); if ( xLayouter.is() ) { Reference< XUIElement > xUI( - xLayouter->getElement( "private:resource/toolbar/toolbar" ), + xLayouter->getElement( u"private:resource/toolbar/toolbar"_ustr ), UNO_SET_THROW ); m_xMainToolbar.set(xUI->getRealInterface(), css::uno::UNO_QUERY); OSL_ENSURE( m_xMainToolbar.is(), "SbaTableQueryBrowser::attachFrame: where's my toolbox?" ); @@ -1645,7 +1645,7 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const std::unique_ptr<weld::TreeIter> xDataSourceEntry = m_pTreeView->GetRootLevelParent(xCurrentEntry.get()); DBTreeListUserData* pDSData = xDataSourceEntry - ? reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDataSourceEntry).toUInt64()) + ? weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xDataSourceEntry)) : nullptr; if ( nId == ID_TREE_CLOSE_CONN ) @@ -1655,9 +1655,9 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const else if ( nId == ID_TREE_EDIT_DATABASE ) { ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithComponentContext( getORB(), - "/org.openoffice.Office.DataAccess/Policies/Features/Common" ) ); + u"/org.openoffice.Office.DataAccess/Policies/Features/Common"_ustr ) ); bool bHaveEditDatabase( true ); - OSL_VERIFY( aConfig.getNodeValue( "EditDatabaseFromDataSourceView" ) >>= bHaveEditDatabase ); + OSL_VERIFY( aConfig.getNodeValue( u"EditDatabaseFromDataSourceView"_ustr ) >>= bHaveEditDatabase ); aReturn.bEnabled = getORB().is() && xDataSourceEntry && bHaveEditDatabase; } else if ( nId == ID_BROWSER_COPY ) @@ -2034,7 +2034,7 @@ void SbaTableQueryBrowser::implAddDatasource(const OUString& _rDbName, OUString& pDSData->eType = etDatasource; pDSData->sAccessor = sDataSourceId; pDSData->xConnection = _rxConnection; - OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pDSData))); + OUString sId(weld::toId(pDSData)); std::unique_ptr<weld::TreeIter> xDatasourceEntry(rTreeView.make_iterator()); rTreeView.insert(nullptr, -1, &sDSDisplayName, &sId, nullptr, nullptr, false, xDatasourceEntry.get()); @@ -2045,7 +2045,7 @@ void SbaTableQueryBrowser::implAddDatasource(const OUString& _rDbName, OUString& { DBTreeListUserData* pQueriesData = new DBTreeListUserData; pQueriesData->eType = etQueryContainer; - sId = OUString::number(reinterpret_cast<sal_uInt64>(pQueriesData)); + sId = weld::toId(pQueriesData); std::unique_ptr<weld::TreeIter> xRet(rTreeView.make_iterator()); rTreeView.insert(xDatasourceEntry.get(), -1, &_rQueryName, &sId, @@ -2058,7 +2058,7 @@ void SbaTableQueryBrowser::implAddDatasource(const OUString& _rDbName, OUString& { DBTreeListUserData* pTablesData = new DBTreeListUserData; pTablesData->eType = etTableContainer; - sId = OUString::number(reinterpret_cast<sal_uInt64>(pTablesData)); + sId = weld::toId(pTablesData); std::unique_ptr<weld::TreeIter> xRet(rTreeView.make_iterator()); rTreeView.insert(xDatasourceEntry.get(), -1, &_rTableName, &sId, @@ -2089,7 +2089,7 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce weld::TreeView& rTreeView = m_pTreeView->GetWidget(); rTreeView.make_unsorted(); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rParent).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(rParent)); if (pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables pData->xContainer = _xNameAccess; @@ -2120,7 +2120,7 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce rTreeView.make_sorted(); } -std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implAppendEntry(const weld::TreeIter* pParent, const OUString& rName, DBTreeListUserData* pUserData) +std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implAppendEntry(const weld::TreeIter* pParent, const OUString& rName, const DBTreeListUserData* pUserData) { EntryType eEntryType = pUserData->eType; @@ -2128,7 +2128,7 @@ std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implAppendEntry(const weld OUString aImage = xImageProvider->getImageId(rName, getDatabaseObjectType(eEntryType)); - OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pUserData))); + OUString sId(weld::toId(pUserData)); weld::TreeView& rTreeView = m_pTreeView->GetWidget(); std::unique_ptr<weld::TreeIter> xNewEntry(rTreeView.make_iterator()); rTreeView.insert(pParent, -1, &rName, &sId, nullptr, nullptr, eEntryType == etQueryContainer, xNewEntry.get()); @@ -2150,7 +2150,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, const weld::TreeIter&, rParent, b std::unique_ptr<weld::TreeIter> xFirstParent = m_pTreeView->GetRootLevelParent(&rParent); OSL_ENSURE(xFirstParent,"SbaTableQueryBrowser::OnExpandEntry: No rootlevelparent!"); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rParent).toInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(rParent)); assert(pData && "SbaTableQueryBrowser::OnExpandEntry: No user data!"); if (etTableContainer == pData->eType) @@ -2159,9 +2159,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, const weld::TreeIter&, rParent, b // it could be that we already have a connection SharedConnection xConnection; - ensureConnection(xFirstParent.get(), xConnection); - - if ( xConnection.is() ) + if (ensureConnection(xFirstParent.get(), xConnection) && xConnection.is()) { SQLExceptionInfo aInfo; try @@ -2238,7 +2236,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, const weld::TreeIter&, rParent, b // we have to expand the queries or bookmarks if (ensureEntryObject(rParent)) { - DBTreeListUserData* pParentData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rParent).toUInt64()); + DBTreeListUserData* pParentData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(rParent)); Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY ); populateTree(xCollection, rParent, etQuery); } @@ -2252,8 +2250,8 @@ bool SbaTableQueryBrowser::ensureEntryObject(const weld::TreeIter& rEntry) // the user data of the entry weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntry).toUInt64()); - OSL_ENSURE(pEntryData,"ensureEntryObject: user data should already be set!"); + DBTreeListUserData* pEntryData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(rEntry)); + assert(pEntryData && "ensureEntryObject: user data should already be set!"); std::unique_ptr<weld::TreeIter> xDataSourceEntry = m_pTreeView->GetRootLevelParent(&rEntry); @@ -2275,7 +2273,7 @@ bool SbaTableQueryBrowser::ensureEntryObject(const weld::TreeIter& rEntry) if (rTreeView.iter_compare(*xParent, *xDataSourceEntry) != 0) { OUString aName(rTreeView.get_text(rEntry)); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xParent).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xParent)); try { Reference< XNameAccess > xNameAccess(pData->xContainer,UNO_QUERY); @@ -2347,17 +2345,17 @@ bool SbaTableQueryBrowser::implLoadAnything(const OUString& _rDataSourceName, co Reference<XPropertySet> xProp( getRowSet(), UNO_QUERY_THROW ); Reference< XLoadable > xLoadable( xProp, UNO_QUERY_THROW ); // the values allowing the RowSet to re-execute - xProp->setPropertyValue(PROPERTY_DATASOURCENAME, makeAny(_rDataSourceName)); + xProp->setPropertyValue(PROPERTY_DATASOURCENAME, Any(_rDataSourceName)); if(_rxConnection.is()) - xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( _rxConnection.getTyped() ) ); + xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( _rxConnection.getTyped() ) ); // set this _before_ setting the connection, else the rowset would rebuild it ... - xProp->setPropertyValue(PROPERTY_COMMAND_TYPE, makeAny(nCommandType)); - xProp->setPropertyValue(PROPERTY_COMMAND, makeAny(_rCommand)); - xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, css::uno::makeAny(_bEscapeProcessing)); + xProp->setPropertyValue(PROPERTY_COMMAND_TYPE, Any(nCommandType)); + xProp->setPropertyValue(PROPERTY_COMMAND, Any(_rCommand)); + xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, css::uno::Any(_bEscapeProcessing)); if ( m_bPreview ) { - xProp->setPropertyValue(PROPERTY_FETCHDIRECTION, makeAny(FetchDirection::FORWARD)); + xProp->setPropertyValue(PROPERTY_FETCHDIRECTION, Any(FetchDirection::FORWARD)); } // the formatter depends on the data source we're working on, so rebuild it here ... @@ -2427,44 +2425,44 @@ bool SbaTableQueryBrowser::implSelect(const OUString& _rDataSourceName, const OU const SharedConnection& _rxConnection, bool _bSelectDirect) { - if (_rDataSourceName.getLength() && _rCommand.getLength() && (-1 != nCommandType)) - { - std::unique_ptr<weld::TreeIter> xDataSource; - std::unique_ptr<weld::TreeIter> xCommandType; - std::unique_ptr<weld::TreeIter> xCommand = getObjectEntry( _rDataSourceName, _rCommand, nCommandType, &xDataSource, &xCommandType, true, _rxConnection ); + if (!_rDataSourceName.getLength() || !_rCommand.getLength() || (-1 == nCommandType)) + return false; - if (xCommand) - { - weld::TreeView& rTreeView = m_pTreeView->GetWidget(); + std::unique_ptr<weld::TreeIter> xDataSource; + std::unique_ptr<weld::TreeIter> xCommandType; + std::unique_ptr<weld::TreeIter> xCommand = getObjectEntry( _rDataSourceName, _rCommand, nCommandType, &xDataSource, &xCommandType, true, _rxConnection ); - bool bSuccess = true; - if ( _bSelectDirect ) - { - bSuccess = implSelect(xCommand.get()); - } - else - { - rTreeView.select(*xCommand); - } + if (xCommand) + { + weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - if ( bSuccess ) - { - rTreeView.scroll_to_row(*xCommand); - rTreeView.set_cursor(*xCommand); - } + bool bSuccess = true; + if ( _bSelectDirect ) + { + bSuccess = implSelect(xCommand.get()); } - else if (!xCommandType) + else { - if (m_xCurrentlyDisplayed) - { - // tell the old entry (if any) it has been deselected - selectPath(m_xCurrentlyDisplayed.get(), false); - m_xCurrentlyDisplayed.reset(); - } + rTreeView.select(*xCommand); + } - // we have a command and need to display this in the rowset - return implLoadAnything(_rDataSourceName, _rCommand, nCommandType, _bEscapeProcessing, _rxConnection); + if ( bSuccess ) + { + rTreeView.scroll_to_row(*xCommand); + rTreeView.set_cursor(*xCommand); + } + } + else if (!xCommandType) + { + if (m_xCurrentlyDisplayed) + { + // tell the old entry (if any) it has been deselected + selectPath(m_xCurrentlyDisplayed.get(), false); + m_xCurrentlyDisplayed.reset(); } + + // we have a command and need to display this in the rowset + return implLoadAnything(_rDataSourceName, _rCommand, nCommandType, _bEscapeProcessing, _rxConnection); } return false; } @@ -2482,11 +2480,11 @@ std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implGetConnectionEntry(con { weld::TreeView& rTreeView = m_pTreeView->GetWidget(); std::unique_ptr<weld::TreeIter> xCurrentEntry(rTreeView.make_iterator(&rEntry)); - DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xCurrentEntry).toInt64()); + DBTreeListUserData* pEntryData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xCurrentEntry)); while (pEntryData->eType != etDatasource) { rTreeView.iter_parent(*xCurrentEntry); - pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xCurrentEntry).toInt64()); + pEntryData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xCurrentEntry)); } return xCurrentEntry; } @@ -2497,7 +2495,7 @@ bool SbaTableQueryBrowser::implSelect(const weld::TreeIter* pEntry) return false; weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pEntry).toUInt64()); + DBTreeListUserData* pEntryData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*pEntry)); switch (pEntryData->eType) { case etTableOrView: @@ -2513,11 +2511,11 @@ bool SbaTableQueryBrowser::implSelect(const weld::TreeIter* pEntry) // get the entry for the tables or queries std::unique_ptr<weld::TreeIter> xContainer = rTreeView.make_iterator(pEntry); rTreeView.iter_parent(*xContainer); - DBTreeListUserData* pContainerData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xContainer).toUInt64()); + DBTreeListUserData* pContainerData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xContainer)); // get the entry for the datasource std::unique_ptr<weld::TreeIter> xConnection = implGetConnectionEntry(*xContainer); - DBTreeListUserData* pConData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xConnection).toUInt64()); + DBTreeListUserData* pConData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xConnection)); // reinitialize the rowset // but first check if it is necessary @@ -2540,8 +2538,7 @@ bool SbaTableQueryBrowser::implSelect(const weld::TreeIter* pEntry) { while (rTreeView.iter_compare(*xNextTemp, *xConnection) != 0) { - sNameBuffer.insert(0,'/'); - sNameBuffer.insert(0, rTreeView.get_text(*xTemp)); + sNameBuffer.insert(0, rTreeView.get_text(*xTemp) + "/"); rTreeView.copy_iterator(*xNextTemp, *xTemp); if (!rTreeView.iter_parent(*xNextTemp)) break; @@ -2578,7 +2575,7 @@ bool SbaTableQueryBrowser::implSelect(const weld::TreeIter* pEntry) selectPath(m_xCurrentlyDisplayed.get()); // get the name of the data source currently selected - ensureConnection(m_xCurrentlyDisplayed.get(), pConData->xConnection); + (void)ensureConnection(m_xCurrentlyDisplayed.get(), pConData->xConnection); if ( !pConData->xConnection.is() ) { @@ -2624,7 +2621,7 @@ bool SbaTableQueryBrowser::implSelect(const weld::TreeIter* pEntry) bool bEscapeProcessing = true; if(xNameAccess.is() && xNameAccess->hasByName(sSimpleName)) { - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pEntry).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*pEntry)); if ( !pData->xObjectProperties.is() ) { Reference<XInterface> xObject; @@ -2656,7 +2653,7 @@ bool SbaTableQueryBrowser::implSelect(const weld::TreeIter* pEntry) OUString sReplace = sSql.replaceFirst(sFilter, ""); xAnalyzer->setQuery(sReplace); Reference<XSingleSelectQueryComposer> xComposer(xAnalyzer,UNO_QUERY); - xComposer->setFilter("0=1"); + xComposer->setFilter(u"0=1"_ustr); aName = xAnalyzer->getQuery(); nCommandType = CommandType::COMMAND; } @@ -2725,14 +2722,14 @@ std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::getEntryFromContainer(cons if (rTreeView.iter_children(*xContainer)) { // 1st child is queries - DBTreeListUserData* pQueriesData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xContainer).toUInt64()); + DBTreeListUserData* pQueriesData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xContainer)); if (pQueriesData && pQueriesData->xContainer == rxNameAccess) break; if (rTreeView.iter_next_sibling(*xContainer)) { // 2nd child is tables - DBTreeListUserData* pTablesData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xContainer).toUInt64()); + DBTreeListUserData* pTablesData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xContainer)); if (pTablesData && pTablesData->xContainer == rxNameAccess) break; } @@ -2759,8 +2756,8 @@ void SAL_CALL SbaTableQueryBrowser::elementInserted(const ContainerEvent& rEvent rTreeView.make_unsorted(); // insert the new entry into the tree - DBTreeListUserData* pContainerData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xEntry).toUInt64()); - OSL_ENSURE(pContainerData, "elementInserted: There must be user data for this type!"); + DBTreeListUserData* pContainerData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xEntry)); + assert(pContainerData && "elementInserted: There must be user data for this type!"); DBTreeListUserData* pNewData = new DBTreeListUserData; bool bIsTable = etTableContainer == pContainerData->eType; @@ -2824,7 +2821,7 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven // unload unloadAndCleanup( false ); // don't dispose the connection - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xTemp).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xTemp)); rTreeView.set_id(*xTemp, OUString()); delete pData; // the data could be null because we have a table which isn't correct rTreeView.remove(*xTemp); @@ -2839,7 +2836,7 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven { if (rTreeView.get_text(*xChild) == aName) { - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xChild).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xChild)); rTreeView.set_id(*xChild, OUString()); delete pData; rTreeView.remove(*xChild); @@ -2864,7 +2861,7 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve std::unique_ptr<weld::TreeIter> xContainer = getEntryFromContainer(xNames); if (xContainer) { - // a table or query as been replaced + // a table or query has been replaced OUString aName = ::comphelper::getString(_rEvent.Accessor); weld::TreeView& rTreeView = m_pTreeView->GetWidget(); @@ -2875,7 +2872,7 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve std::unique_ptr<weld::TreeIter> xTemp = rTreeView.make_iterator(m_xCurrentlyDisplayed.get()); unloadAndCleanup( false ); // don't dispose the connection - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xTemp).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xTemp)); if (pData) { if ( etTableOrView == pData->eType ) @@ -2900,7 +2897,7 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve { if (rTreeView.get_text(*xChild) == aName) { - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xChild).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xChild)); if (pData) { if ( etTableOrView == pData->eType ) @@ -2968,7 +2965,7 @@ void SbaTableQueryBrowser::disposeConnection(const weld::TreeIter* pDSEntry) if (pDSEntry) { weld::TreeView& rTreeView = m_pTreeView->GetWidget(); - DBTreeListUserData* pTreeListData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pDSEntry).toUInt64()); + DBTreeListUserData* pTreeListData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*pDSEntry)); if (pTreeListData) impl_releaseConnection(pTreeListData->xConnection); } @@ -3004,7 +3001,7 @@ void SbaTableQueryBrowser::closeConnection(const weld::TreeIter& rDSEntry, bool { std::unique_ptr<weld::TreeIter> xRemove(rTreeView.make_iterator(xElements.get())); bElements = rTreeView.iter_next_sibling(*xElements); - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xRemove).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xRemove)); rTreeView.set_id(*xRemove, OUString()); delete pData; rTreeView.remove(*xRemove); @@ -3095,13 +3092,13 @@ namespace } } -void SbaTableQueryBrowser::impl_initialize() +void SbaTableQueryBrowser::impl_initialize(const ::comphelper::NamedValueCollection& rArguments) { SolarMutexGuard aGuard; // doin' a lot of VCL stuff here -> lock the SolarMutex // first initialize the parent - SbaXDataBrowserController::impl_initialize(); + SbaXDataBrowserController::impl_initialize(rArguments); Reference<XConnection> xForeignConnection; Reference< XFrame > xFrame; @@ -3113,8 +3110,6 @@ void SbaTableQueryBrowser::impl_initialize() OUString sInitialDataSourceName; OUString sInitialCommand; - const NamedValueCollection& rArguments( getInitParams() ); - rArguments.get_ensureType( PROPERTY_DATASOURCENAME, sInitialDataSourceName ); rArguments.get_ensureType( PROPERTY_COMMAND_TYPE, nInitialDisplayCommandType ); rArguments.get_ensureType( PROPERTY_COMMAND, sInitialCommand ); @@ -3123,22 +3118,22 @@ void SbaTableQueryBrowser::impl_initialize() rArguments.get_ensureType( PROPERTY_UPDATE_SCHEMANAME, aSchemaName ); rArguments.get_ensureType( PROPERTY_UPDATE_TABLENAME, aTableName ); rArguments.get_ensureType( PROPERTY_ESCAPE_PROCESSING, bEscapeProcessing ); - rArguments.get_ensureType( "Frame", xFrame ); + rArguments.get_ensureType( u"Frame"_ustr, xFrame ); rArguments.get_ensureType( PROPERTY_SHOWMENU, m_bShowMenu ); // disable the browser if either of ShowTreeViewButton (compatibility name) or EnableBrowser // is present and set to FALSE - bool bDisableBrowser = !rArguments.getOrDefault( "ShowTreeViewButton", true ) // compatibility name + bool bDisableBrowser = !rArguments.getOrDefault( u"ShowTreeViewButton"_ustr, true ) // compatibility name || !rArguments.getOrDefault( PROPERTY_ENABLE_BROWSER, true ); - OSL_ENSURE( !rArguments.has( "ShowTreeViewButton" ), + OSL_ENSURE( !rArguments.has( u"ShowTreeViewButton"_ustr ), "SbaTableQueryBrowser::impl_initialize: ShowTreeViewButton is superseded by EnableBrowser!" ); m_bEnableBrowser = !bDisableBrowser; // hide the tree view it is disabled in general, or if the settings tell to hide it initially bool bHideTreeView = ( !m_bEnableBrowser ) - || !rArguments.getOrDefault( "ShowTreeView", true ) // compatibility name + || !rArguments.getOrDefault( u"ShowTreeView"_ustr, true ) // compatibility name || !rArguments.getOrDefault( PROPERTY_SHOW_BROWSER, true ); - OSL_ENSURE( !rArguments.has( "ShowTreeView" ), + OSL_ENSURE( !rArguments.has( u"ShowTreeView"_ustr ), "SbaTableQueryBrowser::impl_initialize: ShowTreeView is superseded by ShowBrowser!" ); if ( bHideTreeView ) @@ -3152,7 +3147,7 @@ void SbaTableQueryBrowser::impl_initialize() { Sequence< OUString> aProperties { - "AlwaysShowCursor", PROPERTY_BORDER, "HasNavigationBar", "HasRecordMarker", "Tabstop" + u"AlwaysShowCursor"_ustr, PROPERTY_BORDER, u"HasNavigationBar"_ustr, u"HasRecordMarker"_ustr, u"Tabstop"_ustr }; Sequence< Any> aValues { @@ -3252,9 +3247,9 @@ void SbaTableQueryBrowser::impl_initialize() try { Reference< XPropertySet > xRowSetProps(getRowSet(), UNO_QUERY); - xRowSetProps->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(aCatalogName)); - xRowSetProps->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(aSchemaName)); - xRowSetProps->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(aTableName)); + xRowSetProps->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,Any(aCatalogName)); + xRowSetProps->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,Any(aSchemaName)); + xRowSetProps->setPropertyValue(PROPERTY_UPDATE_TABLENAME,Any(aTableName)); } catch(const Exception&) @@ -3306,7 +3301,7 @@ bool SbaTableQueryBrowser::ensureConnection(const weld::TreeIter* pAnyEntry, Sha weld::TreeView& rTreeView = m_pTreeView->GetWidget(); DBTreeListUserData* pDSData = xDSEntry - ? reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDSEntry).toUInt64()) + ? weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xDSEntry)) : nullptr; return ensureConnection(xDSEntry.get(), pDSData, rConnection); @@ -3327,7 +3322,7 @@ bool SbaTableQueryBrowser::getExistentConnectionFor(const weld::TreeIter* pAnyEn weld::TreeView& rTreeView = m_pTreeView->GetWidget(); DBTreeListUserData* pDSData = xDSEntry - ? reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDSEntry).toUInt64()) + ? weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xDSEntry)) : nullptr; if (pDSData) rConnection = pDSData->xConnection; @@ -3461,16 +3456,16 @@ void SbaTableQueryBrowser::implAdministrate(const weld::TreeIter& rApplyTo) InteractionHandler::createWithParent(getORB(), nullptr) ); ::comphelper::NamedValueCollection aLoadArgs; - aLoadArgs.put( "Model", xDocumentModel ); - aLoadArgs.put( "InteractionHandler", xInteractionHandler ); - aLoadArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); + aLoadArgs.put( u"Model"_ustr, xDocumentModel ); + aLoadArgs.put( u"InteractionHandler"_ustr, xInteractionHandler ); + aLoadArgs.put( u"MacroExecutionMode"_ustr, MacroExecMode::USE_CONFIG ); Sequence< PropertyValue > aLoadArgPV; aLoadArgs >>= aLoadArgPV; xFrameLoader->loadComponentFromURL( xDocumentModel->getURL(), - "_default", + u"_default"_ustr, FrameSearchFlag::ALL | FrameSearchFlag::GLOBAL, aLoadArgPV ); @@ -3495,7 +3490,7 @@ bool SbaTableQueryBrowser::requestQuickHelp(const void* pUserData, OUString& rTe OUString SbaTableQueryBrowser::getContextMenuResourceName() const { - return "explorer"; + return u"explorer"_ustr; } IController& SbaTableQueryBrowser::getCommandController() @@ -3523,7 +3518,7 @@ Any SbaTableQueryBrowser::getCurrentSelection(weld::TreeView& rControl) const return Any(); NamedDatabaseObject aSelectedObject; - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xSelected).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xSelected)); aSelectedObject.Type = static_cast< sal_Int32 >( pData->eType ); switch ( aSelectedObject.Type ) @@ -3544,7 +3539,7 @@ Any SbaTableQueryBrowser::getCurrentSelection(weld::TreeView& rControl) const break; } - return makeAny( aSelectedObject ); + return Any( aSelectedObject ); } vcl::Window* SbaTableQueryBrowser::getMenuParent() const @@ -3644,7 +3639,7 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame) if ( xLayoutManager.is() ) { xLayoutManager->lock(); - xLayoutManager->createElement( "private:resource/toolbar/toolbar" ); + xLayoutManager->createElement( u"private:resource/toolbar/toolbar"_ustr ); xLayoutManager->unlock(); xLayoutManager->doLayout(); } @@ -3781,14 +3776,14 @@ void SbaTableQueryBrowser::impl_cleanupDataSourceEntry(std::u16string_view rData do { // delete any user data of the child entries of the to-be-removed entry - const DBTreeListUserData* pData = reinterpret_cast<const DBTreeListUserData*>(rTreeView.get_id(*xChild).toUInt64()); + const DBTreeListUserData* pData = weld::fromId<const DBTreeListUserData*>(rTreeView.get_id(*xChild)); rTreeView.set_id(*xChild, OUString()); delete pData; } while (rTreeView.iter_next_sibling(*xChild)); } // remove the entry - DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDataSourceEntry).toUInt64()); + DBTreeListUserData* pData = weld::fromId<DBTreeListUserData*>(rTreeView.get_id(*xDataSourceEntry)); rTreeView.set_id(*xDataSourceEntry, OUString()); delete pData; rTreeView.remove(*xDataSourceEntry); |