summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/relationdesign
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/relationdesign')
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnection.cxx2
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnectionData.cxx59
-rw-r--r--dbaccess/source/ui/relationdesign/RelationController.cxx27
-rw-r--r--dbaccess/source/ui/relationdesign/RelationDesignView.cxx6
-rw-r--r--dbaccess/source/ui/relationdesign/RelationTableView.cxx27
5 files changed, 51 insertions, 70 deletions
diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
index ba60ae54661b..4b8086f5111f 100644
--- a/dbaccess/source/ui/relationdesign/RTableConnection.cxx
+++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
@@ -51,7 +51,7 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const to
{
OTableConnection::Draw(rRenderContext, rRect);
ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get());
- if (pData && (pData->GetCardinality() == Cardinality::Undefined))
+ if (!pData || pData->GetCardinality() == Cardinality::Undefined)
return;
// search lines for top line
diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
index 1e38bb2f7e03..c679e462c630 100644
--- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
+++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
@@ -41,8 +41,7 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
ORelationTableConnectionData::ORelationTableConnectionData()
- :OTableConnectionData()
- ,m_nUpdateRules(KeyRule::NO_ACTION)
+ :m_nUpdateRules(KeyRule::NO_ACTION)
,m_nDeleteRules(KeyRule::NO_ACTION)
,m_nCardinality(Cardinality::Undefined)
{
@@ -113,9 +112,7 @@ void ORelationTableConnectionData::ChangeOrientation()
}
// adapt member
- TTableWindowData::value_type pTemp = m_pReferencingTable;
- m_pReferencingTable = m_pReferencedTable;
- m_pReferencedTable = pTemp;
+ std::swap( m_pReferencingTable, m_pReferencedTable );
}
void ORelationTableConnectionData::SetCardinality()
@@ -148,15 +145,13 @@ bool ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet
if ( xKeyColumns.is() )
{
Sequence< OUString> aKeyColumns = xKeyColumns->getElementNames();
- const OUString* pKeyIter = aKeyColumns.getConstArray();
- const OUString* pKeyEnd = pKeyIter + aKeyColumns.getLength();
- for(;pKeyIter != pKeyEnd;++pKeyIter)
+ for (auto& keyColumn : aKeyColumns)
{
for (auto const& elem : m_vConnLineData)
{
++nValidLinesCount;
- if ( elem->GetFieldName(_eEConnectionSide) == *pKeyIter )
+ if (elem->GetFieldName(_eEConnectionSide) == keyColumn)
{
++nPrimKeysCount;
break;
@@ -257,11 +252,12 @@ bool ORelationTableConnectionData::Update()
xTableProp->getPropertyValue(PROPERTY_NAME) >>= sSourceName;
OUString sKeyName = sSourceName + getReferencedTable()->GetTableName();
- xKey->setPropertyValue(PROPERTY_NAME,makeAny(sKeyName));
- xKey->setPropertyValue(PROPERTY_TYPE,makeAny(KeyType::FOREIGN));
- xKey->setPropertyValue(PROPERTY_REFERENCEDTABLE,makeAny(getReferencedTable()->GetTableName()));
- xKey->setPropertyValue(PROPERTY_UPDATERULE, makeAny(GetUpdateRules()));
- xKey->setPropertyValue(PROPERTY_DELETERULE, makeAny(GetDeleteRules()));
+ xKey->setPropertyValue(PROPERTY_NAME,Any(sKeyName));
+ xKey->setPropertyValue(PROPERTY_TYPE,Any(KeyType::FOREIGN));
+ // get the full name of the tables to ensure uniqueness across catalogs and schema
+ xKey->setPropertyValue(PROPERTY_REFERENCEDTABLE,Any(getReferencedTable()->GetComposedName()));
+ xKey->setPropertyValue(PROPERTY_UPDATERULE, Any(GetUpdateRules()));
+ xKey->setPropertyValue(PROPERTY_DELETERULE, Any(GetDeleteRules()));
}
Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
@@ -279,8 +275,8 @@ bool ORelationTableConnectionData::Update()
Reference<XPropertySet> xColumn = xColumnFactory->createDataDescriptor();
if ( xColumn.is() )
{
- xColumn->setPropertyValue(PROPERTY_NAME,makeAny(elem->GetSourceFieldName()));
- xColumn->setPropertyValue(PROPERTY_RELATEDCOLUMN,makeAny(elem->GetDestFieldName()));
+ xColumn->setPropertyValue(PROPERTY_NAME,Any(elem->GetSourceFieldName()));
+ xColumn->setPropertyValue(PROPERTY_RELATEDCOLUMN,Any(elem->GetDestFieldName()));
xColumnAppend->appendByDescriptor(xColumn);
}
}
@@ -304,35 +300,28 @@ bool ORelationTableConnectionData::Update()
{
OUString sReferencedTable;
xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable;
- if ( sReferencedTable == getReferencedTable()->GetTableName() )
+ if ( sReferencedTable == getReferencedTable()->GetComposedName() )
{
xColSup.set(xKey,UNO_QUERY_THROW);
try
{
Reference<XNameAccess> xColumns = xColSup->getColumns();
Sequence< OUString> aNames = xColumns->getElementNames();
- const OUString* pIter = aNames.getConstArray();
- const OUString* pEnd = pIter + aNames.getLength();
+ const OUString* pIter = aNames.begin();
+ const OUString* pEnd = aNames.end();
- Reference<XPropertySet> xColumn;
OUString sName,sRelatedColumn;
for ( ; pIter != pEnd ; ++pIter )
{
- xColumn.set(xColumns->getByName(*pIter),UNO_QUERY_THROW);
+ Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY_THROW);
xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn;
- bool bFoundElem = false;
- for (auto const& elem : m_vConnLineData)
- {
- if( elem->GetSourceFieldName() == sName
- && elem->GetDestFieldName() == sRelatedColumn )
- {
- bFoundElem = true;
- break;
- }
- }
- if (!bFoundElem)
+ if (std::none_of(m_vConnLineData.begin(), m_vConnLineData.end(),
+ [&sName, &sRelatedColumn](auto& elem) {
+ return elem->GetSourceFieldName() == sName
+ && elem->GetDestFieldName() == sRelatedColumn;
+ }))
break;
}
if ( pIter == pEnd )
@@ -365,16 +354,14 @@ bool ORelationTableConnectionData::Update()
OConnectionLineDataVec().swap(m_vConnLineData);
Reference<XNameAccess> xColumns = xColSup->getColumns();
Sequence< OUString> aNames = xColumns->getElementNames();
- const OUString* pIter = aNames.getConstArray();
- const OUString* pEnd = pIter + aNames.getLength();
m_vConnLineData.reserve( aNames.getLength() );
Reference<XPropertySet> xColumn;
OUString sName,sRelatedColumn;
- for(;pIter != pEnd;++pIter)
+ for (auto& colName : aNames)
{
- xColumns->getByName(*pIter) >>= xColumn;
+ xColumns->getByName(colName) >>= xColumn;
if ( xColumn.is() )
{
OConnectionLineDataRef pNewData = new OConnectionLineData();
diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx
index d6181459ca6f..7cab45c54d55 100644
--- a/dbaccess/source/ui/relationdesign/RelationController.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationController.cxx
@@ -19,7 +19,6 @@
#include <sal/config.h>
-#include <iterator>
#include <map>
#include <strings.hrc>
@@ -30,7 +29,6 @@
#include <comphelper/types.hxx>
#include <core_resource.hxx>
#include <connectivity/dbtools.hxx>
-#include <comphelper/processfactory.hxx>
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
@@ -46,7 +44,7 @@
#include <RTableConnectionData.hxx>
#include <RelationTableView.hxx>
#include <RelationDesignView.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <osl/thread.hxx>
#include <osl/mutex.hxx>
@@ -60,16 +58,13 @@ org_openoffice_comp_dbu_ORelationDesign_get_implementation(
}
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::io;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::ui::dialogs;
-using namespace ::com::sun::star::util;
using namespace ::dbtools;
using namespace ::dbaui;
using namespace ::comphelper;
@@ -77,12 +72,12 @@ using namespace ::osl;
OUString SAL_CALL ORelationController::getImplementationName()
{
- return "org.openoffice.comp.dbu.ORelationDesign";
+ return u"org.openoffice.comp.dbu.ORelationDesign"_ustr;
}
Sequence< OUString> SAL_CALL ORelationController::getSupportedServiceNames()
{
- return { "com.sun.star.sdb.RelationDesign" };
+ return { u"com.sun.star.sdb.RelationDesign"_ustr };
}
ORelationController::ORelationController(const Reference< XComponentContext >& _rM)
@@ -140,7 +135,7 @@ void ORelationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue
{
::comphelper::NamedValueCollection aWindowsData;
saveTableWindows( aWindowsData );
- getDataSource()->setPropertyValue( PROPERTY_LAYOUTINFORMATION, makeAny( aWindowsData.getPropertyValues() ) );
+ getDataSource()->setPropertyValue( PROPERTY_LAYOUTINFORMATION, Any( aWindowsData.getPropertyValues() ) );
setModified(false);
}
}
@@ -161,9 +156,9 @@ void ORelationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue
InvalidateFeature(_nId);
}
-void ORelationController::impl_initialize()
+void ORelationController::impl_initialize(const ::comphelper::NamedValueCollection& rArguments)
{
- OJoinController::impl_initialize();
+ OJoinController::impl_initialize(rArguments);
if( !getSdbMetaData().supportsRelations() )
{// check if this database supports relations
@@ -223,8 +218,8 @@ short ORelationController::saveModified()
short nSaved = RET_YES;
if(haveDataSource() && isModified())
{
- std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "dbaccess/ui/designsavemodifieddialog.ui"));
- std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("DesignSaveModifiedDialog"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), u"dbaccess/ui/designsavemodifieddialog.ui"_ustr));
+ std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(u"DesignSaveModifiedDialog"_ustr));
nSaved = xQuery->run();
if(nSaved == RET_YES)
Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
@@ -235,7 +230,7 @@ short ORelationController::saveModified()
void ORelationController::describeSupportedFeatures()
{
OJoinController::describeSupportedFeatures();
- implDescribeSupportedFeature( ".uno:DBAddRelation", SID_RELATION_ADD_RELATION, CommandGroup::EDIT );
+ implDescribeSupportedFeature( u".uno:DBAddRelation"_ustr, SID_RELATION_ADD_RELATION, CommandGroup::EDIT );
}
namespace
@@ -259,7 +254,7 @@ namespace
,const Sequence< OUString>& _aTableList
,const sal_Int32 _nStartIndex
,const sal_Int32 _nEndIndex)
- :m_aTableData(_xMetaData.is() && _xMetaData->supportsMixedCaseQuotedIdentifiers())
+ :m_aTableData(comphelper::UStringMixLess(_xMetaData.is() && _xMetaData->supportsMixedCaseQuotedIdentifiers()))
,m_aTableList(_aTableList)
,m_pParent(_pParent)
,m_xMetaData(_xMetaData)
@@ -494,7 +489,7 @@ void ORelationController::loadData()
}
}
-TTableWindowData::value_type ORelationController::existsTable(const OUString& _rComposedTableName) const
+TTableWindowData::value_type ORelationController::existsTable(std::u16string_view _rComposedTableName) const
{
::comphelper::UStringMixEqual bCase(true);
for (auto const& elem : m_vTableData)
diff --git a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx
index 014579cf7c7f..161702f08196 100644
--- a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx
@@ -24,10 +24,6 @@
using namespace ::dbaui;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::container;
ORelationDesignView::ORelationDesignView(vcl::Window* _pParent, ORelationController& _rController,const Reference< XComponentContext >& _rxContext)
:OJoinDesignView( _pParent, _rController, _rxContext )
@@ -51,7 +47,7 @@ void ORelationDesignView::initialize()
bool ORelationDesignView::PreNotify( NotifyEvent& rNEvt )
{
bool bDone = false;
- if(rNEvt.GetType() == MouseNotifyEvent::GETFOCUS)
+ if(rNEvt.GetType() == NotifyEventType::GETFOCUS)
{
if(m_pTableView && !m_pTableView->HasChildPathFocus())
{
diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
index 9423d1a8470c..9c6b08e1d7ce 100644
--- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <connectivity/dbtools.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <helpids.h>
#include <RelationDesignView.hxx>
#include <JoinController.hxx>
@@ -73,7 +74,7 @@ void ORelationTableView::dispose()
{
if ( m_pContainerListener.is() )
m_pContainerListener->dispose();
- m_pExistingConnection.clear();
+ m_pExistingConnection.reset();
OJoinTableView::dispose();
}
@@ -98,7 +99,7 @@ void ORelationTableView::ReSync()
TTableWindowData::const_reverse_iterator aIter = rTabWinDataList.rbegin();
for(;aIter != rTabWinDataList.rend();++aIter)
{
- TTableWindowData::value_type pData = *aIter;
+ const TTableWindowData::value_type& pData = *aIter;
VclPtr<OTableWindow> pTabWin = createWindow(pData);
if (!pTabWin->Init())
@@ -107,9 +108,10 @@ void ORelationTableView::ReSync()
// it should be cleaned up, including its data in the document
pTabWin->clearListBox();
pTabWin.disposeAndClear();
- arrInvalidTables.push_back(pData->GetTableName());
+ // get the full name of the tables to ensure uniqueness across catalogs and schema
+ arrInvalidTables.push_back(pData->GetComposedName());
- rTabWinDataList.erase( std::remove(rTabWinDataList.begin(), rTabWinDataList.end(), *aIter), rTabWinDataList.end());
+ std::erase(rTabWinDataList, *aIter);
continue;
}
@@ -131,15 +133,15 @@ void ORelationTableView::ReSync()
if ( !arrInvalidTables.empty() )
{
// do the tables to the connection exist?
- OUString strTabExistenceTest = pTabConnData->getReferencingTable()->GetTableName();
+ OUString strTabExistenceTest = pTabConnData->getReferencingTable()->GetComposedName();
bool bInvalid = std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
- strTabExistenceTest = pTabConnData->getReferencedTable()->GetTableName();
+ strTabExistenceTest = pTabConnData->getReferencedTable()->GetComposedName();
bInvalid = bInvalid || std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
if (bInvalid)
{
// no -> bad luck, the connection is gone
- rTabConnDataList.erase( std::remove(rTabConnDataList.begin(), rTabConnDataList.end(), *aConIter), rTabConnDataList.end() );
+ std::erase(rTabConnDataList, *aConIter);
continue;
}
}
@@ -190,7 +192,7 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const
pTabConnData->SetConnLine( 0, sSourceFieldName, sDestFieldName );
if ( bAskUser || m_pExistingConnection )
- m_pCurrentlyTabConnData = pTabConnData; // this implies that we ask the user what to do
+ m_pCurrentlyTabConnData = std::move(pTabConnData); // this implies that we ask the user what to do
else
{
try
@@ -208,7 +210,7 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const
}
catch(const Exception&)
{
- OSL_FAIL("ORelationTableView::AddConnection: Exception occurred!");
+ TOOLS_WARN_EXCEPTION( "dbaccess", "ORelationTableView::AddConnection");
}
}
}
@@ -269,7 +271,7 @@ bool ORelationTableView::RemoveConnection(VclPtr<OTableConnection>& rConn, bool
}
catch(Exception&)
{
- OSL_FAIL("ORelationTableView::RemoveConnection: Something other than SQLException occurred!");
+ TOOLS_WARN_EXCEPTION( "dbaccess", "ORelationTableView::RemoveConnection: Something other than SQLException occurred!");
}
return false;
}
@@ -289,7 +291,8 @@ void ORelationTableView::AddTabWin(const OUString& _rComposedName, const OUStrin
}
// enter the new data structure into DocShell
- TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName ));
+ // show the table's full name as window name to ensure uniqueness across catalogs and schema
+ TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName, _rComposedName ));
pNewTabWinData->ShowAll(false);
// link new window into the window list
@@ -308,7 +311,7 @@ void ORelationTableView::AddTabWin(const OUString& _rComposedName, const OUStrin
if ( m_pAccessible )
m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
Any(),
- makeAny(pNewTabWin->GetAccessible()));
+ Any(pNewTabWin->GetAccessible()));
}
else
{