Tag: cws_src680_odbmacros2 User: fs Date: 2008-01-24 14:11:21+0000 Modified: dba/dbaccess/source/core/dataaccess/ModelImpl.cxx
Log: #i49133# properly set the m_bReadOnly flag, so it is correct if we read from a read-only document/storage File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: ModelImpl.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.cxx?r1=1.21.2.8&r2=1.21.2.9 Delta lines: +24 -10 --------------------- --- ModelImpl.cxx 2008-01-06 21:13:01+0000 1.21.2.8 +++ ModelImpl.cxx 2008-01-24 14:11:18+0000 1.21.2.9 @@ -4,9 +4,9 @@ * * $RCSfile: ModelImpl.cxx,v $ * - * $Revision: 1.21.2.8 $ + * $Revision: 1.21.2.9 $ * - * last change: $Author: fs $ $Date: 2008/01/06 21:13:01 $ + * last change: $Author: fs $ $Date: 2008/01/24 14:11:18 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -62,7 +62,6 @@ #include <com/sun/star/sdbc/XDriverManager.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> -#include <com/sun/star/ucb/AuthenticationRequest.hpp> #include <com/sun/star/ucb/XInteractionSupplyAuthentication.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> @@ -330,7 +329,7 @@ ,m_bHasAnyObjectWithMacros( false ) ,m_aContext( _rxFactory ) ,m_nLoginTimeout(0) - ,m_bReadOnly(sal_False) // we're created as service and have to allow the setting of properties + ,m_bReadOnly(sal_False) ,m_bPasswordRequired(sal_False) ,m_bSuppressVersionColumns(sal_True) ,m_bModified(sal_False) @@ -857,13 +856,15 @@ return bStore; } + // ----------------------------------------------------------------------------- -bool ODatabaseModelImpl::commitStorageIfWriteable( const Reference< XStorage >& _rxStorage ) SAL_THROW(( IOException, WrappedTargetException, RuntimeException )) +namespace { - bool bSuccess = false; - Reference<XTransactedObject> xTrans( _rxStorage, UNO_QUERY ); - if ( xTrans.is() ) + bool lcl_storageIsWritable_nothrow( const Reference< XStorage >& _rxStorage ) { + if ( !_rxStorage.is() ) + return false; + sal_Int32 nMode = ElementModes::READ; try { @@ -873,10 +874,20 @@ } catch( const Exception& ) { - OSL_ENSURE( sal_False, "ODatabaseModelImpl::commitStorageIfWriteable: could not determine the OpenMode of the storage!" ); + DBG_UNHANDLED_EXCEPTION(); } + return ( nMode & ElementModes::WRITE ) != 0; + } +} - if ( ( 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; } @@ -1179,6 +1190,9 @@ if ( m_xDialogLibraries.is() ) m_xDialogLibraries->setRootStorage( 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(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
