1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "AppController.hxx"
31 #include <comphelper/sequence.hxx>
32 #include <comphelper/property.hxx>
33 #include "dbustrings.hrc"
34 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
35 #include <com/sun/star/sdbcx/XAppend.hpp>
36 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
37 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
38 #include <com/sun/star/container/XNameContainer.hpp>
39 #include <com/sun/star/uno/XNamingService.hpp>
40 #include <com/sun/star/sdbc/XDataSource.hpp>
41 #include <com/sun/star/frame/XStorable.hpp>
42 #include <com/sun/star/container/XChild.hpp>
43 #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
44 #include <com/sun/star/sdbc/DataType.hpp>
45 #include <com/sun/star/sdb/CommandType.hpp>
46 #include <com/sun/star/sdb/XBookmarksSupplier.hpp>
47 #include <com/sun/star/sdb/SQLContext.hpp>
48 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
49 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
50 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
51 #include <com/sun/star/sdbcx/XDrop.hpp>
52 #include <unotools/ucbhelper.hxx>
53 #include "dlgsave.hxx"
54 #include <comphelper/types.hxx>
55 #include <vcl/msgbox.hxx>
56 #include <cppuhelper/typeprovider.hxx>
57 #include <cppuhelper/exc_hlp.hxx>
58 #include <connectivity/dbexception.hxx>
59 #include <vcl/waitobj.hxx>
60 #include <rtl/ustrbuf.hxx>
61 #include "AppView.hxx"
62 #include <svx/dataaccessdescriptor.hxx>
63 #include <svx/dbaobjectex.hxx>
64 #include "browserids.hxx"
65 #include "dbu_reghelper.hxx"
66 #include "dbu_app.hrc"
67 #include <vcl/menu.hxx>
68 #include <comphelper/uno3.hxx>
69 #include <vcl/svapp.hxx>
70 #include <svtools/svlbitm.hxx>
71 #include "listviewitems.hxx"
72 #include "AppDetailView.hxx"
73 #include "linkeddocuments.hxx"
74 #include <vcl/lstbox.hxx>
75 #include <connectivity/dbtools.hxx>
76 #include "sqlmessage.hxx"
77 #include <tools/string.hxx>
78 #include "dbexchange.hxx"
79 #include "UITools.hxx"
81 #include <svtools/svtreebx.hxx>
82 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
83 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
84 #include <unotools/pathoptions.hxx>
85 #include <sfx2/docfilt.hxx>
86 #include <svtools/fileview.hxx>
87 #include <tools/diagnose_ex.h>
88 #include <osl/diagnose.h>
89 #include "defaultobjectnamecheck.hxx"
90 #include <osl/mutex.hxx>
91 #include "subcomponentmanager.hxx"
93 //........................................................................
96 //........................................................................
97 using namespace ::dbtools
;
98 using namespace ::svx
;
99 using namespace ::svtools
;
100 using namespace ::com::sun::star::uno
;
101 using namespace ::com::sun::star::task
;
102 using namespace ::com::sun::star::beans
;
103 using namespace ::com::sun::star::lang
;
104 using namespace ::com::sun::star::container
;
105 using namespace ::com::sun::star::sdb
;
106 using namespace ::com::sun::star::sdbc
;
107 using namespace ::com::sun::star::sdbcx
;
108 using namespace ::com::sun::star::frame
;
109 using namespace ::com::sun::star::ucb
;
110 using namespace ::com::sun::star::util
;
112 // -----------------------------------------------------------------------------
113 void OApplicationController::deleteTables(const ::std::vector
< ::rtl::OUString
>& _rList
)
115 SharedConnection
xConnection( ensureConnection() );
117 Reference
<XTablesSupplier
> xSup(xConnection
,UNO_QUERY
);
118 OSL_ENSURE(xSup
.is(),"OApplicationController::deleteTable: no XTablesSuppier!");
121 Reference
<XNameAccess
> xTables
= xSup
->getTables();
122 Reference
<XDrop
> xDrop(xTables
,UNO_QUERY
);
125 bool bConfirm
= true;
126 ::std::vector
< ::rtl::OUString
>::const_iterator aEnd
= _rList
.end();
127 for (::std::vector
< ::rtl::OUString
>::const_iterator aIter
= _rList
.begin(); aIter
!= aEnd
; ++aIter
)
129 ::rtl::OUString sTableName
= *aIter
;
131 sal_Int32 nResult
= RET_YES
;
133 nResult
= ::dbaui::askForUserAction(getView(),STR_TITLE_CONFIRM_DELETION
,STR_QUERY_DELETE_TABLE
,_rList
.size() > 1 && (aIter
+1) != _rList
.end(),sTableName
);
135 bool bUserConfirmedDelete
=
136 ( RET_YES
== nResult
)
137 || ( RET_ALL
== nResult
);
138 if ( bUserConfirmedDelete
&& m_pSubComponentManager
->closeSubFrames( sTableName
, E_TABLE
) )
140 SQLExceptionInfo aErrorInfo
;
143 if ( xTables
->hasByName(sTableName
) )
144 xDrop
->dropByName(sTableName
);
147 Reference
<XViewsSupplier
> xViewsSup(xConnection
,UNO_QUERY
);
149 Reference
<XNameAccess
> xViews
;
150 if ( xViewsSup
.is() )
152 xViews
= xViewsSup
->getViews();
153 if ( xViews
.is() && xViews
->hasByName(sTableName
) )
155 xDrop
.set(xViews
,UNO_QUERY
);
157 xDrop
->dropByName(sTableName
);
162 catch(SQLContext
& e
) { aErrorInfo
= e
; }
163 catch(SQLWarning
& e
) { aErrorInfo
= e
; }
164 catch(SQLException
& e
) { aErrorInfo
= e
; }
165 catch(WrappedTargetException
& e
)
168 if(e
.TargetException
>>= aSql
)
171 OSL_FAIL("OApplicationController::implDropTable: something strange happended!");
173 catch( const Exception
& )
175 DBG_UNHANDLED_EXCEPTION();
178 if ( aErrorInfo
.isValid() )
179 showError(aErrorInfo
);
181 if ( RET_ALL
== nResult
)
190 String
sMessage(ModuleRes(STR_MISSING_TABLES_XDROP
));
191 ErrorBox
aError(getView(), WB_OK
, sMessage
);
196 // -----------------------------------------------------------------------------
197 void OApplicationController::deleteObjects( ElementType _eType
, const ::std::vector
< ::rtl::OUString
>& _rList
, bool _bConfirm
)
199 Reference
< XNameContainer
> xNames( getElements( _eType
), UNO_QUERY
);
200 Reference
< XHierarchicalNameContainer
> xHierarchyName( xNames
, UNO_QUERY
);
203 rtl::OString sDialogPosition
;
204 svtools::QueryDeleteResult_Impl eResult
= _bConfirm
? svtools::QUERYDELETE_YES
: svtools::QUERYDELETE_ALL
;
206 // The list of elements to delete is allowed to contain related elements: A given element may
207 // be the ancestor or child of another element from the list.
208 // We want to ensure that ancestors get deleted first, so we normalize the list in this respect.
210 ::std::set
< ::rtl::OUString
> aDeleteNames
;
211 // Note that this implicitly uses ::std::less< ::rtl::OUString > a comparison operation, which
212 // results in lexicographical order, which is exactly what we need, because "foo" is *before*
213 // any "foo/bar" in this order.
215 _rList
.begin(), _rList
.end(),
216 ::std::insert_iterator
< ::std::set
< ::rtl::OUString
> >( aDeleteNames
, aDeleteNames
.begin() )
219 ::std::set
< ::rtl::OUString
>::size_type nCount
= aDeleteNames
.size();
220 for ( ::std::set
< ::rtl::OUString
>::size_type nObjectsLeft
= nCount
; !aDeleteNames
.empty(); )
222 ::std::set
< ::rtl::OUString
>::iterator aThisRound
= aDeleteNames
.begin();
224 if ( eResult
!= svtools::QUERYDELETE_ALL
)
226 svtools::QueryDeleteDlg_Impl
aDlg( getView(), *aThisRound
);
228 if ( !sDialogPosition
.isEmpty() )
229 aDlg
.SetWindowState( sDialogPosition
);
231 if ( nObjectsLeft
> 1 )
232 aDlg
.EnableAllButton();
234 if ( aDlg
.Execute() == RET_OK
)
235 eResult
= aDlg
.GetResult();
239 sDialogPosition
= aDlg
.GetWindowState( );
242 bool bSuccess
= false;
244 bool bUserConfirmedDelete
=
245 ( eResult
== svtools::QUERYDELETE_ALL
)
246 || ( eResult
== svtools::QUERYDELETE_YES
);
248 if ( bUserConfirmedDelete
249 && ( ( _eType
== E_QUERY
) ? m_pSubComponentManager
->closeSubFrames( *aThisRound
, _eType
) : true )
254 if ( xHierarchyName
.is() )
255 xHierarchyName
->removeByHierarchicalName( *aThisRound
);
257 xNames
->removeByName( *aThisRound
);
261 // now that we removed the element, care for all it's child elements
262 // which may also be a part of the list
264 OSL_ENSURE( aThisRound
->getLength() - 1 >= 0, "OApplicationController::deleteObjects: empty name?" );
265 ::rtl::OUStringBuffer
sSmallestSiblingName( *aThisRound
);
266 sSmallestSiblingName
.append( (sal_Unicode
)( '/' + 1) );
268 ::std::set
< ::rtl::OUString
>::iterator aUpperChildrenBound
= aDeleteNames
.lower_bound( sSmallestSiblingName
.makeStringAndClear() );
269 for ( ::std::set
< ::rtl::OUString
>::iterator aObsolete
= aThisRound
;
270 aObsolete
!= aUpperChildrenBound
;
273 #if OSL_DEBUG_LEVEL > 0
274 ::rtl::OUString sObsoleteName
= *aObsolete
;
276 ::std::set
< ::rtl::OUString
>::iterator aNextObsolete
= aObsolete
; ++aNextObsolete
;
277 aDeleteNames
.erase( aObsolete
);
279 aObsolete
= aNextObsolete
;
282 catch(const SQLException
&)
284 showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
286 catch(const WrappedTargetException
& e
)
289 if ( e
.TargetException
>>= aSql
)
290 showError( SQLExceptionInfo( e
.TargetException
) );
292 OSL_FAIL( "OApplicationController::deleteObjects: something strange happended!" );
294 catch( const Exception
& )
296 DBG_UNHANDLED_EXCEPTION();
302 // okay, this object could not be deleted (or the user did not want to delete it),
303 // but continue with the rest
304 aDeleteNames
.erase( aThisRound
);
310 // -----------------------------------------------------------------------------
311 void OApplicationController::deleteEntries()
313 SolarMutexGuard aSolarGuard
;
314 ::osl::MutexGuard
aGuard( getMutex() );
316 if ( getContainer() )
318 ::std::vector
< ::rtl::OUString
> aList
;
319 getSelectionElementNames(aList
);
320 ElementType eType
= getContainer()->getElementType();
327 deleteObjects( E_QUERY
, aList
, true );
330 deleteObjects( E_FORM
, aList
, true );
333 deleteObjects( E_REPORT
, aList
, true );
340 // -----------------------------------------------------------------------------
341 const SharedConnection
& OApplicationController::ensureConnection( ::dbtools::SQLExceptionInfo
* _pErrorInfo
)
343 SolarMutexGuard aSolarGuard
;
344 ::osl::MutexGuard
aGuard( getMutex() );
346 if ( !m_xDataSourceConnection
.is() )
348 WaitObject
aWO(getView());
349 String
sConnectingContext( ModuleRes( STR_COULDNOTCONNECT_DATASOURCE
) );
350 sConnectingContext
.SearchAndReplaceAscii("$name$", getStrippedDatabaseName());
352 m_xDataSourceConnection
.reset( connect( getDatabaseName(), sConnectingContext
, _pErrorInfo
) );
353 if ( m_xDataSourceConnection
.is() )
355 SQLExceptionInfo aError
;
358 m_xMetaData
= m_xDataSourceConnection
->getMetaData();
360 catch( const SQLException
& )
362 aError
= ::cppu::getCaughtException();
364 catch( const Exception
& )
366 DBG_UNHANDLED_EXCEPTION();
368 if ( aError
.isValid() )
372 *_pErrorInfo
= aError
;
381 return m_xDataSourceConnection
;
383 // -----------------------------------------------------------------------------
384 sal_Bool
OApplicationController::isDataSourceReadOnly() const
386 Reference
<XStorable
> xStore(m_xModel
,UNO_QUERY
);
387 return !xStore
.is() || xStore
->isReadonly();
389 // -----------------------------------------------------------------------------
390 sal_Bool
OApplicationController::isConnectionReadOnly() const
392 sal_Bool bIsConnectionReadOnly
= sal_True
;
393 if ( m_xMetaData
.is() )
397 bIsConnectionReadOnly
= m_xMetaData
->isReadOnly();
399 catch(const SQLException
&)
401 DBG_UNHANDLED_EXCEPTION();
404 // TODO check configuration
405 return bIsConnectionReadOnly
;
407 // -----------------------------------------------------------------------------
408 Reference
< XNameAccess
> OApplicationController::getElements( ElementType _eType
)
410 Reference
< XNameAccess
> xElements
;
417 Reference
< XReportDocumentsSupplier
> xSupp( m_xModel
, UNO_QUERY_THROW
);
418 xElements
.set( xSupp
->getReportDocuments(), UNO_SET_THROW
);
424 Reference
< XFormDocumentsSupplier
> xSupp( m_xModel
, UNO_QUERY_THROW
);
425 xElements
.set( xSupp
->getFormDocuments(), UNO_SET_THROW
);
431 xElements
.set( getQueryDefintions(), UNO_QUERY_THROW
);
437 if ( m_xDataSourceConnection
.is() )
439 Reference
< XTablesSupplier
> xSup( getConnection(), UNO_QUERY_THROW
);
440 xElements
.set( xSup
->getTables(), UNO_SET_THROW
);
449 catch(const Exception
&)
451 DBG_UNHANDLED_EXCEPTION();
456 // -----------------------------------------------------------------------------
457 void OApplicationController::getSelectionElementNames(::std::vector
< ::rtl::OUString
>& _rNames
) const
459 SolarMutexGuard aSolarGuard
;
460 ::osl::MutexGuard
aGuard( getMutex() );
462 OSL_ENSURE(getContainer(),"View isn't valid! -> GPF");
464 getContainer()->getSelectionElementNames( _rNames
);
467 // -----------------------------------------------------------------------------
468 SAL_WNODEPRECATED_DECLARATIONS_PUSH
469 ::std::auto_ptr
< OLinkedDocumentsAccess
> OApplicationController::getDocumentsAccess( ElementType _eType
)
471 OSL_ENSURE( ( _eType
== E_TABLE
) || ( _eType
== E_QUERY
) || ( _eType
== E_FORM
) || ( _eType
== E_REPORT
),
472 "OApplicationController::getDocumentsAccess: only forms and reports are supported here!" );
474 SharedConnection
xConnection( ensureConnection() );
475 Reference
< XNameAccess
> xDocContainer
;
477 if ( ( _eType
== E_FORM
) | ( _eType
== E_REPORT
) )
479 xDocContainer
.set( getElements( _eType
) );
480 OSL_ENSURE( xDocContainer
.is(), "OApplicationController::getDocumentsAccess: invalid container!" );
483 ::std::auto_ptr
< OLinkedDocumentsAccess
> pDocuments( new OLinkedDocumentsAccess(
484 getView(), this, getORB(), xDocContainer
, xConnection
, getDatabaseName()
488 SAL_WNODEPRECATED_DECLARATIONS_POP
490 // -----------------------------------------------------------------------------
491 TransferableHelper
* OApplicationController::copyObject()
495 SolarMutexGuard aSolarGuard
;
496 ::osl::MutexGuard
aGuard( getMutex() );
498 ElementType eType
= getContainer()->getElementType();
499 TransferableHelper
* pData
= NULL
;
505 SharedConnection
xConnection( ensureConnection() );
506 Reference
< XDatabaseMetaData
> xMetaData
;
507 if ( xConnection
.is() )
508 xMetaData
= xConnection
->getMetaData();
510 ::rtl::OUString sName
= getContainer()->getQualifiedName( NULL
);
511 if ( !sName
.isEmpty() )
513 ::rtl::OUString sDataSource
= getDatabaseName();
515 if ( eType
== E_TABLE
)
517 pData
= new ODataClipboard(sDataSource
, CommandType::TABLE
, sName
, xConnection
, getNumberFormatter(xConnection
,getORB()), getORB());
521 pData
= new ODataClipboard(sDataSource
, CommandType::QUERY
, sName
, getNumberFormatter(xConnection
,getORB()), getORB());
529 ::std::vector
< ::rtl::OUString
> aList
;
530 getSelectionElementNames(aList
);
531 Reference
< XHierarchicalNameAccess
> xElements(getElements(eType
),UNO_QUERY
);
532 if ( xElements
.is() && !aList
.empty() )
534 Reference
< XContent
> xContent(xElements
->getByHierarchicalName(*aList
.begin()),UNO_QUERY
);
535 pData
= new OComponentTransferable( getDatabaseName(), xContent
);
543 // the owner ship goes to ODataClipboards
546 catch(const SQLException
&)
548 showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
550 catch( const Exception
& )
552 DBG_UNHANDLED_EXCEPTION();
556 // -----------------------------------------------------------------------------
557 sal_Bool
OApplicationController::paste( ElementType _eType
,const ::svx::ODataAccessDescriptor
& _rPasteData
,const String
& _sParentFolder
,sal_Bool _bMove
)
561 if ( _eType
== E_QUERY
)
563 sal_Int32 nCommandType
= CommandType::TABLE
;
564 if ( _rPasteData
.has(daCommandType
) )
565 _rPasteData
[daCommandType
] >>= nCommandType
;
567 if ( CommandType::QUERY
== nCommandType
|| CommandType::COMMAND
== nCommandType
)
569 // read all necessary data
571 ::rtl::OUString sCommand
;
572 sal_Bool bEscapeProcessing
= sal_True
;
574 _rPasteData
[daCommand
] >>= sCommand
;
575 if ( _rPasteData
.has(daEscapeProcessing
) )
576 _rPasteData
[daEscapeProcessing
] >>= bEscapeProcessing
;
578 // plausibility check
579 sal_Bool bValidDescriptor
= sal_False
;
580 ::rtl::OUString sDataSourceName
= _rPasteData
.getDataSource();
581 if (CommandType::QUERY
== nCommandType
)
582 bValidDescriptor
= sDataSourceName
.getLength() && sCommand
.getLength();
583 else if (CommandType::COMMAND
== nCommandType
)
584 bValidDescriptor
= !sCommand
.isEmpty();
585 if (!bValidDescriptor
)
587 OSL_FAIL("OApplicationController::paste: invalid descriptor!");
591 // the target object name (as we'll suggest it to the user)
592 ::rtl::OUString sTargetName
;
595 if ( CommandType::QUERY
== nCommandType
)
596 sTargetName
= sCommand
;
598 if ( sTargetName
.isEmpty() )
600 String sDefaultName
= String( ModuleRes( STR_QRY_TITLE
) );
601 sDefaultName
= sDefaultName
.GetToken( 0, ' ' );
603 Reference
< XNameAccess
> xQueries( getQueryDefintions(), UNO_QUERY_THROW
);
604 sTargetName
= ::dbtools::createUniqueName( xQueries
, sDefaultName
, sal_False
);
607 catch(const Exception
&)
609 DBG_UNHANDLED_EXCEPTION();
612 Reference
< XPropertySet
> xQuery
;
613 if (CommandType::QUERY
== nCommandType
)
615 // need to extract the statement and the escape processing flag from the query object
616 sal_Bool bSuccess
= sal_False
;
619 // the concrete query
620 Reference
< XQueryDefinitionsSupplier
> xSourceQuerySup(
621 getDataSourceByName( sDataSourceName
, getView(), getORB(), NULL
),
623 Reference
< XNameAccess
> xQueries( xSourceQuerySup
->getQueryDefinitions(), UNO_SET_THROW
);
624 if ( xQueries
->hasByName( sCommand
) )
626 xQuery
.set( xQueries
->getByName(sCommand
), UNO_QUERY_THROW
);
630 catch(SQLException
&) { throw; } // caught and handled by the outer catch
631 catch( const Exception
& )
633 DBG_UNHANDLED_EXCEPTION();
638 OSL_FAIL("OApplicationController::paste: could not extract the source query object!");
639 // TODO: maybe this is worth an error message to be displayed to the user ....
645 Reference
< XNameContainer
> xDestQueries(getQueryDefintions(), UNO_QUERY
);
646 Reference
< XSingleServiceFactory
> xQueryFactory(xDestQueries
, UNO_QUERY
);
647 if (!xQueryFactory
.is())
649 OSL_FAIL("OApplicationController::paste: invalid destination query container!");
653 // here we have everything needed to create a new query object ...
654 // ... ehm, except a new name
657 DynamicTableOrQueryNameCheck
aNameChecker( getConnection(), CommandType::QUERY
);
658 ::dbtools::SQLExceptionInfo aDummy
;
659 bool bNeedAskForName
= ( sCommand
.isEmpty() )
660 /* we did not have a source name, so the target name was auto-generated */
661 || ( !aNameChecker
.isNameValid( sTargetName
, aDummy
) );
662 /* name is invalid in the target DB (e.g. because it already
663 has a /table/ with that name) */
664 if ( bNeedAskForName
)
666 OSaveAsDlg
aAskForName( getView(),
672 SAD_ADDITIONAL_DESCRIPTION
| SAD_TITLE_PASTE_AS
);
673 if ( RET_OK
!= aAskForName
.Execute() )
674 // cancelled by the user
676 sTargetName
= aAskForName
.getName();
679 // create a new object
680 Reference
< XPropertySet
> xNewQuery(xQueryFactory
->createInstance(), UNO_QUERY
);
681 OSL_ENSURE(xNewQuery
.is(), "OApplicationController::paste: invalid object created by factory!");
686 ::comphelper::copyProperties(xQuery
,xNewQuery
);
689 xNewQuery
->setPropertyValue(PROPERTY_COMMAND
,makeAny(sCommand
));
690 xNewQuery
->setPropertyValue(PROPERTY_ESCAPE_PROCESSING
,makeAny(bEscapeProcessing
));
693 xDestQueries
->insertByName( sTargetName
, makeAny(xNewQuery
) );
694 xNewQuery
.set(xDestQueries
->getByName( sTargetName
),UNO_QUERY
);
695 if ( xQuery
.is() && xNewQuery
.is() )
697 Reference
<XColumnsSupplier
> xSrcColSup(xQuery
,UNO_QUERY
);
698 Reference
<XColumnsSupplier
> xDstColSup(xNewQuery
,UNO_QUERY
);
699 if ( xSrcColSup
.is() && xDstColSup
.is() )
701 Reference
<XNameAccess
> xSrcNameAccess
= xSrcColSup
->getColumns();
702 Reference
<XNameAccess
> xDstNameAccess
= xDstColSup
->getColumns();
703 Reference
<XDataDescriptorFactory
> xFac(xDstNameAccess
,UNO_QUERY
);
704 Reference
<XAppend
> xAppend(xFac
,UNO_QUERY
);
705 if ( xSrcNameAccess
.is() && xDstNameAccess
.is() && xSrcNameAccess
->hasElements() && xAppend
.is() )
707 Reference
<XPropertySet
> xDstProp(xFac
->createDataDescriptor());
709 Sequence
< ::rtl::OUString
> aSeq
= xSrcNameAccess
->getElementNames();
710 const ::rtl::OUString
* pIter
= aSeq
.getConstArray();
711 const ::rtl::OUString
* pEnd
= pIter
+ aSeq
.getLength();
712 for( ; pIter
!= pEnd
; ++pIter
)
714 Reference
<XPropertySet
> xSrcProp(xSrcNameAccess
->getByName(*pIter
),UNO_QUERY
);
715 ::comphelper::copyProperties(xSrcProp
,xDstProp
);
716 xAppend
->appendByDescriptor(xDstProp
);
724 OSL_TRACE("There should be a sequence in it!");
727 else if ( _rPasteData
.has(daComponent
) ) // forms or reports
729 Reference
<XContent
> xContent
;
730 _rPasteData
[daComponent
] >>= xContent
;
731 return insertHierachyElement(_eType
,_sParentFolder
,Reference
<XNameAccess
>(xContent
,UNO_QUERY
).is(),xContent
,_bMove
);
734 catch(const SQLException
&) { showError( SQLExceptionInfo( ::cppu::getCaughtException() ) ); }
735 catch(const Exception
& )
737 DBG_UNHANDLED_EXCEPTION();
741 // -----------------------------------------------------------------------------
742 Reference
<XNameContainer
> OApplicationController::getQueryDefintions() const
744 Reference
<XQueryDefinitionsSupplier
> xSet(m_xDataSource
,UNO_QUERY
);
745 Reference
<XNameContainer
> xNames
;
748 xNames
.set(xSet
->getQueryDefinitions(),UNO_QUERY
);
752 // -----------------------------------------------------------------------------
753 void OApplicationController::getSupportedFormats(ElementType _eType
,::std::vector
<SotFormatStringId
>& _rFormatIds
) const
758 _rFormatIds
.push_back(SOT_FORMATSTR_ID_DBACCESS_TABLE
);
759 _rFormatIds
.push_back(SOT_FORMAT_RTF
);
760 _rFormatIds
.push_back(SOT_FORMATSTR_ID_HTML
);
763 _rFormatIds
.push_back(SOT_FORMATSTR_ID_DBACCESS_QUERY
);
769 // -----------------------------------------------------------------------------
770 sal_Bool
OApplicationController::isTableFormat() const
772 return m_aTableCopyHelper
.isTableFormat(getViewClipboard());
774 // -----------------------------------------------------------------------------
775 IMPL_LINK( OApplicationController
, OnAsyncDrop
, void*, /*NOTINTERESTEDIN*/ )
778 SolarMutexGuard aSolarGuard
;
779 ::osl::MutexGuard
aGuard( getMutex() );
782 if ( m_aAsyncDrop
.nType
== E_TABLE
)
784 SharedConnection
xConnection( ensureConnection() );
785 if ( xConnection
.is() )
786 m_aTableCopyHelper
.asyncCopyTagTable( m_aAsyncDrop
, getDatabaseName(), xConnection
);
790 if ( paste(m_aAsyncDrop
.nType
,m_aAsyncDrop
.aDroppedData
,m_aAsyncDrop
.aUrl
,m_aAsyncDrop
.nAction
== DND_ACTION_MOVE
)
791 && m_aAsyncDrop
.nAction
== DND_ACTION_MOVE
)
793 Reference
<XContent
> xContent
;
794 m_aAsyncDrop
.aDroppedData
[daComponent
] >>= xContent
;
795 ::std::vector
< ::rtl::OUString
> aList
;
796 sal_Int32 nIndex
= 0;
797 ::rtl::OUString sName
= xContent
->getIdentifier()->getContentIdentifier();
798 ::rtl::OUString sErase
= sName
.getToken(0,'/',nIndex
); // we don't want to have the "private:forms" part
801 aList
.push_back(sName
.copy(sErase
.getLength() + 1));
802 deleteObjects( m_aAsyncDrop
.nType
, aList
, false );
807 m_aAsyncDrop
.aDroppedData
.clear();
811 //........................................................................
813 //........................................................................
816 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */