diff options
109 files changed, 4623 insertions, 3734 deletions
diff --git a/dbaccess/inc/IEnvironment.hxx b/dbaccess/inc/IEnvironment.hxx index 18652be7781b..4ea2a5e7dbb6 100644 --- a/dbaccess/inc/IEnvironment.hxx +++ b/dbaccess/inc/IEnvironment.hxx @@ -30,38 +30,46 @@ #ifndef DBAUI_IENVIRONMENT_HXX #define DBAUI_IENVIRONMENT_HXX -#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ #include <com/sun/star/sdbc/SQLException.hpp> -#endif + +#include <connectivity/standardsqlstate.hxx> + +namespace dbtools +{ + class SQLExceptionInfo; +} namespace dbaui { // interface class for a generell environment class IEnvironment { - protected: public: /** appends an error in the current environment. - @param _aException - contains a description of the error or the error directly */ - virtual void appendError(const ::com::sun::star::sdbc::SQLException& _aException) = 0; + virtual void appendError( + const ::rtl::OUString& _rErrorMessage, + const ::dbtools::StandardSQLState _eSQLState = ::dbtools::SQL_GENERAL_ERROR, + const sal_Int32 _nErrorCode = 1000 + ) = 0; /** clears the error state. */ virtual void clearError() = 0; - /** set the current error in the given parameter. - @param _rException - will contain the current error - */ - virtual void getError(::com::sun::star::sdbc::SQLException& _rException ) const = 0; - /** @retrun returns <TRUE/> when an error was set otherwise <FALSE/> */ virtual sal_Bool hasError() const = 0; + /** returns the current error + */ + virtual const ::dbtools::SQLExceptionInfo& getError() const = 0; + + /** displays the current error, or does nothing if there is no current error + */ + virtual void displayError() = 0; + /** gives access to the currently used connection @return the currently used connection. diff --git a/dbaccess/inc/genericcontroller.hxx b/dbaccess/inc/genericcontroller.hxx index df84edac9d52..190cd8485713 100644 --- a/dbaccess/inc/genericcontroller.hxx +++ b/dbaccess/inc/genericcontroller.hxx @@ -59,6 +59,7 @@ /** === end UNO includes === **/ #include <comphelper/broadcasthelper.hxx> +#include <comphelper/sharedmutex.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/stl_types.hxx> #include <connectivity/dbexception.hxx> @@ -68,6 +69,11 @@ #include <boost/optional.hpp> #include <sfx2/userinputinterception.hxx> +namespace dbtools +{ + class SQLExceptionInfo; +} + class Window; class VCLXWindow; namespace dbaui @@ -179,7 +185,7 @@ namespace dbaui }; // .................................................................... - typedef ::comphelper::OBaseMutex OGenericUnoController_MBASE; + typedef ::comphelper::SharedMutexBase OGenericUnoController_MBASE; typedef ::cppu::WeakComponentImplHelper11 < ::com::sun::star::frame::XDispatch , ::com::sun::star::frame::XDispatchProviderInterceptor @@ -255,8 +261,8 @@ namespace dbaui // ---------------------------------------------------------------- // attribute access - ::osl::Mutex& getMutex( ) { return OGenericUnoController_MBASE::m_aMutex; } - ::cppu::OBroadcastHelper& getBroadcastHelper() { return OGenericUnoController_Base::rBHelper; } + ::osl::Mutex& getMutex() const { return OGenericUnoController_MBASE::getMutex(); } + ::cppu::OBroadcastHelper& getBroadcastHelper() { return OGenericUnoController_Base::rBHelper; } // ---------------------------------------------------------------- // methods @@ -347,21 +353,15 @@ namespace dbaui // connect to a datasource ::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 _bStartListening = sal_False - ); - - // connect to a datasource - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > connect( - const ::rtl::OUString& _rDataSourceName, - sal_Bool _bStartListening = sal_False + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& _xDataSource, + ::dbtools::SQLExceptionInfo* _pErrorInfo ); // connect to a datasource ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > connect( const ::rtl::OUString& _rsDataSourceName, const ::rtl::OUString& _rContextInformation, - sal_Bool _bStartListening = sal_False + ::dbtools::SQLExceptionInfo* _pErrorInfo ); void startConnectionListening(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection); diff --git a/dbaccess/inc/singledoccontroller.hxx b/dbaccess/inc/singledoccontroller.hxx index 7c22bd301837..f63d1c02fdf2 100644 --- a/dbaccess/inc/singledoccontroller.hxx +++ b/dbaccess/inc/singledoccontroller.hxx @@ -136,26 +136,30 @@ namespace dbaui // IEnvironment /** appends an error in the current environment. - @param _aException - contains a description of the error or the error directly */ - virtual void appendError(const ::com::sun::star::sdbc::SQLException& _aException); + virtual void appendError( + const ::rtl::OUString& _rErrorMessage, + const ::dbtools::StandardSQLState _eSQLState = ::dbtools::SQL_GENERAL_ERROR, + const sal_Int32 _nErrorCode = 1000 + ); /** clears the error state. */ virtual void clearError(); - /** set the current error in the given parameter. - @param _rException - will contain the current error - */ - virtual void getError(::com::sun::star::sdbc::SQLException& _rException ) const; - /** @return <TRUE/> when an error was set otherwise <FALSE/> */ virtual sal_Bool hasError() const; + /** returns the current error + */ + virtual const ::dbtools::SQLExceptionInfo& getError() const; + + /** displays the current error, or does nothing if there is no current error + */ + virtual void displayError(); + /** shows an info box with the string conntection lost. */ void connectionLostMessage() const; diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java new file mode 100644 index 000000000000..41bf379f7a91 --- /dev/null +++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java @@ -0,0 +1,203 @@ +/************************************************************************* + * + * 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: ApplicationController.java,v $ + * $Revision: 1.1.2.1 $ + * + * 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. + * + ************************************************************************/ + +package complex.dbaccess; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.FrameSearchFlag; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XOfficeDatabaseDocument; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import connectivity.tools.HsqlColumnDescriptor; +import connectivity.tools.HsqlDatabase; +import connectivity.tools.HsqlTableDescriptor; +import helper.URLHelper; +import java.io.File; +import java.io.IOException; + +/** complex test case for Base's application UI + */ +public class ApplicationController extends complexlib.ComplexTestCase +{ + private HsqlDatabase m_database; + private XOfficeDatabaseDocument m_databaseDocument; + private XDatabaseDocumentUI m_documentUI; + + public ApplicationController() + { + super(); + } + + // -------------------------------------------------------------------------------------------------------- + public String[] getTestMethodNames() + { + return new String[] { + "checkSaveAs" + }; + } + + // -------------------------------------------------------------------------------------------------------- + public String getTestObjectName() + { + return getClass().getName(); + } + + // -------------------------------------------------------------------------------------------------------- + protected final XMultiServiceFactory getORB() + { + return (XMultiServiceFactory)param.getMSF(); + } + + // -------------------------------------------------------------------------------------------------------- + protected final XComponentContext getComponentContext() + { + XComponentContext context = null; + try + { + XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, getORB() ); + context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class, + orbProps.getPropertyValue( "DefaultContext" ) ); + } + catch ( Exception ex ) + { + failed( "could not retrieve the ComponentContext" ); + } + return context; + } + + // -------------------------------------------------------------------------------------------------------- + private void impl_closeDocument() + { + if ( m_database != null ) + { + m_database.close(); + m_database = null; + m_databaseDocument = null; + m_documentUI = null; + } + } + + // -------------------------------------------------------------------------------------------------------- + private void impl_switchToDocument( String _documentURL ) throws java.lang.Exception + { + // close previous database document + impl_closeDocument(); + + // create/load the new database document + m_database = ( _documentURL == null ) + ? new HsqlDatabase( getORB() ) + : new HsqlDatabase( getORB(), _documentURL ); + m_databaseDocument = m_database.getDatabaseDocument(); + + // load it into a frame + Object object = getORB().createInstance( "com.sun.star.frame.Desktop" ); + XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class, object ); + XComponent loadedComponent = xComponentLoader.loadComponentFromURL( m_database.getDocumentURL(), "_blank", FrameSearchFlag.ALL, new PropertyValue[0] ); + + assure( "too many document instances!", + UnoRuntime.areSame( loadedComponent, m_databaseDocument ) ); + + // get the controller, which provides access to various UI operations + XModel docModel = (XModel)UnoRuntime.queryInterface( XModel.class, + loadedComponent ); + m_documentUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class, + docModel.getCurrentController() ); + } + + // -------------------------------------------------------------------------------------------------------- + public void before() throws Exception, java.lang.Exception + { + impl_switchToDocument( null ); + } + + // -------------------------------------------------------------------------------------------------------- + public void after() + { + impl_closeDocument(); + } + + // -------------------------------------------------------------------------------------------------------- + public void checkSaveAs() throws Exception, IOException, java.lang.Exception + { + // issue 93737 describes the problem that when you save-as a database document, and do changes to it, + // then those changes are saved in the old document, actually + String oldDocumentURL = m_database.getDocumentURL(); + + File documentFile = java.io.File.createTempFile( getTestObjectName(), ".odb" ); + documentFile.deleteOnExit(); + String newDocumentURL = URLHelper.getFileURLFromSystemPath( documentFile.getAbsoluteFile() ); + + // store the doc in a new location + XStorable storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class, + m_databaseDocument ); + storeDoc.storeAsURL( newDocumentURL, new PropertyValue[] {} ); + + // connect + m_documentUI.connect(); + assure( "could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected() ); + + // create a table in the database + m_database.createTable( new HsqlTableDescriptor( "abc", new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "a", "VARCHAR(50)" ), + new HsqlColumnDescriptor( "b", "VARCHAR(50)" ), + new HsqlColumnDescriptor( "c", "VARCHAR(50)" ) + } + ) ); + + // load the old document, and verify there is *no* table therein + impl_switchToDocument( oldDocumentURL ); + m_documentUI.connect(); + assure( "could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected() ); + XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface( XTablesSupplier.class, + m_documentUI.getActiveConnection() ); + XNameAccess tables = suppTables.getTables(); + assure( "the table was created in the wrong database", !tables.hasByName( "abc" ) ); + + // load the new document, and verify there *is* a table therein + impl_switchToDocument( newDocumentURL ); + m_documentUI.connect(); + assure( "could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected() ); + + suppTables = (XTablesSupplier)UnoRuntime.queryInterface( XTablesSupplier.class, + m_documentUI.getActiveConnection() ); + tables = suppTables.getTables(); + assure( "the newly created table has not been written", tables.hasByName( "abc" ) ); + } +} diff --git a/dbaccess/qa/complex/dbaccess/dbaccess.sce b/dbaccess/qa/complex/dbaccess/dbaccess.sce index 3e0357af2727..b546f6ee7496 100644 --- a/dbaccess/qa/complex/dbaccess/dbaccess.sce +++ b/dbaccess/qa/complex/dbaccess/dbaccess.sce @@ -6,3 +6,4 @@ -o complex.dbaccess.DatabaseDocument -o complex.dbaccess.DataSource -o complex.dbaccess.Parser +-o complex.dbaccess.ApplicationController diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index e2f14fcd9f8c..06e10a34405b 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -884,7 +884,7 @@ void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Referenc { Sequence<sal_Int8> aSeq; if(x.is()) - x->readSomeBytes(aSeq,length); + x->readBytes(aSeq,length); updateValue(columnIndex,aSeq); aOldValue = (*(*m_aCurrentRow))[columnIndex]; (*(*m_aCurrentRow))[columnIndex] = aSeq; diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 33bb22dc2864..318b49e247bc 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -575,7 +575,7 @@ void ORowSetCache::updateBinaryStream( sal_Int32 columnIndex, const Reference< : Sequence<sal_Int8> aSeq; if(x.is()) - x->readSomeBytes(aSeq,length); + x->readBytes(aSeq,length); updateValue(columnIndex,aSeq); } // ------------------------------------------------------------------------- @@ -586,7 +586,7 @@ void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference Sequence<sal_Int8> aSeq; if(x.is()) - x->readSomeBytes(aSeq,length); + x->readBytes(aSeq,length); updateValue(columnIndex,aSeq); } diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 3eddeb562c3f..4dfd571f1148 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1548,6 +1548,7 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert ::rtl::OUString sColumnExp = aSQL.makeStringAndClear(); getBoleanComparisonPredicate( sColumnExp, bValue, m_nBoolCompareMode, aSQL ); } + break; default: aSQL.append( STR_EQUAL ); aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx index 48427e47faa6..761b27fc94ed 100644 --- a/dbaccess/source/core/api/preparedstatement.cxx +++ b/dbaccess/source/core/api/preparedstatement.cxx @@ -81,9 +81,10 @@ OPreparedStatement::OPreparedStatement(const Reference< XConnection > & _xConn, :OStatementBase(_xConn, _xStatement) { DBG_CTOR(OPreparedStatement, NULL); + m_xAggregateAsParameters = Reference< XParameters >( m_xAggregateAsSet, UNO_QUERY_THROW ); + Reference<XDatabaseMetaData> xMeta = _xConn->getMetaData(); m_pColumns = new OColumns(*this, m_aMutex, xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),::std::vector< ::rtl::OUString>(), NULL,NULL); - m_xAggregateAsParameters = Reference< XParameters > (m_xAggregateAsSet, UNO_QUERY); } //-------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index 812d7bd85df5..a3a66290d5b5 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -138,7 +138,7 @@ OQuery::OQuery( const Reference< XPropertySet >& _rxCommandDefinition ,const Reference< XMultiServiceFactory >& _xORB) :OContentHelper(_xORB,NULL,TContentPtr(new OContentHelper_Impl)) ,OQueryDescriptor_Base(m_aMutex,*this) - ,ODataSettings(m_aBHelper,sal_True) + ,ODataSettings(OContentHelper::rBHelper,sal_True) ,m_xCommandDefinition(_rxCommandDefinition) ,m_xConnection(_rxConn) ,m_pColumnMediator( NULL ) diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx index ea5524d89cd2..b26a7c46f9f9 100644 --- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx +++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx @@ -147,7 +147,7 @@ OComponentDefinition::OComponentDefinition(const Reference< XMultiServiceFactory ,const TContentPtr& _pImpl ,sal_Bool _bTable) :OContentHelper(_xORB,_xParentContainer,_pImpl) - ,ODataSettings(m_aBHelper,!_bTable) + ,ODataSettings(OContentHelper::rBHelper,!_bTable) ,m_bTable(_bTable) { DBG_CTOR(OComponentDefinition, NULL); @@ -166,7 +166,7 @@ OComponentDefinition::OComponentDefinition( const Reference< XInterface >& _rxCo ,const TContentPtr& _pImpl ,sal_Bool _bTable) :OContentHelper(_xORB,_rxContainer,_pImpl) - ,ODataSettings(m_aBHelper,!_bTable) + ,ODataSettings(OContentHelper::rBHelper,!_bTable) ,m_bTable(_bTable) { DBG_CTOR(OComponentDefinition, NULL); diff --git a/dbaccess/source/core/dataaccess/ContentHelper.cxx b/dbaccess/source/core/dataaccess/ContentHelper.cxx index a74e13f8eefa..e4c1d781d63b 100644 --- a/dbaccess/source/core/dataaccess/ContentHelper.cxx +++ b/dbaccess/source/core/dataaccess/ContentHelper.cxx @@ -667,6 +667,7 @@ void SAL_CALL OContentHelper::setParent( const Reference< XInterface >& _xParent ::osl::MutexGuard aGuard(m_aMutex); m_xParentContainer = _xParent; } + // ----------------------------------------------------------------------------- void SAL_CALL OContentHelper::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException) { diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 7638609062d9..b3e329c6889a 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -1,1472 +1,1452 @@ -/************************************************************************* - * - * 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: ModelImpl.cxx,v $ - * $Revision: 1.25.6.12 $ - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_dbaccess.hxx" - -#include "commandcontainer.hxx" -#include "connection.hxx" -#include "core_resource.hrc" -#include "core_resource.hxx" -#include "databasecontext.hxx" -#include "databasedocument.hxx" -#include "datasource.hxx" -#include "dbastrings.hrc" -#include "ModelImpl.hxx" -#include "userinformation.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/container/XSet.hpp> -#include <com/sun/star/document/MacroExecMode.hpp> -#include <com/sun/star/embed/XTransactedObject.hpp> -#include <com/sun/star/embed/XTransactionBroadcaster.hpp> -#include <com/sun/star/sdb/BooleanComparisonMode.hpp> -#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp> -#include <com/sun/star/script/DocumentDialogLibraryContainer.hpp> -#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> -#include <com/sun/star/form/XLoadable.hpp> -/** === end UNO includes === **/ - -#include <comphelper/interaction.hxx> -#include <comphelper/mediadescriptor.hxx> -#include <comphelper/namedvaluecollection.hxx> -#include <comphelper/seqstream.hxx> -#include <comphelper/sequence.hxx> -#include <connectivity/dbexception.hxx> -#include <cppuhelper/exc_hlp.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <rtl/digest.h> -#include <sfx2/signaturestate.hxx> -#include <tools/debug.hxx> -#include <tools/diagnose_ex.h> -#include <tools/errcode.hxx> -#include <tools/urlobj.hxx> -#include <unotools/sharedunocomponent.hxx> - -#include <algorithm> - -using namespace ::com::sun::star::document; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::embed; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::task; -using namespace ::com::sun::star::ucb; -using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::view; -using namespace ::com::sun::star::task; -using namespace ::com::sun::star::reflection; -using namespace ::com::sun::star::script; -using namespace ::cppu; -using namespace ::osl; -using namespace ::vos; -using namespace ::dbtools; -using namespace ::comphelper; -namespace css = ::com::sun::star; - -//........................................................................ -namespace dbaccess -{ -//........................................................................ - -//======================================================================== -//= SharedMutex -//======================================================================== -//------------------------------------------------------------------------ -SharedMutex::SharedMutex() - :m_refCount( 0 ) -{ -} - -//------------------------------------------------------------------------ -SharedMutex::~SharedMutex() -{ -} - -//------------------------------------------------------------------------ -void SAL_CALL SharedMutex::acquire() -{ - osl_incrementInterlockedCount( &m_refCount ); -} - -//------------------------------------------------------------------------ -void SAL_CALL SharedMutex::release() -{ - if ( 0 == osl_decrementInterlockedCount( &m_refCount ) ) - delete this; -} - -//============================================================ -//= VosMutexFacade -//============================================================ -//------------------------------------------------------------------------ -VosMutexFacade::VosMutexFacade( ::osl::Mutex& _rMutex ) - :m_rMutex( _rMutex ) -{ -} - -//------------------------------------------------------------------------ -void SAL_CALL VosMutexFacade::acquire() -{ - m_rMutex.acquire(); -} - -//------------------------------------------------------------------------ -sal_Bool SAL_CALL VosMutexFacade::tryToAcquire() -{ - return m_rMutex.tryToAcquire(); -} - -//------------------------------------------------------------------------ -void SAL_CALL VosMutexFacade::release() -{ - m_rMutex.release(); -} - -//============================================================ -//= DocumentStorageAccess -//============================================================ -DBG_NAME( DocumentStorageAccess ) -class DocumentStorageAccess : public ::cppu::WeakImplHelper2< XDocumentSubStorageSupplier - , XTransactionListener > -{ - typedef ::std::map< ::rtl::OUString, Reference< XStorage > > NamedStorages; - - ::osl::Mutex m_aMutex; - /// all sub storages which we ever gave to the outer world - NamedStorages m_aExposedStorages; - ODatabaseModelImpl* m_pModelImplementation; - bool m_bPropagateCommitToRoot; - -public: - DocumentStorageAccess( ODatabaseModelImpl& _rModelImplementation ) - :m_pModelImplementation( &_rModelImplementation ) - ,m_bPropagateCommitToRoot( true ) - { - DBG_CTOR( DocumentStorageAccess, NULL ); - } - -protected: - ~DocumentStorageAccess() - { - DBG_DTOR( DocumentStorageAccess, NULL ); - } - -public: - void dispose(); - - void suspendCommitPropagation() - { - DBG_ASSERT( m_bPropagateCommitToRoot, "DocumentStorageAccess:: suspendCommitPropagation: already suspended" ); - m_bPropagateCommitToRoot = false; - } - void resumeCommitPropagation() - { - DBG_ASSERT( !m_bPropagateCommitToRoot, "DocumentStorageAccess:: suspendCommitPropagation: already suspended" ); - m_bPropagateCommitToRoot = true; - } - - // XDocumentSubStorageSupplier - virtual Reference< XStorage > SAL_CALL getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw (RuntimeException); - virtual Sequence< ::rtl::OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (IOException, RuntimeException); - - // XTransactionListener - virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); - - // XEventListener - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); -}; - -//-------------------------------------------------------------------------- -void DocumentStorageAccess::dispose() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - for ( NamedStorages::iterator loop = m_aExposedStorages.begin(); - loop != m_aExposedStorages.end(); - ++loop - ) - { - try - { - Reference< XTransactionBroadcaster > xBroadcaster( loop->second, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->removeTransactionListener( this ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - m_aExposedStorages.clear(); - - m_pModelImplementation = NULL; -} - -//-------------------------------------------------------------------------- -Reference< XStorage > SAL_CALL DocumentStorageAccess::getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - NamedStorages::iterator pos = m_aExposedStorages.find( aStorageName ); - if ( pos == m_aExposedStorages.end() ) - { - Reference< XStorage > xResult = m_pModelImplementation->getStorage( aStorageName, nMode ); - Reference< XTransactionBroadcaster > xBroadcaster( xResult, UNO_QUERY ); - if ( xBroadcaster.is() ) - xBroadcaster->addTransactionListener( this ); - - pos = m_aExposedStorages.insert( NamedStorages::value_type( aStorageName, xResult ) ).first; - } - - return pos->second; -} - -//-------------------------------------------------------------------------- -Sequence< ::rtl::OUString > SAL_CALL DocumentStorageAccess::getDocumentSubStoragesNames( ) throw (IOException, RuntimeException) -{ - Reference< XStorage > xRootStor( m_pModelImplementation->getRootStorage() ); - if ( !xRootStor.is() ) - return Sequence< ::rtl::OUString >(); - - ::std::vector< ::rtl::OUString > aNames; - - Reference< XNameAccess > xNames( xRootStor, UNO_QUERY_THROW ); - Sequence< ::rtl::OUString > aElementNames( xNames->getElementNames() ); - for ( sal_Int32 i=0; i<aElementNames.getLength(); ++i ) - { - if ( xRootStor->isStorageElement( aElementNames[i] ) ) - aNames.push_back( aElementNames[i] ); - } - return aNames.empty() - ? Sequence< ::rtl::OUString >() - : Sequence< ::rtl::OUString >( &aNames[0], aNames.size() ); -} - -//-------------------------------------------------------------------------- -void SAL_CALL DocumentStorageAccess::preCommit( const css::lang::EventObject& /*aEvent*/ ) throw (Exception, RuntimeException) -{ - // not interested in -} - -//-------------------------------------------------------------------------- -void SAL_CALL DocumentStorageAccess::commited( const css::lang::EventObject& aEvent ) throw (RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - if ( m_pModelImplementation ) - m_pModelImplementation->setModified( sal_True ); - - if ( m_pModelImplementation && m_bPropagateCommitToRoot ) - { - Reference< XStorage > xStorage( aEvent.Source, UNO_QUERY ); - if ( m_pModelImplementation->isDatabaseStorage( xStorage ) ) - { - m_pModelImplementation->commitRootStorage(); - } - } -} - -//-------------------------------------------------------------------------- -void SAL_CALL DocumentStorageAccess::preRevert( const css::lang::EventObject& /*aEvent*/ ) throw (Exception, RuntimeException) -{ - // not interested in -} - -//-------------------------------------------------------------------------- -void SAL_CALL DocumentStorageAccess::reverted( const css::lang::EventObject& /*aEvent*/ ) throw (RuntimeException) -{ - // not interested in -} - -//-------------------------------------------------------------------------- -void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& Source ) throw ( RuntimeException ) -{ - ODatabaseModelImpl* pImpl = m_pModelImplementation; - if ( pImpl ) - pImpl->disposing( Source ); - - for ( NamedStorages::iterator find = m_aExposedStorages.begin(); - find != m_aExposedStorages.end(); - ++find - ) - if ( find->second == Source.Source ) - { - m_aExposedStorages.erase( find ); - break; - } -} - -//============================================================ -//= ODatabaseModelImpl -//============================================================ -DBG_NAME(ODatabaseModelImpl) -//-------------------------------------------------------------------------- -ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XMultiServiceFactory >& _rxFactory, ODatabaseContext& _rDBContext ) - :m_xModel() - ,m_xDataSource() - ,m_pStorageAccess( NULL ) - ,m_aMutexFacade( m_xMutex->getMutex() ) - ,m_aContainer(4) - ,m_aStorages() - ,m_aMacroMode( *this ) - ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) - ,m_pDBContext( &_rDBContext ) - ,m_refCount(0) - ,m_bHasAnyObjectWithMacros( false ) - ,m_bHasMacroStorages( false ) - ,m_bModificationLock( false ) - ,m_bDocumentInitialized( false ) - ,m_aContext( _rxFactory ) - ,m_nLoginTimeout(0) - ,m_bReadOnly(sal_False) - ,m_bPasswordRequired(sal_False) - ,m_bSuppressVersionColumns(sal_True) - ,m_bModified(sal_False) - ,m_bDocumentReadOnly(sal_False) - ,m_bDisposingSubStorages( sal_False ) - ,m_pSharedConnectionManager(NULL) - ,m_nControllerLockCount(0) -{ - // some kind of default - DBG_CTOR(ODatabaseModelImpl,NULL); - m_sConnectURL = ::rtl::OUString::createFromAscii("jdbc:"); - m_aTableFilter.realloc(1); - m_aTableFilter[0] = ::rtl::OUString::createFromAscii("%"); - impl_construct_nothrow(); -} - -//-------------------------------------------------------------------------- -ODatabaseModelImpl::ODatabaseModelImpl( - const ::rtl::OUString& _rRegistrationName, - const Reference< XMultiServiceFactory >& _rxFactory, - ODatabaseContext& _rDBContext - ) - :m_xModel() - ,m_xDataSource() - ,m_pStorageAccess( NULL ) - ,m_aMutexFacade( m_xMutex->getMutex() ) - ,m_aContainer(4) - ,m_aStorages() - ,m_aMacroMode( *this ) - ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) - ,m_pDBContext( &_rDBContext ) - ,m_refCount(0) - ,m_bHasAnyObjectWithMacros( false ) - ,m_bHasMacroStorages( false ) - ,m_bModificationLock( false ) - ,m_bDocumentInitialized( false ) - ,m_aContext( _rxFactory ) - ,m_sName(_rRegistrationName) - ,m_nLoginTimeout(0) - ,m_bReadOnly(sal_False) - ,m_bPasswordRequired(sal_False) - ,m_bSuppressVersionColumns(sal_True) - ,m_bModified(sal_False) - ,m_bDocumentReadOnly(sal_False) - ,m_bDisposingSubStorages( sal_False ) - ,m_pSharedConnectionManager(NULL) - ,m_nControllerLockCount(0) -{ - DBG_CTOR(ODatabaseModelImpl,NULL); - impl_construct_nothrow(); -} - -//-------------------------------------------------------------------------- -ODatabaseModelImpl::~ODatabaseModelImpl() -{ - DBG_DTOR(ODatabaseModelImpl,NULL); -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::impl_construct_nothrow() -{ - // create the property bag to hold the settings (also known as "Info" property) - try - { - // the set of property value types in the bag is limited: - Sequence< Type > aAllowedTypes(6); - Type* pAllowedType = aAllowedTypes.getArray(); - *pAllowedType++ = ::getCppuType( static_cast< sal_Bool* >( NULL ) ); - *pAllowedType++ = ::getCppuType( static_cast< double* >( NULL ) ); - *pAllowedType++ = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ); - *pAllowedType++ = ::getCppuType( static_cast< sal_Int32* >( NULL ) ); - *pAllowedType++ = ::getCppuType( static_cast< sal_Int16* >( NULL ) ); - *pAllowedType++ = ::getCppuType( static_cast< Sequence< Any >* >( NULL ) ); - - Sequence< Any > aInitArgs( 2 ); - aInitArgs[0] <<= NamedValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutomaticAddition" ) ), - makeAny( (sal_Bool)sal_True ) - ); - aInitArgs[1] <<= NamedValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowedTypes" ) ), - makeAny( aAllowedTypes ) - ); - - m_xSettings.set( m_aContext.createComponentWithArguments( "com.sun.star.beans.PropertyBag", aInitArgs ), UNO_QUERY_THROW ); - - // insert the default settings - Reference< XPropertyContainer > xContainer( m_xSettings, UNO_QUERY_THROW ); - const AsciiPropertyValue* pSettings = getDefaultDataSourceSettings(); - for ( ; pSettings->AsciiName; ++pSettings ) - { - xContainer->addProperty( - ::rtl::OUString::createFromAscii( pSettings->AsciiName ), - PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT, - pSettings->DefaultValue - ); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -// ----------------------------------------------------------------------------- -namespace -{ - // ......................................................................... - ::rtl::OUString lcl_getContainerStorageName_throw( ODatabaseModelImpl::ObjectType _eType ) - { - const sal_Char* pAsciiName( NULL ); - switch ( _eType ) - { - case ODatabaseModelImpl::E_FORM: pAsciiName = "forms"; break; - case ODatabaseModelImpl::E_REPORT: pAsciiName = "reports"; break; - case ODatabaseModelImpl::E_QUERY: pAsciiName = "queries"; break; - case ODatabaseModelImpl::E_TABLE: pAsciiName = "tables"; break; - default: - throw RuntimeException(); - } - return ::rtl::OUString::createFromAscii( pAsciiName ); - } - - // ......................................................................... - bool lcl_hasObjectWithMacros_throw( const ODefinitionContainer_Impl& _rObjectDefinitions, const Reference< XStorage >& _rxContainerStorage ) - { - bool bSomeDocHasMacros = false; - - for ( ODefinitionContainer_Impl::const_iterator object = _rObjectDefinitions.begin(); - ( object != _rObjectDefinitions.end() ) && !bSomeDocHasMacros; - ++object - ) - { -#if OSL_DEBUG_LEVEL > 0 - const ::rtl::OUString& rName( object->first ); (void)rName; -#endif - - const TContentPtr& rDefinition( object->second ); - const ::rtl::OUString& rPersistentName( rDefinition->m_aProps.sPersistentName ); - - if ( !rPersistentName.getLength() ) - { // it's a logical sub folder used to organize the real objects - const ODefinitionContainer_Impl& rSubFoldersObjectDefinitions( dynamic_cast< const ODefinitionContainer_Impl& >( *rDefinition.get() ) ); - bSomeDocHasMacros = lcl_hasObjectWithMacros_throw( rSubFoldersObjectDefinitions, _rxContainerStorage ); - continue; - } - - bSomeDocHasMacros = ODatabaseModelImpl::objectHasMacros( _rxContainerStorage, rPersistentName ); - } - return bSomeDocHasMacros; - } - - // ......................................................................... - bool lcl_hasObjectsWithMacros_nothrow( ODatabaseModelImpl& _rModel, const ODatabaseModelImpl::ObjectType _eType ) - { - bool bSomeDocHasMacros = false; - - const OContentHelper_Impl& rContainerData( *_rModel.getObjectContainer( _eType ).get() ); - const ODefinitionContainer_Impl& rObjectDefinitions = dynamic_cast< const ODefinitionContainer_Impl& >( rContainerData ); - - try - { - Reference< XStorage > xContainerStorage( _rModel.getStorage( - _rModel.getObjectContainerStorageName( _eType ), ElementModes::READWRITE ) ); - // note the READWRITE here: If the storage already existed before, then the OpenMode will - // be ignored, anyway. - // If the storage did not yet exist, then it will be created. If the database document - // is read-only, the OpenMode will be automatically downgraded to READ. Otherwise, - // the storage will in fact be created as READWRITE. While this is not strictly necessary - // for this particular use case here, it is required since the storage is *cached*, and - // later use cases will need the READWRITE mode. - - if ( xContainerStorage.is() ) - bSomeDocHasMacros = lcl_hasObjectWithMacros_throw( rObjectDefinitions, xContainerStorage ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - // be on the safe side: If we can't reliably determine whether there are macros, - // assume there actually are. Better this way, than the other way round. - bSomeDocHasMacros = true; - } - - return bSomeDocHasMacros; - } -} - -// ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::objectHasMacros( const Reference< XStorage >& _rxContainerStorage, const ::rtl::OUString& _rPersistentName ) -{ - OSL_PRECOND( _rxContainerStorage.is(), "ODatabaseModelImpl::objectHasMacros: this will crash!" ); - - bool bHasMacros = true; - try - { - if ( !_rxContainerStorage->hasByName( _rPersistentName ) ) - return false; - - Reference< XStorage > xObjectStor( _rxContainerStorage->openStorageElement( - _rPersistentName, ElementModes::READ ) ); - - bHasMacros = ::sfx2::DocumentMacroMode::storageHasMacros( xObjectStor ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return bHasMacros; -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::reset() -{ - m_bReadOnly = sal_False; - ::std::vector< TContentPtr > aEmptyContainers( 4 ); - m_aContainer.swap( aEmptyContainers ); - - if ( m_pStorageAccess ) - { - m_pStorageAccess->dispose(); - m_pStorageAccess->release(); - m_pStorageAccess = NULL; - } -} -// ----------------------------------------------------------------------------- -void SAL_CALL ODatabaseModelImpl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException) -{ - Reference<XConnection> xCon(Source.Source,UNO_QUERY); - if ( xCon.is() ) - { - bool bStore = false; - OWeakConnectionArray::iterator aEnd = m_aConnections.end(); - for (OWeakConnectionArray::iterator i = m_aConnections.begin(); aEnd != i; ++i) - { - if ( xCon == i->get() ) - { - *i = OWeakConnection(); - bStore = true; - break; - } - } - - if ( bStore ) - commitRootStorage(); - } - else // storage - { - if ( !m_bDisposingSubStorages ) - { - Reference<XStorage> xStorage(Source.Source,UNO_QUERY); - TStorages::iterator aFind = ::std::find_if(m_aStorages.begin(),m_aStorages.end(), - ::std::compose1(::std::bind2nd(::std::equal_to<Reference<XStorage> >(),xStorage),::std::select2nd<TStorages::value_type>())); - if ( aFind != m_aStorages.end() ) - m_aStorages.erase(aFind); - } - } -} -//------------------------------------------------------------------------------ -void ODatabaseModelImpl::clearConnections() -{ - OWeakConnectionArray aConnections; - aConnections.swap( m_aConnections ); - - Reference< XConnection > xConn; - for ( OWeakConnectionArray::iterator i = aConnections.begin(); aConnections.end() != i; ++i ) - { - xConn = *i; - if ( xConn.is() ) - { - try - { - xConn->close(); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - } - - m_pSharedConnectionManager = NULL; - m_xSharedConnectionManager = NULL; -} -//------------------------------------------------------------------------------ -void ODatabaseModelImpl::dispose() -{ - // dispose the data source and the model - try - { - Reference< XDataSource > xDS( m_xDataSource ); - ::comphelper::disposeComponent( xDS ); - - Reference< XModel > xModel( m_xModel ); - ::comphelper::disposeComponent( xModel ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - m_xDataSource = WeakReference<XDataSource>(); - m_xModel = WeakReference< XModel >(); - - ::std::vector<TContentPtr>::iterator aIter = m_aContainer.begin(); - ::std::vector<TContentPtr>::iterator aEnd = m_aContainer.end(); - for (;aIter != aEnd ; ++aIter) - { - if ( aIter->get() ) - (*aIter)->m_pDataSource = NULL; - } - m_aContainer.clear(); - - clearConnections(); - - m_xNumberFormatsSupplier = NULL; - - try - { - sal_Bool bStore = commitEmbeddedStorage(); - disposeStorages(); - if ( bStore ) - commitRootStorage(); - - impl_switchToStorage_throw( NULL ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - if ( m_pStorageAccess ) - { - m_pStorageAccess->dispose(); - m_pStorageAccess->release(); - m_pStorageAccess = NULL; - } -} -// ----------------------------------------------------------------------------- -const Reference< XNumberFormatsSupplier > & ODatabaseModelImpl::getNumberFormatsSupplier() -{ - if (!m_xNumberFormatsSupplier.is()) - { - // the arguments : the locale of the current user - UserInformation aUserInfo; - Sequence< Any > aArguments(1); - aArguments.getArray()[0] <<= aUserInfo.getUserLanguage(); - - m_xNumberFormatsSupplier.set( - m_aContext.createComponentWithArguments( "com.sun.star.util.NumberFormatsSupplier", aArguments ), UNO_QUERY_THROW ); - DBG_ASSERT(m_xNumberFormatsSupplier.is(), "ODatabaseModelImpl::getNumberFormatsSupplier : could not instantiate the formats supplier !"); - } - return m_xNumberFormatsSupplier; -} -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArgs ) -{ - ::comphelper::NamedValueCollection aMediaDescriptor( _rArgs ); - - ::rtl::OUString sDocumentLocation( aMediaDescriptor.getOrDefault( "SalvagedFile", _rURL ) ); - if ( !sDocumentLocation.getLength() ) - // this indicates "the document is being recovered, but _rURL already is the real document URL, - // not the temporary document location" - sDocumentLocation = _rURL; - - if ( aMediaDescriptor.has( "SalvagedFile" ) ) - aMediaDescriptor.remove( "SalvagedFile" ); - - m_aArgs = stripLoadArguments( aMediaDescriptor ); - - switchToURL( sDocumentLocation, _rURL ); -} - -// ----------------------------------------------------------------------------- -Sequence< PropertyValue > ODatabaseModelImpl::stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments ) -{ - OSL_ENSURE( !_rArguments.has( "Model" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (1)!" ); - OSL_ENSURE( !_rArguments.has( "ViewName" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (2)!" ); - - ::comphelper::NamedValueCollection aMutableArgs( _rArguments ); - aMutableArgs.remove( "Model" ); - aMutableArgs.remove( "ViewName" ); - return aMutableArgs.getPropertyValues(); -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::disposeStorages() SAL_THROW(()) -{ - m_bDisposingSubStorages = sal_True; - - TStorages::iterator aEnd = m_aStorages.end(); - for ( TStorages::iterator aIter = m_aStorages.begin(); - aIter != aEnd ; - ++aIter - ) - { - try - { - ::comphelper::disposeComponent( aIter->second ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - m_aStorages.clear(); - - m_bDisposingSubStorages = sal_False; -} -// ----------------------------------------------------------------------------- -Reference< XSingleServiceFactory > ODatabaseModelImpl::createStorageFactory() const -{ - return Reference< XSingleServiceFactory >( m_aContext.createComponent( "com.sun.star.embed.StorageFactory" ), UNO_QUERY_THROW ); -} -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::commitRootStorage() -{ - Reference< XStorage > xStorage( getOrCreateRootStorage() ); -#if OSL_DEBUG_LEVEL > 0 - bool bSuccess = -#endif - commitStorageIfWriteable_ignoreErrors( xStorage ); - OSL_ENSURE( bSuccess || !xStorage.is(), - "ODatabaseModelImpl::commitRootStorage: could commit the storage!" ); -} -// ----------------------------------------------------------------------------- -Reference< XStorage > ODatabaseModelImpl::getOrCreateRootStorage() -{ - if ( !m_xDocumentStorage.is() ) - { - Reference< XSingleServiceFactory> xStorageFactory = createStorageFactory(); - if ( xStorageFactory.is() ) - { - Any aSource; - ::comphelper::NamedValueCollection aArgs( m_aArgs ); - - aSource = aArgs.get( "Stream" ); - if ( !aSource.hasValue() ) - aSource = aArgs.get( "InputStream" ); - if ( !aSource.hasValue() && m_sDocFileLocation.getLength() ) - aSource <<= m_sDocFileLocation; - // TODO: shouldn't we also check URL? - - OSL_ENSURE( aSource.hasValue(), "ODatabaseModelImpl::getOrCreateRootStorage: no source to create the storage from!" ); - - if ( aSource.hasValue() ) - { - Sequence< Any > aStorageCreationArgs(2); - aStorageCreationArgs[0] = aSource; - aStorageCreationArgs[1] <<= ElementModes::READWRITE; - - Reference< XStorage > xDocumentStorage; - try - { - xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW ); - } - catch( const Exception& ) - { - m_bDocumentReadOnly = sal_True; - aStorageCreationArgs[1] <<= ElementModes::READ; - try - { - xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - impl_switchToStorage_throw( xDocumentStorage ); - } - } - } - return m_xDocumentStorage.getTyped(); -} -// ----------------------------------------------------------------------------- -DocumentStorageAccess* ODatabaseModelImpl::getDocumentStorageAccess() -{ - if ( !m_pStorageAccess ) - { - m_pStorageAccess = new DocumentStorageAccess( *this ); - m_pStorageAccess->acquire(); - } - return m_pStorageAccess; -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::modelIsDisposing( const bool _wasInitialized, ResetModelAccess ) -{ - m_xModel = Reference< XModel >(); - - // Basic libraries and Dialog libraries are a model facet, though held at this impl class. - // They automatically dispose themself when the model they belong to is being disposed. - // So, to not be tempted to do anything with them, again, we reset them. - m_xBasicLibraries.clear(); - m_xDialogLibraries.clear(); - - m_bDocumentInitialized = _wasInitialized; -} - -// ----------------------------------------------------------------------------- -Reference< XDocumentSubStorageSupplier > ODatabaseModelImpl::getDocumentSubStorageSupplier() -{ - return getDocumentStorageAccess(); -} -// ----------------------------------------------------------------------------- -Reference<XStorage> ODatabaseModelImpl::getStorage( const ::rtl::OUString& _sStorageName, sal_Int32 _nMode ) -{ - OSL_ENSURE(_sStorageName.getLength(),"ODatabaseModelImpl::getStorage: Invalid storage name!"); - Reference<XStorage> xStorage; - TStorages::iterator aFind = m_aStorages.find(_sStorageName); - if ( aFind == m_aStorages.end() ) - { - try - { - Reference< XStorage > xMyStorage( getOrCreateRootStorage() ); - if ( xMyStorage.is() ) - { - sal_Int32 nMode = m_bDocumentReadOnly ? ElementModes::READ : _nMode; - if ( nMode == ElementModes::READ ) - { - Reference< XNameAccess > xSubStorageNames( xMyStorage, UNO_QUERY ); - if ( xSubStorageNames.is() && !xSubStorageNames->hasByName( _sStorageName ) ) - return xStorage; - } - - xStorage = xMyStorage->openStorageElement( _sStorageName, nMode ); - Reference< XTransactionBroadcaster > xBroad( xStorage, UNO_QUERY ); - if ( xBroad.is() ) - xBroad->addTransactionListener( getDocumentStorageAccess() ); - aFind = m_aStorages.insert( TStorages::value_type( _sStorageName, xStorage ) ).first; - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - - if ( aFind != m_aStorages.end() ) - xStorage = aFind->second; - - return xStorage; -} -// ----------------------------------------------------------------------------- -sal_Bool ODatabaseModelImpl::commitEmbeddedStorage( sal_Bool _bPreventRootCommits ) -{ - if ( _bPreventRootCommits && m_pStorageAccess ) - m_pStorageAccess->suspendCommitPropagation(); - - sal_Bool bStore = sal_False; - try - { - TStorages::iterator aFind = m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database"))); - if ( aFind != m_aStorages.end() ) - bStore = commitStorageIfWriteable(aFind->second); - } - catch(Exception&) - { - OSL_ENSURE(0,"Exception Caught: Could not store embedded database!"); - } - - if ( _bPreventRootCommits && m_pStorageAccess ) - m_pStorageAccess->resumeCommitPropagation(); - - return bStore; - -} - -// ----------------------------------------------------------------------------- -namespace -{ - bool lcl_storageIsWritable_nothrow( const Reference< XStorage >& _rxStorage ) - { - if ( !_rxStorage.is() ) - return false; - - sal_Int32 nMode = ElementModes::READ; - try - { - Reference< XPropertySet > xStorageProps( _rxStorage, UNO_QUERY_THROW ); - xStorageProps->getPropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ) ) ) >>= nMode; - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return ( nMode & ElementModes::WRITE ) != 0; - } -} - -// ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::commitStorageIfWriteable( const Reference< XStorage >& _rxStorage ) SAL_THROW(( IOException, WrappedTargetException, RuntimeException )) -{ - bool bSuccess = false; - Reference<XTransactedObject> xTrans( _rxStorage, UNO_QUERY ); - if ( xTrans.is() ) - { - if ( lcl_storageIsWritable_nothrow( _rxStorage ) ) - xTrans->commit(); - bSuccess = true; - } - return bSuccess; -} -// ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const Reference< XStorage >& _rxStorage ) SAL_THROW(()) -{ - bool bSuccess = false; - try - { - bSuccess = commitStorageIfWriteable( _rxStorage ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return bSuccess; -} -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::setModified( sal_Bool _bModified ) -{ - if ( isModifyLocked() ) - return; - - try - { - Reference< XModifiable > xModi( m_xModel.get(), UNO_QUERY ); - if ( xModi.is() ) - xModi->setModified( _bModified ); - else - m_bModified = _bModified; - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -// ----------------------------------------------------------------------------- -Reference<XDataSource> ODatabaseModelImpl::getOrCreateDataSource() -{ - Reference<XDataSource> xDs = m_xDataSource; - if ( !xDs.is() ) - { - xDs = new ODatabaseSource(this); - m_xDataSource = xDs; - } - return xDs; -} -// ----------------------------------------------------------------------------- -Reference< XModel> ODatabaseModelImpl::getModel_noCreate() const -{ - return m_xModel; -} -// ----------------------------------------------------------------------------- -Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership( bool _bInitialize ) -{ - Reference< XModel > xModel( m_xModel ); - OSL_PRECOND( !xModel.is(), "ODatabaseModelImpl::createNewModel_deliverOwnership: not to be called if there already is a model!" ); - if ( !xModel.is() ) - { - xModel = ODatabaseDocument::createDatabaseDocument( this, ODatabaseDocument::FactoryAccess() ); - m_xModel = xModel; - - try - { - Reference< XSet > xModelCollection; - if ( m_aContext.createComponent( "com.sun.star.frame.GlobalEventBroadcaster", xModelCollection ) ) - xModelCollection->insert( makeAny( xModel ) ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - if ( _bInitialize ) - { - try - { - Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW ); - xLoad->initNew(); - } - catch( RuntimeException& ) { throw; } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - } - return xModel; -} -// ----------------------------------------------------------------------------- -oslInterlockedCount SAL_CALL ODatabaseModelImpl::acquire() -{ - return osl_incrementInterlockedCount(&m_refCount); -} -// ----------------------------------------------------------------------------- -oslInterlockedCount SAL_CALL ODatabaseModelImpl::release() -{ - if ( osl_decrementInterlockedCount(&m_refCount) == 0 ) - { - acquire(); // prevent multiple releases - dispose(); - m_pDBContext->storeTransientProperties(*this); - revokeDataSource(); - delete this; - return 0; - } - return m_refCount; -} -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::commitStorages() SAL_THROW(( IOException, RuntimeException )) -{ - try - { - TStorages::iterator aIter = m_aStorages.begin(); - TStorages::iterator aEnd = m_aStorages.end(); - for (; aIter != aEnd ; ++aIter) - commitStorageIfWriteable( aIter->second ); - } - catch(const WrappedTargetException&) - { - // WrappedTargetException not allowed to leave - throw IOException(); - } -} - -// ----------------------------------------------------------------------------- -const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() -{ - static const AsciiPropertyValue aKnownSettings[] = - { - // known JDBC settings - AsciiPropertyValue( "JavaDriverClass", makeAny( ::rtl::OUString() ) ), - // known settings for file-based drivers - AsciiPropertyValue( "Extension", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "CharSet", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "HeaderLine", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "FieldDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ) ) ), - AsciiPropertyValue( "StringDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\"" ) ) ) ), - AsciiPropertyValue( "DecimalDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ) ), - AsciiPropertyValue( "ThousandDelimiter", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "ShowDeleted", makeAny( (sal_Bool)sal_False ) ), - // known ODBC settings - AsciiPropertyValue( "SystemDriverSettings", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "UseCatalog", makeAny( (sal_Bool)sal_False ) ), - // settings related to auto increment handling - AsciiPropertyValue( "AutoIncrementCreation", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "AutoRetrievingStatement", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "IsAutoRetrievingEnabled", makeAny( (sal_Bool)sal_False ) ), - // known Adabas D driver setting - AsciiPropertyValue( "ShutdownDatabase", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "DataCacheSizeIncrement", makeAny( (sal_Int32)20 ) ), - AsciiPropertyValue( "DataCacheSize", makeAny( (sal_Int32)20 ) ), - AsciiPropertyValue( "ControlUser", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "ControlPassword", makeAny( ::rtl::OUString() ) ), - // known LDAP driver settings - AsciiPropertyValue( "HostName", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "PortNumber", makeAny( (sal_Int32)389 ) ), - AsciiPropertyValue( "BaseDN", makeAny( ::rtl::OUString() ) ), - AsciiPropertyValue( "MaxRowCount", makeAny( (sal_Int32)100 ) ), - // misc known driver settings - AsciiPropertyValue( "ParameterNameSubstitution", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "AddIndexAppendix", makeAny( (sal_Bool)sal_True ) ), - // known SDB level settings - AsciiPropertyValue( "IgnoreDriverPrivileges", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "NoNameLengthLimit", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "AppendTableAliasName", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "GenerateASBeforeCorrelationName", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "ColumnAliasInOrderBy", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "EnableSQL92Check", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "BooleanComparisonMode", makeAny( BooleanComparisonMode::EQUAL_INTEGER ) ), - AsciiPropertyValue( "TableTypeFilterMode", makeAny( (sal_Int32)3 ) ), - AsciiPropertyValue( "RespectDriverResultSetType", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "UseSchemaInSelect", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "UseCatalogInSelect", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "EnableOuterJoinEscape", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "PreferDosLikeLineEnds", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "FormsCheckRequiredFields", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "EscapeDateTime", makeAny( (sal_Bool)sal_True ) ), - AsciiPropertyValue( "IgnoreCurrency", makeAny( (sal_Bool)sal_False ) ), - AsciiPropertyValue( "TypeInfoSettings", makeAny( Sequence< Any >()) ), - AsciiPropertyValue( "LocalSocket", makeAny( ::rtl::OUString() ) ), - - AsciiPropertyValue( NULL, Any() ) - }; - return aKnownSettings; -} - -// ----------------------------------------------------------------------------- -TContentPtr& ODatabaseModelImpl::getObjectContainer( ObjectType _eType ) -{ - OSL_PRECOND( _eType >= E_FORM && _eType <= E_TABLE, "ODatabaseModelImpl::getObjectContainer: illegal index!" ); - TContentPtr& rContentPtr = m_aContainer[ _eType ]; - - if ( !rContentPtr.get() ) - { - rContentPtr = TContentPtr( new ODefinitionContainer_Impl ); - rContentPtr->m_pDataSource = this; - rContentPtr->m_aProps.aTitle = lcl_getContainerStorageName_throw( _eType ); - } - return rContentPtr; -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::revokeDataSource() const -{ - if ( m_pDBContext && m_sDocumentURL.getLength() ) - m_pDBContext->deregisterPrivate( m_sDocumentURL ); -} - -// ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::adjustMacroMode_AutoReject() -{ - return m_aMacroMode.adjustMacroMode( NULL ); -} - -// ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::checkMacrosOnLoading() -{ - ::comphelper::NamedValueCollection aArgs( m_aArgs ); - Reference< XInteractionHandler > xInteraction; - xInteraction = aArgs.getOrDefault( "InteractionHandler", xInteraction ); - return m_aMacroMode.checkMacrosOnLoading( xInteraction ); -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::resetMacroExecutionMode() -{ - m_aMacroMode = ::sfx2::DocumentMacroMode( *this ); -} - -// ----------------------------------------------------------------------------- -Reference< XStorageBasedLibraryContainer > ODatabaseModelImpl::getLibraryContainer( bool _bScript ) -{ - Reference< XStorageBasedLibraryContainer >& rxContainer( _bScript ? m_xBasicLibraries : m_xDialogLibraries ); - if ( rxContainer.is() ) - return rxContainer; - - Reference< XStorageBasedDocument > xDocument( getModel_noCreate(), UNO_QUERY_THROW ); - // this is only to be called if there already exists a document model - in fact, it is - // to be called by the document model only - - try - { - Reference< XStorageBasedLibraryContainer > (*Factory)( const Reference< XComponentContext >&, const Reference< XStorageBasedDocument >&) - = _bScript ? &DocumentScriptLibraryContainer::create : &DocumentDialogLibraryContainer::create; - - rxContainer.set( - (*Factory)( m_aContext.getUNOContext(), xDocument ), - UNO_QUERY_THROW - ); - } - catch( const RuntimeException& ) - { - throw; - } - catch( const Exception& ) - { - throw WrappedTargetRuntimeException( - ::rtl::OUString(), - xDocument, - ::cppu::getCaughtException() - ); - } - return rxContainer; -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::storeLibraryContainersTo( const Reference< XStorage >& _rxToRootStorage ) -{ - if ( m_xBasicLibraries.is() ) - m_xBasicLibraries->storeLibrariesToStorage( _rxToRootStorage ); - - if ( m_xDialogLibraries.is() ) - m_xDialogLibraries->storeLibrariesToStorage( _rxToRootStorage ); -} - -// ----------------------------------------------------------------------------- -Reference< XStorage > ODatabaseModelImpl::switchToStorage( const Reference< XStorage >& _rxNewRootStorage ) -{ - if ( !_rxNewRootStorage.is() ) - throw IllegalArgumentException(); - - return impl_switchToStorage_throw( _rxNewRootStorage ); -} - -// ----------------------------------------------------------------------------- -namespace -{ - void lcl_modifyListening( ::sfx2::IModifiableDocument& _rDocument, - const Reference< XStorage >& _rxStorage, ::rtl::Reference< ::sfx2::DocumentStorageModifyListener >& _inout_rListener, - ::vos::IMutex& _rMutex, bool _bListen ) - { - Reference< XModifiable > xModify( _rxStorage, UNO_QUERY ); - OSL_ENSURE( xModify.is() || !_rxStorage.is(), "lcl_modifyListening: storage can't notify us!" ); - - if ( xModify.is() && !_bListen && _inout_rListener.is() ) - { - xModify->removeModifyListener( _inout_rListener.get() ); - } - - if ( _inout_rListener.is() ) - { - _inout_rListener->dispose(); - _inout_rListener = NULL; - } - - if ( xModify.is() && _bListen ) - { - // the listener from sfx2 uses SolarMutex internally - _inout_rListener = new ::sfx2::DocumentStorageModifyListener( _rDocument, _rMutex ); - xModify->addModifyListener( _inout_rListener.get() ); - } - } - - // ------------------------------------------------------------------------- - static void lcl_rebaseScriptStorage_throw( const Reference< XStorageBasedLibraryContainer >& _rxContainer, - const Reference< XStorage >& _rxNewRootStorage ) - { - if ( _rxContainer.is() ) - { - if ( _rxNewRootStorage.is() ) - _rxContainer->setRootStorage( _rxNewRootStorage ); -// else - // TODO: what to do here? dispose the container? - } - } -} - -// ----------------------------------------------------------------------------- -Reference< XStorage > ODatabaseModelImpl::impl_switchToStorage_throw( const Reference< XStorage >& _rxNewRootStorage ) -{ - // stop listening for modifications at the old storage - lcl_modifyListening( *this, m_xDocumentStorage.getTyped(), m_pStorageModifyListener, m_aMutexFacade, false ); - - // set new storage - m_xDocumentStorage.reset( _rxNewRootStorage, SharedStorage::TakeOwnership ); - - // start listening for modifications - lcl_modifyListening( *this, m_xDocumentStorage.getTyped(), m_pStorageModifyListener, m_aMutexFacade, true ); - - // forward new storage to Basic and Dialog library containers - lcl_rebaseScriptStorage_throw( m_xBasicLibraries, m_xDocumentStorage.getTyped() ); - lcl_rebaseScriptStorage_throw( m_xDialogLibraries, m_xDocumentStorage.getTyped() ); - - m_bReadOnly = !lcl_storageIsWritable_nothrow( m_xDocumentStorage.getTyped() ); - // TODO: our data source, if it exists, must broadcast the change of its ReadOnly property - - return m_xDocumentStorage.getTyped(); -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::switchToURL( const ::rtl::OUString& _rDocumentLocation, const ::rtl::OUString& _rDocumentURL ) -{ - // register at the database context, or change registration - if ( _rDocumentURL != m_sDocumentURL ) - { - if ( m_pDBContext ) - { - if ( m_sDocumentURL.getLength() ) - m_pDBContext->nameChangePrivate( m_sDocumentURL, _rDocumentURL ); - else - m_pDBContext->registerPrivate( _rDocumentURL, this ); - } - - // if we do not have a name, yet (i.e. are not registered at the database context), - // then use the URL as name - if ( !m_sName.getLength() ) - { - INetURLObject aURL( _rDocumentURL ); - if ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) - m_sName = _rDocumentURL; - } - } - - // remember both - m_sDocFileLocation = _rDocumentLocation.getLength() ? _rDocumentLocation : _rDocumentURL; - m_sDocumentURL = _rDocumentURL; -} - -// ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::isDatabaseStorage( const Reference< XStorage >& _rxStorage ) const -{ - TStorages::const_iterator pos = m_aStorages.find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "database" ) ) ); - if ( ( pos != m_aStorages.end() ) - && ( pos->second == _rxStorage ) - ) - { - return true; - } - return false; -} - -// ----------------------------------------------------------------------------- -::rtl::OUString ODatabaseModelImpl::getObjectContainerStorageName( const ObjectType _eType ) -{ - return lcl_getContainerStorageName_throw( _eType ); -} - -// ----------------------------------------------------------------------------- -sal_Int16 ODatabaseModelImpl::getCurrentMacroExecMode() const -{ - sal_Int16 nCurrentMode = MacroExecMode::NEVER_EXECUTE; - try - { - ::comphelper::NamedValueCollection aArgs( m_aArgs ); - nCurrentMode = aArgs.getOrDefault( "MacroExecutionMode", nCurrentMode ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return nCurrentMode; -} - -// ----------------------------------------------------------------------------- -sal_Bool ODatabaseModelImpl::setCurrentMacroExecMode( sal_uInt16 nMacroMode ) -{ - try - { - ::comphelper::NamedValueCollection aArgs( m_aArgs ); - aArgs.put( "MacroExecutionMode", nMacroMode ); - aArgs >>= m_aArgs; - return sal_True; - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - - return sal_False; -} - -// ----------------------------------------------------------------------------- -::rtl::OUString ODatabaseModelImpl::getDocumentLocation() const -{ - // don't return getURL() (or m_sDocumentURL, which is the same). In case we were recovered - // after a previous crash of OOo, m_sDocFileLocation points to the file which were loaded from, - // and this is the one we need for security checks. - return getDocFileLocation(); -} - -// ----------------------------------------------------------------------------- -Reference< XStorage > ODatabaseModelImpl::getLastCommitDocumentStorage() -{ - // we do not support signing the scripting storages, so we're allowed to - // return <NULL/> here. - return Reference< XStorage >(); -} - -// ----------------------------------------------------------------------------- -sal_Bool ODatabaseModelImpl::documentStorageHasMacros() const -{ - // does our root storage contain macros? - if ( ::sfx2::DocumentMacroMode::storageHasMacros( m_xDocumentStorage ) ) - { - const_cast< ODatabaseModelImpl* >( this )->m_bHasMacroStorages = true; - return true; - } - - // do we have forms or reports with macros? - if ( lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_FORM ) - || lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_REPORT ) - ) - { - const_cast< ODatabaseModelImpl* >( this )->m_bHasAnyObjectWithMacros = true; - return true; - } - - return false; -} - -// ----------------------------------------------------------------------------- -Reference< XEmbeddedScripts > ODatabaseModelImpl::getEmbeddedDocumentScripts() const -{ - return Reference< XEmbeddedScripts >( getModel_noCreate(), UNO_QUERY ); -} - -// ----------------------------------------------------------------------------- -sal_Int16 ODatabaseModelImpl::getScriptingSignatureState() const -{ - // no support for signatures at the moment - return SIGNATURESTATE_NOSIGNATURES; -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::showBrokenSignatureWarning( const Reference< XInteractionHandler >& /*_rxInteraction*/ ) const -{ - OSL_ENSURE( false, "ODatabaseModelImpl::showBrokenSignatureWarning: signatures can't be broken - we do not support them!" ); -} - -// ----------------------------------------------------------------------------- -void ODatabaseModelImpl::storageIsModified() -{ - setModified( sal_True ); -} - -// ----------------------------------------------------------------------------- -ModelDependentComponent::ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model ) - :m_pImpl( _model ) - ,m_xMutex( _model->getSharedMutex() ) -{ -} - -// ----------------------------------------------------------------------------- -ModelDependentComponent::~ModelDependentComponent() -{ -} - -//........................................................................ -} // namespace dbaccess -//........................................................................ - +/*************************************************************************
+ *
+ * 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: ModelImpl.cxx,v $
+ * $Revision: 1.25.6.12 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "commandcontainer.hxx"
+#include "connection.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "databasecontext.hxx"
+#include "databasedocument.hxx"
+#include "datasource.hxx"
+#include "dbastrings.hrc"
+#include "ModelImpl.hxx"
+#include "userinformation.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
+#include <com/sun/star/sdb/BooleanComparisonMode.hpp>
+#include <com/sun/star/script/DocumentScriptLibraryContainer.hpp>
+#include <com/sun/star/script/DocumentDialogLibraryContainer.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/interaction.hxx>
+#include <comphelper/mediadescriptor.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbexception.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/digest.h>
+#include <sfx2/signaturestate.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/errcode.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/sharedunocomponent.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::reflection;
+using namespace ::com::sun::star::script;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::vos;
+using namespace ::dbtools;
+using namespace ::comphelper;
+namespace css = ::com::sun::star;
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+//============================================================
+//= VosMutexFacade
+//============================================================
+//------------------------------------------------------------------------
+VosMutexFacade::VosMutexFacade( ::osl::Mutex& _rMutex )
+ :m_rMutex( _rMutex )
+{
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL VosMutexFacade::acquire()
+{
+ m_rMutex.acquire();
+}
+
+//------------------------------------------------------------------------
+sal_Bool SAL_CALL VosMutexFacade::tryToAcquire()
+{
+ return m_rMutex.tryToAcquire();
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL VosMutexFacade::release()
+{
+ m_rMutex.release();
+}
+
+//============================================================
+//= DocumentStorageAccess
+//============================================================
+DBG_NAME( DocumentStorageAccess )
+class DocumentStorageAccess : public ::cppu::WeakImplHelper2< XDocumentSubStorageSupplier
+ , XTransactionListener >
+{
+ typedef ::std::map< ::rtl::OUString, Reference< XStorage > > NamedStorages;
+
+ ::osl::Mutex m_aMutex;
+ /// all sub storages which we ever gave to the outer world
+ NamedStorages m_aExposedStorages;
+ ODatabaseModelImpl* m_pModelImplementation;
+ bool m_bPropagateCommitToRoot;
+
+public:
+ DocumentStorageAccess( ODatabaseModelImpl& _rModelImplementation )
+ :m_pModelImplementation( &_rModelImplementation )
+ ,m_bPropagateCommitToRoot( true )
+ {
+ DBG_CTOR( DocumentStorageAccess, NULL );
+ }
+
+protected:
+ ~DocumentStorageAccess()
+ {
+ DBG_DTOR( DocumentStorageAccess, NULL );
+ }
+
+public:
+ void dispose();
+
+ void suspendCommitPropagation()
+ {
+ DBG_ASSERT( m_bPropagateCommitToRoot, "DocumentStorageAccess:: suspendCommitPropagation: already suspended" );
+ m_bPropagateCommitToRoot = false;
+ }
+ void resumeCommitPropagation()
+ {
+ DBG_ASSERT( !m_bPropagateCommitToRoot, "DocumentStorageAccess:: suspendCommitPropagation: already suspended" );
+ m_bPropagateCommitToRoot = true;
+ }
+
+ // XDocumentSubStorageSupplier
+ virtual Reference< XStorage > SAL_CALL getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getDocumentSubStoragesNames( ) throw (IOException, RuntimeException);
+
+ // XTransactionListener
+ virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+//--------------------------------------------------------------------------
+void DocumentStorageAccess::dispose()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ for ( NamedStorages::iterator loop = m_aExposedStorages.begin();
+ loop != m_aExposedStorages.end();
+ ++loop
+ )
+ {
+ try
+ {
+ Reference< XTransactionBroadcaster > xBroadcaster( loop->second, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ xBroadcaster->removeTransactionListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ m_aExposedStorages.clear();
+
+ m_pModelImplementation = NULL;
+}
+
+//--------------------------------------------------------------------------
+Reference< XStorage > SAL_CALL DocumentStorageAccess::getDocumentSubStorage( const ::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ NamedStorages::iterator pos = m_aExposedStorages.find( aStorageName );
+ if ( pos == m_aExposedStorages.end() )
+ {
+ Reference< XStorage > xResult = m_pModelImplementation->getStorage( aStorageName, nMode );
+ Reference< XTransactionBroadcaster > xBroadcaster( xResult, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ xBroadcaster->addTransactionListener( this );
+
+ pos = m_aExposedStorages.insert( NamedStorages::value_type( aStorageName, xResult ) ).first;
+ }
+
+ return pos->second;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL DocumentStorageAccess::getDocumentSubStoragesNames( ) throw (IOException, RuntimeException)
+{
+ Reference< XStorage > xRootStor( m_pModelImplementation->getRootStorage() );
+ if ( !xRootStor.is() )
+ return Sequence< ::rtl::OUString >();
+
+ ::std::vector< ::rtl::OUString > aNames;
+
+ Reference< XNameAccess > xNames( xRootStor, UNO_QUERY_THROW );
+ Sequence< ::rtl::OUString > aElementNames( xNames->getElementNames() );
+ for ( sal_Int32 i=0; i<aElementNames.getLength(); ++i )
+ {
+ if ( xRootStor->isStorageElement( aElementNames[i] ) )
+ aNames.push_back( aElementNames[i] );
+ }
+ return aNames.empty()
+ ? Sequence< ::rtl::OUString >()
+ : Sequence< ::rtl::OUString >( &aNames[0], aNames.size() );
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::preCommit( const css::lang::EventObject& /*aEvent*/ ) throw (Exception, RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::commited( const css::lang::EventObject& aEvent ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pModelImplementation )
+ m_pModelImplementation->setModified( sal_True );
+
+ if ( m_pModelImplementation && m_bPropagateCommitToRoot )
+ {
+ Reference< XStorage > xStorage( aEvent.Source, UNO_QUERY );
+ if ( m_pModelImplementation->isDatabaseStorage( xStorage ) )
+ {
+ m_pModelImplementation->commitRootStorage();
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::preRevert( const css::lang::EventObject& /*aEvent*/ ) throw (Exception, RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::reverted( const css::lang::EventObject& /*aEvent*/ ) throw (RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& Source ) throw ( RuntimeException )
+{
+ ODatabaseModelImpl* pImpl = m_pModelImplementation;
+ if ( pImpl )
+ pImpl->disposing( Source );
+
+ for ( NamedStorages::iterator find = m_aExposedStorages.begin();
+ find != m_aExposedStorages.end();
+ ++find
+ )
+ if ( find->second == Source.Source )
+ {
+ m_aExposedStorages.erase( find );
+ break;
+ }
+}
+
+//============================================================
+//= ODatabaseModelImpl
+//============================================================
+DBG_NAME(ODatabaseModelImpl)
+//--------------------------------------------------------------------------
+ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XMultiServiceFactory >& _rxFactory, ODatabaseContext& _rDBContext )
+ :m_xModel()
+ ,m_xDataSource()
+ ,m_pStorageAccess( NULL )
+ ,m_aMutex()
+ ,m_aMutexFacade( m_aMutex )
+ ,m_aContainer(4)
+ ,m_aStorages()
+ ,m_aMacroMode( *this )
+ ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
+ ,m_pDBContext( &_rDBContext )
+ ,m_refCount(0)
+ ,m_bHasAnyObjectWithMacros( false )
+ ,m_bHasMacroStorages( false )
+ ,m_bModificationLock( false )
+ ,m_bDocumentInitialized( false )
+ ,m_aContext( _rxFactory )
+ ,m_nLoginTimeout(0)
+ ,m_bReadOnly(sal_False)
+ ,m_bPasswordRequired(sal_False)
+ ,m_bSuppressVersionColumns(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bDocumentReadOnly(sal_False)
+ ,m_bDisposingSubStorages( sal_False )
+ ,m_pSharedConnectionManager(NULL)
+ ,m_nControllerLockCount(0)
+{
+ // some kind of default
+ DBG_CTOR(ODatabaseModelImpl,NULL);
+ m_sConnectURL = ::rtl::OUString::createFromAscii("jdbc:");
+ m_aTableFilter.realloc(1);
+ m_aTableFilter[0] = ::rtl::OUString::createFromAscii("%");
+ impl_construct_nothrow();
+}
+
+//--------------------------------------------------------------------------
+ODatabaseModelImpl::ODatabaseModelImpl(
+ const ::rtl::OUString& _rRegistrationName,
+ const Reference< XMultiServiceFactory >& _rxFactory,
+ ODatabaseContext& _rDBContext
+ )
+ :m_xModel()
+ ,m_xDataSource()
+ ,m_pStorageAccess( NULL )
+ ,m_aMutex()
+ ,m_aMutexFacade( m_aMutex )
+ ,m_aContainer(4)
+ ,m_aStorages()
+ ,m_aMacroMode( *this )
+ ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE )
+ ,m_pDBContext( &_rDBContext )
+ ,m_refCount(0)
+ ,m_bHasAnyObjectWithMacros( false )
+ ,m_bHasMacroStorages( false )
+ ,m_bModificationLock( false )
+ ,m_bDocumentInitialized( false )
+ ,m_aContext( _rxFactory )
+ ,m_sName(_rRegistrationName)
+ ,m_nLoginTimeout(0)
+ ,m_bReadOnly(sal_False)
+ ,m_bPasswordRequired(sal_False)
+ ,m_bSuppressVersionColumns(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bDocumentReadOnly(sal_False)
+ ,m_bDisposingSubStorages( sal_False )
+ ,m_pSharedConnectionManager(NULL)
+ ,m_nControllerLockCount(0)
+{
+ DBG_CTOR(ODatabaseModelImpl,NULL);
+ impl_construct_nothrow();
+}
+
+//--------------------------------------------------------------------------
+ODatabaseModelImpl::~ODatabaseModelImpl()
+{
+ DBG_DTOR(ODatabaseModelImpl,NULL);
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::impl_construct_nothrow()
+{
+ // create the property bag to hold the settings (also known as "Info" property)
+ try
+ {
+ // the set of property value types in the bag is limited:
+ Sequence< Type > aAllowedTypes(6);
+ Type* pAllowedType = aAllowedTypes.getArray();
+ *pAllowedType++ = ::getCppuType( static_cast< sal_Bool* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< double* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< sal_Int16* >( NULL ) );
+ *pAllowedType++ = ::getCppuType( static_cast< Sequence< Any >* >( NULL ) );
+
+ Sequence< Any > aInitArgs( 2 );
+ aInitArgs[0] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutomaticAddition" ) ),
+ makeAny( (sal_Bool)sal_True )
+ );
+ aInitArgs[1] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowedTypes" ) ),
+ makeAny( aAllowedTypes )
+ );
+
+ m_xSettings.set( m_aContext.createComponentWithArguments( "com.sun.star.beans.PropertyBag", aInitArgs ), UNO_QUERY_THROW );
+
+ // insert the default settings
+ Reference< XPropertyContainer > xContainer( m_xSettings, UNO_QUERY_THROW );
+ const AsciiPropertyValue* pSettings = getDefaultDataSourceSettings();
+ for ( ; pSettings->AsciiName; ++pSettings )
+ {
+ xContainer->addProperty(
+ ::rtl::OUString::createFromAscii( pSettings->AsciiName ),
+ PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT,
+ pSettings->DefaultValue
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ // .........................................................................
+ ::rtl::OUString lcl_getContainerStorageName_throw( ODatabaseModelImpl::ObjectType _eType )
+ {
+ const sal_Char* pAsciiName( NULL );
+ switch ( _eType )
+ {
+ case ODatabaseModelImpl::E_FORM: pAsciiName = "forms"; break;
+ case ODatabaseModelImpl::E_REPORT: pAsciiName = "reports"; break;
+ case ODatabaseModelImpl::E_QUERY: pAsciiName = "queries"; break;
+ case ODatabaseModelImpl::E_TABLE: pAsciiName = "tables"; break;
+ default:
+ throw RuntimeException();
+ }
+ return ::rtl::OUString::createFromAscii( pAsciiName );
+ }
+
+ // .........................................................................
+ bool lcl_hasObjectWithMacros_throw( const ODefinitionContainer_Impl& _rObjectDefinitions, const Reference< XStorage >& _rxContainerStorage )
+ {
+ bool bSomeDocHasMacros = false;
+
+ for ( ODefinitionContainer_Impl::const_iterator object = _rObjectDefinitions.begin();
+ ( object != _rObjectDefinitions.end() ) && !bSomeDocHasMacros;
+ ++object
+ )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ const ::rtl::OUString& rName( object->first ); (void)rName;
+#endif
+
+ const TContentPtr& rDefinition( object->second );
+ const ::rtl::OUString& rPersistentName( rDefinition->m_aProps.sPersistentName );
+
+ if ( !rPersistentName.getLength() )
+ { // it's a logical sub folder used to organize the real objects
+ const ODefinitionContainer_Impl& rSubFoldersObjectDefinitions( dynamic_cast< const ODefinitionContainer_Impl& >( *rDefinition.get() ) );
+ bSomeDocHasMacros = lcl_hasObjectWithMacros_throw( rSubFoldersObjectDefinitions, _rxContainerStorage );
+ continue;
+ }
+
+ bSomeDocHasMacros = ODatabaseModelImpl::objectHasMacros( _rxContainerStorage, rPersistentName );
+ }
+ return bSomeDocHasMacros;
+ }
+
+ // .........................................................................
+ bool lcl_hasObjectsWithMacros_nothrow( ODatabaseModelImpl& _rModel, const ODatabaseModelImpl::ObjectType _eType )
+ {
+ bool bSomeDocHasMacros = false;
+
+ const OContentHelper_Impl& rContainerData( *_rModel.getObjectContainer( _eType ).get() );
+ const ODefinitionContainer_Impl& rObjectDefinitions = dynamic_cast< const ODefinitionContainer_Impl& >( rContainerData );
+
+ try
+ {
+ Reference< XStorage > xContainerStorage( _rModel.getStorage(
+ _rModel.getObjectContainerStorageName( _eType ), ElementModes::READWRITE ) );
+ // note the READWRITE here: If the storage already existed before, then the OpenMode will
+ // be ignored, anyway.
+ // If the storage did not yet exist, then it will be created. If the database document
+ // is read-only, the OpenMode will be automatically downgraded to READ. Otherwise,
+ // the storage will in fact be created as READWRITE. While this is not strictly necessary
+ // for this particular use case here, it is required since the storage is *cached*, and
+ // later use cases will need the READWRITE mode.
+
+ if ( xContainerStorage.is() )
+ bSomeDocHasMacros = lcl_hasObjectWithMacros_throw( rObjectDefinitions, xContainerStorage );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ // be on the safe side: If we can't reliably determine whether there are macros,
+ // assume there actually are. Better this way, than the other way round.
+ bSomeDocHasMacros = true;
+ }
+
+ return bSomeDocHasMacros;
+ }
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::objectHasMacros( const Reference< XStorage >& _rxContainerStorage, const ::rtl::OUString& _rPersistentName )
+{
+ OSL_PRECOND( _rxContainerStorage.is(), "ODatabaseModelImpl::objectHasMacros: this will crash!" );
+
+ bool bHasMacros = true;
+ try
+ {
+ if ( !_rxContainerStorage->hasByName( _rPersistentName ) )
+ return false;
+
+ Reference< XStorage > xObjectStor( _rxContainerStorage->openStorageElement(
+ _rPersistentName, ElementModes::READ ) );
+
+ bHasMacros = ::sfx2::DocumentMacroMode::storageHasMacros( xObjectStor );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bHasMacros;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::reset()
+{
+ m_bReadOnly = sal_False;
+ ::std::vector< TContentPtr > aEmptyContainers( 4 );
+ m_aContainer.swap( aEmptyContainers );
+
+ if ( m_pStorageAccess )
+ {
+ m_pStorageAccess->dispose();
+ m_pStorageAccess->release();
+ m_pStorageAccess = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseModelImpl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException)
+{
+ Reference<XConnection> xCon(Source.Source,UNO_QUERY);
+ if ( xCon.is() )
+ {
+ bool bStore = false;
+ OWeakConnectionArray::iterator aEnd = m_aConnections.end();
+ for (OWeakConnectionArray::iterator i = m_aConnections.begin(); aEnd != i; ++i)
+ {
+ if ( xCon == i->get() )
+ {
+ *i = OWeakConnection();
+ bStore = true;
+ break;
+ }
+ }
+
+ if ( bStore )
+ commitRootStorage();
+ }
+ else // storage
+ {
+ if ( !m_bDisposingSubStorages )
+ {
+ Reference<XStorage> xStorage(Source.Source,UNO_QUERY);
+ TStorages::iterator aFind = ::std::find_if(m_aStorages.begin(),m_aStorages.end(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<Reference<XStorage> >(),xStorage),::std::select2nd<TStorages::value_type>()));
+ if ( aFind != m_aStorages.end() )
+ m_aStorages.erase(aFind);
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void ODatabaseModelImpl::clearConnections()
+{
+ OWeakConnectionArray aConnections;
+ aConnections.swap( m_aConnections );
+
+ Reference< XConnection > xConn;
+ for ( OWeakConnectionArray::iterator i = aConnections.begin(); aConnections.end() != i; ++i )
+ {
+ xConn = *i;
+ if ( xConn.is() )
+ {
+ try
+ {
+ xConn->close();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ m_pSharedConnectionManager = NULL;
+ m_xSharedConnectionManager = NULL;
+}
+//------------------------------------------------------------------------------
+void ODatabaseModelImpl::dispose()
+{
+ // dispose the data source and the model
+ try
+ {
+ Reference< XDataSource > xDS( m_xDataSource );
+ ::comphelper::disposeComponent( xDS );
+
+ Reference< XModel > xModel( m_xModel );
+ ::comphelper::disposeComponent( xModel );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xDataSource = WeakReference<XDataSource>();
+ m_xModel = WeakReference< XModel >();
+
+ ::std::vector<TContentPtr>::iterator aIter = m_aContainer.begin();
+ ::std::vector<TContentPtr>::iterator aEnd = m_aContainer.end();
+ for (;aIter != aEnd ; ++aIter)
+ {
+ if ( aIter->get() )
+ (*aIter)->m_pDataSource = NULL;
+ }
+ m_aContainer.clear();
+
+ clearConnections();
+
+ m_xNumberFormatsSupplier = NULL;
+
+ try
+ {
+ sal_Bool bStore = commitEmbeddedStorage();
+ disposeStorages();
+ if ( bStore )
+ commitRootStorage();
+
+ impl_switchToStorage_throw( NULL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( m_pStorageAccess )
+ {
+ m_pStorageAccess->dispose();
+ m_pStorageAccess->release();
+ m_pStorageAccess = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+const Reference< XNumberFormatsSupplier > & ODatabaseModelImpl::getNumberFormatsSupplier()
+{
+ if (!m_xNumberFormatsSupplier.is())
+ {
+ // the arguments : the locale of the current user
+ UserInformation aUserInfo;
+ Sequence< Any > aArguments(1);
+ aArguments.getArray()[0] <<= aUserInfo.getUserLanguage();
+
+ m_xNumberFormatsSupplier.set(
+ m_aContext.createComponentWithArguments( "com.sun.star.util.NumberFormatsSupplier", aArguments ), UNO_QUERY_THROW );
+ DBG_ASSERT(m_xNumberFormatsSupplier.is(), "ODatabaseModelImpl::getNumberFormatsSupplier : could not instantiate the formats supplier !");
+ }
+ return m_xNumberFormatsSupplier;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::attachResource( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rArgs )
+{
+ ::comphelper::NamedValueCollection aMediaDescriptor( _rArgs );
+
+ ::rtl::OUString sDocumentLocation( aMediaDescriptor.getOrDefault( "SalvagedFile", _rURL ) );
+ if ( !sDocumentLocation.getLength() )
+ // this indicates "the document is being recovered, but _rURL already is the real document URL,
+ // not the temporary document location"
+ sDocumentLocation = _rURL;
+
+ if ( aMediaDescriptor.has( "SalvagedFile" ) )
+ aMediaDescriptor.remove( "SalvagedFile" );
+
+ m_aArgs = stripLoadArguments( aMediaDescriptor );
+
+ switchToURL( sDocumentLocation, _rURL );
+}
+
+// -----------------------------------------------------------------------------
+Sequence< PropertyValue > ODatabaseModelImpl::stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments )
+{
+ OSL_ENSURE( !_rArguments.has( "Model" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (1)!" );
+ OSL_ENSURE( !_rArguments.has( "ViewName" ), "ODatabaseModelImpl::stripLoadArguments: this is suspicious (2)!" );
+
+ ::comphelper::NamedValueCollection aMutableArgs( _rArguments );
+ aMutableArgs.remove( "Model" );
+ aMutableArgs.remove( "ViewName" );
+ return aMutableArgs.getPropertyValues();
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::disposeStorages() SAL_THROW(())
+{
+ m_bDisposingSubStorages = sal_True;
+
+ TStorages::iterator aEnd = m_aStorages.end();
+ for ( TStorages::iterator aIter = m_aStorages.begin();
+ aIter != aEnd ;
+ ++aIter
+ )
+ {
+ try
+ {
+ ::comphelper::disposeComponent( aIter->second );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ m_aStorages.clear();
+
+ m_bDisposingSubStorages = sal_False;
+}
+// -----------------------------------------------------------------------------
+Reference< XSingleServiceFactory > ODatabaseModelImpl::createStorageFactory() const
+{
+ return Reference< XSingleServiceFactory >( m_aContext.createComponent( "com.sun.star.embed.StorageFactory" ), UNO_QUERY_THROW );
+}
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::commitRootStorage()
+{
+ Reference< XStorage > xStorage( getOrCreateRootStorage() );
+#if OSL_DEBUG_LEVEL > 0
+ bool bSuccess =
+#endif
+ commitStorageIfWriteable_ignoreErrors( xStorage );
+ OSL_ENSURE( bSuccess || !xStorage.is(),
+ "ODatabaseModelImpl::commitRootStorage: could commit the storage!" );
+}
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::getOrCreateRootStorage()
+{
+ if ( !m_xDocumentStorage.is() )
+ {
+ Reference< XSingleServiceFactory> xStorageFactory = createStorageFactory();
+ if ( xStorageFactory.is() )
+ {
+ Any aSource;
+ ::comphelper::NamedValueCollection aArgs( m_aArgs );
+
+ aSource = aArgs.get( "Stream" );
+ if ( !aSource.hasValue() )
+ aSource = aArgs.get( "InputStream" );
+ if ( !aSource.hasValue() && m_sDocFileLocation.getLength() )
+ aSource <<= m_sDocFileLocation;
+ // TODO: shouldn't we also check URL?
+
+ OSL_ENSURE( aSource.hasValue(), "ODatabaseModelImpl::getOrCreateRootStorage: no source to create the storage from!" );
+
+ if ( aSource.hasValue() )
+ {
+ Sequence< Any > aStorageCreationArgs(2);
+ aStorageCreationArgs[0] = aSource;
+ aStorageCreationArgs[1] <<= ElementModes::READWRITE;
+
+ Reference< XStorage > xDocumentStorage;
+ try
+ {
+ xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ m_bDocumentReadOnly = sal_True;
+ aStorageCreationArgs[1] <<= ElementModes::READ;
+ try
+ {
+ xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ impl_switchToStorage_throw( xDocumentStorage );
+ }
+ }
+ }
+ return m_xDocumentStorage.getTyped();
+}
+// -----------------------------------------------------------------------------
+DocumentStorageAccess* ODatabaseModelImpl::getDocumentStorageAccess()
+{
+ if ( !m_pStorageAccess )
+ {
+ m_pStorageAccess = new DocumentStorageAccess( *this );
+ m_pStorageAccess->acquire();
+ }
+ return m_pStorageAccess;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::modelIsDisposing( const bool _wasInitialized, ResetModelAccess )
+{
+ m_xModel = Reference< XModel >();
+
+ // Basic libraries and Dialog libraries are a model facet, though held at this impl class.
+ // They automatically dispose themself when the model they belong to is being disposed.
+ // So, to not be tempted to do anything with them, again, we reset them.
+ m_xBasicLibraries.clear();
+ m_xDialogLibraries.clear();
+
+ m_bDocumentInitialized = _wasInitialized;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XDocumentSubStorageSupplier > ODatabaseModelImpl::getDocumentSubStorageSupplier()
+{
+ return getDocumentStorageAccess();
+}
+// -----------------------------------------------------------------------------
+Reference<XStorage> ODatabaseModelImpl::getStorage( const ::rtl::OUString& _sStorageName, sal_Int32 _nMode )
+{
+ OSL_ENSURE(_sStorageName.getLength(),"ODatabaseModelImpl::getStorage: Invalid storage name!");
+ Reference<XStorage> xStorage;
+ TStorages::iterator aFind = m_aStorages.find(_sStorageName);
+ if ( aFind == m_aStorages.end() )
+ {
+ try
+ {
+ Reference< XStorage > xMyStorage( getOrCreateRootStorage() );
+ if ( xMyStorage.is() )
+ {
+ sal_Int32 nMode = m_bDocumentReadOnly ? ElementModes::READ : _nMode;
+ if ( nMode == ElementModes::READ )
+ {
+ Reference< XNameAccess > xSubStorageNames( xMyStorage, UNO_QUERY );
+ if ( xSubStorageNames.is() && !xSubStorageNames->hasByName( _sStorageName ) )
+ return xStorage;
+ }
+
+ xStorage = xMyStorage->openStorageElement( _sStorageName, nMode );
+ Reference< XTransactionBroadcaster > xBroad( xStorage, UNO_QUERY );
+ if ( xBroad.is() )
+ xBroad->addTransactionListener( getDocumentStorageAccess() );
+ aFind = m_aStorages.insert( TStorages::value_type( _sStorageName, xStorage ) ).first;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if ( aFind != m_aStorages.end() )
+ xStorage = aFind->second;
+
+ return xStorage;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::commitEmbeddedStorage( sal_Bool _bPreventRootCommits )
+{
+ if ( _bPreventRootCommits && m_pStorageAccess )
+ m_pStorageAccess->suspendCommitPropagation();
+
+ sal_Bool bStore = sal_False;
+ try
+ {
+ TStorages::iterator aFind = m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")));
+ if ( aFind != m_aStorages.end() )
+ bStore = commitStorageIfWriteable(aFind->second);
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"Exception Caught: Could not store embedded database!");
+ }
+
+ if ( _bPreventRootCommits && m_pStorageAccess )
+ m_pStorageAccess->resumeCommitPropagation();
+
+ return bStore;
+
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ bool lcl_storageIsWritable_nothrow( const Reference< XStorage >& _rxStorage )
+ {
+ if ( !_rxStorage.is() )
+ return false;
+
+ sal_Int32 nMode = ElementModes::READ;
+ try
+ {
+ Reference< XPropertySet > xStorageProps( _rxStorage, UNO_QUERY_THROW );
+ xStorageProps->getPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ) ) ) >>= nMode;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return ( nMode & ElementModes::WRITE ) != 0;
+ }
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::commitStorageIfWriteable( const Reference< XStorage >& _rxStorage ) SAL_THROW(( IOException, WrappedTargetException, RuntimeException ))
+{
+ bool bSuccess = false;
+ Reference<XTransactedObject> xTrans( _rxStorage, UNO_QUERY );
+ if ( xTrans.is() )
+ {
+ if ( lcl_storageIsWritable_nothrow( _rxStorage ) )
+ xTrans->commit();
+ bSuccess = true;
+ }
+ return bSuccess;
+}
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::commitStorageIfWriteable_ignoreErrors( const Reference< XStorage >& _rxStorage ) SAL_THROW(())
+{
+ bool bSuccess = false;
+ try
+ {
+ bSuccess = commitStorageIfWriteable( _rxStorage );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSuccess;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::setModified( sal_Bool _bModified )
+{
+ if ( isModifyLocked() )
+ return;
+
+ try
+ {
+ Reference< XModifiable > xModi( m_xModel.get(), UNO_QUERY );
+ if ( xModi.is() )
+ xModi->setModified( _bModified );
+ else
+ m_bModified = _bModified;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference<XDataSource> ODatabaseModelImpl::getOrCreateDataSource()
+{
+ Reference<XDataSource> xDs = m_xDataSource;
+ if ( !xDs.is() )
+ {
+ xDs = new ODatabaseSource(this);
+ m_xDataSource = xDs;
+ }
+ return xDs;
+}
+// -----------------------------------------------------------------------------
+Reference< XModel> ODatabaseModelImpl::getModel_noCreate() const
+{
+ return m_xModel;
+}
+// -----------------------------------------------------------------------------
+Reference< XModel > ODatabaseModelImpl::createNewModel_deliverOwnership( bool _bInitialize )
+{
+ Reference< XModel > xModel( m_xModel );
+ OSL_PRECOND( !xModel.is(), "ODatabaseModelImpl::createNewModel_deliverOwnership: not to be called if there already is a model!" );
+ if ( !xModel.is() )
+ {
+ xModel = ODatabaseDocument::createDatabaseDocument( this, ODatabaseDocument::FactoryAccess() );
+ m_xModel = xModel;
+
+ try
+ {
+ Reference< XSet > xModelCollection;
+ if ( m_aContext.createComponent( "com.sun.star.frame.GlobalEventBroadcaster", xModelCollection ) )
+ xModelCollection->insert( makeAny( xModel ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( _bInitialize )
+ {
+ try
+ {
+ Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW );
+ xLoad->initNew();
+ }
+ catch( RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ return xModel;
+}
+// -----------------------------------------------------------------------------
+oslInterlockedCount SAL_CALL ODatabaseModelImpl::acquire()
+{
+ return osl_incrementInterlockedCount(&m_refCount);
+}
+// -----------------------------------------------------------------------------
+oslInterlockedCount SAL_CALL ODatabaseModelImpl::release()
+{
+ if ( osl_decrementInterlockedCount(&m_refCount) == 0 )
+ {
+ acquire(); // prevent multiple releases
+ dispose();
+ m_pDBContext->storeTransientProperties(*this);
+ revokeDataSource();
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::commitStorages() SAL_THROW(( IOException, RuntimeException ))
+{
+ try
+ {
+ TStorages::iterator aIter = m_aStorages.begin();
+ TStorages::iterator aEnd = m_aStorages.end();
+ for (; aIter != aEnd ; ++aIter)
+ commitStorageIfWriteable( aIter->second );
+ }
+ catch(const WrappedTargetException&)
+ {
+ // WrappedTargetException not allowed to leave
+ throw IOException();
+ }
+}
+
+// -----------------------------------------------------------------------------
+const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings()
+{
+ static const AsciiPropertyValue aKnownSettings[] =
+ {
+ // known JDBC settings
+ AsciiPropertyValue( "JavaDriverClass", makeAny( ::rtl::OUString() ) ),
+ // known settings for file-based drivers
+ AsciiPropertyValue( "Extension", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "CharSet", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "HeaderLine", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "FieldDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ) ) ),
+ AsciiPropertyValue( "StringDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\"" ) ) ) ),
+ AsciiPropertyValue( "DecimalDelimiter", makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) ) ),
+ AsciiPropertyValue( "ThousandDelimiter", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "ShowDeleted", makeAny( (sal_Bool)sal_False ) ),
+ // known ODBC settings
+ AsciiPropertyValue( "SystemDriverSettings", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "UseCatalog", makeAny( (sal_Bool)sal_False ) ),
+ // settings related to auto increment handling
+ AsciiPropertyValue( "AutoIncrementCreation", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "AutoRetrievingStatement", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "IsAutoRetrievingEnabled", makeAny( (sal_Bool)sal_False ) ),
+ // known Adabas D driver setting
+ AsciiPropertyValue( "ShutdownDatabase", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "DataCacheSizeIncrement", makeAny( (sal_Int32)20 ) ),
+ AsciiPropertyValue( "DataCacheSize", makeAny( (sal_Int32)20 ) ),
+ AsciiPropertyValue( "ControlUser", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "ControlPassword", makeAny( ::rtl::OUString() ) ),
+ // known LDAP driver settings
+ AsciiPropertyValue( "HostName", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "PortNumber", makeAny( (sal_Int32)389 ) ),
+ AsciiPropertyValue( "BaseDN", makeAny( ::rtl::OUString() ) ),
+ AsciiPropertyValue( "MaxRowCount", makeAny( (sal_Int32)100 ) ),
+ // misc known driver settings
+ AsciiPropertyValue( "ParameterNameSubstitution", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "AddIndexAppendix", makeAny( (sal_Bool)sal_True ) ),
+ // known SDB level settings
+ AsciiPropertyValue( "IgnoreDriverPrivileges", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "NoNameLengthLimit", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "AppendTableAliasName", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "GenerateASBeforeCorrelationName", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "ColumnAliasInOrderBy", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "EnableSQL92Check", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "BooleanComparisonMode", makeAny( BooleanComparisonMode::EQUAL_INTEGER ) ),
+ AsciiPropertyValue( "TableTypeFilterMode", makeAny( (sal_Int32)3 ) ),
+ AsciiPropertyValue( "RespectDriverResultSetType", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "UseSchemaInSelect", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "UseCatalogInSelect", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "EnableOuterJoinEscape", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "PreferDosLikeLineEnds", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "FormsCheckRequiredFields", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "EscapeDateTime", makeAny( (sal_Bool)sal_True ) ),
+ AsciiPropertyValue( "IgnoreCurrency", makeAny( (sal_Bool)sal_False ) ),
+ AsciiPropertyValue( "TypeInfoSettings", makeAny( Sequence< Any >()) ),
+ AsciiPropertyValue( "LocalSocket", makeAny( ::rtl::OUString() ) ),
+
+ AsciiPropertyValue( NULL, Any() )
+ };
+ return aKnownSettings;
+}
+
+// -----------------------------------------------------------------------------
+TContentPtr& ODatabaseModelImpl::getObjectContainer( ObjectType _eType )
+{
+ OSL_PRECOND( _eType >= E_FORM && _eType <= E_TABLE, "ODatabaseModelImpl::getObjectContainer: illegal index!" );
+ TContentPtr& rContentPtr = m_aContainer[ _eType ];
+
+ if ( !rContentPtr.get() )
+ {
+ rContentPtr = TContentPtr( new ODefinitionContainer_Impl );
+ rContentPtr->m_pDataSource = this;
+ rContentPtr->m_aProps.aTitle = lcl_getContainerStorageName_throw( _eType );
+ }
+ return rContentPtr;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::revokeDataSource() const
+{
+ if ( m_pDBContext && m_sDocumentURL.getLength() )
+ m_pDBContext->deregisterPrivate( m_sDocumentURL );
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::adjustMacroMode_AutoReject()
+{
+ return m_aMacroMode.adjustMacroMode( NULL );
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::checkMacrosOnLoading()
+{
+ ::comphelper::NamedValueCollection aArgs( m_aArgs );
+ Reference< XInteractionHandler > xInteraction;
+ xInteraction = aArgs.getOrDefault( "InteractionHandler", xInteraction );
+ return m_aMacroMode.checkMacrosOnLoading( xInteraction );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::resetMacroExecutionMode()
+{
+ m_aMacroMode = ::sfx2::DocumentMacroMode( *this );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorageBasedLibraryContainer > ODatabaseModelImpl::getLibraryContainer( bool _bScript )
+{
+ Reference< XStorageBasedLibraryContainer >& rxContainer( _bScript ? m_xBasicLibraries : m_xDialogLibraries );
+ if ( rxContainer.is() )
+ return rxContainer;
+
+ Reference< XStorageBasedDocument > xDocument( getModel_noCreate(), UNO_QUERY_THROW );
+ // this is only to be called if there already exists a document model - in fact, it is
+ // to be called by the document model only
+
+ try
+ {
+ Reference< XStorageBasedLibraryContainer > (*Factory)( const Reference< XComponentContext >&, const Reference< XStorageBasedDocument >&)
+ = _bScript ? &DocumentScriptLibraryContainer::create : &DocumentDialogLibraryContainer::create;
+
+ rxContainer.set(
+ (*Factory)( m_aContext.getUNOContext(), xDocument ),
+ UNO_QUERY_THROW
+ );
+ }
+ catch( const RuntimeException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ throw WrappedTargetRuntimeException(
+ ::rtl::OUString(),
+ xDocument,
+ ::cppu::getCaughtException()
+ );
+ }
+ return rxContainer;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::storeLibraryContainersTo( const Reference< XStorage >& _rxToRootStorage )
+{
+ if ( m_xBasicLibraries.is() )
+ m_xBasicLibraries->storeLibrariesToStorage( _rxToRootStorage );
+
+ if ( m_xDialogLibraries.is() )
+ m_xDialogLibraries->storeLibrariesToStorage( _rxToRootStorage );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::switchToStorage( const Reference< XStorage >& _rxNewRootStorage )
+{
+ if ( !_rxNewRootStorage.is() )
+ throw IllegalArgumentException();
+
+ return impl_switchToStorage_throw( _rxNewRootStorage );
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_modifyListening( ::sfx2::IModifiableDocument& _rDocument,
+ const Reference< XStorage >& _rxStorage, ::rtl::Reference< ::sfx2::DocumentStorageModifyListener >& _inout_rListener,
+ ::vos::IMutex& _rMutex, bool _bListen )
+ {
+ Reference< XModifiable > xModify( _rxStorage, UNO_QUERY );
+ OSL_ENSURE( xModify.is() || !_rxStorage.is(), "lcl_modifyListening: storage can't notify us!" );
+
+ if ( xModify.is() && !_bListen && _inout_rListener.is() )
+ {
+ xModify->removeModifyListener( _inout_rListener.get() );
+ }
+
+ if ( _inout_rListener.is() )
+ {
+ _inout_rListener->dispose();
+ _inout_rListener = NULL;
+ }
+
+ if ( xModify.is() && _bListen )
+ {
+ _inout_rListener = new ::sfx2::DocumentStorageModifyListener( _rDocument, _rMutex );
+ xModify->addModifyListener( _inout_rListener.get() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ static void lcl_rebaseScriptStorage_throw( const Reference< XStorageBasedLibraryContainer >& _rxContainer,
+ const Reference< XStorage >& _rxNewRootStorage )
+ {
+ if ( _rxContainer.is() )
+ {
+ if ( _rxNewRootStorage.is() )
+ _rxContainer->setRootStorage( _rxNewRootStorage );
+// else
+ // TODO: what to do here? dispose the container?
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::impl_switchToStorage_throw( const Reference< XStorage >& _rxNewRootStorage )
+{
+ // stop listening for modifications at the old storage
+ lcl_modifyListening( *this, m_xDocumentStorage.getTyped(), m_pStorageModifyListener, m_aMutexFacade, false );
+
+ // set new storage
+ m_xDocumentStorage.reset( _rxNewRootStorage, SharedStorage::TakeOwnership );
+
+ // start listening for modifications
+ lcl_modifyListening( *this, m_xDocumentStorage.getTyped(), m_pStorageModifyListener, m_aMutexFacade, true );
+
+ // forward new storage to Basic and Dialog library containers
+ lcl_rebaseScriptStorage_throw( m_xBasicLibraries, m_xDocumentStorage.getTyped() );
+ lcl_rebaseScriptStorage_throw( m_xDialogLibraries, m_xDocumentStorage.getTyped() );
+
+ m_bReadOnly = !lcl_storageIsWritable_nothrow( m_xDocumentStorage.getTyped() );
+ // TODO: our data source, if it exists, must broadcast the change of its ReadOnly property
+
+ return m_xDocumentStorage.getTyped();
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::switchToURL( const ::rtl::OUString& _rDocumentLocation, const ::rtl::OUString& _rDocumentURL )
+{
+ // register at the database context, or change registration
+ if ( _rDocumentURL != m_sDocumentURL )
+ {
+ if ( m_pDBContext )
+ {
+ if ( m_sDocumentURL.getLength() )
+ m_pDBContext->nameChangePrivate( m_sDocumentURL, _rDocumentURL );
+ else
+ m_pDBContext->registerPrivate( _rDocumentURL, this );
+ }
+
+ if ( ( m_sName == m_sDocumentURL ) // our name is our old URL
+ || ( !m_sName.getLength() ) // we do not have a name, yet (i.e. are not registered at the database context)
+ )
+ {
+ INetURLObject aURL( _rDocumentURL );
+ if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ m_sName = _rDocumentURL;
+ // TODO: our data source must broadcast the change of the Name property
+ }
+ }
+ }
+
+ // remember both
+ m_sDocFileLocation = _rDocumentLocation.getLength() ? _rDocumentLocation : _rDocumentURL;
+ m_sDocumentURL = _rDocumentURL;
+}
+
+// -----------------------------------------------------------------------------
+bool ODatabaseModelImpl::isDatabaseStorage( const Reference< XStorage >& _rxStorage ) const
+{
+ TStorages::const_iterator pos = m_aStorages.find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "database" ) ) );
+ if ( ( pos != m_aStorages.end() )
+ && ( pos->second == _rxStorage )
+ )
+ {
+ return true;
+ }
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODatabaseModelImpl::getObjectContainerStorageName( const ObjectType _eType )
+{
+ return lcl_getContainerStorageName_throw( _eType );
+}
+
+// -----------------------------------------------------------------------------
+sal_Int16 ODatabaseModelImpl::getCurrentMacroExecMode() const
+{
+ sal_Int16 nCurrentMode = MacroExecMode::NEVER_EXECUTE;
+ try
+ {
+ ::comphelper::NamedValueCollection aArgs( m_aArgs );
+ nCurrentMode = aArgs.getOrDefault( "MacroExecutionMode", nCurrentMode );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return nCurrentMode;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::setCurrentMacroExecMode( sal_uInt16 nMacroMode )
+{
+ try
+ {
+ ::comphelper::NamedValueCollection aArgs( m_aArgs );
+ aArgs.put( "MacroExecutionMode", nMacroMode );
+ aArgs >>= m_aArgs;
+ return sal_True;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODatabaseModelImpl::getDocumentLocation() const
+{
+ // don't return getURL() (or m_sDocumentURL, which is the same). In case we were recovered
+ // after a previous crash of OOo, m_sDocFileLocation points to the file which were loaded from,
+ // and this is the one we need for security checks.
+ return getDocFileLocation();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XStorage > ODatabaseModelImpl::getLastCommitDocumentStorage()
+{
+ // we do not support signing the scripting storages, so we're allowed to
+ // return <NULL/> here.
+ return Reference< XStorage >();
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseModelImpl::documentStorageHasMacros() const
+{
+ // does our root storage contain macros?
+ if ( ::sfx2::DocumentMacroMode::storageHasMacros( m_xDocumentStorage ) )
+ {
+ const_cast< ODatabaseModelImpl* >( this )->m_bHasMacroStorages = true;
+ return true;
+ }
+
+ // do we have forms or reports with macros?
+ if ( lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_FORM )
+ || lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_REPORT )
+ )
+ {
+ const_cast< ODatabaseModelImpl* >( this )->m_bHasAnyObjectWithMacros = true;
+ return true;
+ }
+
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XEmbeddedScripts > ODatabaseModelImpl::getEmbeddedDocumentScripts() const
+{
+ return Reference< XEmbeddedScripts >( getModel_noCreate(), UNO_QUERY );
+}
+
+// -----------------------------------------------------------------------------
+sal_Int16 ODatabaseModelImpl::getScriptingSignatureState() const
+{
+ // no support for signatures at the moment
+ return SIGNATURESTATE_NOSIGNATURES;
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::showBrokenSignatureWarning( const Reference< XInteractionHandler >& /*_rxInteraction*/ ) const
+{
+ OSL_ENSURE( false, "ODatabaseModelImpl::showBrokenSignatureWarning: signatures can't be broken - we do not support them!" );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseModelImpl::storageIsModified()
+{
+ setModified( sal_True );
+}
+
+// -----------------------------------------------------------------------------
+ModelDependentComponent::ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model )
+ :m_pImpl( _model )
+ ,m_aMutex( _model->getSharedMutex() )
+{
+}
+
+// -----------------------------------------------------------------------------
+ModelDependentComponent::~ModelDependentComponent()
+{
+}
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.hxx b/dbaccess/source/core/dataaccess/ModelImpl.hxx index 9c845c7c171d..f7628aa45b40 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.hxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.hxx @@ -1,676 +1,637 @@ -/************************************************************************* - * - * 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: ModelImpl.hxx,v $ - * $Revision: 1.24.26.1 $ - * - * 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 _DBA_COREDATAACCESS_MODELIMPL_HXX_ -#define _DBA_COREDATAACCESS_MODELIMPL_HXX_ - -#include "apitools.hxx" -#include "bookmarkcontainer.hxx" -#include "ContentHelper.hxx" -#include "core_resource.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertyAccess.hpp> -#include <com/sun/star/container/XContainerListener.hpp> -#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp> -#include <com/sun/star/document/XEventListener.hpp> -#include <com/sun/star/document/XStorageBasedDocument.hpp> -#include <com/sun/star/embed/ElementModes.hpp> -#include <com/sun/star/embed/XStorage.hpp> -#include <com/sun/star/embed/XTransactionListener.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/lang/NotInitializedException.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/sdb/XBookmarksSupplier.hpp> -#include <com/sun/star/sdb/XCompletedConnection.hpp> -#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp> -#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp> -#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp> -#include <com/sun/star/sdbc/XDataSource.hpp> -#include <com/sun/star/sdbc/XIsolatedConnection.hpp> -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#include <com/sun/star/util/XCloseable.hpp> -#include <com/sun/star/util/XFlushable.hpp> -#include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#include <com/sun/star/util/XNumberFormatter.hpp> -#include <com/sun/star/util/XRefreshable.hpp> -#include <com/sun/star/sdb/XDocumentDataSource.hpp> -#include <com/sun/star/frame/DoubleInitializationException.hpp> -/** === end UNO includes === **/ - -#include <comphelper/broadcasthelper.hxx> -#include <comphelper/proparrhlp.hxx> -#include <connectivity/CommonTools.hxx> -#include <cppuhelper/propshlp.hxx> -#include <cppuhelper/weakref.hxx> -#include <sfx2/docmacromode.hxx> -#include <sfx2/docstoragemodifylistener.hxx> -#include <tools/string.hxx> -#include <unotools/sharedunocomponent.hxx> -#include <vos/mutex.hxx> - -#include <memory> - -namespace comphelper -{ - class NamedValueCollection; -} - -//........................................................................ -namespace dbaccess -{ -//........................................................................ - -typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > OWeakConnection; -typedef std::vector< OWeakConnection > OWeakConnectionArray; - -struct AsciiPropertyValue -{ - // note: the canonic member order would be AsciiName / DefaultValue, but - // this crashes on unxlngi6.pro, since there's a bug which somehow results in - // getDefaultDataSourceSettings returning corrupted Any instances then. - ::com::sun::star::uno::Any DefaultValue; - const sal_Char* AsciiName; - - AsciiPropertyValue( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rDefaultValue ) - :DefaultValue( _rDefaultValue ) - ,AsciiName( _pAsciiName ) - { - } -}; - -class ODatabaseContext; -class OSharedConnectionManager; - -//============================================================ -//= SharedMutex -//============================================================ -/** a shared mutex, which deletes itself as soon as the last reference - to it dies. -*/ -class SharedMutex -{ -private: - oslInterlockedCount m_refCount; - mutable ::osl::Mutex m_aMutex; - -public: - SharedMutex(); - - void SAL_CALL acquire(); - void SAL_CALL release(); - - inline ::osl::Mutex& getMutex() const { return m_aMutex; } - -private: - ~SharedMutex(); -}; - -//============================================================ -//= SharedMutexHolder -//============================================================ -/** a base class merely holding a SharedMutex instance. Useful if you - need to ensure the SharedMutex is to be initialized before other - of your members, in this case just derive from SharedMutexHolder. -*/ -class SharedMutexHolder -{ -protected: - SharedMutexHolder() : m_xMutex( new SharedMutex ) { } - ~SharedMutexHolder() { } - -protected: - ::rtl::Reference< SharedMutex > m_xMutex; -}; - -//============================================================ -//= VosMutexFacade -//============================================================ -/** a class which provides an IMutex interface to an OSL-based mutex -*/ -class VosMutexFacade : public ::vos::IMutex -{ -public: - /** beware of life time: the mutex you pass here must live as least as long - as the VosMutexFacade instance lives. - */ - VosMutexFacade( ::osl::Mutex& _rMutex ); - - // IMutex - virtual void SAL_CALL acquire(); - virtual sal_Bool SAL_CALL tryToAcquire(); - virtual void SAL_CALL release(); - -private: - ::osl::Mutex& m_rMutex; -}; - -//============================================================ -//= ODatabaseModelImpl -//============================================================ -DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >,TStorages); - -typedef ::utl::SharedUNOComponent< ::com::sun::star::embed::XStorage > SharedStorage; - -class ODatabaseContext; -class DocumentStorageAccess; -class OSharedConnectionManager; -class ODatabaseModelImpl :public SharedMutexHolder - ,public ::rtl::IReference - ,public ::sfx2::IMacroDocumentAccess - ,public ::sfx2::IModifiableDocument -{ -public: - enum ObjectType - { - E_FORM = 0, - E_REPORT = 1, - E_QUERY = 2, - E_TABLE = 3 - }; - -private: - OModuleClient m_aModuleClient; - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel; - ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDataSource > m_xDataSource; - - DocumentStorageAccess* m_pStorageAccess; - VosMutexFacade m_aMutexFacade; - ::std::vector< TContentPtr > m_aContainer; // one for each ObjectType - TStorages m_aStorages; - ::sfx2::DocumentMacroMode m_aMacroMode; - sal_Int16 m_nImposedMacroExecMode; - - ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > m_xBasicLibraries; - ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > m_xDialogLibraries; - - SharedStorage m_xDocumentStorage; - ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListener; - ODatabaseContext* m_pDBContext; - - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArgs; - /// the URL the document was loaded from - ::rtl::OUString m_sDocFileLocation; - - oslInterlockedCount m_refCount; - - /// do we have any object (forms/reports) which contains macros? - bool m_bHasAnyObjectWithMacros; - /// does our root storage have macro/script sub storages? - bool m_bHasMacroStorages; - - /// true if setting the Modified flag of the document is currently locked - bool m_bModificationLock; - - /// true if and only if a database document existed previously (though meanwhile disposed), and was already initialized - bool m_bDocumentInitialized; - - /** the URL which the document should report as it's URL - - This might differ from ->m_sDocFileLocation in case the document was loaded - as part of a crash recovery process. In this case, ->m_sDocFileLocation points to - the temporary file where the DB had been saved to, after a crash. - ->m_sDocumentURL then is the URL of the document which actually had - been recovered. - */ - ::rtl::OUString m_sDocumentURL; - -public: - OWeakConnectionArray m_aConnections; - const ::comphelper::ComponentContext m_aContext; - -public: - ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xCommandDefinitions; - ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xTableDefinitions; - - ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > - m_xNumberFormatsSupplier; - ::rtl::OUString m_sConnectURL; - ::rtl::OUString m_sName; // transient, our creator has to tell us the title - ::rtl::OUString m_sUser; - ::rtl::OUString m_aPassword; // transient ! - ::rtl::OUString m_sFailedPassword; - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> - m_aLayoutInformation; - sal_Int32 m_nLoginTimeout; - sal_Bool m_bReadOnly : 1; - sal_Bool m_bPasswordRequired : 1; - sal_Bool m_bSuppressVersionColumns : 1; - sal_Bool m_bModified : 1; - sal_Bool m_bDocumentReadOnly : 1; - sal_Bool m_bDisposingSubStorages; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyAccess > - m_xSettings; - ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableFilter; - ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableTypeFilter; - OSharedConnectionManager* m_pSharedConnectionManager; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > - m_xSharedConnectionManager; - sal_uInt16 m_nControllerLockCount; - - void reset(); - - /** determines whether the database document has an embedded data storage - */ - inline bool isEmbeddedDatabase() const { return ( m_sConnectURL.compareToAscii( "sdbc:embedded:", 14 ) == 0 ); } - - /** stores the embedded storage ("database") - - @param _bPreventRootCommits - Normally, committing the embedded storage results in also commiting the root storage - - this is an automatism for data safety reasons. - If you pass <TRUE/> here, committing the root storage is prevented for this particular - call. - @return <TRUE/> if the storage could be commited, otherwise <FALSE/> - */ - sal_Bool commitEmbeddedStorage( sal_Bool _bPreventRootCommits = sal_False ); - - /** commits all storages storages which have been obtained via getStorage - */ - void commitStorages() - SAL_THROW(( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException )); - - ODatabaseModelImpl( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, - ODatabaseContext& _pDBContext - ); - virtual ~ODatabaseModelImpl(); - - ODatabaseModelImpl( - const ::rtl::OUString& _rRegistrationName, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, - ODatabaseContext& _rDBContext - ); - - // XEventListener - void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); - - void setModified( sal_Bool bModified ); - - void dispose(); - - inline ::rtl::OUString getURL() const { return m_sDocumentURL; } - inline ::rtl::OUString getDocFileLocation() const { return m_sDocFileLocation; } - - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> getStorage(const ::rtl::OUString& _sStorageName,sal_Int32 nMode = ::com::sun::star::embed::ElementModes::READWRITE); -// helper - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& - getNumberFormatsSupplier(); - - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& - getResource() const { return m_aArgs; } - - void attachResource( - const ::rtl::OUString& _rURL, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ); - - static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments ); - -// other stuff - void flushTables(); - - // disposes all elements in m_aStorages, and clears it - void disposeStorages() SAL_THROW(()); - - /// creates a ->com::sun::star::embed::StorageFactory - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > - createStorageFactory() const; - - /// commits our storage - void commitRootStorage(); - - /// commits a given storage if it's not readonly - static bool commitStorageIfWriteable( - const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage - ) - SAL_THROW(( - ::com::sun::star::io::IOException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException - )); - - /// commits a given storage if it's not readonly, ignoring (but asserting) all errors - static bool commitStorageIfWriteable_ignoreErrors( - const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage - ) - SAL_THROW(()); - - void clearConnections(); - - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getOrCreateRootStorage(); - inline ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getRootStorage() const { return m_xDocumentStorage.getTyped(); } - inline void resetRootStroage() { impl_switchToStorage_throw( NULL ); } - - /** returns the data source. If it doesn't exist it will be created - */ - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getOrCreateDataSource(); - - /** returns the model, if there already exists one - */ - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getModel_noCreate() const; - - /** returns a new ->ODatabaseDocument - - @param _bInitializeIfNecessary - calls XLoadable::initNew on the newly created model, if necessary - - @precond - No ->ODatabaseDocument exists so far - - @seealso - getModel_noCreate - */ - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > createNewModel_deliverOwnership( bool _bInitialize ); - - struct ResetModelAccess { friend class ODatabaseDocument; private: ResetModelAccess() { } }; - - /** resets the model to NULL - - Only to be called when the model is being disposed - */ - void modelIsDisposing( const bool _wasInitialized, ResetModelAccess ); - - bool hadInitializedDocument() const { return m_bDocumentInitialized; } - - DocumentStorageAccess* - getDocumentStorageAccess(); - - ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentSubStorageSupplier > - getDocumentSubStorageSupplier(); - - inline ::rtl::Reference< SharedMutex > getSharedMutex() const { return m_xMutex; } - - /** @see osl_incrementInterlockedCount. - */ - virtual oslInterlockedCount SAL_CALL acquire(); - - /** @see osl_decrementInterlockedCount. - */ - virtual oslInterlockedCount SAL_CALL release(); - - /// returns a all known data source settings, including their default values - static const AsciiPropertyValue* getDefaultDataSourceSettings(); - - /** retrieves the requested container of objects (forms/reports/tables/queries) - */ - TContentPtr& getObjectContainer( const ObjectType _eType ); - - /** determines whether the given storage is the storage of our embedded database (named "database"), if any - */ - bool isDatabaseStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage ) const; - - /** returns the name of the storage which is used to stored objects of the given type, if applicable - */ - static ::rtl::OUString - getObjectContainerStorageName( const ObjectType _eType ); - - /** revokes the data source registration at the database context - */ - void revokeDataSource() const; - - /** determines whether a given object storage contains macros - */ - static bool objectHasMacros( - const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxContainerStorage, - const ::rtl::OUString& _rPersistentName - ); - - /** determines whether the database document has any object (form/report) which contains macros - - In such a case, *all* objects in the document keep the macro capability, and the database document - itself does *not* allow embedding macros. - */ - bool hasAnyObjectWithMacros() const { return m_bHasAnyObjectWithMacros; } - - /** determines whether the document storage has sub storages used to store macros/scripts - - Though the current version does not allow creating such documents, later versions will, so - we need to be prepared when we encounter them. - */ - bool hasMacroStorages() const { return m_bHasMacroStorages; } - - /** checks our document's macro execution mode, using the interaction handler as supplied with our - load arguments - */ - bool checkMacrosOnLoading(); - - /** adjusts our document's macro execution mode, without using any UI, assuming the user - would reject execution of macros, if she would have been asked. - - If checkMacrosOnLoading has been called before (and thus the macro execution mode - is already adjusted), then the current execution mode is simply returned. - - @return - whether or not macro execution is allowed - */ - bool adjustMacroMode_AutoReject(); - - /** resets our macro execute mode, so next time the checkMacrosOnLoading is called, it will - behave as if it has never been called before - */ - void resetMacroExecutionMode(); - - /** ensures that ->m_xBasicLibraries resp. m_xDialogLibraries exists - - @return - the requested library container. Is never <NULL/>. - - @throws RuntimeException - if something does wrong, which indicates a server error in the installation - */ - ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > - getLibraryContainer( bool _bScript ); - - /** lets our library containers store themself into the given root storage - */ - void storeLibraryContainersTo( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxToRootStorage ); - - /** rebases the document to the given storage - - No actual committing, copying, saving, whatsoever happens. The storage is just remembered as the documents - new storage, nothing more. - - @throws ::com::sun::star::lang::IllegalArgumentException - if the given storage is <NULL/> - @throws ::com::sun::star::lang::RuntimeException - if any of the invoked operations does so - */ - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > - switchToStorage( - const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage - ); - - /** switches to the given document location/URL - - The document location is the URL of the file from which the document has been loaded. - The document URL is the "intended location" of the document. It differs from the location - if and only if the document was loaded as part of a document recovery process. In this case, - the location points to some temporary file, but the URL is the URL of the file which has been - just recovered. The next store operation would operate on the URL, not the location. - */ - void switchToURL( - const ::rtl::OUString& _rDocumentLocation, - const ::rtl::OUString& _rDocumentURL - ); - - /** returns the macro mode imposed by an external instance, which passed it to attachResource - */ - sal_Int16 getImposedMacroExecMode() const - { - return m_nImposedMacroExecMode; - } - void setImposedMacroExecMode( const sal_Int16 _nMacroMode ) - { - m_nImposedMacroExecMode = _nMacroMode; - } - -public: - // IMacroDocumentAccess overridables - virtual sal_Int16 getCurrentMacroExecMode() const; - virtual sal_Bool setCurrentMacroExecMode( sal_uInt16 ); - virtual ::rtl::OUString getDocumentLocation() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getLastCommitDocumentStorage(); - virtual sal_Bool documentStorageHasMacros() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const; - virtual sal_Int16 getScriptingSignatureState() const; - virtual void showBrokenSignatureWarning( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxInteraction ) const; - - // IModifiableDocument - virtual void storageIsModified(); - - // don't use directly, use the ModifyLock class instead - void lockModify() { m_bModificationLock = true; } - void unlockModify() { m_bModificationLock = false; } - bool isModifyLocked() const { return m_bModificationLock; } - -private: - void impl_construct_nothrow(); - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > - impl_switchToStorage_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage ); -}; - -/** a small base class for UNO components whose functionality depends on a ODatabaseModelImpl -*/ -class ModelDependentComponent -{ -protected: - ::rtl::Reference< ODatabaseModelImpl > m_pImpl; - ::rtl::Reference< SharedMutex > m_xMutex; - -protected: - ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model ); - virtual ~ModelDependentComponent(); - - /** returns the component itself - */ - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const = 0; - - inline ::osl::Mutex& getMutex() const - { - return m_xMutex->getMutex(); - } - -public: - struct GuardAccess { friend class ModelMethodGuard; private: GuardAccess() { } }; - - /** returns the mutex used for thread safety - - @throws ::com::sun::star::lang::DisposedException - if m_pImpl is <NULL/>. Usually, you will set this member in your derived - component's <code>dispose</code> method to <NULL/>. - */ - inline ::osl::Mutex& getMutex( GuardAccess ) const - { - return getMutex(); - } - inline ::rtl::Reference< ODatabaseModelImpl > getImpl( GuardAccess ) - { - return m_pImpl; - } - - /// checks whether the component is already disposed, throws a DisposedException if so - inline void checkDisposed() const - { - if ( !m_pImpl.is() ) - throw ::com::sun::star::lang::DisposedException( ::rtl::OUString::createFromAscii( "Component is already disposed." ), getThis() ); - } - - inline void lockModify() - { - m_pImpl->lockModify(); - } - - inline void unlockModify() - { - m_pImpl->unlockModify(); - } -}; - -class ModifyLock -{ -public: - ModifyLock( ModelDependentComponent& _component ) - :m_rComponent( _component ) - { - m_rComponent.lockModify(); - } - - ~ModifyLock() - { - m_rComponent.unlockModify(); - } - -private: - ModelDependentComponent& m_rComponent; -}; - -/** a guard for public methods of objects dependent on a ODatabaseModelImpl instance - - Just put this guard onto the stack at the beginning of your method. Don't bother yourself - with a MutexGuard, checks for being disposed, and the like. -*/ -class ModelMethodGuard : public ::osl::ResettableMutexGuard -{ -private: - typedef ::osl::ResettableMutexGuard BaseMutexGuard; - -public: - /** constructs the guard - - @param _component - the component whose functionality depends on a ODatabaseModelImpl instance - - @throws ::com::sun::star::lang::DisposedException - If the given component is already disposed - */ - ModelMethodGuard( const ModelDependentComponent& _component ) - :BaseMutexGuard( _component.getMutex( ModelDependentComponent::GuardAccess() ) ) - { - _component.checkDisposed(); - } - - ~ModelMethodGuard() - { - } -}; - -//........................................................................ -} // namespace dbaccess -//........................................................................ - -#endif // _DBA_COREDATAACCESS_DATALINK_HXX_ - +/*************************************************************************
+ *
+ * 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: ModelImpl.hxx,v $
+ * $Revision: 1.24.26.1 $
+ *
+ * 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 _DBA_COREDATAACCESS_MODELIMPL_HXX_
+#define _DBA_COREDATAACCESS_MODELIMPL_HXX_
+
+#include "apitools.hxx"
+#include "bookmarkcontainer.hxx"
+#include "ContentHelper.hxx"
+#include "core_resource.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/document/XStorageBasedDocument.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XTransactionListener.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/lang/NotInitializedException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/XIsolatedConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/XFlushable.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/frame/DoubleInitializationException.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/sharedmutex.hxx>
+#include <connectivity/CommonTools.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <sfx2/docmacromode.hxx>
+#include <sfx2/docstoragemodifylistener.hxx>
+#include <tools/string.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <vos/mutex.hxx>
+
+#include <memory>
+
+namespace comphelper
+{
+ class NamedValueCollection;
+}
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > OWeakConnection;
+typedef std::vector< OWeakConnection > OWeakConnectionArray;
+
+struct AsciiPropertyValue
+{
+ // note: the canonic member order would be AsciiName / DefaultValue, but
+ // this crashes on unxlngi6.pro, since there's a bug which somehow results in
+ // getDefaultDataSourceSettings returning corrupted Any instances then.
+ ::com::sun::star::uno::Any DefaultValue;
+ const sal_Char* AsciiName;
+
+ AsciiPropertyValue( const sal_Char* _pAsciiName, const ::com::sun::star::uno::Any& _rDefaultValue )
+ :DefaultValue( _rDefaultValue )
+ ,AsciiName( _pAsciiName )
+ {
+ }
+};
+
+class ODatabaseContext;
+class OSharedConnectionManager;
+
+//============================================================
+//= VosMutexFacade
+//============================================================
+/** a class which provides an IMutex interface to an OSL-based mutex
+*/
+class VosMutexFacade : public ::vos::IMutex
+{
+public:
+ /** beware of life time: the mutex you pass here must live as least as long
+ as the VosMutexFacade instance lives.
+ */
+ VosMutexFacade( ::osl::Mutex& _rMutex );
+
+ // IMutex
+ virtual void SAL_CALL acquire();
+ virtual sal_Bool SAL_CALL tryToAcquire();
+ virtual void SAL_CALL release();
+
+private:
+ ::osl::Mutex& m_rMutex;
+};
+
+
+//============================================================
+//= ODatabaseModelImpl
+//============================================================
+DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >,TStorages);
+
+typedef ::utl::SharedUNOComponent< ::com::sun::star::embed::XStorage > SharedStorage;
+
+class ODatabaseContext;
+class DocumentStorageAccess;
+class OSharedConnectionManager;
+class ODatabaseModelImpl :public ::rtl::IReference
+ ,public ::sfx2::IMacroDocumentAccess
+ ,public ::sfx2::IModifiableDocument
+{
+public:
+ enum ObjectType
+ {
+ E_FORM = 0,
+ E_REPORT = 1,
+ E_QUERY = 2,
+ E_TABLE = 3
+ };
+
+private:
+ OModuleClient m_aModuleClient;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDataSource > m_xDataSource;
+
+ DocumentStorageAccess* m_pStorageAccess;
+ ::comphelper::SharedMutex m_aMutex;
+ VosMutexFacade m_aMutexFacade;
+ ::std::vector< TContentPtr > m_aContainer; // one for each ObjectType
+ TStorages m_aStorages;
+ ::sfx2::DocumentMacroMode m_aMacroMode;
+ sal_Int16 m_nImposedMacroExecMode;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > m_xBasicLibraries;
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer > m_xDialogLibraries;
+
+ SharedStorage m_xDocumentStorage;
+ ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListener;
+ ODatabaseContext* m_pDBContext;
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArgs;
+ /// the URL the document was loaded from
+ ::rtl::OUString m_sDocFileLocation;
+
+ oslInterlockedCount m_refCount;
+
+ /// do we have any object (forms/reports) which contains macros?
+ bool m_bHasAnyObjectWithMacros;
+ /// does our root storage have macro/script sub storages?
+ bool m_bHasMacroStorages;
+
+ /// true if setting the Modified flag of the document is currently locked
+ bool m_bModificationLock;
+
+ /// true if and only if a database document existed previously (though meanwhile disposed), and was already initialized
+ bool m_bDocumentInitialized;
+
+ /** the URL which the document should report as it's URL
+
+ This might differ from ->m_sDocFileLocation in case the document was loaded
+ as part of a crash recovery process. In this case, ->m_sDocFileLocation points to
+ the temporary file where the DB had been saved to, after a crash.
+ ->m_sDocumentURL then is the URL of the document which actually had
+ been recovered.
+ */
+ ::rtl::OUString m_sDocumentURL;
+
+public:
+ OWeakConnectionArray m_aConnections;
+ const ::comphelper::ComponentContext m_aContext;
+
+public:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xCommandDefinitions;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XNameAccess > m_xTableDefinitions;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
+ m_xNumberFormatsSupplier;
+ ::rtl::OUString m_sConnectURL;
+ ::rtl::OUString m_sName; // transient, our creator has to tell us the title
+ ::rtl::OUString m_sUser;
+ ::rtl::OUString m_aPassword; // transient !
+ ::rtl::OUString m_sFailedPassword;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>
+ m_aLayoutInformation;
+ sal_Int32 m_nLoginTimeout;
+ sal_Bool m_bReadOnly : 1;
+ sal_Bool m_bPasswordRequired : 1;
+ sal_Bool m_bSuppressVersionColumns : 1;
+ sal_Bool m_bModified : 1;
+ sal_Bool m_bDocumentReadOnly : 1;
+ sal_Bool m_bDisposingSubStorages;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyAccess >
+ m_xSettings;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableFilter;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aTableTypeFilter;
+ OSharedConnectionManager* m_pSharedConnectionManager;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >
+ m_xSharedConnectionManager;
+ sal_uInt16 m_nControllerLockCount;
+
+ void reset();
+
+ /** determines whether the database document has an embedded data storage
+ */
+ inline bool isEmbeddedDatabase() const { return ( m_sConnectURL.compareToAscii( "sdbc:embedded:", 14 ) == 0 ); }
+
+ /** stores the embedded storage ("database")
+
+ @param _bPreventRootCommits
+ Normally, committing the embedded storage results in also commiting the root storage
+ - this is an automatism for data safety reasons.
+ If you pass <TRUE/> here, committing the root storage is prevented for this particular
+ call.
+ @return <TRUE/> if the storage could be commited, otherwise <FALSE/>
+ */
+ sal_Bool commitEmbeddedStorage( sal_Bool _bPreventRootCommits = sal_False );
+
+ /** commits all storages storages which have been obtained via getStorage
+ */
+ void commitStorages()
+ SAL_THROW(( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException ));
+
+ ODatabaseModelImpl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,
+ ODatabaseContext& _pDBContext
+ );
+ virtual ~ODatabaseModelImpl();
+
+ ODatabaseModelImpl(
+ const ::rtl::OUString& _rRegistrationName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,
+ ODatabaseContext& _rDBContext
+ );
+
+ // XEventListener
+ void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ void setModified( sal_Bool bModified );
+
+ void dispose();
+
+ inline ::rtl::OUString getURL() const { return m_sDocumentURL; }
+ inline ::rtl::OUString getDocFileLocation() const { return m_sDocFileLocation; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> getStorage(const ::rtl::OUString& _sStorageName,sal_Int32 nMode = ::com::sun::star::embed::ElementModes::READWRITE);
+// helper
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >&
+ getNumberFormatsSupplier();
+
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
+ getResource() const { return m_aArgs; }
+
+ void attachResource(
+ const ::rtl::OUString& _rURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs );
+
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments );
+
+// other stuff
+ void flushTables();
+
+ // disposes all elements in m_aStorages, and clears it
+ void disposeStorages() SAL_THROW(());
+
+ /// creates a ->com::sun::star::embed::StorageFactory
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
+ createStorageFactory() const;
+
+ /// commits our storage
+ void commitRootStorage();
+
+ /// commits a given storage if it's not readonly
+ static bool commitStorageIfWriteable(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage
+ )
+ SAL_THROW((
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException
+ ));
+
+ /// commits a given storage if it's not readonly, ignoring (but asserting) all errors
+ static bool commitStorageIfWriteable_ignoreErrors(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage
+ )
+ SAL_THROW(());
+
+ void clearConnections();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getOrCreateRootStorage();
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getRootStorage() const { return m_xDocumentStorage.getTyped(); }
+ inline void resetRootStroage() { impl_switchToStorage_throw( NULL ); }
+
+ /** returns the data source. If it doesn't exist it will be created
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getOrCreateDataSource();
+
+ /** returns the model, if there already exists one
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getModel_noCreate() const;
+
+ /** returns a new ->ODatabaseDocument
+
+ @param _bInitializeIfNecessary
+ calls XLoadable::initNew on the newly created model, if necessary
+
+ @precond
+ No ->ODatabaseDocument exists so far
+
+ @seealso
+ getModel_noCreate
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > createNewModel_deliverOwnership( bool _bInitialize );
+
+ struct ResetModelAccess { friend class ODatabaseDocument; private: ResetModelAccess() { } };
+
+ /** resets the model to NULL
+
+ Only to be called when the model is being disposed
+ */
+ void modelIsDisposing( const bool _wasInitialized, ResetModelAccess );
+
+ bool hadInitializedDocument() const { return m_bDocumentInitialized; }
+
+ DocumentStorageAccess*
+ getDocumentStorageAccess();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentSubStorageSupplier >
+ getDocumentSubStorageSupplier();
+
+ inline const ::comphelper::SharedMutex& getSharedMutex() const { return m_aMutex; }
+
+ /** @see osl_incrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL acquire();
+
+ /** @see osl_decrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL release();
+
+ /// returns a all known data source settings, including their default values
+ static const AsciiPropertyValue* getDefaultDataSourceSettings();
+
+ /** retrieves the requested container of objects (forms/reports/tables/queries)
+ */
+ TContentPtr& getObjectContainer( const ObjectType _eType );
+
+ /** determines whether the given storage is the storage of our embedded database (named "database"), if any
+ */
+ bool isDatabaseStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage ) const;
+
+ /** returns the name of the storage which is used to stored objects of the given type, if applicable
+ */
+ static ::rtl::OUString
+ getObjectContainerStorageName( const ObjectType _eType );
+
+ /** revokes the data source registration at the database context
+ */
+ void revokeDataSource() const;
+
+ /** determines whether a given object storage contains macros
+ */
+ static bool objectHasMacros(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxContainerStorage,
+ const ::rtl::OUString& _rPersistentName
+ );
+
+ /** determines whether the database document has any object (form/report) which contains macros
+
+ In such a case, *all* objects in the document keep the macro capability, and the database document
+ itself does *not* allow embedding macros.
+ */
+ bool hasAnyObjectWithMacros() const { return m_bHasAnyObjectWithMacros; }
+
+ /** determines whether the document storage has sub storages used to store macros/scripts
+
+ Though the current version does not allow creating such documents, later versions will, so
+ we need to be prepared when we encounter them.
+ */
+ bool hasMacroStorages() const { return m_bHasMacroStorages; }
+
+ /** checks our document's macro execution mode, using the interaction handler as supplied with our
+ load arguments
+ */
+ bool checkMacrosOnLoading();
+
+ /** adjusts our document's macro execution mode, without using any UI, assuming the user
+ would reject execution of macros, if she would have been asked.
+
+ If checkMacrosOnLoading has been called before (and thus the macro execution mode
+ is already adjusted), then the current execution mode is simply returned.
+
+ @return
+ whether or not macro execution is allowed
+ */
+ bool adjustMacroMode_AutoReject();
+
+ /** resets our macro execute mode, so next time the checkMacrosOnLoading is called, it will
+ behave as if it has never been called before
+ */
+ void resetMacroExecutionMode();
+
+ /** ensures that ->m_xBasicLibraries resp. m_xDialogLibraries exists
+
+ @return
+ the requested library container. Is never <NULL/>.
+
+ @throws RuntimeException
+ if something does wrong, which indicates a server error in the installation
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XStorageBasedLibraryContainer >
+ getLibraryContainer( bool _bScript );
+
+ /** lets our library containers store themself into the given root storage
+ */
+ void storeLibraryContainersTo( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxToRootStorage );
+
+ /** rebases the document to the given storage
+
+ No actual committing, copying, saving, whatsoever happens. The storage is just remembered as the documents
+ new storage, nothing more.
+
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if the given storage is <NULL/>
+ @throws ::com::sun::star::lang::RuntimeException
+ if any of the invoked operations does so
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ switchToStorage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage
+ );
+
+ /** switches to the given document location/URL
+
+ The document location is the URL of the file from which the document has been loaded.
+ The document URL is the "intended location" of the document. It differs from the location
+ if and only if the document was loaded as part of a document recovery process. In this case,
+ the location points to some temporary file, but the URL is the URL of the file which has been
+ just recovered. The next store operation would operate on the URL, not the location.
+ */
+ void switchToURL(
+ const ::rtl::OUString& _rDocumentLocation,
+ const ::rtl::OUString& _rDocumentURL
+ );
+
+ /** returns the macro mode imposed by an external instance, which passed it to attachResource
+ */
+ sal_Int16 getImposedMacroExecMode() const
+ {
+ return m_nImposedMacroExecMode;
+ }
+ void setImposedMacroExecMode( const sal_Int16 _nMacroMode )
+ {
+ m_nImposedMacroExecMode = _nMacroMode;
+ }
+
+public:
+ // IMacroDocumentAccess overridables
+ virtual sal_Int16 getCurrentMacroExecMode() const;
+ virtual sal_Bool setCurrentMacroExecMode( sal_uInt16 );
+ virtual ::rtl::OUString getDocumentLocation() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getLastCommitDocumentStorage();
+ virtual sal_Bool documentStorageHasMacros() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const;
+ virtual sal_Int16 getScriptingSignatureState() const;
+ virtual void showBrokenSignatureWarning( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxInteraction ) const;
+
+ // IModifiableDocument
+ virtual void storageIsModified();
+
+ // don't use directly, use the ModifyLock class instead
+ void lockModify() { m_bModificationLock = true; }
+ void unlockModify() { m_bModificationLock = false; }
+ bool isModifyLocked() const { return m_bModificationLock; }
+
+private:
+ void impl_construct_nothrow();
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ impl_switchToStorage_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxNewRootStorage );
+};
+
+/** a small base class for UNO components whose functionality depends on a ODatabaseModelImpl
+*/
+class ModelDependentComponent
+{
+protected:
+ ::rtl::Reference< ODatabaseModelImpl > m_pImpl;
+ mutable ::comphelper::SharedMutex m_aMutex;
+
+protected:
+ ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model );
+ virtual ~ModelDependentComponent();
+
+ /** returns the component itself
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const = 0;
+
+ inline ::osl::Mutex& getMutex() const
+ {
+ return m_aMutex;
+ }
+
+public:
+ struct GuardAccess { friend class ModelMethodGuard; private: GuardAccess() { } };
+
+ /** returns the mutex used for thread safety
+
+ @throws ::com::sun::star::lang::DisposedException
+ if m_pImpl is <NULL/>. Usually, you will set this member in your derived
+ component's <code>dispose</code> method to <NULL/>.
+ */
+ inline ::osl::Mutex& getMutex( GuardAccess ) const
+ {
+ return getMutex();
+ }
+ inline ::rtl::Reference< ODatabaseModelImpl > getImpl( GuardAccess )
+ {
+ return m_pImpl;
+ }
+
+ /// checks whether the component is already disposed, throws a DisposedException if so
+ inline void checkDisposed() const
+ {
+ if ( !m_pImpl.is() )
+ throw ::com::sun::star::lang::DisposedException( ::rtl::OUString::createFromAscii( "Component is already disposed." ), getThis() );
+ }
+
+ inline void lockModify()
+ {
+ m_pImpl->lockModify();
+ }
+
+ inline void unlockModify()
+ {
+ m_pImpl->unlockModify();
+ }
+};
+
+class ModifyLock
+{
+public:
+ ModifyLock( ModelDependentComponent& _component )
+ :m_rComponent( _component )
+ {
+ m_rComponent.lockModify();
+ }
+
+ ~ModifyLock()
+ {
+ m_rComponent.unlockModify();
+ }
+
+private:
+ ModelDependentComponent& m_rComponent;
+};
+
+/** a guard for public methods of objects dependent on a ODatabaseModelImpl instance
+
+ Just put this guard onto the stack at the beginning of your method. Don't bother yourself
+ with a MutexGuard, checks for being disposed, and the like.
+*/
+class ModelMethodGuard : public ::osl::ResettableMutexGuard
+{
+private:
+ typedef ::osl::ResettableMutexGuard BaseMutexGuard;
+
+public:
+ /** constructs the guard
+
+ @param _component
+ the component whose functionality depends on a ODatabaseModelImpl instance
+
+ @throws ::com::sun::star::lang::DisposedException
+ If the given component is already disposed
+ */
+ ModelMethodGuard( const ModelDependentComponent& _component )
+ :BaseMutexGuard( _component.getMutex( ModelDependentComponent::GuardAccess() ) )
+ {
+ _component.checkDisposed();
+ }
+
+ ~ModelMethodGuard()
+ {
+ }
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBA_COREDATAACCESS_DATALINK_HXX_
+
diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 0c333cf0b7be..0d5bcb3e7081 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -339,7 +339,7 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const ::rtl::OUStrin Reference< XLoadable > xLoad( xModel, UNO_QUERY_THROW ); ::comphelper::NamedValueCollection aArgs; - aArgs.put( "FileName", _sURL ); + aArgs.put( "URL", _sURL ); aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); aArgs.put( "InteractionHandler", m_aContext.createComponent( "com.sun.star.sdb.InteractionHandler" ) ); diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index e12e3e4cb764..37d80067a573 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -40,11 +40,16 @@ #include "databasecontext.hxx" #include "documentcontainer.hxx" +#include <comphelper/documentconstants.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/enumhelper.hxx> +#include <comphelper/numberedcollection.hxx> #include <comphelper/genericpropertyset.hxx> #include <comphelper/property.hxx> - #include <svtools/saveopt.hxx> +#include <framework/titlehelper.hxx> + /** === begin UNO includes === **/ #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XFilter.hpp> @@ -378,12 +383,12 @@ void ODatabaseDocument::impl_import_throw( const ::comphelper::NamedValueCollect /** property map for import info set */ comphelper::PropertyMapEntry aExportInfoMap[] = - { + { { MAP_LEN( "BaseURI"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "StreamName"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 }, - { NULL, 0, 0, NULL, 0, 0 } - }; - uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); + { NULL, 0, 0, NULL, 0, 0 } + }; + uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseURI")), uno::makeAny(_rResource.getOrDefault("URL",::rtl::OUString()))); xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StreamName")), uno::makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("content.xml")))); @@ -392,8 +397,8 @@ void ODatabaseDocument::impl_import_throw( const ::comphelper::NamedValueCollect aFilterArgs[nCount] <<= xInfoSet; Reference< XImporter > xImporter( - m_pImpl->m_aContext.createComponentWithArguments( "com.sun.star.comp.sdb.DBFilter", aFilterArgs ), - UNO_QUERY_THROW ); + m_pImpl->m_aContext.createComponentWithArguments( "com.sun.star.comp.sdb.DBFilter", aFilterArgs ), + UNO_QUERY_THROW ); Reference< XComponent > xComponent( *this, UNO_QUERY_THROW ); xImporter->setTargetDocument( xComponent ); @@ -446,6 +451,14 @@ void SAL_CALL ODatabaseDocument::load( const Sequence< PropertyValue >& _Argumen impl_reset_nothrow(); ::comphelper::NamedValueCollection aResource( _Arguments ); + if ( aResource.has( "FileName" ) && !aResource.has( "URL" ) ) + // FileName is the compatibility name for URL, so we might have clients passing + // a FileName only. However, some of our code works with the URL only, so ensure + // we have one. + aResource.put( "URL", aResource.get( "FileName" ) ); + if ( aResource.has( "URL" ) && !aResource.has( "FileName" ) ) + // similar ... just in case there is legacy code which expects a FileName only + aResource.put( "FileName", aResource.get( "URL" ) ); // now that somebody (perhaps) told us an macro execution mode, remember it as // ImposedMacroExecMode @@ -1146,13 +1159,13 @@ void SAL_CALL ODatabaseDocument::close( sal_Bool _bDeliverOwnership ) throw (Clo } catch ( const Exception& ) { - ::osl::MutexGuard aGuard( m_xMutex->getMutex() ); + ::osl::MutexGuard aGuard( m_aMutex ); m_bClosing = false; throw; } // SYNCHRONIZED -> - ::osl::MutexGuard aGuard( m_xMutex->getMutex() ); + ::osl::MutexGuard aGuard( m_aMutex ); m_bClosing = false; // <- SYNCHRONIZED } @@ -1261,14 +1274,18 @@ void ODatabaseDocument::writeStorage( const Reference< XStorage >& _rxTargetStor /** property map for export info set */ comphelper::PropertyMapEntry aExportInfoMap[] = { - { MAP_LEN( "UsePrettyPrinting" ), 0, &::getCppuType((sal_Bool*)0), beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_LEN( "BaseURI"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "StreamName"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 }, + { MAP_LEN( "UsePrettyPrinting" ), 0, &::getCppuType((sal_Bool*)0), beans::PropertyAttribute::MAYBEVOID, 0}, { NULL, 0, 0, NULL, 0, 0 } }; uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) ); SvtSaveOptions aSaveOpt; xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting")), uno::makeAny(aSaveOpt.IsPrettyPrinting())); + if ( aSaveOpt.IsSaveRelFSys() ) + xInfoSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseURI")), uno::makeAny(_rMediaDescriptor.getOrDefault("URL",::rtl::OUString()))); + sal_Int32 nArgsLen = aDelegatorArguments.getLength(); aDelegatorArguments.realloc(nArgsLen+1); aDelegatorArguments[nArgsLen++] <<= xInfoSet; @@ -1380,7 +1397,7 @@ void ODatabaseDocument::disposing() m_aStorageListeners.disposeAndClear( aDisposeEvent ); // SYNCHRONIZED -> - ::osl::MutexGuard aGuard( m_xMutex->getMutex() ); + ::osl::MutexGuard aGuard( m_aMutex ); DBG_ASSERT( m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" ); // normally, nobody should explicitly dispose, but only XCloseable::close the document. And upon diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 18869c3f9b67..fe2f1d8ecd59 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -586,7 +586,7 @@ void ODatabaseSource::setName( const Reference< XDocumentDataSource >& _rxDocume { ODatabaseSource& rModelImpl = dynamic_cast< ODatabaseSource& >( *_rxDocument.get() ); - ::osl::MutexGuard aGuard( rModelImpl.m_xMutex->getMutex() ); + ::osl::MutexGuard aGuard( rModelImpl.m_aMutex ); if ( rModelImpl.m_pImpl.is() ) rModelImpl.m_pImpl->m_sName = _rNewName; } @@ -1201,7 +1201,7 @@ Reference< XConnection > SAL_CALL ODatabaseSource::connectWithCompletion( const ::rtl::OUString sServerName( m_pImpl->m_sName ); INetURLObject aURLCheck( sServerName ); if ( aURLCheck.GetProtocol() != INET_PROT_NOT_VALID ) - sServerName = aURLCheck.getName(); + sServerName = aURLCheck.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS ); // the request AuthenticationRequest aRequest; diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index 25ddba5e1b68..859855b0bc0c 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -148,7 +148,7 @@ ODocumentContainer::ODocumentContainer(const Reference< XMultiServiceFactory >& , sal_Bool _bFormsContainer ) :ODefinitionContainer(_xORB,_xParentContainer,_pImpl) - ,OPropertyStateContainer(m_aBHelper) + ,OPropertyStateContainer(OContentHelper::rBHelper) ,m_bFormsContainer(_bFormsContainer) { DBG_CTOR(ODocumentContainer, NULL); @@ -162,7 +162,7 @@ ODocumentContainer::ODocumentContainer(const Reference< XMultiServiceFactory >& ODocumentContainer::~ODocumentContainer() { DBG_DTOR(ODocumentContainer, NULL); - if ( !m_aBHelper.bInDispose && !m_aBHelper.bDisposed ) + if ( !OContentHelper::rBHelper.bInDispose && !OContentHelper::rBHelper.bDisposed ) { acquire(); dispose(); diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index f8772375c3cf..db239fd11654 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -545,7 +545,7 @@ ODocumentDefinition::ODocumentDefinition(const Reference< XInterface >& _rxConta ,const Reference<XConnection>& _xConnection ) :OContentHelper(_xORB,_rxContainer,_pImpl) - ,OPropertyStateContainer(m_aBHelper) + ,OPropertyStateContainer(OContentHelper::rBHelper) ,m_pInterceptor(NULL) ,m_bForm(_bForm) ,m_bOpenInDesign(sal_False) @@ -562,7 +562,7 @@ ODocumentDefinition::ODocumentDefinition(const Reference< XInterface >& _rxConta ODocumentDefinition::~ODocumentDefinition() { DBG_DTOR(ODocumentDefinition, NULL); - if ( !m_aBHelper.bInDispose && !m_aBHelper.bDisposed ) + if ( !OContentHelper::rBHelper.bInDispose && !OContentHelper::rBHelper.bDisposed ) { acquire(); dispose(); diff --git a/dbaccess/source/core/dataaccess/documenteventnotifier.cxx b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx index fb998a31716d..98976bb52ebd 100644 --- a/dbaccess/source/core/dataaccess/documenteventnotifier.cxx +++ b/dbaccess/source/core/dataaccess/documenteventnotifier.cxx @@ -167,8 +167,9 @@ namespace dbaccess //-------------------------------------------------------------------- void DocumentEventNotifier_Impl::disposing() { + // SYNCHRONIZED -> // cancel any pending asynchronous events - ::osl::MutexGuard aGuard( m_rMutex ); + ::osl::ResettableMutexGuard aGuard( m_rMutex ); if ( m_pEventBroadcaster.is() ) { m_pEventBroadcaster->removeEventsForProcessor( this ); @@ -177,10 +178,16 @@ namespace dbaccess } lang::EventObject aEvent( m_rDocument ); + aGuard.clear(); + // <-- SYNCHRONIZED + m_aLegacyEventListeners.disposeAndClear( aEvent ); m_aDocumentEventListeners.disposeAndClear( aEvent ); + // SYNCHRONIZED -> + aGuard.reset(); m_bDisposed = true; + // <-- SYNCHRONIZED } //-------------------------------------------------------------------- diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx index 4f18487490ec..697ec70fcdb2 100644 --- a/dbaccess/source/core/inc/ContentHelper.hxx +++ b/dbaccess/source/core/inc/ContentHelper.hxx @@ -132,7 +132,7 @@ namespace dbaccess ::comphelper::UStringHash, ::comphelper::UStringEqual > PropertyChangeListenerContainer; - typedef ::comphelper::OMutexAndBroadcastHelper OContentHelper_MBASE; + typedef ::comphelper::OBaseMutex OContentHelper_MBASE; typedef ::cppu::WeakComponentImplHelper9 < ::com::sun::star::ucb::XContent , ::com::sun::star::ucb::XCommandProcessor , ::com::sun::star::lang::XServiceInfo @@ -166,7 +166,6 @@ namespace dbaccess TContentPtr m_pImpl; sal_uInt32 m_nCommandId; - // helper virtual void SAL_CALL disposing(); diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index b6a9053271c0..94f4f9fd26bc 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -36,11 +36,7 @@ #include <unotools/confignode.hxx> #include <tools/rc.hxx> #include <tools/debug.hxx> -// --- needed because of the solar mutex -#include <vos/mutex.hxx> -#include <vcl/svapp.hxx> #include <osl/file.hxx> -// --- #include "dbastrings.hrc" #include "core_resource.hxx" #include "core_resource.hrc" @@ -127,7 +123,6 @@ ODsnTypeCollection::ODsnTypeCollection() :m_nLivingIterators(0) #endif { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); DBG_CTOR(ODsnTypeCollection,NULL); ODataSourceTypeStringListResource aTypes(RSC_DATASOURCE_TYPES); aTypes.fill(m_aDsnPrefixes); diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index cc661fab1914..1ba0c73bf089 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -103,6 +103,8 @@ #ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ #include <com/sun/star/awt/FontDescriptor.hpp> #endif +#include <svtools/filenotation.hxx> +#include <tools/diagnose_ex.h> namespace dbaxml { @@ -615,7 +617,8 @@ void ODBExport::exportConnectionData() { SvXMLElementExport aDatabaseDescription(*this,XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, sal_True, sal_True); { - AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,m_aTypeCollection.cutPrefix(sValue)); + ::svt::OFileNotation aTransformer( m_aTypeCollection.cutPrefix(sValue) ); + AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,GetRelativeReference(aTransformer.get( ::svt::OFileNotation::N_URL ))); AddAttribute(XML_NAMESPACE_DB,XML_MEDIA_TYPE,m_aTypeCollection.getMediaType(eType)); try { @@ -995,60 +998,68 @@ void ODBExport::exportFilter(XPropertySet* _xProp // ----------------------------------------------------------------------------- void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) { - if ( _xColSup.is() ) + OSL_PRECOND( _xColSup.is(), "ODBExport::exportColumns: invalid columns supplier!" ); + if ( !_xColSup.is() ) + return; + + try { - Reference<XNameAccess> xNameAccess = _xColSup->getColumns(); - if ( xNameAccess.is() && xNameAccess->hasElements() ) + Reference<XNameAccess> xNameAccess( _xColSup->getColumns(), UNO_SET_THROW ); + if ( !xNameAccess->hasElements() ) + return; + + SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, sal_True, sal_True); + Sequence< ::rtl::OUString> aSeq = xNameAccess->getElementNames(); + const ::rtl::OUString* pIter = aSeq.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); + for( ; pIter != pEnd ; ++pIter) { - SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, sal_True, sal_True); - Sequence< ::rtl::OUString> aSeq = xNameAccess->getElementNames(); - const ::rtl::OUString* pIter = aSeq.getConstArray(); - const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); - for( ; pIter != pEnd ; ++pIter) + Reference<XPropertySet> xProp(xNameAccess->getByName(*pIter),UNO_QUERY); + if ( xProp.is() ) { - Reference<XPropertySet> xProp(xNameAccess->getByName(*pIter),UNO_QUERY); - if ( xProp.is() ) - { - SvXMLAttributeList* pAtt = new SvXMLAttributeList; - Reference<XAttributeList> xAtt = pAtt; - exportStyleName(xProp.get(),*pAtt); - - sal_Bool bHidden = getBOOL(xProp->getPropertyValue(PROPERTY_HIDDEN)); + SvXMLAttributeList* pAtt = new SvXMLAttributeList; + Reference<XAttributeList> xAtt = pAtt; + exportStyleName(xProp.get(),*pAtt); - ::rtl::OUString sValue; - xProp->getPropertyValue(PROPERTY_HELPTEXT) >>= sValue; - Any aColumnDefault; - aColumnDefault = xProp->getPropertyValue(PROPERTY_CONTROLDEFAULT); + sal_Bool bHidden = getBOOL(xProp->getPropertyValue(PROPERTY_HIDDEN)); - if ( bHidden || sValue.getLength() || aColumnDefault.hasValue() || pAtt->getLength() ) - { - AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter); - if ( bHidden ) - AddAttribute(XML_NAMESPACE_DB, XML_VISIBLE,XML_FALSE); + ::rtl::OUString sValue; + xProp->getPropertyValue(PROPERTY_HELPTEXT) >>= sValue; + Any aColumnDefault; + aColumnDefault = xProp->getPropertyValue(PROPERTY_CONTROLDEFAULT); - if ( sValue.getLength() ) - AddAttribute(XML_NAMESPACE_DB, XML_HELP_MESSAGE,sValue); - - if ( aColumnDefault.hasValue() ) - { - ::rtl::OUStringBuffer sColumnDefaultString,sType; - SvXMLUnitConverter::convertAny( sColumnDefaultString, sType, aColumnDefault ); - AddAttribute(XML_NAMESPACE_DB, XML_TYPE_NAME,sType.makeStringAndClear()); - AddAttribute(XML_NAMESPACE_DB, XML_DEFAULT_VALUE,sColumnDefaultString.makeStringAndClear()); - } + if ( bHidden || sValue.getLength() || aColumnDefault.hasValue() || pAtt->getLength() ) + { + AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter); + if ( bHidden ) + AddAttribute(XML_NAMESPACE_DB, XML_VISIBLE,XML_FALSE); - if ( pAtt->getLength() ) - AddAttributeList(xAtt); - } + if ( sValue.getLength() ) + AddAttribute(XML_NAMESPACE_DB, XML_HELP_MESSAGE,sValue); - if ( GetAttrList().getLength() ) + if ( aColumnDefault.hasValue() ) { - SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_COLUMN, sal_True, sal_True); + ::rtl::OUStringBuffer sColumnDefaultString,sType; + SvXMLUnitConverter::convertAny( sColumnDefaultString, sType, aColumnDefault ); + AddAttribute(XML_NAMESPACE_DB, XML_TYPE_NAME,sType.makeStringAndClear()); + AddAttribute(XML_NAMESPACE_DB, XML_DEFAULT_VALUE,sColumnDefaultString.makeStringAndClear()); } + + if ( pAtt->getLength() ) + AddAttributeList(xAtt); + } + + if ( GetAttrList().getLength() ) + { + SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_COLUMN, sal_True, sal_True); } } } } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } // ----------------------------------------------------------------------------- void ODBExport::exportForms() @@ -1137,20 +1148,22 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) pExportHelper[i].second.first->insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( pExportHelper[i].second.second, aPropertyStates ))); } - Reference< XNameAccess > xCollection = xSup->getColumns(); + Reference< XNameAccess > xCollection; try { + xCollection.set( xSup->getColumns(), UNO_SET_THROW ); awt::FontDescriptor aFont; _xProp->getPropertyValue(PROPERTY_FONT) >>= aFont; GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,aFont.Family,aFont.Pitch,aFont.CharSet ); + + m_aCurrentPropertyStates = m_xCellExportHelper->Filter(_xProp); + ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportAutoStyle); + exportCollection(xCollection,XML_TOKEN_INVALID,XML_TOKEN_INVALID,sal_False,aMemFunc); } catch(Exception&) { - // not interested in + DBG_UNHANDLED_EXCEPTION(); } - m_aCurrentPropertyStates = m_xCellExportHelper->Filter(_xProp); - ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportAutoStyle); - exportCollection(xCollection,XML_TOKEN_INVALID,XML_TOKEN_INVALID,sal_False,aMemFunc); m_aCurrentPropertyStates.clear(); } else diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 8ab5d173acf0..128ad71ffc21 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -128,6 +128,7 @@ #include <toolkit/helper/vclunohelper.hxx> #endif #include <tools/diagnose_ex.h> +#include <comphelper/namedvaluecollection.hxx> using namespace ::com::sun::star; @@ -182,11 +183,6 @@ sal_Int32 ReadThroughComponent( xImporter->setTargetDocument( xModelComponent ); -#ifdef TIMELOG - // if we do profiling, we want to know the stream - RTL_LOGFILE_TRACE_AUTHOR1( "dbaxml", "oj", - "ReadThroughComponent : parsing \"%s\"", pStreamName ); -#endif // finally, parser the stream try @@ -280,6 +276,12 @@ sal_Int32 ReadThroughComponent( return 1; // TODO/LATER: error handling } +#ifdef TIMELOG + // if we do profiling, we want to know the stream + RTL_LOGFILE_TRACE_AUTHOR1( "dbaxml", "oj", + "ReadThroughComponent : parsing \"%s\"", pStreamName ); +#endif + uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream(); // read from the stream return ReadThroughComponent( xInputStream @@ -355,18 +357,16 @@ sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescripto sal_Bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException) { -::rtl::OUString sFileName; - - const PropertyValue* pIter = rDescriptor.getConstArray(); - const PropertyValue* pEnd = pIter + rDescriptor.getLength(); - for(;pIter != pEnd;++pIter) - { - if( pIter->Name.equalsAscii( "FileName" ) ) - pIter->Value >>= sFileName; - } + ::rtl::OUString sFileName; + ::comphelper::NamedValueCollection aMediaDescriptor( rDescriptor ); + if ( aMediaDescriptor.has( "URL" ) ) + sFileName = aMediaDescriptor.getOrDefault( "URL", ::rtl::OUString() ); + if ( !sFileName.getLength() && aMediaDescriptor.has( "FileName" ) ) + sFileName = aMediaDescriptor.getOrDefault( "FileName", sFileName ); + OSL_ENSURE( sFileName.getLength(), "ODBFilter::implImport: no URL given!" ); + sal_Bool bRet = ( sFileName.getLength() != 0 ); - sal_Bool bRet = (sFileName.getLength() != 0); if ( bRet ) { uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY); 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& ) { diff --git a/reportdesign/images/em42.png b/reportdesign/images/em42.png Binary files differnew file mode 100644 index 000000000000..31f48ea8fb69 --- /dev/null +++ b/reportdesign/images/em42.png diff --git a/reportdesign/images/em42_hc.png b/reportdesign/images/em42_hc.png Binary files differnew file mode 100644 index 000000000000..3870cc4709d4 --- /dev/null +++ b/reportdesign/images/em42_hc.png diff --git a/reportdesign/inc/RptResId.hrc b/reportdesign/inc/RptResId.hrc index f22819d4e9f4..0faa2de30a08 100644 --- a/reportdesign/inc/RptResId.hrc +++ b/reportdesign/inc/RptResId.hrc @@ -227,6 +227,7 @@ #define RID_ERR_NO_COMMAND (RID_STRING_START + 151) #define RID_ERR_NO_OBJECTS (RID_STRING_START + 152) #define RID_STR_AREA (RID_STRING_START + 153) +#define RID_STR_NONE (RID_STRING_START + 154) // #define RID_STR_ (RID_STRING_START + 130) // ----------------------------------------------------------------------- diff --git a/reportdesign/registry/data/org/openoffice/Office/UI/ReportCommands.xcu b/reportdesign/registry/data/org/openoffice/Office/UI/ReportCommands.xcu index bfcce7dc5aba..90bbcb2a5e6e 100644 --- a/reportdesign/registry/data/org/openoffice/Office/UI/ReportCommands.xcu +++ b/reportdesign/registry/data/org/openoffice/Office/UI/ReportCommands.xcu @@ -8,7 +8,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ReportCommands.xcu,v $ - * $Revision: 1.2 $ + * $Revision: 1.2.2.1 $ * * This file is part of OpenOffice.org. * @@ -88,14 +88,12 @@ </node> <node oor:name=".uno:InsertDateTimeField" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="de">~Datum und Zeit...</value> <value xml:lang="en-US">~Date and Time...</value> </prop> </node> <node oor:name=".uno:SelectReport" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="de">~Bericht markieren...</value> - <value xml:lang="en-US">~Select Report...</value> + <value xml:lang="en-US">~Select Report</value> </prop> </node> <node oor:name=".uno:SubReportInNewWindow" oor:op="replace"> @@ -253,7 +251,6 @@ </node> <node oor:name=".uno:SectionAlignBottom" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="de">Unten am Bereich</value> <value xml:lang="en-US">Bottom Align on Section</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> @@ -262,19 +259,27 @@ </node> <node oor:name=".uno:SectionAlignCenter" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="de">Zentriert am Bereich</value> <value xml:lang="en-US">Centered on Section</value> </prop> </node> <node oor:name=".uno:SectionAlignMiddle" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="de">Mittig am Bereich</value> <value xml:lang="en-US">Middle on Section</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> <value>1</value> </prop> </node> + <node oor:name=".uno:SelectAllLabels" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Select all Labels</value> + </prop> + </node> + <node oor:name=".uno:SelectAllEdits" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Select all Formatted Fields</value> + </prop> + </node> </node> <node oor:name="Popups"> <node oor:name=".uno:ExportReportTo" oor:op="replace"> diff --git a/reportdesign/source/core/api/Group.cxx b/reportdesign/source/core/api/Group.cxx index c2939a8ce9f1..ec26696f8ec6 100644 --- a/reportdesign/source/core/api/Group.cxx +++ b/reportdesign/source/core/api/Group.cxx @@ -125,8 +125,10 @@ void SAL_CALL OGroup::dispose() throw(uno::RuntimeException) // void SAL_CALL OGroup::disposing() { - ::comphelper::disposeComponent(m_xHeader); - ::comphelper::disposeComponent(m_xFooter); + m_xHeader.clear(); + m_xFooter.clear(); + //::comphelper::disposeComponent(m_xHeader); + //::comphelper::disposeComponent(m_xFooter); ::comphelper::disposeComponent(m_xFunctions); m_xContext.clear(); } diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 0f7ab046cc41..11142178063e 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -582,7 +582,11 @@ struct OReportDefinitionImpl ,m_bModified(_aCopy.m_bModified) ,m_bEscapeProcessing(_aCopy.m_bEscapeProcessing) {} + ~OReportDefinitionImpl(); }; +OReportDefinitionImpl::~OReportDefinitionImpl() +{ +} DBG_NAME( rpt_OReportDefinition ) // ----------------------------------------------------------------------------- @@ -718,11 +722,16 @@ void SAL_CALL OReportDefinition::disposing() m_pImpl->m_aStorageChangeListeners.disposeAndClear( aDisposeEvent ); ::comphelper::disposeComponent(m_pImpl->m_xGroups); - ::comphelper::disposeComponent(m_pImpl->m_xReportHeader); - ::comphelper::disposeComponent(m_pImpl->m_xReportFooter); - ::comphelper::disposeComponent(m_pImpl->m_xPageHeader); - ::comphelper::disposeComponent(m_pImpl->m_xPageFooter); - ::comphelper::disposeComponent(m_pImpl->m_xDetail); + m_pImpl->m_xReportHeader.clear(); + m_pImpl->m_xReportFooter.clear(); + m_pImpl->m_xPageHeader.clear(); + m_pImpl->m_xPageFooter.clear(); + m_pImpl->m_xDetail.clear(); + //::comphelper::disposeComponent(m_pImpl->m_xReportHeader); + //::comphelper::disposeComponent(m_pImpl->m_xReportFooter); + //::comphelper::disposeComponent(m_pImpl->m_xPageHeader); + //::comphelper::disposeComponent(m_pImpl->m_xPageFooter); + //::comphelper::disposeComponent(m_pImpl->m_xDetail); ::comphelper::disposeComponent(m_pImpl->m_xFunctions); //::comphelper::disposeComponent(m_pImpl->m_xStorage); diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx index 84bfb62480fe..14118e0baaad 100644 --- a/reportdesign/source/core/api/Section.cxx +++ b/reportdesign/source/core/api/Section.cxx @@ -172,6 +172,7 @@ uno::Any SAL_CALL OSection::queryInterface( const uno::Type& _rType ) throw (uno // ----------------------------------------------------------------------------- void SAL_CALL OSection::dispose() throw(uno::RuntimeException) { + OSL_ENSURE(!rBHelper.bDisposed,"Already disposed!"); SectionPropertySet::dispose(); cppu::WeakComponentImplHelperBase::dispose(); diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx index c2b3714526f4..f6cd4ca66ab5 100644 --- a/reportdesign/source/filter/xml/xmlfilter.cxx +++ b/reportdesign/source/filter/xml/xmlfilter.cxx @@ -562,7 +562,10 @@ sal_Bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) static const ::rtl::OUString s_sOld(RTL_CONSTASCII_USTRINGPARAM("OldFormat")); static comphelper::PropertyMapEntry pMap[] = { - {"OldFormat", 9, 1, &::getCppuType((const sal_Bool*)0) ,PropertyAttribute::BOUND,0}, + { MAP_LEN( "OldFormat" ), 1, &::getCppuType((const sal_Bool*)0), beans::PropertyAttribute::BOUND, 0 }, + { MAP_LEN( "StreamName"), 0, &::getCppuType( (::rtl::OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 }, + { MAP_LEN("PrivateData"), 0, &::getCppuType( (uno::Reference<XInterface> *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 }, + { MAP_LEN( "StreamName"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 }, { MAP_LEN( "StreamName"), 0,&::getCppuType( (::rtl::OUString *)0 ),beans::PropertyAttribute::MAYBEVOID, 0 }, { NULL, 0, 0, NULL, 0, 0 } }; diff --git a/reportdesign/source/inc/uistrings.hrc b/reportdesign/source/inc/uistrings.hrc index 6cd0e28323dd..c6e4669f6b74 100644 --- a/reportdesign/source/inc/uistrings.hrc +++ b/reportdesign/source/inc/uistrings.hrc @@ -68,6 +68,11 @@ DECLARE_CONSTASCII_USTRING(PROPERTY_TITLE ); DECLARE_CONSTASCII_USTRING(PROPERTY_AREA ); DECLARE_CONSTASCII_USTRING(PROPERTY_FILLCOLOR ); +DECLARE_CONSTASCII_USTRING(PROPERTY_FILLGRADIENT ); +DECLARE_CONSTASCII_USTRING(PROPERTY_FILLGRADIENTNAME ); +DECLARE_CONSTASCII_USTRING(PROPERTY_FILLHATCHNAME ); +DECLARE_CONSTASCII_USTRING(PROPERTY_FILLBITMAPNAME ); +DECLARE_CONSTASCII_USTRING(PROPERTY_FILLSTYLE ); } #endif // REPORTDESIGN_SHARED_UISTRINGS_HRC diff --git a/reportdesign/source/shared/uistrings.cxx b/reportdesign/source/shared/uistrings.cxx index f8593d6f67fc..2fc710228552 100644 --- a/reportdesign/source/shared/uistrings.cxx +++ b/reportdesign/source/shared/uistrings.cxx @@ -62,5 +62,10 @@ namespace rptui IMPLEMENT_CONSTASCII_USTRING(PROPERTY_AREA , "Area"); IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILLCOLOR , "FillColor"); + IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILLGRADIENT , "FillGradient"); + IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILLGRADIENTNAME , "FillGradientName"); + IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILLHATCHNAME , "FillHatchName"); + IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILLBITMAPNAME , "FillBitmapName"); + IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FILLSTYLE , "FillStyle"); } diff --git a/reportdesign/source/ui/inc/DesignView.hxx b/reportdesign/source/ui/inc/DesignView.hxx index bc072711e45a..47d75744ee1b 100644 --- a/reportdesign/source/ui/inc/DesignView.hxx +++ b/reportdesign/source/ui/inc/DesignView.hxx @@ -34,23 +34,28 @@ #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/report/XSection.hpp> #include <com/sun/star/report/XReportComponent.hpp> -#include <vcl/split.hxx> -#include <vcl/scrbar.hxx> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/datatransfer/DataFlavor.hpp> #include <tools/link.hxx> #include <tools/gen.hxx> + #include <vcl/timer.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/splitwin.hxx> +#include <vcl/split.hxx> +#include <vcl/scrbar.hxx> + #include <svtools/hint.hxx> #include <svtools/brdcst.hxx> -#include <comphelper/stl_types.hxx> -#include "ReportDefines.hxx" #include <svtools/colorcfg.hxx> #include <boost/shared_ptr.hpp> #include <svx/svdedtv.hxx> -#include <vcl/tabpage.hxx> -#include <vcl/splitwin.hxx> -#include <MarkedSection.hxx> +#include <svx/zoomitem.hxx> + +#include <comphelper/stl_types.hxx> + +#include "ReportDefines.hxx" +#include "MarkedSection.hxx" #include "ScrollHelper.hxx" class KeyEvent; @@ -276,12 +281,17 @@ namespace rptui /** zoom the ruler and view windows */ - void zoom(const sal_Int16 _nZoom); + void zoom(const Fraction& _aZoom); /** fills the vector with all selected control models /param _rSelection The vector will be filled and will not be cleared before. */ void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const; + + /** calculates the zoom factor. + @param _eType which kind of zoom is needed + */ + sal_uInt16 getZoomFactor(SvxZoomType _eType) const; }; //================================================================== } //rptui diff --git a/reportdesign/source/ui/inc/ReportController.hxx b/reportdesign/source/ui/inc/ReportController.hxx index 44928a9f01c5..40e45fc67457 100644 --- a/reportdesign/source/ui/inc/ReportController.hxx +++ b/reportdesign/source/ui/inc/ReportController.hxx @@ -53,6 +53,7 @@ #include <svtools/transfer.hxx> #include <svtools/lstner.hxx> #include <svx/svdedtv.hxx> +#include <svx/zoomitem.hxx> #include "ModuleHelper.hxx" #include <comphelper/uno3.hxx> @@ -116,8 +117,8 @@ namespace rptui ::rtl::OUString m_sMode; /// the current mode of the controller sal_Int32 m_nSplitPos; /// the position of the splitter sal_Int32 m_nPageNum; /// the page number from the restoreView call - //sal_Int32 m_nExecuteReportEvent; sal_Int16 m_nZoomValue; + SvxZoomType m_eZoomType; sal_Bool m_bShowRuler; sal_Bool m_bGridVisible; sal_Bool m_bGridUse; @@ -176,6 +177,10 @@ namespace rptui */ void openSortingAndGroupingDialog(); + /** opens the zoom dialog + */ + void openZoomDialog(); + /** returns the position of the group inside the groups collection */ sal_Int32 getGroupPosition(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup); @@ -419,7 +424,8 @@ namespace rptui ::boost::shared_ptr<rptui::OReportModel> getSdrModel(); inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; } - inline sal_Int16 getZoomValue() const { return m_nZoomValue; } + inline sal_Int16 getZoomValue() const { return m_nZoomValue; } + inline void resetZoomType() { m_eZoomType = SVX_ZOOM_PERCENT; } // com::sun::star::beans::XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/reportdesign/source/ui/inc/ReportWindow.hxx b/reportdesign/source/ui/inc/ReportWindow.hxx index ba4e96d6a0c7..0cbe48c38203 100644 --- a/reportdesign/source/ui/inc/ReportWindow.hxx +++ b/reportdesign/source/ui/inc/ReportWindow.hxx @@ -35,6 +35,7 @@ #include "StartMarker.hxx" #include <svtools/ruler.hxx> #include <svx/svdedtv.hxx> +#include <svx/zoomitem.hxx> #include <vector> #include <boost/shared_ptr.hpp> @@ -68,6 +69,7 @@ namespace rptui void ImplInitSettings(); sal_Int32 GetTotalHeight() const; + sal_Int32 impl_getRealPixelWidth() const; OReportWindow(OReportWindow&); void operator =(OReportWindow&); @@ -120,7 +122,7 @@ namespace rptui */ BOOL HasSelection(); - Point getScrollOffset() const; + Point getThumbPos() const; /** removes the section at the given position. * @@ -162,9 +164,9 @@ namespace rptui */ sal_Int32 getMaxMarkerWidth(sal_Bool _bWithEnd) const; - void ScrollChildren(long nDeltaX, long nDeltaY); + void ScrollChildren(const Point& _aThumbPos); - void notifyHeightChanged(); + void notifySizeChanged(); /** unmark all objects on the views without the given one. * @@ -220,12 +222,17 @@ namespace rptui /** zoom the ruler and view windows */ - void zoom(const sal_Int16 _nZoom); + void zoom(const Fraction& _aZoom); /** fills the vector with all selected control models /param _rSelection The vector will be filled and will not be cleared before. */ void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const; + + /** calculates the zoom factor. + @param _eType which kind of zoom is needed + */ + sal_uInt16 getZoomFactor(SvxZoomType _eType) const; }; //================================================================== } //rptui diff --git a/reportdesign/source/ui/inc/ScrollHelper.hxx b/reportdesign/source/ui/inc/ScrollHelper.hxx index 76e8695ef8d9..5321103b7c78 100644 --- a/reportdesign/source/ui/inc/ScrollHelper.hxx +++ b/reportdesign/source/ui/inc/ScrollHelper.hxx @@ -66,7 +66,6 @@ namespace rptui ScrollBar m_aVScroll; ScrollBarBox m_aCornerWin; // window in the bottom right corner Size m_aTotalPixelSize; - Point m_aPixOffset; // offset to virtual window (pixel) ODesignView* m_pParent; OReportWindow m_aReportWindow; ::rtl::Reference<comphelper::OPropertyChangeMultiplexer > @@ -76,7 +75,6 @@ namespace rptui Size ResizeScrollBars(); void ImplInitSettings(); void impl_initScrollBar( ScrollBar& _rScrollBar ) const; - void impl_scrollContent( long nDeltaX, long nDeltaY ); OScrollWindowHelper(OScrollWindowHelper&); void operator =(OScrollWindowHelper&); @@ -95,7 +93,7 @@ namespace rptui */ void initialize(); - inline Point getScrollOffset() const { return Point(m_aHScroll.GetThumbPos(),m_aVScroll.GetThumbPos())/*m_aScrollOffset*/; } + inline Point getThumbPos() const { return Point(m_aHScroll.GetThumbPos(),m_aVScroll.GetThumbPos())/*m_aScrollOffset*/; } inline const OReportWindow& getReportWindow() const { return m_aReportWindow; } void setTotalSize(sal_Int32 _nWidth ,sal_Int32 _nHeight); inline Size getTotalSize() const { return m_aTotalPixelSize; } @@ -218,12 +216,17 @@ namespace rptui /** zoom the ruler and view windows */ - void zoom(const sal_Int16 _nZoom); + void zoom(const Fraction& _aZoom); /** fills the vector with all selected control models /param _rSelection The vector will be filled and will not be cleared before. */ void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const; + + /** calculates the zoom factor. + @param _eType which kind of zoom is needed + */ + sal_uInt16 getZoomFactor(SvxZoomType _eType) const; }; } #endif // RPTUI_SCROLLHELPER_HXX diff --git a/reportdesign/source/ui/inc/SectionWindow.hxx b/reportdesign/source/ui/inc/SectionWindow.hxx index 0f0bfe73effe..cf1ecb056646 100644 --- a/reportdesign/source/ui/inc/SectionWindow.hxx +++ b/reportdesign/source/ui/inc/SectionWindow.hxx @@ -121,9 +121,9 @@ namespace rptui /** zoom the ruler and view windows */ - void zoom(const sal_Int16 _nZoom); + void zoom(const Fraction& _aZoom); - void scrollChildren(long _nDeltaX); + void scrollChildren(long _nThumbPosX); }; //============================================================================== } // rptui diff --git a/reportdesign/source/ui/inc/StartMarker.hxx b/reportdesign/source/ui/inc/StartMarker.hxx index 268119e44927..bbe4204eb989 100644 --- a/reportdesign/source/ui/inc/StartMarker.hxx +++ b/reportdesign/source/ui/inc/StartMarker.hxx @@ -87,7 +87,7 @@ namespace rptui /** zoom the ruler and view windows */ - void zoom(const sal_Int16 _nZoom); + void zoom(const Fraction& _aZoom); }; } #endif // RPTUI_STARTMARKER_HXX diff --git a/reportdesign/source/ui/inc/UITools.hxx b/reportdesign/source/ui/inc/UITools.hxx index 4885dc361aca..28b42b65402b 100644 --- a/reportdesign/source/ui/inc/UITools.hxx +++ b/reportdesign/source/ui/inc/UITools.hxx @@ -166,10 +166,10 @@ namespace rptui Rectangle getRectangleFromControl(SdrObject* pControl); /** sets the map mode at the window - @param _nZoom in percentage + @param _aZoom the zoom scale @param _rWindow where to set the map mode */ - void setZoomFactor(const sal_Int16 _nZoom,Window& _rWindow); + void setZoomFactor(const Fraction& _aZoom,Window& _rWindow); } #endif //RPTUI_UITOOLS_HXX diff --git a/reportdesign/source/ui/inc/ViewsWindow.hxx b/reportdesign/source/ui/inc/ViewsWindow.hxx index b7b419f70db3..995b59e7adba 100644 --- a/reportdesign/source/ui/inc/ViewsWindow.hxx +++ b/reportdesign/source/ui/inc/ViewsWindow.hxx @@ -353,9 +353,9 @@ namespace rptui /** zoom the ruler and view windows */ - void zoom(const sal_Int16 _nZoom); + void zoom(const Fraction& _aZoom); - void scrollChildren(long nDeltaX, long nDeltaY); + void scrollChildren(const Point& _aThumbPos); /** fills the vector with all selected control models /param _rSelection The vector will be filled and will not be cleared before. diff --git a/reportdesign/source/ui/inc/metadata.hxx b/reportdesign/source/ui/inc/metadata.hxx index 7e38f5f99a60..2d320df2385a 100644 --- a/reportdesign/source/ui/inc/metadata.hxx +++ b/reportdesign/source/ui/inc/metadata.hxx @@ -107,6 +107,7 @@ namespace rptui //======================================================================== //= property ids (for all browseable properties) + //= The ID is used for the view order in the property browser. //======================================================================== #define PROPERTY_ID_FORCENEWPAGE 1 @@ -135,10 +136,12 @@ namespace rptui #define PROPERTY_ID_PRINTWHENGROUPCHANGE 24 #define PROPERTY_ID_DEEPTRAVERSING 25 #define PROPERTY_ID_PREEVALUATED 26 - #define PROPERTY_ID_BACKCOLOR 27 - #define PROPERTY_ID_BACKTRANSPARENT 28 - #define PROPERTY_ID_CONTROLBACKGROUND 29 - #define PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT 30 + + #define PROPERTY_ID_BACKCOLOR 29 + #define PROPERTY_ID_CONTROLBACKGROUND 30 + #define PROPERTY_ID_BACKTRANSPARENT 27 + #define PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT 28 + #define PROPERTY_ID_FORMULALIST 31 #define PROPERTY_ID_SCOPE 32 #define PROPERTY_ID_RESETPAGENUMBER 33 diff --git a/reportdesign/source/ui/inc/statusbarcontroller.hxx b/reportdesign/source/ui/inc/statusbarcontroller.hxx index f736e129c519..613ec72b5627 100644 --- a/reportdesign/source/ui/inc/statusbarcontroller.hxx +++ b/reportdesign/source/ui/inc/statusbarcontroller.hxx @@ -51,16 +51,20 @@ namespace rptui public: OStatusbarController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + + private: + void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException); // XInterface DECLARE_XINTERFACE( ) // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); // need by registration - static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException ); - static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); - static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL - create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); // XInitialization diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx index aa0abdc7a278..3940e8e8326a 100644 --- a/reportdesign/source/ui/inspection/GeometryHandler.cxx +++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx @@ -43,6 +43,7 @@ #include <svtools/syslocale.hxx> #include <tools/diagnose_ex.h> #include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> #include "com/sun/star/inspection/StringRepresentation.hpp" #include <com/sun/star/inspection/PropertyLineElement.hpp> #include <com/sun/star/inspection/PropertyControlType.hpp> @@ -441,6 +442,43 @@ uno::Any SAL_CALL GeometryHandler::getPropertyValue(const ::rtl::OUString & Prop aPropertyValue.clear(); } break; + case PROPERTY_ID_AREA: + { + drawing::FillStyle aFillStyle; + m_xReportComponent->getPropertyValue(PROPERTY_FILLSTYLE) >>= aFillStyle; + ::rtl::OUString sProperty; + switch(aFillStyle) + { + case drawing::FillStyle_GRADIENT: + sProperty = PROPERTY_FILLGRADIENTNAME; + break; + case drawing::FillStyle_HATCH: + sProperty = PROPERTY_FILLHATCHNAME; + break; + case drawing::FillStyle_BITMAP: + sProperty = PROPERTY_FILLBITMAPNAME; + break; + case drawing::FillStyle_NONE: + { + const ::rtl::OUString sNone = String( ModuleRes( RID_STR_NONE ) ); + aPropertyValue <<= sNone; + break; + } + default: + break; + } + + if ( sProperty.getLength() ) + { + aPropertyValue = m_xReportComponent->getPropertyValue(sProperty); + //if ( drawing::FillStyle_GRADIENT == aFillStyle ) + //{ + // static const ::rtl::OUString s_sFillTransparenceGradientName(RTL_CONSTASCII_USTRINGPARAM("FillTransparenceGradientName")); + // aPropertyValue = m_xReportComponent->getPropertyValue(s_sFillTransparenceGradientName); + //} + } + } + break; default: aPropertyValue = m_xReportComponent->getPropertyValue( PropertyName ); break; @@ -1024,9 +1062,11 @@ uno::Any SAL_CALL GeometryHandler::convertToPropertyValue(const ::rtl::OUString return m_xFormComponentHandler->convertToPropertyValue(PROPERTY_FONTNAME, _rControlValue); case PROPERTY_ID_SCOPE: case PROPERTY_ID_FORMULALIST: - case PROPERTY_ID_AREA: aPropertyValue = _rControlValue; break; + case PROPERTY_ID_AREA: + //aPropertyValue = _rControlValue; + break; case PROPERTY_ID_TYPE: { ::rtl::OUString sValue; @@ -1251,13 +1291,12 @@ uno::Sequence< beans::Property > SAL_CALL GeometryHandler::getSupportedPropertie } // for (size_t i = 0; i < sizeof(pIncludeProperties)/sizeof(pIncludeProperties[0]) ;++i ) // special property for shapes -// if ( uno::Reference< report::XShape>(m_xReportComponent,uno::UNO_QUERY).is() ) -// { -// beans::Property aValue; -// aValue.Name = PROPERTY_AREA; -// aNewProps.push_back(aValue); -// } - // re-enable when the remaining issues of #i88727# are fixed + if ( uno::Reference< report::XShape>(m_xReportComponent,uno::UNO_QUERY).is() ) + { + beans::Property aValue; + aValue.Name = PROPERTY_AREA; + aNewProps.push_back(aValue); + } return uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size()); } @@ -1283,12 +1322,14 @@ uno::Sequence< ::rtl::OUString > SAL_CALL GeometryHandler::getActuatingPropertie { ::osl::MutexGuard aGuard( m_aMutex ); - uno::Sequence< ::rtl::OUString > aSeq(5); + uno::Sequence< ::rtl::OUString > aSeq(7); aSeq[0] = PROPERTY_BACKTRANSPARENT; aSeq[1] = PROPERTY_CONTROLBACKGROUNDTRANSPARENT; aSeq[2] = PROPERTY_FORMULALIST; aSeq[3] = PROPERTY_TYPE; aSeq[4] = PROPERTY_DATAFIELD; + aSeq[5] = PROPERTY_FILLSTYLE; + aSeq[6] = PROPERTY_FILLCOLOR; return ::comphelper::concatSequences(m_xFormComponentHandler->getActuatingProperties(),aSeq); } @@ -1339,15 +1380,15 @@ inspection::InteractiveSelectionResult SAL_CALL GeometryHandler::onInteractivePr inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled; const uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY); const uno::Reference< report::XShape> xShape(m_xReportComponent,uno::UNO_QUERY); + aGuard.clear(); if ( rptui::openAreaDialog( xShape, xInspectorWindow) ) { eResult = inspection::InteractiveSelectionResult_ObtainedValue; beans::PropertyChangeEvent aScopeEvent; - aScopeEvent.PropertyName = PROPERTY_FILLCOLOR; - // aScopeEvent.OldValue <<= _nOldDataFieldType; - aScopeEvent.NewValue <<= xShape->getPropertyValue(PROPERTY_FILLCOLOR); + aScopeEvent.PropertyName = PROPERTY_FILLSTYLE; + aScopeEvent.NewValue = xShape->getPropertyValue(PROPERTY_FILLSTYLE); m_aPropertyListeners.notify( aScopeEvent, &beans::XPropertyChangeListener::propertyChange ); } return eResult; @@ -1363,79 +1404,102 @@ void SAL_CALL GeometryHandler::actuatingPropertyChanged(const ::rtl::OUString & throw lang::NullPointerException(); ::osl::MutexGuard aGuard( m_aMutex ); - const sal_Int32 nId = m_pInfoService->getPropertyId(ActuatingPropertyName); - switch(nId) + if ( ActuatingPropertyName == PROPERTY_FILLSTYLE ) { - case PROPERTY_ID_TYPE: - { - sal_uInt32 nNewVal = 0; - NewValue >>= nNewVal; - switch(nNewVal) + drawing::FillStyle aFillStyle; + NewValue >>= aFillStyle; + const sal_Bool bEnable = aFillStyle == drawing::FillStyle_SOLID; + _rxInspectorUI->enablePropertyUI(PROPERTY_FILLCOLOR,bEnable); + if ( bEnable ) + _rxInspectorUI->rebuildPropertyUI(PROPERTY_FILLCOLOR); + + _rxInspectorUI->rebuildPropertyUI(PROPERTY_AREA); + } // if ( ActuatingPropertyName == PROPERTY_FILLSTYLE || ActuatingPropertyName == PROPERTY_FILLCOLOR ) + else if ( ActuatingPropertyName == PROPERTY_FILLCOLOR ) + { + if ( m_xReportComponent.is() && m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_FILLSTYLE) ) + { + drawing::FillStyle aFillStyle; + m_xReportComponent->getPropertyValue( PROPERTY_FILLSTYLE ) >>= aFillStyle; + _rxInspectorUI->enablePropertyUI(PROPERTY_FILLCOLOR,aFillStyle == drawing::FillStyle_SOLID); + } + } + else + { + const sal_Int32 nId = m_pInfoService->getPropertyId(ActuatingPropertyName); + switch(nId) + { + case PROPERTY_ID_TYPE: { - case DATA_OR_FORMULA: - _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD); - _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True); - _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False); - _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False); - OSL_ENSURE(m_sDefaultFunction.getLength() == 0,"Why is the m_sDefaultFunction set?"); - OSL_ENSURE(m_sScope.getLength() == 0,"Why is the m_sScope set?"); - break; - case FUNCTION: + sal_uInt32 nNewVal = 0; + NewValue >>= nNewVal; + switch(nNewVal) + { + case DATA_OR_FORMULA: + _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD); + _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True); + _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False); + _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False); + OSL_ENSURE(m_sDefaultFunction.getLength() == 0,"Why is the m_sDefaultFunction set?"); + OSL_ENSURE(m_sScope.getLength() == 0,"Why is the m_sScope set?"); + break; + case FUNCTION: + _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD); + _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST); + _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True); + _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,m_sDefaultFunction.getLength() != 0); + _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_sScope.getLength() != 0); + break; + case USER_DEF_FUNCTION: + _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False); + _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_True); + _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST); + _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False); + break; + case COUNTER: + _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False); + _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False); + _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_True); + break; + } + } + break; + case PROPERTY_ID_DATAFIELD: + { + sal_Bool bEnable = (m_nDataFieldType != DATA_OR_FORMULA && m_nDataFieldType != COUNTER ); + if ( bEnable ) + { + ::rtl::OUString sValue; + m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ) >>= sValue; + bEnable = sValue.getLength() != 0; + } + _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,bEnable); + if ( bEnable ) + { _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD); _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST); - _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True); - _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,m_sDefaultFunction.getLength() != 0); - _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_sScope.getLength() != 0); - break; - case USER_DEF_FUNCTION: - _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False); - _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_True); - _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST); - _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False); - break; - case COUNTER: - _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False); - _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False); - _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_True); - break; + } } - } - break; - case PROPERTY_ID_DATAFIELD: - { - sal_Bool bEnable = (m_nDataFieldType != DATA_OR_FORMULA && m_nDataFieldType != COUNTER ); - if ( bEnable ) + break; + case PROPERTY_ID_FORMULALIST: { - ::rtl::OUString sValue; - m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ) >>= sValue; - bEnable = sValue.getLength() != 0; + _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_nDataFieldType == FUNCTION || m_nDataFieldType == COUNTER); } - _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,bEnable); - if ( bEnable ) + break; + case PROPERTY_ID_BACKTRANSPARENT: + case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT: { - _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD); - _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST); + sal_Bool bValue = sal_False; + NewValue >>= bValue; + bValue = !bValue; + _rxInspectorUI->enablePropertyUI(PROPERTY_BACKCOLOR,bValue); + _rxInspectorUI->enablePropertyUI(PROPERTY_CONTROLBACKGROUND,bValue); } - } - break; - case PROPERTY_ID_FORMULALIST: - { - _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_nDataFieldType == FUNCTION || m_nDataFieldType == COUNTER); - } - break; - case PROPERTY_ID_BACKTRANSPARENT: - case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT: - { - sal_Bool bValue = sal_False; - NewValue >>= bValue; - bValue = !bValue; - _rxInspectorUI->enablePropertyUI(PROPERTY_BACKCOLOR,bValue); - _rxInspectorUI->enablePropertyUI(PROPERTY_CONTROLBACKGROUND,bValue); - } - break; - default: - m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, _rxInspectorUI, _bFirstTimeInit); - break; + break; + default: + m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, _rxInspectorUI, _bFirstTimeInit); + break; + } // switch(nId) } } diff --git a/reportdesign/source/ui/inspection/inspection.src b/reportdesign/source/ui/inspection/inspection.src index 8bff7188ce72..4aadda5c3536 100644 --- a/reportdesign/source/ui/inspection/inspection.src +++ b/reportdesign/source/ui/inspection/inspection.src @@ -59,6 +59,11 @@ String RID_STR_FORCENEWPAGE_CONST { Text [ en-US ] = "None;Before Section;After Section;Before & After Section" ; }; +String RID_STR_NONE +{ + Text [ en-US ] = "None"; +}; + String RID_STR_NEWROWORCOL { Text [ en-US ] = "New Row Or Column" ; diff --git a/reportdesign/source/ui/inspection/metadata.cxx b/reportdesign/source/ui/inspection/metadata.cxx index 8653812ed212..587c81be49b4 100644 --- a/reportdesign/source/ui/inspection/metadata.cxx +++ b/reportdesign/source/ui/inspection/metadata.cxx @@ -296,6 +296,7 @@ namespace rptui PROPERTY_EFFECTIVEMIN, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HideInactiveSelection")), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SubmitAction")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputRequired")), PROPERTY_EMPTY_IS_NULL, PROPERTY_FILTERPROPOSAL ,PROPERTY_POSITIONX diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx index 57d442ff0763..9cd7a2afd6f9 100644 --- a/reportdesign/source/ui/misc/UITools.cxx +++ b/reportdesign/source/ui/misc/UITools.cxx @@ -1082,13 +1082,11 @@ void correctOverlapping(SdrObject* _pControl,OReportSection& _aReportSection,boo rSectionView.InsertObjectAtView(_pControl,*rSectionView.GetSdrPageView(),SDRINSERT_ADDMARK); } // ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- -void setZoomFactor(const sal_Int16 _nZoom,Window& _rWindow) +void setZoomFactor(const Fraction& _aZoom,Window& _rWindow) { - Fraction aZoom(_nZoom,100); MapMode aMapMode( _rWindow.GetMapMode() ); - aMapMode.SetScaleX(aZoom); - aMapMode.SetScaleY(aZoom); + aMapMode.SetScaleX(_aZoom); + aMapMode.SetScaleY(_aZoom); _rWindow.SetMapMode(aMapMode); } // ----------------------------------------------------------------------------- diff --git a/reportdesign/source/ui/misc/statusbarcontroller.cxx b/reportdesign/source/ui/misc/statusbarcontroller.cxx index 17155e10adb5..b69fa43224d4 100644 --- a/reportdesign/source/ui/misc/statusbarcontroller.cxx +++ b/reportdesign/source/ui/misc/statusbarcontroller.cxx @@ -137,24 +137,27 @@ void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEv ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::MutexGuard aGuard(m_aMutex); - if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) + if ( m_pController.is() ) { - Sequence< PropertyValue > aSeq; - if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 ) + if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) { - SvxZoomSliderItem aZoomSlider(100); - aZoomSlider.PutValue(_aEvent.State); - static_cast<SvxZoomSliderControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider); - } - } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) - else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) - { - Sequence< PropertyValue > aSeq; - if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 ) + Sequence< PropertyValue > aSeq; + if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 2 ) + { + SvxZoomSliderItem aZoomSlider(100,20,400); + aZoomSlider.PutValue(_aEvent.State); + static_cast<SvxZoomSliderControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoomSlider); + } + } // if ( m_aCommandURL.equalsAscii(".uno:ZoomSlider") ) + else if ( m_aCommandURL.equalsAscii(".uno:Zoom") ) { - SvxZoomItem aZoom; - aZoom.PutValue(_aEvent.State); - static_cast<SvxZoomStatusBarControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom); + Sequence< PropertyValue > aSeq; + if ( (_aEvent.State >>= aSeq) && aSeq.getLength() == 3 ) + { + SvxZoomItem aZoom; + aZoom.PutValue(_aEvent.State); + static_cast<SvxZoomStatusBarControl*>(m_pController.get())->StateChanged(m_nSlotId,SFX_ITEM_AVAILABLE,&aZoom); + } } } } @@ -162,17 +165,17 @@ void SAL_CALL OStatusbarController::statusChanged( const FeatureStateEvent& _aEv // XStatusbarController ::sal_Bool SAL_CALL OStatusbarController::mouseButtonDown(const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) { - return m_pController.getRef()->mouseButtonDown(_aEvent); + return m_pController.is() && m_pController.getRef()->mouseButtonDown(_aEvent); } ::sal_Bool SAL_CALL OStatusbarController::mouseMove( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) { - return m_pController.getRef()->mouseMove(_aEvent); + return m_pController.is() && m_pController.getRef()->mouseMove(_aEvent); } ::sal_Bool SAL_CALL OStatusbarController::mouseButtonUp( const ::com::sun::star::awt::MouseEvent& _aEvent)throw (::com::sun::star::uno::RuntimeException) { - return m_pController.getRef()->mouseButtonUp(_aEvent); + return m_pController.is() && m_pController.getRef()->mouseButtonUp(_aEvent); } void SAL_CALL OStatusbarController::command( @@ -182,7 +185,8 @@ void SAL_CALL OStatusbarController::command( const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException) { - m_pController.getRef()->command( aPos, nCommand, bMouseEvent, aData ); + if ( m_pController.is() ) + m_pController.getRef()->command( aPos, nCommand, bMouseEvent, aData ); } void SAL_CALL OStatusbarController::paint( @@ -192,17 +196,20 @@ void SAL_CALL OStatusbarController::paint( ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException) { - return m_pController.getRef()->paint( xGraphics, rOutputRectangle, nItemId, nStyle ); + if ( m_pController.is() ) + m_pController.getRef()->paint( xGraphics, rOutputRectangle, nItemId, nStyle ); } void SAL_CALL OStatusbarController::click() throw (::com::sun::star::uno::RuntimeException) { - m_pController.getRef()->click(); + if ( m_pController.is() ) + m_pController.getRef()->click(); } void SAL_CALL OStatusbarController::doubleClick() throw (::com::sun::star::uno::RuntimeException) { - m_pController.getRef()->doubleClick(); + if ( m_pController.is() ) + m_pController.getRef()->doubleClick(); } // ----------------------------------------------------------------------------- void SAL_CALL OStatusbarController::update() throw ( RuntimeException ) @@ -213,7 +220,12 @@ void SAL_CALL OStatusbarController::update() throw ( RuntimeException ) xUp->update(); } // ----------------------------------------------------------------------------- - +// XComponent +void SAL_CALL OStatusbarController::dispose() throw (::com::sun::star::uno::RuntimeException) +{ + m_pController.dispose(); + svt::StatusbarController::dispose(); +} // ============================================================================= } // rptui // ============================================================================= diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx index 78179fa3d6c9..b7dedea9f2e4 100644 --- a/reportdesign/source/ui/report/DesignView.cxx +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -750,9 +750,14 @@ sal_uInt32 ODesignView::getMarkedObjectCount() const return m_aScrollWindow.getMarkedObjectCount(); } // ----------------------------------------------------------------------------- -void ODesignView::zoom(const sal_Int16 _nZoom) +void ODesignView::zoom(const Fraction& _aZoom) { - m_aScrollWindow.zoom(_nZoom); + m_aScrollWindow.zoom(_aZoom); +} +// ----------------------------------------------------------------------------- +sal_uInt16 ODesignView::getZoomFactor(SvxZoomType _eType) const +{ + return m_aScrollWindow.getZoomFactor(_eType); } //============================================================================ } // rptui diff --git a/reportdesign/source/ui/report/InsertFunctions.cxx b/reportdesign/source/ui/report/InsertFunctions.cxx deleted file mode 100644 index e2156f7de0ed..000000000000 --- a/reportdesign/source/ui/report/InsertFunctions.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************* - * - * 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: InsertFunctions.cxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_reportdesign.hxx" -#include <com/sun/star/embed/NoVisualAreaSizeException.hpp> -#include <com/sun/star/embed/Aspects.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/embed/XEmbedPersist.hpp> -//------------------------------------------------------------------------ - -#include <toolkit/helper/vclunohelper.hxx> -#include <sot/exchange.hxx> -#include <svtools/globalnameitem.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/docfile.hxx> -#include <svtools/stritem.hxx> -#include <svx/svdoole2.hxx> -#include <svx/svdview.hxx> -#include <svx/pfiledlg.hxx> -#include <tools/urlobj.hxx> -#include <vcl/msgbox.hxx> -#include <svtools/urihelper.hxx> -#include <svtools/moduleoptions.hxx> -#include <svtools/insdlg.hxx> -#include <svtools/soerr.hxx> -#include <svx/svxdlg.hxx> -#include <sot/clsids.hxx> -#include <svx/svdpagv.hxx> -#include <svx/svdpage.hxx> -#include <svx/svdundo.hxx> -#include <svx/svdmodel.hxx> - -#include <cppuhelper/component_context.hxx> -#include <comphelper/processfactory.hxx> -#include <comphelper/storagehelper.hxx> -#include <comphelper/property.hxx> -#include <comphelper/types.hxx> -#include <comphelper/embeddedobjectcontainer.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/frame/XSynchronousFrameLoader.hpp> -#include <com/sun/star/frame/XComponentLoader.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/chart2/data/DatabaseDataProvider.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/chart/ChartDataRowSource.hpp> -#include <com/sun/star/chart2/data/XDataReceiver.hpp> - -using namespace ::com::sun::star; - -#include "InsertFunctions.hxx" -#include "RptObject.hxx" - -namespace rptui -{ -//------------------------------------------------------------------------ -// ----------------------------------------------------------------------------- -} // namespace rptui -// ----------------------------------------------------------------------------- - diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 55eab50acc81..2bb3d3d5dbc8 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -115,6 +115,9 @@ #include <svx/brshitem.hxx> #include <svx/flagsdef.hxx> //CHINA001 #include <svx/svdpagv.hxx> +#include <svx/svxdlg.hxx> +#include <svx/zoom_def.hxx> +#include <svx/dialogs.hrc> #include "DesignView.hxx" #include "ModuleHelper.hxx" @@ -280,7 +283,7 @@ DBG_NAME( rpt_OReportController ) OReportController::OReportController(Reference< XComponentContext > const & xContext) : OReportController_BASE(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY)) ,OPropertyStateContainer(OGenericUnoController_Base::rBHelper) -,m_aSelectionListeners( m_aMutex ) +,m_aSelectionListeners( getMutex() ) ,m_pMyOwnView(NULL) ,m_pClipbordNotifier(NULL) ,m_pGroupsFloater(NULL) @@ -288,6 +291,7 @@ OReportController::OReportController(Reference< XComponentContext > const & xCon ,m_nSplitPos(-1) ,m_nPageNum(-1) ,m_nZoomValue(100) +,m_eZoomType(SVX_ZOOM_PERCENT) ,m_bShowRuler(sal_True) ,m_bGridVisible(sal_True) ,m_bGridUse(sal_True) @@ -299,7 +303,7 @@ OReportController::OReportController(Reference< XComponentContext > const & xCon { m_sMode = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("normal")); DBG_CTOR( rpt_OReportController,NULL); - registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZoomValue")),PROPERTY_ID_ZOOMVALUE,beans::PropertyAttribute::BOUND| beans::PropertyAttribute::TRANSIENT, &m_nZoomValue, ::getCppuType(reinterpret_cast< sal_Int16*>(NULL))); + registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZoomValue")),PROPERTY_ID_ZOOMVALUE,beans::PropertyAttribute::BOUND| beans::PropertyAttribute::TRANSIENT,&m_nZoomValue,::getCppuType(reinterpret_cast< sal_Int16*>(NULL))); } // ----------------------------------------------------------------------------- OReportController::~OReportController() @@ -894,8 +898,8 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const case SID_ATTR_ZOOM: aReturn.bEnabled = sal_True; { - SvxZoomItem aZoom(SVX_ZOOM_PERCENT,m_nZoomValue); - aZoom.SetValueSet(SVX_ZOOM_ENABLE_50|SVX_ZOOM_ENABLE_75|SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_150|SVX_ZOOM_ENABLE_200); + SvxZoomItem aZoom(m_eZoomType,m_nZoomValue); + aZoom.SetValueSet(SVX_ZOOM_ENABLE_50|SVX_ZOOM_ENABLE_75|SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_200); aZoom.QueryValue(aReturn.aValue); //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue); } @@ -903,11 +907,10 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const case SID_ATTR_ZOOMSLIDER: aReturn.bEnabled = sal_True; { - SvxZoomSliderItem aZoomSlider(m_nZoomValue); + SvxZoomSliderItem aZoomSlider(m_nZoomValue,20,400); aZoomSlider.AddSnappingPoint(50); aZoomSlider.AddSnappingPoint(75); aZoomSlider.AddSnappingPoint(100); - aZoomSlider.AddSnappingPoint(150); aZoomSlider.AddSnappingPoint(200); aZoomSlider.QueryValue(aReturn.aValue); //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue); @@ -947,7 +950,7 @@ namespace void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs) { ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); if ( !getView() ) { switch(_nId) @@ -1594,11 +1597,16 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > case SID_GROUP: break; case SID_ATTR_ZOOM: - if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") ) + if ( aArgs.getLength() == 0 ) + { + openZoomDialog(); + } + else if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") ) { SvxZoomItem aZoomItem; aZoomItem.PutValue(aArgs[0].Value); m_nZoomValue = aZoomItem.GetValue(); + m_eZoomType = aZoomItem.GetType(); impl_zoom_nothrow(); } // if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") ) break; @@ -1608,6 +1616,7 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > SvxZoomSliderItem aZoomSlider; aZoomSlider.PutValue(aArgs[0].Value); m_nZoomValue = aZoomSlider.GetValue(); + m_eZoomType = SVX_ZOOM_PERCENT; impl_zoom_nothrow(); } break; @@ -1749,7 +1758,7 @@ sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/) throw( Runt return sal_True; vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); if ( getView() && getView()->IsInModalMode() ) return sal_False; @@ -2023,7 +2032,7 @@ SfxUndoManager* OReportController::getUndoMgr() // ----------------------------------------------------------------------------- void OReportController::setModified(sal_Bool _bModified) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); try { if ( m_xReportDefinition.is() ) @@ -2069,7 +2078,7 @@ void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _ if ( xGroup.is() ) { ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); sal_Int32 nGroupPos = 0; _rEvent.Accessor >>= nGroupPos; @@ -2109,14 +2118,14 @@ void SAL_CALL OReportController::elementRemoved( const ContainerEvent& _rEvent ) void SAL_CALL OReportController::elementReplaced( const ContainerEvent& /*_rEvent*/ ) throw(RuntimeException) { ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); OSL_ENSURE(0,"Not yet implemented!"); } // ----------------------------------------------------------------------------- void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException) { ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); try { sal_Bool bShow = sal_False; @@ -2374,6 +2383,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ uno::Any aValue; static_cast<const SvxSizeItem*>(pItem)->QueryValue(aValue,MID_SIZE_SIZE); xProp->setPropertyValue(PROPERTY_PAPERSIZE,aValue); + resetZoomType(); } if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_LRSPACE,sal_True,&pItem)) @@ -2394,6 +2404,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ uno::Any aValue; pPageItem->QueryValue(aValue,MID_PAGE_LAYOUT); xProp->setPropertyValue(PROPERTY_PAGESTYLELAYOUT,aValue); + resetZoomType(); } if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,sal_True,&pItem)) { @@ -2417,7 +2428,7 @@ void OReportController::openPageDialog(const uno::Reference<report::XSection>& _ // ----------------------------------------------------------------------------- sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel) throw( uno::RuntimeException ) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); m_xReportDefinition.set(xModel,uno::UNO_QUERY); return m_xReportDefinition.is(); } @@ -2486,7 +2497,7 @@ void OReportController::alignControlsWithUndo(USHORT _nUndoStrId,sal_Int32 _nCon // ----------------------------------------------------------------------------- uno::Any SAL_CALL OReportController::getViewData(void) throw( uno::RuntimeException ) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); typedef ::std::pair< ::rtl::OUString,sal_uInt16> TStringIntPair; const TStringIntPair pViewDataList[] = { @@ -2556,7 +2567,7 @@ uno::Any SAL_CALL OReportController::getViewData(void) throw( uno::RuntimeExcept // ----------------------------------------------------------------------------- void SAL_CALL OReportController::restoreViewData(const uno::Any& Data) throw( uno::RuntimeException ) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); uno::Sequence<beans::PropertyValue> aProps; if ( Data >>= aProps ) { @@ -2817,7 +2828,7 @@ void OReportController::insertGraphic() // ----------------------------------------------------------------------------- ::sal_Bool SAL_CALL OReportController::select( const Any& aSelection ) throw (IllegalArgumentException, RuntimeException) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); ::sal_Bool bRet = sal_True; if ( m_pMyOwnView ) { @@ -2857,7 +2868,7 @@ void OReportController::insertGraphic() // ----------------------------------------------------------------------------- Any SAL_CALL OReportController::getSelection( ) throw (RuntimeException) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); Any aRet; if ( m_pMyOwnView ) { @@ -2934,8 +2945,9 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co } else { - SdrUnoObj* pLabel,*pControl; - FmFormView::createControlLabelPair(NULL,m_pMyOwnView + SdrUnoObj* pLabel( NULL ); + SdrUnoObj* pControl( NULL ); + FmFormView::createControlLabelPair(m_pMyOwnView ,nLeftMargin,0 ,NULL,NULL,_nObjectId,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT, NULL,pSectionWindow->getReportSection().getPage(),m_aReportModel.get(), @@ -3222,7 +3234,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs) pSectionViews[0] = &pSectionWindow[1]->getReportSection().getSectionView(); pSectionViews[1] = &pSectionWindow[0]->getReportSection().getSectionView(); // find this in svx - FmFormView::createControlLabelPair(pSectionViews[0],m_pMyOwnView + FmFormView::createControlLabelPair(m_pMyOwnView ,nLeftMargin,0 ,xField,xNumberFormats,nOBJID,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT, pSectionWindow[1]->getReportSection().getPage(),pSectionWindow[0]->getReportSection().getPage(),m_aReportModel.get(), @@ -3737,7 +3749,7 @@ void OReportController::checkChartEnabled() throw (uno::RuntimeException) { vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); uno::Reference< frame::XTitle> xTitle(m_xReportDefinition,uno::UNO_QUERY_THROW); @@ -3775,12 +3787,12 @@ void SAL_CALL OReportController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHa } void SAL_CALL OReportController::setMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); m_sMode = aMode; } ::rtl::OUString SAL_CALL OReportController::getMode( ) throw (::com::sun::star::uno::RuntimeException) { - ::osl::MutexGuard aGuard(m_aMutex); + ::osl::MutexGuard aGuard( getMutex() ); return m_sMode; } ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OReportController::getSupportedModes( ) throw (::com::sun::star::uno::RuntimeException) @@ -3846,15 +3858,12 @@ void OReportController::impl_fillState_nothrow(const ::rtl::OUString& _sProperty void OReportController::impl_zoom_nothrow() { Fraction aZoom(m_nZoomValue,100); - MapMode aMapMode = m_pMyOwnView->GetMapMode(); - aMapMode.SetScaleX(aZoom); - aMapMode.SetScaleY(aZoom); - m_pMyOwnView->SetMapMode(aMapMode); - m_pMyOwnView->zoom(m_nZoomValue); + setZoomFactor(aZoom,*m_pMyOwnView); + m_pMyOwnView->zoom(aZoom); // TRY /*m_pMyOwnView->Invalidate(INVALIDATE_NOCHILDREN);*/ - InvalidateFeature(SID_ATTR_ZOOM); - InvalidateFeature(SID_ATTR_ZOOMSLIDER); + InvalidateFeature(SID_ATTR_ZOOM,Reference< XStatusListener >(),sal_True); + InvalidateFeature(SID_ATTR_ZOOMSLIDER,Reference< XStatusListener >(),sal_True); } // ----------------------------------------------------------------------------- sal_Bool OReportController::isFormatCommandEnabled(sal_uInt16 _nCommand,const uno::Reference< report::XReportControlFormat>& _xReportControlFormat) const @@ -3917,3 +3926,58 @@ void OReportController::impl_fillCustomShapeState_nothrow(const char* _pCustomSh _rState.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_CUSTOMSHAPE && sShapeType.compareToAscii(_pCustomShapeType) == 0; } // ----------------------------------------------------------------------------- +void OReportController::openZoomDialog() +{ + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + static SfxItemInfo aItemInfos[] = + { + { SID_ATTR_ZOOM, SFX_ITEM_POOLABLE } + }; + SfxPoolItem* pDefaults[] = + { + new SvxZoomItem() + }; + static USHORT pRanges[] = + { + SID_ATTR_ZOOM,SID_ATTR_ZOOM, + 0 + }; + try + { + ::std::auto_ptr<SfxItemPool> pPool( new SfxItemPool(String::CreateFromAscii("ZoomProperties"), SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, pDefaults) ); + pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why + pPool->FreezeIdRanges(); // the same + + ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges)); + // fill it + SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM ); + aZoomItem.SetValueSet(SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_WHOLEPAGE|SVX_ZOOM_ENABLE_PAGEWIDTH); + pDescriptor->Put(aZoomItem); + + ::std::auto_ptr<AbstractSvxZoomDialog> pDlg( pFact->CreateSvxZoomDialog(NULL, *pDescriptor.get(), RID_SVXDLG_ZOOM) ); + pDlg->SetLimits( 20, 400 ); + bool bCancel = ( RET_CANCEL == pDlg->Execute() ); + + if ( !bCancel ) + { + const SvxZoomItem& rZoomItem = (const SvxZoomItem&)pDlg->GetOutputItemSet()->Get( SID_ATTR_ZOOM ); + m_eZoomType = rZoomItem.GetType(); + m_nZoomValue = rZoomItem.GetValue(); + if ( m_eZoomType != SVX_ZOOM_PERCENT ) + m_nZoomValue = m_pMyOwnView->getZoomFactor( m_eZoomType ); + + impl_zoom_nothrow(); + } // if ( !bCancel ) + } + catch(uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) + delete pDefaults[i]; + } // if(pFact) +} +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 8fef01ffd020..cf462c8b1456 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -63,6 +63,9 @@ #include <connectivity/dbtools.hxx> +#include <vcl/lineinfo.hxx> +#include "ColorChanger.hxx" + #include <svtools/itempool.hxx> #include <svtools/extcolorcfg.hxx> #include <unotools/confignode.hxx> @@ -101,7 +104,6 @@ OReportSection::OReportSection(OSectionWindow* _pParent,const uno::Reference< re EnableChildTransparentMode(); SetHelpId(HID_REPORTSECTION); SetMapMode( MapMode( MAP_100TH_MM ) ); - EnableMapMode(); try { @@ -114,7 +116,6 @@ OReportSection::OReportSection(OSectionWindow* _pParent,const uno::Reference< re m_pFunc.reset(new DlgEdFuncSelect( this )); m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( /* m_pParent->getViewsWindow()->getView()->getReportView()->getController().getORB() */ ) ); - Show(); } //------------------------------------------------------------------------------ OReportSection::~OReportSection() @@ -140,6 +141,8 @@ OReportSection::~OReportSection() //------------------------------------------------------------------------------ void OReportSection::Paint( const Rectangle& rRect ) { + Window::Paint(rRect); + if ( m_pView ) { // repaint, get PageView and prepare Region @@ -169,9 +172,7 @@ void OReportSection::Paint( const Rectangle& rRect ) pPgView->GetView().EndDrawLayers(*pTargetPaintWindow); } - - const Region aReg(rRect); - m_pView->CompleteRedraw(this,aReg); + m_pView->CompleteRedraw(this,aPaintRectRegion); } } //------------------------------------------------------------------------------ @@ -246,7 +247,18 @@ void OReportSection::fill() m_pView->SetDesignMode( TRUE ); m_pView->StartListening( *m_pModel ); - Resize(); + /*Resize();*/ + if ( m_xSection.is() && m_pPage && m_pView ) + { + uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition(); + m_pPage->SetSize( Size( getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight()) ); + const Size aPageSize = m_pPage->GetSize(); + const sal_Int32 nWorkAreaLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); + const sal_Int32 nWorkAreaRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); + m_pView->SetWorkArea( Rectangle( Point( nWorkAreaLeftMargin, 0), Size(aPageSize.Width() - nWorkAreaLeftMargin - nWorkAreaRightMargin,aPageSize.Height()) ) ); + } // if ( m_xSection.is() && m_pPage && m_pView ) + + //SetBackground( Wallpaper( COL_BLUE )); } // ----------------------------------------------------------------------------- void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyCopiedObjects,bool _bForce) diff --git a/reportdesign/source/ui/report/ReportWindow.cxx b/reportdesign/source/ui/report/ReportWindow.cxx index 3a71951ea152..3d04b2898669 100644 --- a/reportdesign/source/ui/report/ReportWindow.cxx +++ b/reportdesign/source/ui/report/ReportWindow.cxx @@ -134,7 +134,6 @@ void OReportWindow::addSection(const uno::Reference< report::XSection >& _xSecti m_aViewsWindow.addSection(_xSection,_sColorEntry,_nPosition); - Resize(); m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight()); } //------------------------------------------------------------------------------ @@ -152,11 +151,11 @@ void OReportWindow::showRuler(sal_Bool _bShow) //------------------------------------------------------------------------------ sal_Int32 OReportWindow::getMaxMarkerWidth(sal_Bool _bWithEnd) const { - Fraction aStartWith(long(REPORT_STARTMARKER_WIDTH)); - aStartWith *= m_aViewsWindow.GetMapMode().GetScaleX(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= m_aViewsWindow.GetMapMode().GetScaleX(); if ( _bWithEnd ) - aStartWith += Fraction(long(REPORT_ENDMARKER_WIDTH)); - return sal_Int32((long)aStartWith); + aStartWidth += Fraction(long(REPORT_ENDMARKER_WIDTH)); + return sal_Int32((long)aStartWidth); } //------------------------------------------------------------------------------ sal_Int32 OReportWindow::GetTotalWidth() const @@ -164,11 +163,14 @@ sal_Int32 OReportWindow::GetTotalWidth() const sal_Int32 nWidth = 0; if ( !m_aViewsWindow.empty() ) { - Fraction aStartWith(long(REPORT_ENDMARKER_WIDTH + REPORT_STARTMARKER_WIDTH)); - aStartWith *= m_aViewsWindow.GetMapMode().GetScaleX(); + Fraction aStartWidth(long(REPORT_ENDMARKER_WIDTH + REPORT_STARTMARKER_WIDTH )); + const Fraction aZoom(m_pView->getController().getZoomValue(),100); + aStartWidth *= aZoom; // m_aViewsWindow.GetMapMode().GetScaleX();; const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width; - const Size aPageSize = m_aViewsWindow.LogicToPixel(Size(nPaperWidth,0)); - nWidth = aPageSize.Width() + long(aStartWith); + Fraction aPaperWidth(nPaperWidth,1); + aPaperWidth *= aZoom; + const Size aPageSize = LogicToPixel(Size(aPaperWidth,0)); + nWidth = aPageSize.Width() + long(aStartWidth); } return nWidth; } @@ -179,16 +181,15 @@ void OReportWindow::Resize() if ( !m_aViewsWindow.empty() ) { const Size aTotalOutputSize = GetOutputSizePixel(); - Fraction aStartWith(long(REPORT_STARTMARKER_WIDTH)); - aStartWith *= m_aViewsWindow.GetMapMode().GetScaleX(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)*m_pView->getController().getZoomValue(),100); - const Point aOffset = LogicToPixel( Point( SECTION_OFFSET, SECTION_OFFSET ), MAP_APPFONT ); - Point aStartPoint((long)aStartWith + aOffset.X(),0); + const Point aOffset = LogicToPixel( Point( SECTION_OFFSET, 0 ), MAP_APPFONT ); + Point aStartPoint((long)aStartWidth + aOffset.X(),0); uno::Reference<report::XReportDefinition> xReportDefinition = getReportView()->getController().getReportDefinition(); const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width; sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); - Size aPageSize = m_aViewsWindow.LogicToPixel(Size(nPaperWidth,0)); + Size aPageSize = m_aViewsWindow.LogicToPixel(Size(nPaperWidth ,0)); nLeftMargin = m_aViewsWindow.LogicToPixel(Size(nLeftMargin,0)).Width(); nRightMargin = m_aViewsWindow.LogicToPixel(Size(nRightMargin,0)).Width(); @@ -211,9 +212,9 @@ void OReportWindow::Resize() } } //------------------------------------------------------------------------------ -Point OReportWindow::getScrollOffset() const +Point OReportWindow::getThumbPos() const { - return m_pParent->getScrollOffset(); + return m_pParent->getThumbPos(); } //------------------------------------------------------------------------------ void OReportWindow::ImplInitSettings() @@ -235,22 +236,22 @@ void OReportWindow::DataChanged( const DataChangedEvent& rDCEvt ) //------------------------------------------------------------------------------ sal_Int32 OReportWindow::GetTotalHeight() const { - return m_aHRuler.GetSizePixel().Height() + m_aViewsWindow.getTotalHeight(); + return m_aViewsWindow.getTotalHeight(); } //------------------------------------------------------------------------------ -void OReportWindow::ScrollChildren(long nDeltaX, long nDeltaY) +void OReportWindow::ScrollChildren(const Point& _aThumbPos) { - if ( nDeltaX ) + MapMode aMap = m_aHRuler.GetMapMode(); + Point aOrg( aMap.GetOrigin() ); + if ( aOrg.X() != (-_aThumbPos.X()) ) { - MapMode aMap = m_aHRuler.GetMapMode(); - Point aOrg( aMap.GetOrigin() ); - aMap.SetOrigin( Point(aOrg.X() - nDeltaX, aOrg.Y())); + aMap.SetOrigin( Point(- _aThumbPos.X(), aOrg.Y())); m_aHRuler.SetMapMode( aMap ); - m_aHRuler.Scroll(-nDeltaX,0); + m_aHRuler.Scroll(-(aOrg.X() + _aThumbPos.X()),0); } - - m_aViewsWindow.scrollChildren(nDeltaX,nDeltaY); + /*const Point aPos(PixelToLogic(_aThumbPos));*/ + m_aViewsWindow.scrollChildren(_aThumbPos); } //---------------------------------------------------------------------------- USHORT OReportWindow::getSectionCount() const @@ -258,11 +259,9 @@ USHORT OReportWindow::getSectionCount() const return m_aViewsWindow.getSectionCount(); } //---------------------------------------------------------------------------- -void OReportWindow::notifyHeightChanged() +void OReportWindow::notifySizeChanged() { m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight()); - //Resize(); - //Invalidate(INVALIDATE_TRANSPARENT); } //---------------------------------------------------------------------------- BOOL OReportWindow::HasSelection() @@ -371,7 +370,6 @@ void OReportWindow::setGridSnap(BOOL bOn) // ----------------------------------------------------------------------------- void OReportWindow::setDragStripes(BOOL bOn) { - m_aViewsWindow.setDragStripes(bOn); } // ----------------------------------------------------------------------------- @@ -385,13 +383,18 @@ sal_uInt32 OReportWindow::getMarkedObjectCount() const return m_aViewsWindow.getMarkedObjectCount(); } // ----------------------------------------------------------------------------- -void OReportWindow::zoom(const sal_Int16 _nZoom) +void OReportWindow::zoom(const Fraction& _aZoom) { - m_aHRuler.SetZoom(Fraction(_nZoom,100)); + m_aHRuler.SetZoom(_aZoom); m_aHRuler.Invalidate(); - m_aViewsWindow.zoom(_nZoom); - notifyHeightChanged(); + //setZoomFactor(_aZoom,*this); // if this will be include the H - ruler has the wrong size + m_aViewsWindow.zoom(_aZoom); + + notifySizeChanged(); + const Point aNewThumbPos( m_pParent->getThumbPos() ); + + ScrollChildren( aNewThumbPos ); Resize(); Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); @@ -401,7 +404,43 @@ void OReportWindow::fillControlModelSelection(::std::vector< uno::Reference< uno { m_aViewsWindow.fillControlModelSelection(_rSelection); } +// ----------------------------------------------------------------------------- +sal_Int32 OReportWindow::impl_getRealPixelWidth() const +{ + const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width; + MapMode aMap( MAP_100TH_MM ); + const Size aPageSize = LogicToPixel(Size(nPaperWidth,0),aMap); + return aPageSize.Width() + REPORT_ENDMARKER_WIDTH + REPORT_STARTMARKER_WIDTH + SECTION_OFFSET; +} +// ----------------------------------------------------------------------------- +sal_uInt16 OReportWindow::getZoomFactor(SvxZoomType _eType) const +{ + sal_uInt16 nZoom(100); + const Size aSize( GetSizePixel() ); + switch( _eType) + { + case SVX_ZOOM_PERCENT: + nZoom = m_pView->getController().getZoomValue(); + break; + case SVX_ZOOM_OPTIMAL: + break; + case SVX_ZOOM_WHOLEPAGE: + { + nZoom = (USHORT)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth()); + MapMode aMap( MAP_100TH_MM ); + const Size aHeight = m_aViewsWindow.LogicToPixel(m_aViewsWindow.PixelToLogic(Size(0,GetTotalHeight() + m_aHRuler.GetSizePixel().Height())),aMap); + nZoom = ::std::min(nZoom,(USHORT)(long)Fraction(aSize.Height()*100,aHeight.Height())); + } + break; + case SVX_ZOOM_PAGEWIDTH: + nZoom = (USHORT)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth()); + break; + default: + break; + } + return nZoom; +} //================================================================== } //rptui //================================================================== diff --git a/reportdesign/source/ui/report/ScrollHelper.cxx b/reportdesign/source/ui/report/ScrollHelper.cxx index bbb9e2c8435e..9ab957796c39 100644 --- a/reportdesign/source/ui/report/ScrollHelper.cxx +++ b/reportdesign/source/ui/report/ScrollHelper.cxx @@ -46,13 +46,11 @@ namespace rptui using namespace ::com::sun::star; // ----------------------------------------------------------------------------- -void lcl_setScrollBar(sal_Int32 _nNewValue,sal_Int32 _nOffSet,const Point& _aPos,const Size& _aSize,ScrollBar& _rScrollBar) +void lcl_setScrollBar(sal_Int32 _nNewValue,const Point& _aPos,const Size& _aSize,ScrollBar& _rScrollBar) { _rScrollBar.SetPosSizePixel(_aPos,_aSize); _rScrollBar.SetPageSize( _nNewValue ); _rScrollBar.SetVisibleSize( _nNewValue ); - (void)_nOffSet; - //_rScrollBar.SetThumbPos( -_nOffSet ); } // ----------------------------------------------------------------------------- @@ -97,6 +95,7 @@ void OScrollWindowHelper::impl_initScrollBar( ScrollBar& _rScrollBar ) const aStyle.SetDragFullOptions( aStyle.GetDragFullOptions() | DRAGFULL_OPTION_SCROLL ); // live scrolling aSettings.SetStyleSettings( aStyle ); _rScrollBar.SetSettings( aSettings ); + //_rScrollBar.SetMapMode( MapMode( MAP_100TH_MM ) ); _rScrollBar.SetScrollHdl( LINK( this, OScrollWindowHelper, ScrollHdl ) ); _rScrollBar.SetLineSize( SCR_LINE_SIZE ); @@ -115,16 +114,12 @@ void OScrollWindowHelper::setTotalSize(sal_Int32 _nWidth ,sal_Int32 _nHeight) { m_aTotalPixelSize.Width() = _nWidth; m_aTotalPixelSize.Height() = _nHeight; - m_aHScroll.SetRangeMax( m_aTotalPixelSize.Width() ); + + // now set the ranges without start marker + Fraction aStartWidth(REPORT_STARTMARKER_WIDTH * m_pParent->getController().getZoomValue(),100); + long nWidth = long(_nWidth - (double)aStartWidth); + m_aHScroll.SetRangeMax( nWidth ); m_aVScroll.SetRangeMax( m_aTotalPixelSize.Height() ); - /*Point aNewPixOffset(-m_aHScroll.GetThumbPos(),-m_aVScroll.GetThumbPos()); - if ( m_aPixOffset != aNewPixOffset ) - { - const long nX = aNewPixOffset.X() - m_aPixOffset.X(); - const long nY = aNewPixOffset.Y() - m_aPixOffset.Y(); - impl_scrollContent( -nX, -nY ); - m_aPixOffset = aNewPixOffset; - }*/ Resize(); } @@ -136,6 +131,7 @@ Size OScrollWindowHelper::ResizeScrollBars() if ( aOutPixSz.Width() == 0 || aOutPixSz.Height() == 0 ) return aOutPixSz; + aOutPixSz.Height() -= m_aReportWindow.getRulerHeight(); // determine the size of the output-area and if we need scrollbars const long nScrSize = GetSettings().GetStyleSettings().GetScrollBarSize(); bool bVVisible = false; // by default no vertical-ScrollBar @@ -164,7 +160,7 @@ Size OScrollWindowHelper::ResizeScrollBars() } while ( bChanged ); // until no visibility has changed - const Point aOldPixOffset( m_aPixOffset ); + aOutPixSz.Height() += m_aReportWindow.getRulerHeight(); // show or hide scrollbars m_aVScroll.Show( bVVisible ); @@ -182,66 +178,29 @@ Size OScrollWindowHelper::ResizeScrollBars() const Point aOffset = LogicToPixel( Point( SECTION_OFFSET, SECTION_OFFSET ), MAP_APPFONT ); // resize scrollbars and set their ranges { - Fraction aStartWith(long(REPORT_STARTMARKER_WIDTH)); - const Fraction aZoom(m_pParent->getController().getZoomValue(),100); - aStartWith *= aZoom; - - const sal_Int32 nOldThumbPos = m_aHScroll.GetThumbPos(); - const sal_Int32 nNewWidth = aOutPixSz.Width() - aOffset.X(); - lcl_setScrollBar(nNewWidth,m_aPixOffset.X(),Point( (long)aStartWith + aOffset.X(), aOutPixSz.Height() ),Size( aOutPixSz.Width() - long(aStartWith), nScrSize ),m_aHScroll); - m_aPixOffset.X() += nOldThumbPos - m_aHScroll.GetThumbPos(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH*m_pParent->getController().getZoomValue()),100); + const sal_Int32 nNewWidth = aOutPixSz.Width() - aOffset.X() - (long)aStartWidth; + lcl_setScrollBar(nNewWidth,Point( (long)aStartWidth + aOffset.X(), aOutPixSz.Height() ),Size( nNewWidth, nScrSize ),m_aHScroll); } { - const sal_Int32 nOldThumbPos = m_aVScroll.GetThumbPos(); const sal_Int32 nNewHeight = aOutPixSz.Height() - m_aReportWindow.getRulerHeight(); - lcl_setScrollBar(nNewHeight,m_aPixOffset.Y(),Point( aOutPixSz.Width(), m_aReportWindow.getRulerHeight() ),Size( nScrSize,nNewHeight),m_aVScroll); - m_aPixOffset.Y() += nOldThumbPos - m_aVScroll.GetThumbPos(); + lcl_setScrollBar(nNewHeight,Point( aOutPixSz.Width(), m_aReportWindow.getRulerHeight() ),Size( nScrSize,nNewHeight),m_aVScroll); } - // select the shifted map-mode - if ( m_aPixOffset != aOldPixOffset ) - { - const long nX = m_aPixOffset.X() - aOldPixOffset.X(); - const long nY = m_aPixOffset.Y() - aOldPixOffset.Y(); - impl_scrollContent( -nX, -nY ); - } return aOutPixSz; } //------------------------------------------------------------------------------ -void OScrollWindowHelper::impl_scrollContent( long nDeltaX, long nDeltaY ) -{ - m_aReportWindow.ScrollChildren(nDeltaX,nDeltaY); -} -//------------------------------------------------------------------------------ void OScrollWindowHelper::Resize() { OScrollWindowHelper_BASE::Resize(); - // Size aSize = GetOutputSizePixel(); - // const Size aMinSize(getMaxMarkerWidth(sal_False),0); - // bool bResize = false; - //if( aSize.Width() < aMinSize.Width() ) - //{ - // aSize.setWidth( aMinSize.Width() ); - // bResize = true; - //} - //if( aSize.Height() < aMinSize.Height() ) - //{ - // aSize.setHeight( aMinSize.Height() ); - // bResize = true; - //} - //if( bResize ) - // { - // //static_cast<SplitWindow*>(GetParent())->SetItemSize(2,aSize.getWidth()); - // SetOutputSizePixel( aSize ); - // } const Size aTotalOutputSize = ResizeScrollBars(); - m_aReportWindow.SetPosSizePixel(Point( 0, 0 ),Size( aTotalOutputSize.Width(), aTotalOutputSize.Height())); + m_aReportWindow.SetPosSizePixel(Point( 0, 0 ),aTotalOutputSize); } //------------------------------------------------------------------------------ IMPL_LINK( OScrollWindowHelper, ScrollHdl, ScrollBar*, /*pScroll*/ ) { - impl_scrollContent( m_aHScroll.GetDelta(), m_aVScroll.GetDelta() ); + m_aReportWindow.ScrollChildren( getThumbPos() ); return 0; } //------------------------------------------------------------------------------ @@ -416,7 +375,7 @@ void OScrollWindowHelper::DataChanged( const DataChangedEvent& rDCEvt ) // ----------------------------------------------------------------------------- void OScrollWindowHelper::_propertyChanged(const beans::PropertyChangeEvent& /*_rEvent*/) throw( uno::RuntimeException) { - m_aReportWindow.notifyHeightChanged(); + m_aReportWindow.notifySizeChanged(); } // ----------------------------------------------------------------------------- void OScrollWindowHelper::setGridSnap(BOOL bOn) @@ -439,9 +398,10 @@ sal_uInt32 OScrollWindowHelper::getMarkedObjectCount() const return m_aReportWindow.getMarkedObjectCount(); } // ----------------------------------------------------------------------------- -void OScrollWindowHelper::zoom(const sal_Int16 _nZoom) +void OScrollWindowHelper::zoom(const Fraction& _aZoom) { - m_aReportWindow.zoom(_nZoom); + m_aReportWindow.zoom(_aZoom); + Resize(); Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_TRANSPARENT); } // ----------------------------------------------------------------------------- @@ -449,7 +409,11 @@ void OScrollWindowHelper::fillControlModelSelection(::std::vector< uno::Referenc { m_aReportWindow.fillControlModelSelection(_rSelection); } - +// ----------------------------------------------------------------------------- +sal_uInt16 OScrollWindowHelper::getZoomFactor(SvxZoomType _eType) const +{ + return m_aReportWindow.getZoomFactor(_eType); +} //============================================================================== } // rptui //============================================================================== diff --git a/reportdesign/source/ui/report/SectionWindow.cxx b/reportdesign/source/ui/report/SectionWindow.cxx index a54f8fecd6e7..2d67af00d7d0 100644 --- a/reportdesign/source/ui/report/SectionWindow.cxx +++ b/reportdesign/source/ui/report/SectionWindow.cxx @@ -68,23 +68,26 @@ OSectionWindow::OSectionWindow( OViewsWindow* _pParent,const uno::Reference< rep { DBG_CTOR( rpt_OSectionWindow,NULL); SetUniqueId(UID_RPT_SECTIONSWINDOW); - SetMapMode( MapMode( MAP_100TH_MM ) ); - EnableMapMode(); + const MapMode& rMapMode = _pParent->GetMapMode(); + SetMapMode( rMapMode ); ImplInitSettings(); - // TRY m_aSplitter.SetMapMode( MapMode( MAP_100TH_MM ) ); - m_aSplitter.EnableMapMode(); - m_aSplitter.SetStartSplitHdl(LINK(this, OSectionWindow,StartSplitHdl)); m_aSplitter.SetSplitHdl(LINK(this, OSectionWindow,SplitHdl)); m_aSplitter.SetEndSplitHdl(LINK(this, OSectionWindow,EndSplitHdl)); m_aSplitter.SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() )); m_aSplitter.SetSplitPosPixel(m_aSplitter.LogicToPixel(Size(0,_xSection->getHeight())).Height()); - m_aSplitter.Show(); + m_aStartMarker.setCollapsedHdl(LINK(this,OSectionWindow,Collapsed)); + m_aStartMarker.zoom(rMapMode.GetScaleX()); + setZoomFactor(rMapMode.GetScaleX(),m_aReportSection); + setZoomFactor(rMapMode.GetScaleX(),m_aSplitter); + setZoomFactor(rMapMode.GetScaleX(),m_aEndMarker); + + m_aSplitter.Show(); m_aStartMarker.Show(); m_aReportSection.Show(); m_aEndMarker.Show(); @@ -135,12 +138,13 @@ void OSectionWindow::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) { m_pParent->getView()->SetUpdateMode(FALSE); Resize(); - m_pParent->getView()->notifyHeightChanged(); + m_pParent->getView()->notifySizeChanged(); m_pParent->resize(*this); m_pParent->getView()->SetUpdateMode(TRUE); m_aStartMarker.Invalidate(INVALIDATE_NOERASE); m_aEndMarker.Invalidate(INVALIDATE_NOERASE); m_aReportSection.Invalidate(/*INVALIDATE_NOERASE*/); + getViewsWindow()->getView()->getReportView()->getController().resetZoomType(); // Invalidate(INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); // m_pParent->Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE|INVALIDATE_TRANSPARENT); // m_pParent->Invalidate(/*INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE |*/ INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); @@ -178,7 +182,7 @@ void OSectionWindow::setGroupSectionTitle(const uno::Reference< report::XGroup>& void OSectionWindow::ImplInitSettings() { SetBackground( ); - // SetBackground( Wallpaper( COL_RED )); + //SetBackground( Wallpaper( COL_RED )); } //----------------------------------------------------------------------------- void OSectionWindow::DataChanged( const DataChangedEvent& rDCEvt ) @@ -197,14 +201,12 @@ void OSectionWindow::Resize() { Window::Resize(); - //const Point aOffset = LogicToPixel( Point( SECTION_OFFSET, SECTION_OFFSET ), MAP_APPFONT ); - Size aOutputSize = GetOutputSizePixel(); Fraction aEndWidth(long(REPORT_ENDMARKER_WIDTH)); aEndWidth *= GetMapMode().GetScaleX(); - const Point aOffset = m_pParent->getView()->getScrollOffset(); - aOutputSize.Width() -= aOffset.X(); + const Point aThumbPos = m_pParent->getView()->getThumbPos(); + aOutputSize.Width() -= aThumbPos.X(); aOutputSize.Height() -= m_aSplitter.GetSizePixel().Height(); if ( m_aStartMarker.isCollapsed() ) @@ -214,7 +216,7 @@ void OSectionWindow::Resize() } else { - const bool bShowEndMarker = m_pParent->getView()->GetTotalWidth() <= (aOffset.X() + aOutputSize.Width() ); + const bool bShowEndMarker = m_pParent->getView()->GetTotalWidth() <= (aThumbPos.X() + aOutputSize.Width() ); Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); aStartWidth *= GetMapMode().GetScaleX(); @@ -229,6 +231,7 @@ void OSectionWindow::Resize() aSectionSize.Width() = aOutputSize.Width() - (long)aStartWidth; if ( bShowEndMarker ) aSectionSize.Width() -= (long)aEndWidth; + m_aReportSection.SetPosSizePixel(aReportPos,aSectionSize); // set splitter @@ -248,7 +251,7 @@ void OSectionWindow::Resize() void OSectionWindow::setCollapsed(sal_Bool _bCollapsed) { m_aReportSection.Show(_bCollapsed); - m_aEndMarker.Show/*setCollapsed*/(_bCollapsed); + m_aEndMarker.Show(_bCollapsed); m_aSplitter.Show(_bCollapsed); } //----------------------------------------------------------------------------- @@ -278,14 +281,15 @@ IMPL_LINK( OSectionWindow, Collapsed, OStartMarker *, _pMarker ) return 0L; } // ----------------------------------------------------------------------------- -void OSectionWindow::zoom(const sal_Int16 _nZoom) +void OSectionWindow::zoom(const Fraction& _aZoom) { - setZoomFactor(_nZoom,*this); - m_aStartMarker.zoom(_nZoom); - setZoomFactor(_nZoom,m_aReportSection); - setZoomFactor(_nZoom,m_aSplitter); - setZoomFactor(_nZoom,m_aEndMarker); - Resize(); + setZoomFactor(_aZoom,*this); + m_aStartMarker.zoom(_aZoom); + + setZoomFactor(_aZoom,m_aReportSection); + setZoomFactor(_aZoom,m_aSplitter); + setZoomFactor(_aZoom,m_aEndMarker); + //Resize(); Invalidate(/*INVALIDATE_UPDATE |*/ /* | INVALIDATE_TRANSPARENT *//*INVALIDATE_NOCHILDREN*/); } //----------------------------------------------------------------------------- @@ -338,34 +342,40 @@ IMPL_LINK( OSectionWindow, SplitHdl, Splitter*, _pSplitter ) return 0L; } // ----------------------------------------------------------------------------- -void lcl_scroll(Window& _rWindow,const Size& _aDelta) +void lcl_scroll(Window& _rWindow,const Point& _aDelta) { - _rWindow.Scroll(-_aDelta.Width(),-_aDelta.Height(),SCROLL_CHILDREN/*|SCROLL_CLIP*/); + _rWindow.Scroll(-_aDelta.X(),-_aDelta.Y()/*,SCROLL_CHILDREN*//*|SCROLL_CLIP*/); _rWindow.Invalidate(INVALIDATE_TRANSPARENT); } // ----------------------------------------------------------------------------- -void lcl_setMapMode(Window& _rWindow,long _nDeltaX, long _nDeltaY) +void lcl_setOrigin(Window& _rWindow,long _nX, long _nY) { MapMode aMap = _rWindow.GetMapMode(); - Point aOrg = aMap.GetOrigin(); - aMap.SetOrigin( Point(aOrg.X() - _nDeltaX, aOrg.Y() - _nDeltaY)); + aMap.SetOrigin( Point(- _nX, - _nY)); _rWindow.SetMapMode( aMap ); } //---------------------------------------------------------------------------- -void OSectionWindow::scrollChildren(long _nDeltaX) +void OSectionWindow::scrollChildren(long _nX) { - const Size aDelta( PixelToLogic(Size(_nDeltaX,0)) ); - lcl_setMapMode(m_aReportSection,aDelta.Width(), 0); + const Point aDelta( _nX,0 ); + + MapMode aMapMode( m_aReportSection.GetMapMode() ); + const Point aOld = aMapMode.GetOrigin(); + lcl_setOrigin(m_aReportSection,aDelta.X(), 0); + + aMapMode = m_aReportSection.GetMapMode(); + const Point aNew = aMapMode.GetOrigin(); + const Point aDiff = aOld - aNew; { - OWindowPositionCorrector aCorrector(&m_aReportSection,-_nDeltaX,0); - lcl_scroll(m_aReportSection,aDelta); + //OWindowPositionCorrector aCorrector(&m_aReportSection,-aDelta.Width(),0); + lcl_scroll(m_aReportSection,aDiff); } - // lcl_setMapMode(m_aEndMarker,_nDeltaX, 0); - lcl_scroll(m_aEndMarker,aDelta); + //lcl_setOrigin(m_aEndMarker,_nDeltaX, 0); + lcl_scroll(m_aEndMarker,m_aEndMarker.PixelToLogic(Point(_nX,0))); - lcl_setMapMode(m_aSplitter,_nDeltaX, 0); - lcl_scroll(m_aSplitter,aDelta); + lcl_setOrigin(m_aSplitter,_nX, 0); + lcl_scroll(m_aSplitter,aDiff); Resize(); } diff --git a/reportdesign/source/ui/report/StartMarker.cxx b/reportdesign/source/ui/report/StartMarker.cxx index b3e6d81f7a94..b525a42f5dd8 100644 --- a/reportdesign/source/ui/report/StartMarker.cxx +++ b/reportdesign/source/ui/report/StartMarker.cxx @@ -45,7 +45,6 @@ #include <svtools/smplhint.hxx> #define CORNER_SPACE 5 -#define TEXT_WIDTH 10 //===================================================================== namespace rptui @@ -64,7 +63,7 @@ OStartMarker::OStartMarker(OSectionWindow* _pParent,const ::rtl::OUString& _sCol : OColorListener(_pParent,_sColorEntry) ,m_aVRuler(this,WB_VERT) ,m_aText(this,WB_HYPHENATION) -,m_aImage(this,WB_LEFT|WB_TOP) +,m_aImage(this,WB_LEFT|WB_TOP|WB_SCALE) ,m_pParent(_pParent) ,m_bShowRuler(sal_True) { @@ -177,7 +176,7 @@ void OStartMarker::MouseButtonUp( const MouseEvent& rMEvt ) const Size aOutputSize = GetOutputSizePixel(); if( aPos.X() > aOutputSize.Width() || aPos.Y() > aOutputSize.Height() ) return; - Rectangle aRect(m_aImage.GetPosPixel(),m_aImage.GetImage().GetSizePixel()); + Rectangle aRect(m_aImage.GetPosPixel(),m_aImage.GetSizePixel()); if ( rMEvt.GetClicks() == 2 || aRect.IsInside( aPos ) ) { m_bCollapsed = !m_bCollapsed; @@ -237,25 +236,25 @@ void OStartMarker::Resize() const long nOutputWidth = aOutputSize.Width(); const long nOutputHeight = aOutputSize.Height(); + const long nVRulerWidth = m_aVRuler.GetSizePixel().Width(); + const Point aRulerPos(nOutputWidth - nVRulerWidth,0); + m_aVRuler.SetPosSizePixel(aRulerPos,Size(nVRulerWidth,nOutputHeight)); + Size aImageSize = m_aImage.GetImage().GetSizePixel(); const MapMode& rMapMode = GetMapMode(); aImageSize.Width() = long(aImageSize.Width() * (double)rMapMode.GetScaleX()); aImageSize.Height() = long(aImageSize.Height() * (double)rMapMode.GetScaleY()); - const long nVRulerWidth = m_aVRuler.GetSizePixel().Width(); - const Point aRulerPos(nOutputWidth - nVRulerWidth/* - 5*/,0); + Fraction aExtraWidth(long(REPORT_EXTRA_SPACE)); aExtraWidth *= rMapMode.GetScaleX(); Point aPos(aImageSize.Width() + (long)(aExtraWidth + aExtraWidth), aExtraWidth); - - m_aText.SetPosSizePixel(aPos,Size(aRulerPos.X() - aPos.X(),::std::max<sal_Int32>(nOutputHeight - 2*aPos.Y(),LogicToPixel(Size(0,m_aText.GetTextHeight())).Height()))); + const long nHeight = ::std::max<sal_Int32>(nOutputHeight - 2*aPos.Y(),LogicToPixel(Size(0,m_aText.GetTextHeight())).Height()); + m_aText.SetPosSizePixel(aPos,Size(aRulerPos.X() - aPos.X(),nHeight)); aPos.X() = aExtraWidth; aPos.Y() += static_cast<sal_Int32>((LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() - aImageSize.Height()) * 0.5) ; - m_aImage.SetPosSizePixel(aPos,aImageSize);/*Size(aImageSize.Width() + (long)aExtraWidth,aImageSize.Height() + (long)aExtraWidth));*/ - //m_aImage.SetPosPixel(aPos); - - m_aVRuler.SetPosSizePixel(aRulerPos,Size(nVRulerWidth,nOutputHeight)); + m_aImage.SetPosSizePixel(aPos,aImageSize); } // ----------------------------------------------------------------------------- void OStartMarker::setTitle(const String& _sTitle) @@ -314,13 +313,11 @@ void OStartMarker::setCollapsed(sal_Bool _bCollapsed) showRuler(_bCollapsed); } // ----------------------------------------------------------------------- -void OStartMarker::zoom(const sal_Int16 _nZoom) +void OStartMarker::zoom(const Fraction& _aZoom) { - setZoomFactor(_nZoom,*this); - m_aVRuler.SetZoom(Fraction(_nZoom,100)); - // setZoomFactor(_nZoom,m_aVRuler); - setZoomFactor(_nZoom,m_aText); - setZoomFactor(_nZoom,m_aImage); + setZoomFactor(_aZoom,*this); + m_aVRuler.SetZoom(_aZoom); + setZoomFactor(_aZoom,m_aText); Resize(); Invalidate(); } diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index bc82a3b38d75..f51074e14d6f 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -189,7 +189,6 @@ OViewsWindow::OViewsWindow( OReportWindow* _pReportWindow) SetPaintTransparent(TRUE); SetUniqueId(UID_RPT_VIEWSWINDOW); SetMapMode( MapMode( MAP_100TH_MM ) ); - EnableMapMode(); StartListening(m_aColorConfig); ImplInitSettings(); } @@ -251,11 +250,12 @@ void OViewsWindow::resize(const OSectionWindow& _rSectionWindow) pSectionWindow->getStartMarker().Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT ); } } // for (;aIter != aEnd ; ++aIter,++nPos) - Fraction aStartWith(long(REPORT_STARTMARKER_WIDTH)); - aStartWith *= GetMapMode().GetScaleX(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= GetMapMode().GetScaleX(); Size aOut = GetOutputSizePixel(); - aOut.Width() = aStartWith; + aOut.Width() = aStartWidth; aOut = PixelToLogic(aOut); + m_pParent->notifySizeChanged(); Rectangle aRect(PixelToLogic(Point(0,0)),aOut); Invalidate(aRect,INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT); @@ -264,18 +264,18 @@ void OViewsWindow::resize(const OSectionWindow& _rSectionWindow) void OViewsWindow::Resize() { Window::Resize(); - if ( m_aSections.empty() ) - return; - - const Point aOffset = m_pParent->getScrollOffset(); - Point aStartPoint(0,aOffset.Y()); - TSectionsMap::iterator aIter = m_aSections.begin(); - TSectionsMap::iterator aEnd = m_aSections.end(); - for (USHORT nPos=0;aIter != aEnd ; ++aIter,++nPos) + if ( !m_aSections.empty() ) { - const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter); - impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,true); - } // for (;aIter != aEnd ; ++aIter) + const Point aOffset(m_pParent->getThumbPos()); + Point aStartPoint(0,-aOffset.Y()); + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (USHORT nPos=0;aIter != aEnd ; ++aIter,++nPos) + { + const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter); + impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,true); + } // for (;aIter != aEnd ; ++aIter) + } } // ----------------------------------------------------------------------------- void OViewsWindow::Paint( const Rectangle& rRect ) @@ -283,13 +283,13 @@ void OViewsWindow::Paint( const Rectangle& rRect ) Window::Paint( rRect ); Size aOut = GetOutputSizePixel(); - Fraction aStartWith(long(REPORT_STARTMARKER_WIDTH)); - aStartWith *= GetMapMode().GetScaleX(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= GetMapMode().GetScaleX(); - aOut.Width() -= (long)aStartWith; + aOut.Width() -= (long)aStartWidth; aOut = PixelToLogic(aOut); - Rectangle aRect(PixelToLogic(Point(aStartWith,0)),aOut); + Rectangle aRect(PixelToLogic(Point(aStartWidth,0)),aOut); Wallpaper aWall( m_aColorConfig.GetColorValue(::svtools::APPBACKGROUND).nColor ); DrawWallpaper(aRect,aWall); } @@ -317,7 +317,6 @@ void OViewsWindow::DataChanged( const DataChangedEvent& rDCEvt ) void OViewsWindow::addSection(const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry,USHORT _nPosition) { ::boost::shared_ptr<OSectionWindow> pSectionWindow( new OSectionWindow(this,_xSection,_sColorEntry) ); - m_aSections.insert(getIteratorAtPos(_nPosition) , TSectionsMap::value_type(pSectionWindow)); m_pParent->setMarked(&pSectionWindow->getReportSection().getSectionView(),m_aSections.size() == 1); @@ -361,7 +360,6 @@ sal_Int32 OViewsWindow::getTotalHeight() const { nHeight += (*aIter)->GetSizePixel().Height(); } - return nHeight; } //---------------------------------------------------------------------------- @@ -1735,53 +1733,59 @@ void OViewsWindow::collapseSections(const uno::Sequence< beans::PropertyValue>& } } // ----------------------------------------------------------------------------- -void OViewsWindow::zoom(const sal_Int16 _nZoom) +void OViewsWindow::zoom(const Fraction& _aZoom) { - Fraction aStartWith(long(REPORT_STARTMARKER_WIDTH)); - aStartWith *= GetMapMode().GetScaleX(); + const MapMode& aMapMode = GetMapMode(); + + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + if ( _aZoom < aMapMode.GetScaleX() ) + aStartWidth *= aMapMode.GetScaleX(); + else + aStartWidth *= _aZoom; - setZoomFactor(_nZoom,*this); + setZoomFactor(_aZoom,*this); TSectionsMap::iterator aIter = m_aSections.begin(); TSectionsMap::iterator aEnd = m_aSections.end(); for (;aIter != aEnd ; ++aIter) { - (*aIter)->zoom(_nZoom); + (*aIter)->zoom(_aZoom); } // for (;aIter != aEnd ; ++aIter) Resize(); Size aOut = GetOutputSizePixel(); - aOut.Width() = aStartWith; + aOut.Width() = aStartWidth; aOut = PixelToLogic(aOut); Rectangle aRect(PixelToLogic(Point(0,0)),aOut); Invalidate(aRect,/*INVALIDATE_NOERASE | */INVALIDATE_NOCHILDREN /*| INVALIDATE_TRANSPARENT*/); } //---------------------------------------------------------------------------- -void OViewsWindow::scrollChildren(long _nDeltaX, long _nDeltaY) +void OViewsWindow::scrollChildren(const Point& _aThumbPos) { - const Size aDelta( PixelToLogic(Size(_nDeltaX,_nDeltaY)) ); - if ( _nDeltaY ) + const Point aPos(PixelToLogic(_aThumbPos)); { - MapMode aMap = GetMapMode(); - Point aOrg = aMap.GetOrigin(); - aMap.SetOrigin( Point(aOrg.X() , aOrg.Y() - _nDeltaY)); - SetMapMode( aMap ); - OWindowPositionCorrector aCorrector(this,0,-_nDeltaY); - Scroll(0,-aDelta.Height(),SCROLL_CHILDREN); + MapMode aMapMode = GetMapMode(); + const Point aOld = aMapMode.GetOrigin(); + aMapMode.SetOrigin(m_pParent->GetMapMode().GetOrigin()); + + const Point aPosY(m_pParent->PixelToLogic(_aThumbPos,aMapMode)); + + aMapMode.SetOrigin( Point(aOld.X() , - aPosY.Y())); + SetMapMode( aMapMode ); + //OWindowPositionCorrector aCorrector(this,0,-( aOld.Y() + aPosY.Y())); + Scroll(0, -( aOld.Y() + aPosY.Y()),SCROLL_CHILDREN); + Resize(); Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_TRANSPARENT); } - if ( _nDeltaX ) + TSectionsMap::iterator aIter = m_aSections.begin(); + TSectionsMap::iterator aEnd = m_aSections.end(); + for (;aIter != aEnd ; ++aIter) { - TSectionsMap::iterator aIter = m_aSections.begin(); - TSectionsMap::iterator aEnd = m_aSections.end(); - for (;aIter != aEnd ; ++aIter) - { - (*aIter)->scrollChildren(_nDeltaX); - } // for (;aIter != aEnd ; ++aIter) - } + (*aIter)->scrollChildren(aPos.X()); + } // for (;aIter != aEnd ; ++aIter) } // ----------------------------------------------------------------------------- void OViewsWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx index 01dade9ca42d..e852beac5ff6 100644 --- a/reportdesign/source/ui/report/dlgedfunc.cxx +++ b/reportdesign/source/ui/report/dlgedfunc.cxx @@ -91,17 +91,17 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) OScrollWindowHelper* pScrollWindow = pReportWindow->getScrollWindow(); Size aOut = pReportWindow->GetOutputSizePixel(); - Fraction aStartWith(long(REPORT_STARTMARKER_WIDTH)); - aStartWith *= m_pParent->GetMapMode().GetScaleX(); + Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); + aStartWidth *= m_pParent->GetMapMode().GetScaleX(); - aOut.Width() -= (long)aStartWith; + aOut.Width() -= (long)aStartWidth; - Rectangle aOutRect( pScrollWindow->getScrollOffset(), aOut ); + Rectangle aOutRect( pScrollWindow->getThumbPos(), aOut ); aOutRect = m_pParent->PixelToLogic( aOutRect ); //Rectangle aWorkArea = m_pParent->getView()->GetWorkArea(); Point aGcc3WorkaroundTemporary; Rectangle aWorkArea(aGcc3WorkaroundTemporary,pScrollWindow->getTotalSize()); - aWorkArea.Right() -= (long)aStartWith; + aWorkArea.Right() -= (long)aStartWidth; aWorkArea = pScrollWindow->PixelToLogic( aWorkArea ); if( !aOutRect.IsInside( rPos ) && aWorkArea.IsInside( rPos ) ) { @@ -388,6 +388,13 @@ sal_Bool DlgEdFunc::handleKeyEvent(const KeyEvent& _rEvent) } } break; + case KEY_DELETE: + if ( !rCode.IsMod1() && !rCode.IsMod2() ) + { + bReturn = TRUE; + break; + } // if ( !rCode.IsMod1() && !rCode.IsMod2() ) + // run through default: { bReturn = m_rView.KeyInput(_rEvent, m_pParent); diff --git a/reportdesign/source/ui/report/makefile.mk b/reportdesign/source/ui/report/makefile.mk index 7cc2c2befd6e..b7c700d141b3 100644 --- a/reportdesign/source/ui/report/makefile.mk +++ b/reportdesign/source/ui/report/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.5.2.1 $ # # This file is part of OpenOffice.org. # @@ -56,7 +56,6 @@ SLOFILES =\ $(SLO)$/dlgedclip.obj \ $(SLO)$/ReportWindow.obj \ $(SLO)$/DesignView.obj \ - $(SLO)$/InsertFunctions.obj \ $(SLO)$/propbrw.obj diff --git a/reportdesign/source/ui/report/report.src b/reportdesign/source/ui/report/report.src index 6612311d5c33..4a45d9c9e063 100644 --- a/reportdesign/source/ui/report/report.src +++ b/reportdesign/source/ui/report/report.src @@ -583,7 +583,7 @@ Image REPORT_TREE_ICON }; String RID_STR_COULD_NOT_CREATE_REPORT { - Text [ en-US ] = "An error occured while creating the report." ; + Text [ en-US ] = "An error occurred while creating the report." ; }; String RID_STR_CAUGHT_FOREIGN_EXCEPTION { diff --git a/reportdesign/uiconfig/dbreport/menubar/menubar.xml b/reportdesign/uiconfig/dbreport/menubar/menubar.xml index 0b84d9bcd326..3e678b5b2f37 100644 --- a/reportdesign/uiconfig/dbreport/menubar/menubar.xml +++ b/reportdesign/uiconfig/dbreport/menubar/menubar.xml @@ -1,168 +1,172 @@ <?xml version="1.0" encoding="UTF-8"?> <menu:menubar xmlns:menu="http://openoffice.org/2001/menu" menu:id="menubar"> - <menu:menu menu:id=".uno:PickList" > + <menu:menu menu:id=".uno:PickList" > + <menu:menupopup> + <menu:menuitem menu:id=".uno:AddDirect"/> + <menu:menuitem menu:id=".uno:Open"/> + <menu:menuitem menu:id=".uno:RecentFileList"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:AutoPilotMenu"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:CloseDoc"/> + <menu:menuitem menu:id=".uno:Save"/> + <menu:menuitem menu:id=".uno:SaveAs"/> + <menu:menuitem menu:id=".uno:SaveAll"/> + <menu:menuseparator/> + <menu:menu menu:id=".uno:ExportReportTo"> <menu:menupopup> - <menu:menuitem menu:id=".uno:AddDirect"/> - <menu:menuitem menu:id=".uno:Open"/> - <menu:menuitem menu:id=".uno:RecentFileList"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:AutoPilotMenu"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:CloseDoc"/> - <menu:menuitem menu:id=".uno:Save"/> - <menu:menuitem menu:id=".uno:SaveAs"/> - <menu:menuitem menu:id=".uno:SaveAll"/> - <menu:menuseparator/> - <menu:menu menu:id=".uno:ExportReportTo"> - <menu:menupopup> - <menu:menuitem menu:id=".uno:TextDocument"/> + <menu:menuitem menu:id=".uno:TextDocument"/> <menu:menuitem menu:id=".uno:Spreadsheet"/> - </menu:menupopup> - </menu:menu> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:Quit"/> </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:EditMenu" > + </menu:menu> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:Quit"/> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:EditMenu" > + <menu:menupopup> + <menu:menuitem menu:id=".uno:Undo"/> + <menu:menuitem menu:id=".uno:Redo"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:Cut"/> + <menu:menuitem menu:id=".uno:Copy"/> + <menu:menuitem menu:id=".uno:Paste"/> + <menu:menu menu:id=".uno:Select"> <menu:menupopup> - <menu:menuitem menu:id=".uno:Undo"/> - <menu:menuitem menu:id=".uno:Redo"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:Cut"/> - <menu:menuitem menu:id=".uno:Copy"/> - <menu:menuitem menu:id=".uno:Paste"/> - <menu:menuitem menu:id=".uno:SelectAll"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:Delete"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:PageHeaderFooter"/> - <menu:menuitem menu:id=".uno:ReportHeaderFooter"/> - <menu:menuitem menu:id=".uno:ColumnHeaderFooter"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:SelectReport"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:ExecuteReport"/> + <menu:menuitem menu:id=".uno:SelectAll"/> + <menu:menuitem menu:id=".uno:SelectAllLabels"/> + <menu:menuitem menu:id=".uno:SelectAllEdits"/> + <menu:menuitem menu:id=".uno:SelectReport"/> </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:ViewMenu" > + </menu:menu> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:Delete"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:PageHeaderFooter"/> + <menu:menuitem menu:id=".uno:ReportHeaderFooter"/> + <menu:menuitem menu:id=".uno:ColumnHeaderFooter"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:ExecuteReport"/> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:ViewMenu" > + <menu:menupopup> + <menu:menuitem menu:id=".uno:SwitchControlDesignMode"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:ControlProperties"/> + <menu:menuitem menu:id=".uno:AddField"/> + <menu:menuitem menu:id=".uno:DbSortingAndGrouping"/> + <menu:menuitem menu:id=".uno:ReportNavigator"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:AvailableToolbars"/> + <menu:menuitem menu:id=".uno:StatusBarVisible"/> + <menu:menuitem menu:id=".uno:ShowRuler"/> + <menu:menu menu:id=".uno:GridMenu" > <menu:menupopup> - <menu:menuitem menu:id=".uno:SwitchControlDesignMode"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:SubReportInNewWindow"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:ControlProperties"/> - <menu:menuitem menu:id=".uno:AddField"/> - <menu:menuitem menu:id=".uno:DbSortingAndGrouping"/> - <menu:menuitem menu:id=".uno:ReportNavigator"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:AvailableToolbars"/> - <menu:menuitem menu:id=".uno:StatusBarVisible"/> - <menu:menuitem menu:id=".uno:ShowRuler"/> - <menu:menu menu:id=".uno:GridMenu" > - <menu:menupopup> - <menu:menuitem menu:id=".uno:GridVisible"/> - <menu:menuitem menu:id=".uno:GridUse"/> - </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:SnapLinesMenu"> - <menu:menupopup> - <menu:menuitem menu:id=".uno:HelplinesMove"/> - </menu:menupopup> - </menu:menu> + <menu:menuitem menu:id=".uno:GridVisible"/> + <menu:menuitem menu:id=".uno:GridUse"/> </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:InsertMenu" > + </menu:menu> + <menu:menu menu:id=".uno:SnapLinesMenu"> <menu:menupopup> - <menu:menuitem menu:id=".uno:InsertPageNumberField"/> - <menu:menuitem menu:id=".uno:InsertDateTimeField"/> - <menu:menuseparator/> - <menu:menu menu:id=".uno:GraphicMenu"> - <menu:menupopup> - <menu:menuitem menu:id=".uno:InsertGraphic"/> - </menu:menupopup> - </menu:menu> + <menu:menuitem menu:id=".uno:HelplinesMove"/> </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:FormatMenu" > + </menu:menu> + <menu:menuitem menu:id=".uno:Zoom"/> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:InsertMenu" > + <menu:menupopup> + <menu:menuitem menu:id=".uno:InsertPageNumberField"/> + <menu:menuitem menu:id=".uno:InsertDateTimeField"/> + <menu:menuseparator/> + <menu:menu menu:id=".uno:GraphicMenu"> <menu:menupopup> - <menu:menuitem menu:id=".uno:ConditionalFormatting"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:FontDialog"/> - <menu:menuitem menu:id=".uno:PageDialog"/> - <menu:menuseparator/> - <menu:menu menu:id=".uno:ArrangeMenu"> - <menu:menupopup> - <menu:menuitem menu:id=".uno:BringToFront"/> - <menu:menuitem menu:id=".uno:ObjectBackOne"/> - <menu:menuitem menu:id=".uno:ObjectForwardOne"/> - <menu:menuitem menu:id=".uno:SendToBack"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:SetObjectToForeground"/> - <menu:menuitem menu:id=".uno:SetObjectToBackground"/> - </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:ObjectAlign" > - <menu:menupopup> - <menu:menuitem menu:id=".uno:ObjectAlignLeft"/> - <menu:menuitem menu:id=".uno:AlignCenter"/> - <menu:menuitem menu:id=".uno:ObjectAlignRight"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:AlignUp"/> - <menu:menuitem menu:id=".uno:AlignMiddle"/> - <menu:menuitem menu:id=".uno:AlignDown"/> - </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:ObjectResize" > - <menu:menupopup> - <menu:menuitem menu:id=".uno:SmallestWidth"/> - <menu:menuitem menu:id=".uno:GreatestWidth"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:SmallestHeight"/> - <menu:menuitem menu:id=".uno:GreatestHeight"/> - </menu:menupopup> - </menu:menu> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:Distribution"/> + <menu:menuitem menu:id=".uno:InsertGraphic"/> </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:ToolsMenu" > + </menu:menu> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:FormatMenu" > + <menu:menupopup> + <menu:menuitem menu:id=".uno:ConditionalFormatting"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:FontDialog"/> + <menu:menuitem menu:id=".uno:PageDialog"/> + <menu:menuseparator/> + <menu:menu menu:id=".uno:ArrangeMenu"> <menu:menupopup> - <menu:menu menu:id=".uno:MacrosMenu" > - <menu:menupopup> - <menu:menuitem menu:id=".uno:MacroRecorder"/> - <menu:menuitem menu:id=".uno:RunMacro"/> - <menu:menu menu:id=".uno:ScriptOrganizer"/> - <menu:menuitem menu:id=".uno:MacroSignature"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:MacroOrganizer?TabId:short=1"/> - </menu:menupopup> - </menu:menu> - <menu:menuitem menu:id="service:com.sun.star.deployment.ui.PackageManagerDialog"/> - <menu:menuitem menu:id=".uno:ConfigureDialog"/> - <menu:menuitem menu:id=".uno:OptionsTreeDialog"/> + <menu:menuitem menu:id=".uno:BringToFront"/> + <menu:menuitem menu:id=".uno:ObjectBackOne"/> + <menu:menuitem menu:id=".uno:ObjectForwardOne"/> + <menu:menuitem menu:id=".uno:SendToBack"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:SetObjectToForeground"/> + <menu:menuitem menu:id=".uno:SetObjectToBackground"/> </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:WindowList" > + </menu:menu> + <menu:menu menu:id=".uno:ObjectAlign" > <menu:menupopup> - <menu:menuitem menu:id=".uno:NewWindow"/> - <menu:menuitem menu:id=".uno:CloseWin"/> - <menu:menuseparator/> + <menu:menuitem menu:id=".uno:ObjectAlignLeft"/> + <menu:menuitem menu:id=".uno:AlignCenter"/> + <menu:menuitem menu:id=".uno:ObjectAlignRight"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:AlignUp"/> + <menu:menuitem menu:id=".uno:AlignMiddle"/> + <menu:menuitem menu:id=".uno:AlignDown"/> </menu:menupopup> - </menu:menu> - <menu:menu menu:id=".uno:HelpMenu"> + </menu:menu> + <menu:menu menu:id=".uno:ObjectResize" > <menu:menupopup> - <menu:menuitem menu:id=".uno:HelpIndex"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:ExtendedHelp"/> - <menu:menuitem menu:id=".uno:HelpTip"/> - <menu:menuitem menu:id=".uno:ActiveHelp"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:HelperDialog"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:HelpSupport"/> - <menu:menuitem menu:id=".uno:OnlineRegistrationDlg"/> - <menu:menuseparator/> - <menu:menuitem menu:id=".uno:About"/> + <menu:menuitem menu:id=".uno:SmallestWidth"/> + <menu:menuitem menu:id=".uno:GreatestWidth"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:SmallestHeight"/> + <menu:menuitem menu:id=".uno:GreatestHeight"/> </menu:menupopup> - </menu:menu> + </menu:menu> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:Distribution"/> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:ToolsMenu" > + <menu:menupopup> + <menu:menu menu:id=".uno:MacrosMenu" > + <menu:menupopup> + <menu:menuitem menu:id=".uno:MacroRecorder"/> + <menu:menuitem menu:id=".uno:RunMacro"/> + <menu:menu menu:id=".uno:ScriptOrganizer"/> + <menu:menuitem menu:id=".uno:MacroSignature"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:MacroOrganizer?TabId:short=1"/> + </menu:menupopup> + </menu:menu> + <menu:menuitem menu:id="service:com.sun.star.deployment.ui.PackageManagerDialog"/> + <menu:menuitem menu:id=".uno:ConfigureDialog"/> + <menu:menuitem menu:id=".uno:OptionsTreeDialog"/> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:WindowList" > + <menu:menupopup> + <menu:menuitem menu:id=".uno:NewWindow"/> + <menu:menuitem menu:id=".uno:CloseWin"/> + <menu:menuseparator/> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:HelpMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:HelpIndex"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:ExtendedHelp"/> + <menu:menuitem menu:id=".uno:HelpTip"/> + <menu:menuitem menu:id=".uno:ActiveHelp"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:HelperDialog"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:HelpSupport"/> + <menu:menuitem menu:id=".uno:OnlineRegistrationDlg"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:About"/> + </menu:menupopup> + </menu:menu> </menu:menubar> diff --git a/reportdesign/uiconfig/dbreport/statusbar/statusbar.xml b/reportdesign/uiconfig/dbreport/statusbar/statusbar.xml index 74a549121c91..7e50780b633d 100644 --- a/reportdesign/uiconfig/dbreport/statusbar/statusbar.xml +++ b/reportdesign/uiconfig/dbreport/statusbar/statusbar.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE statusbar:statusbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "statusbar.dtd"> <statusbar:statusbar xmlns:statusbar="http://openoffice.org/2001/statusbar" xmlns:xlink="http://www.w3.org/1999/xlink"> - <statusbar:statusbaritem xlink:href=".uno:ReportStatusDummy" statusbar:align="center" statusbar:ownerdraw="true" statusbar:autosize="true"/> + <statusbar:statusbaritem xlink:href=".uno:ZoomSlider" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="130" statusbar:helpid="helpid:11065"/> + <statusbar:statusbaritem xlink:href=".uno:Zoom" statusbar:align="center" statusbar:width="35" statusbar:helpid="helpid:10000"/> </statusbar:statusbar> diff --git a/reportdesign/util/description.xml b/reportdesign/util/description.xml index a7f78e8b6e6a..e93c239d67d1 100644 --- a/reportdesign/util/description.xml +++ b/reportdesign/util/description.xml @@ -1,22 +1,27 @@ -<?xml version="1.0" encoding="utf-8"?>
-<description xmlns="http://openoffice.org/extensions/description/2006"
- xmlns:d="http://openoffice.org/extensions/description/2006"
- xmlns:xlink="http://www.w3.org/1999/xlink">
- <display-name>
- <name lang="en-US">Sun™ Report Builder</name>
- <!-- <name lang="en-US">Sun(TM) Report Builder</name> -->
- </display-name>
- <registration>
- <simple-license accept-by="admin" default-license-id="en-US" >
- <license-text xlink:href="licensefile" lang="isocode" license-id="lic-isocode"/>
- </simple-license>
- </registration>
- <version value="1.0.6"/>
- <identifier value="com.sun.reportdesigner"/>
- <dependencies>
- <OpenOffice.org-minimal-version value="3.0" d:name="OpenOffice.org 3.0"/>
- </dependencies>
- <publisher>
- <name xlink:href="http://www.sun.com/staroffice" lang="en">Sun Microsystems, Inc.</name>
- </publisher>
-</description>
+<?xml version="1.0" encoding="utf-8"?> +<description xmlns="http://openoffice.org/extensions/description/2006" + xmlns:d="http://openoffice.org/extensions/description/2006" + xmlns:xlink="http://www.w3.org/1999/xlink"> + <display-name> + <name lang="en-US">Sun™ Report Builder</name> + <!-- <name lang="en-US">Sun(TM) Report Builder</name> --> + </display-name> + <registration> + <simple-license accept-by="admin" default-license-id="en-US" > + <license-text xlink:href="licensefile" lang="isocode" license-id="lic-isocode"/> + </simple-license> + </registration> + <version value="#VERSION#"/> + <identifier value="com.sun.reportdesigner"/> + <dependencies> + <OpenOffice.org-minimal-version value="3.1" d:name="OpenOffice.org 3.1"/> + </dependencies> + <publisher> + <name xlink:href="http://www.sun.com/software/star/staroffice/extensions.jsp?cid=925095" lang="en">Sun Microsystems, Inc.</name> + </publisher> + <icon> + <default xlink:href="images/em42.png" /> + <high-contrast xlink:href="images/em42_hc.png" /> + </icon> +</description> + diff --git a/reportdesign/util/makefile.mk b/reportdesign/util/makefile.mk index c1b5c2fd3bac..293fb8691873 100644 --- a/reportdesign/util/makefile.mk +++ b/reportdesign/util/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.21 $ +# $Revision: 1.21.2.2 $ # # This file is part of OpenOffice.org. # @@ -37,6 +37,13 @@ TARGET2=$(TARGET)ui GEN_HID=TRUE GEN_HID_OTHER=TRUE +EXTENSION_VERSION_BASE=1.0.9 +.IF "$(PRODUCT)" != "" + EXTENSION_VERSION=$(EXTENSION_VERSION_BASE) +.ELSE + EXTENSION_VERSION=$(EXTENSION_VERSION_BASE).$(BUILD) +.ENDIF + # --- Settings ---------------------------------- .INCLUDE : makefile.pmk @@ -202,8 +209,12 @@ DEF3NAME=$(SHL3TARGET) .IF "$(SOLAR_JAVA)"!="" -XMLFILES = $(EXTENSIONDIR)$/description.xml \ - $(EXTENSIONDIR)$/META-INF$/manifest.xml +XMLFILES = $(EXTENSIONDIR)$/META-INF$/manifest.xml + +# DESCRIPTION_SRC is the source file which is copied into the extension +# It is defaulted to "descriptio.xml", but we want to pre-process it, so we use an intermediate +# file +DESCRIPTION_SRC = $(MISC)$/description.xml COMPONENT_MERGED_XCU= \ $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Setup.xcu \ @@ -223,6 +234,10 @@ COMPONENT_MERGED_XCU= \ COMPONENT_OTR_FILES= \ $(EXTENSIONDIR)$/template$/en-US$/wizard$/report$/default.otr + +COMPONENT_IMAGES= \ + $(EXTENSIONDIR)$/images$/em42.png \ + $(EXTENSIONDIR)$/images$/em42_hc.png COMPONENT_HTMLFILES = $(EXTENSIONDIR)$/THIRDPARTYREADMELICENSE.html \ $(EXTENSIONDIR)$/readme_en-US.html \ @@ -254,7 +269,7 @@ COMPONENT_MANIFEST_GENERIC:=TRUE COMPONENT_MANIFEST_SEARCHDIR:=registry # make sure to add your custom files here -EXTENSION_PACKDEPS=$(COMPONENT_EXTJARFILES) $(COMPONENT_HTMLFILES) $(COMPONENT_OTR_FILES) $(COMPONENT_HELP) +EXTENSION_PACKDEPS=$(COMPONENT_EXTJARFILES) $(COMPONENT_HTMLFILES) $(COMPONENT_OTR_FILES) $(COMPONENT_HELP) $(COMPONENT_IMAGES) # --- Targets ---------------------------------- @@ -316,6 +331,10 @@ $(EXTENSIONDIR)$/readme_en-US.% : $(PRJ)$/license$/readme_en-US.% @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ +$(EXTENSIONDIR)$/images$/%.png : $(PRJ)$/images$/%.png + @@-$(MKDIRHIER) $(@:d) + $(COPY) $< $@ + $(EXTENSIONDIR)$/THIRDPARTYREADMELICENSE.html : $(PRJ)$/license$/THIRDPARTYREADMELICENSE.html @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ @@ -324,6 +343,9 @@ $(COMPONENT_HELP) : $$(@:f) @@-$(MKDIRHIER) $(@:d) $(COPY) $< $@ +$(DESCRIPTION_SRC): description.xml + $(TYPE) description.xml | $(SED) s/#VERSION#/$(EXTENSION_VERSION)/> $@ + .ELSE # "$(SOLAR_JAVA)"!="" .INCLUDE : target.mk .ENDIF # "$(SOLAR_JAVA)"!="" |