Tag: odbmacros_2_5 User: fs Date: 2008-02-26 14:13:49+0000 Modified: dba/dbaccess/source/core/dataaccess/documentdefinition.cxx
Log: #i49133# support a 'Hidden' flag 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.50.2.5.2.2&r2=1.50.2.5.2.3 Delta lines: +74 -52 --------------------- --- documentdefinition.cxx 2008-02-20 14:47:36+0000 1.50.2.5.2.2 +++ documentdefinition.cxx 2008-02-26 14:13:46+0000 1.50.2.5.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: documentdefinition.cxx,v $ * - * $Revision: 1.50.2.5.2.2 $ + * $Revision: 1.50.2.5.2.3 $ * - * last change: $Author: fs $ $Date: 2008/02/20 14:47:36 $ + * last change: $Author: fs $ $Date: 2008/02/26 14:13:46 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -970,24 +970,31 @@ DBG_ERROR( "unreachable" ); } - Reference<XModel> xModel; - if ( m_pImpl->m_aProps.sPersistentName.getLength() ) - { - Sequence< PropertyValue > aLoadArgs; - aDocumentArgs >>= aLoadArgs; - loadEmbeddedObject( xConnection, Sequence< sal_Int8 >(), aLoadArgs, false, !m_bOpenInDesign ); - if ( m_xEmbeddedObject.is() ) - { - xModel.set(getComponent(),UNO_QUERY); + OSL_ENSURE( m_pImpl->m_aProps.sPersistentName.getLength(), + "ODocumentDefinition::onCommandOpenSomething: no persistent name - cannot load!" ); + if ( !m_pImpl->m_aProps.sPersistentName.getLength() ) + return; + + // embedded objects themself do not support the hidden flag. We implement support for + // it by changing the STATE to RUNNING only, instead of ACTIVE. + bool bOpenHidden = aDocumentArgs.getOrDefault( "Hidden", false ); + aDocumentArgs.remove( "Hidden" ); + + loadEmbeddedObject( xConnection, Sequence< sal_Int8 >(), aDocumentArgs.getPropertyValues(), false, !m_bOpenInDesign ); + OSL_ENSURE( m_xEmbeddedObject.is(), "ODocumentDefinition::onCommandOpenSomething: what's this?" ); + if ( !m_xEmbeddedObject.is() ) + return; + + Reference< XModel > xModel( getComponent(), UNO_QUERY ); Reference< report::XReportDefinition > xReportDefinition(xModel,UNO_QUERY); - Reference< XModule> xModule(xModel,UNO_QUERY); + Reference< XModule > xModule( xModel, UNO_QUERY ); if ( xModule.is() ) { if ( m_bForm ) - xModule->setIdentifier(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.FormDesign"))); + xModule->setIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.FormDesign" ) ) ); else if ( !xReportDefinition.is() ) - xModule->setIdentifier(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.TextReportDesign"))); + xModule->setIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.TextReportDesign" ) ) ); } bool bIsAliveNewStyleReport = ( !m_bOpenInDesign && xReportDefinition.is() ); @@ -1003,7 +1010,7 @@ return; } - if ( _bActivate ) + if ( _bActivate && !bOpenHidden ) { m_xEmbeddedObject->changeState( EmbedStates::ACTIVE ); impl_onActivateEmbeddedObject(); @@ -1011,8 +1018,6 @@ fillReportData(); _out_rComponent <<= xModel; - } - } } // ----------------------------------------------------------------------------- @@ -1027,8 +1032,15 @@ sal_Bool bOpenForMail = aCommand.Name.equalsAscii( "openForMail" ); if ( bOpen || bOpenInDesign || bOpenForMail ) { - m_bOpenInDesign = bOpenInDesign; - onCommandOpenSomething( aCommand.Argument, !bOpenForMail, Environment, aRet ); + bool bActivateObject = true; + if ( bOpenForMail ) + { + OSL_ENSURE( false, "ODocumentDefinition::execute: 'openForMail' should not be used anymore - use the 'Hidden' parameter instead!" ); + bActivateObject = false; + } + + m_bOpenInDesign = bOpenInDesign || bOpenForMail; + onCommandOpenSomething( aCommand.Argument, bActivateObject, Environment, aRet ); } else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "copyTo" ) ) ) { @@ -1082,7 +1094,9 @@ aIni[0] >>= sURL; onCommandInsert( sURL, Environment ); } - else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getdocumentinfo" ) ) ) + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getdocumentinfo" ) ) // compatibility + || aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "getDocumentInfo" ) ) + ) { onCommandGetDocumentInfo( aRet ); } @@ -1098,12 +1112,17 @@ dispose(); } - else if ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) + else if ( ( aCommand.Name.compareToAscii( "shutdown" ) == 0 ) // compatibility + || ( aCommand.Name.compareToAscii( "close" ) == 0 ) + ) { - bool bClose = prepareClose(); - if ( bClose && m_xEmbeddedObject.is() ) - m_xEmbeddedObject->changeState(EmbedStates::LOADED); - aRet <<= bClose; + bool bSuccess = prepareClose(); + if ( bSuccess && m_xEmbeddedObject.is() ) + { + m_xEmbeddedObject->changeState( EmbedStates::LOADED ); + bSuccess = m_xEmbeddedObject->getCurrentState() == EmbedStates::LOADED; + } + aRet <<= bSuccess; } else aRet = OContentHelper::execute(aCommand,CommandId,Environment); @@ -1814,8 +1833,8 @@ try { - // suspend the controller. Embedded objects are not allowed to rais - // own UI on their own decision, instead, this has always to be triggered + // suspend the controller. Embedded objects are not allowed to raise + // own UI at their own discretion, instead, this has always to be triggered // by the embedding component. Thus, we do the suspend call here. // #i49370# / 2005-06-09 / [EMAIL PROTECTED] @@ -1823,9 +1842,12 @@ Reference< XController > xController; if ( xModel.is() ) xController = xModel->getCurrentController(); - OSL_ENSURE( xController.is(), "ODocumentDefinition::prepareClose: no controller!" ); + + OSL_ENSURE( xController.is() || ( m_xEmbeddedObject->getCurrentState() < EmbedStates::ACTIVE ), + "ODocumentDefinition::prepareClose: no controller!" ); if ( !xController.is() ) - return sal_False; + // document has not yet been activated, i.e. has no UI, yet + return true; sal_Bool bCouldSuspend = xController->suspend( sal_True ); if ( !bCouldSuspend ) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
