summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r--dbaccess/source/ui/app/AppController.cxx210
-rw-r--r--dbaccess/source/ui/app/AppController.hxx66
-rw-r--r--dbaccess/source/ui/app/AppControllerDnD.cxx75
-rw-r--r--dbaccess/source/ui/app/AppControllerGen.cxx181
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.cxx63
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.hxx12
-rw-r--r--dbaccess/source/ui/app/IApplicationController.hxx32
-rw-r--r--dbaccess/source/ui/app/makefile.mk5
-rw-r--r--dbaccess/source/ui/app/subcomponentmanager.cxx432
-rw-r--r--dbaccess/source/ui/app/subcomponentmanager.hxx115
-rw-r--r--dbaccess/source/ui/browser/brwctrlr.cxx6
-rw-r--r--dbaccess/source/ui/browser/dbloader.cxx4
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.cxx4
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.hxx2
-rw-r--r--dbaccess/source/ui/browser/dsbrowserDnD.cxx12
-rw-r--r--dbaccess/source/ui/browser/genericcontroller.cxx51
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx64
-rw-r--r--dbaccess/source/ui/control/dbtreelistbox.cxx108
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.src15
-rw-r--r--dbaccess/source/ui/dlg/paramdialog.cxx5
-rw-r--r--dbaccess/source/ui/inc/QueryDesignView.hxx13
-rw-r--r--dbaccess/source/ui/inc/QueryViewSwitch.hxx21
-rw-r--r--dbaccess/source/ui/inc/RTableConnectionData.hxx3
-rw-r--r--dbaccess/source/ui/inc/UITools.hxx8
-rw-r--r--dbaccess/source/ui/inc/WNameMatch.hxx4
-rw-r--r--dbaccess/source/ui/inc/datasourceconnector.hxx22
-rw-r--r--dbaccess/source/ui/inc/dbtreelistbox.hxx63
-rw-r--r--dbaccess/source/ui/inc/querycontainerwindow.hxx9
-rw-r--r--dbaccess/source/ui/inc/querycontroller.hxx11
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx7
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx21
-rw-r--r--dbaccess/source/ui/misc/WNameMatch.cxx4
-rw-r--r--dbaccess/source/ui/misc/databaseobjectview.cxx17
-rw-r--r--dbaccess/source/ui/misc/datasourceconnector.cxx94
-rw-r--r--dbaccess/source/ui/misc/dsmeta.cxx6
-rw-r--r--dbaccess/source/ui/misc/singledoccontroller.cxx65
-rw-r--r--dbaccess/source/ui/querydesign/JoinController.cxx2
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx55
-rw-r--r--dbaccess/source/ui/querydesign/QueryViewSwitch.cxx35
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx37
-rw-r--r--dbaccess/source/ui/querydesign/querycontainerwindow.cxx4
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx158
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx2
-rw-r--r--dbaccess/source/ui/uno/unoDirectSql.cxx2
44 files changed, 1317 insertions, 808 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 4c7c97054368..ccac5237d7dc 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -34,6 +34,7 @@
#include "AppController.hxx"
#include "dbustrings.hrc"
#include "advancedsettingsdlg.hxx"
+#include "subcomponentmanager.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/beans/NamedValue.hpp>
@@ -407,7 +408,8 @@ DBG_NAME(OApplicationController)
//--------------------------------------------------------------------
OApplicationController::OApplicationController(const Reference< XMultiServiceFactory >& _rxORB)
:OApplicationController_CBASE( _rxORB )
- ,m_aContextMenuInterceptors( m_aMutex )
+ ,m_aContextMenuInterceptors( getMutex() )
+ ,m_pSubComponentManager( new SubComponentManager( getSharedMutex() ) )
,m_aTableCopyHelper(this)
,m_pClipbordNotifier(NULL)
,m_nAsyncDrop(0)
@@ -417,7 +419,7 @@ OApplicationController::OApplicationController(const Reference< XMultiServiceFac
,m_eCurrentType(E_NONE)
,m_bNeedToReconnect(sal_False)
,m_bSuspended( sal_False )
- ,m_pSelectionNotifier( new SelectionNotifier( m_aMutex, *this ) )
+ ,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) )
{
DBG_CTOR(OApplicationController,NULL);
@@ -472,8 +474,7 @@ void SAL_CALL OApplicationController::disposing()
::std::for_each(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),XContainerFunctor(this));
m_aCurrentContainers.clear();
- m_aSpecialSubFrames.clear();
- m_aDocuments.clear();
+ m_pSubComponentManager->disposing();
m_pSelectionNotifier->disposing();
if ( getView() )
@@ -596,7 +597,7 @@ sal_Bool OApplicationController::Construct(Window* _pParent)
//--------------------------------------------------------------------
void SAL_CALL OApplicationController::disposing(const EventObject& _rSource) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
if ( xCon.is() )
{
@@ -622,22 +623,7 @@ void SAL_CALL OApplicationController::disposing(const EventObject& _rSource) thr
}
else
{
- Reference<XComponent> xComp(_rSource.Source,UNO_QUERY);
- Reference<XContainer> xContainer(_rSource.Source,UNO_QUERY);
- if ( xComp.is() )
- {
- TDocuments::iterator aFind = ::std::find_if(m_aDocuments.begin(),m_aDocuments.end(),
- ::std::compose1(::std::bind2nd(::std::equal_to<Reference<XComponent> >(),xComp),::std::select1st<TDocuments::value_type>()));
- if ( aFind != m_aDocuments.end() )
- m_aDocuments.erase(aFind);
-
- TFrames::iterator aFind2 = ::std::find_if(m_aSpecialSubFrames.begin(),m_aSpecialSubFrames.end(),
- ::std::compose1(::std::bind2nd(::std::equal_to<Reference<XComponent> >(),xComp),
- ::std::compose1(::std::select2nd<TTypeFrame>(),::std::select2nd<TFrames::value_type>())));
- if ( aFind2 != m_aSpecialSubFrames.end() )
- m_aSpecialSubFrames.erase(aFind2);
-
- }
+ Reference<XContainer> xContainer( _rSource.Source, UNO_QUERY );
if ( xContainer.is() )
{
TContainerVector::iterator aFind = ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer);
@@ -662,7 +648,7 @@ sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend) throw( Runt
}
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( getView() && getView()->IsInModalMode() )
return sal_False;
@@ -1150,7 +1136,7 @@ namespace
void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( isUserDefinedFeature( _nId ) )
{
@@ -1329,7 +1315,6 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa
lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
}
- m_sDatabaseName = ::rtl::OUString();
/*updateTitle();*/
m_bCurrentlyModified = sal_False;
InvalidateFeature(ID_BROWSER_SAVEDOC);
@@ -1425,7 +1410,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa
Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
- addDocumentListener( xComponent, NULL );
+ onDocumentOpened( ::rtl::OUString(), E_QUERY, E_OPEN_DESIGN, xComponent, NULL );
}
}
break;
@@ -1466,18 +1451,17 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa
InvalidateAll();
break;
case SID_DB_APP_DSRELDESIGN:
- if ( !impl_activateSubFrame_throw(::rtl::OUString(),SID_DB_APP_DSRELDESIGN,E_OPEN_DESIGN) )
+ if ( !m_pSubComponentManager->activateSubFrame( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN ) )
{
SharedConnection xConnection( ensureConnection() );
if ( xConnection.is() )
{
RelationDesigner aDesigner( getORB(), this, m_aCurrentFrame.getFrame() );
+
Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
- addDocumentListener( xComponent, NULL );
- m_aSpecialSubFrames.insert(TFrames::value_type(::rtl::OUString(),
- TTypeFrame(TTypeOpenMode(SID_DB_APP_DSRELDESIGN,E_OPEN_DESIGN),xComponent)));
- } // if ( xConnection.is() )
+ onDocumentOpened( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xComponent, NULL );
+ }
}
break;
case SID_DB_APP_DSUSERADMIN:
@@ -1676,7 +1660,7 @@ OApplicationView* OApplicationController::getContainer() const
void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
@@ -1712,7 +1696,7 @@ void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& _rE
void SAL_CALL OApplicationController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
@@ -1746,7 +1730,7 @@ void SAL_CALL OApplicationController::elementRemoved( const ContainerEvent& _rEv
void SAL_CALL OApplicationController::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
@@ -1971,16 +1955,15 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const
Reference< XComponent > xDefinition;
xRet = aHelper->open( _sName, xDefinition, _eOpenMode, _rAdditionalArguments );
- addDocumentListener(xRet,xDefinition);
+ onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition );
}
break;
case E_QUERY:
case E_TABLE:
{
- if ( !impl_activateSubFrame_throw(_sName,_eType,_eOpenMode) )
+ if ( !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode ) )
{
-
SharedConnection xConnection( ensureConnection() );
if ( !xConnection.is() )
break;
@@ -2017,9 +2000,7 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const
}
Reference< XComponent > xComponent( pDesigner->openExisting( aDataSource, _sName, aArguments.getPropertyValues() ), UNO_QUERY );
- addDocumentListener( xComponent, NULL );
- m_aSpecialSubFrames.insert(TFrames::value_type(_sName,
- TTypeFrame(TTypeOpenMode(_eType,_eOpenMode),xComponent)));
+ onDocumentOpened( _sName, _eType, _eOpenMode, xComponent, NULL );
}
}
break;
@@ -2066,7 +2047,7 @@ void OApplicationController::newElementWithPilot( ElementType _eType )
else
xComponent = aHelper->newFormWithPilot(xDefinition,nCommandType,sName);
- addDocumentListener(xComponent,xDefinition);
+ onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, xComponent, xDefinition );
}
}
break;
@@ -2076,12 +2057,13 @@ void OApplicationController::newElementWithPilot( ElementType _eType )
::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
if ( aHelper->isConnected() )
{
- Reference< XComponent > xComponent,xDefinition;
+ Reference< XComponent > xComponent;
if ( E_QUERY == _eType )
xComponent = aHelper->newQueryWithPilot();
else
xComponent = aHelper->newTableWithPilot();
- addDocumentListener(xComponent,xDefinition);
+
+ onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, xComponent, NULL );
}
}
break;
@@ -2107,7 +2089,7 @@ void OApplicationController::newElement( ElementType _eType, sal_Bool _bSQLView
sal_Int32 nCommandType = -1;
const ::rtl::OUString sName(getCurrentlySelectedName(nCommandType));
xComponent = aHelper->newDocument(_eType == E_FORM ? ID_FORM_NEW_TEXT : ID_REPORT_NEW_TEXT,xDefinition,nCommandType,sName);
- addDocumentListener(xComponent,xDefinition);
+ onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, xComponent, xDefinition );
}
}
break;
@@ -2129,7 +2111,7 @@ void OApplicationController::newElement( ElementType _eType, sal_Bool _bSQLView
Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
Reference< XComponent > xComponent( pDesigner->createNew( xDataSource ), UNO_QUERY );
- addDocumentListener(xComponent,NULL);
+ onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, xComponent, NULL );
}
}
break;
@@ -2163,7 +2145,7 @@ void OApplicationController::addContainerListener(const Reference<XNameAccess>&
void OApplicationController::renameEntry()
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
::std::vector< ::rtl::OUString> aList;
@@ -2311,68 +2293,59 @@ void OApplicationController::renameEntry()
DBG_UNHANDLED_EXCEPTION();
}
}
-// -----------------------------------------------------------------------------
-void OApplicationController::onEntryDeSelect(SvTreeListBox& /*_rTree*/)
-{
- SelectionGuard aSelGuard( *m_pSelectionNotifier );
- InvalidateAll();
-}
// -----------------------------------------------------------------------------
-void OApplicationController::onEntrySelect(SvLBoxEntry* _pEntry)
+void OApplicationController::onSelectionChanged()
{
InvalidateAll();
+ SelectionGuard aSelGuard( *m_pSelectionNotifier );
+
OApplicationView* pView = getContainer();
- if ( pView )
- {
- SelectionGuard aSelGuard( *m_pSelectionNotifier );
+ if ( !pView )
+ return;
+ if ( pView->getSelectionCount() == 1 )
+ {
const ElementType eType = pView->getElementType();
- if ( _pEntry && pView->isALeafSelected() )
+ if ( pView->isALeafSelected() )
{
- const ::rtl::OUString sName = pView->getQualifiedName( _pEntry );
- selectEntry(eType,sName);
+ const ::rtl::OUString sName = pView->getQualifiedName( NULL /* means 'first selected' */ );
+ showPreviewFor( eType, sName );
}
}
}
// -----------------------------------------------------------------------------
-void OApplicationController::selectEntry(const ElementType _eType,const ::rtl::OUString& _sName)
+void OApplicationController::showPreviewFor(const ElementType _eType,const ::rtl::OUString& _sName)
{
OApplicationView* pView = getContainer();
- Reference< XContent> xContent;
+ if ( !pView )
+ return;
+
try
{
switch( _eType )
{
case E_FORM:
case E_REPORT:
- if ( _sName.getLength() )
- {
- Reference< XHierarchicalNameAccess > xContainer(getElements(_eType),UNO_QUERY);
- if ( xContainer.is() && xContainer->hasByHierarchicalName(_sName) )
- xContent.set(xContainer->getByHierarchicalName(_sName),UNO_QUERY);
- }
- break;
+ {
+ Reference< XHierarchicalNameAccess > xContainer( getElements( _eType ), UNO_QUERY_THROW );
+ Reference< XContent> xContent( xContainer->getByHierarchicalName( _sName ), UNO_QUERY_THROW );
+ pView->showPreview( xContent );
+ }
+ break;
+
+ case E_TABLE:
case E_QUERY:
- if ( pView->isPreviewEnabled() )
{
SharedConnection xConnection( ensureConnection() );
if ( xConnection.is() )
- pView->showPreview(getDatabaseName(),xConnection,_sName,sal_False);
+ pView->showPreview( getDatabaseName(), xConnection, _sName, _eType == E_TABLE );
}
return;
- case E_TABLE:
- {
- SharedConnection xConnection( ensureConnection() );
- if ( xConnection.is() )
- {
- pView->showPreview(getDatabaseName(),xConnection,_sName,_eType == E_TABLE);
- return;
- }
- }
- break;
+
default:
+ OSL_ENSURE( false, "OApplicationController::showPreviewFor: unexpected element type!" );
break;
}
}
@@ -2384,8 +2357,6 @@ void OApplicationController::selectEntry(const ElementType _eType,const ::rtl::O
{
DBG_UNHANDLED_EXCEPTION();
}
-
- pView->showPreview(xContent);
}
//------------------------------------------------------------------------------
@@ -2403,21 +2374,21 @@ IMPL_LINK(OApplicationController, OnInvalidateClipboard, void*, EMPTYARG)
return 0L;
}
// -----------------------------------------------------------------------------
-void OApplicationController::onCutEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onCutEntry()
{
}
// -----------------------------------------------------------------------------
-void OApplicationController::onCopyEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onCopyEntry()
{
Execute(ID_BROWSER_COPY,Sequence<PropertyValue>());
}
// -----------------------------------------------------------------------------
-void OApplicationController::onPasteEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onPasteEntry()
{
Execute(ID_BROWSER_PASTE,Sequence<PropertyValue>());
}
// -----------------------------------------------------------------------------
-void OApplicationController::onDeleteEntry(SvLBoxEntry* /*_pEntry*/)
+void OApplicationController::onDeleteEntry()
{
ElementType eType = getContainer()->getElementType();
sal_uInt16 nId = 0;
@@ -2796,7 +2767,7 @@ IMPL_LINK( OApplicationController, OnFirstControllerConnected, void*, /**/ )
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > & _rxModel) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
if ( !xOfficeDoc.is() && _rxModel.is() )
{
@@ -2822,14 +2793,10 @@ sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel >
}
m_xDataSource.set(xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference<XDataSource>(),UNO_QUERY);
- if ( !m_xDataSource.is() )
- m_sDatabaseName = ::rtl::OUString();
- else
+ if ( m_xDataSource.is() )
{
try
{
- m_xDataSource->getPropertyValue(PROPERTY_NAME) >>= m_sDatabaseName;
-
m_xDataSource->addPropertyChangeListener(PROPERTY_INFO, this);
m_xDataSource->addPropertyChangeListener(PROPERTY_URL, this);
m_xDataSource->addPropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this);
@@ -2920,7 +2887,7 @@ void SAL_CALL OApplicationController::removeSelectionChangeListener( const Refer
::sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) throw (IllegalArgumentException, RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Sequence< ::rtl::OUString> aSelection;
if ( !_aSelection.hasValue() || !getView() )
{
@@ -3048,12 +3015,30 @@ void SAL_CALL OApplicationController::removeSelectionChangeListener( const Refer
Any SAL_CALL OApplicationController::getSelection( ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Sequence< NamedDatabaseObject > aCurrentSelection;
const ElementType eType( getContainer()->getElementType() );
if ( eType != E_NONE )
+ {
getContainer()->describeCurrentSelectionForType( eType, aCurrentSelection );
+ if ( aCurrentSelection.getLength() == 0 )
+ { // if no objects are selected, add an entry to the sequence which describes the overall category
+ // which is selected currently
+ aCurrentSelection.realloc(1);
+ aCurrentSelection[0].Name = getDatabaseName();
+ switch ( eType )
+ {
+ case E_TABLE: aCurrentSelection[0].Type = DatabaseObjectContainer::TABLES; break;
+ case E_QUERY: aCurrentSelection[0].Type = DatabaseObjectContainer::QUERIES; break;
+ case E_FORM: aCurrentSelection[0].Type = DatabaseObjectContainer::FORMS; break;
+ case E_REPORT: aCurrentSelection[0].Type = DatabaseObjectContainer::REPORTS; break;
+ default:
+ OSL_ENSURE( false, "OApplicationController::getSelection: unexpected current element type!" );
+ break;
+ }
+ }
+ }
return makeAny( aCurrentSelection );
}
// -----------------------------------------------------------------------------
@@ -3083,45 +3068,6 @@ void OApplicationController::impl_migrateScripts_nothrow()
}
}
-// -----------------------------------------------------------------------------
-bool OApplicationController::impl_activateSubFrame_throw(const ::rtl::OUString& _sName,const sal_Int32 _nKind,const ElementOpenMode _eOpenMode) const
-{
- bool bFound = false;
- TFrames::const_iterator aFind = m_aSpecialSubFrames.find(_sName);
- for(;aFind != m_aSpecialSubFrames.end();++aFind)
- {
- if ( aFind->second.first.first == _nKind && aFind->second.first.second == _eOpenMode )
- {
- const Reference< XFrame> xFrame(aFind->second.second,UNO_QUERY);
- if ( xFrame.is() )
- {
- Reference< awt::XTopWindow> xTopWindow(xFrame->getContainerWindow(),UNO_QUERY);
- if ( xTopWindow.is() )
- xTopWindow->toFront();
- bFound = true;
- }
- break;
- } // if ( aFind->second.first.first == _nKind && aFind->second.first.second == _eOpenMode )
- }
- return bFound;
-}
-// -----------------------------------------------------------------------------
-void OApplicationController::impl_deActivateSubFrame_throw(const ::rtl::OUString& _sName,const sal_Int32 _nKind)
-{
- TFrames aCopy = m_aSpecialSubFrames;
- TFrames::iterator aFind = aCopy.find(_sName);
- for(;aFind != aCopy.end();++aFind)
- {
- if ( aFind->second.first.first == _nKind )
- {
- Reference< XFrame> xFrame(aFind->second.second,UNO_QUERY);
- if ( xFrame.is() )
- {
- ::comphelper::disposeComponent(xFrame);
- }
- } // if ( aFind->second.first.first == _nKind && aFind->second.first.second == _eOpenMode )
- }
-}
//........................................................................
} // namespace dbaui
//........................................................................
diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx
index 07be5b0bd4e1..96ca58d6f428 100644
--- a/dbaccess/source/ui/app/AppController.hxx
+++ b/dbaccess/source/ui/app/AppController.hxx
@@ -76,6 +76,9 @@ FORWARD_DECLARE_INTERFACE(ucb,XContent)
namespace dbaui
{
//........................................................................
+
+ class SubComponentManager;
+
//====================================================================
//= OApplicationController
//====================================================================
@@ -101,13 +104,6 @@ namespace dbaui
typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > TContainer;
typedef ::std::vector< TContainer > TContainerVector;
- typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > TComponent;
- typedef ::std::map< TComponent, TComponent > TDocuments;
-
- typedef ::std::pair< sal_Int32, ElementOpenMode > TTypeOpenMode;
- typedef ::std::pair< TTypeOpenMode , TComponent > TTypeFrame;
- typedef ::std::multimap< ::rtl::OUString, TTypeFrame > TFrames;
-
private:
OTableCopyHelper::DropDescriptor m_aAsyncDrop;
@@ -130,14 +126,13 @@ namespace dbaui
ModelControllerConnector
m_aModelConnector;
TContainerVector m_aCurrentContainers; // the containers where we are listener on
- TDocuments m_aDocuments;
- TFrames m_aSpecialSubFrames; // contains the query, table and relation frame
+ ::rtl::Reference< SubComponentManager >
+ m_pSubComponentManager;
::dbaccess::ODsnTypeCollection
m_aTypeCollection;
OTableCopyHelper m_aTableCopyHelper;
TransferableClipboardListener*
m_pClipbordNotifier; // notifier for changes in the clipboard
- mutable ::rtl::OUString m_sDatabaseName;
ULONG m_nAsyncDrop;
OAsyncronousLink m_aControllerConnectedEvent;
OAsyncronousLink m_aSelectContainerEvent;
@@ -156,23 +151,11 @@ namespace dbaui
OApplicationView* getContainer() const;
- /** activates the current table, query or relation design frame when existing
- @param _sName the name of the component
- @param _nKind the kind of the component
- */
- bool impl_activateSubFrame_throw(const ::rtl::OUString& _sName,const sal_Int32 _nKind,const ElementOpenMode _eOpenMode) const;
-
- /** deactivates the current table or query frame when existing
- @param _sName the name of the component
- @param _nKind the kind of the component
- */
- void impl_deActivateSubFrame_throw(const ::rtl::OUString& _sName,const sal_Int32 _nKind);
-
/** returns the database name
@return
the database name
*/
- inline ::rtl::OUString getDatabaseName() const { return m_sDatabaseName; }
+ ::rtl::OUString getDatabaseName() const;
/** returns the stripped database name.
@return
@@ -359,14 +342,15 @@ namespace dbaui
*/
void askToReconnect();
- /** add event listener and remember the document
- @param _xDocument
- the new document, may be <NULL/>
- @param _xDefinition
- The defintion object.
+ /** remember a newly opened sub document for later access
*/
- void addDocumentListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDocument,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDefinition);
+ void onDocumentOpened(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nType,
+ const ElementOpenMode _eMode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDocument,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDefinition
+ );
/** Inserts a new object into the hierachy given be the type.
@param _eType
@@ -408,9 +392,9 @@ namespace dbaui
*/
::rtl::OUString getCurrentlySelectedName(sal_Int32& _rnCommandType) const;
- /** select the give entry
+ /** shows the preview for the given entry
*/
- void selectEntry(const ElementType _eType,const ::rtl::OUString& _sName);
+ void showPreviewFor( const ElementType _eType,const ::rtl::OUString& _sName );
/** called when we just connected to a new, non-NULL model
@@ -489,7 +473,7 @@ namespace dbaui
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getActiveConnection() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > > SAL_CALL getSubComponents() throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isConnected( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL connect( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL connect( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL closeSubComponents( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL loadComponent( ::sal_Int32 ObjectType, const ::rtl::OUString& ObjectName, ::sal_Bool ForEditing ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL loadComponentWithArguments( ::sal_Int32 ObjectType, const ::rtl::OUString& ObjectName, ::sal_Bool ForEditing, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
@@ -505,8 +489,11 @@ namespace dbaui
virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
/** retrieves the current connection, creates it if necessary
+
+ If an error occurs, then this is either stored in the location pointed to by <arg>_pErrorInfo</arg>,
+ or, if <code>_pErrorInfo</code> is <NULL/>, then the error is displayed to the user.
*/
- const SharedConnection& ensureConnection();
+ const SharedConnection& ensureConnection( ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL );
/** retrieves the current connection
*/
@@ -525,12 +512,11 @@ namespace dbaui
// IApplicationController
virtual bool onEntryDoubleClick(SvTreeListBox& _rTree);
virtual sal_Bool onContainerSelect(ElementType _eType);
- virtual void onEntrySelect(SvLBoxEntry* _pEntry);
- virtual void onEntryDeSelect(SvTreeListBox& _rTree);
- virtual void onCutEntry(SvLBoxEntry* _pEntry);
- virtual void onCopyEntry(SvLBoxEntry* _pEntry);
- virtual void onPasteEntry(SvLBoxEntry* _pEntry);
- virtual void onDeleteEntry(SvLBoxEntry* _pEntry);
+ virtual void onSelectionChanged();
+ virtual void onCutEntry();
+ virtual void onCopyEntry();
+ virtual void onPasteEntry();
+ virtual void onDeleteEntry();
virtual void previewChanged( sal_Int32 _nMode);
virtual void containerFound( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer);
diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx
index e063e45c824a..989ceacdc1f0 100644
--- a/dbaccess/source/ui/app/AppControllerDnD.cxx
+++ b/dbaccess/source/ui/app/AppControllerDnD.cxx
@@ -221,6 +221,7 @@
#ifndef _VOS_MUTEX_HXX_
#include <vos/mutex.hxx>
#endif
+#include "subcomponentmanager.hxx"
//........................................................................
namespace dbaui
@@ -263,7 +264,11 @@ void OApplicationController::deleteTables(const ::std::vector< ::rtl::OUString>&
sal_Int32 nResult = RET_YES;
if ( bConfirm )
nResult = ::dbaui::askForUserAction(getView(),STR_TITLE_CONFIRM_DELETION ,STR_QUERY_DELETE_TABLE,_rList.size() > 1 && (aIter+1) != _rList.end(),sTableName);
- if ( (RET_YES == nResult) || (RET_ALL == nResult) )
+
+ bool bUserConfirmedDelete =
+ ( RET_YES == nResult )
+ || ( RET_ALL == nResult );
+ if ( bUserConfirmedDelete && m_pSubComponentManager->closeSubFrames( sTableName, E_TABLE ) )
{
SQLExceptionInfo aErrorInfo;
try
@@ -286,7 +291,6 @@ void OApplicationController::deleteTables(const ::std::vector< ::rtl::OUString>&
}
}
}
- impl_deActivateSubFrame_throw(sTableName,E_TABLE);
}
catch(SQLContext& e) { aErrorInfo = e; }
catch(SQLWarning& e) { aErrorInfo = e; }
@@ -370,8 +374,13 @@ void OApplicationController::deleteObjects( ElementType _eType, const ::std::vec
bool bSuccess = false;
- if ( ( eResult == svtools::QUERYDELETE_ALL ) ||
- ( eResult == svtools::QUERYDELETE_YES ) )
+ bool bUserConfirmedDelete =
+ ( eResult == svtools::QUERYDELETE_ALL )
+ || ( eResult == svtools::QUERYDELETE_YES );
+
+ if ( bUserConfirmedDelete
+ && ( ( _eType == E_QUERY ) ? m_pSubComponentManager->closeSubFrames( *aThisRound, _eType ) : true )
+ )
{
try
{
@@ -380,9 +389,6 @@ void OApplicationController::deleteObjects( ElementType _eType, const ::std::vec
else
xNames->removeByName( *aThisRound );
- if ( _eType == E_QUERY )
- impl_deActivateSubFrame_throw(*aThisRound,_eType);
-
bSuccess = true;
// now that we removed the element, care for all it's child elements
@@ -438,7 +444,7 @@ void OApplicationController::deleteObjects( ElementType _eType, const ::std::vec
void OApplicationController::deleteEntries()
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( getContainer() )
{
@@ -465,10 +471,10 @@ void OApplicationController::deleteEntries()
}
}
// -----------------------------------------------------------------------------
-const SharedConnection& OApplicationController::ensureConnection()
+const SharedConnection& OApplicationController::ensureConnection( ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( !m_xDataSourceConnection.is() )
{
@@ -476,13 +482,34 @@ const SharedConnection& OApplicationController::ensureConnection()
String sConnectingContext( ModuleRes( STR_COULDNOTCONNECT_DATASOURCE ) );
sConnectingContext.SearchAndReplaceAscii("$name$", getStrippedDatabaseName());
- m_xDataSourceConnection.reset( connect( getDatabaseName(), sConnectingContext, sal_True ) );
+ m_xDataSourceConnection.reset( connect( getDatabaseName(), sConnectingContext, _pErrorInfo ) );
if ( m_xDataSourceConnection.is() )
- m_xMetaData = m_xDataSourceConnection->getMetaData();
-
- // otherwise we got a loop when connecting to db throws an error
-// if ( !m_xDataSourceConnection.is() )
-// getContainer()->clearSelection();
+ {
+ SQLExceptionInfo aError;
+ try
+ {
+ m_xMetaData = m_xDataSourceConnection->getMetaData();
+ }
+ catch( const SQLException& )
+ {
+ aError = ::cppu::getCaughtException();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if ( aError.isValid() )
+ {
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = aError;
+ }
+ else
+ {
+ showError( aError );
+ }
+ }
+ }
}
return m_xDataSourceConnection;
}
@@ -502,8 +529,9 @@ sal_Bool OApplicationController::isConnectionReadOnly() const
{
bIsConnectionReadOnly = m_xMetaData->isReadOnly();
}
- catch(SQLException&)
+ catch(const SQLException&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
}
// TODO check configuration
@@ -562,7 +590,7 @@ Reference< XNameAccess > OApplicationController::getElements( ElementType _eType
void OApplicationController::getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames) const
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
OSL_ENSURE(getContainer(),"View isn't valid! -> GPF");
@@ -595,7 +623,7 @@ TransferableHelper* OApplicationController::copyObject()
try
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
ElementType eType = getContainer()->getElementType();
TransferableHelper* pData = NULL;
@@ -634,7 +662,7 @@ TransferableHelper* OApplicationController::copyObject()
if ( xElements.is() && !aList.empty() )
{
Reference< XContent> xContent(xElements->getByHierarchicalName(*aList.begin()),UNO_QUERY);
- pData = new OComponentTransferable(m_sDatabaseName,xContent);
+ pData = new OComponentTransferable( getDatabaseName(), xContent );
}
}
break;
@@ -714,7 +742,8 @@ sal_Bool OApplicationController::paste( ElementType _eType,const ::svx::ODataAcc
try
{
// the concrete query
- Reference<XQueryDefinitionsSupplier> xSourceQuerySup(getDataSourceByName_displayError( sDataSourceName, getView(), getORB(), true ),UNO_QUERY);
+ Reference< XDataSource > xDataSource( getDataSourceByName( sDataSourceName, getView(), getORB(), NULL ) );
+ Reference< XQueryDefinitionsSupplier > xSourceQuerySup( xDataSource, UNO_QUERY );
if ( xSourceQuerySup.is() )
xQueries.set(xSourceQuerySup->getQueryDefinitions(),UNO_QUERY);
@@ -865,7 +894,7 @@ sal_Bool OApplicationController::isTableFormat() const
sal_Bool OApplicationController::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc, sal_Bool _bCheck)
{
// first get the dest connection
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
SharedConnection xConnection( ensureConnection() );
if ( !xConnection.is() )
@@ -878,7 +907,7 @@ IMPL_LINK( OApplicationController, OnAsyncDrop, void*, /*NOTINTERESTEDIN*/ )
{
m_nAsyncDrop = 0;
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( m_aAsyncDrop.nType == E_TABLE )
diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx
index 59c5bcf8334b..2570822ca6e2 100644
--- a/dbaccess/source/ui/app/AppControllerGen.cxx
+++ b/dbaccess/source/ui/app/AppControllerGen.cxx
@@ -40,6 +40,7 @@
#include "defaultobjectnamecheck.hxx"
#include "dlgsave.hxx"
#include "UITools.hxx"
+#include "subcomponentmanager.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/container/XChild.hpp>
@@ -216,7 +217,7 @@ void OApplicationController::openDialog( const ::rtl::OUString& _sServiceName )
try
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
WaitObject aWO(getView());
Sequence< Any > aArgs(3);
@@ -306,7 +307,7 @@ void OApplicationController::openDirectSQLDialog()
void SAL_CALL OApplicationController::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( evt.PropertyName == PROPERTY_USER )
{
m_bNeedToReconnect = sal_True;
@@ -347,7 +348,7 @@ void SAL_CALL OApplicationController::propertyChange( const PropertyChangeEvent&
// -----------------------------------------------------------------------------
Reference< XDataSource > SAL_CALL OApplicationController::getDataSource() throw (RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
return xDataSource;
}
@@ -355,7 +356,7 @@ Reference< XDataSource > SAL_CALL OApplicationController::getDataSource() throw
// -----------------------------------------------------------------------------
Reference< XWindow > SAL_CALL OApplicationController::getApplicationMainWindow() throw (RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Reference< XFrame > xFrame( getFrame(), UNO_QUERY_THROW );
Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
return xWindow;
@@ -364,134 +365,47 @@ Reference< XWindow > SAL_CALL OApplicationController::getApplicationMainWindow()
// -----------------------------------------------------------------------------
Sequence< Reference< XComponent > > SAL_CALL OApplicationController::getSubComponents() throw (RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aMutex);
- Sequence< Reference< XComponent > > aComponents( m_aDocuments.size() );
- ::std::transform( m_aDocuments.begin(), m_aDocuments.end(), aComponents.getArray(), ::std::select1st< TDocuments::value_type >() );
- return aComponents;
+ return m_pSubComponentManager->getSubComponents();
}
// -----------------------------------------------------------------------------
Reference< XConnection > SAL_CALL OApplicationController::getActiveConnection() throw (RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
return m_xDataSourceConnection.getTyped();
}
// -----------------------------------------------------------------------------
::sal_Bool SAL_CALL OApplicationController::isConnected( ) throw (RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
return m_xDataSourceConnection.is();
}
// -----------------------------------------------------------------------------
-::sal_Bool SAL_CALL OApplicationController::connect( ) throw (RuntimeException)
+void SAL_CALL OApplicationController::connect( ) throw (SQLException, RuntimeException)
{
- ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
-
- ensureConnection();
- return isConnected();
-}
-
-// -----------------------------------------------------------------------------
-namespace
-{
- static Reference< XController > lcl_getController( const OApplicationController::TDocuments::iterator& _docPos )
+ SQLExceptionInfo aError;
+ SharedConnection xConnection = ensureConnection( &aError );
+ if ( !xConnection.is() )
{
- Reference< XController > xController;
+ if ( aError.isValid() )
+ aError.doThrow();
- Reference< XComponent > xComponent( _docPos->first );
- Reference< XModel > xModel( xComponent, UNO_QUERY );
- if ( xModel.is() )
- xController = xModel->getCurrentController();
- else
- {
- xController.set( xComponent, UNO_QUERY );
- if ( !xController.is() )
- {
- Reference<XFrame> xFrame( xComponent, UNO_QUERY );
- if ( xFrame.is() )
- xController = xFrame->getController();
- }
- }
- return xController;
+ // no particular error, but nonetheless could not connect -> throw a generic exception
+ String sConnectingContext( ModuleRes( STR_COULDNOTCONNECT_DATASOURCE ) );
+ sConnectingContext.SearchAndReplaceAscii( "$name$", getStrippedDatabaseName() );
+ ::dbtools::throwGenericSQLException( sConnectingContext, *this );
}
}
// -----------------------------------------------------------------------------
::sal_Bool SAL_CALL OApplicationController::closeSubComponents( ) throw (RuntimeException)
{
- ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard( m_aMutex );
-
- try
- {
- typedef ::std::vector< Reference< XComponent > > ComponentArray;
- ComponentArray aClosedComponents;
-
- TDocuments aDocuments( m_aDocuments );
- for ( TDocuments::iterator doc = aDocuments.begin();
- doc != aDocuments.end();
- ++doc
- )
- {
- Reference< XController > xController( lcl_getController( doc ) );
- OSL_ENSURE( xController.is(), "OApplicationController::closeSubComponents: did not find the sub controller!" );
-
- // suspend the controller in the document
- if ( !xController.is()
- || !xController->suspend( sal_True )
- )
- // break complete operation, no sense in continueing
- break;
-
- // revoke event listener
- Reference< XComponent > xDocument = doc->first;
- if ( xDocument.is() )
- xDocument->removeEventListener( static_cast< XFrameActionListener* >( this ) );
-
- bool bClosedSubDoc = false;
- try
- {
- Reference< XCloseable > xCloseable( xController->getFrame(), UNO_QUERY_THROW );
- xCloseable->close( sal_True );
- bClosedSubDoc = true;
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-
- if ( !bClosedSubDoc )
- // no sense in continueing with the other docs
- break;
-
- aClosedComponents.push_back( doc->first );
- }
-
- // now remove all the components which we could successfully close
- // (this might be none, or all, or something inbetween) from m_aDocuments
- for ( ComponentArray::const_iterator comp = aClosedComponents.begin();
- comp != aClosedComponents.end();
- ++comp
- )
- {
- TDocuments::iterator pos = m_aDocuments.find( *comp );
- OSL_ENSURE( pos != m_aDocuments.end(),
- "OApplicationController::closeSubComponents: closed a component which doesn't exist anymore!" );
- if ( pos !=m_aDocuments.end() )
- m_aDocuments.erase( pos );
- }
- }
- catch ( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-
- return m_aDocuments.empty();
+ return m_pSubComponentManager->closeSubComponents();
}
+
// -----------------------------------------------------------------------------
namespace
{
@@ -569,7 +483,7 @@ Reference< XComponent > SAL_CALL OApplicationController::loadComponentWithArgume
const ::rtl::OUString& _ObjectName, ::sal_Bool _ForEditing, const Sequence< PropertyValue >& _Arguments ) throw (IllegalArgumentException, NoSuchElementException, SQLException, RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
impl_validateObjectTypeAndName_throw( _ObjectType, _ObjectName );
@@ -601,7 +515,7 @@ void SAL_CALL OApplicationController::releaseContextMenuInterceptor( const Refer
void OApplicationController::previewChanged( sal_Int32 _nMode )
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( m_xDataSource.is() && !isDataSourceReadOnly() )
{
@@ -645,7 +559,7 @@ void OApplicationController::askToReconnect()
{
m_bNeedToReconnect = sal_False;
sal_Bool bClear = sal_True;
- if ( !m_aDocuments.empty() )
+ if ( !m_pSubComponentManager->empty() )
{
QueryBox aQry(getView(), ModuleRes(APP_CLOSEDOCUMENTS));
switch (aQry.Execute())
@@ -671,28 +585,53 @@ void OApplicationController::askToReconnect()
}
// -----------------------------------------------------------------------------
+::rtl::OUString OApplicationController::getDatabaseName() const
+{
+ ::rtl::OUString sDatabaseName;
+ try
+ {
+ if ( m_xDataSource.is() )
+ {
+ OSL_VERIFY( m_xDataSource->getPropertyValue( PROPERTY_NAME ) >>= sDatabaseName );
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sDatabaseName;
+}
+
+// -----------------------------------------------------------------------------
::rtl::OUString OApplicationController::getStrippedDatabaseName() const
{
- return ::dbaui::getStrippedDatabaseName(m_xDataSource,m_sDatabaseName);
+ ::rtl::OUString sDatabaseName;
+ return ::dbaui::getStrippedDatabaseName( m_xDataSource, sDatabaseName );
}
// -----------------------------------------------------------------------------
-void OApplicationController::addDocumentListener(const Reference< XComponent >& _xDocument,const Reference< XComponent >& _xDefintion)
+void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, const sal_Int32 _nType,
+ const ElementOpenMode _eMode, const Reference< XComponent >& _xDocument, const Reference< XComponent >& _rxDefinition )
{
- if ( _xDocument.is() )
+ OSL_PRECOND( _xDocument.is(), "OApplicationController::onDocumentOpened: illegal document!" );
+ if ( !_xDocument.is() )
+ return;
+
+ try
{
- try
- {
- m_aDocuments[_xDocument] = _xDefintion;
- _xDocument->addEventListener(static_cast<XFrameActionListener*>(this));
- Reference<XPropertySet> xProp(_xDefintion,UNO_QUERY_THROW);
- if ( xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) )
- xProp->addPropertyChangeListener(PROPERTY_NAME,static_cast<XPropertyChangeListener*>(this));
- }
- catch(Exception&)
+ m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument );
+
+ if ( _rxDefinition.is() )
{
+ Reference< XPropertySet > xProp( _rxDefinition, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPSI( xProp->getPropertySetInfo(), UNO_SET_THROW );
+ xProp->addPropertyChangeListener( PROPERTY_NAME, static_cast< XPropertyChangeListener* >( this ) );
}
}
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
// -----------------------------------------------------------------------------
sal_Bool OApplicationController::insertHierachyElement(ElementType _eType,const String& _sParentFolder,sal_Bool _bCollection,const Reference<XContent>& _xContent,sal_Bool _bMove)
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
index 2f0bd0b55877..f4c7a4eca31d 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
@@ -351,10 +351,10 @@ OAppDetailPageHelper::~OAppDetailPageHelper()
{
if ( m_pLists[i] )
{
- m_pLists[i]->clearCurrentSelectionEntry();
+ m_pLists[i]->clearCurrentSelection();
m_pLists[i]->Hide();
::std::auto_ptr<DBTreeListBox> aTemp(m_pLists[i]);
- m_pLists[i]->clearCurrentSelectionEntry();
+ m_pLists[i]->clearCurrentSelection(); // why a second time?
m_pLists[i] = NULL;
}
@@ -379,9 +379,7 @@ void OAppDetailPageHelper::selectAll()
int nPos = getVisibleControlIndex();
if ( nPos < E_ELEMENT_TYPE_COUNT )
{
- m_pLists[nPos]->lockAutoSelect();
m_pLists[nPos]->SelectAll(TRUE);
- m_pLists[nPos]->unlockAutoSelect();
}
}
// -----------------------------------------------------------------------------
@@ -907,8 +905,7 @@ DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, cons
_pTreeView->SetDoubleClickHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick));
_pTreeView->SetEnterKeyHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick));
- _pTreeView->SetSelectHdl(LINK(this, OAppDetailPageHelper, OnEntrySelectHdl));
- _pTreeView->SetDeselectHdl(LINK(this, OAppDetailPageHelper, OnDeSelectHdl));
+ _pTreeView->SetSelChangeHdl(LINK(this, OAppDetailPageHelper, OnEntrySelChange));
_pTreeView->setCutHandler(LINK(this, OAppDetailPageHelper, OnCutEntry));
_pTreeView->setCopyHandler(LINK(this, OAppDetailPageHelper, OnCopyEntry));
@@ -1066,48 +1063,33 @@ IMPL_LINK(OAppDetailPageHelper, OnEntryDoubleClick, SvTreeListBox*, _pTree)
return bHandled ? 1L : 0L;
}
// -----------------------------------------------------------------------------
-IMPL_LINK(OAppDetailPageHelper, OnDeSelectHdl, SvTreeListBox*, _pTree)
+IMPL_LINK(OAppDetailPageHelper, OnEntrySelChange, void*, /*NOINTERESTEDIN*/)
{
- OSL_ENSURE( _pTree, "OAppDetailPageHelper, OnDeSelectHdl: invalid callback!" );
- if ( _pTree != NULL )
- getBorderWin().getView()->getAppController().onEntryDeSelect( *_pTree );
+ getBorderWin().getView()->getAppController().onSelectionChanged();
return 1L;
}
// -----------------------------------------------------------------------------
-IMPL_LINK(OAppDetailPageHelper, OnEntrySelectHdl, SvLBoxEntry*, _pEntry)
+IMPL_LINK( OAppDetailPageHelper, OnCutEntry, void*, /*NOINTERESTEDIN*/ )
{
- if ( 1 == getSelectionCount() )
- {
- getBorderWin().getView()->getAppController().onEntrySelect(_pEntry);
- }
- else
- {
- showPreview(NULL);
- }
+ getBorderWin().getView()->getAppController().onCutEntry();
return 1L;
}
// -----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnCutEntry, SvLBoxEntry*, _pEntry )
+IMPL_LINK( OAppDetailPageHelper, OnCopyEntry, void*, /*NOINTERESTEDIN*/ )
{
- getBorderWin().getView()->getAppController().onCutEntry(_pEntry);
+ getBorderWin().getView()->getAppController().onCopyEntry();
return 1L;
}
// -----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnCopyEntry, SvLBoxEntry*, _pEntry )
+IMPL_LINK( OAppDetailPageHelper, OnPasteEntry, void*, /*NOINTERESTEDIN*/ )
{
- getBorderWin().getView()->getAppController().onCopyEntry(_pEntry);
+ getBorderWin().getView()->getAppController().onPasteEntry();
return 1L;
}
// -----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnPasteEntry, SvLBoxEntry*, _pEntry )
+IMPL_LINK( OAppDetailPageHelper, OnDeleteEntry, void*, /*NOINTERESTEDIN*/ )
{
- getBorderWin().getView()->getAppController().onPasteEntry(_pEntry);
- return 1L;
-}
-// -----------------------------------------------------------------------------
-IMPL_LINK( OAppDetailPageHelper, OnDeleteEntry, SvLBoxEntry*, _pEntry )
-{
- getBorderWin().getView()->getAppController().onDeleteEntry(_pEntry);
+ getBorderWin().getView()->getAppController().onDeleteEntry();
return 1L;
}
// -----------------------------------------------------------------------------
@@ -1182,16 +1164,12 @@ void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,BOOL _bForce)
m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, m_aMenu->GetItemText(nSelectedAction));
Resize();
+ // simulate a selectionChanged event at the controller, to force the preview to be updated
if ( isPreviewEnabled() )
{
- DBTreeListBox* pTree = getCurrentView();
- if ( pTree )
+ if ( getCurrentView() && getCurrentView()->FirstSelected() )
{
- SvLBoxEntry* pEntry = pTree->GetSelectedEntry();
- if ( pEntry )
- {
- getBorderWin().getView()->getAppController().onEntrySelect(pEntry);
- }
+ getBorderWin().getView()->getAppController().onSelectionChanged();
}
}
else
@@ -1255,9 +1233,12 @@ void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent)
{
m_aPreview.Hide();
m_aDocumentInfo.Hide();
- DBTreeListBox* pTreeView = getCurrentView();
- if ( pTreeView )
- pTreeView->clearCurrentSelectionEntry();
+
+ // Why the below code? It might have side effects, as the tree view needs to know
+ // its current selection for other purposes than the preview, too.
+// DBTreeListBox* pTreeView = getCurrentView();
+// if ( pTreeView )
+// pTreeView->clearCurrentSelection();
}
}
catch( const Exception& )
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.hxx b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
index 51f094bbbe25..2481c8744913 100644
--- a/dbaccess/source/ui/app/AppDetailPageHelper.hxx
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
@@ -196,14 +196,12 @@ namespace dbaui
DBTreeListBox* createSimpleTree( ULONG _nHelpId, const Image& _rImage, const Image& _rImageHC );
DECL_LINK( OnEntryDoubleClick, SvTreeListBox* );
- DECL_LINK( OnDeSelectHdl, SvTreeListBox* );
+ DECL_LINK( OnEntrySelChange, void* );
- DECL_LINK( OnEntrySelectHdl, SvLBoxEntry* );
-
- DECL_LINK( OnCutEntry, SvLBoxEntry* );
- DECL_LINK( OnCopyEntry, SvLBoxEntry* );
- DECL_LINK( OnPasteEntry, SvLBoxEntry* );
- DECL_LINK( OnDeleteEntry, SvLBoxEntry* );
+ DECL_LINK( OnCutEntry, void* );
+ DECL_LINK( OnCopyEntry, void* );
+ DECL_LINK( OnPasteEntry, void* );
+ DECL_LINK( OnDeleteEntry, void* );
DECL_LINK(PreviewChangeHdl, void*);
// click a TB slot
diff --git a/dbaccess/source/ui/app/IApplicationController.hxx b/dbaccess/source/ui/app/IApplicationController.hxx
index 89ff2381e9dd..321eb3aafd75 100644
--- a/dbaccess/source/ui/app/IApplicationController.hxx
+++ b/dbaccess/source/ui/app/IApplicationController.hxx
@@ -71,37 +71,23 @@ namespace dbaui
@param _pEntry
the selected entry
*/
- virtual void onEntrySelect(SvLBoxEntry* _pEntry) = 0;
+ virtual void onSelectionChanged() = 0;
- /** called when an entry in a tree view has been de-selected
- @param _pTree
- The tree list box.
- */
- virtual void onEntryDeSelect(SvTreeListBox& _rTree) = 0;
-
- /** called when a "Cut" command is executed for a tree view entry
- @param _pEntry
- The entry which was cutted.
+ /** called when a "Cut" command is executed in a tree view
*/
- virtual void onCutEntry(SvLBoxEntry* _pEntry) = 0;
+ virtual void onCutEntry() = 0;
- /** called when a "Copy" command is executed for a tree view entry
- @param _pEntry
- The entry which was cutted.
+ /** called when a "Copy" command is executed in a tree view
*/
- virtual void onCopyEntry(SvLBoxEntry* _pEntry) = 0;
+ virtual void onCopyEntry() = 0;
- /** called when a "Paste" command is executed for a tree view entry
- @param _pEntry
- The entry which was cutted.
+ /** called when a "Paste" command is executed in a tree view
*/
- virtual void onPasteEntry(SvLBoxEntry* _pEntry) = 0;
+ virtual void onPasteEntry() = 0;
- /** called when a "Delete" command is executed for a tree view entry
- @param _pEntry
- The entry which was cutted.
+ /** called when a "Delete" command is executed in a tree view
*/
- virtual void onDeleteEntry(SvLBoxEntry* _pEntry) = 0;
+ virtual void onDeleteEntry() = 0;
/// called when the preview mode was changed
virtual void previewChanged( sal_Int32 _nMode ) = 0;
diff --git a/dbaccess/source/ui/app/makefile.mk b/dbaccess/source/ui/app/makefile.mk
index bef4e64f6426..b132816a3981 100644
--- a/dbaccess/source/ui/app/makefile.mk
+++ b/dbaccess/source/ui/app/makefile.mk
@@ -8,7 +8,7 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.5 $
+# $Revision: 1.5.80.1 $
#
# This file is part of OpenOffice.org.
#
@@ -51,7 +51,8 @@ EXCEPTIONSFILES=\
$(SLO)$/AppDetailPageHelper.obj \
$(SLO)$/AppSwapWindow.obj \
$(SLO)$/AppTitleWindow.obj \
- $(SLO)$/AppView.obj
+ $(SLO)$/AppView.obj \
+ $(SLO)$/subcomponentmanager.obj
SLOFILES =\
diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx
new file mode 100644
index 000000000000..c3ce4923b9c2
--- /dev/null
+++ b/dbaccess/source/ui/app/subcomponentmanager.cxx
@@ -0,0 +1,432 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: subcomponentmanager.cxx,v $
+*
+* $Revision: 1.1.2.2 $
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#include "subcomponentmanager.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+#include <hash_map>
+#include <algorithm>
+#include <functional>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::frame::XModel2;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::util::XCloseable;
+ using ::com::sun::star::awt::XTopWindow;
+ /** === end UNO using === **/
+
+ //==============================================================================
+ //= helper structs
+ //==============================================================================
+ namespace
+ {
+ struct SubComponentDescriptor
+ {
+ /// the frame which the component resides in. Must not be <NULL/>
+ Reference< XFrame > xFrame;
+ /// the controller of the sub component. Must not be <NULL/>
+ Reference< XController > xController;
+ /// the model of the sub component. Might be <NULL/>
+ Reference< XModel > xModel;
+
+ SubComponentDescriptor()
+ :xFrame()
+ ,xController()
+ ,xModel()
+ {
+ }
+
+ SubComponentDescriptor( const Reference< XComponent >& _rxComponent )
+ {
+ xModel.set( _rxComponent, UNO_QUERY );
+
+ if ( xModel.is() )
+ xController.set( xModel->getCurrentController(), UNO_SET_THROW );
+ else
+ xController.set( _rxComponent, UNO_QUERY );
+
+ if ( xController.is() )
+ xFrame.set( xController->getFrame(), UNO_SET_THROW );
+ else
+ xFrame.set( _rxComponent, UNO_QUERY_THROW );
+
+ // if the given component was a frame, then ensure we have a controller
+ if ( xFrame.is() && !xController.is() )
+ xController.set( xFrame->getController(), UNO_SET_THROW );
+
+ // if the component was a frame or a controller, then check wether there is a model (not required)
+ if ( !xModel.is() )
+ xModel.set( xController->getModel() );
+ }
+ };
+
+ struct SelectSubComponent : public ::std::unary_function< SubComponentDescriptor, Reference< XComponent > >
+ {
+ Reference< XComponent > operator()( const SubComponentDescriptor _desc ) const
+ {
+ if ( _desc.xModel.is() )
+ return _desc.xModel.get();
+ OSL_ENSURE( _desc.xController.is(), "SelectSubComponent::operator(): illegal component!" );
+ return _desc.xController.get();
+ }
+ };
+
+ struct SubComponentAccessor
+ {
+ /// the name of the sub component
+ ::rtl::OUString sName;
+ /// type of the component - usually an ElementType value
+ sal_Int32 nComponentType;
+ /// the mode in which the sub component has been opened
+ ElementOpenMode eOpenMode;
+
+ SubComponentAccessor()
+ :sName()
+ ,nComponentType( sal_Int32( E_NONE ) )
+ ,eOpenMode( E_OPEN_NORMAL )
+ {
+ }
+
+ SubComponentAccessor( const ::rtl::OUString& _rName, const sal_Int32 _nCompType, const ElementOpenMode _eMode )
+ :sName( _rName )
+ ,nComponentType( _nCompType )
+ ,eOpenMode( _eMode )
+ {
+ }
+ };
+
+ struct SubComponentAccessorHash : public ::std::unary_function< SubComponentAccessor, size_t >
+ {
+ size_t operator()( const SubComponentAccessor& _lhs ) const
+ {
+ return _lhs.sName.hashCode() + _lhs.nComponentType + size_t( _lhs.eOpenMode );
+ }
+ };
+ struct SubComponentAccessorEqual : public ::std::binary_function< SubComponentAccessor, SubComponentAccessor, bool >
+ {
+ bool operator()( const SubComponentAccessor& _lhs, const SubComponentAccessor& _rhs ) const
+ {
+ return ( _lhs.sName == _rhs.sName )
+ && ( _lhs.nComponentType == _rhs.nComponentType )
+ && ( _lhs.eOpenMode == _rhs.eOpenMode );
+ }
+ };
+
+ typedef ::std::hash_map< SubComponentAccessor, SubComponentDescriptor, SubComponentAccessorHash, SubComponentAccessorEqual >
+ SubComponentMap;
+
+ }
+
+ //==============================================================================
+ //= SubComponentManager_Data
+ //==============================================================================
+ struct SubComponentManager_Data
+ {
+ SubComponentManager_Data( const ::comphelper::SharedMutex& _rMutex )
+ :m_aMutex( _rMutex )
+ {
+ }
+
+ mutable ::comphelper::SharedMutex m_aMutex;
+ SubComponentMap m_aComponents;
+
+ ::osl::Mutex& getMutex() const { return m_aMutex; }
+ };
+
+ //====================================================================
+ //= SubComponentManager
+ //====================================================================
+ //--------------------------------------------------------------------
+ SubComponentManager::SubComponentManager( const ::comphelper::SharedMutex& _rMutex )
+ :m_pData( new SubComponentManager_Data( _rMutex ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ SubComponentManager::~SubComponentManager()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SubComponentManager::disposing()
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+ m_pData->m_aComponents.clear();
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ bool lcl_fallbackToAnotherController( SubComponentDescriptor& _rCompDesc )
+ {
+ Reference< XController > xFallback;
+ OSL_PRECOND( _rCompDesc.xModel.is(), "lcl_fallbackToAnotherController: illegal call!" );
+ if ( !_rCompDesc.xModel.is() )
+ return false;
+
+ xFallback.set( _rCompDesc.xModel->getCurrentController() );
+ if ( xFallback == _rCompDesc.xController )
+ // don't accept the very same controller as fallback
+ xFallback.clear();
+
+ if ( !xFallback.is() )
+ {
+ // perhaps XModel2 can be of help here
+ Reference< XModel2 > xModel2( _rCompDesc.xModel, UNO_QUERY );
+ Reference< XEnumeration > xControllerEnum;
+ if ( xModel2.is() )
+ xControllerEnum = xModel2->getControllers();
+ while ( xControllerEnum.is() && xControllerEnum->hasMoreElements() )
+ {
+ xFallback.set( xControllerEnum->nextElement(), UNO_QUERY );
+ if ( xFallback == _rCompDesc.xController )
+ xFallback.clear();
+ }
+ }
+
+ if ( xFallback.is() )
+ {
+ _rCompDesc.xController = xFallback;
+ _rCompDesc.xFrame.set( xFallback->getFrame(), UNO_SET_THROW );
+ return true;
+ }
+
+ return false;
+ }
+
+ //----------------------------------------------------------------
+ bool lcl_closeComponent( const SubComponentDescriptor& _rComponent )
+ {
+ Reference< XController > xController( _rComponent.xController );
+ OSL_ENSURE( xController.is(), "lcl_closeComponent: invalid controller!" );
+
+ // suspend the controller in the document
+ if ( xController.is() )
+ if ( !xController->suspend( sal_True ) )
+ return false;
+
+ bool bSuccess = false;
+ try
+ {
+ Reference< XCloseable > xCloseable( _rComponent.xFrame, UNO_QUERY_THROW );
+ xCloseable->close( sal_True );
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSuccess;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubComponentManager::disposing( const EventObject& _rSource ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ for ( SubComponentMap::iterator comp = m_pData->m_aComponents.begin();
+ comp != m_pData->m_aComponents.end();
+ ++comp
+ )
+ {
+ bool bRemove = false;
+
+ if ( comp->second.xController == _rSource.Source )
+ {
+ if ( !comp->second.xModel.is() )
+ {
+ bRemove = true;
+ }
+ else
+ {
+ // maybe this is just one view to the sub document, and only this view is closed
+ if ( !lcl_fallbackToAnotherController( comp->second ) )
+ {
+ bRemove = true;
+ }
+ }
+ }
+ else if ( comp->second.xModel == _rSource.Source )
+ {
+ bRemove = true;
+ }
+
+ if ( bRemove )
+ {
+ m_pData->m_aComponents.erase( comp );
+ break;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Reference< XComponent> > SubComponentManager::getSubComponents() const
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ Sequence< Reference< XComponent > > aComponents( m_pData->m_aComponents.size() );
+ ::std::transform(
+ m_pData->m_aComponents.begin(),
+ m_pData->m_aComponents.end(),
+ aComponents.getArray(),
+ ::std::compose1( SelectSubComponent(), ::std::select2nd< SubComponentMap::value_type >() )
+ );
+ return aComponents;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool SubComponentManager::closeSubComponents()
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ try
+ {
+ typedef ::std::vector< SubComponentAccessor > ComponentAccessors;
+ ComponentAccessors aClosedComponents;
+
+ SubComponentMap aComponents( m_pData->m_aComponents );
+ for ( SubComponentMap::const_iterator comp = aComponents.begin();
+ comp != aComponents.end();
+ ++comp
+ )
+ {
+ lcl_closeComponent( comp->second );
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return empty();
+ }
+
+ // -----------------------------------------------------------------------------
+ bool SubComponentManager::empty() const
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+ return m_pData->m_aComponents.empty();
+ }
+
+ // -----------------------------------------------------------------------------
+ void SubComponentManager::onSubComponentOpened( const ::rtl::OUString& _rName, const sal_Int32 _nComponentType,
+ const ElementOpenMode _eOpenMode, const Reference< XComponent >& _rxComponent )
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ // put into map
+ SubComponentAccessor aKey( _rName, _nComponentType, _eOpenMode );
+ SubComponentDescriptor aElement( _rxComponent );
+
+ m_pData->m_aComponents.insert( SubComponentMap::value_type(
+ aKey, aElement
+ ) ) ;
+
+ // add as listener
+ aElement.xController->addEventListener( this );
+ if ( aElement.xModel.is() )
+ aElement.xModel->addEventListener( this );
+ }
+
+ // -----------------------------------------------------------------------------
+ bool SubComponentManager::activateSubFrame( const ::rtl::OUString& _rName, const sal_Int32 _nComponentType, const ElementOpenMode _eOpenMode ) const
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ SubComponentAccessor aKey( _rName, _nComponentType, _eOpenMode );
+ SubComponentMap::const_iterator pos = m_pData->m_aComponents.find( aKey );
+ if ( pos == m_pData->m_aComponents.end() )
+ // no component with this name/type/open mode
+ return false;
+
+ const Reference< XFrame > xFrame( pos->second.xFrame, UNO_SET_THROW );
+ const Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ xTopWindow->toFront();
+
+ return true;
+ }
+
+ // -----------------------------------------------------------------------------
+ bool SubComponentManager::closeSubFrames( const ::rtl::OUString& _rName, const sal_Int32 _nComponentType )
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ SubComponentMap aWorkingCopy( m_pData->m_aComponents );
+ for ( SubComponentMap::const_iterator comp = aWorkingCopy.begin();
+ comp != aWorkingCopy.end();
+ ++comp
+ )
+ {
+ if ( ( comp->first.sName != _rName ) || ( comp->first.nComponentType != _nComponentType ) )
+ continue;
+
+ if ( !lcl_closeComponent( comp->second ) )
+ return false;
+ }
+
+ return true;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
diff --git a/dbaccess/source/ui/app/subcomponentmanager.hxx b/dbaccess/source/ui/app/subcomponentmanager.hxx
new file mode 100644
index 000000000000..e2f882052d28
--- /dev/null
+++ b/dbaccess/source/ui/app/subcomponentmanager.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: subcomponentmanager.hxx,v $
+*
+* $Revision: 1.1.2.2 $
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef DBACCESS_SUBCOMPONENTMANAGER_HXX
+#define DBACCESS_SUBCOMPONENTMANAGER_HXX
+
+#include "AppElementType.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/frame/XController.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/sharedmutex.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ struct SubComponentManager_Data;
+ //====================================================================
+ //= SubComponentManager
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::lang::XEventListener
+ > SubComponentManager_Base;
+ class SubComponentManager : public SubComponentManager_Base
+ {
+ public:
+ SubComponentManager( const ::comphelper::SharedMutex& _rMutex );
+ virtual ~SubComponentManager();
+
+ void disposing();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDatabaseDocumentUI helpers
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> >
+ getSubComponents() const;
+ sal_Bool closeSubComponents();
+
+ // container access
+ void onSubComponentOpened(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nComponentType,
+ const ElementOpenMode _eOpenMode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&
+ _rxComponent
+ );
+ bool empty() const;
+
+ /** activates (i.e. brings to top) the frame in which the given component is loaded, if any
+
+ @return
+ <TRUE/> if any only of such a frame was found, i.e. the component had already been loaded
+ previously
+ */
+ bool activateSubFrame(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nComponentType,
+ const ElementOpenMode _eOpenMode
+ ) const;
+
+ /** closes all frames of the given component
+
+ If a view for the component (given by name and type) has been loaded into one or more
+ frames (with potentially different OpenModes), then those frames are gracefully closed.
+
+ @return
+ <TRUE/> if and only if closing those frames was successful, or frames for the given sub component
+ exist.
+ */
+ bool closeSubFrames(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nComponentType
+ );
+ private:
+ ::std::auto_ptr< SubComponentManager_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_SUBCOMPONENTMANAGER_HXX
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index 6352df1c8e4d..6443b06201c7 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -945,14 +945,14 @@ void SbaXDataBrowserController::disposing(const EventObject& Source) throw( Runt
// -----------------------------------------------------------------------
void SAL_CALL SbaXDataBrowserController::setIdentifier( const ::rtl::OUString& _Identifier ) throw (RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
m_sModuleIdentifier = _Identifier;
}
// -----------------------------------------------------------------------
::rtl::OUString SAL_CALL SbaXDataBrowserController::getIdentifier( ) throw (RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
return m_sModuleIdentifier;
}
@@ -1219,7 +1219,7 @@ void SbaXDataBrowserController::disposing()
//------------------------------------------------------------------------------
void SbaXDataBrowserController::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
SbaXDataBrowserController_Base::frameAction( aEvent );
diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx
index fddf41331548..87f924129c16 100644
--- a/dbaccess/source/ui/browser/dbloader.cxx
+++ b/dbaccess/source/ui/browser/dbloader.cxx
@@ -288,7 +288,9 @@ void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const ::
}
else if ( sDataSourceName.getLength() )
{
- xDatabaseDocument.set( getDataSourceOrModel( getDataSourceByName_displayError( sDataSourceName, NULL, m_xServiceFactory, sal_False ) ), UNO_QUERY );
+ ::dbtools::SQLExceptionInfo aError;
+ xDataSource.set( getDataSourceByName( sDataSourceName, NULL, m_xServiceFactory, &aError ) );
+ xDatabaseDocument.set( getDataSourceOrModel( xDataSource ), UNO_QUERY );
}
else if ( xConnection.is() )
{
diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx
index 93d53335bc59..2f7f745460e3 100644
--- a/dbaccess/source/ui/browser/dbtreeview.cxx
+++ b/dbaccess/source/ui/browser/dbtreeview.cxx
@@ -114,9 +114,9 @@ void DBTreeView::setModel(SvLBoxTreeList* _pTreeModel)
}
// -------------------------------------------------------------------------
-void DBTreeView::setSelectHdl(const Link& _rHdl)
+void DBTreeView::setSelChangeHdl( const Link& _rHdl )
{
- m_pTreeListBox->SetSelectHdl(_rHdl);
+ m_pTreeListBox->SetSelChangeHdl( _rHdl );
}
// -----------------------------------------------------------------------------
void DBTreeView::GetFocus()
diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx
index 5a53f6ffab71..534d51542495 100644
--- a/dbaccess/source/ui/browser/dbtreeview.hxx
+++ b/dbaccess/source/ui/browser/dbtreeview.hxx
@@ -73,7 +73,7 @@ namespace dbaui
void setModel(SvLBoxTreeList* _pTreeModel);
- void setSelectHdl(const Link& _rHdl);
+ void setSelChangeHdl(const Link& _rHdl);
DBTreeListBox& getListBox() const { return *m_pTreeListBox; }
diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
index 9dc6e028bfd2..e528427ac008 100644
--- a/dbaccess/source/ui/browser/dsbrowserDnD.cxx
+++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
@@ -82,8 +82,6 @@ namespace dbaui
{
try
{
- ::osl::MutexGuard aGuard(m_aEntryMutex);
-
::rtl::OUString aName = GetEntryText( _pApplyTo );
::rtl::OUString aDSName = getDataSourceAcessor( m_pTreeView->getListBox().GetRootLevelParent( _pApplyTo ) );
@@ -218,10 +216,11 @@ namespace dbaui
return NULL != pTransfer;
}
// -----------------------------------------------------------------------------
- IMPL_LINK(SbaTableQueryBrowser, OnCopyEntry, SvLBoxEntry*, _pEntry)
+ IMPL_LINK(SbaTableQueryBrowser, OnCopyEntry, void*, /*NOTINTERESIN*/)
{
- if( isEntryCopyAllowed(_pEntry) )
- copyEntry(_pEntry);
+ SvLBoxEntry* pSelected = m_pTreeView->getListBox().FirstSelected();
+ if( isEntryCopyAllowed( pSelected ) )
+ copyEntry( pSelected );
return 0;
}
// -----------------------------------------------------------------------------
@@ -246,8 +245,7 @@ namespace dbaui
{
m_nAsyncDrop = 0;
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
-
+ ::osl::MutexGuard aGuard( getMutex() );
if ( m_aAsyncDrop.nType == E_TABLE )
{
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
index 108a8b258b6e..a24c2d4e30dc 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -250,7 +250,7 @@ struct OGenericUnoController_Data
DBG_NAME(OGenericUnoController)
// -------------------------------------------------------------------------
OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFactory >& _rM)
- :OGenericUnoController_Base(m_aMutex)
+ :OGenericUnoController_Base( getMutex() )
#ifdef DBG_UTIL
,m_bDescribingSupportedFeatures( false )
#endif
@@ -266,7 +266,7 @@ OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFacto
{
osl_incrementInterlockedCount( &m_refCount );
{
- m_pData.reset( new OGenericUnoController_Data( *this, m_aMutex ) );
+ m_pData.reset( new OGenericUnoController_Data( *this, getMutex() ) );
}
osl_decrementInterlockedCount( &m_refCount );
@@ -284,7 +284,7 @@ OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFacto
// -----------------------------------------------------------------------------
OGenericUnoController::OGenericUnoController()
- :OGenericUnoController_Base(m_aMutex)
+ :OGenericUnoController_Base( getMutex() )
#ifdef DBG_UTIL
,m_bDescribingSupportedFeatures( false )
#endif
@@ -356,7 +356,7 @@ void OGenericUnoController::impl_initialize()
void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
{
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
Reference< XWindow > xParent;
Reference< XFrame > xFrame;
@@ -453,7 +453,7 @@ void OGenericUnoController::disposing(const EventObject& Source) throw( RuntimeE
//------------------------------------------------------------------------
void OGenericUnoController::modified(const EventObject& aEvent) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( !isDataSourceReadOnly() )
{
Reference<XModifiable> xModi(aEvent.Source,UNO_QUERY);
@@ -481,7 +481,7 @@ Reference< XWindow > SAL_CALL OGenericUnoController::getComponentWindow() throw
void OGenericUnoController::attachFrame( const Reference< XFrame >& _rxFrame ) throw( RuntimeException )
{
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
stopFrameListening( m_aCurrentFrame.getFrame() );
Reference< XFrame > xFrame = m_aCurrentFrame.attachFrame( _rxFrame );
@@ -965,7 +965,7 @@ void SAL_CALL OGenericUnoController::removeEventListener( const Reference< XEven
//------------------------------------------------------------------------------
void OGenericUnoController::frameAction(const FrameActionEvent& aEvent) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
if ( aEvent.Frame == m_aCurrentFrame.getFrame() )
m_aCurrentFrame.frameAction( aEvent.Action );
}
@@ -1101,35 +1101,26 @@ void OGenericUnoController::stopConnectionListening(const Reference< XConnection
xComponent->removeEventListener(static_cast<XFrameActionListener*>(this));
}
// -----------------------------------------------------------------------------
-Reference< XConnection > OGenericUnoController::connect(
- const Reference< XDataSource>& _xDataSource
- ,sal_Bool _bStartListening
- )
+Reference< XConnection > OGenericUnoController::connect( const Reference< XDataSource>& _xDataSource,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
- WaitObject aWaitCursor(getView());
+ WaitObject aWaitCursor( getView() );
ODatasourceConnector aConnector( getORB(), getView(), ::rtl::OUString() );
- Reference<XConnection> xConnection = aConnector.connect(_xDataSource);
-
- // be notified when connection is in disposing
- if (_bStartListening)
- startConnectionListening(xConnection);
+ Reference< XConnection > xConnection = aConnector.connect( _xDataSource, _pErrorInfo );
+ startConnectionListening( xConnection );
return xConnection;
}
// -----------------------------------------------------------------------------
-Reference< XConnection > OGenericUnoController::connect(
- const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rContextInformation,
- sal_Bool _bStartListening )
+Reference< XConnection > OGenericUnoController::connect( const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rContextInformation, ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
- WaitObject aWaitCursor(getView());
+ WaitObject aWaitCursor( getView() );
ODatasourceConnector aConnector( getORB(), getView(), _rContextInformation );
- Reference<XConnection> xConnection = aConnector.connect(_rDataSourceName);
-
- // be notified when connection is in disposing
- if (_bStartListening)
- startConnectionListening(xConnection);
+ Reference<XConnection> xConnection = aConnector.connect( _rDataSourceName, _pErrorInfo );
+ startConnectionListening( xConnection );
return xConnection;
}
@@ -1219,7 +1210,7 @@ Reference< XModel > SAL_CALL OGenericUnoController::getModel(void) throw( Runtim
// -----------------------------------------------------------------------------
Reference< XFrame > SAL_CALL OGenericUnoController::getFrame(void) throw( RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
return m_aCurrentFrame.getFrame();
}
@@ -1442,7 +1433,7 @@ Reference< awt::XWindow> OGenericUnoController::getTopMostContainerWindow() cons
Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw()
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( ! m_xTitleHelper.is ())
{
@@ -1464,7 +1455,7 @@ Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw()
::rtl::OUString SAL_CALL OGenericUnoController::getTitle()
throw (RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( m_bExternalTitle )
return impl_getTitleHelper_throw()->getTitle ();
return getPrivateTitle() + impl_getTitleHelper_throw()->getTitle ();
@@ -1476,7 +1467,7 @@ void SAL_CALL OGenericUnoController::setTitle(const ::rtl::OUString& sTitle)
throw (RuntimeException)
{
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
m_bExternalTitle = sal_True;
impl_getTitleHelper_throw()->setTitle (sTitle);
}
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 8e2f1cbce337..86dc62eda2de 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -82,6 +82,7 @@
#include <com/sun/star/sdb/XResultSetAccess.hpp>
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/FetchDirection.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp>
@@ -223,8 +224,8 @@ DBG_NAME(SbaTableQueryBrowser);
//------------------------------------------------------------------------------
SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XMultiServiceFactory >& _rM)
:SbaXDataBrowserController(_rM)
- ,m_aSelectionListeners(m_aMutex)
- ,m_aContextMenuInterceptors(m_aMutex)
+ ,m_aSelectionListeners( getMutex() )
+ ,m_aContextMenuInterceptors( getMutex() )
,m_aTableCopyHelper(this)
,m_pTreeView(NULL)
,m_pSplitter(NULL)
@@ -402,7 +403,7 @@ sal_Bool SbaTableQueryBrowser::Construct(Window* pParent)
m_pTreeModel->SetSortMode(SortAscending);
m_pTreeModel->SetCompareHdl(LINK(this, SbaTableQueryBrowser, OnTreeEntryCompare));
m_pTreeView->setModel(m_pTreeModel);
- m_pTreeView->setSelectHdl(LINK(this, SbaTableQueryBrowser, OnSelectEntry));
+ m_pTreeView->setSelChangeHdl( LINK( this, SbaTableQueryBrowser, OnSelectionChange ) );
// TODO
getBrowserView()->getVclControl()->GetDataWindow().SetUniqueId(UID_DATABROWSE_DATAWINDOW);
@@ -600,10 +601,19 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun::
{
case DataType::BIT:
case DataType::BOOLEAN:
+ {
aCurrentModelType = ::rtl::OUString::createFromAscii("CheckBox");
aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisualEffect" ) ), makeAny( VisualEffect::FLAT ) ) );
sDefaultProperty = PROPERTY_DEFAULTSTATE;
- break;
+
+ sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
+ OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable );
+ aInitialValues.push_back( NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TriState" ) ),
+ makeAny( sal_Bool( ColumnValue::NO_NULLS != nNullable ) )
+ ) );
+ }
+ break;
case DataType::LONGVARCHAR:
aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), makeAny( (sal_Bool)sal_True ) ) );
@@ -835,7 +845,7 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) throw(
sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeException )
{
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( getView() && getView()->IsInModalMode() )
return sal_False;
sal_Bool bRet = sal_False;
@@ -1773,8 +1783,10 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue
unloadAndCleanup( sal_False );
// reselect the entry
- if(pSelected)
- OnSelectEntry( pSelected );
+ if ( pSelected )
+ {
+ implSelect( pSelected );
+ }
else
{
Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
@@ -2022,8 +2034,6 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent)
// nothing to to ...
return 1L;
- ::osl::MutexGuard aGuard(m_aEntryMutex);
-
SvLBoxEntry* pFirstParent = m_pTreeView->getListBox().GetRootLevelParent(_pParent);
OSL_ENSURE(pFirstParent,"SbaTableQueryBrowser::OnExpandEntry: No rootlevelparent!");
@@ -2289,7 +2299,7 @@ sal_Bool SbaTableQueryBrowser::implSelect(const ::rtl::OUString& _rDataSourceNam
{
if ( _bSelectDirect )
{
- OnSelectEntry(pCommand);
+ implSelect( pCommand );
}
else
m_pTreeView->getListBox().Select(pCommand);
@@ -2314,11 +2324,18 @@ sal_Bool SbaTableQueryBrowser::implSelect(const ::rtl::OUString& _rDataSourceNam
}
//------------------------------------------------------------------------------
-IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry)
+IMPL_LINK(SbaTableQueryBrowser, OnSelectionChange, void*, /*NOINTERESTEDIN*/)
{
- ::osl::MutexGuard aGuard(m_aEntryMutex);
+ return implSelect( m_pTreeView->getListBox().FirstSelected() ) ? 1L : 0L;
+}
- DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
+//------------------------------------------------------------------------------
+bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
+{
+ if ( !_pEntry )
+ return false;
+
+ DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( _pEntry->GetUserData() );
switch (pEntryData->eType)
{
case etTableOrView:
@@ -2326,11 +2343,11 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry)
break;
default:
// nothing to do
- return 0L;
+ return false;
}
- OSL_ENSURE(m_pTreeModel->HasParent(_pEntry), "SbaTableQueryBrowser::OnSelectEntry: invalid entry (1)!");
- OSL_ENSURE(m_pTreeModel->HasParent(m_pTreeModel->GetParent(_pEntry)), "SbaTableQueryBrowser::OnSelectEntry: invalid entry (2)!");
+ OSL_ENSURE(m_pTreeModel->HasParent(_pEntry), "SbaTableQueryBrowser::implSelect: invalid entry (1)!");
+ OSL_ENSURE(m_pTreeModel->HasParent(m_pTreeModel->GetParent(_pEntry)), "SbaTableQueryBrowser::implSelect: invalid entry (2)!");
// get the entry for the tables or queries
SvLBoxEntry* pContainer = m_pTreeModel->GetParent(_pEntry);
@@ -2490,7 +2507,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry)
if(e.TargetException >>= aSql)
showError(SQLExceptionInfo(aSql));
else
- OSL_ENSURE(sal_False, "SbaTableQueryBrowser::OnSelectEntry: something strange happended!");
+ OSL_ENSURE(sal_False, "SbaTableQueryBrowser::implSelect: something strange happended!");
// reset the values
xRowSetProps->setPropertyValue(PROPERTY_DATASOURCENAME,Any());
xRowSetProps->setPropertyValue(PROPERTY_ACTIVE_CONNECTION,Any());
@@ -2502,7 +2519,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry)
xRowSetProps->setPropertyValue(PROPERTY_ACTIVE_CONNECTION,Any());
}
}
- return 0L;
+ return true;
}
// -----------------------------------------------------------------------------
@@ -2533,7 +2550,6 @@ SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAc
void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aEntryMutex);
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
// first search for a definition container where we can insert this element
@@ -2590,8 +2606,6 @@ sal_Bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const String& _sName,
void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aEntryMutex);
-
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
// get the top-level representing the removed data source
@@ -2700,7 +2714,7 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven
// -------------------------------------------------------------------------
void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aEntryMutex);
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
SvLBoxEntry* pContainer = getEntryFromContainer(xNames);
@@ -3218,7 +3232,7 @@ sal_Bool SbaTableQueryBrowser::ensureConnection( SvLBoxEntry* _pDSEntry, void* p
// connect
_rConnection.reset(
- connect( getDataSourceAcessor( _pDSEntry ), sConnectingContext, sal_True ),
+ connect( getDataSourceAcessor( _pDSEntry ), sConnectingContext, NULL ),
SharedConnection::TakeOwnership
);
@@ -3318,8 +3332,8 @@ void SbaTableQueryBrowser::implAdministrate( SvLBoxEntry* _pApplyTo )
if (pTopLevelSelected)
sInitialSelection = getDataSourceAcessor( pTopLevelSelected );
- Reference< XModel > xDocumentModel(
- getDataSourceOrModel(getDataSourceByName_displayError( sInitialSelection, getView(), getORB(), true )),UNO_QUERY);
+ Reference< XDataSource > xDataSource( getDataSourceByName( sInitialSelection, getView(), getORB(), NULL ) );
+ Reference< XModel > xDocumentModel( getDataSourceOrModel( xDataSource ), UNO_QUERY );
if ( xDocumentModel.is() )
{
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
index 89b0d790909d..af2f7e0939bf 100644
--- a/dbaccess/source/ui/control/dbtreelistbox.cxx
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -104,11 +104,9 @@ DBG_NAME(DBTreeListBox)
//------------------------------------------------------------------------
DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle ,sal_Bool _bHandleEnterKey)
:SvTreeListBox(pParent,nWinStyle)
- ,m_pSelectedEntry(NULL)
,m_pDragedEntry(NULL)
,m_pActionListener(NULL)
,m_pContextMenuProvider( NULL )
- ,m_nSelectLock(0)
,m_bHandleEnterKey(_bHandleEnterKey)
,m_xORB(_rxORB)
{
@@ -118,11 +116,9 @@ DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFac
// -----------------------------------------------------------------------------
DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId,sal_Bool _bHandleEnterKey)
:SvTreeListBox(pParent,rResId)
- ,m_pSelectedEntry(NULL)
,m_pDragedEntry(NULL)
,m_pActionListener(NULL)
,m_pContextMenuProvider( NULL )
- ,m_nSelectLock(0)
,m_bHandleEnterKey(_bHandleEnterKey)
,m_xORB(_rxORB)
{
@@ -149,8 +145,7 @@ void DBTreeListBox::init()
DBTreeListBox::~DBTreeListBox()
{
DBG_DTOR(DBTreeListBox,NULL);
- if(m_aTimer.IsActive())
- m_aTimer.Stop();
+ implStopSelectionTimer();
}
//------------------------------------------------------------------------
SvLBoxEntry* DBTreeListBox::GetEntryPosByName( const String& aName, SvLBoxEntry* pStart, const IEntryFilter* _pFilter ) const
@@ -200,20 +195,6 @@ void DBTreeListBox::RequestingChilds( SvLBoxEntry* pParent )
}
// -------------------------------------------------------------------------
-void DBTreeListBox::SelectEntry(SvLBoxEntry* _pEntry)
-{
- OSL_ENSURE(_pEntry,"Who called me with NULL!");
- if ( _pEntry )
- {
- if ( GetCurEntry() )
- Select(GetCurEntry(), sal_False);
- Select(_pEntry, sal_True);
- SetCurEntry(_pEntry);
- implSelected(_pEntry);
- }
-}
-
-// -------------------------------------------------------------------------
void DBTreeListBox::InitEntry( SvLBoxEntry* _pEntry, const XubString& aStr, const Image& _rCollEntryBmp, const Image& _rExpEntryBmp, SvLBoxButtonKind eButtonKind)
{
SvTreeListBox::InitEntry( _pEntry, aStr, _rCollEntryBmp,_rExpEntryBmp, eButtonKind);
@@ -223,40 +204,33 @@ void DBTreeListBox::InitEntry( SvLBoxEntry* _pEntry, const XubString& aStr, cons
}
// -------------------------------------------------------------------------
-void DBTreeListBox::implSelected(SvLBoxEntry* _pSelected)
+void DBTreeListBox::implStopSelectionTimer()
{
- if(!m_nSelectLock && _pSelected && m_pSelectedEntry != _pSelected)
- {
- // re-start the timer
- if(m_aTimer.IsActive())
- m_aTimer.Stop();
- m_pSelectedEntry = _pSelected;
- m_aTimer.Start();
- }
+ if ( m_aTimer.IsActive() )
+ m_aTimer.Stop();
}
// -------------------------------------------------------------------------
-sal_Int32 DBTreeListBox::lockAutoSelect()
+void DBTreeListBox::implStartSelectionTimer()
{
- return ++m_nSelectLock;
+ implStopSelectionTimer();
+ m_aTimer.Start();
}
-// -------------------------------------------------------------------------
-sal_Int32 DBTreeListBox::unlockAutoSelect()
-{
- DBG_ASSERT(m_nSelectLock, "DBTreeListBox::unlockAutoSelect: not locked!");
- return --m_nSelectLock;
-}
// -----------------------------------------------------------------------------
void DBTreeListBox::DeselectHdl()
{
+ m_aSelectedEntries.erase( GetHdlEntry() );
SvTreeListBox::DeselectHdl();
+ implStartSelectionTimer();
}
// -------------------------------------------------------------------------
void DBTreeListBox::SelectHdl()
{
- implSelected(GetHdlEntry());
+ m_aSelectedEntries.insert( GetHdlEntry() );
+ SvTreeListBox::SelectHdl();
+ implStartSelectionTimer();
}
// -------------------------------------------------------------------------
@@ -281,15 +255,16 @@ IMPL_LINK(DBTreeListBox, OnResetEntry, SvLBoxEntry*, pEntry)
// -----------------------------------------------------------------------------
void DBTreeListBox::ModelHasEntryInvalidated( SvListEntry* _pEntry )
{
- SvTreeListBox::ModelHasEntryInvalidated(_pEntry);
- if ( _pEntry == m_pSelectedEntry && m_pSelectedEntry )
+ SvTreeListBox::ModelHasEntryInvalidated( _pEntry );
+
+ if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
{
- SvLBoxItem* pTextItem = m_pSelectedEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
- if ( pTextItem && !static_cast<OBoldListboxString*>(pTextItem)->isEmphasized() )
+ SvLBoxItem* pTextItem = static_cast< SvLBoxEntry* >( _pEntry )->GetFirstItem( SV_ITEM_ID_BOLDLBSTRING );
+ if ( pTextItem && !static_cast< OBoldListboxString* >( pTextItem )->isEmphasized() )
{
- if(m_aTimer.IsActive())
- m_aTimer.Stop();
- m_pSelectedEntry = NULL;
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( _pEntry );
+ // ehm - why?
}
}
}
@@ -297,11 +272,10 @@ void DBTreeListBox::ModelHasEntryInvalidated( SvListEntry* _pEntry )
void DBTreeListBox::ModelHasRemoved( SvListEntry* _pEntry )
{
SvTreeListBox::ModelHasRemoved(_pEntry);
- if (_pEntry == m_pSelectedEntry)
+ if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
{
- if(m_aTimer.IsActive())
- m_aTimer.Stop();
- m_pSelectedEntry = NULL;
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( _pEntry );
}
}
@@ -364,7 +338,7 @@ void DBTreeListBox::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
if ( m_pDragedEntry && m_pActionListener->requestDrag( _nAction, _rPosPixel ) )
{
// if the (asynchronous) drag started, stop the selection timer
- m_aTimer.Stop();
+ implStopSelectionTimer();
// and stop selecting entries by simply moving the mouse
EndSelection();
}
@@ -414,24 +388,24 @@ void DBTreeListBox::KeyInput( const KeyEvent& rKEvt )
switch(eFunc)
{
case KEYFUNC_CUT:
- bHandled = (m_aCutHandler.IsSet() && m_pSelectedEntry);
+ bHandled = ( m_aCutHandler.IsSet() && !m_aSelectedEntries.empty() );
if ( bHandled )
- m_aCutHandler.Call(m_pSelectedEntry);
+ m_aCutHandler.Call( NULL );
break;
case KEYFUNC_COPY:
- bHandled = (m_aCopyHandler.IsSet() && m_pSelectedEntry);
+ bHandled = ( m_aCopyHandler.IsSet() && !m_aSelectedEntries.empty() );
if ( bHandled )
- m_aCopyHandler.Call(m_pSelectedEntry);
+ m_aCopyHandler.Call( NULL );
break;
case KEYFUNC_PASTE:
- bHandled = (m_aPasteHandler.IsSet() && m_pSelectedEntry);
+ bHandled = ( m_aPasteHandler.IsSet() && !m_aSelectedEntries.empty() );
if ( bHandled )
- m_aPasteHandler.Call(m_pSelectedEntry);
+ m_aPasteHandler.Call( NULL );
break;
case KEYFUNC_DELETE:
- bHandled = (m_aDeleteHandler.IsSet() && m_pSelectedEntry);
+ bHandled = ( m_aDeleteHandler.IsSet() && !m_aSelectedEntries.empty() );
if ( bHandled )
- m_aDeleteHandler.Call(m_pSelectedEntry);
+ m_aDeleteHandler.Call( NULL );
break;
default:
break;
@@ -480,9 +454,8 @@ BOOL DBTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText
aEntry.aNewText =rNewText;
if(m_aEditedHandler.Call(&aEntry) != 0)
{
- if(m_aTimer.IsActive())
- m_aTimer.Stop();
- m_pSelectedEntry = NULL; // to force that the renamed selection will be reselected
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( pEntry );
}
SetEntryText(pEntry,aEntry.aNewText);
@@ -730,24 +703,23 @@ PopupMenu* DBTreeListBox::CreateContextMenu( void )
// -----------------------------------------------------------------------------
void DBTreeListBox::ExcecuteContextMenuAction( USHORT _nSelectedPopupEntry )
{
- if ( m_pContextMenuProvider )
+ if ( m_pContextMenuProvider && _nSelectedPopupEntry )
m_pContextMenuProvider->getCommandController().executeChecked( _nSelectedPopupEntry, Sequence< PropertyValue >() );
}
// -----------------------------------------------------------------------------
IMPL_LINK(DBTreeListBox, OnTimeOut, void*, /*EMPTY_ARG*/)
{
- if(m_aTimer.IsActive())
- m_aTimer.Stop();
- if (m_pSelectedEntry)
- aSelectHdl.Call( m_pSelectedEntry );
+ implStopSelectionTimer();
+
+ m_aSelChangeHdl.Call( NULL );
return 0L;
}
// -----------------------------------------------------------------------------
void DBTreeListBox::StateChanged( StateChangedType nStateChange )
{
- if ( nStateChange == STATE_CHANGE_VISIBLE && m_aTimer.IsActive() )
- m_aTimer.Stop();
+ if ( nStateChange == STATE_CHANGE_VISIBLE )
+ implStopSelectionTimer();
}
// .........................................................................
} // namespace dbaui
diff --git a/dbaccess/source/ui/dlg/dbadmin.src b/dbaccess/source/ui/dlg/dbadmin.src
index dbdb441b0c08..3ccb261bad48 100644
--- a/dbaccess/source/ui/dlg/dbadmin.src
+++ b/dbaccess/source/ui/dlg/dbadmin.src
@@ -537,13 +537,15 @@ TabPage PAGE_MYSQL_JDBC
FixedText FT_JDBCDRIVERCLASS
{
- Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ;
+ Pos = MAP_APPFONT ( 6,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ;
Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
Text[ en-US ] = "MySQL JDBC d~river class";
};
Edit ET_JDBCDRIVERCLASS
{
- Pos = MAP_APPFONT ( EDIT_X , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 + EDIT_HEIGHT) ;
+ Pos = MAP_APPFONT ( EDIT_X,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 + EDIT_HEIGHT) ;
Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ;
TabStop = TRUE ;
Border = TRUE ;
@@ -572,13 +574,15 @@ TabPage PAGE_ORACLE_JDBC
FixedText FT_JDBCDRIVERCLASS
{
- Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ;
+ Pos = MAP_APPFONT ( 6,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ;
Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
Text[ en-US ] = "Oracle JDBC d~river class";
};
Edit ET_JDBCDRIVERCLASS
{
- Pos = MAP_APPFONT ( EDIT_X , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 + EDIT_HEIGHT) ;
+ Pos = MAP_APPFONT ( EDIT_X,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT + ( FIXEDTEXT_HEIGHT - EDIT_HEIGHT ) / 2 ) ;
Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ;
TabStop = TRUE ;
Border = TRUE ;
@@ -586,7 +590,8 @@ TabPage PAGE_ORACLE_JDBC
PushButton PB_TESTDRIVERCLASS
{
TabStop = TRUE ;
- Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -2 + EDIT_HEIGHT) ;
+ Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT + ( FIXEDTEXT_HEIGHT - BUTTON_HEIGHT ) / 2 ) ;
Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
Text [ en-US ] = "Test class" ;
};
diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx
index 094b4ca727c1..9ebdb683e4a4 100644
--- a/dbaccess/source/ui/dlg/paramdialog.cxx
+++ b/dbaccess/source/ui/dlg/paramdialog.cxx
@@ -67,6 +67,7 @@
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
+#include <tools/diagnose_ex.h>
#ifndef _DBAUI_LOCALRESACCESS_HXX_
#include "localresaccess.hxx"
#endif
@@ -163,7 +164,7 @@ DBG_NAME(OParameterDialog)
}
catch(Exception&)
{
- DBG_ERROR("OParameterDialog::OParameterDialog : soemthing went wrong while retrieving the parameters !");
+ DBG_UNHANDLED_EXCEPTION();
}
@@ -254,6 +255,7 @@ DBG_NAME(OParameterDialog)
}
catch(Exception&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
String sMessage;
@@ -314,6 +316,7 @@ DBG_NAME(OParameterDialog)
}
catch(Exception&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
}
diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx
index d45087709e8d..1078946a5dc5 100644
--- a/dbaccess/source/ui/inc/QueryDesignView.hxx
+++ b/dbaccess/source/ui/inc/QueryDesignView.hxx
@@ -153,7 +153,18 @@ namespace dbaui
void stopTimer();
void startTimer();
void reset();
- sal_Bool InitFromParseNode();
+
+ /** initializes the view from the current parser / parse iterator of the controller
+
+ @param _pErrorInfo
+ When not <NULL/>, the instance pointed to by this parameter takes the error
+ which happened during the initialization.
+ If it is not <NULL/>, then any such error will be displayed, using the controller's
+ showError method.
+
+ @return <TRUE/> if and only if the initialization was successful
+ */
+ bool initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo );
::connectivity::OSQLParseNode* getPredicateTreeFromEntry( OTableFieldDescRef pEntry,
const String& _sCriteria,
diff --git a/dbaccess/source/ui/inc/QueryViewSwitch.hxx b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
index 122dd2f24b41..c0692ba48af0 100644
--- a/dbaccess/source/ui/inc/QueryViewSwitch.hxx
+++ b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
@@ -30,9 +30,12 @@
#ifndef DBAUI_QUERYVIEWSWITCH_HXX
#define DBAUI_QUERYVIEWSWITCH_HXX
-#ifndef DBAUI_QUERYVIEW_HXX
#include "queryview.hxx"
-#endif
+
+namespace dbtools
+{
+ class SQLExceptionInfo;
+}
namespace dbaui
{
@@ -70,18 +73,20 @@ namespace dbaui
virtual void initialize();
/** show the text or the design view
@return
- <TRUE/> when all went right otherwise <FALSE/> which implies an aditional
- call of switchView from the controller to restore the old state
+ <TRUE/> if and only if the view could be successfully, switched, <FALSE/> otherwise
+ (In the latter case, the controller will issue another switchView call to restore the
+ old state)
*/
- sal_Bool switchView();
+ bool switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo );
sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
void setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
void setNoneVisbleRow(sal_Int32 _nRows);
+ void SaveUIConfig();
+ bool reset( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+ void GrabFocus();
+
// returs the add table dialog from the design view
OAddTableDlg* getAddTableDialog();
- void SaveUIConfig();
- void reset();
- void GrabFocus();
OQueryDesignView* getDesignView() const { return m_pDesignView; }
OQueryContainerWindow* getContainer() const;
diff --git a/dbaccess/source/ui/inc/RTableConnectionData.hxx b/dbaccess/source/ui/inc/RTableConnectionData.hxx
index d5215e503734..1cb3c75540bd 100644
--- a/dbaccess/source/ui/inc/RTableConnectionData.hxx
+++ b/dbaccess/source/ui/inc/RTableConnectionData.hxx
@@ -58,7 +58,6 @@ namespace dbaui
friend bool operator!=(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs) { return !(lhs == rhs); }
::osl::Mutex m_aMutex;
- ::rtl::OUString m_sDatabaseName;
// @see com.sun.star.sdbc.KeyRule
sal_Int32 m_nUpdateRules;
@@ -85,8 +84,6 @@ namespace dbaui
virtual void CopyFrom(const OTableConnectionData& rSource);
virtual OTableConnectionData* NewInstance() const { return new ORelationTableConnectionData(); }
- inline ::rtl::OUString GetDatabaseName() const { return m_sDatabaseName; }
-
/** Update create a new relation
@return true if successful
diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx
index 297cdceb9b36..51722ee431cb 100644
--- a/dbaccess/source/ui/inc/UITools.hxx
+++ b/dbaccess/source/ui/inc/UITools.hxx
@@ -200,15 +200,15 @@ namespace dbaui
the window to use as parent for error messages
@param _rxORB
a service factory to use for components to be created
- @param _bDisplayError
- determines whether the method should display an error, when it happens, or simply absorb it
+ @param _pErrorInfo
+ takes the error info in case of failure. If <NULL/>, the error is displayed to the user.
*/
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >
- getDataSourceByName_displayError(
+ getDataSourceByName(
const ::rtl::OUString& _rDataSourceName,
Window* _pErrorMessageParent,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB,
- bool _bDisplayError
+ ::dbtools::SQLExceptionInfo* _pErrorInfo
);
/** returns either the model when data source is given as parameter,
diff --git a/dbaccess/source/ui/inc/WNameMatch.hxx b/dbaccess/source/ui/inc/WNameMatch.hxx
index 3b6653494ac7..c8f7daa83394 100644
--- a/dbaccess/source/ui/inc/WNameMatch.hxx
+++ b/dbaccess/source/ui/inc/WNameMatch.hxx
@@ -95,8 +95,8 @@ namespace dbaui
DECL_LINK( ButtonClickHdl, Button * );
DECL_LINK( RightButtonClickHdl, Button * );
DECL_LINK( AllNoneClickHdl, Button * );
- DECL_LINK( TableListClickHdl, SvTreeListBox* );
- DECL_LINK( TableListRightSelectHdl, SvTreeListBox* );
+ DECL_LINK( TableListClickHdl, void* );
+ DECL_LINK( TableListRightSelectHdl, void* );
public:
virtual void Reset ( );
diff --git a/dbaccess/source/ui/inc/datasourceconnector.hxx b/dbaccess/source/ui/inc/datasourceconnector.hxx
index 4a6b31dedb8b..382e59b10e7f 100644
--- a/dbaccess/source/ui/inc/datasourceconnector.hxx
+++ b/dbaccess/source/ui/inc/datasourceconnector.hxx
@@ -44,6 +44,11 @@
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
+namespace dbtools
+{
+ class SQLExceptionInfo;
+}
+
class Window;
//.........................................................................
namespace dbaui
@@ -75,14 +80,21 @@ namespace dbaui
/// returns <TRUE/> if the object is able to create data source connections
sal_Bool isValid() const { return m_xORB.is(); }
- /// create a data source connection
+ /** creates a connection to the data source, displays the possible error to the user, or returns it
+ */
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
- connect(const ::rtl::OUString& _rDataSourceName, sal_Bool _bShowError = sal_True) const;
+ connect(
+ const ::rtl::OUString& _rDataSourceName,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo
+ ) const;
- /// create a data source connection
+ /** creates a connection to the data source, displays the possible error to the user, or returns it
+ */
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
- connect(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& _xDataSource
- , sal_Bool _bShowError = sal_True) const;
+ connect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& _xDataSource,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo
+ ) const;
};
//.........................................................................
diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx
index b28729b29eb8..2877e2650323 100644
--- a/dbaccess/source/ui/inc/dbtreelistbox.hxx
+++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx
@@ -30,21 +30,15 @@
#ifndef DBAUI_DBTREELISTBOX_HXX
#define DBAUI_DBTREELISTBOX_HXX
-#ifndef _SVTREEBOX_HXX
-#include <svtools/svtreebx.hxx>
-#endif
-#ifndef _SV_TIMER_HXX
-#include <vcl/timer.hxx>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#endif
-#ifndef DBAUI_SCROLLHELPER_HXX
#include "ScrollHelper.hxx"
-#endif
-#ifndef _DBAUI_MODULE_DBU_HXX_
#include "moduledbu.hxx"
-#endif
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <svtools/svtreebx.hxx>
+#include <vcl/timer.hxx>
+
+#include <set>
namespace dbaui
@@ -70,13 +64,14 @@ namespace dbaui
OScrollHelper m_aScrollHelper;
Timer m_aTimer; // is needed for table updates
Point m_aMousePos;
- SvLBoxEntry* m_pSelectedEntry;
+ ::std::set< SvListEntry* > m_aSelectedEntries;
SvLBoxEntry* m_pDragedEntry;
IControlActionListener* m_pActionListener;
IContextMenuProvider*
m_pContextMenuProvider;
Link m_aPreExpandHandler; // handler to be called before a node is expanded
+ Link m_aSelChangeHdl; // handlet to be called (asynchronously) when the selection changes in any way
Link m_aCutHandler; // called when someone press CTRL+X
Link m_aCopyHandler; // called when someone press CTRL+C
Link m_aPasteHandler; // called when someone press CTRL+V
@@ -86,7 +81,6 @@ namespace dbaui
Link m_aEnterKeyHdl;
- sal_Int32 m_nSelectLock;
sal_Bool m_bHandleEnterKey;
protected:
@@ -116,28 +110,15 @@ namespace dbaui
inline void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) { m_xORB = _xORB; }
- void SetPreExpandHandler(const Link& _rHdl) { m_aPreExpandHandler = _rHdl; }
- Link GetPreExpandHandler() const { return m_aPreExpandHandler; }
-
- void setCutHandler(const Link& _rHdl) { m_aCutHandler = _rHdl; }
- Link getCutHandler() const { return m_aCutHandler; }
-
- void setCopyHandler(const Link& _rHdl) { m_aCopyHandler = _rHdl; }
- Link getCopyHandler() const { return m_aCopyHandler; }
-
- void setPasteHandler(const Link& _rHdl) { m_aPasteHandler = _rHdl; }
- Link getPasteHandler() const { return m_aPasteHandler; }
+ void SetPreExpandHandler(const Link& _rHdl) { m_aPreExpandHandler = _rHdl; }
+ void SetSelChangeHdl( const Link& _rHdl ) { m_aSelChangeHdl = _rHdl; }
+ void setCutHandler(const Link& _rHdl) { m_aCutHandler = _rHdl; }
+ void setCopyHandler(const Link& _rHdl) { m_aCopyHandler = _rHdl; }
+ void setPasteHandler(const Link& _rHdl) { m_aPasteHandler = _rHdl; }
+ void setDeleteHandler(const Link& _rHdl) { m_aDeleteHandler = _rHdl; }
+ void setEditingHandler(const Link& _rHdl) { m_aEditingHandler = _rHdl; }
+ void setEditedHandler(const Link& _rHdl) { m_aEditedHandler = _rHdl; }
- void setDeleteHandler(const Link& _rHdl) { m_aDeleteHandler = _rHdl; }
- Link getDeleteHandler() const { return m_aDeleteHandler; }
-
- void setEditingHandler(const Link& _rHdl){ m_aEditingHandler = _rHdl; }
- Link getEditingHandler() const { return m_aEditingHandler; }
-
- void setEditedHandler(const Link& _rHdl) { m_aEditedHandler = _rHdl; }
- Link getEditedHandler() const { return m_aEditedHandler; }
-
- inline SvLBoxEntry* GetSelectedEntry() const { return m_pSelectedEntry; }
// modified the given entry so that the expand handler is called whenever the entry is expanded
// (normally, the expand handler is called only once)
void EnableExpandHandler(SvLBoxEntry* _pEntry);
@@ -152,7 +133,6 @@ namespace dbaui
virtual void StateChanged( StateChangedType nStateChange );
virtual void InitEntry( SvLBoxEntry* pEntry, const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp, SvLBoxButtonKind eButtonKind);
- virtual void SelectEntry(SvLBoxEntry* _pEntry);
// enable editing for tables/views and queries
virtual BOOL EditingEntry( SvLBoxEntry* pEntry, Selection& );
virtual BOOL EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
@@ -162,13 +142,9 @@ namespace dbaui
virtual PopupMenu* CreateContextMenu( void );
virtual void ExcecuteContextMenuAction( USHORT nSelectedPopupEntry );
- sal_Int32 lockAutoSelect();
- sal_Int32 unlockAutoSelect();
- sal_Int32 locked() const { return m_nSelectLock; }
-
void SetEnterKeyHdl(const Link& rNewHdl) {m_aEnterKeyHdl = rNewHdl;}
- inline void clearCurrentSelectionEntry() { m_pSelectedEntry = NULL; }
+ void clearCurrentSelection() { m_aSelectedEntries.clear(); }
protected:
virtual void MouseButtonDown( const MouseEvent& rMEvt );
@@ -183,7 +159,8 @@ namespace dbaui
virtual void ModelHasRemoved( SvListEntry* pEntry );
virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
- void implSelected(SvLBoxEntry* _pSelected);
+ void implStopSelectionTimer();
+ void implStartSelectionTimer();
protected:
using SvTreeListBox::ExecuteDrop;
diff --git a/dbaccess/source/ui/inc/querycontainerwindow.hxx b/dbaccess/source/ui/inc/querycontainerwindow.hxx
index 831af124969b..44af65ed2b2a 100644
--- a/dbaccess/source/ui/inc/querycontainerwindow.hxx
+++ b/dbaccess/source/ui/inc/querycontainerwindow.hxx
@@ -113,11 +113,12 @@ namespace dbaui
::rtl::OUString getStatement() { return m_pViewSwitch->getStatement( ); }
void setStatement( const ::rtl::OUString& _rsStatement ) { m_pViewSwitch->setStatement( _rsStatement ); }
- void initialize() { m_pViewSwitch->initialize(); }
- void SaveUIConfig() { m_pViewSwitch->SaveUIConfig(); }
- void reset() { m_pViewSwitch->reset(); }
+ void initialize() { m_pViewSwitch->initialize(); }
+ void SaveUIConfig() { m_pViewSwitch->SaveUIConfig(); }
+ bool reset( ::dbtools::SQLExceptionInfo* _pErrorInfo ) { return m_pViewSwitch->reset( _pErrorInfo ); }
+
+ bool switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo );
- sal_Bool switchView();
virtual void GetFocus();
protected:
diff --git a/dbaccess/source/ui/inc/querycontroller.hxx b/dbaccess/source/ui/inc/querycontroller.hxx
index c3a50673a76b..b79e6ea6dfc5 100644
--- a/dbaccess/source/ui/inc/querycontroller.hxx
+++ b/dbaccess/source/ui/inc/querycontroller.hxx
@@ -196,7 +196,7 @@ namespace dbaui
static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
- protected:
+ private:
virtual void onLoadedMenu(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager);
// OPropertyArrayUsageHelper
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
@@ -207,7 +207,13 @@ namespace dbaui
virtual void reset();
virtual void impl_initialize();
- void resetImpl();
+ void impl_reset();
+ /// tells the user that we needed to switch to SQL view automatically
+ void impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails );
+
+ /** switches to the graphical or SQL view mode, as determined by m_bGraphicalDesign
+ */
+ bool impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo );
/// sets m_sStatement, and notifies our respective property change listeners
void setStatement_fireEvent( const ::rtl::OUString& _rNewStatement, bool _bFireStatementChange = true );
@@ -217,6 +223,7 @@ namespace dbaui
// OJoinController overridables
virtual bool allowViews() const;
virtual bool allowQueries() const;
+
private:
DECL_LINK( OnExecuteAddTable, void* );
};
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index 556c381bc063..9354aa943a93 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -132,8 +132,6 @@ namespace dbaui
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xMainToolbar;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xCurrentDatabaseDocument;
- ::osl::Mutex m_aEntryMutex;
-
// ---------------------------
struct ExternalFeature
{
@@ -398,10 +396,10 @@ namespace dbaui
String GetEntryText( SvLBoxEntry* _pEntry ) const;
// is called when a table or a query was selected
- DECL_LINK( OnSelectEntry, SvLBoxEntry* );
+ DECL_LINK( OnSelectionChange, void* );
DECL_LINK( OnExpandEntry, SvLBoxEntry* );
- DECL_LINK( OnCopyEntry, SvLBoxEntry* );
+ DECL_LINK( OnCopyEntry, void* );
DECL_LINK( OnTreeEntryCompare, const SvSortData* );
@@ -410,6 +408,7 @@ namespace dbaui
void implRemoveStatusListeners();
sal_Bool implSelect(const ::svx::ODataAccessDescriptor& _rDescriptor,sal_Bool _bSelectDirect = sal_False);
+ bool implSelect( SvLBoxEntry* _pEntry );
/// selects the entry given and loads the grid control with the object's data
sal_Bool implSelect(
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 3e026d4e5116..9f0f9bd2c85e 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -408,8 +408,8 @@ SQLExceptionInfo createConnection( const Reference< ::com::sun::star::beans::XP
return aInfo;
}
// -----------------------------------------------------------------------------
-Reference< XDataSource > getDataSourceByName_displayError( const ::rtl::OUString& _rDataSourceName,
- Window* _pErrorMessageParent, Reference< XMultiServiceFactory > _rxORB, bool _bDisplayError)
+Reference< XDataSource > getDataSourceByName( const ::rtl::OUString& _rDataSourceName,
+ Window* _pErrorMessageParent, Reference< XMultiServiceFactory > _rxORB, ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
::comphelper::ComponentContext aContext( _rxORB );
Reference< XNameAccess > xDatabaseContext( aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
@@ -450,16 +450,18 @@ Reference< XDataSource > getDataSourceByName_displayError( const ::rtl::OUString
if ( xDatasource.is() )
return xDatasource;
- if ( _bDisplayError )
+ if ( aSQLError.isValid() )
{
- if ( aSQLError.isValid() )
- showError( aSQLError, _pErrorMessageParent, _rxORB );
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = aSQLError;
+ }
else
{
- DBG_ERROR( "getDataSourceByName_displayError: not yet implemented!" );
- // by spec, we must pass this to an interaction handler ...
+ showError( aSQLError, _pErrorMessageParent, _rxORB );
}
}
+
return Reference<XDataSource>();
}
// -----------------------------------------------------------------------------
@@ -1414,14 +1416,15 @@ void fillAutoIncrementValue(const Reference<XConnection>& _xConnection,
{
_xDataSource->getPropertyValue(PROPERTY_NAME) >>= _rsDatabaseName;
}
- catch(Exception)
+ catch(const Exception& )
{
+ DBG_UNHANDLED_EXCEPTION();
}
}
::rtl::OUString sName = _rsDatabaseName;
INetURLObject aURL(sName);
if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
- sName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_WITH_CHARSET);
+ sName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
return sName;
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx
index 98adbb8953c5..93feb3aa49b1 100644
--- a/dbaccess/source/ui/misc/WNameMatch.cxx
+++ b/dbaccess/source/ui/misc/WNameMatch.cxx
@@ -282,7 +282,7 @@ IMPL_LINK( OWizNameMatching, RightButtonClickHdl, Button *, pButton )
return 0;
}
//------------------------------------------------------------------------------
-IMPL_LINK( OWizNameMatching, TableListClickHdl, SvTreeListBox *, /*pListBox*/ )
+IMPL_LINK( OWizNameMatching, TableListClickHdl, void*, /*NOTINTERESTEDIN*/ )
{
SvLBoxEntry* pEntry = m_CTRL_LEFT.FirstSelected();
if(pEntry)
@@ -316,7 +316,7 @@ IMPL_LINK( OWizNameMatching, TableListClickHdl, SvTreeListBox *, /*pListBox*/ )
return 0;
}
//------------------------------------------------------------------------------
-IMPL_LINK( OWizNameMatching, TableListRightSelectHdl, SvTreeListBox *, /*pListBox*/ )
+IMPL_LINK( OWizNameMatching, TableListRightSelectHdl, void*, /*NOTINTERESTEDIN*/ )
{
SvLBoxEntry* pEntry = m_CTRL_RIGHT.FirstSelected();
if(pEntry)
diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx
index 724e9f0f4285..21a247c73c9f 100644
--- a/dbaccess/source/ui/misc/databaseobjectview.cxx
+++ b/dbaccess/source/ui/misc/databaseobjectview.cxx
@@ -250,10 +250,17 @@ namespace dbaui
{
DatabaseObjectView::fillDispatchArgs( _rDispatchArguments, _aDataSource, _rObjectName );
- sal_Bool bIncludeQueryName = 0 != _rObjectName.getLength();
+ bool bIncludeQueryName = 0 != _rObjectName.getLength();
+ bool bEditViewAsSQLCommand = ( m_nCommandType == CommandType::TABLE ) && m_bPreferSQLView;
sal_Int32 nPos = _rDispatchArguments.getLength();
- _rDispatchArguments.realloc(_rDispatchArguments.getLength() + 2 + ( bIncludeQueryName ? 1 : 0 ) );
+
+ sal_Int32 nNewLen = _rDispatchArguments.getLength() + 2;
+ if ( bIncludeQueryName )
+ ++nNewLen;
+ if ( bEditViewAsSQLCommand )
+ ++nNewLen;
+ _rDispatchArguments.realloc( nNewLen );
_rDispatchArguments[nPos ].Name = PROPERTY_GRAPHICAL_DESIGN;
_rDispatchArguments[nPos++].Value <<= ::cppu::bool2any( !m_bPreferSQLView );
@@ -266,6 +273,12 @@ namespace dbaui
_rDispatchArguments[nPos ].Name = PROPERTY_COMMAND;
_rDispatchArguments[nPos++].Value <<= _rObjectName;
}
+
+ if ( bEditViewAsSQLCommand )
+ {
+ _rDispatchArguments[nPos ].Name = PROPERTY_ESCAPE_PROCESSING;
+ _rDispatchArguments[nPos++].Value <<= sal_Bool( sal_False );
+ }
}
//======================================================================
diff --git a/dbaccess/source/ui/misc/datasourceconnector.cxx b/dbaccess/source/ui/misc/datasourceconnector.cxx
index 40c073b521ac..470ab5f08ba3 100644
--- a/dbaccess/source/ui/misc/datasourceconnector.cxx
+++ b/dbaccess/source/ui/misc/datasourceconnector.cxx
@@ -91,6 +91,9 @@
#ifndef TOOLS_DIAGNOSE_EX_H
#include <tools/diagnose_ex.h>
#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
#ifndef _DBU_MISC_HRC_
#include "dbu_misc.hrc"
#endif
@@ -132,7 +135,8 @@ namespace dbaui
}
//---------------------------------------------------------------------
- Reference< XConnection > ODatasourceConnector::connect(const ::rtl::OUString& _rDataSourceName, sal_Bool _bShowError) const
+ Reference< XConnection > ODatasourceConnector::connect( const ::rtl::OUString& _rDataSourceName,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo ) const
{
Reference< XConnection > xConnection;
@@ -142,28 +146,24 @@ namespace dbaui
// get the data source
Reference< XDataSource > xDatasource(
- getDataSourceByName_displayError( _rDataSourceName, m_pErrorMessageParent, m_xORB, _bShowError ),
+ getDataSourceByName( _rDataSourceName, m_pErrorMessageParent, m_xORB, _pErrorInfo ),
UNO_QUERY
);
+
if ( xDatasource.is() )
- xConnection = connect( xDatasource, _bShowError );
+ xConnection = connect( xDatasource, _pErrorInfo );
return xConnection;
}
//---------------------------------------------------------------------
- Reference< XConnection > ODatasourceConnector::connect(const Reference< XDataSource>& _xDataSource, sal_Bool _bShowError) const
+ Reference< XConnection > ODatasourceConnector::connect(const Reference< XDataSource>& _xDataSource,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo ) const
{
Reference< XConnection > xConnection;
- OSL_ENSURE(isValid(), "ODatasourceConnector::connect: invalid object!");
- if (!isValid())
- return xConnection;
-
- if (!_xDataSource.is())
- {
- OSL_ENSURE(sal_False, "ODatasourceConnector::connect: could not retrieve the data source!");
+ OSL_ENSURE( isValid() && _xDataSource.is(), "ODatasourceConnector::connect: invalid object or argument!" );
+ if ( !isValid() || !_xDataSource.is() )
return xConnection;
- }
// get user/password
::rtl::OUString sPassword, sUser;
@@ -177,7 +177,7 @@ namespace dbaui
}
catch(Exception&)
{
- OSL_ENSURE(sal_False, "ODatasourceConnector::connect: error while retrieving data source properties!");
+ DBG_UNHANDLED_EXCEPTION();
}
// try to connect
@@ -210,19 +210,44 @@ namespace dbaui
xConnection = _xDataSource->getConnection(sUser, sPassword);
}
}
- catch(SQLContext& e) { aInfo = SQLExceptionInfo(e); }
- catch(SQLWarning& e) { aInfo = SQLExceptionInfo(e); }
- catch(SQLException& e) { aInfo = SQLExceptionInfo(e); }
+ catch( const SQLException& )
+ {
+ aInfo = ::cppu::getCaughtException();
+ }
catch(const Exception&)
{
DBG_UNHANDLED_EXCEPTION();
}
- if ( !_bShowError )
- return xConnection;
+ if ( !aInfo.isValid() )
+ {
+ // there was no error during connecting, but perhaps a warning?
+ Reference< XWarningsSupplier > xConnectionWarnings( xConnection, UNO_QUERY );
+ if ( xConnectionWarnings.is() )
+ {
+ try
+ {
+ Any aWarnings( xConnectionWarnings->getWarnings() );
+ if ( aWarnings.hasValue() )
+ {
+ String sMessage( ModuleRes( STR_WARNINGS_DURING_CONNECT ) );
+ sMessage.SearchAndReplaceAscii( "$buttontext$", Button::GetStandardText( BUTTON_MORE ) );
+ sMessage = OutputDevice::GetNonMnemonicString( sMessage );
- // was there and error?
- if ( aInfo.isValid() )
+ SQLWarning aContext;
+ aContext.Message = sMessage;
+ aContext.NextException = aWarnings;
+ aInfo = aContext;
+ }
+ xConnectionWarnings->clearWarnings();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ else
{
if ( m_sContextInformation.getLength() )
{
@@ -232,37 +257,20 @@ namespace dbaui
aInfo = aError;
}
-
- showError(aInfo, m_pErrorMessageParent, m_xORB);
- return xConnection;
}
- // was there a warning?
- Reference< XWarningsSupplier > xConnectionWarnings( xConnection, UNO_QUERY );
- if ( xConnectionWarnings.is() )
+ // was there an error?
+ if ( aInfo.isValid() )
{
- try
+ if ( _pErrorInfo )
{
- Any aWarnings( xConnectionWarnings->getWarnings() );
- if ( aWarnings.hasValue() )
- {
- String sMessage( ModuleRes( STR_WARNINGS_DURING_CONNECT ) );
- sMessage.SearchAndReplaceAscii( "$buttontext$", Button::GetStandardText( BUTTON_MORE ) );
- sMessage = OutputDevice::GetNonMnemonicString( sMessage );
-
- SQLContext aContext;
- aContext.Message = sMessage;
- aContext.NextException = aWarnings;
- showError( SQLExceptionInfo( aContext ), m_pErrorMessageParent, m_xORB );
- }
- xConnectionWarnings->clearWarnings();
+ *_pErrorInfo = aInfo;
}
- catch( const Exception& )
+ else
{
- DBG_UNHANDLED_EXCEPTION();
+ showError( aInfo, m_pErrorMessageParent, m_xORB );
}
}
-
return xConnection;
}
diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx
index 4fe29a04e2a6..aa31554f861b 100644
--- a/dbaccess/source/ui/misc/dsmeta.cxx
+++ b/dbaccess/source/ui/misc/dsmeta.cxx
@@ -120,9 +120,9 @@ namespace dbaui
if ( s_aSupport.empty() )
{
s_aSupport[ ::dbaccess::DST_MSACCESS ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 );
- s_aSupport[ ::dbaccess::DST_MYSQL_ODBC ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0 );
- s_aSupport[ ::dbaccess::DST_MYSQL_JDBC ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0 );
- s_aSupport[ ::dbaccess::DST_MYSQL_NATIVE ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0 );
+ s_aSupport[ ::dbaccess::DST_MYSQL_ODBC ] = InitAdvanced( 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0 );
+ s_aSupport[ ::dbaccess::DST_MYSQL_JDBC ] = InitAdvanced( 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0 );
+ s_aSupport[ ::dbaccess::DST_MYSQL_NATIVE ] = InitAdvanced( 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0 );
s_aSupport[ ::dbaccess::DST_ORACLE_JDBC ] = InitAdvanced( InitAdvanced::All );
s_aSupport[ ::dbaccess::DST_ADABAS ] = InitAdvanced( 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0 );
s_aSupport[ ::dbaccess::DST_CALC ] = InitAdvanced( InitAdvanced::None );
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
index 965185288203..ecc898cbecbc 100644
--- a/dbaccess/source/ui/misc/singledoccontroller.cxx
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -141,7 +141,7 @@ namespace dbaui
public:
OModuleClient m_aModuleClient;
- Any m_aCurrentError; // contains the current error which can be set through IEnvironment
+ ::dbtools::SQLExceptionInfo m_aCurrentError; // contains the current error which can be set through IEnvironment
// <properties>
SharedConnection m_xConnection;
@@ -337,7 +337,7 @@ namespace dbaui
// now really reconnect ...
if ( bReConnect )
{
- m_pImpl->m_xConnection.reset( connect( m_pImpl->m_aDataSource.getDataSource(), sal_True ), SharedConnection::TakeOwnership );
+ m_pImpl->m_xConnection.reset( connect( m_pImpl->m_aDataSource.getDataSource(), NULL ), SharedConnection::TakeOwnership );
m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
}
@@ -408,61 +408,38 @@ namespace dbaui
else
OSingleDocumentController_Base::disposing( _rSource );
}
+
//--------------------------------------------------------------------
- namespace
+ void OSingleDocumentController::appendError( const ::rtl::OUString& _rErrorMessage, const ::dbtools::StandardSQLState _eSQLState,
+ const sal_Int32 _nErrorCode )
{
- void concatSQLExceptions(Any& _rChainLeft, const Any& _rChainRight)
- {
- if (!_rChainLeft.hasValue())
- _rChainLeft = _rChainRight;
- else
- {
- // to travel the chain by reference (and not by value), we need the getValue ...
- // looks like a hack, but the meaning of getValue is documented, and it's the only chance for reference-traveling ....
-
- DBG_ASSERT(::dbtools::SQLExceptionInfo(_rChainLeft).isValid(), "concatSQLExceptions: invalid warnings chain (this will crash)!");
-
- const SQLException* pChainTravel = static_cast<const SQLException*>(_rChainLeft.getValue());
- ::dbtools::SQLExceptionIteratorHelper aReferenceIterHelper(*pChainTravel);
- while (aReferenceIterHelper.hasMoreElements())
- pChainTravel = aReferenceIterHelper.next();
-
- // reached the end of the chain, and pChainTravel points to the last element
- const_cast<SQLException*>(pChainTravel)->NextException = _rChainRight;
- }
- }
-
+ m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::SQL_EXCEPTION, _rErrorMessage, getStandardSQLStateAscii( _eSQLState ),
+ _nErrorCode );
}
//--------------------------------------------------------------------
- /** appends an error in the current environment.
- @param _aException
- contains a description of the error or the error directly
- */
- void OSingleDocumentController::appendError(const SQLException& _aException)
+ void OSingleDocumentController::clearError()
{
- concatSQLExceptions(m_pImpl->m_aCurrentError,makeAny(_aException));
+ m_pImpl->m_aCurrentError = ::dbtools::SQLExceptionInfo();
}
+
//--------------------------------------------------------------------
- /** clears the error state.
- */
- void OSingleDocumentController::clearError()
+ sal_Bool OSingleDocumentController::hasError() const
{
- m_pImpl->m_aCurrentError = Any();
+ return m_pImpl->m_aCurrentError.isValid();
}
+
//--------------------------------------------------------------------
- /** set the current error in the given parameter.
- @param _rException
- will contain the current error
- */
- void OSingleDocumentController::getError(SQLException& _rException ) const
+ const ::dbtools::SQLExceptionInfo& OSingleDocumentController::getError() const
{
- m_pImpl->m_aCurrentError >>= _rException;
+ return m_pImpl->m_aCurrentError;
}
+
//--------------------------------------------------------------------
- sal_Bool OSingleDocumentController::hasError() const
+ void OSingleDocumentController::displayError()
{
- return m_pImpl->m_aCurrentError.hasValue();
+ showError( m_pImpl->m_aCurrentError );
}
+
//--------------------------------------------------------------------
sal_Bool SAL_CALL OSingleDocumentController::suspend(sal_Bool bSuspend) throw( RuntimeException )
{
@@ -690,7 +667,7 @@ namespace dbaui
::rtl::OUString SAL_CALL OSingleDocumentController::getTitle()
throw (RuntimeException)
{
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( m_bExternalTitle )
return impl_getTitleHelper_throw()->getTitle ();
@@ -721,7 +698,7 @@ namespace dbaui
// -----------------------------------------------------------------------------
Reference< XEmbeddedScripts > SAL_CALL OSingleDocumentController::getScriptContainer() throw (RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( getMutex() );
if ( !m_pImpl->documentHasScriptSupport() )
return NULL;
diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx
index 541a78dad0e4..d3f81d34d1d7 100644
--- a/dbaccess/source/ui/querydesign/JoinController.cxx
+++ b/dbaccess/source/ui/querydesign/JoinController.cxx
@@ -444,7 +444,7 @@ sal_Bool SAL_CALL OJoinController::suspend(sal_Bool _bSuspend) throw( RuntimeExc
return sal_True;
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( getView() && getView()->IsInModalMode() )
return sal_False;
sal_Bool bCheck = sal_True;
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 8372f6689347..87bfaffa6d7c 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -440,13 +440,13 @@ namespace
eErrorCode = eColumnNotFound;
String sError(ModuleRes(STR_QRY_COLUMN_NOT_FOUND));
sError.SearchAndReplaceAscii("$name$",aColumnName);
- _pView->getController().appendError(SQLException(sError,NULL,getStandardSQLState( SQL_GENERAL_ERROR ),1000,Any()));
+ _pView->getController().appendError( sError );
try
{
Reference<XDatabaseMetaData> xMeta = _pView->getController().getConnection()->getMetaData();
if ( xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() )
- _pView->getController().appendError(SQLException(String(ModuleRes(STR_QRY_CHECK_CASESENSITIVE)),NULL,getStandardSQLState( SQL_GENERAL_ERROR ),1000,Any()));
+ _pView->getController().appendError( String( ModuleRes( STR_QRY_CHECK_CASESENSITIVE ) ) );
}
catch(Exception&)
{
@@ -715,7 +715,7 @@ namespace
pNode->getChild(1)->getNodeType() == SQL_NODE_EQUAL))
{
String sError(ModuleRes(STR_QRY_JOIN_COLUMN_COMPARE));
- _pView->getController().appendError(SQLException(sError,NULL,getStandardSQLState( SQL_GENERAL_ERROR ),1000,Any()));
+ _pView->getController().appendError( sError );
return eIllegalJoin;
}
@@ -1364,6 +1364,9 @@ namespace
pNodeTmp = pNode->getChild(1);
::connectivity::OSQLParseNode::absorptions(pNodeTmp);
pNodeTmp = pNode->getChild(1);
+ // compress sort the criteria @see http://www.openoffice.org/issues/show_bug.cgi?id=24079
+ OSQLParseNode::compress(pNodeTmp);
+ pNodeTmp = pNode->getChild(1);
// first extract the inner joins conditions
GetInnerJoinCriteria(_pView,pNodeTmp);
@@ -1533,7 +1536,7 @@ namespace
{
eErrorCode = eNoColumnInLike;
String sError(ModuleRes(STR_QRY_LIKE_LEFT_NO_COLUMN));
- _pView->getController().appendError(SQLException(sError,NULL,getStandardSQLState( SQL_GENERAL_ERROR ),1000,Any()));
+ _pView->getController().appendError( sError );
}
}
else if( SQL_ISRULEOR2(pCondition,test_for_null,in_predicate)
@@ -2546,8 +2549,9 @@ namespace
}
return eErrorCode;
}
+
//------------------------------------------------------------------------------
- void showParseError(IEnvironment& _rEnvironment,SqlParseError _eErrorCode)
+ String getParseErrorMessage( SqlParseError _eErrorCode )
{
USHORT nResId;
switch(_eErrorCode)
@@ -2592,12 +2596,9 @@ namespace
nResId = STR_QRY_SYNTAX;
break;
}
- // ErrorBox( _pWindow, ModuleRes( nResId ) ).Execute();
- ModuleRes aRes(nResId);
- String sError(aRes);
- _rEnvironment.appendError(SQLException(sError,NULL,getStandardSQLState( SQL_GENERAL_ERROR ),1000,Any()));
+ ;
+ return String( ModuleRes( nResId ) );
}
- // -----------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
@@ -3030,12 +3031,10 @@ sal_Bool OQueryDesignView::checkStatement()
aSqlCmd += sOrder;
else
{
- if ( !m_rController.hasError() ) // fill generell error string
- showParseError(m_rController,eErrorCode);
+ if ( !m_rController.hasError() )
+ m_rController.appendError( getParseErrorMessage( eErrorCode ) );
- SQLException aError;
- m_rController.getError(aError);
- m_rController.showError(aError);
+ m_rController.displayError();
}
if ( xConnection.is() )
@@ -3228,25 +3227,33 @@ void OQueryDesignView::setNoneVisbleRow(sal_Int32 _nRows)
m_pSelectionBox->SetNoneVisbleRow(_nRows);
}
// -----------------------------------------------------------------------------
-sal_Bool OQueryDesignView::InitFromParseNode()
+bool OQueryDesignView::initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
SqlParseError eErrorCode = eNativeMode;
m_rController.clearError();
+
try
{
- if ( (eErrorCode = InitFromParseNodeImpl(this,m_pSelectionBox)) != eOk )
+ eErrorCode = InitFromParseNodeImpl( this, m_pSelectionBox );
+
+ if ( eErrorCode != eOk )
{
- if ( !m_rController.hasError() ) // fill generell error string
- showParseError(m_rController,eErrorCode);
+ if ( !m_rController.hasError() )
+ m_rController.appendError( getParseErrorMessage( eErrorCode ) );
- SQLException aError;
- m_rController.getError(aError);
- m_rController.showError(aError);
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = m_rController.getError();
+ }
+ else
+ {
+ m_rController.displayError();
+ }
}
}
- catch(Exception&)
+ catch ( const Exception& )
{
- OSL_ENSURE(0,"Can not fill query view!");
+ DBG_UNHANDLED_EXCEPTION();
}
return eErrorCode == eOk;
}
diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
index 0aedd42e4cc6..36b7afe6d727 100644
--- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
+++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
@@ -208,40 +208,44 @@ OQueryContainerWindow* OQueryViewSwitch::getContainer() const
}
// -----------------------------------------------------------------------------
-sal_Bool OQueryViewSwitch::switchView()
+bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
sal_Bool bRet = sal_True;
sal_Bool bGraphicalDesign = static_cast<OQueryController&>(m_pDesignView->getController()).isGraphicalDesign();
OAddTableDlg* pAddTabDialog( getAddTableDialog() );
- if ( !bGraphicalDesign ) // we have to hide the add table dialog
+ OQueryContainerWindow* pContainer = getContainer();
+ if ( !bGraphicalDesign )
{
+ // hide the "Add Table" dialog
m_bAddTableDialogWasVisible = pAddTabDialog ? pAddTabDialog->IsVisible() : false;
if ( m_bAddTableDialogWasVisible )
pAddTabDialog->Hide();
- }
- OQueryContainerWindow* pContainer = getContainer();
- if ( !bGraphicalDesign )
- {
+ // tell the views they're in/active
m_pDesignView->stopTimer();
m_pTextView->getSqlEdit()->startTimer();
+ // set the most recent statement at the text view
m_pTextView->clear();
m_pTextView->setStatement(static_cast<OQueryController&>(m_pDesignView->getController()).getStatement());
}
else
{
- ::rtl::OUString sOldStatement = static_cast<OQueryController&>(m_pDesignView->getController()).getStatement();
- // we have to stop the sqledit from our textview
+ // tell the text view it's inactive now
m_pTextView->getSqlEdit()->stopTimer();
+ ::rtl::OUString sOldStatement = static_cast<OQueryController&>(m_pDesignView->getController()).getStatement();
+
+ // update the "Add Table" dialog
if ( pAddTabDialog )
pAddTabDialog->Update();
- bRet = m_pDesignView->InitFromParseNode();
- // only show the view when the data is inserted
+ // initialize the design view
+ bRet = m_pDesignView->initByParseIterator( _pErrorInfo );
+
+ // tell the design view it's active now
m_pDesignView->startTimer();
}
@@ -299,11 +303,16 @@ Reference< XMultiServiceFactory > OQueryViewSwitch::getORB() const
return m_pDesignView->getORB();
}
// -----------------------------------------------------------------------------
-void OQueryViewSwitch::reset()
+bool OQueryViewSwitch::reset( ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
m_pDesignView->reset();
- if ( m_pDesignView->InitFromParseNode() )
- switchView();
+ if ( !m_pDesignView->initByParseIterator( _pErrorInfo ) )
+ return false;
+
+ if ( switchView( _pErrorInfo ) )
+ return false;
+
+ return true;
}
// -----------------------------------------------------------------------------
void OQueryViewSwitch::setNoneVisbleRow(sal_Int32 _nRows)
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 94fe8550d759..241e5f439909 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -1649,6 +1649,13 @@ void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, USHORT& _nColu
getFields()[nOldPosition - 1] = pEntry;
ColumnMoved(pEntry->GetColumnId(),FALSE);
+ } // if ( pEntry->GetColumnId() != nColumnId )
+
+ if ( pEntry->GetFunctionType() & (FKT_AGGREGATE) )
+ {
+ String sFunctionName = pEntry->GetFunction();
+ if ( GetFunctionName(sal_uInt32(-1),sFunctionName) )
+ pEntry->SetFunction(sFunctionName);
}
// Neuzeichnen
@@ -2294,6 +2301,36 @@ sal_Bool OSelectionBrowseBox::GetFunctionName(sal_uInt32 _nFunctionTokenId,Strin
case SQL_TOKEN_SUM:
rFkt = m_pFunctionCell->GetEntry(5);
break;
+ case SQL_TOKEN_EVERY:
+ rFkt = m_pFunctionCell->GetEntry(6);
+ break;
+ case SQL_TOKEN_ANY:
+ rFkt = m_pFunctionCell->GetEntry(7);
+ break;
+ case SQL_TOKEN_SOME:
+ rFkt = m_pFunctionCell->GetEntry(8);
+ break;
+ case SQL_TOKEN_STDDEV_POP:
+ rFkt = m_pFunctionCell->GetEntry(9);
+ break;
+ case SQL_TOKEN_STDDEV_SAMP:
+ rFkt = m_pFunctionCell->GetEntry(10);
+ break;
+ case SQL_TOKEN_VAR_SAMP:
+ rFkt = m_pFunctionCell->GetEntry(11);
+ break;
+ case SQL_TOKEN_VAR_POP:
+ rFkt = m_pFunctionCell->GetEntry(12);
+ break;
+ case SQL_TOKEN_COLLECT:
+ rFkt = m_pFunctionCell->GetEntry(13);
+ break;
+ case SQL_TOKEN_FUSION:
+ rFkt = m_pFunctionCell->GetEntry(14);
+ break;
+ case SQL_TOKEN_INTERSECTION:
+ rFkt = m_pFunctionCell->GetEntry(15);
+ break;
default:
{
xub_StrLen nCount = m_aFunctionStrings.GetTokenCount();
diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
index 20040666e4e1..2f3a70890e92 100644
--- a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
+++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
@@ -120,9 +120,9 @@ namespace dbaui
}
}
// -----------------------------------------------------------------------------
- sal_Bool OQueryContainerWindow::switchView()
+ bool OQueryContainerWindow::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
- return m_pViewSwitch->switchView();
+ return m_pViewSwitch->switchView( _pErrorInfo );
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index e4709f2ea3a3..4bbd4e1dd419 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -271,9 +271,9 @@ using namespace ::comphelper;
namespace
{
- void ensureToolbars( OQueryController* _pController, sal_Bool _bDesign )
+ void ensureToolbars( OQueryController& _rController, sal_Bool _bDesign )
{
- Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager = _pController->getLayoutManager(_pController->getFrame());
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager = _rController.getLayoutManager( _rController.getFrame() );
if ( xLayoutManager.is() )
{
xLayoutManager->lock();
@@ -293,23 +293,6 @@ namespace
xLayoutManager->doLayout();
}
}
-
- void switchDesignModeImpl(OQueryController* _pController,OQueryContainerWindow* _pWindow,sal_Bool& _rbDesign)
- {
- bool isModified = _pController->isModified();
-
- if ( !_pWindow->switchView() )
- {
- _rbDesign = !_rbDesign;
- _pWindow->switchView();
- }
- else
- {
- ensureToolbars( _pController, _rbDesign );
- }
-
- _pController->setModified( isModified );
- }
}
//------------------------------------------------------------------------------
@@ -555,8 +538,10 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
getContainer()->paste();
break;
case ID_BROWSER_SQL:
+ {
if ( !getContainer()->checkStatement() )
break;
+ SQLExceptionInfo aError;
try
{
::rtl::OUString aErrorMsg;
@@ -567,30 +552,33 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
delete m_pSqlIterator->getParseTree();
m_pSqlIterator->setParseTree(NULL);
m_bGraphicalDesign = !m_bGraphicalDesign;
- switchDesignModeImpl(this,getContainer(),m_bGraphicalDesign);
+ impl_setViewMode( &aError );
}
else
{
::connectivity::OSQLParseNode* pNode = m_aSqlParser.parseTree(aErrorMsg,m_sStatement,m_bGraphicalDesign);
- // m_pParseNode = pNode;
- if(pNode)
+ if ( pNode )
{
delete m_pSqlIterator->getParseTree();
m_pSqlIterator->setParseTree(pNode);
m_pSqlIterator->traverseAll();
+
if ( m_pSqlIterator->hasErrors() )
{
- showError( SQLExceptionInfo( m_pSqlIterator->getErrors() ) );
+ aError = m_pSqlIterator->getErrors();
}
else
{
const OSQLTables& xTabs = m_pSqlIterator->getTables();
- if( m_pSqlIterator->getStatementType() != SQL_STATEMENT_SELECT || xTabs.begin() == xTabs.end())
+ if ( m_pSqlIterator->getStatementType() != SQL_STATEMENT_SELECT || xTabs.begin() == xTabs.end() )
{
- ModuleRes aModuleRes(STR_QRY_NOSELECT);
- String sTmpStr(aModuleRes);
- ::rtl::OUString sError(sTmpStr);
- showError(SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")),1000,Any()));
+ aError = SQLException(
+ String( ModuleRes( STR_QRY_NOSELECT ) ),
+ NULL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ),
+ 1000,
+ Any()
+ );
}
else
{
@@ -601,33 +589,41 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
setStatement_fireEvent( sNewStatement );
getContainer()->SaveUIConfig();
m_vTableConnectionData.clear();
- switchDesignModeImpl(this,getContainer(),m_bGraphicalDesign);
+ impl_setViewMode( &aError );
}
}
}
else
{
- ModuleRes aModuleRes(STR_QRY_SYNTAX);
- String sTmpStr(aModuleRes);
- ::rtl::OUString sError(sTmpStr);
- showError(SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000") ),1000,Any()));
+ aError = SQLException(
+ String( ModuleRes( STR_QRY_SYNTAX ) ),
+ NULL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ),
+ 1000,
+ Any()
+ );
}
}
}
- catch(SQLException& e)
+ catch(const SQLException& e)
{
- ::dbtools::SQLExceptionInfo aInfo(e);
- showError(aInfo);
+ aError = ::cppu::getCaughtException();
}
- catch(Exception&)
+ catch(const Exception&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
+
+ if ( aError.isValid() )
+ showError( aError );
+
if(m_bGraphicalDesign)
{
InvalidateFeature(ID_BROWSER_ADDTABLE);
InvalidateFeature(SID_RELATION_ADD_RELATION);
}
- break;
+ }
+ break;
case SID_BROWSER_CLEAR_QUERY:
{
getUndoMgr()->EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() );
@@ -721,7 +717,11 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
pNodeTmp = pTemp->getChild(1);
::connectivity::OSQLParseNode::absorptions(pNodeTmp);
pNodeTmp = pTemp->getChild(1);
- }
+ } // if ( pCondition ) // no where clause
+ ::rtl::OUString sTemp;
+ pNode->parseNodeToStr(sTemp,getConnection());
+ getContainer()->setStatement(sTemp);
+
}
}
@@ -743,6 +743,48 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
}
InvalidateFeature(_nId);
}
+
+// -----------------------------------------------------------------------------
+void OQueryController::impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails )
+{
+ SQLContext aErrorContext;
+ aErrorContext.Message = lcl_getObjectResourceString( STR_ERROR_PARSING_STATEMENT, m_nCommandType );
+ aErrorContext.Context = *this;
+ aErrorContext.Details = lcl_getObjectResourceString( STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType );
+ aErrorContext.NextException = _rErrorDetails;
+ showError( aErrorContext );
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryController::impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ OSL_PRECOND( getContainer(), "OQueryController::impl_setViewMode: illegal call!" );
+
+ bool wasModified = isModified();
+
+ SQLExceptionInfo aError;
+ bool bSuccess = getContainer()->switchView( &aError );
+ if ( !bSuccess )
+ {
+ m_bGraphicalDesign = !m_bGraphicalDesign;
+ // restore old state
+ getContainer()->switchView( NULL );
+ // don't pass &aError here, this would overwrite the error which the first switchView call
+ // returned in this location.
+ if ( _pErrorInfo )
+ *_pErrorInfo = aError;
+ else
+ showError( aError );
+ }
+ else
+ {
+ ensureToolbars( *this, m_bGraphicalDesign );
+ }
+
+ setModified( wasModified );
+ return bSuccess;
+}
+
// -----------------------------------------------------------------------------
void OQueryController::impl_initialize()
{
@@ -876,8 +918,19 @@ void OQueryController::impl_initialize()
try
{
getContainer()->initialize();
- resetImpl();
- switchDesignModeImpl(this,getContainer(),m_bGraphicalDesign);
+ impl_reset();
+
+ bool bAttemptedGraphicalDesign = m_bGraphicalDesign;
+ SQLExceptionInfo aError;
+ impl_setViewMode( &aError );
+ if ( aError.isValid() && bAttemptedGraphicalDesign && !m_bGraphicalDesign )
+ {
+ if ( !editingView() )
+ {
+ impl_showAutoSQLViewError( aError.get() );
+ }
+ }
+
getUndoMgr()->Clear();
if ( ( m_bGraphicalDesign )
@@ -908,7 +961,7 @@ void OQueryController::impl_initialize()
// -----------------------------------------------------------------------------
void OQueryController::onLoadedMenu(const Reference< ::com::sun::star::frame::XLayoutManager >& /*_xLayoutManager*/)
{
- ensureToolbars( this, m_bGraphicalDesign );
+ ensureToolbars( *this, m_bGraphicalDesign );
}
// -----------------------------------------------------------------------------
@@ -920,7 +973,7 @@ void OQueryController::onLoadedMenu(const Reference< ::com::sun::star::frame::XL
if ( !editingCommand() )
{
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
String aDefaultName = String( ModuleRes( editingView() ? STR_VIEW_TITLE : STR_QRY_TITLE ) );
sName = aDefaultName.GetToken(0,' ');
sName += ::rtl::OUString::valueOf(getCurrentStartNumber());
@@ -1035,7 +1088,7 @@ void OQueryController::reconnect(sal_Bool _bUI)
{
m_bGraphicalDesign = sal_False;
// don't call Execute(SQL) because this changes the sql statement
- switchDesignModeImpl(this,getContainer(),m_bGraphicalDesign);
+ impl_setViewMode( NULL );
}
InvalidateAll();
}
@@ -1514,7 +1567,7 @@ bool OQueryController::doSaveAsDoc(sal_Bool _bSaveAs)
short OQueryController::saveModified()
{
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
short nRet = RET_YES;
if ( !isConnected() || !isModified() )
return nRet;
@@ -1539,7 +1592,7 @@ short OQueryController::saveModified()
return nRet;
}
// -----------------------------------------------------------------------------
-void OQueryController::resetImpl()
+void OQueryController::impl_reset()
{
bool bValid = false;
Sequence< PropertyValue > aLayoutInformation;
@@ -1576,7 +1629,7 @@ void OQueryController::resetImpl()
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "OQueryController::resetImpl: could not retrieve the layout information from the query!" );
+ OSL_ENSURE( sal_False, "OQueryController::impl_reset: could not retrieve the layout information from the query!" );
}
}
}
@@ -1630,12 +1683,7 @@ void OQueryController::resetImpl()
{
if ( !editingView() )
{
- SQLContext aErrorContext;
- aErrorContext.Message = lcl_getObjectResourceString( STR_ERROR_PARSING_STATEMENT, m_nCommandType );
- aErrorContext.Context = *this;
- aErrorContext.Details = lcl_getObjectResourceString( STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType );
- aErrorContext.NextException <<= m_pSqlIterator->getErrors();
- showError( aErrorContext );
+ impl_showAutoSQLViewError( makeAny( m_pSqlIterator->getErrors() ) );
}
bError = true;
}
@@ -1672,8 +1720,8 @@ void OQueryController::resetImpl()
// -----------------------------------------------------------------------------
void OQueryController::reset()
{
- resetImpl();
- getContainer()->reset();
+ impl_reset();
+ getContainer()->reset( NULL );
getUndoMgr()->Clear();
}
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 632dc665ff57..72b2a0382fbf 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -674,7 +674,7 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( Runti
return sal_True;
vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ::osl::MutexGuard aGuard(m_aMutex);
+ ::osl::MutexGuard aGuard( getMutex() );
if ( getView() && getView()->IsInModalMode() )
return sal_False;
sal_Bool bCheck = sal_True;
diff --git a/dbaccess/source/ui/uno/unoDirectSql.cxx b/dbaccess/source/ui/uno/unoDirectSql.cxx
index 823ba3dd2714..bf32f8943717 100644
--- a/dbaccess/source/ui/uno/unoDirectSql.cxx
+++ b/dbaccess/source/ui/uno/unoDirectSql.cxx
@@ -120,7 +120,7 @@ DBG_NAME(ODirectSQLDialog)
{
// the connection the row set is working with
ODatasourceConnector aDSConnector(m_aContext.getLegacyServiceFactory(),_pParent);
- xConnection = aDSConnector.connect(m_sInitialSelection);
+ xConnection = aDSConnector.connect( m_sInitialSelection, NULL );
}
catch( const Exception& )
{