User: hr Date: 05/09/23 05:06:28 Modified: /dba/dbaccess/source/core/dataaccess/ documentdefinition.cxx
Log: INTEGRATION: CWS dba201b (1.26.18); FILE MERGED 2005/09/21 07:03:07 oj 1.26.18.8: RESYNC: (1.27-1.28); FILE MERGED 2005/07/29 10:04:30 fs 1.26.18.7: #i52603# suspend(false) if suspend(true) was successful, but closing needed to be cancelled for other reasons 2005/07/26 07:51:47 fs 1.26.18.6: #i52479# execute: be more tolerant: accept OpenCommandArgument, OpenCommandArgument2, and no OpenCommandArgument at all 2005/07/11 13:37:01 fs 1.26.18.5: merging CWS dba201 into CWS dba201b 2005/07/11 07:19:16 oj 1.26.18.4: RESYNC: (1.26-1.27); FILE MERGED 2005/06/09 08:55:15 fs 1.26.18.3: #i49370# do a prepareClose/suspend when a close-command is intercepted 2005/06/08 14:48:11 fs 1.26.18.2: still #i50475#: copyTo requires to open the storage not-readonly, since the parent storage might be implicitly opened with the same permissions 2005/06/08 14:06:45 fs 1.26.18.1: #i50475# be more conservative with the readonly flag, don't switch to not-readonly if not necessary File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: documentdefinition.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.28&r2=1.29 Delta lines: +188 -142 ----------------------- --- documentdefinition.cxx 8 Sep 2005 13:30:10 -0000 1.28 +++ documentdefinition.cxx 23 Sep 2005 12:06:25 -0000 1.29 @@ -453,6 +453,7 @@ ,m_pClientHelper(NULL) ,m_bForm(_bForm) ,m_bOpenInDesign(sal_False) + ,m_bInExecute(sal_False) { DBG_CTOR(ODocumentDefinition, NULL); registerProperties(); @@ -547,11 +548,41 @@ describeProperties(aProps); return new OPropertyArrayHelper(aProps); } +class OExecuteImpl +{ + sal_Bool& m_rbSet; +public: + OExecuteImpl(sal_Bool& _rbSet) : m_rbSet(_rbSet){ m_rbSet=sal_True; } + ~OExecuteImpl(){ m_rbSet = sal_False; } +}; +// ----------------------------------------------------------------------------- +namespace +{ + bool lcl_extractOpenMode( const Any& _rValue, sal_Int32& /* [out] */ _rMode ) + { + OpenCommandArgument aOpenCommand; + if ( _rValue >>= aOpenCommand ) + _rMode = aOpenCommand.Mode; + else + { + OpenCommandArgument2 aOpenCommand; + if ( _rValue >>= aOpenCommand ) + _rMode = aOpenCommand.Mode; + else + return false; + } + return true; + } +} + // ----------------------------------------------------------------------------- Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 CommandId, const Reference< XCommandEnvironment >& Environment ) throw (Exception, CommandAbortedException, RuntimeException) { Any aRet; ::osl::MutexGuard aGuard(m_aMutex); + if ( !m_bInExecute ) + { + OExecuteImpl aExecuteGuard(m_bInExecute); sal_Bool bOpenInDesign = aCommand.Name.equalsAscii("openDesign"); sal_Bool bOpenForMail = aCommand.Name.equalsAscii("openForMail"); if ( aCommand.Name.compareToAscii( "open" ) == 0 || bOpenInDesign || bOpenForMail ) @@ -560,70 +591,43 @@ // open command for a folder content ////////////////////////////////////////////////////////////////// Reference< XConnection> xConnection; - OpenCommandArgument2 aOpenCommand; - if ( !( aCommand.Argument >>= aOpenCommand ) ) - { - sal_Bool bFound = sal_False; - Sequence< PropertyValue > aSeq; - if ( aCommand.Argument >>= aSeq ) + sal_Int32 nOpenMode = OpenMode::DOCUMENT; + + lcl_extractOpenMode( aCommand.Argument, nOpenMode ); + + Sequence< PropertyValue > aArguments; + if ( aCommand.Argument >>= aArguments ) { - const PropertyValue* pIter = aSeq.getConstArray(); - const PropertyValue* pEnd = pIter + aSeq.getLength(); + const PropertyValue* pIter = aArguments.getConstArray(); + const PropertyValue* pEnd = pIter + aArguments.getLength(); for(;pIter != pEnd;++pIter) { if ( pIter->Name == PROPERTY_ACTIVECONNECTION ) xConnection.set(pIter->Value,UNO_QUERY); - else if ( !bFound ) - bFound = ( pIter->Value >>= aOpenCommand ); - } - } - if ( !bFound ) - { - OSL_ENSURE( sal_False, "Wrong argument type!" ); - ucbhelper::cancelCommandExecution( - makeAny( IllegalArgumentException( - rtl::OUString(), - static_cast< cppu::OWeakObject * >( this ), - -1 ) ), - Environment ); - // Unreachable + else + lcl_extractOpenMode( pIter->Value, nOpenMode ); } } - sal_Bool bOpenFolder = - ( ( aOpenCommand.Mode == OpenMode::ALL ) || - ( aOpenCommand.Mode == OpenMode::FOLDERS ) || - ( aOpenCommand.Mode == OpenMode::DOCUMENTS ) ); + if ( xConnection.is() ) m_xLastKnownConnection = xConnection; - if ( bOpenFolder ) + if ( ( nOpenMode == OpenMode::ALL ) + || ( nOpenMode == OpenMode::FOLDERS ) + || ( nOpenMode == OpenMode::DOCUMENTS ) + || ( nOpenMode == OpenMode::DOCUMENT_SHARE_DENY_NONE ) + || ( nOpenMode == OpenMode::DOCUMENT_SHARE_DENY_WRITE ) + ) { - // open as folder - return result set - + // opening as folder is not supported ucbhelper::cancelCommandExecution( makeAny( UnsupportedOpenModeException( rtl::OUString(), static_cast< cppu::OWeakObject * >( this ), - sal_Int16( aOpenCommand.Mode ) ) ), - Environment ); - // Unreachable - } - else - { - // Check open mode - if ( ( aOpenCommand.Mode - == OpenMode::DOCUMENT_SHARE_DENY_NONE ) || - ( aOpenCommand.Mode - == OpenMode::DOCUMENT_SHARE_DENY_WRITE ) ) - { - // Unsupported. - ucbhelper::cancelCommandExecution( - makeAny( UnsupportedOpenModeException( - rtl::OUString(), - static_cast< cppu::OWeakObject * >( this ), - sal_Int16( aOpenCommand.Mode ) ) ), + sal_Int16( nOpenMode ) ) ), Environment ); // Unreachable + DBG_ERROR( "unreachable" ); } Reference<XModel> xModel; @@ -768,7 +772,6 @@ } } } - } else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "copyTo" ) ) ) { Sequence<Any> aIni; @@ -838,6 +841,7 @@ } else aRet = OContentHelper::execute(aCommand,CommandId,Environment); + } return aRet; } // ----------------------------------------------------------------------------- @@ -911,6 +915,8 @@ sal_Bool ODocumentDefinition::save(sal_Bool _bApprove) { // default handling: instantiate an interaction handler and let it handle the parameter request + if ( !m_bOpenInDesign ) + return sal_False; try { @@ -1302,6 +1308,48 @@ return bRet; } // ----------------------------------------------------------------------------- +bool ODocumentDefinition::prepareClose() +{ + if ( !m_xEmbeddedObject.is() ) + return true; + + try + { + // suspend the controller. Embedded objects are not allowed to rais + // own UI on their own decision, instead, this has always to be triggered + // by the embedding component. Thus, we do the suspend call here. + // #i49370# / 2005-06-09 / [EMAIL PROTECTED] + + Reference< XModel > xModel( getComponent(), UNO_QUERY ); + Reference< XController > xController; + if ( xModel.is() ) + xController = xModel->getCurrentController(); + OSL_ENSURE( xController.is(), "ODocumentDefinition::prepareClose: no controller!" ); + if ( !xController.is() ) + return sal_False; + + sal_Bool bCouldSuspend = xController->suspend( sal_True ); + if ( !bCouldSuspend ) + // controller vetoed the closing + return false; + + if ( isModified() && !save( sal_True ) ) + { + if ( bCouldSuspend ) + // revert suspension + xController->suspend( sal_False ); + // saving failed or was cancelled + return false; + } + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "ODocumentDefinition::prepareClose: caught an exception!" ); + } + + return true; +} +// ----------------------------------------------------------------------------- void ODocumentDefinition::setModelReadOnly(sal_Bool _bReadOnly) { Reference<XModel> xModel(getComponent(),UNO_QUERY); @@ -1322,7 +1370,6 @@ { if ( !m_bForm && _bFill && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign ) // open a report in alive mode, so we need to fill it { - // setModelReadOnly(sal_False); Sequence<Any> aArgs(2); PropertyValue aValue; aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TextDocument")); @@ -1335,7 +1382,6 @@ Reference< XJobExecutor > xExecuteable(m_xORB->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.wizards.report.CallReportWizard")),aArgs),UNO_QUERY); if ( xExecuteable.is() ) xExecuteable->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fill"))); -// setModelReadOnly(sal_True); } } // ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
