summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/app/AppControllerDnD.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/app/AppControllerDnD.cxx')
-rw-r--r--dbaccess/source/ui/app/AppControllerDnD.cxx114
1 files changed, 88 insertions, 26 deletions
diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx
index 6b0a17d05446..73af7c3514cf 100644
--- a/dbaccess/source/ui/app/AppControllerDnD.cxx
+++ b/dbaccess/source/ui/app/AppControllerDnD.cxx
@@ -49,12 +49,10 @@
#include <connectivity/dbtools.hxx>
#include <dbexchange.hxx>
#include <UITools.hxx>
-#include <algorithm>
-#include <iterator>
#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
#include <svtools/querydelete.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <osl/diagnose.h>
#include <defaultobjectnamecheck.hxx>
#include <osl/mutex.hxx>
@@ -76,7 +74,6 @@ using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::ucb;
-using namespace ::com::sun::star::util;
void OApplicationController::deleteTables(const std::vector< OUString>& _rList)
{
@@ -95,7 +92,7 @@ void OApplicationController::deleteTables(const std::vector< OUString>& _rList)
std::vector< OUString>::const_iterator aEnd = _rList.end();
for (std::vector< OUString>::const_iterator aIter = _rList.begin(); aIter != aEnd; ++aIter)
{
- OUString sTableName = *aIter;
+ const OUString& sTableName = *aIter;
sal_Int32 nResult = RET_YES;
if ( bConfirm )
@@ -316,7 +313,8 @@ const SharedConnection& OApplicationController::ensureConnection( ::dbtools::SQL
SolarMutexGuard aSolarGuard;
OUString sConnectingContext(DBA_RES(STR_COULDNOTCONNECT_DATASOURCE));
- sConnectingContext = sConnectingContext.replaceFirst("$name$", getStrippedDatabaseName());
+ OUString sDatabaseName;
+ sConnectingContext = sConnectingContext.replaceFirst("$name$", ::dbaui::getStrippedDatabaseName(m_xDataSource, sDatabaseName));
// do the connection *without* holding getMutex() to avoid deadlock
// when we are not in the main thread and we need username/password
@@ -365,7 +363,7 @@ const SharedConnection& OApplicationController::ensureConnection( ::dbtools::SQL
{
if ( _pErrorInfo )
{
- *_pErrorInfo = aError;
+ *_pErrorInfo = std::move(aError);
}
else
{
@@ -482,15 +480,15 @@ std::unique_ptr< OLinkedDocumentsAccess > OApplicationController::getDocumentsAc
return pDocuments;
}
-TransferableHelper* OApplicationController::copyObject()
+bool OApplicationController::copySQLObject(ODataClipboard& rExchange)
{
+ bool bSuccess = false;
try
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getMutex() );
ElementType eType = getContainer()->getElementType();
- TransferableHelper* pData = nullptr;
switch( eType )
{
case E_TABLE:
@@ -508,15 +506,42 @@ TransferableHelper* OApplicationController::copyObject()
if ( eType == E_TABLE )
{
- pData = new ODataClipboard(sDataSource, CommandType::TABLE, sName, xConnection, getNumberFormatter(xConnection, getORB()), getORB());
+ rExchange.Update(sDataSource, CommandType::TABLE, sName, xConnection, getNumberFormatter(xConnection, getORB()), getORB());
}
else
{
- pData = new ODataClipboard(sDataSource, CommandType::QUERY, sName, getNumberFormatter(xConnection, getORB()), getORB());
+ rExchange.Update(sDataSource, CommandType::QUERY, sName, getNumberFormatter(xConnection, getORB()), getORB());
}
+ bSuccess = true;
}
+ break;
}
+ default:
break;
+ }
+ }
+ catch(const SQLException&)
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("dbaccess");
+ }
+ return bSuccess;
+}
+
+bool OApplicationController::copyDocObject(svx::OComponentTransferable& rExchange)
+{
+ bool bSuccess = false;
+ try
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ElementType eType = getContainer()->getElementType();
+ switch( eType )
+ {
case E_FORM:
case E_REPORT:
{
@@ -526,16 +551,56 @@ TransferableHelper* OApplicationController::copyObject()
if ( xElements.is() && !aList.empty() )
{
Reference< XContent> xContent(xElements->getByHierarchicalName(*aList.begin()),UNO_QUERY);
- pData = new OComponentTransferable( getDatabaseName(), xContent );
+ rExchange.Update(getDatabaseName(), xContent);
+ bSuccess = true;
}
+ break;
}
- break;
default:
break;
}
+ }
+ catch(const SQLException&)
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("dbaccess");
+ }
+ return bSuccess;
+}
- // the ownership goes to ODataClipboards
- return pData;
+rtl::Reference<TransferableHelper> OApplicationController::copyObject()
+{
+ try
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ElementType eType = getContainer()->getElementType();
+ switch( eType )
+ {
+ case E_TABLE:
+ case E_QUERY:
+ {
+ rtl::Reference<ODataClipboard> xExchange(new ODataClipboard);
+ if (copySQLObject(*xExchange))
+ return xExchange;
+ break;
+ }
+ case E_FORM:
+ case E_REPORT:
+ {
+ rtl::Reference<svx::OComponentTransferable> xExchange(new svx::OComponentTransferable);
+ if (copyDocObject(*xExchange))
+ return xExchange;
+ break;
+ }
+ break;
+ default:
+ break;
+ }
}
catch(const SQLException&)
{
@@ -679,11 +744,11 @@ bool OApplicationController::paste( ElementType _eType, const svx::ODataAccessDe
::comphelper::copyProperties(xQuery,xNewQuery);
else
{
- xNewQuery->setPropertyValue(PROPERTY_COMMAND,makeAny(sCommand));
- xNewQuery->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,makeAny(bEscapeProcessing));
+ xNewQuery->setPropertyValue(PROPERTY_COMMAND,Any(sCommand));
+ xNewQuery->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,Any(bEscapeProcessing));
}
// insert
- xDestQueries->insertByName( sTargetName, makeAny(xNewQuery) );
+ xDestQueries->insertByName( sTargetName, Any(xNewQuery) );
xNewQuery.set(xDestQueries->getByName( sTargetName),UNO_QUERY);
if ( xQuery.is() && xNewQuery.is() )
{
@@ -699,12 +764,9 @@ bool OApplicationController::paste( ElementType _eType, const svx::ODataAccessDe
{
Reference<XPropertySet> xDstProp(xFac->createDataDescriptor());
- Sequence< OUString> aSeq = xSrcNameAccess->getElementNames();
- const OUString* pIter = aSeq.getConstArray();
- const OUString* pEnd = pIter + aSeq.getLength();
- for( ; pIter != pEnd ; ++pIter)
+ for (auto& name : xSrcNameAccess->getElementNames())
{
- Reference<XPropertySet> xSrcProp(xSrcNameAccess->getByName(*pIter),UNO_QUERY);
+ Reference<XPropertySet> xSrcProp(xSrcNameAccess->getByName(name),UNO_QUERY);
::comphelper::copyProperties(xSrcProp,xDstProp);
xAppend->appendByDescriptor(xDstProp);
}
@@ -721,7 +783,7 @@ bool OApplicationController::paste( ElementType _eType, const svx::ODataAccessDe
{
Reference<XContent> xContent;
_rPasteData[DataAccessDescriptorProperty::Component] >>= xContent;
- return insertHierachyElement(_eType,_sParentFolder,Reference<XNameAccess>(xContent,UNO_QUERY).is(),xContent,_bMove);
+ return insertHierarchyElement(_eType,_sParentFolder,Reference<XNameAccess>(xContent,UNO_QUERY).is(),xContent,_bMove);
}
}
catch(const SQLException&) { showError( SQLExceptionInfo( ::cppu::getCaughtException() ) ); }
@@ -787,10 +849,10 @@ IMPL_LINK_NOARG( OApplicationController, OnAsyncDrop, void*, void )
std::vector< OUString> aList;
sal_Int32 nIndex = 0;
OUString sName = xContent->getIdentifier()->getContentIdentifier();
- OUString sErase = sName.getToken(0,'/',nIndex); // we don't want to have the "private:forms" part
+ std::u16string_view sErase = o3tl::getToken(sName,0,'/',nIndex); // we don't want to have the "private:forms" part
if ( nIndex != -1 )
{
- aList.push_back(sName.copy(sErase.getLength() + 1));
+ aList.push_back(sName.copy(sErase.size() + 1));
deleteObjects( m_aAsyncDrop.nType, aList, false );
}
}