summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/app
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/app')
-rw-r--r--dbaccess/source/ui/app/AppController.cxx106
-rw-r--r--dbaccess/source/ui/app/AppControllerGen.cxx1
-rw-r--r--dbaccess/source/ui/app/app.src6
-rw-r--r--dbaccess/source/ui/app/closeveto.cxx180
-rw-r--r--dbaccess/source/ui/app/closeveto.hxx67
-rw-r--r--dbaccess/source/ui/app/makefile.mk3
6 files changed, 318 insertions, 45 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index f624853c8852..8559c3249feb 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -32,6 +32,7 @@
#include "dbustrings.hrc"
#include "advancedsettingsdlg.hxx"
#include "subcomponentmanager.hxx"
+#include "closeveto.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/beans/NamedValue.hpp>
@@ -1300,8 +1301,8 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa
::comphelper::NamedValueCollection aCreationArgs;
aCreationArgs.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, ID_NEW_VIEW_DESIGN == _nId );
- Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
- Reference< XComponent > xComponent( aDesigner.createNew( xDataSource, aCreationArgs ), UNO_QUERY );
+ const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
+ const Reference< XComponent > xComponent( aDesigner.createNew( xDataSource, aCreationArgs ), UNO_QUERY );
onDocumentOpened( ::rtl::OUString(), E_QUERY, E_OPEN_DESIGN, xComponent, NULL );
}
}
@@ -1352,8 +1353,8 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa
{
RelationDesigner aDesigner( getORB(), this, m_aCurrentFrame.getFrame() );
- Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
- Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
+ const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
+ const Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
onDocumentOpened( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xComponent, NULL );
}
}
@@ -1949,6 +1950,9 @@ IMPL_LINK( OApplicationController, OnCreateWithPilot, void*, _pType )
// -----------------------------------------------------------------------------
void OApplicationController::newElementWithPilot( ElementType _eType )
{
+ CloseVeto aKeepDoc( getFrame() );
+ // prevent the document being closed while the wizard is open
+
OSL_ENSURE( getContainer(), "OApplicationController::newElementWithPilot: without a view?" );
switch ( _eType )
@@ -2710,61 +2714,83 @@ void SAL_CALL OApplicationController::attachFrame( const Reference< XFrame > & i
sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > & _rxModel) throw( RuntimeException )
{
::osl::MutexGuard aGuard( getMutex() );
- Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
- if ( !xOfficeDoc.is() && _rxModel.is() )
+ const Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
+ const Reference< XModifiable > xDocModify( _rxModel, UNO_QUERY );
+ if ( ( !xOfficeDoc.is() || !xDocModify.is() ) && _rxModel.is() )
{
DBG_ERROR( "OApplicationController::attachModel: invalid model!" );
return sal_False;
}
- DBG_ASSERT( !( m_xModel.is() && ( m_xModel != _rxModel ) ),
- "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" );
- // at least: remove as property change listener from the old model/data source
+ if ( m_xModel.is() && ( m_xModel != _rxModel ) && ( _rxModel.is() ) )
+ {
+ OSL_ENSURE( false, "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" );
+ // we'd need to completely update our view here, close sub components, and the like
+ return sal_False;
+ }
+
+ const ::rtl::OUString aPropertyNames[] =
+ {
+ PROPERTY_URL, PROPERTY_USER
+ };
+
+ // disconnect from old model
+ try
+ {
+ if ( m_xDataSource.is() )
+ {
+ for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
+ {
+ m_xDataSource->removePropertyChangeListener( aPropertyNames[i], this );
+ }
+ }
+
+ Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ xBroadcaster->removeModifyListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
m_xModel = _rxModel;
- if ( m_xModel.is() )
+ m_xDocumentModify = xDocModify;
+ m_xDataSource.set( xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference< XDataSource >(), UNO_QUERY );
+
+ // connect to new model
+ try
{
- m_xDocumentModify.set( m_xModel, UNO_QUERY_THROW );
+ if ( m_xDataSource.is() )
+ {
+ for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
+ {
+ m_xDataSource->addPropertyChangeListener( aPropertyNames[i], this );
+ }
+ }
+
+ Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY_THROW );
+ xBroadcaster->addModifyListener( this );
+
}
- else
+ catch( const Exception& )
{
- m_xDocumentModify.clear();
+ DBG_UNHANDLED_EXCEPTION();
}
- m_xDataSource.set(xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference<XDataSource>(),UNO_QUERY);
+ // initial preview mode
if ( m_xDataSource.is() )
{
try
{
- m_xDataSource->addPropertyChangeListener(PROPERTY_INFO, this);
- m_xDataSource->addPropertyChangeListener(PROPERTY_URL, this);
- m_xDataSource->addPropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this);
- m_xDataSource->addPropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this);
- m_xDataSource->addPropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this);
- m_xDataSource->addPropertyChangeListener(PROPERTY_TABLEFILTER, this);
- m_xDataSource->addPropertyChangeListener(PROPERTY_TABLETYPEFILTER, this);
- m_xDataSource->addPropertyChangeListener(PROPERTY_USER, this);
// to get the 'modified' for the data source
- Reference< XModifyBroadcaster > xBroadcaster(m_xModel, UNO_QUERY);
- if ( xBroadcaster.is() )
- xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this));
-
- Sequence<PropertyValue> aFields;
- m_xDataSource->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aFields;
- PropertyValue *pIter = aFields.getArray();
- PropertyValue *pEnd = pIter + aFields.getLength();
- for (; pIter != pEnd && pIter->Name != INFO_PREVIEW; ++pIter)
- ;
-
- if ( pIter != pEnd )
+ ::comphelper::NamedValueCollection aLayoutInfo( m_xDataSource->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) );
+ if ( aLayoutInfo.has( (rtl::OUString)INFO_PREVIEW ) )
{
- sal_Int32 nValue = 0;
- pIter->Value >>= nValue;
- m_ePreviewMode = static_cast<PreviewMode>(nValue);
+ const sal_Int32 nPreviewMode( aLayoutInfo.getOrDefault( (rtl::OUString)INFO_PREVIEW, (sal_Int32)0 ) );
+ m_ePreviewMode = static_cast< PreviewMode >( nPreviewMode );
if ( getView() )
- {
- getContainer()->switchPreview(m_ePreviewMode);
- }
+ getContainer()->switchPreview( m_ePreviewMode );
}
}
catch( const Exception& )
diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx
index e6159a204d2a..f7fb899388c6 100644
--- a/dbaccess/source/ui/app/AppControllerGen.cxx
+++ b/dbaccess/source/ui/app/AppControllerGen.cxx
@@ -670,7 +670,6 @@ void OApplicationController::askToReconnect()
void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, const sal_Int32 _nType,
const ElementOpenMode _eMode, const Reference< XComponent >& _xDocument, const Reference< XComponent >& _rxDefinition )
{
- OSL_PRECOND( _xDocument.is(), "OApplicationController::onDocumentOpened: illegal document!" );
if ( !_xDocument.is() )
return;
diff --git a/dbaccess/source/ui/app/app.src b/dbaccess/source/ui/app/app.src
index 4af2bdb70521..529e6ac55009 100644
--- a/dbaccess/source/ui/app/app.src
+++ b/dbaccess/source/ui/app/app.src
@@ -261,19 +261,19 @@ Menu RID_MENU_APP_EDIT
MenuItem
{
Identifier = SID_DB_APP_DSPROPS;
- Text[ en-US ] = "Properties";
+ Text[ en-US ] = "Properties...";
Command = ".uno:DBDSProperties";
};
MenuItem
{
Identifier = SID_DB_APP_DSCONNECTION_TYPE;
- Text[ en-US ] = "Connection Type";
+ Text[ en-US ] = "Connection Type...";
Command = ".uno:DBDSConnectionType";
};
MenuItem
{
Identifier = SID_DB_APP_DSADVANCED_SETTINGS;
- Text[ en-US ] = "Advanced Settings";
+ Text[ en-US ] = "Advanced Settings...";
Command = ".uno:DBDSAdvancedSettings";
};
};
diff --git a/dbaccess/source/ui/app/closeveto.cxx b/dbaccess/source/ui/app/closeveto.cxx
new file mode 100644
index 000000000000..558df26b643e
--- /dev/null
+++ b/dbaccess/source/ui/app/closeveto.cxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "precompiled_dbaccess.hxx"
+
+#include "closeveto.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/XCloseable.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+#include <tools/diagnose_ex.h>
+
+//......................................................................................................................
+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::util::XCloseable;
+ using ::com::sun::star::util::XCloseListener;
+ using ::com::sun::star::util::CloseVetoException;
+ using ::com::sun::star::lang::EventObject;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= CloseListener_Impl
+ //==================================================================================================================
+ typedef ::cppu::WeakImplHelper1 < XCloseListener
+ > CloseListener_Base;
+ class DBACCESS_DLLPRIVATE CloseListener_Impl : public CloseListener_Base
+ {
+ public:
+ CloseListener_Impl()
+ :m_bHasOwnership( false )
+ {
+ }
+
+ // XCloseListener
+ virtual void SAL_CALL queryClosing( const EventObject& Source, ::sal_Bool GetsOwnership ) throw (CloseVetoException, RuntimeException);
+ virtual void SAL_CALL notifyClosing( const EventObject& Source ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source) throw (RuntimeException);
+
+ bool hasOwnership() const { return m_bHasOwnership; }
+
+ protected:
+ ~CloseListener_Impl()
+ {
+ }
+
+ private:
+ bool m_bHasOwnership;
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL CloseListener_Impl::queryClosing( const EventObject& i_source, ::sal_Bool i_deliverOwnership ) throw (CloseVetoException, RuntimeException)
+ {
+ (void)i_source;
+
+ if ( !m_bHasOwnership )
+ m_bHasOwnership = i_deliverOwnership;
+
+ throw CloseVetoException();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL CloseListener_Impl::notifyClosing( const EventObject& i_source ) throw (RuntimeException)
+ {
+ (void)i_source;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL CloseListener_Impl::disposing( const EventObject& i_source ) throw (RuntimeException)
+ {
+ (void)i_source;
+ }
+
+ //==================================================================================================================
+ //= CloseVeto_Data
+ //==================================================================================================================
+ struct DBACCESS_DLLPRIVATE CloseVeto_Data
+ {
+ Reference< XCloseable > xCloseable;
+ ::rtl::Reference< CloseListener_Impl > pListener;
+ };
+
+ //==================================================================================================================
+ //= operations
+ //==================================================================================================================
+ namespace
+ {
+ //--------------------------------------------------------------------------------------------------------------
+ void lcl_init( CloseVeto_Data& i_data, const Reference< XInterface >& i_closeable )
+ {
+ i_data.xCloseable.set( i_closeable, UNO_QUERY );
+ ENSURE_OR_RETURN_VOID( i_data.xCloseable.is(), "CloseVeto: the component is not closeable!" );
+
+ i_data.pListener = new CloseListener_Impl;
+ i_data.xCloseable->addCloseListener( i_data.pListener.get() );
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void lcl_deinit( CloseVeto_Data& i_data )
+ {
+ if ( !i_data.xCloseable.is() )
+ return;
+
+ i_data.xCloseable->removeCloseListener( i_data.pListener.get() );
+ if ( i_data.pListener->hasOwnership() )
+ {
+ try
+ {
+ i_data.xCloseable->close( sal_True );
+ }
+ catch( const CloseVetoException& ) { }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+
+ //==================================================================================================================
+ //= CloseVeto
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ CloseVeto::CloseVeto( const Reference< XInterface >& i_closeable )
+ :m_pData( new CloseVeto_Data )
+ {
+ lcl_init( *m_pData, i_closeable );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ CloseVeto::~CloseVeto()
+ {
+ lcl_deinit( *m_pData );
+ }
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
diff --git a/dbaccess/source/ui/app/closeveto.hxx b/dbaccess/source/ui/app/closeveto.hxx
new file mode 100644
index 000000000000..f7e1c83644d1
--- /dev/null
+++ b/dbaccess/source/ui/app/closeveto.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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_CLOSEVETO_HXX
+#define DBACCESS_CLOSEVETO_HXX
+
+#include "dbaccessdllapi.h"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XInterface.hpp>
+/** === end UNO includes === **/
+
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= CloseVeto
+ //==================================================================================================================
+ struct CloseVeto_Data;
+ /** will add a XCloseListener to a given component, and veto its closing as long as the <code>CloseVeto</code>
+ instance is alive.
+
+ If closing has been requested and vetoed while the <code>CloseVeto</code> instance is alive, and the ownership
+ went to the <code>CloseVeto</code> instance, then it will close the component in its dtor.
+ */
+ class DBACCESS_DLLPRIVATE CloseVeto
+ {
+ public:
+ CloseVeto( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_closeable );
+ ~CloseVeto();
+
+ private:
+ ::boost::scoped_ptr< CloseVeto_Data > m_pData;
+ };
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
+
+#endif // DBACCESS_CLOSEVETO_HXX
diff --git a/dbaccess/source/ui/app/makefile.mk b/dbaccess/source/ui/app/makefile.mk
index a7097b4330e1..e26927d99628 100644
--- a/dbaccess/source/ui/app/makefile.mk
+++ b/dbaccess/source/ui/app/makefile.mk
@@ -48,7 +48,8 @@ EXCEPTIONSFILES=\
$(SLO)$/AppSwapWindow.obj \
$(SLO)$/AppTitleWindow.obj \
$(SLO)$/AppView.obj \
- $(SLO)$/subcomponentmanager.obj
+ $(SLO)$/subcomponentmanager.obj \
+ $(SLO)$/closeveto.obj
SLOFILES =\